classify.vue 4.9 KB

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