recommend.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. <template>
  2. <view class="recommend">
  3. <view class="re-list" v-for="b in bastList" :key="b.id">
  4. <view class="re-img">
  5. <image :src="b.image" mode=""></image>
  6. </view>
  7. <view class="re-right">
  8. <view class="re-right-top">
  9. <view class="good-name clamp2">{{b.store_name}}</view>
  10. <view class="store-name clamp">
  11. 门店:{{checkedStore.name}}
  12. </view>
  13. <text>距离:{{checkedStore.distance | des}}</text>
  14. </view>
  15. <view class="re-right-bottom">
  16. <view class="re-right-bottom-left">
  17. <text>¥{{b.price}}</text><text class="ot-price" v-if="b.ot_price*1 > b.price*1">¥{{b.ot_price}}</text>
  18. </view>
  19. <view class="re-right-bottom-right" @click="navTo('/pages/product/product?id=' + b.id + '&type=0')">
  20. 立即购买
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <uni-load-more :status="loadingType"></uni-load-more>
  26. </view>
  27. </template>
  28. <script>
  29. import { mapState, mapMutations } from 'vuex';
  30. import { groom1 } from '@/api/index.js';
  31. export default {
  32. data() {
  33. return {
  34. bastList: [],
  35. loadingType: 'more',
  36. page: 1,
  37. limit: 10,
  38. }
  39. },
  40. filters: {
  41. des(val) {
  42. let str = ''
  43. if(val) {
  44. if(val <= 1000) {
  45. str = parseInt(val) + 'm'
  46. }else {
  47. str = parseInt(val/1000) + 'km'
  48. }
  49. }
  50. return str
  51. }
  52. },
  53. onShow() {
  54. this.getRecommend()
  55. console.log(this.checkedStore)
  56. },
  57. computed: {
  58. ...mapState('user',['checkedStore'])
  59. },
  60. // 页面到底部
  61. onReachBottom() {
  62. console.log('到底')
  63. this.getRecommend()
  64. },
  65. methods: {
  66. navTo(url) {
  67. uni.navigateTo({
  68. url: url
  69. })
  70. },
  71. getRecommend() {
  72. let obj = this
  73. if(obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  74. return
  75. }
  76. obj.loadingType = 'loading'
  77. groom1({
  78. page: obj.page,
  79. limit: obj.limit
  80. }).then( ({data}) => {
  81. obj.bastList = obj.bastList.concat(data.list)
  82. console.log(data.list,'groom1')
  83. obj.page++
  84. if(data.list.length == obj.limit) {
  85. obj.loadingType = 'more'
  86. }else {
  87. obj.loadingType = 'noMore'
  88. }
  89. })
  90. }
  91. }
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .re-list {
  96. margin: 20rpx;
  97. height: 280rpx;
  98. background-color: #FFFFFF;
  99. border-radius: 8rpx;
  100. display: flex;
  101. $wi: 200rpx;
  102. .re-img {
  103. margin: auto 0;
  104. image {
  105. width: $wi;
  106. height: $wi;
  107. border-radius: 10rpx;
  108. margin: 0 25rpx;
  109. }
  110. }
  111. .re-right {
  112. height: $wi;
  113. width: 100%;
  114. margin: auto 0;
  115. font-family: PingFang-SC-Medium;
  116. position: relative;
  117. .re-right-top {
  118. color: #333333;
  119. font-size: 30rpx;
  120. .good-name {
  121. width: 380rpx;
  122. font-size: 30rpx;
  123. font-family: PingFang SC;
  124. font-weight: 500;
  125. color: #333333;
  126. }
  127. .store-name {
  128. padding-top: 10rpx;
  129. width: 300rpx;
  130. font-size: 22rpx;
  131. font-family: PingFang SC;
  132. font-weight: 500;
  133. color: #DCB876;
  134. }
  135. text {
  136. color: #DCB876;
  137. font-size: 22rpx;
  138. }
  139. }
  140. .re-right-bottom {
  141. width: 450rpx;
  142. display: flex;
  143. justify-content:space-between;
  144. position: absolute;
  145. bottom: 0;
  146. .re-right-bottom-left {
  147. height: 60rpx;
  148. line-height: 60rpx;
  149. margin: auto 0;
  150. font-size: 32rpx;
  151. color: #901B21;
  152. .ot-price {
  153. padding-left: 8rpx;
  154. font-size: 20rpx;
  155. font-family: PingFang SC;
  156. font-weight: 500;
  157. text-decoration: line-through;
  158. color: #9D9D9D;
  159. }
  160. // span {
  161. // margin-left: 5rpx;
  162. // color: #989B9F;
  163. // font-size: 15rpx;
  164. // text-decoration: line-through;
  165. // }
  166. }
  167. .re-right-bottom-right {
  168. width: 160rpx;
  169. line-height: 60rpx;
  170. background: #901b21;
  171. border-radius: 30rpx;
  172. font-size: 28rpx;
  173. font-family: PingFang SC;
  174. font-weight: 500;
  175. color: #FFFFFF;
  176. text-align: center;
  177. }
  178. }
  179. }
  180. }
  181. </style>