classify.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <view class="container">
  3. <!-- 头部轮播 -->
  4. <view class="carousel-section">
  5. <swiper class="carousel" autoplay="true" duration="400" interval="5000">
  6. <swiper-item v-for="(item, index) in bannerImg" :key="index" class="carousel-item" @click="bannerNavToUrl(item)">
  7. <image :src="item.img" mode=" scaleToFill" />
  8. </swiper-item>
  9. </swiper>
  10. </view>
  11. <view class="type-title-box flex">
  12. <view class="title-border"></view>
  13. <view class="title-content">
  14. <text v-if="type == 1">精品推荐</text>
  15. <text v-if="type == 2">热门榜单</text>
  16. <text v-if="type == 3">首发新品</text>
  17. <text v-if="type == 4">促销单品</text>
  18. </view>
  19. <view class="title-border"></view>
  20. </view>
  21. <view class="goodsList-box">
  22. <view class="goodsList-item flex" :key="ind" v-for="(ls, ind) in list">
  23. <image :src="ls.image" mode=" scaleToFill"></image>
  24. <view class="goodsList-content">
  25. <view class="title">
  26. <text>{{ ls.store_name }}</text>
  27. </view>
  28. <view class="goods-money flex">
  29. <view class="money-box">
  30. <view class="money">
  31. <text class="font-size-sm">¥</text>
  32. {{ ls.price }}
  33. </view>
  34. <view class="otMoney-box">
  35. <text class="otMoney">¥{{ ls.ot_price }}</text>
  36. <text class="sales">已售{{ ls.sales }}件</text>
  37. </view>
  38. </view>
  39. <view @click="navTo(ls)" class="cart iconfont iconcart"></view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import { groomList } from '@/api/product.js';
  48. export default {
  49. data() {
  50. return {
  51. list: [],
  52. bannerImg: []
  53. };
  54. },
  55. onLoad(option) {
  56. // 获取查询对象
  57. this.type = option.type;
  58. // 加载基础数据
  59. this.loadData();
  60. },
  61. methods: {
  62. navTo: function(ls) {
  63. uni.navigateTo({
  64. url: '/pages/product/product?id=' + ls.id
  65. });
  66. },
  67. // 请求载入数据
  68. async loadData() {
  69. groomList({}, this.type)
  70. .then(({ data }) => {
  71. // 保存轮播图
  72. this.bannerImg = data.banner;
  73. // 保存商品信息
  74. this.list = data.list;
  75. })
  76. .catch(e => {
  77. console.log(e);
  78. });
  79. },
  80. // 轮播图跳转
  81. bannerNavToUrl(item) {
  82. // #ifdef H5
  83. if (item.wap_link.indexOf('http') > 0) {
  84. window.location.href = item.wap_link;
  85. }
  86. // #endif
  87. if (item.wap_link) {
  88. uni.navigateTo({
  89. url: item.wap_link
  90. });
  91. }
  92. }
  93. }
  94. };
  95. </script>
  96. <style lang="scss">
  97. page {
  98. background: $page-color-base;
  99. }
  100. .carousel-section {
  101. padding: 0;
  102. .titleNview-placing {
  103. padding-top: 0;
  104. height: 0;
  105. }
  106. .swiper-dots {
  107. left: 45rpx;
  108. bottom: 40rpx;
  109. }
  110. .carousel {
  111. width: 100%;
  112. height: 360rpx;
  113. .carousel-item {
  114. width: 100%;
  115. height: 100%;
  116. overflow: hidden;
  117. }
  118. image {
  119. width: 100%;
  120. height: 100%;
  121. }
  122. }
  123. }
  124. // 中间标题样式
  125. .type-title-box {
  126. padding: 40rpx;
  127. .title-content {
  128. height: 100%;
  129. width: 200rpx;
  130. text-align: center;
  131. font-size: $font-lg;
  132. font-weight: 500;
  133. color: $font-color-dark;
  134. }
  135. .title-border {
  136. width: 250rpx;
  137. height: 2rpx;
  138. background-color: #e9e9e9;
  139. }
  140. }
  141. // 商品列表
  142. .goodsList-box {
  143. .goodsList-item {
  144. margin-bottom: 40rpx;
  145. background-color: #ffffff;
  146. padding: 30rpx;
  147. image {
  148. flex-shrink: 0;
  149. border-radius: $border-radius-sm;
  150. height: 180rpx;
  151. width: 180rpx;
  152. }
  153. .goodsList-content {
  154. padding-left: 20rpx;
  155. flex-grow: 1;
  156. height: 180rpx;
  157. .title {
  158. font-size: $font-base;
  159. color: $font-color-dark;
  160. font-weight: 500;
  161. margin-bottom: 50rpx;
  162. }
  163. .goods-money {
  164. .money-box {
  165. .money {
  166. font-size: $font-lg;
  167. color: $color-red;
  168. margin-bottom: 10rpx;
  169. font-weight: bold;
  170. }
  171. .otMoney-box {
  172. font-size: $font-sm;
  173. .otMoney {
  174. color: $font-color-dark;
  175. padding-right: 20rpx;
  176. }
  177. .sales {
  178. color: $font-color-light;
  179. }
  180. }
  181. }
  182. .cart {
  183. border: 1px solid $color-red;
  184. color: $color-red;
  185. padding: 10rpx;
  186. font-size: $font-base;
  187. font-weight: bold;
  188. border-radius: 99px;
  189. }
  190. }
  191. }
  192. }
  193. }
  194. </style>