classify.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. <text v-if="type == 6">礼包商品</text>
  20. </view>
  21. <view class="title-border"></view>
  22. </view> -->
  23. <view class="goodsList-box flex">
  24. <view class="goodsList-item" :key="ind" v-for="(ls, ind) in list" @click="navTo(ls)">
  25. <image :src="ls.image" mode=" scaleToFill"></image>
  26. <view class="goodsList-content">
  27. <view class="title clamp2">
  28. <text>{{ ls.store_name }}</text>
  29. </view>
  30. <view class="goods-money">
  31. <view class="money-box">
  32. <view class="money">
  33. <text class="font-size-sm" v-if="type != 10">¥</text>
  34. {{ ls.price }}
  35. <text class="font-size-sm " v-if="ls.unit_name">/{{ls.unit_name}}</text>
  36. <template v-if="type==5">
  37. <text class="font-size-sm">+</text>
  38. <text class="font-size-sm">{{ ls.min_integral }}积分</text>
  39. </template>
  40. <template v-if="type==10">
  41. <text class="font-size-sm">积分</text>
  42. </template>
  43. <text class="otMoney" v-else>{{ls.ot_price}}</text>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import {
  54. groomList,
  55. getProducts
  56. } from '@/api/product.js';
  57. export default {
  58. data() {
  59. return {
  60. list: [],
  61. bannerImg: [],
  62. page: 1,
  63. limit: 10,
  64. };
  65. },
  66. onLoad(option) {
  67. // 获取查询对象
  68. this.type = option.type;
  69. // 加载基础数据
  70. this.loadData();
  71. },
  72. methods: {
  73. navTo: function(ls) {
  74. uni.navigateTo({
  75. url: '/pages/product/product?id=' + ls.id
  76. });
  77. },
  78. // 请求载入数据
  79. async loadData() {
  80. if(this.type == 10 || this.type == 11) {
  81. getProducts({
  82. sid: this.type == 10 ? 54: 56,
  83. page: 1,
  84. limit: 1000
  85. }, this.type)
  86. .then(({
  87. data
  88. }) => {
  89. // 保存轮播图
  90. // 保存商品信息
  91. this.list = data.map((res) => {
  92. res.price = +res.price;
  93. return res
  94. });
  95. })
  96. .catch(e => {
  97. console.log(e);
  98. });
  99. }else {
  100. groomList({}, this.type)
  101. .then(({
  102. data
  103. }) => {
  104. // 保存轮播图
  105. this.bannerImg = data.banner;
  106. // 保存商品信息
  107. this.list = data.list.map((res) => {
  108. res.price = +res.price;
  109. res.ot_price = +res.ot_price;
  110. if (res.min_integral) {
  111. res.min_integral = +res.min_integral;
  112. }
  113. return res
  114. });
  115. })
  116. .catch(e => {
  117. console.log(e);
  118. });
  119. }
  120. },
  121. // 轮播图跳转
  122. bannerNavToUrl(item) {
  123. // #ifdef H5
  124. if (item.wap_link.indexOf('http') > 0) {
  125. window.location.href = item.wap_link;
  126. }
  127. // #endif
  128. if (item.wap_link) {
  129. uni.navigateTo({
  130. url: item.wap_link
  131. });
  132. }
  133. }
  134. }
  135. };
  136. </script>
  137. <style lang="scss">
  138. page {
  139. background: $page-color-base;
  140. }
  141. .carousel-section {
  142. padding: 0;
  143. .titleNview-placing {
  144. padding-top: 0;
  145. height: 0;
  146. }
  147. .swiper-dots {
  148. left: 45rpx;
  149. bottom: 40rpx;
  150. }
  151. .carousel {
  152. width: 100%;
  153. height: 360rpx;
  154. .carousel-item {
  155. width: 100%;
  156. height: 100%;
  157. overflow: hidden;
  158. }
  159. image {
  160. width: 100%;
  161. height: 100%;
  162. }
  163. }
  164. }
  165. // 中间标题样式
  166. .type-title-box {
  167. padding: 40rpx;
  168. .title-content {
  169. height: 100%;
  170. width: 200rpx;
  171. text-align: center;
  172. font-size: $font-lg;
  173. font-weight: 500;
  174. color: $font-color-dark;
  175. }
  176. .title-border {
  177. width: 250rpx;
  178. height: 2rpx;
  179. background-color: #e9e9e9;
  180. }
  181. }
  182. // 商品列表
  183. .goodsList-box {
  184. padding: 30rpx;
  185. flex-wrap: wrap;
  186. .goodsList-item {
  187. margin-bottom: 40rpx;
  188. background-color: #ffffff;
  189. border-radius: 10rpx;
  190. width: 330rpx;
  191. image {
  192. flex-shrink: 0;
  193. border-radius: $border-radius-sm;
  194. height: 330rpx;
  195. width: 330rpx;
  196. }
  197. .goodsList-content {
  198. flex-grow: 1;
  199. position: relative;
  200. padding: 20rpx;
  201. .title {
  202. font-size: $font-base;
  203. color: $font-color-dark;
  204. font-weight: 500;
  205. height: 3em;
  206. }
  207. .goods-money {
  208. .money-box {
  209. .money {
  210. font-size: $font-lg;
  211. color: $color-red;
  212. font-weight: bold;
  213. }
  214. .otMoney {
  215. color: $font-color-disabled;
  216. padding-right: 20rpx;
  217. font-size: 24rpx;
  218. text-decoration:line-through;
  219. padding-left: 10rpx;;
  220. }
  221. }
  222. .cart {
  223. border: 1px solid $color-red;
  224. color: $color-red;
  225. font-size: $font-base;
  226. font-weight: bold;
  227. border-radius: 99px;
  228. width: 55rpx;
  229. height: 55rpx;
  230. display: flex;
  231. justify-content: center;
  232. align-items: center;
  233. }
  234. }
  235. }
  236. }
  237. }
  238. </style>