orderAdmin.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  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="toCall(item)">
  58. 联系客户
  59. </view>
  60. <view class="btm-btn ksps" 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. </view>
  74. </template>
  75. <script>
  76. import {
  77. orderList,
  78. } from '@/api/order.js';
  79. import {
  80. GetAdminOrderList
  81. } from '@/api/user.js'
  82. export default {
  83. data() {
  84. return {
  85. tabCurrentIndex: 0,
  86. navList: [{
  87. state: 0,
  88. text: '待付款',
  89. loadingType: 'more',
  90. orderList: [],
  91. page: 1, //当前页数
  92. limit: 10 //每次信息条数
  93. },
  94. {
  95. state: 1,
  96. text: '待发货',
  97. loadingType: 'more',
  98. orderList: [],
  99. page: 1, //当前页数
  100. limit: 10 //每次信息条数
  101. },
  102. {
  103. state: 2,
  104. text: '待收货',
  105. loadingType: 'more',
  106. orderList: [],
  107. page: 1, //当前页数
  108. limit: 10 //每次信息条数
  109. },
  110. {
  111. state: 4,
  112. text: '已完成',
  113. loadingType: 'more',
  114. orderList: [],
  115. page: 1, //当前页数
  116. limit: 10 //每次信息条数
  117. }
  118. ]
  119. };
  120. },
  121. onLoad(options) {
  122. /**
  123. * 修复app端点击除全部订单外的按钮进入时不加载数据的问题
  124. * 替换onLoad下代码即可
  125. */
  126. this.tabCurrentIndex = +options.state;
  127. // #ifndef MP
  128. this.loadData();
  129. // #endif
  130. // #ifdef MP
  131. if (options.state == 0) {
  132. this.loadData();
  133. }
  134. // #endif
  135. },
  136. // #ifdef APP-PLUS || H5
  137. onBackPress(e) {
  138. uni.switchTab({
  139. url: '/pages/home/user',
  140. });
  141. return true;
  142. },
  143. // #endif
  144. methods: {
  145. // 前往商家
  146. shopNext() {
  147. // 打开地图导航
  148. uni.openLocation({
  149. latitude: +this.item.system_store.latitude,
  150. longitude: +this.item.system_store.longitude,
  151. fail(e) {
  152. console.log(e);
  153. }
  154. })
  155. },
  156. // 联系用户
  157. toCall(phone) {
  158. uni.makePhoneCall({
  159. phoneNumber:phone
  160. })
  161. },
  162. //跳转到订单详情
  163. goToOrderDetail(e) {
  164. uni.navigateTo({
  165. url: '/pages/order/orderDetail?type=2&id=' + e.order_id
  166. });
  167. },
  168. //获取订单列表
  169. loadData(source) {
  170. //这里是将订单挂载到tab列表下
  171. let index = this.tabCurrentIndex;
  172. let navItem = this.navList[index];
  173. let state = navItem.state;
  174. if (source === 'tabChange' && navItem.loaded === true) {
  175. //tab切换只有第一次需要加载数据
  176. return;
  177. }
  178. if (navItem.loadingType === 'loading') {
  179. //防止重复加载
  180. return;
  181. }
  182. if (navItem.loadingType === 'noMore') {
  183. //防止重复加载
  184. return;
  185. }
  186. // 修改当前对象状态为加载中
  187. navItem.loadingType = 'loading';
  188. GetAdminOrderList({
  189. status: state,
  190. page: navItem.page,
  191. limit: navItem.limit,
  192. shopping_type: 1 //1-送货,2自提
  193. })
  194. .then(({
  195. data
  196. }) => {
  197. let arr = data.map(e => {
  198. let b = this.orderStateExp(e.status);
  199. e.stateTip = b.stateTip;
  200. e.stateTipColor = b.stateTipColor;
  201. return e;
  202. });
  203. navItem.orderList = navItem.orderList.concat(arr);
  204. // console.log(navItem.orderList);
  205. navItem.page++;
  206. if (navItem.limit == data.length) {
  207. //判断是否还有数据, 有改为 more, 没有改为noMore
  208. navItem.loadingType = 'more';
  209. return;
  210. } else {
  211. //判断是否还有数据, 有改为 more, 没有改为noMore
  212. navItem.loadingType = 'noMore';
  213. }
  214. uni.hideLoading();
  215. this.$set(navItem, 'loaded', true);
  216. })
  217. .catch(e => {
  218. console.log(e);
  219. });
  220. },
  221. //swiper 切换
  222. changeTab(e) {
  223. this.tabCurrentIndex = e.target.current;
  224. this.loadData('tabChange');
  225. },
  226. //顶部tab点击
  227. tabClick(index) {
  228. this.tabCurrentIndex = index;
  229. },
  230. //订单状态文字和颜色
  231. orderStateExp(state) {
  232. let stateTip = '',
  233. stateTipColor = '#3C82E6';
  234. switch (+state) {
  235. case 0:
  236. stateTip = '待付款';
  237. stateTipColor = '#3C82E6'
  238. break;
  239. case 1:
  240. stateTip = '待发货';
  241. stateTipColor = '#3C82E6'
  242. break;
  243. case 2:
  244. stateTip = '待收货';
  245. break;
  246. case 3:
  247. stateTip = '待评价';
  248. break;
  249. case 4:
  250. stateTip = '已完成';
  251. stateTipColor = '#999999';
  252. break;
  253. case 9:
  254. stateTip = '订单已关闭';
  255. stateTipColor = '#909399';
  256. break;
  257. //更多自定义
  258. }
  259. return {
  260. stateTip,
  261. stateTipColor
  262. };
  263. }
  264. }
  265. };
  266. </script>
  267. <style lang="scss">
  268. page,
  269. .content {
  270. background: $page-color-base;
  271. height: 100%;
  272. }
  273. .swiper-box {
  274. height: calc(100% - 40px);
  275. }
  276. .list-scroll-content {
  277. height: 100%;
  278. }
  279. .navbar {
  280. display: flex;
  281. height: 40px;
  282. padding: 0 5px;
  283. background: #fff;
  284. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  285. position: relative;
  286. z-index: 10;
  287. .nav-item {
  288. flex: 1;
  289. display: flex;
  290. justify-content: center;
  291. align-items: center;
  292. height: 100%;
  293. font-size: 15px;
  294. color: $font-color-dark;
  295. position: relative;
  296. &.current {
  297. color: $base-color;
  298. &:after {
  299. content: '';
  300. position: absolute;
  301. left: 50%;
  302. bottom: 0;
  303. transform: translateX(-50%);
  304. width: 44px;
  305. height: 0;
  306. border-bottom: 2px solid $base-color;
  307. }
  308. }
  309. }
  310. }
  311. .order-item {
  312. padding-left: 30rpx;
  313. padding-right: 30rpx;
  314. margin: 0 30rpx;
  315. margin-bottom: 30rpx;
  316. border-radius: 30rpx;
  317. background: #fff;
  318. color: #A8ADBF;
  319. .i-top {
  320. height: 80rpx;
  321. .order-code{
  322. font-size: $font-sm;
  323. .no{
  324. padding: 10rpx 10rpx;
  325. background-color: #FFEAE5;
  326. color: #FD5B23;
  327. line-height: 1;
  328. border-top-right-radius: 10rpx;
  329. border-bottom-left-radius: 10rpx;
  330. margin-right: 10rpx;
  331. }
  332. }
  333. .del-btn {
  334. padding: 10rpx 0 10rpx 36rpx;
  335. font-size: $font-lg;
  336. position: relative;
  337. &:after {
  338. content: '';
  339. width: 0;
  340. height: 30rpx;
  341. border-left: 1px solid $border-color-dark;
  342. position: absolute;
  343. left: 20rpx;
  344. top: 50%;
  345. transform: translateY(-50%);
  346. }
  347. }
  348. }
  349. .info-info {
  350. width: 215rpx;
  351. height: 200rpx;
  352. position: absolute;
  353. top: 80rpx;
  354. right: 35rpx;
  355. display: flex;
  356. flex-direction: column;
  357. justify-content: flex-end;
  358. align-items: flex-end;
  359. font-size: 30rpx;
  360. font-weight: 500;
  361. .hj {
  362. padding-top: 40rpx;
  363. color: $font-color-dark;
  364. padding-bottom: 20rpx;
  365. }
  366. .js {
  367. color: #A8ADBF;
  368. }
  369. }
  370. .kh-info {
  371. font-size: 24rpx;
  372. font-weight: 500;
  373. color: #666666;
  374. padding: 20rpx 0;
  375. border-top: 1px solid #F8F8F8;
  376. view {
  377. padding: 5rpx 0;
  378. }
  379. text {
  380. font-weight: bold;
  381. color: #333333;
  382. }
  383. }
  384. /* 多条商品 */
  385. .goods-box {
  386. height: 200rpx;
  387. padding: 20rpx 0;
  388. white-space: nowrap;
  389. padding-right: 250rpx;
  390. .goods-item {
  391. width: 120rpx;
  392. height: 180rpx;
  393. display: inline-block;
  394. margin-right: 24rpx;
  395. }
  396. .goods-img {
  397. display: block;
  398. width: 120rpx;
  399. height: 120rpx;
  400. }
  401. .good-name {
  402. font-size: 24rpx;
  403. text-align: center;
  404. width: 120rpx;
  405. padding-top: 10rpx;
  406. margin-right: 0;
  407. color: $font-color-dark;
  408. }
  409. }
  410. .btm-btn-wrap {
  411. height: 90rpx;
  412. width: 100%;
  413. font-size: 24rpx;
  414. font-weight: 500;
  415. color: #A3A8BB;
  416. line-height: 1;
  417. .btm-right {
  418. justify-content: flex-end;
  419. }
  420. .btm-btn {
  421. width: 144rpx;
  422. padding: 10rpx 0;
  423. border: 2px solid #ededed;
  424. border-radius: 28rpx;
  425. font-size: 26rpx;
  426. font-weight: 500;
  427. text-align: center;
  428. margin-left: 10rpx;
  429. color: #999999;
  430. }
  431. .ksps {
  432. border-color: #4589ec;
  433. color: #4589ec;
  434. }
  435. }
  436. }
  437. </style>