list.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view>
  3. <scroll-view class="home-goods" scroll-y scroll-with-animation @scrolltoupper="scrolltoupper" @scrolltolower="scrolltolower" upper-threshold="80">
  4. <view class="goods-list">
  5. <view class="list-item" v-for="(item,index) in goodsData" :key="index" @click="toDetail(item.goods_id)">
  6. <view class="image">
  7. <image :src="item.image_list[0].url"></image>
  8. <text>{{$dialog.disFormat(item.price,item.line_price)}}折</text>
  9. </view>
  10. <view class="info">
  11. <view class="title" v-if="item.is_new==1">{{item.price}}元代{{item.line_price}}元商场权益券{{item.product_name}}</view>
  12. <view class="title" v-else>{{item.product_name}}</view>
  13. <view class="tags"></view>
  14. <view class="tags">已售{{item.sale_stock}}</view>
  15. <view class="price-btn">
  16. <view class="price">{{$dialog.formatMoney(item.price)}}</view>
  17. <view class="price-line">{{$dialog.formatMoney(item.line_price)}}</view>
  18. <view class="buy-btn">立即抢购</view>
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </scroll-view>
  24. </view>
  25. </template>
  26. <script>
  27. var app;
  28. export default {
  29. data() {
  30. return {
  31. storeId:"",
  32. goodsData:[],
  33. orderData:{
  34. size:10,
  35. page:1,
  36. loading:false,
  37. isDone:false
  38. },
  39. }
  40. },
  41. onLoad() {
  42. app = this;
  43. app.getGoods()
  44. },
  45. methods: {
  46. scrolltoupper(){},
  47. scrolltolower(e){
  48. if (app.orderData.isDone || app.goodsData.length == 0) return ;
  49. app.getGoods()
  50. },
  51. toDetail(id){
  52. uni.navigateTo({
  53. url:`/pages/goods/detail?goods=${id}`
  54. })
  55. },
  56. async getGoods(){
  57. var formData = {};
  58. const tokenPoi = uni.getStorageSync("contact");
  59. formData.store = tokenPoi.poi_id;
  60. formData.page = app.orderData.page;
  61. formData.size = app.orderData.size;
  62. var resp = await app.$api.home.goods.get(formData);
  63. if (resp.code !== 200) {
  64. return app.$dialog.showSuccess(resp.msg)
  65. }
  66. app.isLogin = true;
  67. if (resp.data.rows.length > 0) {
  68. app.orderData.page ++;
  69. app.goodsData = [...app.goodsData,...resp.data.rows];
  70. } else {
  71. app.orderData.isDone = true;
  72. }
  73. },
  74. }
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .home-goods{
  79. width: 95%;
  80. margin: 20rpx auto;
  81. .list-item{
  82. display: flex;
  83. align-items: center;
  84. gap: 20rpx;
  85. background-color: #fff;
  86. padding: 20rpx;
  87. margin-top: 20rpx;
  88. border-radius: 20rpx;
  89. .info{
  90. flex: 1 1 0%;
  91. overflow: hidden;
  92. .title{
  93. overflow: hidden;
  94. text-overflow: ellipsis;
  95. white-space: nowrap;
  96. font-size: 32rpx;
  97. color: #333;
  98. font-weight: 900;
  99. }
  100. .tags {
  101. color: #94a3b8;
  102. font-size: 24rpx;
  103. margin: 10rpx 0;
  104. }
  105. .price-btn{
  106. display: flex;
  107. align-items: center;
  108. gap: 20rpx;
  109. align-items: flex-end;
  110. .price{
  111. font-size: 30rpx;
  112. color: $main-color;
  113. font-weight: 900;
  114. }
  115. .price-line {
  116. color: #999999;font-size: 24rpx;text-decoration-line: line-through;
  117. }
  118. .buy-btn{
  119. margin-left: auto;
  120. margin-right: 0;
  121. background-color: $main-color;
  122. color: #fff;
  123. border-radius: 30rpx;
  124. font-size: 28rpx;
  125. padding: 10rpx 20rpx;
  126. }
  127. }
  128. }
  129. .image {
  130. height: 180rpx;
  131. overflow: hidden;display: flex;align-items: center;min-width: 180rpx;
  132. position: relative;
  133. text {
  134. background-color: $main-color;
  135. color: #fff;
  136. position: absolute;
  137. top: 10rpx;
  138. left: 10rpx;
  139. font-size: 24rpx;
  140. border-radius: 30rpx;
  141. padding: 10rpx 15rpx;
  142. }
  143. image {
  144. width: 180rpx;
  145. border-radius: 10upx;
  146. height: 100%;
  147. }
  148. }
  149. }
  150. .goods-title{
  151. display: flex;
  152. align-items: center;
  153. justify-content: space-between;
  154. .title-left{
  155. .name {
  156. font-size: 34rpx;
  157. color: #333;
  158. font-weight: 900;
  159. }
  160. text {
  161. color: $main-color;
  162. font-weight: 700;
  163. font-size: 24rpx;
  164. }
  165. }
  166. .title-more{
  167. display: flex;
  168. align-items: center;
  169. color: #94a3b8;
  170. font-size: 28rpx;
  171. image {
  172. width: 28rpx;
  173. height: 28rpx;
  174. }
  175. }
  176. }
  177. }
  178. </style>