classify.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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 class="clamp2">{{ ls.store_name }}</text>
  27. </view>
  28. <view class="goods-money flex">
  29. <view class="money-box">
  30. <text class="otMoney">¥{{ ls.ot_price }}</text>
  31. <image src="@/static/icon/decline.png"></image>
  32. <text class="decline">直降{{ ls.ot_price - ls.price}}元</text>
  33. <!-- <view class="otMoney-box"> -->
  34. <view class="money">¥{{ ls.price }}</view>
  35. <!-- <text class="sales">已售{{ ls.sales }}件</text> -->
  36. <!-- </view> -->
  37. </view>
  38. <view class="button" @click="navTo(ls)">立即购买</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. title: '',
  54. };
  55. },
  56. onLoad(option) {
  57. // 获取查询对象
  58. this.type = option.type;
  59. // 加载基础数据
  60. this.loadData();
  61. },
  62. created() {
  63. this.getTitle()
  64. },
  65. mounted() {
  66. },
  67. methods: {
  68. //动态改变标头
  69. getTitle() {
  70. let title = ''
  71. if(this.type == 1) {
  72. title = "精选好货"
  73. }else if(this.type == 2) {
  74. title = "热销专区"
  75. }else if(this.type == 3) {
  76. title = "收藏夹"
  77. }else {
  78. title = "促销单品"
  79. }
  80. uni.setNavigationBarTitle({
  81. title: title
  82. });
  83. },
  84. navTo: function(ls) {
  85. uni.navigateTo({
  86. url: '/pages/product/product?id=' + ls.id
  87. });
  88. },
  89. // 请求载入数据
  90. async loadData() {
  91. groomList({}, this.type)
  92. .then(({ data }) => {
  93. // 保存轮播图
  94. this.bannerImg = data.banner;
  95. // 保存商品信息
  96. this.list = data.list;
  97. })
  98. .catch(e => {
  99. console.log(e);
  100. });
  101. },
  102. // 轮播图跳转
  103. bannerNavToUrl(item) {
  104. // #ifdef H5
  105. if (item.wap_link.indexOf('http') > 0) {
  106. window.location.href = item.wap_link;
  107. }
  108. // #endif
  109. if (item.wap_link) {
  110. uni.navigateTo({
  111. url: item.wap_link
  112. });
  113. }
  114. }
  115. }
  116. };
  117. </script>
  118. <style lang="scss">
  119. page {
  120. background: $page-color-base;
  121. }
  122. .carousel-section {
  123. padding: 0;
  124. .titleNview-placing {
  125. padding-top: 0;
  126. height: 0;
  127. }
  128. .swiper-dots {
  129. left: 45rpx;
  130. bottom: 40rpx;
  131. }
  132. .carousel {
  133. width: 100%;
  134. height: 360rpx;
  135. .carousel-item {
  136. width: 100%;
  137. height: 100%;
  138. overflow: hidden;
  139. }
  140. image {
  141. width: 100%;
  142. height: 100%;
  143. }
  144. }
  145. }
  146. // 中间标题样式
  147. .type-title-box {
  148. padding: 40rpx;
  149. .title-content {
  150. height: 100%;
  151. width: 200rpx;
  152. text-align: center;
  153. font-size: $font-lg;
  154. font-weight: 500;
  155. color: $font-color-dark;
  156. }
  157. .title-border {
  158. width: 250rpx;
  159. height: 2rpx;
  160. background-color: #e9e9e9;
  161. }
  162. }
  163. // 商品列表
  164. .goodsList-box {
  165. padding: 30rpx;
  166. .goodsList-item {
  167. box-shadow:0 0 20rpx 6rpx #f1f1f1;
  168. border-radius: 10rpx;
  169. margin-bottom: 30rpx;
  170. background-color: #ffffff;
  171. padding: 30rpx;
  172. image {
  173. flex-shrink: 0;
  174. border-radius: $border-radius-sm;
  175. height: 180rpx;
  176. width: 180rpx;
  177. }
  178. .goodsList-content {
  179. margin-left: 20rpx;
  180. flex-grow: 1;
  181. height: 180rpx;
  182. position: relative;
  183. .title {
  184. font-size: $font-base;
  185. color: $font-color-dark;
  186. font-weight: bold;
  187. }
  188. .goods-money {
  189. position: absolute;
  190. left: 0;
  191. bottom: 0;
  192. width:100%;
  193. .money-box {
  194. .otMoney {
  195. color: #999999;
  196. text-decoration: line-through;
  197. margin-right: 15rpx;
  198. font-size: 20rpx;
  199. }
  200. .money {
  201. color: #EF3A55;
  202. font-weight: bold;
  203. font-size: 35rpx;
  204. }
  205. image {
  206. width: 20rpx;
  207. height: 20rpx;
  208. margin-right: 5rpx;
  209. }
  210. .decline {
  211. color: #FFB238;
  212. font-size: 20rpx;
  213. }
  214. .sales {
  215. color: $font-color-light;
  216. }
  217. }
  218. .button {
  219. background: linear-gradient(90deg, #438BED 0%, #44BFEC 100%);
  220. background-color: #438BED;
  221. height: 50rpx;
  222. border-radius: 20rpx;
  223. padding: 10rpx 15rpx;
  224. color: #fff;
  225. font-size: 25rpx;
  226. position: relative;
  227. top: 20rpx;
  228. }
  229. .cart {
  230. border: 1px solid $color-red;
  231. color: $color-red;
  232. font-size: $font-base;
  233. font-weight: bold;
  234. border-radius: 99px;
  235. width: 55rpx;
  236. height: 55rpx;
  237. display: flex;
  238. justify-content: center;
  239. align-items: center;
  240. }
  241. }
  242. }
  243. }
  244. }
  245. </style>