index.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class="user_store_attention">
  3. <view class="item" v-for="(item,index) in storeList" :key="index" @click="goStore(item)">
  4. <image :src="item.merchant.mer_avatar" mode=""></image>
  5. <view class="info">
  6. <view class="name line1">{{item.merchant.mer_name}}<text v-if="item.merchant.is_trader" class="font-bg-red ml8">自营</text></view>
  7. <view class="des">{{item.merchant.care_count || 0}}人关注</view>
  8. <view class="btn" @click.stop="bindDetele(item,index)">取消关注</view>
  9. </view>
  10. </view>
  11. <view class="empty-txt" v-if="storeList.length == 0">暂无数据</view>
  12. </view>
  13. </template>
  14. <script>
  15. let app = getApp();
  16. import { getMerchantLst,collectDel } from '@/api/store.js'
  17. export default{
  18. data(){
  19. return {
  20. storeList:[],
  21. isScroll:true,
  22. page:1,
  23. limit:20,
  24. hide_mer_status: app.globalData.hide_mer_status
  25. }
  26. },
  27. onLoad() {
  28. this.getList()
  29. },
  30. onReady(){
  31. uni.$on('update',(data)=>{
  32. this.hide_mer_status = data.hide_mer_status
  33. })
  34. },
  35. mounted: function() {
  36. const app = getApp();
  37. this.$nextTick(() => {
  38. this.hide_mer_status = app.globalData.hide_mer_status
  39. });
  40. },
  41. methods:{
  42. goStore(item){
  43. if(this.hide_mer_status != 1){
  44. uni.navigateTo({
  45. url:`/pages/store/home/index?id=${item.merchant.mer_id}`
  46. })
  47. }
  48. },
  49. getList(){
  50. if(!this.isScroll) return
  51. getMerchantLst({
  52. page:this.page,
  53. limit:this.limit
  54. }).then(res=>{
  55. this.isScroll = res.data.list.length>=this.limit
  56. this.storeList = this.storeList.concat(res.data.list)
  57. this.page+=1
  58. })
  59. },
  60. // 删除收藏
  61. bindDetele(item,index){
  62. collectDel({
  63. type:10,
  64. type_id:item.type_id
  65. }).then(res=>{
  66. uni.showToast({
  67. title:'已取消',
  68. icon:'none'
  69. })
  70. this.storeList.splice(index,1)
  71. })
  72. }
  73. },
  74. onReachBottom() {
  75. this.getList()
  76. }
  77. }
  78. </script>
  79. <style lang="scss">
  80. .user_store_attention{
  81. .item{
  82. position: relative;
  83. display: flex;
  84. padding: 30rpx 20rpx;
  85. background-color: #fff;
  86. &::after{
  87. content: ' ';
  88. position: absolute;
  89. bottom: 0;
  90. left: 30rpx;
  91. right: 0;
  92. height: 1px;
  93. background: #f0f0f0;
  94. }
  95. image{
  96. width: 88rpx;
  97. height: 88rpx;
  98. border-radius: 50%;
  99. }
  100. .info{
  101. flex: 1;
  102. display: flex;
  103. flex-direction: column;
  104. justify-content: space-between;
  105. margin-left: 20rpx;
  106. position: relative;
  107. .name{
  108. width: 410rpx;
  109. font-weight: bold;
  110. }
  111. .des{
  112. color: #666666;
  113. font-size: 22rpx;
  114. }
  115. .btn{
  116. display: flex;
  117. align-items: center;
  118. justify-content: center;
  119. position: absolute;
  120. right: 0;
  121. top: 50%;
  122. width:150rpx;
  123. height:50rpx;
  124. transform: translateY(-50%);
  125. border:1px solid #BBBBBB;
  126. border-radius:25rpx;
  127. font-size: 26rpx;
  128. }
  129. }
  130. }
  131. }
  132. </style>