mymodellist.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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="setmodel(item)">
  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. that.navList.orderList.forEach(item => {
  69. item.is_default = 0
  70. })
  71. item.is_default=1;
  72. uni.showToast({
  73. title:res.msg
  74. })
  75. })
  76. .catch(e => {
  77. });
  78. },
  79. // 获取模板列表
  80. getList(source) {
  81. //这里是将订单挂载到tab列表下
  82. let navItem = this.navList;
  83. let state = navItem.state;
  84. if (source === 'tabChange' && navItem.loaded === true) {
  85. //tab切换只有第一次需要加载数据
  86. return;
  87. }
  88. if (navItem.loadingType === 'loading') {
  89. //防止重复加载
  90. return;
  91. }
  92. if (navItem.loadingType === 'noMore') {
  93. //防止重复加载
  94. return;
  95. }
  96. // 修改当前对象状态为加载中
  97. navItem.loadingType = 'loading';
  98. userShowTemplateList({
  99. page: navItem.page,
  100. pageSize: navItem.limit
  101. })
  102. .then(({
  103. data
  104. }) => {
  105. let arr = data.list.map(e => {
  106. return e;
  107. });
  108. navItem.orderList = navItem.orderList.concat(arr);
  109. navItem.page++;
  110. if (navItem.limit == arr.length) {
  111. //判断是否还有数据, 有改为 more, 没有改为noMore
  112. navItem.loadingType = 'more';
  113. return;
  114. } else {
  115. //判断是否还有数据, 有改为 more, 没有改为noMore
  116. navItem.loadingType = 'noMore';
  117. }
  118. uni.hideLoading();
  119. this.$set(navItem, 'loaded', true);
  120. })
  121. .catch(e => {
  122. console.log(e);
  123. });
  124. },
  125. navTo(url) {
  126. if (url) {
  127. if (url.indexOf('http') > -1) {
  128. // #ifdef H5
  129. window.location.href = url
  130. // #endif
  131. // #ifdef APP
  132. plus.runtime.openURL(url)
  133. // #endif
  134. } else {
  135. uni.navigateTo({
  136. url: url
  137. })
  138. }
  139. }
  140. }
  141. },
  142. };
  143. </script>
  144. <style lang="scss">
  145. page,
  146. .indexBox {
  147. height: auto;
  148. min-height: 100%;
  149. }
  150. .hot-list-box {
  151. padding: $page-row-spacing;
  152. padding-bottom: 0;
  153. .list-box {
  154. display: flex;
  155. flex-wrap: wrap;
  156. justify-content: space-between;
  157. align-items: flex-start;
  158. padding-bottom: 20rpx;
  159. .list {
  160. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  161. border-radius: 15rpx;
  162. .list-image-box {
  163. width: 330rpx;
  164. height: 420rpx;
  165. overflow: hidden;
  166. .list-image {
  167. width: 100%;
  168. }
  169. }
  170. .list-content {
  171. padding: 20rpx;
  172. line-height: 1;
  173. .list-title {
  174. color: $font-color-dark;
  175. font-size: $font-base;
  176. margin-bottom: 10rpx;
  177. }
  178. .list-money {
  179. border-radius: 10rpx;
  180. padding: 20rpx 20rpx;
  181. background: linear-gradient(to bottom, #ff629f, rgba(255, 98, 159, 0.5));
  182. text-align: center;
  183. font-size: $font-lg;
  184. font-weight: bold;
  185. color: #FFFFFF;
  186. &.action{
  187. background: #FFFFFF;
  188. color: $font-color-dark;
  189. }
  190. }
  191. }
  192. }
  193. }
  194. }
  195. </style>