order.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. <template>
  2. <view :class="['qn-page-' + theme]" style="height: 100vh">
  3. <view class="content">
  4. <view class="navbar">
  5. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="[tabCurrentIndex === index ? 'current' : '']" @click="tabClick(item, index)">
  6. {{ item.text }}
  7. <view class="current-line primary-btn"></view>
  8. </view>
  9. </view>
  10. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  11. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  12. <scroll-view @scrolltolower="scrollBootom" scroll-y="true" style="height:100%">
  13. <Aempty text="您还没有相关订单" src="https://onlineimg.qianniao.vip/order.png" v-if="orderList.length === 0"></Aempty>
  14. <view v-for="(item, index) in orderList" :key="index" class="order-item">
  15. <view class="clearfix order-no-view" @click="goPage(`/pagesT/order/orderDetail?id=` + item.id)">
  16. <text class="float_left order-no-text">{{ $_utils.formatDate(item.createTime) }}</text>
  17. <text class="float_right order-status-text">
  18. {{
  19. item.orderStatus === 1
  20. ? '待付款'
  21. : item.orderStatus === 2
  22. ? '待付款'
  23. : item.orderStatus === 3
  24. ? '待发货'
  25. : item.orderStatus === 4
  26. ? '待收货'
  27. : item.orderStatus === 5
  28. ? '已完成'
  29. : item.orderStatus === 6
  30. ? '已关闭'
  31. : item.orderStatus === 7
  32. ? '取消审核中'
  33. : ''
  34. }}
  35. </text>
  36. <text v-if="item.deliveryTypeMsg === '上门自提'" class="float_right order-status-text" style="font-weight: bold;margin-right: 20rpx;">
  37. 自提码:{{ item.verifyCode }}
  38. </text>
  39. </view>
  40. <view class="goods-ul" @click="goPage(`/pagesT/order/orderDetail?id=` + item.id)">
  41. <block v-for="(it, gindex) in item.goodsData" :key="gindex">
  42. <view class="goods-li clearfix" v-if="gindex <= 4">
  43. <image class="goods-img float_left" :src="it.images && it.images.length ? it.images[0] : ''" mode="aspectFill"></image>
  44. <view class="buyNum">x{{ it.isEq === 5 ? it.extends.u_1_buy : it.buyNum }}</view>
  45. <!-- <view class="float_right goods-right">
  46. <view class="goods-name">{{ it.goodsName }}</view>
  47. <view class="goods-descrip">
  48. 规格:{{ it.unitName }};
  49. <text v-for="(ip, indexSp) in it.specGroup" :key="indexSp">{{ ip.specValueName }};</text>
  50. </view>
  51. <view class="goods-price clearfix">
  52. <view class="float_left primary-color">¥{{ it.price }}</view>
  53. <view class="float_right">*{{ it.buyNum }}</view>
  54. </view>
  55. </view> -->
  56. </view>
  57. </block>
  58. <view class="goods-li" style="font-size: 20rpx;color: #666;">查看明细</view>
  59. </view>
  60. <view class="money-view">
  61. 共{{ item.goodsNum || 0 }}件商品,总价:¥{{ item.totalMoney || '0.00' }}
  62. <!-- <view class="price">
  63. 实付款:
  64. <text style="font-size: 20rpx;">¥</text>
  65. <view style="display: inline-block;font-size: 32rpx;"><rich-text :nodes="$_utils.splitPrice(item.payAmount)"></rich-text></view>
  66. </view> -->
  67. </view>
  68. <view class="middle clearfix" v-if="[1, 2, 3, 4, 5].includes(item.orderStatus)">
  69. <!-- #ifdef APP-PLUS||MP-WEIXIN -->
  70. <!-- (未付款||部分付款)&&订单状态不为已完成&&付款方式不为银行付款 -->
  71. <view
  72. class="btnSAdd float_right primary-btn"
  73. @click="goPay(item)"
  74. v-if="(parseInt(item.payStatus) === 4 || parseInt(item.payStatus) === 3) && item.orderStatus !== 5 && item.payType.indexOf('4') === -1"
  75. >
  76. 去付款
  77. </view>
  78. <!-- #endif -->
  79. <!-- 出库状态等于5 的时候可以确认收货 以及出库状态等于6加上退款状态等于5的状态可以确认收货 -->
  80. <view
  81. class="btnSAdd float_right primary-btn"
  82. v-if="(item.orderStatus === 4 && item.outStatus === 5) || (item.orderStatus === 4 && item.outStatus === 6 && item.isRet === 5)"
  83. @click="confirmOrder(item.id)"
  84. >
  85. 确认收货
  86. </view>
  87. <view @click="goPage('/pagesT/order/orderLogistics?id=' + item.id)" v-if="item.orderStatus > 3 && item.deliveryType === 1" class="btnS float_right">
  88. 查看物流
  89. </view>
  90. <view v-if="item.orderStatus === 5" class="btnSAdd float_right primary-btn" @click="againPay(item)">再次购买</view>
  91. <view v-if="item.payType.indexOf('4') > -1 && [1, 2].includes(item.orderStatus)" class="btnSAdd float_right primary-btn" @click="upBankPic(item)">
  92. 上传凭证
  93. </view>
  94. <view
  95. @click="cancelOrder(item)"
  96. v-if="[1, 2].includes(item.orderStatus) || (item.orderStatus === 3 && isCancelOrder === 5)"
  97. class="btnS float_right"
  98. >
  99. 取消订单
  100. </view>
  101. </view>
  102. </view>
  103. <u-loadmore margin-top="20" v-if="orderList.length" :status="loading_status" />
  104. </scroll-view>
  105. </swiper-item>
  106. </swiper>
  107. </view>
  108. <CancelOrder
  109. @confirm="cancelOrderConfirm"
  110. :payStatus="pay_status"
  111. :cancelbeforeOrderStatus="order_status"
  112. :orderId="order_id"
  113. @close="closeCancel"
  114. :show="cancel_show"
  115. ></CancelOrder>
  116. </view>
  117. </template>
  118. <script>
  119. import CancelOrder from './CancelOrder.vue';
  120. export default {
  121. components: {
  122. CancelOrder
  123. },
  124. data() {
  125. return {
  126. order_id: 0,
  127. order_status: '',
  128. pay_status: '',
  129. cancel_show: false,
  130. orderList: [],
  131. tabCurrentIndex: 0,
  132. state: 1,
  133. loading_status: 'loadmore',
  134. navList: [
  135. {
  136. state: 0,
  137. text: '全部'
  138. },
  139. {
  140. state: 2,
  141. text: '待付款'
  142. },
  143. {
  144. state: 3,
  145. text: '待发货'
  146. },
  147. {
  148. state: 4,
  149. text: '待收货'
  150. },
  151. {
  152. state: 5,
  153. text: '已完成'
  154. }
  155. // {
  156. // state: 6,
  157. // text: '已关闭',
  158. // }
  159. ],
  160. page: 1,
  161. pageSize: 10,
  162. pageTotal: 0,
  163. tmplIds: []
  164. };
  165. },
  166. computed: {
  167. // 是否在发货前可以取消订单
  168. isCancelOrder() {
  169. return this.$store.state.baseSet.cancelOrder || 5;
  170. }
  171. },
  172. onLoad(options) {
  173. this.tabCurrentIndex = +options.state;
  174. switch (this.tabCurrentIndex) {
  175. case 0:
  176. this.state = 0;
  177. break;
  178. case 1:
  179. this.state = 2;
  180. break;
  181. case 2:
  182. this.state = 3;
  183. break;
  184. case 3:
  185. this.state = 4;
  186. break;
  187. case 4:
  188. this.state = 5;
  189. break;
  190. case 5:
  191. this.state = 6;
  192. break;
  193. }
  194. // #ifdef MP-WEIXIN
  195. this.getSettingDataByMessageId();
  196. // #endif
  197. },
  198. onShow() {
  199. this.getOrderSelect();
  200. },
  201. methods: {
  202. closeCancel() {
  203. this.cancel_show = false;
  204. },
  205. // 上传打款凭证
  206. upBankPic(item) {
  207. const payAmount = item.payStatus === 3 ? item.notPayMoney : item.payAmount;
  208. this.goPage(`/pagesT/money/BankPay?orderId=${item.id}&payAmount=${payAmount}`, 'redirectTo');
  209. },
  210. // 再次购买
  211. againPay(row) {
  212. // if (this.$store.state.baseSet.personnelReview === 5) {
  213. // 验证账户状态
  214. this.userAudit();
  215. if (!this.isUserAudit) {
  216. return;
  217. }
  218. // }
  219. const goodsData = row.goodsData.map(item => {
  220. let obj = {};
  221. if (item.isEq === 5) {
  222. obj = {
  223. goodsId: item.goodsId,
  224. buyNum: item.extends.u_1_buy,
  225. shopId: item.shopId,
  226. skuId: item.extends.uId_1,
  227. source: this.$common.source(),
  228. goodsBasicId: item.goodsBasicId
  229. };
  230. } else {
  231. obj = {
  232. goodsId: item.goodsId,
  233. buyNum: item.buyNum,
  234. shopId: item.shopId,
  235. skuId: item.skuId,
  236. source: this.$common.source(),
  237. goodsBasicId: item.goodsBasicId
  238. };
  239. }
  240. return obj;
  241. });
  242. this.$u.api
  243. .addCart({
  244. goodsData: goodsData
  245. })
  246. .then(res => {
  247. this.goPage('/pages/cart/cart', 'switchTab');
  248. });
  249. },
  250. // 点击支付
  251. goPay(item) {
  252. const price = item.payStatus === 3 ? item.notPayMoney : item.payAmount;
  253. uni.navigateTo({
  254. url: `/pagesT/money/pay?id=${item.id}&price=${price}&no=${item.no}&payType=${item.payType}`
  255. });
  256. },
  257. scrollBootom() {
  258. if (this.pageTotal / this.pageSize > this.page) {
  259. this.page += 1;
  260. this.getOrderSelect();
  261. }
  262. },
  263. // 获取订单列表
  264. getOrderSelect() {
  265. const params = {
  266. page: this.page,
  267. pageSize: this.pageSize
  268. };
  269. if (this.state) {
  270. params.orderStatus = this.state;
  271. }
  272. this.loading_status = 'loading';
  273. this.$u.api
  274. .getOrderSelect({
  275. ...params
  276. })
  277. .then(res => {
  278. if (this.page === 1) {
  279. this.orderList = res.data;
  280. } else {
  281. this.orderList = this.orderList.concat(res.data);
  282. }
  283. this.pageTotal = res.pageTotal;
  284. this.loading_status = this.$_utils.loadStatus(this.page, this.pageSize, this.pageTotal);
  285. });
  286. },
  287. //swiper 切换
  288. changeTab(e) {
  289. this.tabCurrentIndex = e.target.current;
  290. this.page = 1;
  291. switch (this.tabCurrentIndex) {
  292. case 0:
  293. this.state = 0;
  294. break;
  295. case 1:
  296. this.state = 2;
  297. break;
  298. case 2:
  299. this.state = 3;
  300. break;
  301. case 3:
  302. this.state = 4;
  303. break;
  304. }
  305. this.orderList = [];
  306. this.getOrderSelect();
  307. },
  308. //顶部tab点击
  309. tabClick(item, index) {
  310. this.tabCurrentIndex = index;
  311. this.state = item.state;
  312. // this.getOrderSelect()
  313. },
  314. //取消订单
  315. cancelOrder(row) {
  316. this.cancelHandel(row);
  317. // #ifdef MP-WEIXIN
  318. if (this.tmplIds.length) {
  319. uni.requestSubscribeMessage({
  320. tmplIds: this.tmplIds,
  321. success: res => {
  322. this.cancelHandel(row);
  323. },
  324. fail: res => {
  325. console.log(res);
  326. this.cancelHandel(row);
  327. }
  328. });
  329. } else {
  330. this.cancelHandel(row);
  331. }
  332. // #endif
  333. // #ifdef APP-PLUS
  334. this.cancelHandel(row);
  335. // #endif
  336. },
  337. cancelHandel(row) {
  338. this.order_id = row.id;
  339. this.order_status = row.orderStatus;
  340. this.pay_status = row.payStatus;
  341. this.cancel_show = true;
  342. },
  343. cancelOrderConfirm() {
  344. this.getOrderSelect();
  345. },
  346. // 确认收货
  347. confirmOrder(id) {
  348. uni.showModal({
  349. title: '提示',
  350. content: '确定要确认收货吗?',
  351. success: res => {
  352. if (res.confirm) {
  353. this.$u.api
  354. .updateOrderStatus(id, {
  355. orderStatus: 5
  356. })
  357. .then(data => {
  358. this.$api.msg('操作成功');
  359. this.getOrderSelect();
  360. });
  361. }
  362. }
  363. });
  364. },
  365. // 获取消息模版ID 后台取消订单, 退款通知
  366. getSettingDataByMessageId() {
  367. this.$u.api
  368. .getSettingDataByMessageId({
  369. id: [5, 7]
  370. })
  371. .then(res => {
  372. if (res.data.length > 0) {
  373. this.tmplIds = res.data.map(item => {
  374. return item.weixinTemplateId;
  375. });
  376. }
  377. });
  378. }
  379. }
  380. };
  381. </script>
  382. <style lang="scss">
  383. .order-item {
  384. margin: 24upx 0;
  385. padding-bottom: 24rpx;
  386. background-color: #fff;
  387. .order-no-view {
  388. font-size: 24upx;
  389. padding: 24upx 30upx;
  390. color: #666;
  391. font-weight: 300;
  392. border-bottom: 1upx solid #eee;
  393. .order-status-text {
  394. font-weight: 500;
  395. }
  396. }
  397. .goods-li:last-child {
  398. margin-bottom: 0;
  399. }
  400. .goods-ul {
  401. padding: 20rpx 10rpx 0;
  402. .goods-li {
  403. margin: 0 10rpx;
  404. display: inline-block;
  405. text-align: center;
  406. line-height: 100rpx;
  407. background: #eeeeee;
  408. border-radius: 16rpx;
  409. overflow: hidden;
  410. width: 100upx;
  411. height: 100upx;
  412. .goods-img {
  413. width: 100%;
  414. height: 100%;
  415. }
  416. position: relative;
  417. .buyNum {
  418. position: absolute;
  419. font-size: 20rpx;
  420. color: #ffffff;
  421. line-height: 32rpx;
  422. background-color: rgba($color: #000000, $alpha: 0.6);
  423. padding: 0 10rpx;
  424. right: 0;
  425. bottom: 0;
  426. }
  427. }
  428. }
  429. .goods-li {
  430. // background: #fafafa;
  431. // padding: 30upx 20upx;
  432. // margin-bottom: 20upx;
  433. // margin-right: 10rpx;
  434. .goods-right {
  435. width: 500upx;
  436. margin-left: 20upx;
  437. .goods-name {
  438. color: #333;
  439. font-size: 32upx;
  440. margin-bottom: 19upx;
  441. text-overflow: -o-ellipsis-lastline;
  442. overflow: hidden;
  443. text-overflow: ellipsis;
  444. display: -webkit-box;
  445. -webkit-line-clamp: 1;
  446. line-clamp: 1;
  447. -webkit-box-orient: vertical;
  448. }
  449. .goods-descrip {
  450. font-size: 22upx;
  451. color: #999;
  452. margin-bottom: 28upx;
  453. // font-weight: 300;
  454. text-overflow: -o-ellipsis-lastline;
  455. overflow: hidden;
  456. text-overflow: ellipsis;
  457. display: -webkit-box;
  458. -webkit-line-clamp: 1;
  459. line-clamp: 1;
  460. -webkit-box-orient: vertical;
  461. }
  462. .goods-price {
  463. .price {
  464. color: $price-color;
  465. font-size: 40upx;
  466. }
  467. .sku {
  468. font-size: 22upx;
  469. font-weight: 300;
  470. color: #666;
  471. }
  472. .float_right {
  473. font-size: 24upx;
  474. }
  475. }
  476. }
  477. }
  478. }
  479. .money-view {
  480. color: #666666;
  481. text-align: right;
  482. font-size: 24upx;
  483. padding: 24upx 30upx;
  484. .price {
  485. font-size: 24upx;
  486. font-weight: bold;
  487. color: #000000;
  488. margin-left: 10rpx;
  489. display: inline-block;
  490. }
  491. }
  492. .middle {
  493. font-size: 24upx;
  494. position: relative;
  495. padding: 0 30upx;
  496. }
  497. .btnS {
  498. padding: 0 20upx;
  499. line-height: 50upx;
  500. color: #6e6e6e;
  501. font-size: 24upx;
  502. text-align: center;
  503. margin-left: 20upx;
  504. height: 50upx;
  505. background: rgba(241, 241, 241, 1);
  506. // box-shadow: 0px 2upx 14upx 0px rgba(0, 0, 0, 0.1);
  507. border-radius: 8upx;
  508. }
  509. .btnSAdd {
  510. padding: 0 20upx;
  511. line-height: 50upx;
  512. color: #ffffff;
  513. font-size: 24upx;
  514. text-align: center;
  515. height: 50upx;
  516. border-radius: 8upx;
  517. margin-left: 20rpx;
  518. }
  519. .content {
  520. background: $page-color-base;
  521. height: 100vh;
  522. }
  523. .swiper-box {
  524. height: calc(100% - 80upx);
  525. }
  526. .list-scroll-content {
  527. height: 100%;
  528. }
  529. .navbar {
  530. display: flex;
  531. height: 88upx;
  532. background: #fff;
  533. position: relative;
  534. z-index: 10;
  535. border-bottom: 1upx solid #eee;
  536. .nav-item {
  537. flex: 1;
  538. display: flex;
  539. justify-content: center;
  540. align-items: center;
  541. height: 100%;
  542. font-size: 28upx;
  543. color: #666666;
  544. position: relative;
  545. font-weight: 300;
  546. &.current {
  547. font-weight: 500;
  548. .current-line {
  549. content: '';
  550. position: absolute;
  551. left: 50%;
  552. bottom: 10upx;
  553. transform: translateX(-50%);
  554. width: 40upx;
  555. height: 6upx;
  556. background: $base-btn-bg;
  557. border-radius: 6upx;
  558. /*border-bottom: 2px solid #F53C28;*/
  559. }
  560. }
  561. }
  562. }
  563. </style>