mymodellist.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <template>
  2. <view class="indexBox">
  3. <view class="hot-list-box">
  4. <view class="list-box">
  5. <view class="list" @click="navTo('/pages/user/model/model?mtype=' + item.show_template_id + '&type=3')"
  6. v-for="(item,index) in navList.orderList">
  7. <view class="list-image-box">
  8. <image class="list-image" :src="item.img" mode="widthFix"></image>
  9. </view>
  10. <view class="list-content">
  11. <view class="list-title clamp">
  12. {{item.title}}
  13. </view>
  14. <view v-if="item.is_default==0" class="list-money action" @click.stop="setmodel(item)">
  15. 设为默认
  16. </view>
  17. <view v-else class="list-money" @click.stop="">
  18. 默认模板
  19. </view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <uni-load-more :status="navList.loadingType"></uni-load-more>
  25. </view>
  26. </template>
  27. <script>
  28. import {
  29. mapState,
  30. mapMutations
  31. } from 'vuex';
  32. import {
  33. share
  34. } from '@/api/wx';
  35. import {
  36. userShowTemplateList,
  37. setShowTemplate
  38. } from '@/api/model.js';
  39. export default {
  40. data() {
  41. return {
  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. this.getList();
  55. },
  56. // 滚动到底部
  57. onReachBottom() {
  58. this.getList();
  59. },
  60. methods: {
  61. // 设为默认
  62. setmodel(item) {
  63. const that = this;
  64. setShowTemplate({
  65. show_template_id: item.show_template_id
  66. })
  67. .then((res) => {
  68. item.is_default=1;
  69. uni.showToast({
  70. title:res.msg
  71. })
  72. that.navList.orderList=[];
  73. that.navList.page=1;
  74. that.navList.loadingType='more';
  75. that.getList();
  76. })
  77. .catch(e => {
  78. });
  79. },
  80. // 获取模板列表
  81. getList(source) {
  82. //这里是将订单挂载到tab列表下
  83. let navItem = this.navList;
  84. let state = navItem.state;
  85. if (source === 'tabChange' && navItem.loaded === true) {
  86. //tab切换只有第一次需要加载数据
  87. return;
  88. }
  89. if (navItem.loadingType === 'loading') {
  90. //防止重复加载
  91. return;
  92. }
  93. if (navItem.loadingType === 'noMore') {
  94. //防止重复加载
  95. return;
  96. }
  97. // 修改当前对象状态为加载中
  98. navItem.loadingType = 'loading';
  99. userShowTemplateList({
  100. page: navItem.page,
  101. pageSize: navItem.limit
  102. })
  103. .then(({
  104. data
  105. }) => {
  106. let arr = data.list.map(e => {
  107. return e;
  108. });
  109. navItem.orderList = navItem.orderList.concat(arr);
  110. navItem.page++;
  111. if (navItem.limit == arr.length) {
  112. //判断是否还有数据, 有改为 more, 没有改为noMore
  113. navItem.loadingType = 'more';
  114. return;
  115. } else {
  116. //判断是否还有数据, 有改为 more, 没有改为noMore
  117. navItem.loadingType = 'noMore';
  118. }
  119. uni.hideLoading();
  120. this.$set(navItem, 'loaded', true);
  121. })
  122. .catch(e => {
  123. console.log(e);
  124. });
  125. },
  126. navTo(url) {
  127. if (url) {
  128. if (url.indexOf('http') > -1) {
  129. // #ifdef H5
  130. window.location.href = url
  131. // #endif
  132. // #ifdef APP
  133. plus.runtime.openURL(url)
  134. // #endif
  135. } else {
  136. uni.navigateTo({
  137. url: url
  138. })
  139. }
  140. }
  141. }
  142. },
  143. };
  144. </script>
  145. <style lang="scss">
  146. page,
  147. .indexBox {
  148. height: auto;
  149. min-height: 100%;
  150. }
  151. .hot-list-box {
  152. padding: $page-row-spacing;
  153. padding-bottom: 0;
  154. .list-box {
  155. display: flex;
  156. flex-wrap: wrap;
  157. justify-content: space-between;
  158. align-items: flex-start;
  159. padding-bottom: 20rpx;
  160. .list {
  161. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  162. border-radius: 15rpx;
  163. .list-image-box {
  164. width: 330rpx;
  165. height: 420rpx;
  166. overflow: hidden;
  167. .list-image {
  168. width: 100%;
  169. }
  170. }
  171. .list-content {
  172. padding: 20rpx;
  173. line-height: 1;
  174. .list-title {
  175. color: $font-color-dark;
  176. font-size: $font-base;
  177. margin-bottom: 10rpx;
  178. }
  179. .list-money {
  180. border-radius: 10rpx;
  181. padding: 20rpx 20rpx;
  182. background: linear-gradient(to bottom, #ff629f, rgba(255, 98, 159, 0.5));
  183. text-align: center;
  184. font-size: $font-lg;
  185. font-weight: bold;
  186. color: #FFFFFF;
  187. &.action{
  188. background: #FFFFFF;
  189. color: $font-color-dark;
  190. }
  191. }
  192. }
  193. }
  194. }
  195. }
  196. </style>