integral.vue 4.9 KB

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