voucher.vue 4.8 KB

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