adminOrder.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697
  1. <template>
  2. <view class="content">
  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. <!-- <view class=""></view> -->
  15. <text class="time">订单编号:{{ item.order_id }}</text>
  16. <text class="state" style=" color: #901b21; ">{{ item.status_name }}</text>
  17. <text v-if="item.status === 4" class="del-btn iconfont icondelete" @click="deleteOrder(index)"></text>
  18. </view>
  19. <!-- <scroll-view v-if="item.cartInfo.length > 1" class="goods-box" scroll-x>
  20. <view v-for="(goodsItem, goodsIndex) in item._info" :key="goodsIndex" class="goods-item">
  21. <image class="goods-img" :src="goodsItem.productInfo.image" mode="aspectFill"></image>
  22. </view>
  23. </scroll-view> -->
  24. <view class="goods-box-single" v-for="(goodsItem, goodsIndex) in item._info" :key="goodsIndex">
  25. <image class="goods-img" :src="goodsItem.cart_info.productInfo.image" mode="scaleToFill"></image>
  26. <view class="right">
  27. <view class="flex-start">
  28. <text class="title clamp2">{{ goodsItem.cart_info.productInfo.store_name }}</text>
  29. <text class="price" style="flex-grow: 1;text-align: right;color: #901B21;font-size: 30rpx;font-weight: bold;">
  30. {{ goodsItem.cart_info.productInfo.price | moneyNum }}
  31. </text>
  32. </view>
  33. <view class="row flex">
  34. <!-- <view class="row_title" v-if="item.shipping_type === 1">送货上门</view>
  35. <view class="row_title" v-else>门店自提</view> -->
  36. <!-- <text class="row_title">{{ goodsItem.productInfo.attrInfo ? goodsItem.productInfo.attrInfo.suk : '' }}</text> -->
  37. <text class="attr-box">x {{ goodsItem.cart_info.cart_num }}</text>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="price-box">
  42. <text class="num">{{ item._info.length }}</text>
  43. 件商品 邮费 合计
  44. <text class="price">{{ moneyNum(item.pay_price) }}</text>
  45. (含运费
  46. <text class="price">{{ moneyNum(item.pay_postage) }}</text>
  47. </view>
  48. <!-- <view class="action-box b-t" v-if="item.status != 5">
  49. <button v-if="item._status._title == '未支付'" class="action-btn" @click.stop="cancelOrder(item)">取消订单</button>
  50. <button v-if="item._status._title == '未支付'" @click.stop="orderPay(item)" class="action-btn recom">立即支付</button>
  51. <button v-if="item._status._title == '待评价'" class="action-btn">评价</button>
  52. <button v-if="item._status._title == '待收货'" @click.stop="orderTake(item, index)" class="action-btn">确认收货</button>
  53. <button v-if="item._status._title == '未发货'" class="action-btn" @click.stop="orderRefund(item)">申请退款</button>
  54. </view> -->
  55. </view>
  56. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  57. </scroll-view>
  58. </swiper-item>
  59. </swiper>
  60. </view>
  61. </template>
  62. <script>
  63. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  64. import empty from '@/components/empty';
  65. import { orderList, orderCancel, orderDel, orderTake, GetAdminOrderList } from '@/api/order.js';
  66. export default {
  67. components: {
  68. uniLoadMore,
  69. empty
  70. },
  71. filters: {
  72. moneyNum(value) {
  73. return +value;
  74. }
  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. isUser: true
  122. };
  123. },
  124. onLoad(options) {
  125. /**
  126. * 修复app端点击除全部订单外的按钮进入时不加载数据的问题
  127. * 替换onLoad下代码即可
  128. */
  129. console.log(options);
  130. this.isUser = options.isUser;
  131. console.log(this.isUser);
  132. this.tabCurrentIndex = +options.state;
  133. // if(options.state == '4') {
  134. // this.tabCurrentIndex = 3
  135. // }
  136. // #ifndef MP
  137. this.loadData();
  138. // #endif
  139. // #ifdef MP
  140. if (options.state == 0) {
  141. this.loadData();
  142. }
  143. // #endif
  144. },
  145. // #ifdef APP-PLUS || H5
  146. onBackPress(e) {
  147. uni.switchTab({
  148. url: '/pages/user/user'
  149. });
  150. return true;
  151. },
  152. // #endif
  153. methods: {
  154. // 转换金额为数字
  155. moneyNum(value) {
  156. return +value;
  157. },
  158. // 确认收货
  159. orderTake(item, index) {
  160. let obj = this;
  161. uni.showModal({
  162. title: '是否确认收货?',
  163. success: res => {
  164. if (res.confirm) {
  165. orderTake({
  166. uni: item.order_id
  167. })
  168. .then(e => {
  169. obj.navList[obj.tabCurrentIndex].orderList.splice(index, 1);
  170. uni.showToast({
  171. title: '收货成功'
  172. });
  173. })
  174. .catch(e => {
  175. console.log(e);
  176. });
  177. } else if (res.cancel) {
  178. console.log('取消');
  179. }
  180. }
  181. });
  182. },
  183. //跳转到订单详情
  184. goToOrderDetail(e) {
  185. // uni.navigateTo({
  186. // url: '/pages/order/orderDetail?id=' + e.order_id
  187. // });
  188. },
  189. // 申请退款
  190. orderRefund(e) {
  191. uni.navigateTo({
  192. url: '/pages/order/orderRefund?id=' + e.order_id
  193. });
  194. },
  195. // 订单支付
  196. orderPay(e) {
  197. uni.navigateTo({
  198. url: '/pages/money/pay?type=1&ordid=' + e.order_id + '&money=' + e.pay_price
  199. });
  200. },
  201. //获取订单列表
  202. loadData(source) {
  203. //这里是将订单挂载到tab列表下
  204. let index = this.tabCurrentIndex;
  205. let navItem = this.navList[index];
  206. let state = navItem.state;
  207. if (source === 'tabChange' && navItem.loaded === true) {
  208. //tab切换只有第一次需要加载数据
  209. return;
  210. }
  211. if (navItem.loadingType === 'loading') {
  212. //防止重复加载
  213. return;
  214. }
  215. if (navItem.loadingType === 'noMore') {
  216. //防止重复加载
  217. return;
  218. }
  219. // 修改当前对象状态为加载中
  220. navItem.loadingType = 'loading';
  221. GetAdminOrderList({
  222. status: state,
  223. page: navItem.page,
  224. limit: navItem.limit
  225. })
  226. .then(({ data }) => {
  227. console.log(data, 'ddddddddddd');
  228. let arr = data.map(e => {
  229. let b = this.orderStateExp(e.status);
  230. e.stateTip = b.stateTip;
  231. e.stateTipColor = b.stateTipColor;
  232. return e;
  233. });
  234. navItem.orderList = navItem.orderList.concat(arr);
  235. console.log(navItem.orderList);
  236. navItem.page++;
  237. if (navItem.limit == data.length) {
  238. //判断是否还有数据, 有改为 more, 没有改为noMore
  239. navItem.loadingType = 'more';
  240. return;
  241. } else {
  242. //判断是否还有数据, 有改为 more, 没有改为noMore
  243. navItem.loadingType = 'noMore';
  244. }
  245. uni.hideLoading();
  246. this.$set(navItem, 'loaded', true);
  247. })
  248. .catch(e => {
  249. console.log(e);
  250. });
  251. },
  252. //swiper 切换
  253. changeTab(e) {
  254. this.tabCurrentIndex = e.target.current;
  255. this.loadData('tabChange');
  256. },
  257. //顶部tab点击
  258. tabClick(index) {
  259. console.log(index);
  260. this.tabCurrentIndex = index;
  261. },
  262. //删除订单
  263. deleteOrder(index) {
  264. uni.showLoading({
  265. title: '请稍后'
  266. });
  267. setTimeout(() => {
  268. this.navList[this.tabCurrentIndex].orderList.splice(index, 1);
  269. uni.hideLoading();
  270. }, 600);
  271. },
  272. //取消订单
  273. cancelOrder(item) {
  274. uni.showModal({
  275. title: '订单取消',
  276. content: '是否取消订单?',
  277. success: e => {
  278. if (e.confirm) {
  279. uni.showLoading({
  280. title: '请稍后'
  281. });
  282. orderCancel({ id: item.order_id })
  283. .then(e => {
  284. uni.showToast({
  285. title: '取消成功',
  286. duration: 2000,
  287. position: 'top'
  288. });
  289. })
  290. .catch(e => {
  291. console.log(e);
  292. });
  293. //取消订单后删除待付款中该项
  294. let list = this.navList[this.tabCurrentIndex].orderList;
  295. let index = list.findIndex(val => val.id === item.id);
  296. index !== -1 && list.splice(index, 1);
  297. uni.hideLoading();
  298. }
  299. }
  300. });
  301. },
  302. //订单状态文字和颜色
  303. orderStateExp(state) {
  304. let stateTip = '',
  305. stateTipColor = '#fa436a';
  306. switch (+state) {
  307. case 0:
  308. stateTip = '待付款';
  309. break;
  310. case 1:
  311. stateTip = '待发货';
  312. break;
  313. case 2:
  314. stateTip = '待收货';
  315. break;
  316. case 3:
  317. stateTip = '待评价';
  318. break;
  319. case 4:
  320. stateTip = '已完成';
  321. stateTipColor = '#901b21';
  322. break;
  323. case 9:
  324. stateTip = '订单已关闭';
  325. stateTipColor = '#909399';
  326. break;
  327. //更多自定义
  328. }
  329. return { stateTip, stateTipColor };
  330. }
  331. }
  332. };
  333. </script>
  334. <style lang="scss">
  335. page,
  336. .content {
  337. background: $page-color-base;
  338. height: 100%;
  339. }
  340. .swiper-box {
  341. height: calc(100% - 40px);
  342. }
  343. .list-scroll-content {
  344. height: 100%;
  345. }
  346. .navbar {
  347. display: flex;
  348. height: 40px;
  349. padding: 0 5px;
  350. background: #fff;
  351. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  352. position: relative;
  353. z-index: 10;
  354. .nav-item {
  355. flex: 1;
  356. display: flex;
  357. justify-content: center;
  358. align-items: center;
  359. height: 100%;
  360. font-size: 15px;
  361. color: $font-color-dark;
  362. position: relative;
  363. &.current {
  364. color: $base-color;
  365. &:after {
  366. content: '';
  367. position: absolute;
  368. left: 50%;
  369. bottom: 0;
  370. transform: translateX(-50%);
  371. width: 44px;
  372. height: 0;
  373. border-bottom: 2px solid $base-color;
  374. }
  375. }
  376. }
  377. }
  378. .uni-swiper-item {
  379. height: auto;
  380. }
  381. .order-item {
  382. display: flex;
  383. flex-direction: column;
  384. padding-left: 30rpx;
  385. background: #fff;
  386. margin-top: 16rpx;
  387. .i-top {
  388. display: flex;
  389. align-items: center;
  390. height: 80rpx;
  391. padding-right: 30rpx;
  392. font-size: $font-base;
  393. color: $font-color-dark;
  394. position: relative;
  395. .time {
  396. flex: 1;
  397. }
  398. .state {
  399. color: $base-color;
  400. }
  401. .del-btn {
  402. padding: 10rpx 0 10rpx 36rpx;
  403. font-size: $font-lg;
  404. color: $font-color-light;
  405. position: relative;
  406. &:after {
  407. content: '';
  408. width: 0;
  409. height: 30rpx;
  410. border-left: 1px solid $border-color-dark;
  411. position: absolute;
  412. left: 20rpx;
  413. top: 50%;
  414. transform: translateY(-50%);
  415. }
  416. }
  417. }
  418. /* 多条商品 */
  419. .goods-box {
  420. height: 160rpx;
  421. padding: 20rpx 0;
  422. white-space: nowrap;
  423. .goods-item {
  424. width: 120rpx;
  425. height: 120rpx;
  426. display: inline-block;
  427. margin-right: 24rpx;
  428. }
  429. .goods-img {
  430. display: block;
  431. width: 100%;
  432. height: 100%;
  433. }
  434. }
  435. /* 单条商品 */
  436. .goods-box-single {
  437. display: flex;
  438. padding: 20rpx 0;
  439. .goods-img {
  440. display: block;
  441. width: 120rpx;
  442. height: 120rpx;
  443. }
  444. .right {
  445. flex: 1;
  446. display: flex;
  447. flex-direction: column;
  448. padding: 0 30rpx 0 24rpx;
  449. overflow: hidden;
  450. .row {
  451. margin-top: 10rpx;
  452. justify-content: space-between;
  453. }
  454. .row_title {
  455. // padding:5rpx 10rpx;
  456. // background-color: #dddddd;
  457. // border-radius: 10rpx;
  458. // font-size: 22rpx;
  459. // color: #ffffff;
  460. display: inline-block;
  461. padding: 7rpx 11rpx;
  462. font-size: 20rpx;
  463. font-family: PingFang SC;
  464. font-weight: 500;
  465. color: #fd5b23;
  466. background: #ffeae5;
  467. border-radius: 5rpx;
  468. }
  469. .title {
  470. font-size: $font-base + 2rpx;
  471. color: $font-color-dark;
  472. line-height: 1;
  473. width: 80%;
  474. }
  475. .attr-box {
  476. display: flex;
  477. justify-content: flex-end;
  478. font-size: $font-sm + 2rpx;
  479. color: $font-color-light;
  480. }
  481. .price {
  482. display: inline;
  483. font-size: $font-base + 2rpx;
  484. color: $font-color-dark;
  485. &:before {
  486. content: '¥';
  487. font-size: $font-sm;
  488. }
  489. }
  490. }
  491. }
  492. .price-box {
  493. display: flex;
  494. justify-content: flex-end;
  495. align-items: baseline;
  496. padding: 20rpx 30rpx;
  497. font-size: $font-sm + 2rpx;
  498. color: $font-color-light;
  499. .num {
  500. margin: 0 8rpx;
  501. color: $font-color-dark;
  502. }
  503. .price {
  504. font-size: $font-lg;
  505. color: $font-color-dark;
  506. &:before {
  507. content: '¥';
  508. font-size: $font-sm;
  509. margin: 0 2rpx 0 8rpx;
  510. }
  511. }
  512. }
  513. .action-box {
  514. display: flex;
  515. justify-content: flex-end;
  516. align-items: center;
  517. height: 100rpx;
  518. position: relative;
  519. padding-right: 30rpx;
  520. }
  521. .action-btn {
  522. width: 160rpx;
  523. height: 60rpx;
  524. margin: 0;
  525. margin-left: 24rpx;
  526. padding: 0;
  527. text-align: center;
  528. line-height: 60rpx;
  529. font-size: $font-sm + 2rpx;
  530. color: $font-color-dark;
  531. background: #fff;
  532. border-radius: 100px;
  533. &:after {
  534. border-radius: 100px;
  535. }
  536. &.recom {
  537. color: $base-color;
  538. &:after {
  539. border-color: $base-color;
  540. }
  541. }
  542. &.evaluate {
  543. color: $color-yellow;
  544. &:after {
  545. border-color: $color-yellow;
  546. }
  547. }
  548. }
  549. }
  550. /* load-more */
  551. .uni-load-more {
  552. display: flex;
  553. flex-direction: row;
  554. height: 80rpx;
  555. align-items: center;
  556. justify-content: center;
  557. }
  558. .uni-load-more__text {
  559. font-size: 28rpx;
  560. color: #999;
  561. }
  562. .uni-load-more__img {
  563. height: 24px;
  564. width: 24px;
  565. margin-right: 10px;
  566. }
  567. .uni-load-more__img > view {
  568. position: absolute;
  569. }
  570. .uni-load-more__img > view view {
  571. width: 6px;
  572. height: 2px;
  573. border-top-left-radius: 1px;
  574. border-bottom-left-radius: 1px;
  575. background: #999;
  576. position: absolute;
  577. opacity: 0.2;
  578. transform-origin: 50%;
  579. animation: load 1.56s ease infinite;
  580. }
  581. .uni-load-more__img > view view:nth-child(1) {
  582. transform: rotate(90deg);
  583. top: 2px;
  584. left: 9px;
  585. }
  586. .uni-load-more__img > view view:nth-child(2) {
  587. transform: rotate(180deg);
  588. top: 11px;
  589. right: 0;
  590. }
  591. .uni-load-more__img > view view:nth-child(3) {
  592. transform: rotate(270deg);
  593. bottom: 2px;
  594. left: 9px;
  595. }
  596. .uni-load-more__img > view view:nth-child(4) {
  597. top: 11px;
  598. left: 0;
  599. }
  600. .load1,
  601. .load2,
  602. .load3 {
  603. height: 24px;
  604. width: 24px;
  605. }
  606. .load2 {
  607. transform: rotate(30deg);
  608. }
  609. .load3 {
  610. transform: rotate(60deg);
  611. }
  612. .load1 view:nth-child(1) {
  613. animation-delay: 0s;
  614. }
  615. .load2 view:nth-child(1) {
  616. animation-delay: 0.13s;
  617. }
  618. .load3 view:nth-child(1) {
  619. animation-delay: 0.26s;
  620. }
  621. .load1 view:nth-child(2) {
  622. animation-delay: 0.39s;
  623. }
  624. .load2 view:nth-child(2) {
  625. animation-delay: 0.52s;
  626. }
  627. .load3 view:nth-child(2) {
  628. animation-delay: 0.65s;
  629. }
  630. .load1 view:nth-child(3) {
  631. animation-delay: 0.78s;
  632. }
  633. .load2 view:nth-child(3) {
  634. animation-delay: 0.91s;
  635. }
  636. .load3 view:nth-child(3) {
  637. animation-delay: 1.04s;
  638. }
  639. .load1 view:nth-child(4) {
  640. animation-delay: 1.17s;
  641. }
  642. .load2 view:nth-child(4) {
  643. animation-delay: 1.3s;
  644. }
  645. .load3 view:nth-child(4) {
  646. animation-delay: 1.43s;
  647. }
  648. @-webkit-keyframes load {
  649. 0% {
  650. opacity: 1;
  651. }
  652. 100% {
  653. opacity: 0.2;
  654. }
  655. }
  656. </style>