classify.vue 5.7 KB

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