index.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959
  1. <template>
  2. <div
  3. class='work_down_main'
  4. :class="mobile ? 'mobileMain' : ''"
  5. :style="{marginTop: mobile ? '0px !important':mainMarginTop, marginBottom: mobile ? '0px !important' : '30px !important'}">
  6. <div class="works-wrapper" v-if="!mobile">
  7. <div class="works-category">
  8. <div class="works-category-one">
  9. <div class="work-category-one-body">
  10. <a
  11. class="works-category-one-item"
  12. :class="pagination.selectedCateIdOne == '' ? 'active' : ''"
  13. href="/works/">
  14. 全部
  15. </a>
  16. <a
  17. class="works-category-one-item"
  18. :class="pagination.selectedCateIdOne == category.f_name ? 'active' : ''"
  19. v-for="(category) in categoryList"
  20. :key="`category-one-${category.category_id}`"
  21. :href="`/works/${category.f_name}/`">
  22. {{ category.name }}
  23. </a>
  24. </div>
  25. </div>
  26. <div class="works-category-two">
  27. <!-- 展开按钮 -->
  28. <img
  29. src="@/assets/img/works/expand-arrow@2x.png"
  30. alt="expand"
  31. class="works-expand-arrow"
  32. :class="categoryExpanded ? 'active' : ''"
  33. @click="handleClickExpandCategory">
  34. <!-- 全部二级分类 -->
  35. <div
  36. class="works-category-two-wrapper"
  37. :class="categoryExpanded ? 'expand' : ''"
  38. v-show="pagination.selectedCateIdOne == ''">
  39. <a
  40. class="works-category-two-item"
  41. :class="pagination.cate_id_two.indexOf(category.f_name) > -1 ? 'active' : ''"
  42. v-for="category in categoryAll"
  43. :key="`category-all-${category.category_id}`"
  44. :href="`/works/${category.f_name}/`">
  45. {{ category.name }}
  46. </a>
  47. </div>
  48. <!-- 接口返回的二级分类 -->
  49. <div
  50. class="works-category-two-wrapper"
  51. :class="categoryExpanded ? 'expand' : ''"
  52. v-for="(category) in categoryList"
  53. :key="`category-two-wrapper-${category.category_id}`"
  54. v-show="pagination.selectedCateIdOne == category.f_name">
  55. <a
  56. class="works-category-two-item"
  57. :class="pagination.cate_id_two.indexOf(categoryChild.f_name) > -1 ? 'active' : ''"
  58. v-for="categoryChild in category.child"
  59. :key="`category-two-${categoryChild.category_id}`"
  60. :href="`/works/${categoryChild.f_name}/`">
  61. {{ categoryChild.name }}
  62. </a>
  63. </div>
  64. </div>
  65. </div>
  66. <!-- 资源筛选 -->
  67. <div class="filter-wrapper">
  68. <!-- 价格排序 -->
  69. <div class="sort-content" @click="handleClickPriceSort">
  70. <img src="@/assets/img/common/filter-icon@2x.png">
  71. <span>{{ priceSortText }}</span>
  72. </div>
  73. <!-- 价格筛选 -->
  74. <div class="price-filter">
  75. <el-radio-group v-model="pagination.filter_price" @change="handlePriceFilterChange">
  76. <el-radio :label="0">全部</el-radio>
  77. <el-radio :label="1">付费</el-radio>
  78. <el-radio :label="2">免费</el-radio>
  79. </el-radio-group>
  80. </div>
  81. </div>
  82. <div class="works-list" v-if="worksList.length" v-loading="loadingWorksList">
  83. <div
  84. class="works-item"
  85. v-for="(works, index) in worksList"
  86. :key="`works-item-${index}-${works.wid}`">
  87. <a style="display:block" :href="`${baseUrl}/w/${works.wid}`" @click="cnzz('资源下载','资源商城+项目点击','图片')" target="_blank">
  88. <div class="works-detail-wrapper">
  89. <img v-if="works.image" class="works-image" :src="works.image" alt="works-image">
  90. <div class="works-detail" >
  91. <a class="works-name" @click="cnzz('资源下载','资源商城+项目点击','标题')" :href="`${baseUrl}/w/${works.wid}`">{{ works.name }}</a>
  92. <div class="works-description">{{ works.description }}</div>
  93. <div class="more-info-wrapper">
  94. <div class="price-info">
  95. <span class="works-price">{{ Number(works.price) > 0 ? '¥' + works.price : '免费' }}</span>
  96. <span class="download-count" v-if="Number(works.down_num) > 0">{{ works.down_num }}人已下载</span>
  97. <span class="file-format">{{ works.file_type }}格式</span>
  98. <span class="file-size">{{ works.file_size }}</span>
  99. </div>
  100. <div class="more-info">
  101. <img class="plus-img" src="@/assets/img/works/plus-icon@2x.png" alt="">
  102. <span class="plus-count">{{ works.plus_co }}</span>
  103. <span class="time">{{ works.update_time }}</span>
  104. </div>
  105. </div>
  106. </div>
  107. </div>
  108. </a>
  109. <!-- <a class="works-user-wrapper" :href="`${baseUrl}/wo/${works.uid}/works`">
  110. <img class="user-avatar" :src="works.icon_url" alt="avatar">
  111. <div class="username">{{ works.nickname }}</div>
  112. <div class="company">{{ works.company }} {{ works.kill_title || '' }}</div>
  113. </a> -->
  114. </div>
  115. </div>
  116. <div class="result-empty-wrapper" style="margin-top: 10px;" v-else>
  117. <img src="@/assets/img/common/empty@2x.png" alt="empty">
  118. <span>暂无搜索内容</span>
  119. </div>
  120. <div class="pagination-wrapper" v-if="pagination.total > pagination.pagesize">
  121. <el-pagination
  122. background
  123. layout="prev, pager, next"
  124. :current-page="pagination.page"
  125. :total="pagination.total"
  126. :page-size="pagination.pagesize"
  127. @current-change="handlePageChange">
  128. </el-pagination>
  129. </div>
  130. <!-- 留言 modal -->
  131. <el-dialog
  132. :visible.sync="isShowRemarkDialog"
  133. width="520px"
  134. top="10vh"
  135. class="remark-modal">
  136. <div class="remark-title" slot="title">寻找源码</div>
  137. <div class="remark-content">
  138. <el-form
  139. ref="remarkForm"
  140. :model="remarkModel"
  141. :rules="remarkRules"
  142. class="remark-form">
  143. <el-form-item label="源码描述" prop="remarkDescription">
  144. <el-input
  145. class="remark-description"
  146. type="textarea"
  147. placeholder="请输入您要寻找的源码描述"
  148. maxlength="1000"
  149. :autosize="{ minRows: 6, maxRows: 12 }"
  150. show-word-limit
  151. v-model="remarkModel.remarkDescription"></el-input>
  152. </el-form-item>
  153. <el-form-item label="联系方式" prop="remarkContact">
  154. <el-input
  155. class="remark-contact"
  156. type="input"
  157. placeholder="请输入您的手机号,方便我们找到源码后第一时间通知您"
  158. v-model="remarkModel.remarkContact"></el-input>
  159. </el-form-item>
  160. </el-form>
  161. <div class="action-wrapper">
  162. <el-button
  163. :loading="saveRemarkIsLoading"
  164. class="confirm-btn"
  165. @click="handleSaveRemark">提交</el-button>
  166. </div>
  167. </div>
  168. </el-dialog>
  169. </div>
  170. <div class="works-wrapper-mobile" v-else>
  171. <div class="works-category">
  172. <div class="works-category-one">
  173. <div class="category-scroller">
  174. <div
  175. class="works-category-one-item"
  176. :class="currentCategoryIndex === 0 ? 'active' : ''"
  177. @click="handleClickCategoryOne(0)">
  178. 全部
  179. </div>
  180. <div
  181. class="works-category-one-item"
  182. :class="currentCategoryIndex === index + 1 ? 'active' : ''"
  183. v-for="(category, index) in categoryList"
  184. :key="`category-one-${category.category_id}`"
  185. @click="handleClickCategoryOne(index + 1)">
  186. {{ category.name }}
  187. </div>
  188. </div>
  189. <!-- filter -->
  190. <div class="filter-bg"></div>
  191. <div class="filter-wrapper" @click="handleShowCategoryDrawer">
  192. <img src="@/assets/img/works/filter-icon@2x.png" alt="filter">
  193. </div>
  194. </div>
  195. <div class="works-category-two">
  196. <!-- 全部二级分类 -->
  197. <div
  198. class="works-category-two-wrapper"
  199. :class="categoryExpanded ? 'expand' : ''"
  200. v-show="currentCategoryIndex === 0">
  201. <div
  202. class="works-category-two-item"
  203. :class="pagination.cate_id_two.indexOf(category.f_name) > -1 ? 'active' : ''"
  204. v-for="category in categoryAll"
  205. :key="`category-all-${category.category_id}`"
  206. @click="handleClickCategoryTwo(category.f_name)">
  207. {{ category.name }}
  208. </div>
  209. </div>
  210. <!-- 接口返回的二级分类 -->
  211. <div
  212. class="works-category-two-wrapper"
  213. :class="categoryExpanded ? 'expand' : ''"
  214. v-for="(category, index) in categoryList"
  215. :key="`category-two-wrapper-${category.category_id}`"
  216. v-show="currentCategoryIndex === index + 1">
  217. <div
  218. class="works-category-two-item"
  219. :class="pagination.cate_id_two.indexOf(categoryChild.f_name) > -1 ? 'active' : ''"
  220. v-for="categoryChild in category.child"
  221. :key="`category-two-${categoryChild.category_id}`"
  222. @click="handleClickCategoryTwo(categoryChild.f_name)">
  223. {{ categoryChild.name }}
  224. </div>
  225. </div>
  226. </div>
  227. </div>
  228. <div class="works-list" :class="showWxHeader ? 'works-list__showWxHeader' : ''">
  229. <ul
  230. class="works-list-wrapper"
  231. v-infinite-scroll="handleLoadMoreWorks"
  232. :infinite-scroll-disabled="pagination.noMore"
  233. :infinite-scroll-immediate="false">
  234. <div
  235. class="works-item"
  236. v-for="(works, index) in worksList"
  237. :key="`works-item-${index}-${works.wid}`"
  238. @click="handleClickWorkItem(works.wid)">
  239. <img v-if="works.image" class="works-image" v-lazy="works.image" alt="works-image">
  240. <div class="works-detail" :class="works.image ? '' : 'without-img'">
  241. <div class="works-name">{{ works.name }}</div>
  242. <div class="works-description">{{ works.description }}</div>
  243. <div class="price-info">
  244. <span class="works-price">{{ Number(works.price) > 0 ? '¥' + works.price : '免费' }}</span>
  245. <span class="download-count">{{ works.down_num }}人已下载</span>
  246. </div>
  247. </div>
  248. </div>
  249. <!-- 空数据 -->
  250. <div class="result-empty-wrapper" v-if="!worksList.length && !pagination.loading">
  251. <img src="@/assets/img/common/empty@2x.png" alt="empty">
  252. <span>暂无搜索内容</span>
  253. </div>
  254. <p v-if="pagination.loading" class="works-list-tips">加载中...</p>
  255. <p v-if="worksList.length && pagination.noMore && !firstLoad" class="works-list-tips">没有更多了</p>
  256. </ul>
  257. </div>
  258. <!-- 弹出的分类选择 -->
  259. <el-drawer
  260. ref="categoryDrawer"
  261. class="category-drawer"
  262. :visible.sync="showCategoryDrawer"
  263. direction="ttb"
  264. :withHeader="false">
  265. <div class="drawer-category-one">
  266. <div
  267. class="drawer-category-one-item"
  268. :class="currentDrawerCategoryIndex === 0 ? 'active' : ''"
  269. @click="handleClickDrawerCategoryOne(0)">
  270. 全部
  271. </div>
  272. <div
  273. class="drawer-category-one-item"
  274. :class="currentDrawerCategoryIndex === index + 1 ? 'active' : ''"
  275. v-for="(category, index) in categoryList"
  276. :key="`drawer-category-one-${category.category_id}`"
  277. @click="handleClickDrawerCategoryOne(index + 1)">
  278. {{ category.name }}
  279. </div>
  280. </div>
  281. <div class="drawer-category-two">
  282. <!-- 全部二级分类 -->
  283. <div
  284. class="drawer-category-two-wrapper"
  285. v-show="currentDrawerCategoryIndex === 0">
  286. <div
  287. class="drawer-category-two-item"
  288. :class="pagination.cate_id_two.indexOf(category.category_id) > -1 ? 'active' : ''"
  289. v-for="category in categoryAll"
  290. :key="`drawer-category-all-${category.category_id}`"
  291. @click="handleClickDrawerCategoryTwo(category.category_id)">
  292. {{ category.name }}
  293. </div>
  294. </div>
  295. <!-- 接口返回的二级分类 -->
  296. <div
  297. class="drawer-category-two-wrapper"
  298. v-for="(category, index) in categoryList"
  299. :key="`drawer-category-two-wrapper-${category.category_id}`"
  300. v-show="currentDrawerCategoryIndex === index + 1">
  301. <div
  302. class="drawer-category-two-item"
  303. :class="pagination.cate_id_two.indexOf(categoryChild.category_id) > -1 ? 'active' : ''"
  304. v-for="categoryChild in category.child"
  305. :key="`drawer-category-two-${categoryChild.category_id}`"
  306. @click="handleClickDrawerCategoryTwo(categoryChild.category_id)">
  307. {{ categoryChild.name }}
  308. </div>
  309. </div>
  310. </div>
  311. </el-drawer>
  312. </div>
  313. <div class="works-aside">
  314. <div class="works-aside-body">
  315. <!-- 关键字筛选 -->
  316. <div class="search-wrapper">
  317. <div class="search-content">
  318. <el-input
  319. v-model="pagination.keywords"
  320. @keyup.enter.native="handleKeywordSearch"
  321. class="search-input"
  322. placeholder="源码搜索"></el-input>
  323. <el-button class="search-btn" @click="handleKeywordSearch">搜索</el-button>
  324. </div>
  325. <div class="search-tips">找不到想要的源码?<span @click="handleClickRemark">请留言给我们</span></div>
  326. </div>
  327. <div class="add-works-btn-wraps">
  328. <a class="add-works-btn" target="_blank" href="/otherpage/works/create">上传资源</a>
  329. <a class="add-works-btn" target="_blank" href="/workbench/works/index">我的资源</a>
  330. </div>
  331. </div>
  332. </div>
  333. </div>
  334. </template>
  335. <script>
  336. import {mapState} from "vuex";
  337. import DealSeoList from "@/components/work_down/dealSeoList"
  338. import qs from "qs"
  339. export default {
  340. data () {
  341. // 验证留言手机号
  342. var validateContact = (rule, value, callback) => {
  343. if (!value) {
  344. return callback(new Error('联系方式不能为空'))
  345. }
  346. var reg = /^[0-9-]*$/
  347. if (!reg.test(value)) {
  348. callback(new Error('联系方式只能为数字'))
  349. } else if (value.length > 15) {
  350. callback(new Error('联系方式支持填写不超过15字符'))
  351. } else {
  352. callback()
  353. }
  354. };
  355. return {
  356. baseUrl: '',
  357. // categoryAll: [],
  358. // categoryList: [],
  359. // worksList: [],
  360. currentCategoryIndex: 0,
  361. currentDrawerCategoryIndex: 0,
  362. categoryExpanded: false,
  363. firstLoad: false,
  364. loadingWorksList: false,
  365. showCategoryDrawer: false,
  366. // pagination: {
  367. // page: 1,
  368. // keywords: '',
  369. // cate_id_two: [],
  370. // // 非接口参数
  371. // pagesize: 20,
  372. // total: 0,
  373. // loading: true,
  374. // noMore: true
  375. // },
  376. isWeixinApp: true,
  377. // 寻找源码弹窗
  378. isShowRemarkDialog: false,
  379. saveRemarkIsLoading: false,
  380. remarkModel: {
  381. remarkDescription: '', // 源码描述
  382. remarkContact: '', // 联系方式
  383. },
  384. remarkRules: {
  385. remarkDescription: [
  386. { required: true, message: '源码描述不能为空', trigger: 'blur' },
  387. { min: 5, max: 1000, message: '源码描述支持填写5-1000字符', trigger: 'blur' }
  388. ],
  389. remarkContact: [
  390. { required: true, message: '联系方式不能为空', trigger: 'blur' },
  391. { validator: validateContact, trigger: 'blur' }
  392. ]
  393. }
  394. }
  395. },
  396. head() {
  397. const {
  398. title = "",
  399. keyword = "",
  400. description = "",
  401. h1 = "",
  402. canonical = "",
  403. metaLocation
  404. } = this.head || {}
  405. let obj = {
  406. title: title,
  407. meta: [{
  408. name: "keywords",
  409. content: keyword
  410. }, {
  411. name: "description",
  412. content: description
  413. }, {
  414. name: "h1",
  415. content: h1
  416. }],
  417. link: [{rel: "canonical", href: canonical}]
  418. }
  419. if (metaLocation) {
  420. obj.meta.push({name: "location", content: metaLocation})
  421. }
  422. return obj
  423. },
  424. computed: {
  425. ...mapState(["deviceType"]),
  426. showWxHeader () {
  427. return !this.deviceType.app && !this.isWeixinApp &&
  428. (this.deviceType.android || this.deviceType.ios)
  429. },
  430. mainMarginTop () {
  431. if (this.mobile && this.showWxHeader) {
  432. return '64px !important'
  433. } else if (this.mobile) {
  434. return '0px !important'
  435. } else {
  436. return '55px !important'
  437. }
  438. },
  439. priceSortText () {
  440. let text = '价格'
  441. if (this.pagination.sort == 1) {
  442. text = '从高到低'
  443. } else if (this.pagination.sort == 2) {
  444. text = '从低到高'
  445. }
  446. return text
  447. }
  448. },
  449. async asyncData ({...params}) {
  450. let dealDataObj = new DealSeoList(params)
  451. let ans = await dealDataObj.dealData()
  452. return {
  453. ...ans
  454. }
  455. },
  456. mounted () {
  457. this.baseUrl = this.$store.state.domainConfig.siteUrl
  458. this.isWeixinApp = navigator.userAgent.indexOf("miniProgram") > -1
  459. // const self = this
  460. // const getWorksCategoryPromise = this._getWorksCategory()
  461. // const getWorksListPromise = this._getWorksList()
  462. // Promise.all([getWorksCategoryPromise, getWorksListPromise]).then(([a, b]) => {
  463. // console.log(a, b)
  464. // self.firstLoad = false
  465. // })
  466. },
  467. methods: {
  468. /**
  469. * 获取作品资源分类
  470. */
  471. _getWorksCategory () {
  472. const self = this
  473. const promise = new Promise((resolve, reject) => {
  474. self.$axios.$post('/api/user_works/cate', { root_type: this.root_type }).then(res => {
  475. if (res.status === 1) {
  476. let categoryAll = []
  477. self.categoryList = res.data || []
  478. self.categoryList.forEach(category => {
  479. if (category.child && category.child.length) {
  480. category.child.forEach(categoryChild => {
  481. categoryAll.push(categoryChild)
  482. })
  483. }
  484. })
  485. self.categoryAll = categoryAll
  486. }
  487. resolve()
  488. }).catch(err => {
  489. reject(err)
  490. })
  491. })
  492. return promise
  493. },
  494. /**
  495. * 获取作品列表
  496. */
  497. _getWorksList () {
  498. const self = this
  499. if (!this.firstLoad) {
  500. this.loadingWorksList = true
  501. this.pagination.loading = true
  502. this.pagination.noMore = false
  503. }
  504. const data = {
  505. page: this.pagination.page,
  506. keywords: this.pagination.keywords,
  507. cate_id_two: this.pagination.cate_id_two.join(','),
  508. root_type: this.root_type,
  509. filter_price: this.pagination.filter_price,
  510. sort: this.pagination.sort
  511. }
  512. const promise = new Promise((resolve, reject) => {
  513. self.$axios.$post('/api/user_works/workFileList', data).then(res => {
  514. if (res.status === 1) {
  515. const worksList = res.data.list || []
  516. self.pagination.pagesize = res.data.pagesize || 20
  517. self.pagination.total = res.data.total || 0
  518. if (self.mobile) {
  519. self.worksList = self.worksList.concat(worksList)
  520. } else {
  521. self.worksList = worksList
  522. }
  523. if (self.pagination.page * self.pagination.pagesize >= self.pagination.total) {
  524. self.pagination.noMore = true
  525. } else {
  526. self.pagination.noMore = false
  527. }
  528. }
  529. resolve()
  530. }).catch(err => {
  531. reject(err)
  532. }).then(() => {
  533. self.loadingWorksList = false
  534. self.pagination.loading = false
  535. })
  536. })
  537. return promise
  538. },
  539. /**
  540. * 保存留言
  541. */
  542. _saveRemark () {
  543. const self = this
  544. this.saveRemarkIsLoading = true
  545. const data = {
  546. content: this.remarkModel.remarkDescription,
  547. phone: this.remarkModel.remarkContact
  548. }
  549. this.$axios.$post('/api/UserWorks/addRemark', data).then((res) => {
  550. if (Number(res.status) === 1) {
  551. self.$message.success('提交成功,请耐心等待')
  552. self.isShowRemarkDialog = false
  553. } else {
  554. self.$message.error(res.info)
  555. }
  556. }).then(() => {
  557. self.saveRemarkIsLoading = false
  558. })
  559. },
  560. /**
  561. * 点击一级分类
  562. */
  563. handleClickCategoryOne (id) {
  564. if (id === 0) {
  565. // 点击全部时,移除筛选分类
  566. this.currentCategoryIndex = id
  567. this.pagination.cate_id_two = []
  568. this.pagination.page = 1
  569. this.worksList = []
  570. window.scroll(0, 0)
  571. this._getWorksList()
  572. return
  573. }
  574. if (id !== this.currentCategoryIndex) {
  575. this.currentCategoryIndex = id
  576. }
  577. },
  578. /**
  579. * 点击二级分类
  580. */
  581. handleClickCategoryTwo (id) {
  582. if (this.mobile) {
  583. // 移动端单选
  584. const index = this.pagination.cate_id_two.indexOf(id)
  585. if (index > -1) {
  586. this.pagination.cate_id_two = []
  587. } else {
  588. this.pagination.cate_id_two = [id]
  589. }
  590. this.pagination.page = 1
  591. this.worksList = []
  592. window.scroll(0, 0)
  593. this._getWorksList()
  594. } else {
  595. // web 端多选
  596. const index = this.pagination.cate_id_two.indexOf(id)
  597. if (index > -1) {
  598. // 已选择,移除
  599. this.pagination.cate_id_two.splice(index, 1)
  600. } else {
  601. // 未选择,添加
  602. this.pagination.cate_id_two.push(id)
  603. }
  604. this.pagination.page = 1
  605. this._getWorksList()
  606. }
  607. },
  608. /**
  609. * 展开二级分类
  610. */
  611. handleClickExpandCategory () {
  612. this.categoryExpanded = !this.categoryExpanded
  613. },
  614. /**
  615. * 分页页码改变时
  616. */
  617. handlePageChange (val) {
  618. this.pagination.page = val
  619. this._getWorksList()
  620. // let query = {
  621. // page: val
  622. // }
  623. // if (this.root_type && Number(this.root_type) > 0) {
  624. // query.root_type = this.root_type
  625. // }
  626. // window.location.href = `${window.location.origin}${window.location.pathname}?${qs.stringify(query)}`
  627. },
  628. /**
  629. * mobile 加载更多
  630. */
  631. handleLoadMoreWorks () {
  632. if (this.pagination.loading) {
  633. return
  634. }
  635. this.pagination.page++
  636. this._getWorksList()
  637. },
  638. /**
  639. * 弹出分类选择 drawer
  640. */
  641. handleShowCategoryDrawer () {
  642. this.showCategoryDrawer = true
  643. },
  644. /**
  645. * 点击 mobile 分类 drawer 一级分类
  646. */
  647. handleClickDrawerCategoryOne (id) {
  648. if (id === 0) {
  649. this.showCategoryDrawer = false
  650. return
  651. }
  652. if (id !== this.currentDrawerCategoryIndex) {
  653. this.currentDrawerCategoryIndex = id
  654. }
  655. },
  656. /**
  657. * 点击 mobile 分类 drawer 二级分类
  658. */
  659. handleClickDrawerCategoryTwo (id) {
  660. const index = this.pagination.cate_id_two.indexOf(id)
  661. if (index > -1) {
  662. this.pagination.cate_id_two = []
  663. } else {
  664. this.pagination.cate_id_two = [id]
  665. }
  666. this.showCategoryDrawer = false
  667. this.pagination.page = 1
  668. this.worksList = []
  669. window.scroll(0, 0)
  670. this._getWorksList()
  671. },
  672. /**
  673. * 点击 mobile 每一项列表
  674. */
  675. handleClickWorkItem (wid) {
  676. if (this.deviceType.ios || this.deviceType.android) {
  677. let jumpUrl = `${this.baseUrl}/w/${wid}`
  678. location.href = `proginn://webview?url=${jumpUrl}`
  679. } else {
  680. location.href = `${this.baseUrl}/w/${wid}`
  681. }
  682. },
  683. /**
  684. * 点击上传资源时
  685. */
  686. // handleClickCreate () {
  687. // location.href = '/otherpage/works/create'
  688. // },
  689. /**
  690. * 回车、点击按钮:根据关键词搜索
  691. */
  692. handleKeywordSearch () {
  693. this.cnzz("资源下载","资源商城+搜索","");
  694. this.pagination.page = 1
  695. this._getWorksList()
  696. },
  697. /**
  698. * 点击留言时
  699. */
  700. handleClickRemark () {
  701. this.cnzz("资源下载","资源商城+留言","");
  702. if (this.remarkModel.remarkContact == '') {
  703. // 若已登录,自动填写手机号
  704. if (this.userinfo && this.userinfo.login_mobile) {
  705. this.remarkModel.remarkContact = this.userinfo.login_mobile
  706. }
  707. }
  708. this.isShowRemarkDialog = true
  709. },
  710. /**
  711. * 留言点击保存时
  712. */
  713. handleSaveRemark () {
  714. const self = this
  715. this.cnzz("资源下载","资源商城+留言保存","");
  716. this.$refs.remarkForm.validate((valid) => {
  717. if (valid) {
  718. self._saveRemark()
  719. }
  720. })
  721. },
  722. /**
  723. * 价格筛选改变时
  724. */
  725. handlePriceFilterChange () {
  726. this.pagination.page = 1
  727. this._getWorksList()
  728. },
  729. /**
  730. * 点击价格排序时
  731. */
  732. handleClickPriceSort () {
  733. if (this.pagination.sort == 0) {
  734. this.pagination.sort = 1
  735. } else if (this.pagination.sort == 1) {
  736. this.pagination.sort = 2
  737. } else if (this.pagination.sort == 2) {
  738. this.pagination.sort = 0
  739. }
  740. this.pagination.page = 1
  741. this._getWorksList()
  742. }
  743. }
  744. }
  745. </script>
  746. <style lang="scss" scoped>
  747. @import "@/assets/css/work_down/index.scss";
  748. </style>
  749. <style lang="scss" scoped>
  750. .work_down_main {
  751. display: flex;
  752. width: 100%;
  753. max-width: 1100px;
  754. margin: 0 auto;
  755. }
  756. .works-aside {
  757. position: relative;
  758. padding-left: 20px;
  759. width: 370px;
  760. .works-aside-body {
  761. position: fixed;
  762. min-height: 200px;
  763. width: 350px;
  764. .add-works-btn-wraps {
  765. padding-top: 10px;
  766. display: flex;
  767. width: 100%;
  768. }
  769. .add-works-btn {
  770. margin: 0;
  771. display: block;
  772. text-align: center;
  773. color: #308eff;
  774. background-color: white;
  775. height: 44px;
  776. line-height: 44px;
  777. width: 100%;
  778. outline: none;
  779. border-radius: 0;
  780. font-weight: normal;
  781. font-size: 14px;
  782. &:first-child {
  783. border-right: 1px solid rgba(0,0,0,0.05);
  784. }
  785. }
  786. .search-wrapper {
  787. width: 100%;
  788. height: 100%;
  789. .search-content {
  790. position: relative;
  791. display: flex;
  792. width: 100%;
  793. height: 44px;
  794. display: flex;
  795. align-items: center;
  796. .search-input {
  797. flex: 1;
  798. height: 100%;
  799. input {
  800. border-radius: 0;
  801. outline: none;
  802. border: none;
  803. height: 100%;
  804. }
  805. }
  806. .search-btn {
  807. width: 80px;
  808. height: 100%;
  809. padding: 0;
  810. border: none;
  811. background: #308eff;
  812. border-radius: 0px;
  813. text-align: center;
  814. color: #ffffff;
  815. }
  816. }
  817. .search-tips {
  818. margin-top: 10px;
  819. line-height: 18px;
  820. font-size: 13px;
  821. font-family: PingFangSC, PingFangSC-Regular;
  822. color: #999999;
  823. span {
  824. color: #308eff;
  825. cursor: pointer;
  826. }
  827. }
  828. }
  829. }
  830. }
  831. .category-drawer {
  832. .el-drawer {
  833. height: 100vh !important;
  834. .el-drawer__body {
  835. position: relative;
  836. width: 100%;
  837. display: flex;
  838. }
  839. }
  840. .drawer-category-one {
  841. width: 100px;
  842. height: 100vh;
  843. padding-bottom: 34px;
  844. background: #f4f5f9;
  845. overflow-x: hidden;
  846. overflow-y: auto;
  847. -webkit-overflow-scrolling: touch;
  848. &::-webkit-scrollbar {
  849. display: none;
  850. }
  851. .drawer-category-one-item {
  852. width: 100%;
  853. height: 50px;
  854. line-height: 50px;
  855. text-align: center;
  856. font-size: 15px;
  857. font-family: PingFangSC, PingFangSC-Medium;
  858. font-weight: 500;
  859. color: #222222;
  860. background: inherit;
  861. &.active {
  862. color: #308eff;
  863. background: #ffffff;
  864. }
  865. }
  866. }
  867. .drawer-category-two {
  868. width: calc(100% - 100px);
  869. height: 100vh;
  870. padding: 4px 10px 34px;
  871. background: #ffffff;
  872. overflow-x: hidden;
  873. overflow-y: auto;
  874. -webkit-overflow-scrolling: touch;
  875. &::-webkit-scrollbar {
  876. display: none;
  877. }
  878. .drawer-category-two-wrapper {
  879. width: 100%;
  880. display: flex;
  881. flex-wrap: wrap;
  882. .drawer-category-two-item {
  883. margin: 8px 8px 0 0;
  884. padding: 0 12px;
  885. height: 35px;
  886. line-height: 35px;
  887. background: rgba(244,245,249,.8);
  888. border-radius: 4px;
  889. // opacity: 0.8;
  890. font-size: 13px;
  891. font-family: PingFangSC, PingFangSC-Regular;
  892. font-weight: 400;
  893. color: #222222;
  894. &.active {
  895. height: 33px;
  896. line-height: 33px;
  897. border: 1px solid #308eff;
  898. background: #ffffff;
  899. font-size: 12px;
  900. font-family: PingFangSC, PingFangSC-Medium;
  901. font-weight: 500;
  902. color: #308eff;
  903. }
  904. }
  905. }
  906. }
  907. }
  908. .wx-header-custom-list {
  909. position: fixed !important;
  910. z-index: 11 !important;
  911. }
  912. .search-input {
  913. width: 100%;
  914. height: 34px;
  915. input {
  916. width: 100%;
  917. height: 34px;
  918. line-height: 34px;
  919. padding-left: 10px;
  920. padding-right: 70px;
  921. }
  922. }
  923. .remark-modal .el-dialog__body {
  924. padding-top: 15px !important;
  925. }
  926. .remark-modal .el-form-item__label {
  927. font-weight: 700;
  928. }
  929. .price-filter .el-radio {
  930. margin-right: 18px;
  931. }
  932. </style>