order.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  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">{{ 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">
  37. <view class="order-info-left">客户电话:</view>
  38. <view class="order-info-right">{{ item.phone }}</view>
  39. </view>
  40. <view class="order-info flex" v-if="item.type == 2">
  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.catename }}</view>
  47. </view>
  48. <view class="order-info flex" v-if="tabCurrentIndex == 0 && item.type == 1">
  49. <view class="order-info-left">陪诊服务:</view>
  50. <view class="order-info-right">{{ item.servicename }}</view>
  51. </view>
  52. <view class="order-info flex" v-if="tabCurrentIndex == 0 && item.type == 1 && item.issm == 2">
  53. <view class="order-info-left">接送地址:</view>
  54. <view class="order-info-address">
  55. <view class="order-info-address-main">{{ item.transfer_address }}</view>
  56. <image class="order-info-address-icon" src="../../static/img/order7.png" mode=""></image>
  57. <!-- <view class="order-info-dh">导航</view> -->
  58. </view>
  59. </view>
  60. <view class="order-info flex">
  61. <view class="order-info-left">下单时间:</view>
  62. <view class="order-info-right">{{ item.create_time }}</view>
  63. </view>
  64. <view class="order-info flex">
  65. <view class="order-info-left">备注:</view>
  66. <view class="order-info-right">{{ item.remarks }}</view>
  67. </view>
  68. <view class="order-info flex" v-if="tabCurrentIndex != 0">
  69. <view class="order-info-left">照片:</view>
  70. <view class="order-info-picture">
  71. <view class="order-info-picture-item" v-for="(itm, inx) in item.images"><image :src="itm" mode=""></image></view>
  72. </view>
  73. </view>
  74. <view class="order-btn-box" v-if="tabCurrentIndex == 0">
  75. <view class="order-btn" @click="abandonOrder(item)">
  76. <image class="order-btn-icon" src="../../static/img/order3.png" mode=""></image>
  77. <view class="order-btn-font">放弃订单</view>
  78. </view>
  79. <view class="order-btn btn1" @click="call(item)">
  80. <image class="order-btn-icon1" src="../../static/img/order9.png" mode=""></image>
  81. <view class="order-btn-font">立即联系</view>
  82. </view>
  83. <view class="order-btn btn2" @click="navTo('/pages/jdr/evaluate?unique=' + item.id)">
  84. <image class="order-btn-icon2" src="../../static/img/order8.png" mode=""></image>
  85. <view class="order-btn-font">提交完成</view>
  86. </view>
  87. </view>
  88. <view class="ordering-btn flex" v-if="tabCurrentIndex == 1" @click="call(item)">
  89. <image class="ordering-btn-icon" src="../../static/img/order4.png" mode=""></image>
  90. <view class="ordering-btn-font">立即联系</view>
  91. </view>
  92. </view>
  93. <uni-load-more :status="tabItem.loadingType"></uni-load-more>
  94. </scroll-view>
  95. </swiper-item>
  96. </swiper>
  97. </view>
  98. </template>
  99. <script>
  100. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  101. import empty from '@/components/empty';
  102. import { receiving_list, discard_orde } from '@/api/jdr.js';
  103. import { getTime } from '@/utils/rocessor.js';
  104. export default {
  105. components: {
  106. uniLoadMore,
  107. empty
  108. },
  109. data() {
  110. return {
  111. tabCurrentIndex: 0,
  112. navList: [
  113. {
  114. state: 1,
  115. text: '进行中',
  116. loadingType: 'more',
  117. orderList: [],
  118. page: 1, //当前页数
  119. limit: 10 //每次信息条数
  120. },
  121. {
  122. state: 2,
  123. text: '待确认',
  124. loadingType: 'more',
  125. orderList: [],
  126. page: 1, //当前页数
  127. limit: 10 //每次信息条数
  128. },
  129. {
  130. state: 3,
  131. text: '已完成',
  132. loadingType: 'more',
  133. orderList: [],
  134. page: 1, //当前页数
  135. limit: 10 //每次信息条数
  136. }
  137. ]
  138. };
  139. },
  140. onLoad(options) {
  141. this.tabCurrentIndex = options.state;
  142. /**
  143. * 修复app端点击除全部订单外的按钮进入时不加载数据的问题
  144. * 替换onLoad下代码即可
  145. */
  146. // #ifndef MP
  147. this.loadData();
  148. // #endif
  149. // #ifdef MP
  150. if (options.state == 0) {
  151. this.loadData();
  152. }
  153. // #endif
  154. },
  155. // #ifdef APP-PLUS || H5
  156. onBackPress(e) {
  157. uni.switchTab({
  158. url: '/pages/user/my'
  159. });
  160. return true;
  161. },
  162. // #endif
  163. filters: {
  164. moneyNum(value) {
  165. return +value;
  166. }
  167. },
  168. methods: {
  169. //联系客户
  170. call(item) {
  171. console.log(item.phone);
  172. uni.makePhoneCall({
  173. phoneNumber: item.phone //仅为示例
  174. });
  175. },
  176. // 转换金额为数字
  177. moneyNum(value) {
  178. return +value;
  179. },
  180. navTo(url) {
  181. uni.navigateTo({
  182. url
  183. });
  184. },
  185. //获取订单列表
  186. loadData(source) {
  187. //这里是将订单挂载到tab列表下
  188. let index = this.tabCurrentIndex;
  189. let navItem = this.navList[index];
  190. let state = navItem.state;
  191. if (source === 'shua') {
  192. navItem.loaded = false;
  193. navItem.page = 1;
  194. navItem.limit = 10;
  195. navItem.loadingType = 'more';
  196. navItem.orderList = [];
  197. }
  198. if (source === 'tabChange' && navItem.loaded === true) {
  199. //tab切换只有第一次需要加载数据
  200. return;
  201. }
  202. if (navItem.loadingType === 'loading') {
  203. //防止重复加载
  204. return;
  205. }
  206. if (navItem.loadingType === 'noMore') {
  207. //防止重复加载
  208. return;
  209. }
  210. // 修改当前对象状态为加载中
  211. navItem.loadingType = 'loading';
  212. receiving_list({
  213. status: state,
  214. page: navItem.page,
  215. limit: navItem.limit
  216. })
  217. .then(({ data }) => {
  218. data.forEach(e => {
  219. if (e.remarks == undefined || e.remarks == 'undefined') {
  220. e.remarks = '无';
  221. }
  222. let key = Object.keys(e.cate);
  223. let name = '';
  224. key.forEach(e => {
  225. if (name == '') {
  226. name = name + e;
  227. } else {
  228. name = name + '/' + e;
  229. }
  230. });
  231. e.catename = name;
  232. let key1 = Object.keys(e.service);
  233. let name1 = '';
  234. e.issm = 1;
  235. key1.forEach(es => {
  236. console.log(e);
  237. if (es == '上门接送') {
  238. e.issm = 2;
  239. }
  240. if (name1 == '') {
  241. name1 = name1 + es;
  242. } else {
  243. name1 = name1 + '/' + es;
  244. }
  245. });
  246. e.servicename = name1;
  247. e.time = getTime(e.time);
  248. });
  249. navItem.orderList = navItem.orderList.concat(data);
  250. // console.log(navItem.orderList);
  251. navItem.page++;
  252. if (navItem.limit == data.length) {
  253. //判断是否还有数据, 有改为 more, 没有改为noMore
  254. navItem.loadingType = 'more';
  255. return;
  256. } else {
  257. //判断是否还有数据, 有改为 more, 没有改为noMore
  258. navItem.loadingType = 'noMore';
  259. }
  260. uni.hideLoading();
  261. this.$set(navItem, 'loaded', true);
  262. })
  263. .catch(e => {
  264. console.log(e);
  265. });
  266. },
  267. // 取消接单
  268. abandonOrder(opt) {
  269. const obj = this;
  270. uni.showModal({
  271. title: '提示',
  272. content: '是否取消订单',
  273. success: function(res) {
  274. if (res.confirm) {
  275. discard_orde({}, opt.id).then(e => {
  276. uni.showToast({
  277. title: '放弃订单成功',
  278. icon: 'success',
  279. duration: 2000
  280. });
  281. obj.loadData('shua');
  282. });
  283. } else if (res.cancel) {
  284. console.log('用户点击取消');
  285. }
  286. }
  287. });
  288. },
  289. //swiper 切换
  290. changeTab(e) {
  291. this.tabCurrentIndex = e.target.current;
  292. this.loadData('tabChange');
  293. },
  294. //顶部tab点击
  295. tabClick(index) {
  296. this.tabCurrentIndex = index;
  297. }
  298. }
  299. };
  300. </script>
  301. <style lang="scss">
  302. page,
  303. .content {
  304. background: $page-color-base;
  305. height: 100%;
  306. }
  307. .swiper-box {
  308. height: calc(100% - 40px);
  309. }
  310. .list-scroll-content {
  311. height: 100%;
  312. }
  313. .navbar {
  314. display: flex;
  315. height: 40px;
  316. padding: 0 5px;
  317. background: #fff;
  318. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  319. position: relative;
  320. z-index: 10;
  321. .nav-item {
  322. flex: 1;
  323. display: flex;
  324. justify-content: center;
  325. align-items: center;
  326. height: 100%;
  327. font-size: 15px;
  328. color: $font-color-dark;
  329. position: relative;
  330. &.current {
  331. color: $base-color;
  332. &:after {
  333. content: '';
  334. position: absolute;
  335. left: 50%;
  336. bottom: 0;
  337. transform: translateX(-50%);
  338. width: 44px;
  339. height: 0;
  340. border-bottom: 2px solid $base-color;
  341. }
  342. }
  343. }
  344. }
  345. .uni-swiper-item {
  346. height: auto;
  347. }
  348. .order-item {
  349. width: 702rpx;
  350. background: #ffffff;
  351. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  352. border-radius: 20rpx;
  353. margin: 20rpx auto 0;
  354. padding: 24rpx;
  355. .order-top-left {
  356. display: flex;
  357. align-items: center;
  358. .order-top-left-image {
  359. width: 32rpx;
  360. height: 37rpx;
  361. }
  362. .order-top-left-font {
  363. margin-left: 10rpx;
  364. font-size: 30rpx;
  365. font-family: PingFang SC;
  366. font-weight: bold;
  367. color: #333333;
  368. }
  369. }
  370. .order-top-right {
  371. font-size: 26rpx;
  372. font-family: PingFang SC;
  373. font-weight: 500;
  374. color: #ff6f0f;
  375. }
  376. .order-info {
  377. margin-top: 24rpx;
  378. align-items: flex-start;
  379. .order-info-left {
  380. width: 200rpx;
  381. font-size: 28rpx;
  382. font-family: PingFang SC;
  383. font-weight: 500;
  384. color: #666666;
  385. }
  386. .order-info-right {
  387. font-size: 28rpx;
  388. font-family: PingFang SC;
  389. font-weight: bold;
  390. color: #333333;
  391. }
  392. .order-info-picture {
  393. display: flex;
  394. justify-content: flex-end;
  395. .order-info-picture-item {
  396. width: 130rpx;
  397. height: 130rpx;
  398. margin-left: 10rpx;
  399. image {
  400. width: 100%;
  401. height: 100%;
  402. }
  403. }
  404. }
  405. .order-info-address {
  406. display: flex;
  407. align-items: center;
  408. .order-info-address-main {
  409. font-size: 24rpx;
  410. font-family: PingFang SC;
  411. font-weight: bold;
  412. color: #333333;
  413. margin-right: 10rpx;
  414. }
  415. .order-info-address-icon {
  416. width: 24rpx;
  417. height: 24rpx;
  418. }
  419. .order-info-dh {
  420. margin-left: 4rpx;
  421. font-size: 24rpx;
  422. font-family: PingFang SC;
  423. font-weight: 500;
  424. color: #ff6f0f;
  425. }
  426. }
  427. }
  428. .order-btn-box {
  429. display: flex;
  430. justify-content: space-between;
  431. .btn1 {
  432. border: 1px solid #24a17d !important;
  433. color: #24a17d !important;
  434. }
  435. .btn2 {
  436. border: none !important;
  437. background: #ff6f0f;
  438. color: #fff !important;
  439. }
  440. .order-btn {
  441. margin-top: 34rpx;
  442. align-items: center;
  443. display: flex;
  444. justify-content: center;
  445. width: 211rpx;
  446. height: 74rpx;
  447. border: 1px solid #cdcdcd;
  448. border-radius: 10rpx;
  449. color: #666666;
  450. .order-btn-icon {
  451. width: 38rpx;
  452. height: 38rpx;
  453. }
  454. .order-btn-icon1 {
  455. width: 32rpx;
  456. height: 34rpx;
  457. }
  458. .order-btn-icon2 {
  459. width: 36rpx;
  460. height: 32rpx;
  461. }
  462. .order-btn-font {
  463. margin-left: 7rpx;
  464. font-size: 26rpx;
  465. font-family: PingFang SC;
  466. font-weight: 500;
  467. }
  468. }
  469. }
  470. .ordering-btn {
  471. display: flex;
  472. justify-content: center;
  473. margin: 38rpx auto 0;
  474. width: 566rpx;
  475. height: 74rpx;
  476. background: #24a17d;
  477. border-radius: 15rpx;
  478. .ordering-btn-icon {
  479. width: 32rpx;
  480. height: 34rpx;
  481. }
  482. .ordering-btn-font {
  483. margin-left: 14rpx;
  484. font-size: 30rpx;
  485. font-family: PingFang SC;
  486. font-weight: bold;
  487. color: #ffffff;
  488. }
  489. }
  490. }
  491. /* load-more */
  492. .uni-load-more {
  493. display: flex;
  494. flex-direction: row;
  495. height: 80rpx;
  496. align-items: center;
  497. justify-content: center;
  498. }
  499. @-webkit-keyframes load {
  500. 0% {
  501. opacity: 1;
  502. }
  503. 100% {
  504. opacity: 0.2;
  505. }
  506. }
  507. </style>