modelList.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <template>
  2. <view class="indexBox">
  3. <view class="hot-list-box">
  4. <view class="list-box">
  5. <view class="list" v-for="(item,index) in navList.orderList">
  6. <view class="list-image-box">
  7. <image class="list-image" :src="item.img" mode="widthFix"></image>
  8. </view>
  9. <view class="list-content">
  10. <view class="list-title clamp">
  11. {{item.title}}
  12. </view>
  13. <view class="list-money flex flex-start">
  14. <view class="money">
  15. ¥{{item.price}}
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. </view>
  22. <uni-load-more :status="navList.loadingType"></uni-load-more>
  23. </view>
  24. </template>
  25. <script>
  26. import {
  27. mapState,
  28. mapMutations
  29. } from 'vuex';
  30. import {
  31. share
  32. } from '@/api/wx';
  33. import {
  34. getBannerList,
  35. getShowTemplateList
  36. } from '@/api/model.js';
  37. export default {
  38. data() {
  39. return {
  40. ishot:0,//判断是否热门
  41. isrecommend:0,//判断是否推荐
  42. // 商品列表
  43. navList: {
  44. state: 1,
  45. loadingType: 'more',
  46. orderList: [],
  47. page: 1, //当前页数
  48. limit: 10, //每次信息条数
  49. count: 0, //总消息条数
  50. },
  51. };
  52. },
  53. onLoad: function(option) {
  54. if(option.isrecommend){
  55. uni.setNavigationBarTitle({
  56. title:'精品推荐'
  57. })
  58. this.isrecommend = option.isrecommend
  59. }else if(option.ishot){
  60. uni.setNavigationBarTitle({
  61. title:'热门装扮'
  62. })
  63. this.ishot = option.ishot
  64. }
  65. this.getShowTemplateList();
  66. },
  67. // 滚动到底部
  68. onReachBottom() {
  69. this.getShowTemplateList();
  70. },
  71. methods: {
  72. // 获取模板列表
  73. getShowTemplateList(source) {
  74. //这里是将订单挂载到tab列表下
  75. let navItem = this.navList;
  76. let state = navItem.state;
  77. if (source === 'tabChange' && navItem.loaded === true) {
  78. //tab切换只有第一次需要加载数据
  79. return;
  80. }
  81. if (navItem.loadingType === 'loading') {
  82. //防止重复加载
  83. return;
  84. }
  85. if (navItem.loadingType === 'noMore') {
  86. //防止重复加载
  87. return;
  88. }
  89. // 修改当前对象状态为加载中
  90. navItem.loadingType = 'loading';
  91. getShowTemplateList({
  92. is_recommend: this.isrecommend,
  93. is_hot: this.ishot,
  94. page: navItem.page,
  95. pageSize: navItem.limit
  96. })
  97. .then(({
  98. data
  99. }) => {
  100. let arr = data.list.map(e => {
  101. return e;
  102. });
  103. navItem.orderList = navItem.orderList.concat(arr);
  104. navItem.page++;
  105. if (navItem.limit == arr.length) {
  106. //判断是否还有数据, 有改为 more, 没有改为noMore
  107. navItem.loadingType = 'more';
  108. return;
  109. } else {
  110. //判断是否还有数据, 有改为 more, 没有改为noMore
  111. navItem.loadingType = 'noMore';
  112. }
  113. uni.hideLoading();
  114. this.$set(navItem, 'loaded', true);
  115. })
  116. .catch(e => {
  117. console.log(e);
  118. });
  119. },
  120. navTo(url) {
  121. if (url) {
  122. if (url.indexOf('http') > -1) {
  123. // #ifdef H5
  124. window.location.href = url
  125. // #endif
  126. // #ifdef APP
  127. plus.runtime.openURL(url)
  128. // #endif
  129. } else {
  130. uni.navigateTo({
  131. url: url
  132. })
  133. }
  134. }
  135. }
  136. },
  137. };
  138. </script>
  139. <style lang="scss">
  140. page,
  141. .indexBox {
  142. height: auto;
  143. min-height: 100%;
  144. }
  145. .hot-list-box {
  146. padding: $page-row-spacing;
  147. padding-bottom: 0;
  148. .list-box {
  149. display: flex;
  150. flex-wrap: wrap;
  151. justify-content: space-between;
  152. align-items: flex-start;
  153. padding-bottom: 20rpx;
  154. .list {
  155. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  156. border-radius: 15rpx;
  157. .list-image-box {
  158. width: 330rpx;
  159. height: 420rpx;
  160. overflow: hidden;
  161. .list-image {
  162. width: 100%;
  163. }
  164. }
  165. .list-content {
  166. padding: 20rpx;
  167. line-height: 1;
  168. .list-title {
  169. color: $font-color-dark;
  170. font-size: $font-base;
  171. margin-bottom: 20rpx;
  172. }
  173. .list-money {
  174. .money {
  175. font: $font-lg;
  176. color: #FF3342;
  177. }
  178. }
  179. }
  180. }
  181. }
  182. }
  183. </style>