classify.vue 5.3 KB

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