jlDetil.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <view>
  3. <swiper :style="{ height: height }" class="swiper-box" duration="300">
  4. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  5. <scroll-view scroll-y="true" class="list-scroll-content" @scrolltolower="loadData">
  6. <!-- 空白页 -->
  7. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  8. <!-- 订单列表 -->
  9. <view>
  10. <view class="order-item flex" v-for="(item, index) in tabItem.orderList">
  11. <view class="title-box">
  12. <view class="title">
  13. <text>植物名称:{{ item.name }}</text>
  14. </view>
  15. <view class="time">
  16. <text>{{ item.create_time }}</text>
  17. </view>
  18. <view class="time">
  19. <text>场次:第{{ item.stage }}期</text>
  20. </view>
  21. </view>
  22. <view class="money">
  23. <view>植物进度:{{ item.price * 1 }}</view>
  24. <!-- <view class="">
  25. {{item.status==0&&item.is_return==1}} 待返还
  26. {{item.status==0&&item.is_return==0}} 进行中
  27. {{item.status==1}} 打怪成功
  28. {{item.status==2}} 打怪失败
  29. </view> -->
  30. <view class="money" v-if="item.status == 0 && item.is_return == 1">待发放</view>
  31. <view class="money" v-else-if="item.status == 0 && item.is_return == 0">进行中</view>
  32. <view class="money" v-else-if="item.status == 1">种植成功</view>
  33. <view class="money" v-else-if="item.status == 2">种植失败</view>
  34. </view>
  35. </view>
  36. </view>
  37. <uni-load-more :status="tabItem.loadingType" v-if="!(tabItem.orderList.length == 0 && tabItem.loaded)"></uni-load-more>
  38. </scroll-view>
  39. </swiper-item>
  40. </swiper>
  41. </view>
  42. </template>
  43. <script>
  44. import { getJl } from '@/api/user.js';
  45. import { mapState, mapMutations } from 'vuex';
  46. import { getMoneyStyle } from '@/utils/rocessor.js';
  47. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  48. import empty from '@/components/empty';
  49. export default {
  50. components: {
  51. empty,
  52. uniLoadMore
  53. },
  54. filters: {
  55. getMoneyStyle
  56. },
  57. data() {
  58. return {
  59. zc: 0,
  60. sr: 0,
  61. height: '',
  62. // 头部图高度
  63. maxheight: '',
  64. tabCurrentIndex: 0,
  65. orderStatusSum: 0,
  66. recharge: 0,
  67. navList: [
  68. {
  69. loadingType: 'more',
  70. orderList: [],
  71. page: 1, //当前页数
  72. limit: 10 //每次信息条数
  73. }
  74. ],
  75. money: ''
  76. };
  77. },
  78. computed: {
  79. ...mapState('user', ['userInfo'])
  80. },
  81. onReady(res) {
  82. var _this = this;
  83. uni.getSystemInfo({
  84. success: resu => {
  85. const query = uni.createSelectorQuery();
  86. query.select('.swiper-box').boundingClientRect();
  87. query.exec(function(res) {
  88. _this.height = resu.windowHeight - res[0].top + 'px';
  89. console.log('打印页面的剩余高度', _this.height);
  90. });
  91. },
  92. fail: res => {}
  93. });
  94. },
  95. // onPullDownRefresh() {
  96. // this.loadData()
  97. // },
  98. onLoad() {
  99. this.loadData();
  100. },
  101. methods: {
  102. ...mapMutations('user', ['setUserInfo', 'setOrderInfo']),
  103. async loadData() {
  104. let obj = this;
  105. //这里是将订单挂载到tab列表下
  106. // let index = this.tabCurrentIndex;
  107. let navItem = obj.navList[0];
  108. // let state = navItem.state;
  109. if (navItem.loaded === true) {
  110. //tab切换只有第一次需要加载数据
  111. return;
  112. }
  113. if (navItem.loadingType === 'loading') {
  114. //防止重复加载
  115. return;
  116. }
  117. // 修改当前对象状态为加载中
  118. navItem.loadingType = 'loading';
  119. // console.log(navItem.loadingType);
  120. getJl({
  121. page: navItem.page,
  122. limit: navItem.limit
  123. // pm: navItem.state
  124. })
  125. .then(({ data }) => {
  126. console.log(data.data, '2222');
  127. // obj.zc = data.zc
  128. // obj.sr = data.sr
  129. navItem.orderList = navItem.orderList.concat(data.data);
  130. console.log(navItem.orderList, 'item');
  131. navItem.page++;
  132. if (navItem.limit == data.data.length) {
  133. navItem.loadingType = 'more';
  134. } else {
  135. navItem.loadingType = 'noMore';
  136. }
  137. obj.$set(navItem, 'loaded', true);
  138. })
  139. .catch(e => {
  140. console.log(e);
  141. });
  142. }
  143. }
  144. };
  145. </script>
  146. <style lang="scss">
  147. //列表
  148. .swiper-box {
  149. .order-item:last-child {
  150. margin-bottom: 60rpx;
  151. }
  152. .order-item {
  153. padding: 20rpx 30rpx;
  154. line-height: 1.5;
  155. .title-box {
  156. .title {
  157. font-size: $font-lg;
  158. color: $font-color-base;
  159. }
  160. .time {
  161. font-size: $font-base;
  162. color: $font-color-light;
  163. }
  164. }
  165. .money {
  166. color: #fd5b23;
  167. font-size: $font-lg;
  168. text-align: right;
  169. .status {
  170. color: $font-color-light;
  171. }
  172. }
  173. }
  174. }
  175. .list-scroll-content {
  176. background: #ffffff;
  177. height: 100%;
  178. }
  179. .content {
  180. height: 100%;
  181. .empty-content {
  182. background-color: #ffffff;
  183. }
  184. }
  185. .btn-box {
  186. width: 674rpx;
  187. height: 88rpx;
  188. background: linear-gradient(0deg, #2e58ff, #32c6ff);
  189. border-radius: 44rpx;
  190. font-size: 36rpx;
  191. font-family: PingFang SC;
  192. font-weight: 500;
  193. color: #ffffff;
  194. text-align: center;
  195. line-height: 88rpx;
  196. position: fixed;
  197. bottom: 48rpx;
  198. left: 0;
  199. right: 0;
  200. margin: 0 auto;
  201. }
  202. </style>