orderAdmin.vue 11 KB

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