integral.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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.price - good.ot_price}}元</text>
  15. </view>
  16. <view class="integral-wrap">
  17. <image src="../../static/icon/jf.png" mode=""></image>
  18. <text class="price">{{good.ot_price}}</text>
  19. </view>
  20. </view>
  21. <view class="btn" @click="nav(good.id)">
  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({}, 6)
  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. nav(id) {
  89. uni.navigateTo({
  90. url:'/pages/product/product?id=' + id
  91. })
  92. }
  93. }
  94. };
  95. </script>
  96. <style lang="scss" scoped>
  97. page {
  98. background: $page-color-base;
  99. }
  100. .jg {
  101. height: 20rpx;
  102. }
  103. .good-wrapper {
  104. width: 690rpx;
  105. height: 276rpx;
  106. justify-content: flex-start;
  107. align-items: flex-start;
  108. margin: 0 auto 20rpx;
  109. // &:last-of-type {
  110. // margin-bottom: 0;
  111. // }
  112. background: #FFFFFF;
  113. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  114. border-radius: 10rpx;
  115. padding: 20rpx 25rpx 20rpx 15rpx;
  116. .good-img {
  117. flex-shrink: 0;
  118. background-color: #eee;
  119. width: 236rpx;
  120. height: 236rpx;
  121. border-radius: 10rpx;
  122. margin-right: 20rpx;
  123. }
  124. .good-info {
  125. flex-direction: column;
  126. align-items: flex-start;
  127. width: 100%;
  128. height: 100%;
  129. position: relative;
  130. .tit {
  131. padding-top: 10rpx;
  132. padding-right: 15rpx;
  133. font-size: 32rpx;
  134. font-family: PingFang SC;
  135. font-weight: bold;
  136. }
  137. .btn {
  138. width: 137rpx;
  139. line-height: 52rpx;
  140. background: linear-gradient(0deg, #52C696 0%, #52C696 100%);
  141. border-radius: 26rpx;
  142. font-size: 26rpx;
  143. font-family: PingFang SC;
  144. font-weight: 500;
  145. text-align: center;
  146. color: #FFFFFF;
  147. position: absolute;
  148. bottom: 0;
  149. right: 0;
  150. }
  151. .price-wrap {
  152. .old-price {
  153. .old {
  154. font-size: 26rpx;
  155. font-family: PingFang SC;
  156. font-weight: 500;
  157. text-decoration: line-through;
  158. color: #999999;
  159. }
  160. image {
  161. display: inline-block;
  162. width: 14rpx;
  163. height: 20rpx;
  164. margin: 0 6rpx 0 10rpx;
  165. }
  166. .zj {
  167. font-size: 24rpx;
  168. font-family: PingFang SC;
  169. font-weight: bold;
  170. color: #B59467;
  171. }
  172. }
  173. .integral-wrap {
  174. display: flex;
  175. justify-content: flex-start;
  176. padding-top: 14rpx;
  177. image {
  178. width: 40rpx;
  179. height: 40rpx;
  180. margin-right: 8rpx;
  181. }
  182. .price {
  183. font-size: 36rpx;
  184. font-family: PingFang SC;
  185. font-weight: bold;
  186. color: #FF6F0F;
  187. line-height: 40rpx;
  188. }
  189. }
  190. }
  191. }
  192. }
  193. </style>