classify.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. margin-left: 20rpx;
  155. flex-grow: 1;
  156. height: 180rpx;
  157. position: relative;
  158. .title {
  159. font-size: $font-base;
  160. color: $font-color-dark;
  161. font-weight: 500;
  162. }
  163. .goods-money {
  164. position: absolute;
  165. left: 0;
  166. bottom: 0;
  167. width:100%;
  168. .money-box {
  169. .money {
  170. font-size: $font-lg;
  171. color: $color-red;
  172. font-weight: bold;
  173. }
  174. .otMoney-box {
  175. font-size: $font-sm;
  176. .otMoney {
  177. color: $font-color-dark;
  178. padding-right: 20rpx;
  179. }
  180. .sales {
  181. color: $font-color-light;
  182. }
  183. }
  184. }
  185. .cart {
  186. border: 1px solid $color-red;
  187. color: $color-red;
  188. font-size: $font-base;
  189. font-weight: bold;
  190. border-radius: 99px;
  191. width: 55rpx;
  192. height: 55rpx;
  193. display: flex;
  194. justify-content: center;
  195. align-items: center;
  196. }
  197. }
  198. }
  199. }
  200. }
  201. </style>