classify.vue 5.4 KB

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