index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. <template>
  2. <view class="collection" :style="colorStyle">
  3. <view class="nav acea-row row-center">
  4. <view class="item acea-row row-middle" :class="active == index?'on':''" v-for="(item,index) in navList" :key="index" @click="navTap(index)">{{item.name}}</view>
  5. </view>
  6. <view class="manage acea-row row-between-wrapper" v-if="collectProductList.length">
  7. <view>共 <text class="num">{{count}}</text> {{!active ? '件商品':'条视频'}}</view>
  8. <view class="close" @click="manageTap" v-if="administer">完成</view>
  9. <view @click="manageTap" v-else>管理</view>
  10. </view>
  11. <view class="collectList" v-if="collectProductList.length && !active">
  12. <view class="collectList-content">
  13. <checkbox-group @change="checkboxChange">
  14. <view class="item acea-row" v-for="(item,index) in collectProductList" :key="index" @click="goGoods(item.product_id)">
  15. <!-- #ifndef MP -->
  16. <checkbox class="checkbox" v-if="administer" :value="(item.id).toString()" :checked="item.checked" />
  17. <!-- #endif -->
  18. <!-- #ifdef MP -->
  19. <checkbox class="checkbox" v-if="administer" :value="item.id" :checked="item.checked" />
  20. <!-- #endif -->
  21. <easy-loadimage mode="widthFix" :image-src="item.image" :borderSrc="item.activity_frame.image" width="200rpx" height="200rpx" borderRadius="16rpx"></easy-loadimage>
  22. <view class="text acea-row row-column">
  23. <view class="top">
  24. <view class="name line2">{{item.store_name}}</view>
  25. <view class="flex items-end flex-wrap mt-12 w-full" v-if="item.store_label && item.store_label.length">
  26. <BaseTag
  27. :text="label.label_name"
  28. :color="label.color"
  29. :background="label.bg_color"
  30. :borderColor="label.border_color"
  31. :circle="label.border_color ? true : false"
  32. :imgSrc="label.icon"
  33. v-for="(label, idx) in item.store_label" :key="idx"></BaseTag>
  34. </view>
  35. </view>
  36. <view class="money acea-row row-bottom row-between">
  37. <view class="acea-row row-bottom">
  38. <BaseMoney :money="item.price" symbolSize="24" integerSize="40" decimalSize="24"></BaseMoney>
  39. <view class="svip acea-row" v-if="item.price_type == 'member' && item.vip_price > 0">
  40. <view class="labelCon acea-row row-middle">SVIP</view>
  41. <view class="acea-row row-middle">
  42. <BaseMoney :money="item.vip_price" symbolSize="22" integerSize="22" decimalSize="22"></BaseMoney>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="icon acea-row row-center-wrapper">
  47. <text class="iconfont icon-ic_ShoppingCart1"></text>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </checkbox-group>
  53. </view>
  54. <view class='loadingicon acea-row row-center-wrapper'>
  55. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  56. </view>
  57. <view class="footer acea-row row-between-wrapper" v-if="administer">
  58. <checkbox-group @change="checkboxAllChange">
  59. <checkbox value="all" :checked="isAllSelect" />
  60. <text class='checkAll'>全选</text>
  61. </checkbox-group>
  62. <view class="acea-row row-middle">
  63. <view class="bnt acea-row row-center-wrapper" @click="del('product')">取消收藏({{getIds().length}})</view>
  64. </view>
  65. </view>
  66. <view class="footer-placeholder" v-if="administer"></view>
  67. <view class="safe-placeholder"></view>
  68. </view>
  69. <view class="videoList" v-if="collectProductList.length && active">
  70. <view class='videoList-content'>
  71. <checkbox-group @change="checkboxChange">
  72. <view class="acea-row row-middle">
  73. <view class="item" v-for="(item,index) in collectProductList" :key="index" @click="goVideo(item.video_id)">
  74. <!-- #ifndef MP -->
  75. <checkbox class="checkbox" v-if="administer" :value="(item.id).toString()" :checked="item.checked" />
  76. <!-- #endif -->
  77. <!-- #ifdef MP -->
  78. <checkbox class="checkbox" v-if="administer" :value="item.id" :checked="item.checked" />
  79. <!-- #endif -->
  80. <image :src="item.image" mode="aspectFill"></image>
  81. <view class="like acea-row row-bottom">
  82. <text class="iconfont icon-shipindianzan-weidian1"></text>{{item.like_num}}
  83. </view>
  84. </view>
  85. </view>
  86. </checkbox-group>
  87. </view>
  88. <view class='loadingicon acea-row row-center-wrapper'>
  89. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  90. </view>
  91. <view class="footer acea-row row-between-wrapper" v-if="administer">
  92. <checkbox-group @change="checkboxAllChange">
  93. <checkbox value="all" :checked="isAllSelect" />
  94. <text class='checkAll'>全选</text>
  95. </checkbox-group>
  96. <view class="acea-row row-middle">
  97. <view class="bnt acea-row row-center-wrapper" @click="del('video')">取消收藏({{getIds().length}})</view>
  98. </view>
  99. </view>
  100. <view class="footer-placeholder" v-if="administer"></view>
  101. <view class="safe-placeholder"></view>
  102. </view>
  103. <view class='px-20 mt-20' v-else-if="!collectProductList.length && page > 1">
  104. <emptyPage title="暂无收藏,去看点别的吧~" src="/statics/images/noCollection.gif"></emptyPage>
  105. <!-- <recommend :hostProduct="hostProduct"></recommend> -->
  106. </view>
  107. </view>
  108. </template>
  109. <script>
  110. import colors from '@/mixins/color.js';
  111. import {
  112. HTTP_REQUEST_URL
  113. } from '@/config/app';
  114. import {
  115. getCollectUserList,
  116. getProductHot,
  117. collectDel
  118. } from '@/api/store.js';
  119. import {
  120. mapGetters
  121. } from "vuex";
  122. import {
  123. toLogin
  124. } from '@/libs/login.js';
  125. import recommend from '@/components/recommend';
  126. import home from '@/components/home';
  127. import emptyPage from '@/components/emptyPage.vue';
  128. import WaterfallsFlow from '@/components/WaterfallsFlow/WaterfallsFlow.vue';
  129. export default {
  130. mixins: [colors],
  131. computed: mapGetters(['isLogin']),
  132. components: {
  133. recommend,
  134. home,
  135. emptyPage,
  136. WaterfallsFlow,
  137. },
  138. data() {
  139. return {
  140. navList: [{
  141. name: '商品'
  142. },
  143. {
  144. name: '视频'
  145. }
  146. ],
  147. active: 0,
  148. hostProduct: [],
  149. loadTitle: '加载更多',
  150. loading: false,
  151. loadend: false,
  152. collectProductList: [],
  153. limit: 20,
  154. page: 1,
  155. hotScroll: false,
  156. hotPage: 1,
  157. hotLimit: 10,
  158. imgHost: HTTP_REQUEST_URL,
  159. administer: 0,
  160. isAllSelect: false,
  161. count: 0,
  162. isShowAuth: false
  163. }
  164. },
  165. onLoad(options) {
  166. this.active = options.active || 0
  167. },
  168. onShow() {
  169. uni.removeStorageSync('form_type_cart');
  170. this.loadend = false;
  171. this.page = 1;
  172. this.collectProductList = [];
  173. this.get_host_product();
  174. if (this.isLogin) {
  175. this.get_user_collect_product(this.active ? 'video' : 'product');
  176. } else {
  177. toLogin()
  178. }
  179. },
  180. methods: {
  181. onLoadFun() {
  182. this.get_user_collect_product('product');
  183. this.isShowAuth = false;
  184. },
  185. // 授权关闭
  186. authColse: function(e) {
  187. this.isShowAuth = e
  188. },
  189. goGoods(id) {
  190. if (this.administer) return false
  191. uni.navigateTo({
  192. url: `/pages/goods_details/index?id=${id}`
  193. });
  194. },
  195. goVideo(id) {
  196. if (this.administer) return false
  197. uni.navigateTo({
  198. //#ifdef APP
  199. url: '/pages/short_video/appSwiper/index?id=' + id,
  200. //#endif
  201. //#ifndef APP
  202. url: '/pages/short_video/nvueSwiper/index?id=' + id,
  203. //#endif
  204. })
  205. },
  206. //批量获取id集合
  207. getIds(){
  208. let ids = []
  209. this.collectProductList.forEach(item=>{
  210. if(item.checked){
  211. ids.push(item.id)
  212. }
  213. })
  214. return ids
  215. },
  216. del(type) {
  217. if (!this.getIds().length) {
  218. return this.$util.Tips({
  219. title: '请选择收藏商品或视频'
  220. });
  221. }
  222. collectDel(ids, type).then(res => {
  223. this.loadend = false;
  224. this.page = 1;
  225. this.$set(this, 'collectProductList', []);
  226. this.get_user_collect_product(type);
  227. return this.$util.Tips({
  228. title: res.msg
  229. });
  230. }).catch(err => {
  231. return this.$util.Tips({
  232. title: err
  233. });
  234. })
  235. },
  236. checkboxChange(event) {
  237. let idList = event.detail.value;
  238. this.collectProductList.forEach((item) => {
  239. if (idList.indexOf(item.id + '') !== -1) {
  240. item.checked = true;
  241. } else {
  242. item.checked = false;
  243. }
  244. })
  245. if (idList.length == this.collectProductList.length) {
  246. console.log('4545');
  247. this.isAllSelect = true;
  248. } else {
  249. console.log('4444');
  250. this.isAllSelect = false;
  251. }
  252. },
  253. forGoods(val) {
  254. let that = this;
  255. if (!that.collectProductList.length) return
  256. that.collectProductList.forEach((item) => {
  257. if (val) {
  258. item.checked = true;
  259. } else {
  260. item.checked = false;
  261. }
  262. })
  263. },
  264. checkboxAllChange(event) {
  265. let value = event.detail.value;
  266. if (value.length) {
  267. this.isAllSelect = true;
  268. this.forGoods(1)
  269. } else {
  270. this.isAllSelect = false;
  271. this.forGoods(0)
  272. }
  273. },
  274. manageTap() {
  275. this.administer = !this.administer;
  276. },
  277. navTap(index) {
  278. this.active = index;
  279. let type = 'product'
  280. if (index) {
  281. type = 'video'
  282. } else {
  283. type = 'product'
  284. }
  285. this.isAllSelect = false;
  286. this.forGoods(0);
  287. this.loadend = false;
  288. this.page = 1;
  289. this.$set(this, 'collectProductList', []);
  290. this.get_user_collect_product(type);
  291. },
  292. /**
  293. * 获取收藏产品
  294. */
  295. get_user_collect_product: function(type) {
  296. let that = this;
  297. if (this.loading) return;
  298. if (this.loadend) return;
  299. that.loading = true;
  300. that.loadTitle = "";
  301. getCollectUserList({
  302. page: that.page,
  303. limit: that.limit,
  304. category: type
  305. }).then(res => {
  306. let collectProductList = res.data.list;
  307. collectProductList.forEach(item => {
  308. item.checked = false;
  309. })
  310. this.count = res.data.count;
  311. let loadend = collectProductList.length < that.limit;
  312. that.collectProductList = that.$util.SplitArray(collectProductList, that.collectProductList);
  313. that.$set(that, 'collectProductList', that.collectProductList);
  314. that.loadend = loadend;
  315. that.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
  316. that.page = that.page + 1;
  317. that.loading = false;
  318. }).catch(err => {
  319. that.loading = false;
  320. that.loadTitle = "加载更多";
  321. });
  322. },
  323. /**
  324. * 获取我的推荐
  325. */
  326. get_host_product: function() {
  327. let that = this;
  328. if (that.hotScroll) return
  329. getProductHot(
  330. that.hotPage,
  331. that.hotLimit,
  332. ).then(res => {
  333. that.hotPage++
  334. that.hotScroll = res.data.length < that.hotLimit
  335. that.hostProduct = that.hostProduct.concat(res.data)
  336. });
  337. }
  338. },
  339. onPageScroll(e) {
  340. uni.$emit('scroll');
  341. },
  342. onReachBottom() {
  343. if (this.collectProductList.length) {
  344. this.get_user_collect_product('product');
  345. } else {
  346. // this.get_host_product();
  347. }
  348. }
  349. }
  350. </script>
  351. <style lang="scss">
  352. .collection {
  353. .nav {
  354. background-color: #fff;
  355. height: 80rpx;
  356. .item {
  357. margin: 0 101rpx;
  358. font-weight: 400;
  359. color: #333333;
  360. font-size: 28rpx;
  361. position: relative;
  362. &.on {
  363. font-weight: 500;
  364. font-size: 30rpx;
  365. color: var(--view-theme);
  366. &:before {
  367. content: '';
  368. position: absolute;
  369. width: 64rpx;
  370. height: 6rpx;
  371. background: var(--view-theme);
  372. bottom: 0;
  373. }
  374. }
  375. }
  376. }
  377. .manage {
  378. margin-top: 20rpx;
  379. padding: 32rpx 24rpx 0;
  380. border-radius: 24rpx 24rpx 0 0;
  381. font-weight: 400;
  382. color: #333333;
  383. font-size: 28rpx;
  384. line-height: 40rpx;
  385. background-color: #fff;
  386. .close {
  387. color: #999999;
  388. }
  389. .num {
  390. color: var(--view-theme);
  391. margin: 0 5rpx;
  392. }
  393. }
  394. .collectList {
  395. .collectList-content {
  396. padding: 8rpx 0;
  397. border-radius: 0 0 24rpx 24rpx;
  398. background-color: #FFFFFF;
  399. }
  400. .item {
  401. position: relative;
  402. padding: 24rpx;
  403. .checkbox {
  404. align-self: center;
  405. margin-right: 20rpx;
  406. }
  407. /deep/checkbox .uni-checkbox-input {
  408. margin-right: 0;
  409. }
  410. .text {
  411. flex: 1;
  412. padding-left: 20rpx;
  413. .top {
  414. flex: 1;
  415. }
  416. .name {
  417. font-weight: 400;
  418. color: #333333;
  419. font-size: 28rpx;
  420. line-height: 40rpx;
  421. }
  422. .label {
  423. margin-top: 16rpx;
  424. .labelCon {
  425. height: 26rpx;
  426. border: 1px solid var(--view-theme);
  427. padding: 0 5rpx;
  428. color: var(--view-theme);
  429. font-weight: 400;
  430. font-size: 18rpx;
  431. line-height: 1;
  432. border-radius: 4rpx;
  433. }
  434. }
  435. .money {
  436. font-size: 24rpx;
  437. font-weight: 600;
  438. color: var(--view-theme);
  439. .num {
  440. font-size: 30rpx;
  441. }
  442. .svip {
  443. height: 26rpx;
  444. padding-right: 6rpx;
  445. border-radius: 13rpx;
  446. margin: 0 0 6rpx 8rpx;
  447. background-color: #FFF0D1;
  448. line-height: 1;
  449. }
  450. .labelCon {
  451. padding: 0 6rpx;
  452. border-radius: 13rpx 0 13rpx 13rpx;
  453. margin-right: 6rpx;
  454. background: linear-gradient(90deg, #484643 0%, #1F1B17 100%);
  455. font-weight: 600;
  456. font-size: 18rpx;
  457. color: #FDDAA4;
  458. }
  459. .icon {
  460. width: 48rpx;
  461. height: 48rpx;
  462. border-radius: 24rpx;
  463. background-color: #F5F5F5;
  464. }
  465. .iconfont {
  466. font-size: 30rpx;
  467. color: #333333;
  468. }
  469. }
  470. }
  471. }
  472. }
  473. .videoList {
  474. // padding: 0 4rpx 100rpx 4rpx;
  475. .videoList-content {
  476. // padding: 0 4rpx 100rpx 4rpx;
  477. padding: 8rpx 0;
  478. border-radius: 0 0 24rpx 24rpx;
  479. background-color: #FFFFFF;
  480. }
  481. .item {
  482. width: 226rpx;
  483. height: 300rpx;
  484. border-radius: 8rpx;
  485. position: relative;
  486. margin-left: 16rpx;
  487. margin-top: 20rpx;
  488. position: relative;
  489. overflow: hidden;
  490. image {
  491. width: 100%;
  492. height: 100%;
  493. }
  494. .checkbox {
  495. position: absolute;
  496. top: 10rpx;
  497. left: 10rpx;
  498. z-index: 9;
  499. }
  500. /deep/checkbox .uni-checkbox-input {
  501. margin-right: 0;
  502. background-color: rgba(0, 0, 0, 0.16);
  503. }
  504. /deep/checkbox .wx-checkbox-input {
  505. background-color: rgba(0, 0, 0, 0.16);
  506. }
  507. .like {
  508. position: absolute;
  509. color: #fff;
  510. bottom: 0;
  511. font-weight: 400;
  512. font-size: 20rpx;
  513. left: 0;
  514. width: 226rpx;
  515. height: 100rpx;
  516. background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, rgba(0, 0, 0, 0.25) 100%);
  517. border-radius: 0 0 8rpx 8rpx;
  518. padding: 0 0 14rpx 14rpx;
  519. .iconfont {
  520. font-size: 24rpx;
  521. margin-right: 6rpx;
  522. }
  523. }
  524. }
  525. }
  526. .safe-placeholder {
  527. height: constant(safe-area-inset-bottom);
  528. height: env(safe-area-inset-bottom);
  529. }
  530. .footer-placeholder {
  531. height: 96rpx;
  532. }
  533. .footer {
  534. box-sizing: border-box;
  535. padding: 0 32rpx;
  536. width: 100%;
  537. height: 96rpx;
  538. background-color: #fff;
  539. position: fixed;
  540. bottom: 0;
  541. z-index: 30;
  542. height: calc(96rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  543. height: calc(96rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  544. padding-bottom: constant(safe-area-inset-bottom); ///兼容 IOS<11.2/
  545. padding-bottom: env(safe-area-inset-bottom); ///兼容 IOS>11.2/
  546. width: 100%;
  547. left: 0;
  548. .bnt {
  549. width: 186rpx;
  550. height: 64rpx;
  551. border-radius: 32rpx;
  552. color: #fff;
  553. background-color: var(--view-theme);
  554. font-weight: 500;
  555. font-size: 24rpx;
  556. }
  557. }
  558. }
  559. </style>