classify.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. <text v-if="type == 5">套餐商品</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" @click="navTo(ls)">
  24. <image :src="ls.image" mode=" scaleToFill"></image>
  25. <view class="goodsList-content">
  26. <view class="title">
  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 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. if (this.type == 7) {
  60. uni.setNavigationBarTitle({
  61. title: '商家礼包'
  62. });
  63. }
  64. // 加载基础数据
  65. this.loadData();
  66. },
  67. methods: {
  68. navTo: function(ls) {
  69. uni.navigateTo({
  70. url: '/pages/product/product?id=' + ls.id
  71. });
  72. },
  73. // 请求载入数据
  74. async loadData() {
  75. groomList({}, this.type)
  76. .then(({ data }) => {
  77. // 保存轮播图
  78. this.bannerImg = data.banner;
  79. // 保存商品信息
  80. this.list = data.list;
  81. })
  82. .catch(e => {
  83. console.log(e);
  84. });
  85. },
  86. // 轮播图跳转
  87. bannerNavToUrl(item) {
  88. // #ifdef H5
  89. if (item.wap_link.indexOf('http') > 0) {
  90. window.location.href = item.wap_link;
  91. }
  92. // #endif
  93. if (item.wap_link) {
  94. uni.navigateTo({
  95. url: item.wap_link
  96. });
  97. }
  98. }
  99. }
  100. };
  101. </script>
  102. <style lang="scss">
  103. page {
  104. background: $page-color-base;
  105. }
  106. .carousel-section {
  107. padding: 0;
  108. .titleNview-placing {
  109. padding-top: 0;
  110. height: 0;
  111. }
  112. .swiper-dots {
  113. left: 45rpx;
  114. bottom: 40rpx;
  115. }
  116. .carousel {
  117. width: 100%;
  118. height: 360rpx;
  119. .carousel-item {
  120. width: 100%;
  121. height: 100%;
  122. overflow: hidden;
  123. }
  124. image {
  125. width: 100%;
  126. height: 100%;
  127. }
  128. }
  129. }
  130. // 中间标题样式
  131. .type-title-box {
  132. padding: 40rpx;
  133. .title-content {
  134. height: 100%;
  135. width: 200rpx;
  136. text-align: center;
  137. font-size: $font-lg;
  138. font-weight: 500;
  139. color: $font-color-dark;
  140. }
  141. .title-border {
  142. width: 250rpx;
  143. height: 2rpx;
  144. background-color: #e9e9e9;
  145. }
  146. }
  147. // 商品列表
  148. .goodsList-box {
  149. .goodsList-item {
  150. margin-bottom: 40rpx;
  151. background-color: #ffffff;
  152. padding: 30rpx;
  153. image {
  154. flex-shrink: 0;
  155. border-radius: $border-radius-sm;
  156. height: 180rpx;
  157. width: 180rpx;
  158. }
  159. .goodsList-content {
  160. padding-left: 20rpx;
  161. flex-grow: 1;
  162. height: 180rpx;
  163. .title {
  164. font-size: $font-base;
  165. color: $font-color-dark;
  166. font-weight: 500;
  167. margin-bottom: 50rpx;
  168. }
  169. .goods-money {
  170. .money-box {
  171. .money {
  172. font-size: $font-lg;
  173. color: $color-red;
  174. margin-bottom: 10rpx;
  175. font-weight: bold;
  176. }
  177. .otMoney-box {
  178. font-size: $font-sm;
  179. .otMoney {
  180. color: $font-color-dark;
  181. padding-right: 20rpx;
  182. }
  183. .sales {
  184. color: $font-color-light;
  185. }
  186. }
  187. }
  188. .cart {
  189. border: 1px solid $color-red;
  190. color: $color-red;
  191. padding: 10rpx;
  192. font-size: $font-base;
  193. font-weight: bold;
  194. border-radius: 99px;
  195. }
  196. }
  197. }
  198. }
  199. }
  200. </style>