myCollect.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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="true">
  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. console.log(item);
  80. },
  81. goshop(item) {
  82. let store_id = item.store_id;
  83. let id = item.fav_id;
  84. uni.navigateTo({
  85. url: `/pages/index/shop?id=${id}&store_id=${store_id}`
  86. });
  87. },
  88. upper(e) {
  89. console.log(e)
  90. console.log("顶部")
  91. },
  92. // 滚到底部
  93. lower(e) {
  94. console.log("底部")
  95. },
  96. // 滚动时触发
  97. scroll(e) {
  98. this.old.scrollTop = e.detail.scrollTop
  99. },
  100. onChange(e) {
  101. console.log(e);
  102. this.active = e.detail.name;
  103. this.store_list = [];
  104. this.goods_list = [];
  105. this.page = 1;
  106. if(e.detail.name == 1) {
  107. this.type = 'store';
  108. }else {
  109. this.type = 'goods';
  110. }
  111. this.getlist();
  112. },
  113. getlist() {
  114. this.request({
  115. url: '/v1/favorites/get',
  116. method: 'post',
  117. scrollTop: 0,
  118. data: {
  119. type: this.type,
  120. page: this.page,
  121. page_size: this.page_size
  122. },
  123. success: (res) => {
  124. let { data } = res.data;
  125. console.log(data.goods_list);
  126. let good = data.goods_list;
  127. if(good!=0) {
  128. good.forEach((items,index) => {
  129. console.log(items);
  130. let arr = items.goods_name.split(' ');
  131. items.desarray = arr[0];
  132. items.descire = items.goods_name.replace(arr[0], '');
  133. })
  134. }
  135. this.store_list = this.store_list.concat(data.store_list);
  136. this.goods_list = this.goods_list.concat(good);
  137. }
  138. })
  139. },
  140. }
  141. }
  142. </script>
  143. <style lang="scss">
  144. .titlepadding {
  145. padding-left: 10upx;
  146. }
  147. .hotelcontent {
  148. display: flex;
  149. flex-direction: row;
  150. padding: 18upx 32upx;
  151. border-bottom: 20upx solid #F5F5F5;
  152. .contentleft {
  153. width: 200upx;
  154. height: 180upx;
  155. background-color: red;
  156. }
  157. .contentitle {
  158. padding-left: 35upx;
  159. .contentip {
  160. float: left;
  161. color: #909399;
  162. padding-top: 15upx;
  163. font-size: 24upx;
  164. }
  165. }
  166. }
  167. .van-card {
  168. background-color: #fff!important;
  169. }
  170. .priceClass {
  171. color: #303133!important;
  172. font-size: 28upx!important;
  173. font-weight: normal!important;
  174. }
  175. .desclass {
  176. color: #909399!important;
  177. font-size: 24upx;
  178. }
  179. </style>