index.vue 37 KB

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