myCollect.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view>
  3. <van-tabs :active="active" @change="onChange">
  4. <van-tab :name="1" title="酒店">
  5. </van-tab>
  6. <van-tab :name="2" title="商品">
  7. </van-tab>
  8. </van-tabs>
  9. <scroll-view style="height: 95vh;" class="floor-list"
  10. :scroll-top="scrollTop" scroll-y="true" @scroll="scroll" @scrolltoupper="upper" @scrolltolower="lower"
  11. :refresher-enabled="false">
  12. <view v-if="active == 1" @click="goitem(item)" v-for="(item,index) in store_list" :key="index">
  13. <van-cell :title="item.store_name" title-class="titlepadding">
  14. <template slot="icon">
  15. <image :src="pictureUrl+'/uploads/home/store/'+item.store_id+'/'+item.store_logo" style="border-radius: 50%;
  16. width: 50upx;height: 50upx;vertical-align: middle;"></image>
  17. </template>
  18. </van-cell>
  19. <view class="hotelcontent">
  20. <view class="contentleft">
  21. <image :src="pictureUrl+'/uploads/home/store/'+item.store_id+'/'+item.store_avatar"
  22. style="width: 100%;height: 100%;vertical-align: middle;"></image>
  23. </view>
  24. <view class="contentitle">
  25. <view>{{item.store_name}}</view>
  26. <view class="contentip">{{item.store_summary}}</view>
  27. </view>
  28. </view>
  29. </view>
  30. <view v-if="active == 2" v-for="(item,index) in goods_list" @click="goshop(item)" :key="index">
  31. <van-cell :title="item.store_name" title-class ="titlepadding">
  32. <template slot="icon">
  33. <image :src="pictureUrl+'/uploads/home/store/'+item.store_id+'/'+item.store_avatar" style="border-radius: 50%;
  34. width: 50upx;height: 50upx;vertical-align: middle;"></image>
  35. </template>
  36. </van-cell>
  37. <view style="border-bottom: 20upx solid #F5F5F5;">
  38. <van-card
  39. title-class="priceClass"
  40. desc-class="desclass"
  41. price-class ="priceClass"
  42. :price="item.favlog_price"
  43. :desc="item.descire"
  44. :title="item.desarray"
  45. :thumb="pictureUrl+'/uploads/home/store/goods/' + item.goods_image.substr(0, item.goods_image.indexOf('\_')) + '/' + item.goods_image "
  46. >
  47. </van-card>
  48. </view>
  49. </view>
  50. </scroll-view>
  51. </view>
  52. </template>
  53. <script>
  54. export default {
  55. data() {
  56. return {
  57. pictureUrl: this.pictureUrl,
  58. active: 1,
  59. type: 'store',
  60. page: 1,
  61. page_size: 10,
  62. scrollTop:0,
  63. old: {
  64. scrollTop: 0
  65. },
  66. store_list:[],
  67. goods_list:[]
  68. }
  69. },
  70. onLoad() {
  71. this.getlist();
  72. },
  73. methods: {
  74. goitem(item) {
  75. let id = item.store_id;
  76. uni.navigateTo({
  77. url: `/pages/index/hotel?id=${id}`
  78. });
  79. },
  80. goshop(item) {
  81. let store_id = item.store_id;
  82. let id = item.fav_id;
  83. uni.navigateTo({
  84. url: `/pages/index/shop?id=${id}&store_id=${store_id}`
  85. });
  86. },
  87. upper(e) {
  88. console.log(e)
  89. console.log("顶部")
  90. },
  91. // 滚到底部
  92. lower(e) {
  93. console.log("底部")
  94. },
  95. // 滚动时触发
  96. scroll(e) {
  97. this.old.scrollTop = e.detail.scrollTop
  98. },
  99. onChange(e) {
  100. console.log(e);
  101. this.active = e.detail.name;
  102. this.store_list = [];
  103. this.goods_list = [];
  104. this.page = 1;
  105. if(e.detail.name == 1) {
  106. this.type = 'store';
  107. }else {
  108. this.type = 'goods';
  109. }
  110. this.getlist();
  111. },
  112. getlist() {
  113. this.request({
  114. url: '/v1/favorites/get',
  115. method: 'post',
  116. scrollTop: 0,
  117. data: {
  118. type: this.type,
  119. page: this.page,
  120. page_size: this.page_size
  121. },
  122. success: (res) => {
  123. let { data } = res.data;
  124. console.log(data.goods_list);
  125. let good = data.goods_list;
  126. if(good!=0) {
  127. good.forEach((items,index) => {
  128. console.log(items);
  129. let arr = items.goods_name.split(' ');
  130. items.desarray = arr[0];
  131. items.descire = items.goods_name.replace(arr[0], '');
  132. })
  133. }
  134. this.store_list = this.store_list.concat(data.store_list);
  135. this.goods_list = this.goods_list.concat(good);
  136. }
  137. })
  138. },
  139. }
  140. }
  141. </script>
  142. <style lang="scss">
  143. .titlepadding {
  144. padding-left: 10upx;
  145. }
  146. .hotelcontent {
  147. display: flex;
  148. flex-direction: row;
  149. padding: 18upx 32upx;
  150. border-bottom: 20upx solid #F5F5F5;
  151. .contentleft {
  152. width: 200upx;
  153. height: 180upx;
  154. background-color: red;
  155. }
  156. .contentitle {
  157. padding-left: 35upx;
  158. .contentip {
  159. float: left;
  160. color: #909399;
  161. padding-top: 15upx;
  162. font-size: 24upx;
  163. }
  164. }
  165. }
  166. .van-card {
  167. background-color: #fff!important;
  168. }
  169. .priceClass {
  170. color: #303133!important;
  171. font-size: 28upx!important;
  172. font-weight: normal!important;
  173. }
  174. .desclass {
  175. color: #909399!important;
  176. font-size: 24upx;
  177. }
  178. </style>