index.vue 34 KB

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