order.vue 16 KB

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