orderAdmin.vue 13 KB

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