classify.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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.price - good.ot_price}}元</text>
  16. </view>
  17. <view class="integral-wrap">
  18. <text class="price">¥{{good.ot_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. uni.navigateTo({
  87. url: '/pages/product/product?id=' + ls.id
  88. });
  89. },
  90. // 请求载入数据
  91. async loadData() {
  92. groomList({}, this.type)
  93. .then(({
  94. data
  95. }) => {
  96. // 保存轮播图
  97. this.bannerImg = data.banner;
  98. // 保存商品信息
  99. this.list = data.list;
  100. })
  101. .catch(e => {
  102. console.log(e);
  103. });
  104. },
  105. // 轮播图跳转
  106. bannerNavToUrl(item) {
  107. // #ifdef H5
  108. if (item.wap_link.indexOf('http') > 0) {
  109. window.location.href = item.wap_link;
  110. }
  111. // #endif
  112. if (item.wap_link) {
  113. uni.navigateTo({
  114. url: item.wap_link
  115. });
  116. }
  117. }
  118. }
  119. };
  120. </script>
  121. <style lang="scss">
  122. .cart {
  123. position: fixed;
  124. right: 30rpx;
  125. bottom: 60rpx;
  126. .cart-icon {
  127. width: 150rpx;
  128. height: 150rpx;
  129. }
  130. .text {
  131. background-color: $color-red;
  132. color: #FFF;
  133. position: absolute;
  134. top: 0;
  135. right: 0;
  136. width: 40rpx;
  137. height: 40rpx;
  138. z-index: 999;
  139. text-align: center;
  140. border-radius: 99rpx;
  141. }
  142. }
  143. page {
  144. background: $page-color-base;
  145. }
  146. .good-wrapper {
  147. width: 690rpx;
  148. height: 276rpx;
  149. justify-content: flex-start;
  150. align-items: flex-start;
  151. margin: 0 auto 20rpx;
  152. // &:last-of-type {
  153. // margin-bottom: 0;
  154. // }
  155. background: #FFFFFF;
  156. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  157. border-radius: 10rpx;
  158. padding: 20rpx 25rpx 20rpx 15rpx;
  159. .good-img {
  160. flex-shrink: 0;
  161. background-color: #eee;
  162. width: 236rpx;
  163. height: 236rpx;
  164. border-radius: 10rpx;
  165. margin-right: 20rpx;
  166. }
  167. .good-info {
  168. flex-direction: column;
  169. align-items: flex-start;
  170. width: 100%;
  171. height: 100%;
  172. position: relative;
  173. .tit {
  174. padding-top: 10rpx;
  175. padding-right: 15rpx;
  176. font-size: 32rpx;
  177. font-family: PingFang SC;
  178. font-weight: bold;
  179. }
  180. .btn {
  181. width: 137rpx;
  182. line-height: 52rpx;
  183. background: linear-gradient(0deg, #52C696 0%, #52C696 100%);
  184. border-radius: 26rpx;
  185. font-size: 26rpx;
  186. font-family: PingFang SC;
  187. font-weight: 500;
  188. text-align: center;
  189. color: #FFFFFF;
  190. position: absolute;
  191. bottom: 0;
  192. right: 0;
  193. }
  194. .price-wrap {
  195. .old-price {
  196. .old {
  197. font-size: 26rpx;
  198. font-family: PingFang SC;
  199. font-weight: 500;
  200. text-decoration: line-through;
  201. color: #999999;
  202. }
  203. image {
  204. display: inline-block;
  205. width: 14rpx;
  206. height: 20rpx;
  207. margin: 0 6rpx 0 10rpx;
  208. }
  209. .zj {
  210. font-size: 24rpx;
  211. font-family: PingFang SC;
  212. font-weight: bold;
  213. color: #B59467;
  214. }
  215. }
  216. .integral-wrap {
  217. display: flex;
  218. justify-content: flex-start;
  219. padding-top: 14rpx;
  220. image {
  221. width: 40rpx;
  222. height: 40rpx;
  223. margin-right: 8rpx;
  224. }
  225. .price {
  226. font-size: 36rpx;
  227. font-family: PingFang SC;
  228. font-weight: bold;
  229. color: #FF6F0F;
  230. line-height: 40rpx;
  231. }
  232. }
  233. }
  234. }
  235. }
  236. </style>