classify.vue 4.2 KB

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