index.vue 13 KB

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