orderAdmin.vue 13 KB

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