tuiStoreProduct.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <view>
  3. <!-- 数据列表 -->
  4. <mescroll-body top="0" :height="scrollHeight" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  5. <view class="goods-list">
  6. <view class="item" v-for="(item,index) in dataList" :key="index" @click="showDetail(item)">
  7. <view class="img-box">
  8. <image :src="item.image" mode="aspectFill"></image>
  9. </view>
  10. <view class="info-box">
  11. <view class="title ellipsis2">{{item.productName}}</view>
  12. <view class="price-box">
  13. <view class="now">
  14. <text class="unit">¥</text>
  15. <text class="num">{{item.price.toFixed(2)}}</text>
  16. </view>
  17. <view class="old" v-show="item.price!=item.otPrice&&item.otPrice!==null&&item.otPrice!==undefined">¥{{item.otPrice.toFixed(2)}}</view>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. </mescroll-body>
  23. </view>
  24. </template>
  25. <script>
  26. import {getProducts} from '@/pages_shopping/api/product.js'
  27. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  28. export default {
  29. mixins: [MescrollMixin],
  30. props: {
  31. storeId:'',
  32. scrollHeight: 0
  33. },
  34. data() {
  35. return {
  36. form:{
  37. defaultOrder:'desc',
  38. newOrder:null,
  39. priceOrder:null,
  40. salesOrder:null,
  41. productName:"",
  42. storeId: ""
  43. },
  44. mescroll:null,
  45. // 上拉加载的配置
  46. upOption: {
  47. onScroll:true,
  48. use: true, // 是否启用上拉加载; 默认true
  49. page: {
  50. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  51. size: 10 // 每页数据的数量,默认10
  52. },
  53. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  54. empty: {
  55. icon:'https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/app/newImages/empty_icon.png',
  56. tip: '暂无数据'
  57. },
  58. textNoMore:"已经到底了",
  59. },
  60. // 列表数据
  61. dataList: [],
  62. };
  63. },
  64. watch: {
  65. storeId: {
  66. immediate: true, // 第一次也触发
  67. handler (newVal, oldVal) {
  68. console.log('msg 变了:', newVal)
  69. if(newVal) {
  70. console.log(this.mescroll)
  71. this.mescroll.resetUpScroll()
  72. }
  73. }
  74. }
  75. },
  76. methods:{
  77. mescrollInit(mescroll) {
  78. this.mescroll = mescroll;
  79. },
  80. /*下拉刷新的回调 */
  81. downCallback(mescroll) {
  82. mescroll.resetUpScroll()
  83. },
  84. upCallback(page) {
  85. //联网加载数据
  86. var that = this;
  87. const param = {
  88. page: page.num,
  89. pageSize: page.size,
  90. storeId: this.storeId
  91. }
  92. console.log("==============",'getProducts')
  93. getProducts(param).then(res => {
  94. if(res.code==200){
  95. //设置列表数据
  96. if (page.num == 1) {
  97. that.dataList = res.data.list;
  98. } else {
  99. that.dataList = that.dataList.concat(res.data.list);
  100. }
  101. that.mescroll.endBySize(res.data.list.length, res.data.total);
  102. }else{
  103. uni.showToast({
  104. icon:'none',
  105. title: "请求失败",
  106. });
  107. that.dataList = null;
  108. that.mescroll.endErr();
  109. }
  110. });
  111. },
  112. // 查看详情
  113. showDetail(item) {
  114. uni.navigateTo({
  115. url: '/pages_shopping/productDetails?productId='+item.productId + `${this.storeId ? '&storeId='+this.storeId : ''}`
  116. })
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="scss" scoped>
  122. .desc {
  123. margin-top: 12rpx;
  124. font-family: PingFang SC, PingFang SC;
  125. font-weight: 400;
  126. font-size: 24rpx;
  127. color: #939599;
  128. }
  129. .goods-list{
  130. padding: 20upx;
  131. display: flex;
  132. flex-wrap: wrap;
  133. .item{
  134. margin-right: 20rpx;
  135. margin-bottom: 20rpx;
  136. width: 345rpx;
  137. background: #FFFFFF;
  138. box-shadow: 0px 0px 10rpx 4rpx rgba(199, 199, 199, 0.22);
  139. border-radius: 20rpx;
  140. overflow: hidden;
  141. &:nth-child(2n) {
  142. margin-right: 0;
  143. }
  144. .img-box{
  145. width: 100%;
  146. height: 334upx;
  147. image{
  148. width: 100%;
  149. height: 100%;
  150. }
  151. }
  152. .info-box{
  153. box-sizing: border-box;
  154. height: 182upx;
  155. padding: 20upx 20upx 30upx;
  156. display: flex;
  157. flex-direction: column;
  158. justify-content: space-between;
  159. .title{
  160. font-size: 26upx;
  161. font-family: PingFang SC;
  162. font-weight: 500;
  163. color: #111111;
  164. line-height: 40upx;
  165. }
  166. .price-box{
  167. display: flex;
  168. align-items: flex-end;
  169. .now{
  170. display: flex;
  171. align-items: flex-end;
  172. margin-right: 20upx;
  173. .unit{
  174. font-size: 24upx;
  175. font-family: PingFang SC;
  176. font-weight: 500;
  177. color: #FF6633;
  178. line-height: 1.2;
  179. margin-right: 4upx;
  180. }
  181. .num{
  182. font-size: 36upx;
  183. font-family: PingFang SC;
  184. font-weight: bold;
  185. color: #FF6633;
  186. line-height: 1;
  187. }
  188. }
  189. .old{
  190. font-size: 26upx;
  191. font-family: PingFang SC;
  192. font-weight: 500;
  193. text-decoration: line-through;
  194. color: #BBBBBB;
  195. line-height: 1.1;
  196. }
  197. }
  198. }
  199. }
  200. }
  201. </style>