order.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. <template>
  2. <view class="container">
  3. <u-sticky bgColor="#fff">
  4. <!-- <view class="search-box">
  5. <u-input placeholder="搜索我的订单" v-model="serviceName"
  6. :customStyle="{backgroundColor: '#eee',borderRadius: '50rpx',padding:'12rpx 30rpx'}" :border="false"
  7. @confirm="getOrderList('reload')">
  8. <template slot="suffix">
  9. <image src="/static/search-02.png" mode="aspectFill" style="width: 40rpx;height: 36rpx;"
  10. @click="getOrderList('reload')">
  11. </image>
  12. </template>
  13. </u-input>
  14. </view> -->
  15. <u-tabs :lineWidth="50" :activeStyle="{ color: '#4B91D1' }" :list="typeList" keyName="value"
  16. :current="current" @change="changeTab"></u-tabs>
  17. </u-sticky>
  18. <view class="order-list">
  19. <view class="order-item" v-for="item,index in orderList" :key="index" @click="toDetails(item)">
  20. <!-- 头部为左右结构,左边为名称、订单编号,右边为订单金额 -->
  21. <view class="order-t-box">
  22. <view class="order-t-box-l">
  23. <view class="order-name">
  24. {{item.serviceName || '-'}}(数量:{{item.orderNum || '-'}})
  25. </view>
  26. <view class="order-no">
  27. <span>订单编号:{{item.orderNo || '-'}}</span>
  28. <image class="icon" :src="copyImg" mode="aspectFill"
  29. @click.stop="$utils.copyTxt(item.orderNo)"></image>
  30. </view>
  31. </view>
  32. <view class="order-t-box-r">
  33. <span class="title">订单金额</span>
  34. <span class="price">¥{{item.totalPrice || '-'}}</span>
  35. </view>
  36. </view>
  37. <u-line color="#f0f0f0"></u-line>
  38. <view class="order-b-box">
  39. <view class="order-b-box-l">
  40. <view class="order-b-item">
  41. <span class="title">医院:</span>
  42. <span class="txt">{{item.hospitalVo.name || '-'}}</span>
  43. </view>
  44. <view class="order-b-item">
  45. <span class="title">科室:</span>
  46. <span class="txt">{{item.hospitalDepartmentName || '-'}}</span>
  47. </view>
  48. <view class="order-b-item">
  49. <span class="title">就诊人:</span>
  50. <span class="txt">{{item.patientVo.name || '-'}}({{item.patientVo.mobile || '-'}})</span>
  51. </view>
  52. </view>
  53. <view class="order-b-box-r">
  54. <span class="status"
  55. :class="item.status == 6 ? 'cancle' : ''">{{getStatusTxt(item.status)}}</span>
  56. </view>
  57. </view>
  58. <u-line color="#f0f0f0"></u-line>
  59. <view class="btn-box">
  60. <span class="time">{{$utils.mFormatDate(item.expectedTime, 'yyyy-MM-dd HH:mm') || '-'}}</span>
  61. <view class="btn-box-r">
  62. <span class="btn btn1" v-if="item.status == 1" @click.stop="cancleOrder(item.id)">取消订单</span>
  63. <!-- -->
  64. <span class="btn btn2" v-if="item.status == 2 || item.status == 3" @click.stop="contactPerson(item.id)">联系护工</span>
  65. <span class="btn btn2" v-if="item.status == 5" @click.stop="goEvaluation(item.id)">去评价</span>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. <view class="empty-box" v-if="!orderList.length">
  71. <u-image src="/static/none.png" mode="aspectFill" width="582rpx" height="582rpx"></u-image>
  72. <span class="empty-txt">暂无数据!</span>
  73. <!-- <u-empty marginTop="100" style="width: 100%;"></u-empty> -->
  74. </view>
  75. <view style="width: 100%;padding-bottom: 40rpx;" v-else>
  76. <u-loadmore :status="status" :loading-text="loadingText" :loadmore-text="loadmoreText"
  77. :nomore-text="nomoreText" @loadmore="loadmore" dashed line marginTop="20" />
  78. </view>
  79. <u-popup :overlayStyle="{'touch-action':'none'}" closeable mode="bottom" :show="popShow" @close="popClose"
  80. @open="open" :round="20">
  81. <view class="pop-box">
  82. <view class="pop-title">联系护工</view>
  83. <view class="pop-content">
  84. <view class="pop-item" v-for="item,index in workerList" :key="index"
  85. @click="confirmAndCall(item.mobile)">
  86. <u-icon name="phone" color="#fff"></u-icon>
  87. <span class="txt">{{item.mobile || '-'}}</span>
  88. </view>
  89. </view>
  90. <view class="footer-btn">
  91. <span class="btn">取消</span>
  92. </view>
  93. </view>
  94. </u-popup>
  95. </view>
  96. </template>
  97. <script>
  98. import {
  99. getOrderList,
  100. getOrderStatus,
  101. cancelOrder
  102. } from "@/api/order.js"
  103. export default {
  104. data() {
  105. return {
  106. copyImg: require('@/static/copy.png'),
  107. serviceName: undefined,
  108. orderStatus: undefined,
  109. orderList: [],
  110. typeList: [],
  111. loading: false,
  112. pageSize: 10,
  113. pageNum: 1,
  114. botLoadingShow: 0, //0不显示 1显示 3.显示没有更多了
  115. loadingShow: false,
  116. status: 'loadmore',
  117. loadingText: '努力加载中',
  118. loadmoreText: '上拉或点击加载更多',
  119. nomoreText: '实在没有了',
  120. total: 0,
  121. customBar: 0, //状态栏高度 + 导航栏高度
  122. status: {
  123. 10: ''
  124. },
  125. current: 0,
  126. isFirst: true,
  127. workerList: [{
  128. mobile: '13555265325',
  129. }, {
  130. mobile: '15800215426',
  131. }, {
  132. mobile: '15074125896',
  133. }],
  134. popShow: false,
  135. }
  136. },
  137. onLoad(option) {
  138. if (option.type) {
  139. this.orderStatus = option.type;
  140. switch (option.type) {
  141. case "10":
  142. this.current = 1;
  143. break;
  144. case "20":
  145. this.current = 2;
  146. break
  147. case "40":
  148. this.current = 4;
  149. break
  150. case "60":
  151. this.current = 6;
  152. break
  153. default:
  154. this.current = 0;
  155. break
  156. }
  157. }
  158. console.log('onLoad');
  159. },
  160. onShow() {
  161. if (this.isFirst) {
  162. this.isFirst = false;
  163. this.init();
  164. } else {
  165. // 获取全局参数
  166. const app = getApp();
  167. if (app.globalData.switchTabParams) {
  168. const params = app.globalData.switchTabParams;
  169. console.log('接收到的参数:', params);
  170. if (params.reload) {
  171. console.log('onShow');
  172. this.init()
  173. // 使用完后可以清除
  174. app.globalData.switchTabParams = null;
  175. return
  176. } else {
  177. }
  178. }
  179. }
  180. },
  181. methods: {
  182. init() {
  183. console.log("初始化");
  184. this.getOrderList("reload")
  185. this.getOrderStatus();
  186. },
  187. open() {
  188. this.popShow = true;
  189. },
  190. popClose() {
  191. this.popShow = false;
  192. },
  193. //拨打电话
  194. confirmAndCall(phoneNumber) {
  195. // 先验证电话号码
  196. if (!this.isValidPhoneNumber(phoneNumber)) {
  197. uni.showToast({
  198. title: '电话号码格式不正确',
  199. icon: 'none'
  200. });
  201. return;
  202. }
  203. // 显示确认对话框
  204. uni.showModal({
  205. title: '确认拨打电话',
  206. content: `确定要拨打 ${phoneNumber} 吗?`,
  207. success: (res) => {
  208. if (res.confirm) {
  209. // 用户点击确定,执行拨打电话
  210. this.makePhoneCall(phoneNumber);
  211. }
  212. }
  213. });
  214. },
  215. isValidPhoneNumber(phoneNumber) {
  216. // 简单的电话号码验证
  217. return /^1[3-9]\d{9}$/.test(phoneNumber);
  218. },
  219. makePhoneCall(phoneNumber) {
  220. uni.makePhoneCall({
  221. phoneNumber: phoneNumber,
  222. success: () => {
  223. console.log('拨打电话成功');
  224. },
  225. fail: (err) => {
  226. console.error('拨打电话失败', err);
  227. uni.showToast({
  228. title: '拨打电话失败',
  229. icon: 'none'
  230. });
  231. }
  232. });
  233. },
  234. changeTab(item) {
  235. // console.log("item", item);
  236. this.pageNum = 1;
  237. this.orderList = [];
  238. this.orderStatus = item.code;
  239. this.getOrderList("reload");
  240. },
  241. getStatusTxt(value) {
  242. let obj = this.typeList.find(item => item.code == value);;
  243. return obj ? obj.value : '-'
  244. },
  245. //取消订单
  246. cancleOrder(id) {
  247. //确认是否删除
  248. uni.showModal({
  249. title: '提示',
  250. content: '确定取消订单吗?',
  251. success: (res) => {
  252. if (res.confirm) {
  253. console.log('用户点击确定');
  254. cancelOrder(id).then(res => {
  255. if (res.code == 200) {
  256. uni.showToast({
  257. title: '取消成功',
  258. icon: 'success'
  259. })
  260. this.init()
  261. }
  262. })
  263. } else if (res.cancel) {
  264. console.log('用户点击取消');
  265. }
  266. },
  267. })
  268. },
  269. //联系护工
  270. contactPerson(item) {
  271. this.open()
  272. },
  273. //去评价
  274. goEvaluation(item) {
  275. uni.navigateTo({
  276. url: '/pages/order/evaluation?id=' + item.id
  277. })
  278. },
  279. //获取订单列表
  280. getOrderList(reload) {
  281. // 验证登录
  282. // let token = uni.getStorageSync('apiToken');
  283. // if (!token) return
  284. let that = this;
  285. if (reload) {
  286. that.pageNum = 1;
  287. that.orderList = [];
  288. }
  289. uni.showLoading({
  290. title: '加载中',
  291. mask: true,
  292. });
  293. let param = {
  294. status: that.orderStatus,
  295. serviceName: that.serviceName,
  296. pageNum: that.pageNum,
  297. pageSize: that.pageSize,
  298. };
  299. getOrderList(param).then(res => {
  300. let data = res.rows;
  301. if (data) {
  302. that.orderList.push(...data); //在列表后面新增新获取的数据
  303. that.total = res.total; //获取数据总页数
  304. if (that.orderList.length >= that.total) {
  305. that.status = 'nomore';
  306. return;
  307. }
  308. } else {
  309. that.status = 'nomore';
  310. }
  311. })
  312. .catch((err) => {
  313. console.log(err);
  314. })
  315. .finally(() => {
  316. uni.hideLoading();
  317. });
  318. },
  319. //查询订单状态
  320. getOrderStatus() {
  321. let that = this;
  322. getOrderStatus().then(res => {
  323. if (res.code == 200) {
  324. let data = res.data.orderStatus;
  325. data.unshift({
  326. value: '全部',
  327. code: undefined,
  328. })
  329. this.typeList = data;
  330. }
  331. })
  332. .catch((err) => {
  333. console.log(err);
  334. })
  335. },
  336. //去详情
  337. toDetails(item) {
  338. uni.navigateTo({
  339. url: '/pages/order/orderDetails?id=' + item.id
  340. })
  341. },
  342. //去验收
  343. toAcceptance(item) {
  344. uni.navigateTo({
  345. url: '/pages/mineOrders/acceptance?id=' + item.id
  346. })
  347. },
  348. //加载更多
  349. loadmore() {
  350. // 如果当前页数大于等于总页数,状态修改为没有更多了,不再继续往下执行代码
  351. if (this.orderList.length >= this.total) {
  352. this.status = 'nomore';
  353. return;
  354. }
  355. this.status = 'loading'; //状态改为加载中
  356. this.pageNum++;
  357. this.getOrderList();
  358. },
  359. onReachBottom() {
  360. this.loadmore();
  361. },
  362. //下拉刷新回调函数
  363. onPullDownRefresh() {
  364. // wx.setStorageSync('isChangeBanner', true);
  365. this.init();
  366. setTimeout(function() {
  367. uni.stopPullDownRefresh();
  368. }, 1000);
  369. },
  370. }
  371. }
  372. </script>
  373. <style lang="scss" scoped>
  374. .container {
  375. background-color: #f6f6f6;
  376. }
  377. .search-box {
  378. display: flex;
  379. align-items: center;
  380. padding: 20rpx;
  381. }
  382. .order-list {
  383. margin: 20rpx;
  384. .order-item {
  385. margin-bottom: 20rpx;
  386. background-color: #fff;
  387. border-radius: 20rpx;
  388. padding: 10rpx 24rpx 30rpx;
  389. .order-t-box {
  390. display: flex;
  391. justify-content: space-between;
  392. align-items: flex-start;
  393. padding: 20rpx 0;
  394. .order-t-box-l {
  395. .order-name {
  396. font-size: 32rpx;
  397. font-weight: bold;
  398. }
  399. .order-no {
  400. display: flex;
  401. align-items: center;
  402. margin-top: 15rpx;
  403. font-size: 24rpx;
  404. color: #6F6F6F;
  405. .icon {
  406. width: 40rpx;
  407. height: 40rpx;
  408. margin-left: 10rpx;
  409. }
  410. }
  411. }
  412. .order-t-box-r {
  413. display: flex;
  414. align-items: center;
  415. flex-direction: column;
  416. .title {
  417. font-size: 24rpx;
  418. color: #6F6F6F;
  419. }
  420. .price {
  421. margin-top: 15rpx;
  422. font-size: 32rpx;
  423. font-weight: bold;
  424. color: #FF0000;
  425. }
  426. }
  427. }
  428. .order-b-box {
  429. display: flex;
  430. justify-content: space-between;
  431. align-items: center;
  432. padding: 20rpx 0;
  433. .order-b-box-l {
  434. flex: 1;
  435. .order-b-item {
  436. margin-bottom: 15rpx;
  437. &:last-child {
  438. margin-bottom: 0;
  439. }
  440. .title {
  441. font-size: 26rpx;
  442. color: #1A1A1A;
  443. }
  444. .txt {
  445. font-size: 26rpx;
  446. color: #808080;
  447. }
  448. }
  449. }
  450. .order-b-box-r {
  451. width: 110rpx;
  452. text-align: right;
  453. font-size: 24rpx;
  454. color: #0085FF;
  455. .cancle {
  456. color: #FF0000;
  457. }
  458. }
  459. }
  460. .btn-box {
  461. display: flex;
  462. align-items: center;
  463. justify-content: space-between;
  464. margin-top: 15rpx;
  465. .time {
  466. font-size: 24rpx;
  467. color: #6F6F6F;
  468. }
  469. .btn-box-r {
  470. display: flex;
  471. align-items: center;
  472. .btn {
  473. width: 160rpx;
  474. height: 60rpx;
  475. margin-left: 20rpx;
  476. line-height: 60rpx;
  477. text-align: center;
  478. background-color: #4B91D1;
  479. color: #fff;
  480. border-radius: 30rpx;
  481. font-size: 24rpx;
  482. }
  483. .btn1 {
  484. background-color: #fff;
  485. border: 1rpx solid #4B91D1;
  486. color: #4B91D1;
  487. }
  488. }
  489. }
  490. }
  491. }
  492. .pop-box {
  493. .pop-title {
  494. font-size: 32rpx;
  495. font-weight: bold;
  496. text-align: center;
  497. padding: 20rpx 0;
  498. }
  499. .pop-content {
  500. display: flex;
  501. flex-direction: column;
  502. align-items: center;
  503. margin-top: 30rpx;
  504. font-size: 28rpx;
  505. color: #6F6F6F;
  506. padding: 0 20rpx;
  507. &>view {
  508. margin-bottom: 20rpx;
  509. &:last-child {
  510. margin-bottom: 0;
  511. }
  512. }
  513. .pop-item {
  514. display: flex;
  515. align-items: center;
  516. justify-content: center;
  517. width: 500rpx;
  518. padding: 20rpx 0;
  519. background-color: #4B91D1;
  520. border-radius: 40rpx;
  521. color: #fff;
  522. .txt {
  523. font-size: 28rpx;
  524. }
  525. }
  526. }
  527. .footer-btn {
  528. display: flex;
  529. flex-direction: column;
  530. align-items: center;
  531. margin-top: 60rpx;
  532. .btn {
  533. width: 500rpx;
  534. padding: 20rpx 0;
  535. border: 1rpx solid #4B91D1;
  536. border-radius: 40rpx;
  537. color: #333;
  538. text-align: center;
  539. }
  540. }
  541. }
  542. </style>