voucher.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. <template v-if="good.ot_price - good.price > 0">
  14. <image src="../../static/icon/down.png" mode=""></image>
  15. <text class="zj">直降{{good.ot_price - good.use_max_integral}}元</text>
  16. </template>
  17. </view>
  18. <view class="integral-wrap">
  19. <image src="../../static/icon/jf.png" mode=""></image>
  20. <text class="price">{{good.price}}</text>
  21. </view>
  22. </view>
  23. <view class="btn" @click="nav(good.id)">
  24. 立即购买
  25. </view>
  26. </view>
  27. </view>
  28. <view class="jg"></view>
  29. </view>
  30. </template>
  31. <script>
  32. import { groomList } 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({}, 5)
  76. .then(({ data }) => {
  77. // 保存轮播图
  78. this.bannerImg = data.banner;
  79. // 保存商品信息
  80. this.list = data.list.map(e => {
  81. e.price = Number(e.price);
  82. e.ot_price = Number(e.ot_price);
  83. return e;
  84. });
  85. })
  86. .catch(e => {
  87. console.log(e);
  88. });
  89. },
  90. nav(id) {
  91. uni.navigateTo({
  92. url:'/pages/prefecture/detail?id=' + id
  93. })
  94. }
  95. }
  96. };
  97. </script>
  98. <style lang="scss" scoped>
  99. page {
  100. background: $page-color-base;
  101. }
  102. .jg {
  103. height: 20rpx;
  104. }
  105. .good-wrapper {
  106. width: 690rpx;
  107. height: 276rpx;
  108. justify-content: flex-start;
  109. align-items: flex-start;
  110. margin: 0 auto 20rpx;
  111. // &:last-of-type {
  112. // margin-bottom: 0;
  113. // }
  114. background: #FFFFFF;
  115. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  116. border-radius: 10rpx;
  117. padding: 20rpx 25rpx 20rpx 15rpx;
  118. .good-img {
  119. flex-shrink: 0;
  120. background-color: #eee;
  121. width: 236rpx;
  122. height: 236rpx;
  123. border-radius: 10rpx;
  124. margin-right: 20rpx;
  125. }
  126. .good-info {
  127. flex-direction: column;
  128. align-items: flex-start;
  129. width: 100%;
  130. height: 100%;
  131. position: relative;
  132. .tit {
  133. padding-top: 10rpx;
  134. padding-right: 15rpx;
  135. font-size: 32rpx;
  136. font-family: PingFang SC;
  137. font-weight: bold;
  138. }
  139. .btn {
  140. width: 137rpx;
  141. line-height: 52rpx;
  142. background: linear-gradient(0deg, #52C696 0%, #52C696 100%);
  143. border-radius: 26rpx;
  144. font-size: 26rpx;
  145. font-family: PingFang SC;
  146. font-weight: 500;
  147. text-align: center;
  148. color: #FFFFFF;
  149. position: absolute;
  150. bottom: 0;
  151. right: 0;
  152. }
  153. .price-wrap {
  154. .old-price {
  155. .old {
  156. font-size: 26rpx;
  157. font-family: PingFang SC;
  158. font-weight: 500;
  159. text-decoration: line-through;
  160. color: #999999;
  161. }
  162. image {
  163. display: inline-block;
  164. width: 14rpx;
  165. height: 20rpx;
  166. margin: 0 6rpx 0 10rpx;
  167. }
  168. .zj {
  169. font-size: 24rpx;
  170. font-family: PingFang SC;
  171. font-weight: bold;
  172. color: #B59467;
  173. }
  174. }
  175. .integral-wrap {
  176. display: flex;
  177. justify-content: flex-start;
  178. padding-top: 14rpx;
  179. image {
  180. width: 40rpx;
  181. height: 40rpx;
  182. margin-right: 8rpx;
  183. }
  184. .price {
  185. font-size: 36rpx;
  186. font-family: PingFang SC;
  187. font-weight: bold;
  188. color: #FF6F0F;
  189. line-height: 40rpx;
  190. }
  191. }
  192. }
  193. }
  194. }
  195. </style>