integral.vue 4.1 KB

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