classify.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <view class="container">
  3. <empty v-if="loaded === true && list.length === 0"></empty>
  4. <view class="hotgoods">
  5. <view class="hotgoods-item" v-for="item in list" :key="item.id" @click="navToDetailPage(item)">
  6. <view class="image-wrapper">
  7. <image :src="item.image" mode="scaleToFill"></image>
  8. </view>
  9. <view class="title clamp margin-c-20">{{ item.store_name }}</view>
  10. <view class="hot-price">
  11. <view class="price">
  12. <text class="font-size-sm">¥</text>
  13. {{ item.price }}
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. <uni-load-more :status="loadingType"></uni-load-more>
  19. </view>
  20. </template>
  21. <script>
  22. import empty from '@/components/empty';
  23. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  24. import {
  25. groomList
  26. } from '@/api/product.js';
  27. export default {
  28. data() {
  29. return {
  30. list: [],
  31. bannerImg: [],
  32. type: 1, //1->置换
  33. loadingType: 'more',
  34. loaded:false,
  35. page: 1,
  36. limit:20
  37. };
  38. },
  39. components: {
  40. uniLoadMore,
  41. empty
  42. },
  43. onReachBottom() {
  44. this.loadData();
  45. },
  46. onLoad(option) {
  47. // 获取查询对象
  48. if (option.type) {
  49. this.type = option.type;
  50. uni.setNavigationBarTitle({
  51. title: option.type == 1? '置换': (option.type == 4? '随意嗨购':(option.type == 3? '大牌专区': ''))
  52. })
  53. }
  54. // 加载基础数据
  55. this.loadData();
  56. },
  57. methods: {
  58. navTo: function(ls) {
  59. uni.navigateTo({
  60. url: '/pages/product/product?id=' + ls.id
  61. });
  62. },
  63. // 请求载入数据
  64. async loadData() {
  65. let obj = this
  66. if(obj.loadingType == 'loading' || obj.loadingType == 'noMore') {
  67. return
  68. }
  69. obj.loadingType = 'loading'
  70. groomList({
  71. page: obj.page,
  72. limit:obj.limit
  73. }, this.type)
  74. .then(({
  75. data
  76. }) => {
  77. // 保存轮播图
  78. obj.bannerImg = data.banner;
  79. // 保存商品信息
  80. obj.list = this.list.concat(data.list)
  81. obj.loaded = true
  82. obj.page++
  83. if(obj.limit == data.list.length) {
  84. obj.loadingType = 'more'
  85. }else {
  86. obj.loadingType = 'noMore'
  87. }
  88. })
  89. .catch(e => {
  90. console.log(e);
  91. });
  92. },
  93. // 轮播图跳转
  94. bannerNavToUrl(item) {
  95. // #ifdef H5
  96. if (item.wap_link.indexOf('http') > 0) {
  97. window.location.href = item.wap_link;
  98. }
  99. // #endif
  100. if (item.wap_link) {
  101. uni.navigateTo({
  102. url: item.wap_link
  103. });
  104. }
  105. },
  106. navToDetailPage(e) {
  107. uni.navigateTo({
  108. url: '/pages/product/product?id=' + e.id
  109. })
  110. }
  111. }
  112. };
  113. </script>
  114. <style lang="scss">
  115. page {
  116. background: $page-color-base;
  117. }
  118. .carousel-section {
  119. padding: 0;
  120. .titleNview-placing {
  121. padding-top: 0;
  122. height: 0;
  123. }
  124. .swiper-dots {
  125. left: 45rpx;
  126. bottom: 40rpx;
  127. }
  128. .carousel {
  129. width: 100%;
  130. height: 360rpx;
  131. .carousel-item {
  132. width: 100%;
  133. height: 100%;
  134. overflow: hidden;
  135. }
  136. image {
  137. width: 100%;
  138. height: 100%;
  139. }
  140. }
  141. }
  142. // 中间标题样式
  143. .type-title-box {
  144. padding: 40rpx;
  145. .title-content {
  146. height: 100%;
  147. width: 200rpx;
  148. text-align: center;
  149. font-size: $font-lg;
  150. font-weight: 500;
  151. color: $font-color-dark;
  152. }
  153. .title-border {
  154. width: 250rpx;
  155. height: 2rpx;
  156. background-color: #e9e9e9;
  157. }
  158. }
  159. // 商品列表
  160. .goodsList-box {
  161. .goodsList-item {
  162. margin-bottom: 40rpx;
  163. background-color: #ffffff;
  164. padding: 30rpx;
  165. image {
  166. flex-shrink: 0;
  167. border-radius: $border-radius-sm;
  168. height: 180rpx;
  169. width: 180rpx;
  170. }
  171. .goodsList-content {
  172. margin-left: 20rpx;
  173. flex-grow: 1;
  174. height: 180rpx;
  175. position: relative;
  176. .title {
  177. font-size: $font-base;
  178. color: $font-color-dark;
  179. font-weight: 500;
  180. }
  181. .goods-money {
  182. position: absolute;
  183. left: 0;
  184. bottom: 0;
  185. width: 100%;
  186. .money-box {
  187. .money {
  188. font-size: $font-lg;
  189. color: $color-red;
  190. font-weight: bold;
  191. }
  192. .otMoney-box {
  193. font-size: $font-sm;
  194. .otMoney {
  195. color: $font-color-dark;
  196. padding-right: 20rpx;
  197. }
  198. .sales {
  199. color: $font-color-light;
  200. }
  201. }
  202. }
  203. .cart {
  204. border: 1px solid $color-red;
  205. color: $color-red;
  206. font-size: $font-base;
  207. font-weight: bold;
  208. border-radius: 99px;
  209. width: 55rpx;
  210. height: 55rpx;
  211. display: flex;
  212. justify-content: center;
  213. align-items: center;
  214. }
  215. }
  216. }
  217. }
  218. }
  219. .hotgoods {
  220. margin-top: 38rpx;
  221. width: 100%;
  222. display: flex;
  223. flex-wrap: wrap;
  224. padding: 0 32rpx;
  225. .hotgoods-item {
  226. width: 48%;
  227. background-color: #ffffff;
  228. border-radius: 12rpx;
  229. margin-bottom: 24rpx;
  230. &:nth-child(2n + 1) {
  231. margin-right: 24rpx;
  232. }
  233. .image-wrapper {
  234. width: 100%;
  235. height: 330rpx;
  236. // background: red;
  237. border-radius: 3px;
  238. overflow: hidden;
  239. image {
  240. width: 100%;
  241. height: 100%;
  242. opacity: 1;
  243. border-radius: 12rpx 12rpx 0 0;
  244. }
  245. }
  246. .title {
  247. font-size: $font-base;
  248. color: $font-color-dark;
  249. font-weight: bold;
  250. line-height: 80rpx;
  251. }
  252. .hot-price {
  253. display: flex;
  254. justify-content: space-between;
  255. padding: 0 16rpx 12rpx;
  256. .price {
  257. font-size: 36rpx;
  258. font-weight: bold;
  259. color: #FD3B39;
  260. }
  261. .cart-icon {
  262. image {
  263. width: 44rpx;
  264. height: 44rpx;
  265. }
  266. }
  267. }
  268. }
  269. }
  270. </style>