order.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view class="all">
  3. <view class="navbar">
  4. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  5. </view>
  6. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  7. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  8. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  9. <!-- 空白页 -->
  10. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  11. <!-- 订单列表 -->
  12. <view @click="goToOrderDetail(item)" v-for="(item, index) in tabItem.orderList" :key="index" class="order-item">
  13. <view class="i-top b-b">
  14. <text class="time">{{ item._add_time }}</text>
  15. <text class="state" :style="{ color: item.stateTipColor }">{{ item._status._title }}</text>
  16. <text v-if="item.status === 4" class="del-btn iconfont icondelete" @click="deleteOrder(index)"></text>
  17. </view>
  18. <scroll-view v-if="item.cartInfo.length > 1" class="goods-box" scroll-x>
  19. <view v-for="(goodsItem, goodsIndex) in item.cartInfo" :key="goodsIndex" class="goods-item">
  20. <image class="goods-img" :src="goodsItem.productInfo.image" mode="aspectFill"></image>
  21. </view>
  22. </scroll-view>
  23. <!-- <view v-if="item.cartInfo.length === 1" class="goods-box-single" v-for="(goodsItem, goodsIndex) in item.cartInfo" :key="goodsIndex">
  24. <image class="goods-img" :src="goodsItem.productInfo.image" mode="aspectFill"></image>
  25. <view class="right">
  26. <text class="title clamp">{{ goodsItem.productInfo.store_name }}</text>
  27. <text class="attr-box">{{ goodsItem.attrInfo ? goodsItem.attrInfo.suk : '' }} x {{ goodsItem.cart_num }}</text>
  28. <text class="price">{{ moneyNum(goodsItem.productInfo.price)}}</text>
  29. </view>
  30. </view> -->
  31. <view class="goods-box-single" v-for="(goodsItem, goodsIndex) in item.cartInfo" :key="goodsIndex">
  32. <image class="goods-img" :src="goodsItem.productInfo.image" mode="scaleToFill"></image>
  33. <view class="right">
  34. <view class="flex-start">
  35. <text class="title clamp">{{ goodsItem.productInfo.store_name }}</text>
  36. <text class="price">{{ goodsItem.productInfo.price|moneyNum }}</text>
  37. </view>
  38. <view class="row flex">
  39. <text class="row_title">{{ goodsItem.productInfo.attrInfo ? goodsItem.productInfo.attrInfo.suk : '' }}</text>
  40. <text class="attr-box"> x {{ goodsItem.cart_num }}</text>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="price-box">
  45. <text class="num">{{ item.cartInfo.length }}</text>
  46. 件商品 邮费
  47. <text class="price">{{ moneyNum(item.pay_postage)}}</text>
  48. 实付款
  49. <text class="price">{{ moneyNum(item.pay_price)}}</text>
  50. </view>
  51. <view class="action-box b-t" v-if="item.status != 5">
  52. <button v-if="item._status._title == '未支付'" class="action-btn" @click.stop="cancelOrder(item)">取消订单</button>
  53. <button v-if="item._status._title == '未支付'" @click.stop="orderPay(item)" class="action-btn recom">立即支付</button>
  54. <button v-if="item._status._title == '待评价'" class="action-btn">评价</button>
  55. <button v-if="item._status._title == '待收货'" @click.stop="orderTake(item, index)" class="action-btn">确认收货</button>
  56. <button v-if="item._status._title == '未发货'" class="action-btn" @click.stop="orderRefund(item)">申请退款</button>
  57. </view>
  58. </view>
  59. <uni-load-more :status="tabItem.loadingType" color='#FFF'></uni-load-more>
  60. </scroll-view>
  61. </swiper-item>
  62. </swiper>
  63. </view>
  64. </template>
  65. <script>
  66. import {
  67. getsell
  68. } from '@/api/game.js';
  69. import {
  70. mapState
  71. } from 'vuex';
  72. export default {
  73. computed: {
  74. ...mapState('user', ['hasLogin'])
  75. },
  76. data() {
  77. return {
  78. tabCurrentIndex: 0,
  79. navList: [
  80. {
  81. state: 0,
  82. text: '待付款',
  83. loadingType: 'more',
  84. orderList: [],
  85. page: 1, //当前页数
  86. limit: 10 //每次信息条数
  87. },
  88. {
  89. state: 1,
  90. text: '待发货',
  91. loadingType: 'more',
  92. orderList: [],
  93. page: 1, //当前页数
  94. limit: 10 //每次信息条数
  95. },
  96. {
  97. state: 2,
  98. text: '待收货',
  99. loadingType: 'more',
  100. orderList: [],
  101. page: 1, //当前页数
  102. limit: 10 //每次信息条数
  103. },
  104. {
  105. state: 3,
  106. text: '待评价',
  107. loadingType: 'more',
  108. orderList: [],
  109. page: 1, //当前页数
  110. limit: 10 //每次信息条数
  111. },
  112. {
  113. state: 4,
  114. text: '已完成',
  115. loadingType: 'more',
  116. orderList: [],
  117. page: 1, //当前页数
  118. limit: 10 //每次信息条数
  119. }
  120. ]
  121. }
  122. },
  123. onNavigationBarButtonTap(res){
  124. console.log(res,['res']);
  125. },
  126. onLoad() {
  127. this.loadData()
  128. },
  129. onReachBottom() {
  130. this.loadData()
  131. },
  132. methods: {
  133. nav(url) {
  134. if (!this.hasLogin) {
  135. // 保存地址
  136. saveUrl();
  137. // 登录拦截
  138. interceptor();
  139. } else {
  140. uni.navigateTo({
  141. url
  142. });
  143. }
  144. },
  145. loadData(source) {
  146. //这里是将订单挂载到tab列表下
  147. let index = this.tabCurrentIndex;
  148. let navItem = this.navList[index];
  149. let state = navItem.state;
  150. if (source === 'tabChange' && navItem.loaded === true) {
  151. //tab切换只有第一次需要加载数据
  152. return;
  153. }
  154. if (navItem.loadingType === 'loading') {
  155. //防止重复加载
  156. return;
  157. }
  158. if (navItem.loadingType === 'noMore') {
  159. //防止重复加载
  160. return;
  161. }
  162. // 修改当前对象状态为加载中
  163. navItem.loadingType = 'loading';
  164. if(index==0){
  165. getsell({
  166. type: state,
  167. page: navItem.page,
  168. limit: navItem.limit
  169. })
  170. .then(({ data }) => {
  171. let arr = data.map(e => {
  172. let b = this.orderStateExp(e.status);
  173. e.stateTip = b.stateTip;
  174. e.stateTipColor = b.stateTipColor;
  175. return e;
  176. });
  177. navItem.orderList = navItem.orderList.concat(arr);
  178. // console.log(navItem.orderList);
  179. navItem.page++;
  180. if (navItem.limit == data.length) {
  181. //判断是否还有数据, 有改为 more, 没有改为noMore
  182. navItem.loadingType = 'more';
  183. return;
  184. } else {
  185. //判断是否还有数据, 有改为 more, 没有改为noMore
  186. navItem.loadingType = 'noMore';
  187. }
  188. uni.hideLoading();
  189. this.$set(navItem, 'loaded', true);
  190. })
  191. .catch(e => {
  192. console.log(e);
  193. });
  194. }
  195. },
  196. }
  197. };
  198. </script>
  199. <style lang="scss">
  200. .all {
  201. width: 750rpx;
  202. height: 100%;
  203. background-color: #051137;
  204. padding-top: var(--status-bar-height);
  205. }
  206. </style>