order.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. <template>
  2. <view class="content">
  3. <view class="navbar">
  4. <view v-for="(item, index) in navList" :key="index" class="nav-item" :class="{ current: tabCurrentIndex === index }" @click="tabClick(index)">{{ item.text }}</view>
  5. </view>
  6. <swiper :current="tabCurrentIndex" class="swiper-box" duration="300" @change="changeTab">
  7. <swiper-item class="tab-content" v-for="(tabItem, tabIndex) in navList" :key="tabIndex">
  8. <scroll-view class="list-scroll-content" scroll-y @scrolltolower="loadData">
  9. <!-- 空白页 -->
  10. <empty v-if="tabItem.loaded === true && tabItem.orderList.length === 0"></empty>
  11. <!-- 订单列表 -->
  12. <view class="order-item" v-for="(item, index) in tabItem.orderList">
  13. <view class="order-top flex">
  14. <view class="order-top-left">
  15. <image class="order-top-left-image" src="../../static/img/order5.png" mode=""></image>
  16. <view class="order-top-left-font">订单信息</view>
  17. </view>
  18. <view class="order-top-right">{{ item.after_sales == 1 ? '申请售后' : item.after_sales == 2 ? '售后成功' : tabItem.text }}</view>
  19. </view>
  20. <view class="order-info flex">
  21. <view class="order-info-left">委托时间:</view>
  22. <view class="order-info-right">{{ item.time }}</view>
  23. </view>
  24. <view class="order-info flex">
  25. <view class="order-info-left">订单类型:</view>
  26. <view class="order-info-right">{{ item.type == 2 ? '代办' : '陪诊' }}</view>
  27. </view>
  28. <view class="order-info flex">
  29. <view class="order-info-left">医院:</view>
  30. <view class="order-info-right">{{ item.hospital }}</view>
  31. </view>
  32. <view class="order-info flex">
  33. <view class="order-info-left">预约人:</view>
  34. <view class="order-info-right">{{ item.name }}</view>
  35. </view>
  36. <view class="order-info flex" v-if="item.type == 2">
  37. <view class="order-info-left">代办类型:</view>
  38. <view class="order-info-right">{{ item.catename }}</view>
  39. </view>
  40. <view class="order-info flex" v-if="item.type == 1">
  41. <view class="order-info-left">陪诊类型:</view>
  42. <view class="order-info-right">{{ item.catename }}</view>
  43. </view>
  44. <view class="order-info flex" v-if="item.type == 1">
  45. <view class="order-info-left">陪诊服务:</view>
  46. <view class="order-info-right">{{ item.servicename }}</view>
  47. </view>
  48. <view class="order-info flex" v-if="item.issm == 2">
  49. <view class="order-info-left">接送地址:</view>
  50. <view class="order-info-right">{{ item.transfer_address }}</view>
  51. </view>
  52. <view class="order-info flex">
  53. <view class="order-info-left">备注:</view>
  54. <view class="order-info-right">{{ item.remarks || '无' }}</view>
  55. </view>
  56. <view class="order-btn-box" v-if="tabCurrentIndex == 0">
  57. <view class="order-btn" @click="qxorder(item)">
  58. <image class="order-btn-icon" src="../../static/img/order3.png" mode=""></image>
  59. <view class="order-btn-font">取消订单</view>
  60. </view>
  61. </view>
  62. <view class="ordering" v-if="tabCurrentIndex == 1">
  63. <view class="order-info flex">
  64. <view class="order-info-left">接单人:</view>
  65. <view class="order-info-right">{{ item.receiving.name }}</view>
  66. </view>
  67. <view class="order-info flex">
  68. <view class="order-info-left">接单人电话:</view>
  69. <view class="order-info-right">{{ item.receiving.phone }}</view>
  70. </view>
  71. <view class="ordering-btn flex" @click="call(item)">
  72. <image class="ordering-btn-icon" src="../../static/img/order4.png" mode=""></image>
  73. <view class="ordering-btn-font">立即联系</view>
  74. </view>
  75. </view>
  76. <view class="ordering" v-if="tabCurrentIndex == 2">
  77. <view class="order-info flex">
  78. <view class="order-info-left">接单人:</view>
  79. <view class="order-info-right">{{ item.receiving.name }}</view>
  80. </view>
  81. <view class="order-info flex">
  82. <view class="order-info-left">接单人电话:</view>
  83. <view class="order-info-right">{{ item.receiving.phone }}</view>
  84. </view>
  85. <view class="order-info flex">
  86. <view class="order-info-left">照片:</view>
  87. <view class="order-info-picture">
  88. <view class="order-info-picture-item" v-for="(itm, inx) in item.images"><image :src="itm" mode=""></image></view>
  89. </view>
  90. </view>
  91. <view class="ordering-btnbox">
  92. <view class="ordering-btnbox-left" @click="navTo('/pages/order/evaluate?unique=' + item.id)">
  93. <image class="ordering-btnbox-left-icon" src="../../static/img/order1.png" mode=""></image>
  94. <view class="ordering-btnbox-left-font">{{ item.after_sales == 1 ? '查看售后' : '申请售后' }}</view>
  95. </view>
  96. <view class="ordering-btnbox-right" @click="accomplish(item)"><view class="ordering-btnbox-right-font">确认完成</view></view>
  97. </view>
  98. </view>
  99. <view class="ordering" v-if="tabCurrentIndex == 3">
  100. <view class="order-info flex">
  101. <view class="order-info-left">接单人:</view>
  102. <view class="order-info-right">{{ item.receiving.name }}</view>
  103. </view>
  104. <view class="order-info flex">
  105. <view class="order-info-left">接单人电话:</view>
  106. <view class="order-info-right">{{ item.receiving.phone }}</view>
  107. </view>
  108. <view class="order-info flex">
  109. <view class="order-info-left">照片:</view>
  110. <view class="order-info-picture">
  111. <view class="order-info-picture-item" v-for="(itm, inx) in item.images"><image :src="itm" mode=""></image></view>
  112. </view>
  113. </view>
  114. <view class="order-btn-box">
  115. <view class="order-btn" @click="navTo('/pages/order/evaluate?unique=' + item.id)">
  116. <image class="order-btn-icon" src="../../static/img/order1.png" mode=""></image>
  117. <view class="order-btn-font">{{ item.after_sales == 1 ? '查看售后' : '申请售后' }}</view>
  118. </view>
  119. </view>
  120. </view>
  121. </view>
  122. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  123. </scroll-view>
  124. </swiper-item>
  125. </swiper>
  126. </view>
  127. </template>
  128. <script>
  129. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  130. import { mapState, mapMutations } from 'vuex';
  131. import empty from '@/components/empty';
  132. import { orderList, orderCancel, orderDel, orderTake, confirmation } from '@/api/order.js';
  133. import { getTime } from '@/utils/rocessor.js';
  134. import { saveUrl, interceptor } from '@/utils/loginUtils.js';
  135. export default {
  136. components: {
  137. uniLoadMore,
  138. empty
  139. },
  140. computed: {
  141. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  142. },
  143. data() {
  144. return {
  145. tabCurrentIndex: 0,
  146. navList: [
  147. {
  148. state: 0,
  149. text: '待接单',
  150. loadingType: 'more',
  151. orderList: [],
  152. page: 1, //当前页数
  153. limit: 10 //每次信息条数
  154. },
  155. {
  156. state: 1,
  157. text: '进行中',
  158. loadingType: 'more',
  159. orderList: [],
  160. page: 1, //当前页数
  161. limit: 10 //每次信息条数
  162. },
  163. {
  164. state: 2,
  165. text: '待确认',
  166. loadingType: 'more',
  167. orderList: [],
  168. page: 1, //当前页数
  169. limit: 10 //每次信息条数
  170. },
  171. {
  172. state: 3,
  173. text: '已完成',
  174. loadingType: 'more',
  175. orderList: [],
  176. page: 1, //当前页数
  177. limit: 10 //每次信息条数
  178. }
  179. ]
  180. };
  181. },
  182. onShow() {
  183. this.navList = [
  184. {
  185. state: 0,
  186. text: '待接单',
  187. loadingType: 'more',
  188. orderList: [],
  189. page: 1, //当前页数
  190. limit: 10 //每次信息条数
  191. },
  192. {
  193. state: 1,
  194. text: '进行中',
  195. loadingType: 'more',
  196. orderList: [],
  197. page: 1, //当前页数
  198. limit: 10 //每次信息条数
  199. },
  200. {
  201. state: 2,
  202. text: '待确认',
  203. loadingType: 'more',
  204. orderList: [],
  205. page: 1, //当前页数
  206. limit: 10 //每次信息条数
  207. },
  208. {
  209. state: 3,
  210. text: '已完成',
  211. loadingType: 'more',
  212. orderList: [],
  213. page: 1, //当前页数
  214. limit: 10 //每次信息条数
  215. }
  216. ];
  217. this.tabCurrentIndex = 0;
  218. if (!this.hasLogin) {
  219. // 保存地址
  220. saveUrl();
  221. // 登录拦截
  222. interceptor();
  223. } else {
  224. this.loadData();
  225. }
  226. },
  227. onLoad(options) {},
  228. // #ifdef APP-PLUS || H5
  229. onBackPress(e) {
  230. uni.switchTab({
  231. url: '/pages/user/user'
  232. });
  233. return true;
  234. },
  235. // #endif
  236. filters: {
  237. moneyNum(value) {
  238. return +value;
  239. }
  240. },
  241. methods: {
  242. call(item) {
  243. console.log(item.receiving.phone);
  244. uni.makePhoneCall({
  245. phoneNumber: item.receiving.phone //仅为示例
  246. });
  247. },
  248. // 完成
  249. accomplish(opt) {
  250. const obj = this;
  251. uni.showModal({
  252. title: '提示',
  253. content: '是否确认订单成功',
  254. success: function(res) {
  255. if (res.confirm) {
  256. confirmation({}, opt.id).then(e => {
  257. uni.showToast({
  258. title: '确认订单成功',
  259. icon: 'success',
  260. duration: 2000
  261. });
  262. obj.loadData('shua');
  263. });
  264. } else if (res.cancel) {
  265. console.log('用户点击取消');
  266. }
  267. }
  268. });
  269. },
  270. // 转换金额为数字
  271. moneyNum(value) {
  272. return +value;
  273. },
  274. navTo(url) {
  275. uni.navigateTo({
  276. url
  277. });
  278. },
  279. // 取消订单
  280. qxorder(opt) {
  281. const obj = this;
  282. uni.showModal({
  283. title: '提示',
  284. content: '是否取消订单',
  285. success: function(res) {
  286. if (res.confirm) {
  287. orderCancel({}, opt.id).then(e => {
  288. uni.showToast({
  289. title: '取消订单成功',
  290. icon: 'success',
  291. duration: 2000
  292. });
  293. obj.loadData('shua');
  294. });
  295. } else if (res.cancel) {
  296. console.log('用户点击取消');
  297. }
  298. }
  299. });
  300. },
  301. //获取订单列表
  302. loadData(source) {
  303. //这里是将订单挂载到tab列表下
  304. let index = this.tabCurrentIndex;
  305. let navItem = this.navList[index];
  306. let state = navItem.state;
  307. if (source === 'shua') {
  308. navItem.loaded = false;
  309. navItem.page = 1;
  310. navItem.limit = 10;
  311. navItem.loadingType = 'more';
  312. navItem.orderList = [];
  313. }
  314. if (source === 'tabChange' && navItem.loaded === true) {
  315. //tab切换只有第一次需要加载数据
  316. return;
  317. }
  318. if (navItem.loadingType === 'loading') {
  319. //防止重复加载
  320. return;
  321. }
  322. if (navItem.loadingType === 'noMore') {
  323. //防止重复加载
  324. return;
  325. }
  326. // 修改当前对象状态为加载中
  327. navItem.loadingType = 'loading';
  328. orderList({
  329. status: state,
  330. page: navItem.page,
  331. limit: navItem.limit
  332. })
  333. .then(({ data }) => {
  334. data.forEach(e => {
  335. if (e.remarks == undefined || e.remarks == 'undefined') {
  336. e.remarks = '无';
  337. }
  338. let key = Object.keys(e.cate);
  339. let name = '';
  340. key.forEach(e => {
  341. if (name == '') {
  342. name = name + e;
  343. } else {
  344. name = name + '/' + e;
  345. }
  346. });
  347. e.catename = name;
  348. let key1 = Object.keys(e.service);
  349. let name1 = '';
  350. e.issm = 1;
  351. key1.forEach(es => {
  352. console.log(e);
  353. if (es == '上门接送') {
  354. e.issm = 2;
  355. }
  356. if (name1 == '') {
  357. name1 = name1 + es;
  358. } else {
  359. name1 = name1 + '/' + es;
  360. }
  361. });
  362. e.servicename = name1;
  363. e.time = getTime(e.time);
  364. });
  365. navItem.orderList = navItem.orderList.concat(data);
  366. navItem.page++;
  367. if (navItem.limit == data.length) {
  368. //判断是否还有数据, 有改为 more, 没有改为noMore
  369. navItem.loadingType = 'more';
  370. return;
  371. } else {
  372. //判断是否还有数据, 有改为 more, 没有改为noMore
  373. navItem.loadingType = 'noMore';
  374. }
  375. uni.hideLoading();
  376. this.$set(navItem, 'loaded', true);
  377. })
  378. .catch(e => {
  379. console.log(e);
  380. });
  381. },
  382. //swiper 切换
  383. changeTab(e) {
  384. this.tabCurrentIndex = e.target.current;
  385. this.loadData('tabChange');
  386. },
  387. //顶部tab点击
  388. tabClick(index) {
  389. this.tabCurrentIndex = index;
  390. }
  391. }
  392. };
  393. </script>
  394. <style lang="scss">
  395. page,
  396. .content {
  397. background: $page-color-base;
  398. height: 100%;
  399. }
  400. .swiper-box {
  401. height: calc(100% - 40px);
  402. }
  403. .list-scroll-content {
  404. height: 100%;
  405. }
  406. .navbar {
  407. display: flex;
  408. height: 40px;
  409. padding: 0 5px;
  410. background: #fff;
  411. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  412. position: relative;
  413. z-index: 10;
  414. .nav-item {
  415. flex: 1;
  416. display: flex;
  417. justify-content: center;
  418. align-items: center;
  419. height: 100%;
  420. font-size: 15px;
  421. color: $font-color-dark;
  422. position: relative;
  423. &.current {
  424. color: $base-color;
  425. &:after {
  426. content: '';
  427. position: absolute;
  428. left: 50%;
  429. bottom: 0;
  430. transform: translateX(-50%);
  431. width: 44px;
  432. height: 0;
  433. border-bottom: 2px solid $base-color;
  434. }
  435. }
  436. }
  437. }
  438. .uni-swiper-item {
  439. height: auto;
  440. }
  441. .order-item {
  442. width: 702rpx;
  443. background: #ffffff;
  444. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  445. border-radius: 20rpx;
  446. margin: 20rpx auto 0;
  447. padding: 24rpx;
  448. .order-top-left {
  449. display: flex;
  450. align-items: center;
  451. .order-top-left-image {
  452. width: 32rpx;
  453. height: 37rpx;
  454. }
  455. .order-top-left-font {
  456. margin-left: 10rpx;
  457. font-size: 30rpx;
  458. font-family: PingFang SC;
  459. font-weight: bold;
  460. color: #333333;
  461. }
  462. }
  463. .order-top-right {
  464. font-size: 26rpx;
  465. font-family: PingFang SC;
  466. font-weight: 500;
  467. color: #ff6f0f;
  468. }
  469. .order-info {
  470. margin-top: 24rpx;
  471. align-items: flex-start;
  472. .order-info-left {
  473. width: 200rpx;
  474. font-size: 28rpx;
  475. font-family: PingFang SC;
  476. font-weight: 500;
  477. color: #666666;
  478. }
  479. .order-info-right {
  480. font-size: 28rpx;
  481. font-family: PingFang SC;
  482. font-weight: bold;
  483. color: #333333;
  484. }
  485. .order-info-picture {
  486. display: flex;
  487. justify-content: flex-end;
  488. .order-info-picture-item {
  489. width: 130rpx;
  490. height: 130rpx;
  491. margin-left: 10rpx;
  492. image {
  493. width: 100%;
  494. height: 100%;
  495. }
  496. }
  497. }
  498. }
  499. .order-btn-box {
  500. display: flex;
  501. justify-content: flex-end;
  502. .order-btn {
  503. margin-top: 34rpx;
  504. align-items: center;
  505. display: flex;
  506. justify-content: center;
  507. width: 181rpx;
  508. height: 63rpx;
  509. border: 1rpx solid #c9c9c9;
  510. border-radius: 15rpx;
  511. .order-btn-icon {
  512. width: 38rpx;
  513. height: 38rpx;
  514. }
  515. .order-btn-font {
  516. margin-left: 7rpx;
  517. font-size: 24rpx;
  518. font-family: PingFang SC;
  519. font-weight: 500;
  520. color: #666666;
  521. }
  522. }
  523. }
  524. .ordering {
  525. margin-top: 30rpx;
  526. padding: 30rpx 0 10rpx;
  527. border-top: 1px solid #eaeced;
  528. .ordering-btn {
  529. display: flex;
  530. justify-content: center;
  531. margin: 38rpx auto 0;
  532. width: 566rpx;
  533. height: 74rpx;
  534. background: #24a17d;
  535. border-radius: 15rpx;
  536. .ordering-btn-icon {
  537. width: 32rpx;
  538. height: 34rpx;
  539. }
  540. .ordering-btn-font {
  541. margin-left: 14rpx;
  542. font-size: 30rpx;
  543. font-family: PingFang SC;
  544. font-weight: bold;
  545. color: #ffffff;
  546. }
  547. }
  548. .ordering-btnbox {
  549. margin-top: 40rpx;
  550. display: flex;
  551. justify-content: space-between;
  552. align-items: center;
  553. .ordering-btnbox-left {
  554. display: flex;
  555. flex-direction: column;
  556. align-items: center;
  557. line-height: 1;
  558. .ordering-btnbox-left-icon {
  559. width: 42rpx;
  560. height: 42rpx;
  561. }
  562. .ordering-btnbox-left-font {
  563. margin-top: 10rpx;
  564. font-size: 20rpx;
  565. font-family: PingFang SC;
  566. font-weight: 500;
  567. color: #666666;
  568. }
  569. }
  570. .ordering-btnbox-right {
  571. display: flex;
  572. justify-content: center;
  573. align-items: center;
  574. width: 556rpx;
  575. height: 74rpx;
  576. background: #24a17d;
  577. border-radius: 15rpx;
  578. .ordering-btnbox-right-font {
  579. font-size: 30rpx;
  580. font-family: PingFang SC;
  581. font-weight: bold;
  582. color: #ffffff;
  583. }
  584. }
  585. }
  586. }
  587. }
  588. /* load-more */
  589. .uni-load-more {
  590. display: flex;
  591. flex-direction: row;
  592. height: 80rpx;
  593. align-items: center;
  594. justify-content: center;
  595. }
  596. @-webkit-keyframes load {
  597. 0% {
  598. opacity: 1;
  599. }
  600. 100% {
  601. opacity: 0.2;
  602. }
  603. }
  604. </style>