consumer.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view class="container">
  3. <view class="jg"></view>
  4. <view class="good-wrapper flex" v-for="(good ,index) in list" :key="good.id">
  5. <image :src="good.image" mode="" class="good-img"></image>
  6. <view class="good-info flex">
  7. <view class="tit clamp2">
  8. {{good.store_name }}
  9. </view>
  10. <view class="price-wrap">
  11. <view class="old-price">
  12. <text class="old">¥{{good.ot_price}}</text>
  13. <image src="../../static/icon/down.png" mode=""></image>
  14. <text class="zj">直降{{good.ot_price - good.use_max_integral}}元</text>
  15. </view>
  16. <view class="integral-wrap">
  17. <image src="../../static/icon/jf.png" mode=""></image>
  18. <text class="price">{{good.use_max_integral}}</text>
  19. </view>
  20. </view>
  21. <view class="btn">
  22. 立即购买
  23. </view>
  24. </view>
  25. </view>
  26. <view class="jg"></view>
  27. </view>
  28. </template>
  29. <script>
  30. import { groomList } from '@/api/product.js';
  31. export default {
  32. filters: {
  33. toFixed: function(value) {
  34. // 判断是否为整数
  35. if (value % 1 == 0) {
  36. return value;
  37. } else {
  38. return value.toFixed(2);
  39. }
  40. }
  41. },
  42. data() {
  43. return {
  44. list: [],
  45. bannerImg: []
  46. };
  47. },
  48. onLoad(option) {
  49. // 加载基础数据
  50. this.loadData();
  51. },
  52. methods: {
  53. //详情页
  54. navToDetailPage(item) {
  55. uni.navigateTo({
  56. url: '/pages/product/product?id=' + item.id
  57. });
  58. },
  59. // 轮播图跳转
  60. bannerNavToUrl(item) {
  61. // #ifdef H5
  62. if (item.wap_link.indexOf('http') > 0) {
  63. window.location.href = item.wap_link;
  64. }
  65. // #endif
  66. //测试数据没有写id,用title代替
  67. uni.navigateTo({
  68. url: item.wap_link
  69. });
  70. },
  71. // 请求载入数据
  72. async loadData() {
  73. groomList({}, 5)
  74. .then(({ data }) => {
  75. // 保存轮播图
  76. this.bannerImg = data.banner;
  77. // 保存商品信息
  78. this.list = data.list.map(e => {
  79. e.price = Number(e.price);
  80. e.ot_price = Number(e.ot_price);
  81. return e;
  82. });
  83. })
  84. .catch(e => {
  85. console.log(e);
  86. });
  87. }
  88. }
  89. };
  90. </script>
  91. <style lang="scss" scoped>
  92. page {
  93. background: $page-color-base;
  94. }
  95. .jg {
  96. height: 20rpx;
  97. }
  98. .good-wrapper {
  99. width: 690rpx;
  100. height: 276rpx;
  101. justify-content: flex-start;
  102. align-items: flex-start;
  103. margin: 0 auto 20rpx;
  104. // &:last-of-type {
  105. // margin-bottom: 0;
  106. // }
  107. background: #FFFFFF;
  108. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  109. border-radius: 10rpx;
  110. padding: 20rpx 25rpx 20rpx 15rpx;
  111. .good-img {
  112. flex-shrink: 0;
  113. background-color: #eee;
  114. width: 236rpx;
  115. height: 236rpx;
  116. border-radius: 10rpx;
  117. margin-right: 20rpx;
  118. }
  119. .good-info {
  120. flex-direction: column;
  121. align-items: flex-start;
  122. width: 100%;
  123. height: 100%;
  124. position: relative;
  125. .tit {
  126. padding-top: 10rpx;
  127. padding-right: 15rpx;
  128. font-size: 32rpx;
  129. font-family: PingFang SC;
  130. font-weight: bold;
  131. }
  132. .btn {
  133. width: 137rpx;
  134. line-height: 52rpx;
  135. background: linear-gradient(0deg, #52C696 0%, #52C696 100%);
  136. border-radius: 26rpx;
  137. font-size: 26rpx;
  138. font-family: PingFang SC;
  139. font-weight: 500;
  140. text-align: center;
  141. color: #FFFFFF;
  142. position: absolute;
  143. bottom: 0;
  144. right: 0;
  145. }
  146. .price-wrap {
  147. .old-price {
  148. .old {
  149. font-size: 26rpx;
  150. font-family: PingFang SC;
  151. font-weight: 500;
  152. text-decoration: line-through;
  153. color: #999999;
  154. }
  155. image {
  156. display: inline-block;
  157. width: 14rpx;
  158. height: 20rpx;
  159. margin: 0 6rpx 0 10rpx;
  160. }
  161. .zj {
  162. font-size: 24rpx;
  163. font-family: PingFang SC;
  164. font-weight: bold;
  165. color: #B59467;
  166. }
  167. }
  168. .integral-wrap {
  169. display: flex;
  170. justify-content: flex-start;
  171. padding-top: 14rpx;
  172. image {
  173. width: 40rpx;
  174. height: 40rpx;
  175. margin-right: 8rpx;
  176. }
  177. .price {
  178. font-size: 36rpx;
  179. font-family: PingFang SC;
  180. font-weight: bold;
  181. color: #FF6F0F;
  182. line-height: 40rpx;
  183. }
  184. }
  185. }
  186. }
  187. }
  188. </style>