classify.vue 5.0 KB

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