orderAdmin.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636
  1. <template>
  2. <view class="content">
  3. <view class="navbar">
  4. <view v-for="(item, index) in navList" :key="index" class="nav-item"
  5. :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}
  6. <template v-if="item.ordertype">
  7. <template v-if="shopOrderDetail[item.ordertype]>0">
  8. (<text v-if="shopOrderDetail[item.ordertype]>99">99+</text>
  9. <text v-else>{{shopOrderDetail[item.ordertype]}}</text>)
  10. </template>
  11. </template>
  12. </view>
  13. </view>
  14. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  15. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  16. <scroll-view class="list-scroll-content padding-t-30" scroll-y @scrolltolower="loadData">
  17. <!-- 空白页 -->
  18. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  19. <!-- 订单列表 -->
  20. <view @click="goToOrderDetail(item)" v-for="(item, index) in tabItem.orderList" :key="index"
  21. class="order-item position-relative">
  22. <view class="i-top b-b flex">
  23. <view class="order-code flex">
  24. <view class="no">
  25. 订单编号:
  26. </view>
  27. <view>
  28. {{ item.order_id }}
  29. </view>
  30. </view>
  31. <text class="font-size-sm"
  32. :style="{ color: item.stateTipColor }">{{ item.status_name }}</text>
  33. </view>
  34. <scroll-view v-if="item._info.length > 0" class="goods-box" scroll-x>
  35. <view v-for="(goodsItem, goodsIndex) in item._info" :key="goodsIndex" class="goods-item">
  36. <image class="goods-img" :src="goodsItem.cart_info.productInfo.image" mode="aspectFill">
  37. </image>
  38. <view class="good-name clamp">
  39. {{goodsItem.cart_info.productInfo.suk}}*{{goodsItem.cart_info.cart_num}}
  40. </view>
  41. </view>
  42. </scroll-view>
  43. <view class="info-info">
  44. <view class="js">
  45. 共{{item._info.length}}件
  46. </view>
  47. <view class="hj">
  48. 合计:¥{{item.pay_price}}
  49. </view>
  50. </view>
  51. <!-- 客户信息 -->
  52. <view class="kh-info">
  53. <view class="">
  54. 客户信息:<text>{{item.user_address_info.real_name}} {{item.user_address_info.phone}}</text>
  55. </view>
  56. <view class="">
  57. 配送地址:<text>{{item.user_address_info.locate_address}}</text>
  58. </view>
  59. </view>
  60. <!-- 底部操作栏 -->
  61. <view class="btm-btn-wrap flex">
  62. <view class="btm-left">
  63. 下单时间:{{item.add_time.split(' ')[0].replace(/-/g,'/')}}
  64. </view>
  65. <view class="btm-right flex">
  66. <view class="btm-btn" @click.stop="toCall(item.user_address_info.phone)">
  67. 联系客户
  68. </view>
  69. <view class="btm-btn ksps" @click.stop="actionItem = item"
  70. v-if=" item.status_name=='未发货' &&shopOrderDetail.is_main_store">
  71. <picker mode="selector" :range="kflist" range-key="staff_name" @change="changeKf">
  72. <view>开始配送</view>
  73. </picker>
  74. </view>
  75. <view class="btm-btn ksps" v-if=" item.status_name=='待收货'" @click.stop="shopNext(item)">
  76. 导航
  77. </view>
  78. <view class="btm-btn ksps" v-if=" item.status_name=='未支付'&&shopOrderDetail.is_main_store" @click.stop="payMoney(item)">
  79. 确认支付
  80. </view>
  81. </view>
  82. </view>
  83. </view>
  84. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  85. </scroll-view>
  86. </swiper-item>
  87. </swiper>
  88. </view>
  89. </template>
  90. <script>
  91. import {
  92. adminkf,
  93. GetAdminOrderList,
  94. adminStatistics,
  95. deliveryKeep,
  96. offlinePay
  97. } from '@/api/water.js';
  98. import {
  99. mapState,
  100. mapMutations
  101. } from 'vuex';
  102. export default {
  103. data() {
  104. return {
  105. kflist: [], //客服列表
  106. actionKf: {
  107. staff_name: '',
  108. id: ''
  109. }, //选中的客服
  110. actionItem: {}, //保存当前配送对象
  111. tabCurrentIndex: 0,
  112. navList: [{
  113. state: 0,
  114. text: '待付款',
  115. loadingType: 'more',
  116. orderList: [],
  117. page: 1, //当前页数
  118. limit: 10, //每次信息条数
  119. ordertype: 'unpaid_count'
  120. },
  121. {
  122. state: 1,
  123. text: '待发货',
  124. loadingType: 'more',
  125. orderList: [],
  126. page: 1, //当前页数
  127. limit: 10, //每次信息条数
  128. ordertype: 'unshipped_count'
  129. },
  130. {
  131. state: 2,
  132. text: '待收货',
  133. loadingType: 'more',
  134. orderList: [],
  135. page: 1, //当前页数
  136. limit: 10, //每次信息条数
  137. ordertype: 'received_count'
  138. },
  139. {
  140. state: 3,
  141. text: '待评价',
  142. loadingType: 'more',
  143. orderList: [],
  144. page: 1, //当前页数
  145. limit: 10, //每次信息条数
  146. },
  147. {
  148. state: 4,
  149. text: '已完成',
  150. loadingType: 'more',
  151. orderList: [],
  152. page: 1, //当前页数
  153. limit: 10, //每次信息条数
  154. }
  155. ]
  156. };
  157. },
  158. computed: {
  159. ...mapState('shop', ['shopOrderDetail'])
  160. },
  161. onLoad(options) {
  162. /**
  163. * 修复app端点击除全部订单外的按钮进入时不加载数据的问题
  164. * 替换onLoad下代码即可
  165. */
  166. this.tabCurrentIndex = +options.state;
  167. // #ifndef MP
  168. this.loadData();
  169. // #endif
  170. // #ifdef MP
  171. if (options.state == 0) {
  172. this.loadData();
  173. }
  174. // #endif
  175. // 获取客服
  176. this.getadminkf();
  177. if (!this.shopOrderDetail.unpaid_count) {
  178. this.adminStatistics()
  179. }
  180. },
  181. // #ifdef APP-PLUS || H5
  182. onBackPress(e) {
  183. uni.switchTab({
  184. url: '/pages/home/user',
  185. });
  186. return true;
  187. },
  188. // #endif
  189. methods: {
  190. ...mapMutations('shop', ['setShopOrder']),
  191. // 重新加载数据
  192. reload(){
  193. this.navList[this.tabCurrentIndex].orderList=[]
  194. this.navList[this.tabCurrentIndex].page=1
  195. this.navList[this.tabCurrentIndex].loadingType='more'
  196. this.navList[this.tabCurrentIndex].loaded=false
  197. this.changeKf()
  198. this.loadData()
  199. },
  200. // 确认支付
  201. payMoney(item){
  202. const that = this;
  203. uni.showModal({
  204. title: '支付',
  205. content: '是否确认用户已支付?',
  206. cancelText: '关闭',
  207. confirmText: '确认',
  208. success: res => {
  209. uni.showLoading({
  210. title: '支付中',
  211. mask: true
  212. });
  213. if(res.confirm){
  214. offlinePay({
  215. order_id:item.order_id
  216. }).then((e) => {
  217. uni.hideLoading()
  218. uni.showToast({
  219. title:'支付成功'
  220. })
  221. that.reload();
  222. }).catch((e) => {
  223. uni.hideLoading()
  224. console.log(e, 'sj');
  225. })
  226. }
  227. },
  228. fail: () => {},
  229. complete: () => {}
  230. });
  231. },
  232. // 获取订单数量信息
  233. adminStatistics() {
  234. adminStatistics({}).then((e) => {
  235. this.setShopOrder(e.data)
  236. }).catch((e) => {
  237. console.log(e, 'sj');
  238. })
  239. },
  240. // 客服变更
  241. changeKf(item) {
  242. const that = this;
  243. that.actionKf = that.kflist[item.detail.value]
  244. uni.showModal({
  245. title: '送货',
  246. content: `是否让员工${that.actionKf.staff_name}(${that.actionKf.id})送货?`,
  247. success: res => {
  248. if (res.confirm) {
  249. deliveryKeep({
  250. delivery_kf: that.actionKf.id,
  251. delivery_type: 'send',
  252. order_id: that.actionItem.order_id,
  253. delivery_name: that.actionKf.staff_name,
  254. delivery_id: that.actionKf.phone
  255. }).then((res) => {
  256. uni.showToast({
  257. title: res.msg
  258. });
  259. that.adminStatistics();
  260. that.navList[that.tabCurrentIndex].page = 1;
  261. that.navList[that.tabCurrentIndex].orderList = [];
  262. that.navList[that.tabCurrentIndex].loadingType = 'more';
  263. that.loadData();
  264. }).catch((res) => {
  265. })
  266. }
  267. },
  268. fail: () => {},
  269. complete: () => {}
  270. });
  271. },
  272. // 获取客服列表
  273. getadminkf() {
  274. adminkf({}).then((res) => {
  275. this.kflist = res.data;
  276. console.log(res, 'kf');
  277. }).catch((res) => {
  278. console.log(res);
  279. })
  280. },
  281. // 前往客户
  282. shopNext(item) {
  283. // 打开地图导航
  284. uni.openLocation({
  285. latitude: +item.user_address_info.latitude,
  286. longitude: +item.user_address_info.longitude,
  287. fail(e) {
  288. console.log(e);
  289. }
  290. })
  291. },
  292. // 联系用户
  293. toCall(phone) {
  294. uni.makePhoneCall({
  295. phoneNumber: phone
  296. })
  297. },
  298. //跳转到订单详情
  299. goToOrderDetail(e) {
  300. uni.navigateTo({
  301. url: '/pages/order/orderDetail?type=2&id=' + e.order_id
  302. });
  303. },
  304. //获取订单列表
  305. loadData(source) {
  306. //这里是将订单挂载到tab列表下
  307. let index = this.tabCurrentIndex;
  308. let navItem = this.navList[index];
  309. let state = navItem.state;
  310. if (source === 'tabChange' && navItem.loaded === true) {
  311. //tab切换只有第一次需要加载数据
  312. return;
  313. }
  314. if (navItem.loadingType === 'loading') {
  315. //防止重复加载
  316. return;
  317. }
  318. if (navItem.loadingType === 'noMore') {
  319. //防止重复加载
  320. return;
  321. }
  322. // 修改当前对象状态为加载中
  323. navItem.loadingType = 'loading';
  324. GetAdminOrderList({
  325. status: state,
  326. page: navItem.page,
  327. limit: navItem.limit,
  328. shopping_type: 1 //1-送货,2自提
  329. })
  330. .then(({
  331. data
  332. }) => {
  333. let arr = data.map(e => {
  334. let b = this.orderStateExp(e.status);
  335. e.stateTipColor = b.stateTipColor;
  336. return e;
  337. });
  338. navItem.orderList = navItem.orderList.concat(arr);
  339. // console.log(navItem.orderList);
  340. navItem.page++;
  341. if (navItem.limit == data.length) {
  342. //判断是否还有数据, 有改为 more, 没有改为noMore
  343. navItem.loadingType = 'more';
  344. return;
  345. } else {
  346. //判断是否还有数据, 有改为 more, 没有改为noMore
  347. navItem.loadingType = 'noMore';
  348. }
  349. uni.hideLoading();
  350. this.$set(navItem, 'loaded', true);
  351. })
  352. .catch(e => {
  353. console.log(e);
  354. });
  355. },
  356. //swiper 切换
  357. changeTab(e) {
  358. this.tabCurrentIndex = e.target.current;
  359. this.loadData('tabChange');
  360. },
  361. //顶部tab点击
  362. tabClick(index) {
  363. this.tabCurrentIndex = index;
  364. },
  365. //订单状态文字和颜色
  366. orderStateExp(state) {
  367. let stateTipColor = '#3C82E6';
  368. switch (+state) {
  369. case 0:
  370. //'待付款';
  371. stateTipColor = '#3C82E6'
  372. break;
  373. case 1:
  374. //'待发货';
  375. stateTipColor = '#3C82E6'
  376. break;
  377. case 2:
  378. //'待收货';
  379. break;
  380. case 3:
  381. //'待评价';
  382. break;
  383. case 4:
  384. //'已完成';
  385. stateTipColor = '#999999';
  386. break;
  387. case 9:
  388. //'订单已关闭';
  389. stateTipColor = '#909399';
  390. break;
  391. //更多自定义
  392. }
  393. return {
  394. stateTipColor
  395. };
  396. }
  397. }
  398. };
  399. </script>
  400. <style lang="scss">
  401. page,
  402. .content {
  403. background: $page-color-base;
  404. height: 100%;
  405. }
  406. .swiper-box {
  407. height: calc(100% - 40px);
  408. }
  409. .list-scroll-content {
  410. height: 100%;
  411. }
  412. .navbar {
  413. display: flex;
  414. height: 40px;
  415. padding: 0 5px;
  416. background: #fff;
  417. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  418. position: relative;
  419. z-index: 10;
  420. .nav-item {
  421. flex: 1;
  422. display: flex;
  423. justify-content: center;
  424. align-items: center;
  425. height: 100%;
  426. font-size: 15px;
  427. color: $font-color-dark;
  428. position: relative;
  429. &.current {
  430. color: $base-color;
  431. &:after {
  432. content: '';
  433. position: absolute;
  434. left: 50%;
  435. bottom: 0;
  436. transform: translateX(-50%);
  437. width: 44px;
  438. height: 0;
  439. border-bottom: 2px solid $base-color;
  440. }
  441. }
  442. }
  443. }
  444. .order-item {
  445. padding-left: 30rpx;
  446. padding-right: 30rpx;
  447. margin: 0 30rpx;
  448. margin-bottom: 30rpx;
  449. border-radius: 30rpx;
  450. background: #fff;
  451. color:$font-color-light;
  452. .i-top {
  453. height: 80rpx;
  454. .order-code {
  455. font-size: $font-sm;
  456. .no {
  457. padding: 10rpx 10rpx;
  458. background-color: #FFEAE5;
  459. color: #FD5B23;
  460. line-height: 1;
  461. border-top-right-radius: 10rpx;
  462. border-bottom-left-radius: 10rpx;
  463. margin-right: 10rpx;
  464. }
  465. }
  466. .del-btn {
  467. padding: 10rpx 0 10rpx 36rpx;
  468. font-size: $font-lg;
  469. position: relative;
  470. &:after {
  471. content: '';
  472. width: 0;
  473. height: 30rpx;
  474. border-left: 1px solid $border-color-dark;
  475. position: absolute;
  476. left: 20rpx;
  477. top: 50%;
  478. transform: translateY(-50%);
  479. }
  480. }
  481. }
  482. .info-info {
  483. width: 215rpx;
  484. height: 200rpx;
  485. position: absolute;
  486. top: 80rpx;
  487. right: 35rpx;
  488. display: flex;
  489. flex-direction: column;
  490. justify-content: flex-end;
  491. align-items: flex-end;
  492. font-size: 30rpx;
  493. font-weight: 500;
  494. .hj {
  495. padding-top: 40rpx;
  496. color: $font-color-dark;
  497. padding-bottom: 20rpx;
  498. }
  499. .js {
  500. color:$font-color-light;
  501. }
  502. }
  503. .kh-info {
  504. font-size: 24rpx;
  505. font-weight: 500;
  506. color:$font-color-light;
  507. padding-top: 20rpx;
  508. border-top: 1px solid $border-color-base;
  509. view {
  510. padding: 5rpx 0;
  511. }
  512. text {
  513. font-weight: bold;
  514. }
  515. }
  516. /* 多条商品 */
  517. .goods-box {
  518. height: 200rpx;
  519. padding: 20rpx 0;
  520. white-space: nowrap;
  521. padding-right: 250rpx;
  522. .goods-item {
  523. width: 120rpx;
  524. height: 180rpx;
  525. display: inline-block;
  526. margin-right: 24rpx;
  527. }
  528. .goods-img {
  529. display: block;
  530. width: 120rpx;
  531. height: 120rpx;
  532. }
  533. .good-name {
  534. font-size: 24rpx;
  535. text-align: center;
  536. width: 120rpx;
  537. padding-top: 10rpx;
  538. margin-right: 0;
  539. color: $font-color-dark;
  540. }
  541. }
  542. .btm-btn-wrap {
  543. height: 90rpx;
  544. width: 100%;
  545. font-size: 24rpx;
  546. font-weight: 500;
  547. color:$font-color-light;
  548. line-height: 1;
  549. .btm-right {
  550. justify-content: flex-end;
  551. }
  552. .btm-btn {
  553. width: 144rpx;
  554. padding: 10rpx 0;
  555. border: 2px solid $border-color-base;
  556. border-radius: 28rpx;
  557. font-size: 26rpx;
  558. font-weight: 500;
  559. text-align: center;
  560. margin-left: 10rpx;
  561. color: $font-color-light;
  562. }
  563. .ksps {
  564. border-color:$base-color;
  565. color: $base-color;
  566. }
  567. }
  568. }
  569. .buttomBox {
  570. border-radius: 20rpx;
  571. margin: 0 $page-row-spacing;
  572. margin-bottom: 30rpx;
  573. color: $font-color-dark;
  574. background-color: #FFFFFF;
  575. overflow: hidden;
  576. .send {
  577. text-align: center;
  578. }
  579. .item {
  580. line-height: 100rpx;
  581. height: 100rpx;
  582. text-align: center;
  583. font-size: 32rpx;
  584. color: $base-color;
  585. &.qx {
  586. color: $color-red;
  587. }
  588. }
  589. .border_b {
  590. border-bottom: 1px solid $page-color-light;
  591. }
  592. }
  593. </style>