order-list.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  1. <template>
  2. <view class="order-list">
  3. <!-- 自定义顶部 -->
  4. <cm-header
  5. title="订单列表"
  6. :leftButtonGroup="leftButtonGroup"
  7. @rightClick="handleRightClick"
  8. @init="headerNavInit"
  9. ></cm-header>
  10. <!-- tabs选项卡 -->
  11. <tui-tabs
  12. :tabs="tabs"
  13. selectedColor="#f83c6c"
  14. sliderBgColor="#f83c6c"
  15. :currentTab="currentTab"
  16. @change="tabChange"
  17. ></tui-tabs>
  18. <!-- 协销订单筛选 -->
  19. <order-dealer-filter @change="onFilterChange" v-if="isDealer"></order-dealer-filter>
  20. <!-- 页面轮播 -->
  21. <swiper
  22. :indicator-dots="false"
  23. :autoplay="false"
  24. :duration="400"
  25. :current="currentTab"
  26. @change="swiperChange"
  27. class="swiper"
  28. :style="[swiperHeight]"
  29. >
  30. <swiper-item v-for="(tab, index) in tabs" :key="index">
  31. <tui-skeleton v-if="isRefresh" :loadingType="3" :isLoading="true"></tui-skeleton>
  32. <scroll-view scroll-y="true" class="scroll-box" @scrolltolower="onScrollToLower">
  33. <!-- 订单列表为空 -->
  34. <template v-if="orderList.length <= 0 && !isLoading">
  35. <tui-no-data :imgUrl="staticUrl + 'icon-empty-address.png'" :imgHeight="230" :imgWidth="290">
  36. <view class="empty-tip">您还没有相关订单哟~~</view>
  37. </tui-no-data>
  38. </template>
  39. <template v-else>
  40. <view
  41. class="section"
  42. v-for="orderInfo in orderList"
  43. :key="orderInfo.orderId"
  44. @click="handleToDetail(orderInfo)"
  45. >
  46. <!-- 订单信息 -->
  47. <!-- <view class="order-info">
  48. <view class="order-no">
  49. <text class="label">订单编号:</text> <text>{{ orderInfo.orderNo }}</text>
  50. </view>
  51. <view class="order-time">
  52. <text class="label">下单时间:</text> <text>{{ orderInfo.orderTime }}</text>
  53. </view>
  54. <view class="order-status">{{ stateExpFormat(orderInfo.status) }}</view>
  55. </view> -->
  56. <!-- <tui-divider :height="48"></tui-divider> -->
  57. <!-- 商品列表 -->
  58. <view class="shop-list">
  59. <view
  60. class="shop-section"
  61. v-for="shopInfo in orderInfo.shopOrderList"
  62. :key="shopInfo.shopOrderId"
  63. >
  64. <order-supplier-area :shopInfo="shopInfo" :is-show-state="true"></order-supplier-area>
  65. </view>
  66. </view>
  67. <!-- 商品统计 -->
  68. <view class="total">
  69. <view class="count">共{{ orderInfo.productCount }}件商品</view>
  70. <view class="price">
  71. <template v-if="['31', '32', '33', '81', '82', '83'].includes(orderInfo.status)">
  72. <text class="label">已支付:</text>
  73. <text>¥{{ orderInfo.receiptAmount | priceFormat }}</text>
  74. </template>
  75. <template v-else>
  76. <text class="label">待付总额:</text>
  77. <text>¥{{ orderInfo.pendingPayments | priceFormat }}</text>
  78. </template>
  79. </view>
  80. </view>
  81. <!-- 操作订单 -->
  82. <view class="control">
  83. <order-contror
  84. v-if="orderInfo.userId == userId"
  85. :orderInfo="orderInfo"
  86. @confirm="handleConfirmClick"
  87. ></order-contror>
  88. </view>
  89. </view>
  90. </template>
  91. <cm-loadmore :hasMore="hasNextPage" :isLoading="isLoading" :visiable="visiable"></cm-loadmore>
  92. </scroll-view>
  93. </swiper-item>
  94. </swiper>
  95. <!-- 失效商品列表 -->
  96. <order-invalid-modal
  97. :goodsList="invalidList"
  98. :visible="buyAgainModal"
  99. @confirm="buyAgainModalClick"
  100. @cancel="buyAgainModalHide"
  101. ></order-invalid-modal>
  102. <!-- 操作弹窗 -->
  103. <tui-modal :show="modal" :content="modalText" @click="handleModalConfirm"></tui-modal>
  104. </view>
  105. </template>
  106. <script>
  107. import { fetchUserOrderList, fetchDealerOrderList } from '@/services/api/order.js'
  108. import { debounce } from '@/common/utils.js'
  109. import orderList from '@/pages/views/order/mixins/orderList.js'
  110. import wechatPay from '@/pages/views/order/mixins/wechatPay.js'
  111. import { mapGetters } from 'vuex'
  112. export default {
  113. mixins: [wechatPay, orderList],
  114. data() {
  115. return {
  116. // 布局
  117. headerNavHeight: 0,
  118. leftButtonGroup: [
  119. {
  120. icon: 'icon-daohangfanhui',
  121. color: '#333'
  122. }
  123. ],
  124. // tab栏目配置
  125. tabs: [
  126. {
  127. name: '全部',
  128. state: 0,
  129. mum: '',
  130. isDot: false,
  131. disabled: false
  132. },
  133. {
  134. name: '待付款',
  135. state: 1,
  136. mum: '',
  137. isDot: false,
  138. disabled: false
  139. },
  140. {
  141. name: '待分享',
  142. state: 5,
  143. mum: '',
  144. isDot: false,
  145. disabled: false
  146. },
  147. {
  148. name: '待发货',
  149. state: 2,
  150. mum: '',
  151. isDot: false,
  152. disabled: false
  153. },
  154. {
  155. name: '已发货',
  156. state: 3,
  157. mum: '',
  158. isDot: false,
  159. disabled: false
  160. },
  161. {
  162. name: '退货/款',
  163. state: 4,
  164. mum: '',
  165. isDot: false,
  166. disabled: false
  167. }
  168. ],
  169. currentTab: -1,
  170. // 查询参数
  171. listQuery: {
  172. orderState: 0,
  173. userId: 0,
  174. orderType: 0,
  175. pageNum: 1,
  176. pageSize: 10
  177. },
  178. orderList: [],
  179. total: 0,
  180. hasNextPage: true,
  181. isLoading: true,
  182. isRefresh: true
  183. }
  184. },
  185. computed: {
  186. ...mapGetters(['userId', 'userIdentity']),
  187. visiable() {
  188. return this.orderList.length > this.listQuery.pageSize
  189. },
  190. isDealer() {
  191. return this.userIdentity === 2
  192. },
  193. // 布局
  194. swiperHeight() {
  195. let offset = 44
  196. if (this.isDealer) {
  197. offset = 84
  198. }
  199. return {
  200. height: `calc(100vh - ${offset}px - ${this.headerNavHeight}px);`
  201. }
  202. }
  203. },
  204. onLoad(options) {
  205. this.currentTab = options.current
  206. this.init()
  207. },
  208. onShow() {
  209. if (this.currentTab !== -1) {
  210. this.initOrderList()
  211. }
  212. },
  213. methods: {
  214. init() {
  215. // 订单操作回调
  216. this.$on('orderAction', () => {
  217. this.initOrderList()
  218. })
  219. // 订单支付回调
  220. this.$on('orderPaySuccess', orderInfo => {
  221. this.initOrderList()
  222. if (orderInfo.collageFlag) {
  223. this.$router.navigateTo('share-buy/share-buy-detail?collageId=' + orderInfo.collageId)
  224. } else {
  225. uni.setStorageSync('PAY_ORDER_INFO', orderInfo)
  226. this.$router.navigateTo('order/pay-success')
  227. }
  228. })
  229. },
  230. // 初始化订单列表
  231. initOrderList() {
  232. this.listQuery.orderState = this.tabs[this.currentTab].state
  233. this.listQuery.userId = this.userId
  234. this.listQuery.pageNum = 1
  235. this.isRefresh = true
  236. this.hasNextPage = true
  237. this.fetchOrderList()
  238. },
  239. // 获取订单列表
  240. fetchOrderList: debounce(async function() {
  241. if (!this.hasNextPage) return
  242. this.isLoading = true
  243. if (this.isDealer) {
  244. this.fetchDealerOrderList()
  245. } else {
  246. this.fetchUserOrderList()
  247. }
  248. }),
  249. // 获取普通用户订单列表
  250. async fetchUserOrderList() {
  251. try {
  252. const res = await fetchUserOrderList(this.listQuery)
  253. if (this.isRefresh) {
  254. this.orderList = res.data.list
  255. } else {
  256. this.orderList = [...this.orderList, ...res.data.list]
  257. }
  258. this.total = res.data.total
  259. this.hasNextPage = res.data.hasNextPage
  260. this.listQuery.pageNum++
  261. this.isLoading = false
  262. this.isRefresh = false
  263. } catch (e) {
  264. console.log(e)
  265. }
  266. },
  267. // 获取分销者用户订单列表
  268. async fetchDealerOrderList() {
  269. try {
  270. const res = await fetchDealerOrderList(this.listQuery)
  271. if (this.isRefresh) {
  272. this.orderList = res.data.list
  273. } else {
  274. this.orderList = [...this.orderList, ...res.data.list]
  275. }
  276. this.total = res.data.total
  277. this.hasNextPage = res.data.hasNextPage
  278. this.listQuery.pageNum++
  279. this.isLoading = false
  280. this.isRefresh = false
  281. } catch (e) {
  282. console.log(e)
  283. }
  284. },
  285. // tab切换
  286. tabChange(e) {
  287. this.currentTab = e.index
  288. },
  289. // 轮播切换
  290. swiperChange(e) {
  291. this.currentTab = e.detail.current
  292. this.initOrderList()
  293. },
  294. // 协销筛选订单
  295. onFilterChange(id) {
  296. this.listQuery.orderType = id
  297. this.initOrderList()
  298. },
  299. // 搜索按钮点击
  300. handleRightClick() {
  301. this.$router.navigateTo('order/order-search')
  302. },
  303. // 订单详情
  304. handleToDetail(order) {
  305. this.$router.navigateTo('order/order-detail?orderId=' + order.orderId)
  306. },
  307. // 加载更多
  308. onScrollToLower() {
  309. this.fetchOrderList()
  310. },
  311. //自定义导航初始化
  312. headerNavInit(info) {
  313. this.headerNavHeight = info.height
  314. }
  315. }
  316. }
  317. </script>
  318. <style lang="scss" scoped>
  319. .scroll-box {
  320. height: 100%;
  321. box-sizing: border-box;
  322. }
  323. .section {
  324. padding: 24rpx;
  325. margin-bottom: 24rpx;
  326. background-color: #fff;
  327. .order-info {
  328. position: relative;
  329. line-height: 1.6;
  330. .order-no,
  331. .order-time {
  332. font-size: 26rpx;
  333. color: #333333;
  334. .label {
  335. color: #999999;
  336. }
  337. }
  338. .order-status {
  339. position: absolute;
  340. font-size: 26rpx;
  341. color: #ff457b;
  342. right: 0;
  343. bottom: 0;
  344. }
  345. }
  346. .shop-list {
  347. .shop-section {
  348. margin-bottom: 24rpx;
  349. &:last-child {
  350. margin-bottom: 0;
  351. }
  352. }
  353. }
  354. .total {
  355. display: flex;
  356. justify-content: space-between;
  357. align-items: center;
  358. margin-top: 24rpx;
  359. font-size: 26rpx;
  360. color: #333333;
  361. .count {
  362. font-weight: bold;
  363. }
  364. .price {
  365. color: #ff457b;
  366. .label {
  367. color: #333333;
  368. }
  369. }
  370. }
  371. .control {
  372. margin-top: 32rpx;
  373. }
  374. }
  375. </style>