accessory.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view class="content">
  3. <empty v-if="loaded && goodList.length == 0"></empty>
  4. <view class="good flex" v-for="item in goodList" @click="navTo('/pages/product/product?id=' + item.id)">
  5. <view class="good-img">
  6. <image :src="item.image" mode=""></image>
  7. </view>
  8. <view class="good-info flex">
  9. <view class="good-name clamp2">
  10. {{item.store_name}}
  11. </view>
  12. <view class="good-price">
  13. <view class="old-price" v-if="item.ot_price*1 > item.price*1">
  14. <text class="old-left">¥{{item.ot_price}}</text>
  15. <image src="../../static/icon/down.png" mode="widthFix"></image>
  16. <text class="old-right">直降{{item.ot_price*1 - item.price*1}}元</text>
  17. </view>
  18. <view class="new-price flex">
  19. <view class="">
  20. ¥{{item.price}}
  21. </view>
  22. <view class="good-tip">
  23. 立即购买
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <uni-load-more :status="loadingType" v-if="!(loaded && goodList.length == 0)"></uni-load-more>
  30. </view>
  31. </template>
  32. <script>
  33. import {getProducts } from '@/api/product.js'
  34. export default {
  35. data() {
  36. return {
  37. goodList: [],
  38. page: 1,
  39. limit: 10,
  40. loadingType: 'more',
  41. loaded:false
  42. }
  43. },
  44. onLoad() {
  45. this.getGoodList()
  46. },
  47. onShow() {
  48. },
  49. onReachBottom() {
  50. this.getGoodList()
  51. },
  52. onReady() {
  53. },
  54. methods: {
  55. navTo(url) {
  56. if (url.indexOf('http') != -1) {
  57. window.location.href = url
  58. } else {
  59. uni.navigateTo({
  60. url,
  61. fail() {
  62. uni.switchTab({
  63. url
  64. })
  65. }
  66. })
  67. }
  68. },
  69. getGoodList() {
  70. let obj = this
  71. if (obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  72. return
  73. }
  74. obj.loadingType = 'loading'
  75. getProducts({
  76. page: obj.page,
  77. limit: obj.limit
  78. }).then(res => {
  79. obj.goodList = obj.goodList.concat(res.data)
  80. obj.page++
  81. if (obj.limit == res.data.length) {
  82. obj.loadingType = 'more'
  83. } else {
  84. obj.loadingType = 'noMore'
  85. }
  86. obj.loaded = true
  87. })
  88. },
  89. }
  90. }
  91. </script>
  92. <style lang="scss">
  93. .content {
  94. padding-top: 20rpx;
  95. }
  96. .good {
  97. width: 690rpx;
  98. height: 276rpx;
  99. background: #FFFFFF;
  100. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  101. border-radius: 10rpx;
  102. margin: auto;
  103. padding: 20rpx 15rpx;
  104. margin-bottom: 20rpx;
  105. &:last-of-type {
  106. margin-bottom: 0rpx;
  107. }
  108. .good-img {
  109. flex-shrink: 0;
  110. width: 236rpx;
  111. height: 236rpx;
  112. border-radius: 10rpx;
  113. margin-right: 22rpx;
  114. image {
  115. width: 236rpx;
  116. height: 236rpx;
  117. border-radius: 10rpx;
  118. }
  119. }
  120. .good-info {
  121. flex-grow: 1;
  122. height: 100%;
  123. flex-direction: column;
  124. justify-content: space-between;
  125. align-items: flex-start;
  126. .good-name {
  127. font-size: 32rpx;
  128. font-weight: bold;
  129. padding-top: 10rpx;
  130. color: #333333;
  131. }
  132. .good-price {
  133. width: 100%;
  134. image {
  135. width: 14rpx;
  136. margin: 0 6rpx 0 10rpx;
  137. }
  138. .old-price {
  139. .old-left {
  140. font-size: 26rpx;
  141. font-weight: 500;
  142. text-decoration: line-through;
  143. color: #999999;
  144. }
  145. .old-right {
  146. font-size: 24rpx;
  147. font-weight: bold;
  148. color: #B59467;
  149. }
  150. }
  151. .new-price {
  152. width: 100%;
  153. font-size: 36rpx;
  154. font-weight: bold;
  155. color: #FF4C4C;
  156. justify-content: space-between;
  157. .good-tip {
  158. width: 137rpx;
  159. height: 52rpx;
  160. background: $base-color;
  161. border-radius: 26rpx;
  162. position: relative;
  163. font-size: 26rpx;
  164. font-weight: 500;
  165. color: #FFFFFF;
  166. line-height: 52rpx;
  167. text-align: center;
  168. }
  169. }
  170. }
  171. }
  172. }
  173. </style>