index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <view style="padding: 24rpx 20rpx;">
  3. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  4. <view class="storebox" v-for="(item,index) in dataList" :key="index">
  5. <image class="logo" :src="item.store.logoUrl" mode="aspectFill"></image>
  6. <view class="storebox-r">
  7. <view class="x-bc" style="flex: 1;min-height: 104rpx;">
  8. <view class="" @click="goStoreDetail">
  9. <view class="storename ellipsis">{{item.store.storeName || 's---'}}</view>
  10. <view class="storedesc">24小时营业 月售{{item.store.salesCount|| 0}}</view>
  11. </view>
  12. <view class="storebox-btn" @click="navTo(item)">进店</u-icon></view>
  13. </view>
  14. <scroll-view :scroll-x="true" class="scrollView">
  15. <view class="scrollItem" v-for="(it,i) in item.recommendProductList" :key="i" @click="showDetail(it)">
  16. <image :src="it.image" mode="aspectFill"></image>
  17. <view style="padding: 8rpx;">
  18. <view class="ellipsis" style="white-space: normal;">{{ it.productName || '' }}</view>
  19. <view class="price-box">
  20. <text class="price-box-unit">¥</text>
  21. <text class="price-box-integer">{{splitPrice(it.price || 0).intPart}}</text>
  22. <text class="price-box-decimal">.{{splitPrice(it.price || 0).decPart}}</text>
  23. </view>
  24. </view>
  25. </view>
  26. </scroll-view>
  27. </view>
  28. </view>
  29. </mescroll-body>
  30. </view>
  31. </template>
  32. <script>
  33. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  34. import {recommendList} from "@/api/index.js"
  35. export default {
  36. mixins: [MescrollMixin],
  37. data() {
  38. return {
  39. storeId:'',
  40. list:[],
  41. storeInfo: {},
  42. item: {
  43. productName:'口服液 口服液口服液口服液口服液12',
  44. price: 12.3
  45. },
  46. mescroll:null,
  47. downOption: { //下拉刷新
  48. use:true,
  49. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  50. },
  51. upOption: {
  52. onScroll:false,
  53. use: true, // 是否启用上拉加载; 默认true
  54. page: {
  55. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  56. size: 10 // 每页数据的数量,默认10
  57. },
  58. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  59. textNoMore:"已经到底了",
  60. empty: {
  61. icon:'https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/empty_icon.png',
  62. tip: '暂无数据'
  63. }
  64. },
  65. dataList: []
  66. }
  67. },
  68. onLoad() {
  69. },
  70. methods: {
  71. // 查看详情
  72. showDetail(item) {
  73. uni.navigateTo({
  74. url: '/pages_shopping/productDetails?productId='+item.productId + `${item.storeId ? '&storeId='+item.storeId : ''}`
  75. })
  76. },
  77. splitPrice(num) {
  78. const [intPart = '0', decPart = '00'] = String(num ||0).split('.');
  79. return { intPart, decPart: decPart.padEnd(2, '0').slice(0, 2) };
  80. },
  81. navTo(item) {
  82. uni.navigateTo({
  83. url: '/pages_store/storeIndex?storeId='+item.store.storeId
  84. })
  85. },
  86. mescrollInit(mescroll) {
  87. this.mescroll = mescroll;
  88. },
  89. /*下拉刷新的回调 */
  90. downCallback(mescroll) {
  91. mescroll.resetUpScroll()
  92. },
  93. upCallback(page) {
  94. //联网加载数据
  95. var that = this;
  96. var data = {
  97. pageNum: page.num,
  98. pageSize: page.size
  99. };
  100. recommendList(data).then(res => {
  101. if(res.code==200){
  102. //设置列表数据
  103. let list = res.rows.map(item=>({
  104. ...item,
  105. recommendProductList: item.recommendProductList&&item.recommendProductList.length > 0 ?item.recommendProductList.splice(0,5):[]
  106. }));
  107. if (page.num == 1) {
  108. that.dataList = list
  109. } else {
  110. that.dataList = that.dataList.concat(list);
  111. }
  112. that.mescroll.endBySize(res.rows.length, res.total);
  113. }else{
  114. uni.showToast({
  115. icon:'none',
  116. title: "请求失败",
  117. });
  118. that.dataList = null;
  119. that.mescroll.endErr();
  120. }
  121. });
  122. },
  123. }
  124. }
  125. </script>
  126. <style scoped lang="scss">
  127. .scrollView {
  128. white-space: nowrap;
  129. margin-top: 10rpx;
  130. .scrollItem {
  131. display: inline-block;
  132. background-color: #f5f5f5;
  133. border-radius: 10rpx;
  134. overflow: hidden;
  135. width: 170rpx;
  136. font-size: 28rpx;
  137. margin-right: 10rpx;
  138. image {
  139. height: 170rpx;
  140. width: 170rpx;
  141. }
  142. }
  143. }
  144. .price-box {
  145. font-family: Roboto, Roboto;
  146. font-weight: bold;
  147. font-size: 28rpx;
  148. color: #FF5C03;
  149. margin-top: 6rpx;
  150. &-unit {
  151. font-weight: 600;
  152. font-size: 22rpx;
  153. }
  154. &-decimal {
  155. font-weight: 600;
  156. font-size: 22rpx;
  157. }
  158. &-text {
  159. font-family: PingFang SC, PingFang SC;
  160. font-weight: 500;
  161. font-size: 22rpx;
  162. }
  163. }
  164. .storebox {
  165. background-color: #fff;
  166. padding: 20rpx;
  167. font-family: PingFang SC;
  168. color: #333333;
  169. border-radius: 16rpx 16rpx 16rpx 16rpx;
  170. overflow: hidden;
  171. display: flex;
  172. align-items: flex-start;
  173. margin-bottom: 24rpx;
  174. .logo {
  175. flex-shrink: 0;
  176. width: 104rpx;
  177. height: 104rpx;
  178. background: #fff;
  179. border-radius: 16rpx 16rpx 16rpx 16rpx;
  180. border: 1rpx solid #eee;
  181. margin-right: 16rpx;
  182. box-sizing: border-box;
  183. }
  184. .storename {
  185. font-weight: 500;
  186. font-size: 32rpx;
  187. }
  188. .storedesc {
  189. margin-top: 12rpx;
  190. font-weight: 400;
  191. font-size: 22rpx;
  192. }
  193. .storebox-r {
  194. flex: 1;
  195. overflow: hidden;
  196. }
  197. .storebox-btn {
  198. flex-shrink: 0;
  199. padding: 10rpx 24rpx;
  200. font-size: 28rpx;
  201. border-radius: 28rpx 28rpx 28rpx 28rpx;
  202. border: 2rpx solid #FF5C03;
  203. font-weight: 500;
  204. font-size: 24rpx;
  205. color: #FF5C03;
  206. }
  207. }
  208. </style>