index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <view :data-theme="theme">
  3. <scroll-view v-if="storeList.length" :scroll-y="isScroll" :style="{ height: windowHeight + 'px' }">
  4. <block :key="index" v-for="(item, index) in storeList">
  5. <view @click="goStore(item.merId)" :data-index="index" class="order-item" @touchstart="drawStart" @touchmove="drawMove"
  6. @touchend="drawEnd" :style="{ right: item.right + 'rpx'}">
  7. <view class="content">
  8. <!-- #ifdef MP -->
  9. <image :src="item.merAvatar" mode=""></image>
  10. <!-- #endif -->
  11. <!-- #ifdef H5 || APP-PLUS -->
  12. <easy-loadimage mode="widthFix" :image-src="item.merAvatar"></easy-loadimage>
  13. <!-- #endif -->
  14. <view class="info">
  15. <view class="info_head">
  16. <span class="self" v-if="item.isSelf === true">自营</span>
  17. <text class="name line1">{{item.merName}}</text>
  18. </view>
  19. <view class="collection">
  20. {{item.collectNum}}人关注
  21. </view>
  22. </view>
  23. </view>
  24. <view class="remove" @click.stop="bindDetele(item.merId, index)">取消关注</view>
  25. </view>
  26. </block>
  27. </scroll-view>
  28. <view class='noCommodity' v-if="!storeList.length && page > 1 &&!loading" >
  29. <view class='pictrue mb30'>
  30. <image :src="urlDomain+'crmebimage/presets/noguanzhu.png'"></image>
  31. <view class="text-ccc">收藏列表为空哦~</view>
  32. </view>
  33. <recommend ref="recommendIndex"></recommend>
  34. </view>
  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>
  39. </template>
  40. <script>
  41. // +----------------------------------------------------------------------
  42. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  43. // +----------------------------------------------------------------------
  44. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  45. // +----------------------------------------------------------------------
  46. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  47. // +----------------------------------------------------------------------
  48. // | Author: CRMEB Team <admin@crmeb.com>
  49. // +----------------------------------------------------------------------
  50. let app = getApp();
  51. import { getMerCollectListApi, getMerCollectCancelApi } from '@/api/merchant.js'
  52. import easyLoadimage from '@/components/base/easy-loadimage.vue';
  53. import recommend from "@/components/base/recommend.vue";
  54. export default {
  55. data() {
  56. return {
  57. urlDomain: this.$Cache.get("imgHost"),
  58. delBtnWidth: 160,
  59. storeList: [],
  60. isScroll: true,
  61. theme:app.globalData.theme,
  62. windowHeight: 0,
  63. page:1,
  64. limit:20,
  65. loading: true,
  66. loadTitle:''
  67. };
  68. },
  69. components: {
  70. easyLoadimage,
  71. recommend
  72. },
  73. onLoad: function(options) {
  74. var that = this;
  75. wx.getSystemInfo({
  76. success: function(res) {
  77. that.windowHeight = res.windowHeight -41;
  78. }
  79. });
  80. uni.setNavigationBarTitle({
  81. title: '店铺收藏'
  82. })
  83. this.getList()
  84. },
  85. methods: {
  86. returns: function() {
  87. uni.navigateBack()
  88. },
  89. drawStart: function(e) {
  90. var touch = e.touches[0];
  91. for (var index in this.storeList) {
  92. this.storeList[index].right = 0;
  93. }
  94. this.startX = touch.clientX;
  95. },
  96. drawMove: function(e) {
  97. var touch = e.touches[0];
  98. var item = this.storeList[e.currentTarget.dataset.index];
  99. var disX = this.startX - touch.clientX;
  100. if (disX >= 20) {
  101. if (disX > this.delBtnWidth) {
  102. disX = this.delBtnWidth;
  103. }
  104. this.isScroll = false;
  105. this.storeList[e.currentTarget.dataset.index].right = disX;
  106. } else {
  107. this.isScroll = true;
  108. this.storeList[e.currentTarget.dataset.index].right = 0;
  109. }
  110. },
  111. drawEnd: function(e) {
  112. var item = this.storeList[e.currentTarget.dataset.index];
  113. if (item.right >= this.delBtnWidth / 2) {
  114. this.isScroll = true;
  115. this.storeList[e.currentTarget.dataset.index].right = this.delBtnWidth;
  116. } else {
  117. this.isScroll = true;
  118. this.storeList[e.currentTarget.dataset.index].right = 0;
  119. }
  120. },
  121. goStore(id){
  122. uni.navigateTo({
  123. url:`/pages/merchant/home/index?merId=${id}`
  124. })
  125. },
  126. getList(){
  127. if(!this.isScroll) return
  128. this.loading = true;
  129. this.loadTitle = "";
  130. getMerCollectListApi({
  131. page:this.page,
  132. limit:this.limit
  133. }).then(res=>{
  134. this.isScroll = res.data.list.length>=this.limit
  135. let loadend = res.data.list.length < this.limit;
  136. this.storeList = this.storeList.concat(res.data.list)
  137. this.loadend = loadend;
  138. this.loadTitle = this.storeList.length===0 ? '' : loadend ? '我也是有底线的' : '显示更多';
  139. this.page+=1
  140. this.loading = false;
  141. }).catch(res => {
  142. this.loading = false;
  143. return this.$util.Tips({
  144. title: res
  145. });
  146. });
  147. },
  148. // 删除收藏
  149. bindDetele(id, index){
  150. getMerCollectCancelApi(id).then(res=>{
  151. uni.showToast({
  152. title: '取消成功',
  153. icon:'none'
  154. })
  155. this.storeList.splice(index,1)
  156. })
  157. }
  158. },
  159. onReachBottom() {
  160. this.getList();
  161. if(!this.storeList.length && this.page > 1){
  162. this.$refs.recommendIndex.get_host_product();
  163. }
  164. },
  165. // 滚动监听
  166. onPageScroll(e) {
  167. // 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
  168. uni.$emit('scroll');
  169. }
  170. }
  171. </script>
  172. <style lang="scss" scoped>
  173. .order-item {
  174. height: 180rpx;
  175. width: 92%;
  176. display: flex;
  177. position: relative;
  178. transition: all 0.2s;
  179. margin-bottom: 50rpx;
  180. margin: 20rpx 4%;
  181. border-radius: 16rpx;
  182. background: #fff url('../static/images/storeBg.png') no-repeat;
  183. background-size: 100% 100%;
  184. }
  185. .remove {
  186. width: 130rpx;
  187. height: 100%;
  188. @include main_bg_color(theme);;
  189. color: white;
  190. position: absolute;
  191. top: 0;
  192. right: -160rpx;
  193. display: flex;
  194. justify-content: center;
  195. align-items: center;
  196. z-index: 99;
  197. border-radius: 14rpx;
  198. margin-left: 15rpx;
  199. }
  200. .content{
  201. position: relative;
  202. display: flex;
  203. padding: 30rpx 24rpx;
  204. align-items: center;
  205. image,.easy-loadimage,image,uni-image{
  206. width: 100rpx;
  207. height: 100rpx;
  208. overflow: hidden;
  209. border-radius: 14rpx;
  210. }
  211. .info{
  212. flex: 1;
  213. display: flex;
  214. flex-direction: column;
  215. justify-content: space-between;
  216. margin-left: 20rpx;
  217. position: relative;
  218. .name{
  219. width: 410rpx;
  220. font-weight: bold;
  221. }
  222. }
  223. }
  224. .info_head {
  225. .self{
  226. padding: 2rpx 6rpx;
  227. background: #E93323;
  228. color: #fff;
  229. border-radius: 3rpx;
  230. margin-right: 10rpx;
  231. font-size: 18rpx;
  232. }
  233. }
  234. .collection {
  235. margin-top: 14rpx;
  236. font-size: 22rpx;
  237. color: #666666;
  238. }
  239. </style>