list.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  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. <!-- 联系管理老师 -->
  62. <view class="btn-box-r" v-if="roleType == 'guanli'">
  63. <!-- 待确认 -->
  64. <span class="btn " v-if="item.status == 1" @click.stop="cancleOrder(item.id)">取消订单</span>
  65. <span class="btn btn2" v-if="item.status == 1"
  66. @click.stop="allocation(item.id,item.hospitalId,item.hospitalVo.name)">分配护工</span>
  67. <!-- 待服务,服务中 -->
  68. <span class="btn btn1" v-if="item.status == 2 || item.status == 3"
  69. @click.stop="contactPerson(item.id)">联系护工</span>
  70. <span class="btn btn2" v-if="item.status == 2 || item.status == 3"
  71. @click.stop="changeCaregiver(item.id,item.hospitalId,item.hospitalVo.name)">更换护工</span>
  72. <!-- <span class="btn " v-if="item.status == 1 || item.status == 2 "
  73. @click.stop="contactPerson(item.id)">联系管理老师</span>
  74. <span class="btn btn1" v-if="item.status == 1" @click.stop="startOrder(item.id)">开始服务</span>
  75. <span class="btn btn2" v-if="item.status == 2" @click.stop="confirmOrder(item.id)">完成服务</span> -->
  76. </view>
  77. <!-- 护工 -->
  78. <view class="btn-box-r" v-if="roleType == 'hugong'">
  79. <span class="btn btn2" v-if="item.status == 2 || item.status == 3"
  80. @click.stop="contactPersonManage(item.id)">联系管理老师</span>
  81. <span class="btn " v-if="item.status == 2" @click.stop="startService(item.id)">开始服务</span>
  82. <span class="btn " v-if="item.status == 3" @click.stop="finishService(item.id)">完成服务</span>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. <view class="empty-box" v-if="!orderList.length">
  88. <u-image src="/static/none.png" mode="aspectFill" width="582rpx" height="582rpx"></u-image>
  89. <span class="empty-txt">暂无数据!</span>
  90. <!-- <u-empty marginTop="100" style="width: 100%;"></u-empty> -->
  91. </view>
  92. <view style="width: 100%;padding-bottom: 40rpx;" v-else>
  93. <u-loadmore :status="status" :loading-text="loadingText" :loadmore-text="loadmoreText"
  94. :nomore-text="nomoreText" @loadmore="loadmore" dashed line marginTop="20" />
  95. </view>
  96. <u-popup :overlayStyle="{'touch-action':'none'}" closeable mode="bottom" :show="popShow" @close="popClose"
  97. @open="open" :round="20">
  98. <view class="pop-box">
  99. <view class="pop-title">联系{{popTitle}}</view>
  100. <view class="pop-content">
  101. <view class="pop-item" v-for="item,index in workerList" :key="index" @click="confirmAndCall(item)">
  102. <u-icon name="phone" color="#fff"></u-icon>
  103. <span class="txt">{{item || '-'}}</span>
  104. </view>
  105. </view>
  106. <view class="footer-btn">
  107. <span class="btn">取消</span>
  108. </view>
  109. </view>
  110. </u-popup>
  111. </view>
  112. </template>
  113. <script>
  114. import {
  115. getOrderList,
  116. getOrderStatus,
  117. } from "@/api/order.js"
  118. import {
  119. getManageOrderList,
  120. getNursePhone,
  121. getManagePhone,
  122. cancelOrderManage,
  123. startService,
  124. finishService,
  125. getNurseOrderList
  126. } from "@/api/hospital.js"
  127. export default {
  128. data() {
  129. return {
  130. copyImg: require('@/static/copy.png'),
  131. serviceName: undefined,
  132. orderStatus: undefined,
  133. roleType: 'guanli',
  134. orderList: [{
  135. status: 1,
  136. }, {
  137. status: 2,
  138. }],
  139. typeList: [],
  140. loading: false,
  141. pageSize: 10,
  142. pageNum: 1,
  143. botLoadingShow: 0, //0不显示 1显示 3.显示没有更多了
  144. loadingShow: false,
  145. status: 'loadmore',
  146. loadingText: '努力加载中',
  147. loadmoreText: '上拉或点击加载更多',
  148. nomoreText: '实在没有了',
  149. total: 0,
  150. customBar: 0, //状态栏高度 + 导航栏高度
  151. status: {
  152. 10: ''
  153. },
  154. current: 0,
  155. isFirst: true,
  156. workerList: [{
  157. mobile: '13555265325',
  158. }, {
  159. mobile: '15800215426',
  160. }, {
  161. mobile: '15074125896',
  162. }],
  163. popShow: false,
  164. popTitle: '护工',
  165. }
  166. },
  167. onLoad(option) {
  168. let roleType = uni.getStorageSync('roleType');
  169. if (roleType) { //当前权限
  170. this.roleType = roleType
  171. }
  172. if (option.type) { //订单状态
  173. this.orderStatus = option.type;
  174. if (roleType == 'hugong') {
  175. this.current = option.type - 1;
  176. } else {
  177. this.current = option.type;
  178. }
  179. }
  180. },
  181. onShow() {
  182. if (this.isFirst) {
  183. this.isFirst = false;
  184. } else {
  185. // 获取全局参数
  186. const app = getApp();
  187. if (app.globalData.switchTabParams) {
  188. const params = app.globalData.switchTabParams;
  189. console.log('接收到的参数:', params);
  190. if (params.reload) {
  191. console.log('onShow');
  192. this.init()
  193. // 使用完后可以清除
  194. app.globalData.switchTabParams = null;
  195. return
  196. } else {
  197. }
  198. }
  199. }
  200. },
  201. onLoad() {
  202. this.init();
  203. },
  204. methods: {
  205. init() {
  206. console.log("初始化");
  207. this.getOrderList("reload")
  208. this.getOrderStatus();
  209. },
  210. //获取订单列表
  211. getOrderList(reload) {
  212. // 验证登录
  213. // let token = uni.getStorageSync('apiToken');
  214. // if (!token) return
  215. let that = this;
  216. if (reload) {
  217. that.pageNum = 1;
  218. that.orderList = [];
  219. }
  220. uni.showLoading({
  221. title: '加载中',
  222. mask: true,
  223. });
  224. let param = {
  225. status: that.orderStatus,
  226. pageNum: that.pageNum,
  227. pageSize: that.pageSize,
  228. };
  229. if (that.roleType == 'guanli') {
  230. getManageOrderList(param).then(res => {
  231. let data = res.rows;
  232. if (data) {
  233. that.orderList.push(...data); //在列表后面新增新获取的数据
  234. that.total = res.total; //获取数据总页数
  235. if (that.orderList.length >= that.total) {
  236. that.status = 'nomore';
  237. return;
  238. }
  239. } else {
  240. that.status = 'nomore';
  241. }
  242. })
  243. .catch((err) => {
  244. console.log(err);
  245. })
  246. .finally(() => {
  247. uni.hideLoading();
  248. });
  249. } else {
  250. getNurseOrderList(param).then(res => {
  251. let data = res.rows;
  252. if (data) {
  253. that.orderList.push(...data); //在列表后面新增新获取的数据
  254. that.total = res.total; //获取数据总页数
  255. if (that.orderList.length >= that.total) {
  256. that.status = 'nomore';
  257. return;
  258. }
  259. } else {
  260. that.status = 'nomore';
  261. }
  262. })
  263. .catch((err) => {
  264. console.log(err);
  265. })
  266. .finally(() => {
  267. uni.hideLoading();
  268. });
  269. }
  270. },
  271. //查询订单状态
  272. getOrderStatus() {
  273. let that = this;
  274. getOrderStatus().then(res => {
  275. if (res.code == 200) {
  276. let data = res.data.orderStatus;
  277. //data数据,根据 roleType 判断显示的订单状态,如果为hugong,则不显示待确认
  278. if (that.roleType == 'hugong') {
  279. data = data.filter(item => item.code != '1')
  280. console.log("data", data);
  281. }
  282. data.unshift({
  283. value: '全部',
  284. code: undefined,
  285. })
  286. this.typeList = data;
  287. }
  288. })
  289. .catch((err) => {
  290. console.log(err);
  291. })
  292. },
  293. //分配护工/更换护工
  294. allocation(orderNo, hospitalId, hospitalName) {
  295. uni.navigateTo({
  296. url: '/pages/workbench/caregiverManage?orderNo=' + orderNo + '&type=fenpei' + '&hospitalId=' +
  297. hospitalId + '&hospitalName=' + hospitalName
  298. })
  299. },
  300. changeCaregiver(orderNo, hospitalId, hospitalName) {
  301. uni.navigateTo({
  302. url: '/pages/workbench/caregiverManage?orderNo=' + orderNo + '&type=genghuan' +
  303. '&hospitalId=' +
  304. hospitalId + '&hospitalName=' + hospitalName
  305. })
  306. },
  307. open() {
  308. this.popShow = true;
  309. },
  310. popClose() {
  311. this.popShow = false;
  312. },
  313. //拨打电话
  314. confirmAndCall(phoneNumber) {
  315. // 先验证电话号码
  316. if (!this.isValidPhoneNumber(phoneNumber)) {
  317. uni.showToast({
  318. title: '电话号码格式不正确',
  319. icon: 'none'
  320. });
  321. return;
  322. }
  323. // 显示确认对话框
  324. uni.showModal({
  325. title: '确认拨打电话',
  326. content: `确定要拨打 ${phoneNumber} 吗?`,
  327. success: (res) => {
  328. if (res.confirm) {
  329. // 用户点击确定,执行拨打电话
  330. this.makePhoneCall(phoneNumber);
  331. }
  332. }
  333. });
  334. },
  335. isValidPhoneNumber(phoneNumber) {
  336. // 简单的电话号码验证
  337. return /^1[3-9]\d{9}$/.test(phoneNumber);
  338. },
  339. makePhoneCall(phoneNumber) {
  340. uni.makePhoneCall({
  341. phoneNumber: phoneNumber,
  342. success: () => {
  343. console.log('拨打电话成功');
  344. },
  345. fail: (err) => {
  346. console.error('拨打电话失败', err);
  347. uni.showToast({
  348. title: '拨打电话失败',
  349. icon: 'none'
  350. });
  351. }
  352. });
  353. },
  354. changeTab(item) {
  355. // console.log("item", item);
  356. this.pageNum = 1;
  357. this.orderList = [];
  358. this.orderStatus = item.code;
  359. this.getOrderList("reload");
  360. },
  361. getStatusTxt(value) {
  362. let obj = this.typeList.find(item => item.code == value);;
  363. return obj ? obj.value : '-'
  364. },
  365. //取消订单
  366. cancleOrder(id) {
  367. //确认是否删除
  368. uni.showModal({
  369. title: '提示',
  370. content: '确定取消订单吗?',
  371. success: (res) => {
  372. if (res.confirm) {
  373. console.log('用户点击确定');
  374. cancelOrderManage(id).then(res => {
  375. if (res.code == 200) {
  376. uni.showToast({
  377. title: '取消成功',
  378. icon: 'success'
  379. })
  380. this.getOrderList("reload")
  381. }
  382. })
  383. } else if (res.cancel) {
  384. console.log('用户点击取消');
  385. }
  386. },
  387. })
  388. },
  389. //联系护工
  390. contactPerson(id) {
  391. let that = this;
  392. getNursePhone(id).then(res => {
  393. if (res.code == 200) {
  394. that.popTitle = '护工'
  395. that.workerList = [res.msg];
  396. that.open()
  397. }
  398. })
  399. .catch((err) => {
  400. console.log(err);
  401. })
  402. },
  403. //联系管理老师
  404. contactPersonManage(id) {
  405. let that = this;
  406. getManagePhone(id).then(res => {
  407. if (res.code == 200) {
  408. that.popTitle = '管理老师'
  409. that.workerList = [res.msg];
  410. that.open()
  411. }
  412. })
  413. .catch((err) => {
  414. console.log(err);
  415. })
  416. },
  417. //开始服务
  418. startService(id) {
  419. //确认是否
  420. uni.showModal({
  421. title: '提示',
  422. content: '确定开始服务吗?',
  423. success: (res) => {
  424. if (res.confirm) {
  425. startService(id).then(res => {
  426. if (res.code == 200) {
  427. uni.showToast({
  428. title: '开始成功',
  429. icon: 'success'
  430. })
  431. this.getOrderList("reload")
  432. }
  433. })
  434. } else if (res.cancel) {
  435. console.log('用户点击取消');
  436. }
  437. },
  438. })
  439. },
  440. //完成服务
  441. finishService(id) {
  442. //确认是否
  443. uni.showModal({
  444. title: '提示',
  445. content: '确定完成服务吗?',
  446. success: (res) => {
  447. if (res.confirm) {
  448. finishService(id).then(res => {
  449. if (res.code == 200) {
  450. uni.showToast({
  451. title: '确认成功',
  452. icon: 'success'
  453. })
  454. this.getOrderList("reload")
  455. }
  456. })
  457. } else if (res.cancel) {
  458. console.log('用户点击取消');
  459. }
  460. },
  461. })
  462. },
  463. //去评价
  464. // goEvaluation(item) {
  465. // uni.navigateTo({
  466. // url: '/pages/order/evaluation?id=' + item.id
  467. // })
  468. // },
  469. //去详情
  470. toDetails(item) {
  471. uni.navigateTo({
  472. url: '/pages/workbench/order/orderDetails?id=' + item.id
  473. })
  474. },
  475. //去验收
  476. toAcceptance(item) {
  477. uni.navigateTo({
  478. url: '/pages/mineOrders/acceptance?id=' + item.id
  479. })
  480. },
  481. //加载更多
  482. loadmore() {
  483. // 如果当前页数大于等于总页数,状态修改为没有更多了,不再继续往下执行代码
  484. if (this.orderList.length >= this.total) {
  485. this.status = 'nomore';
  486. return;
  487. }
  488. this.status = 'loading'; //状态改为加载中
  489. this.pageNum++;
  490. this.getOrderList();
  491. },
  492. onReachBottom() {
  493. this.loadmore();
  494. },
  495. //下拉刷新回调函数
  496. onPullDownRefresh() {
  497. // wx.setStorageSync('isChangeBanner', true);
  498. this.init();
  499. setTimeout(function() {
  500. uni.stopPullDownRefresh();
  501. }, 1000);
  502. },
  503. }
  504. }
  505. </script>
  506. <style lang="scss" scoped>
  507. .container {
  508. background-color: #f6f6f6;
  509. }
  510. .search-box {
  511. display: flex;
  512. align-items: center;
  513. padding: 20rpx;
  514. }
  515. .order-list {
  516. margin: 20rpx;
  517. .order-item {
  518. margin-bottom: 20rpx;
  519. background-color: #fff;
  520. border-radius: 20rpx;
  521. padding: 10rpx 24rpx 30rpx;
  522. .order-t-box {
  523. display: flex;
  524. justify-content: space-between;
  525. align-items: flex-start;
  526. padding: 20rpx 0;
  527. .order-t-box-l {
  528. .order-name {
  529. font-size: 32rpx;
  530. font-weight: bold;
  531. }
  532. .order-no {
  533. display: flex;
  534. align-items: center;
  535. margin-top: 15rpx;
  536. font-size: 24rpx;
  537. color: #6F6F6F;
  538. .icon {
  539. width: 40rpx;
  540. height: 40rpx;
  541. margin-left: 10rpx;
  542. }
  543. }
  544. }
  545. .order-t-box-r {
  546. display: flex;
  547. align-items: center;
  548. flex-direction: column;
  549. .title {
  550. font-size: 24rpx;
  551. color: #6F6F6F;
  552. }
  553. .price {
  554. margin-top: 15rpx;
  555. font-size: 32rpx;
  556. font-weight: bold;
  557. color: #FF0000;
  558. }
  559. }
  560. }
  561. .order-b-box {
  562. display: flex;
  563. justify-content: space-between;
  564. align-items: center;
  565. padding: 20rpx 0;
  566. .order-b-box-l {
  567. flex: 1;
  568. .order-b-item {
  569. margin-bottom: 15rpx;
  570. &:last-child {
  571. margin-bottom: 0;
  572. }
  573. .title {
  574. font-size: 26rpx;
  575. color: #1A1A1A;
  576. }
  577. .txt {
  578. font-size: 26rpx;
  579. color: #808080;
  580. }
  581. }
  582. }
  583. .order-b-box-r {
  584. width: 110rpx;
  585. text-align: right;
  586. font-size: 24rpx;
  587. color: #0085FF;
  588. .cancle {
  589. color: #FF0000;
  590. }
  591. }
  592. }
  593. .btn-box {
  594. display: flex;
  595. align-items: center;
  596. justify-content: space-between;
  597. margin-top: 15rpx;
  598. .time {
  599. font-size: 24rpx;
  600. color: #6F6F6F;
  601. }
  602. .btn-box-r {
  603. display: flex;
  604. align-items: center;
  605. .btn {
  606. width: 170rpx;
  607. height: 60rpx;
  608. margin-left: 20rpx;
  609. line-height: 60rpx;
  610. text-align: center;
  611. background-color: #fff;
  612. border: 1rpx solid #4B91D1;
  613. color: #4B91D1;
  614. border-radius: 30rpx;
  615. font-size: 24rpx;
  616. }
  617. .btn1 {
  618. background-color: #00aa00;
  619. border: 1rpx solid #00aa00;
  620. color: #fff;
  621. }
  622. .btn2 {
  623. background-color: #4B91D1;
  624. border: 1rpx solid #4B91D1;
  625. color: #fff;
  626. }
  627. }
  628. }
  629. }
  630. }
  631. .pop-box {
  632. .pop-title {
  633. font-size: 32rpx;
  634. font-weight: bold;
  635. text-align: center;
  636. padding: 20rpx 0;
  637. }
  638. .pop-content {
  639. display: flex;
  640. flex-direction: column;
  641. align-items: center;
  642. margin-top: 30rpx;
  643. font-size: 28rpx;
  644. color: #6F6F6F;
  645. padding: 0 20rpx;
  646. &>view {
  647. margin-bottom: 20rpx;
  648. &:last-child {
  649. margin-bottom: 0;
  650. }
  651. }
  652. .pop-item {
  653. display: flex;
  654. align-items: center;
  655. justify-content: center;
  656. width: 500rpx;
  657. padding: 20rpx 0;
  658. background-color: #4B91D1;
  659. border-radius: 40rpx;
  660. color: #fff;
  661. .txt {
  662. font-size: 28rpx;
  663. }
  664. }
  665. }
  666. .footer-btn {
  667. display: flex;
  668. flex-direction: column;
  669. align-items: center;
  670. margin-top: 60rpx;
  671. .btn {
  672. width: 500rpx;
  673. padding: 20rpx 0;
  674. border: 1rpx solid #4B91D1;
  675. border-radius: 40rpx;
  676. color: #333;
  677. text-align: center;
  678. }
  679. }
  680. }
  681. </style>