order.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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. <span class="btn" v-if="item.status !=6" @click.stop="cancleOrder(item.id)">取消订单</span>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="empty-box" v-if="!orderList.length">
  66. <u-image src="/static/none.png" mode="aspectFill" width="582rpx" height="582rpx"></u-image>
  67. <span class="empty-txt">暂无数据!</span>
  68. <!-- <u-empty marginTop="100" style="width: 100%;"></u-empty> -->
  69. </view>
  70. <view style="width: 100%;padding-bottom: 40rpx;" v-else>
  71. <u-loadmore :status="status" :loading-text="loadingText" :loadmore-text="loadmoreText"
  72. :nomore-text="nomoreText" @loadmore="loadmore" dashed line marginTop="20" />
  73. </view>
  74. </view>
  75. </template>
  76. <script>
  77. import {
  78. getOrderList,
  79. getOrderStatus,
  80. cancelOrder
  81. } from "@/api/order.js"
  82. export default {
  83. data() {
  84. return {
  85. copyImg: require('@/static/copy.png'),
  86. serviceName: undefined,
  87. orderStatus: undefined,
  88. orderList: [],
  89. typeList: [],
  90. loading: false,
  91. pageSize: 10,
  92. pageNum: 1,
  93. botLoadingShow: 0, //0不显示 1显示 3.显示没有更多了
  94. loadingShow: false,
  95. status: 'loadmore',
  96. loadingText: '努力加载中',
  97. loadmoreText: '上拉或点击加载更多',
  98. nomoreText: '实在没有了',
  99. total: 0,
  100. customBar: 0, //状态栏高度 + 导航栏高度
  101. status: {
  102. 10: ''
  103. },
  104. current: 0,
  105. isFirst: true,
  106. }
  107. },
  108. onLoad(option) {
  109. if (option.type) {
  110. this.orderStatus = option.type;
  111. switch (option.type) {
  112. case "10":
  113. this.current = 1;
  114. break;
  115. case "20":
  116. this.current = 2;
  117. break
  118. case "40":
  119. this.current = 4;
  120. break
  121. case "60":
  122. this.current = 6;
  123. break
  124. default:
  125. this.current = 0;
  126. break
  127. }
  128. }
  129. console.log('onLoad');
  130. },
  131. onShow() {
  132. if (this.isFirst) {
  133. this.isFirst = false;
  134. this.init();
  135. } else {
  136. // 获取全局参数
  137. const app = getApp();
  138. if (app.globalData.switchTabParams) {
  139. const params = app.globalData.switchTabParams;
  140. console.log('接收到的参数:', params);
  141. if (params.reload) {
  142. console.log('onShow');
  143. this.init()
  144. // 使用完后可以清除
  145. app.globalData.switchTabParams = null;
  146. return
  147. } else {
  148. }
  149. }
  150. }
  151. },
  152. methods: {
  153. init() {
  154. console.log("初始化");
  155. this.getOrderList("reload")
  156. this.getOrderStatus();
  157. },
  158. changeTab(item) {
  159. // console.log("item", item);
  160. this.pageNum = 1;
  161. this.orderList = [];
  162. this.orderStatus = item.code;
  163. this.getOrderList("reload");
  164. },
  165. getStatusTxt(value) {
  166. let obj = this.typeList.find(item => item.code == value);;
  167. return obj ? obj.value : '-'
  168. },
  169. cancleOrder(id) {
  170. //确认是否删除
  171. uni.showModal({
  172. title: '提示',
  173. content: '确定取消订单吗?',
  174. success: (res) => {
  175. if (res.confirm) {
  176. console.log('用户点击确定');
  177. cancelOrder(id).then(res => {
  178. if (res.code == 200) {
  179. uni.showToast({
  180. title: '取消成功',
  181. icon: 'success'
  182. })
  183. this.init()
  184. }
  185. })
  186. } else if (res.cancel) {
  187. console.log('用户点击取消');
  188. }
  189. },
  190. })
  191. },
  192. getOrderList(reload) {
  193. // 验证登录
  194. // let token = uni.getStorageSync('apiToken');
  195. // if (!token) return
  196. let that = this;
  197. if (reload) {
  198. that.pageNum = 1;
  199. that.orderList = [];
  200. }
  201. uni.showLoading({
  202. title: '加载中',
  203. mask: true,
  204. });
  205. let param = {
  206. status: that.orderStatus,
  207. serviceName: that.serviceName,
  208. pageNum: that.pageNum,
  209. pageSize: that.pageSize,
  210. };
  211. getOrderList(param).then(res => {
  212. let data = res.rows;
  213. if (data) {
  214. that.orderList.push(...data); //在列表后面新增新获取的数据
  215. that.total = res.total; //获取数据总页数
  216. if (that.orderList.length >= that.total) {
  217. that.status = 'nomore';
  218. return;
  219. }
  220. } else {
  221. that.status = 'nomore';
  222. }
  223. })
  224. .catch((err) => {
  225. console.log(err);
  226. })
  227. .finally(() => {
  228. uni.hideLoading();
  229. });
  230. },
  231. //查询订单状态
  232. getOrderStatus() {
  233. let that = this;
  234. getOrderStatus().then(res => {
  235. if (res.code == 200) {
  236. let data = res.data.orderStatus;
  237. data.unshift({
  238. value: '全部',
  239. code: undefined,
  240. })
  241. this.typeList = data;
  242. }
  243. })
  244. .catch((err) => {
  245. console.log(err);
  246. })
  247. },
  248. //去详情
  249. toDetails(item) {
  250. uni.navigateTo({
  251. url: '/pages/order/orderDetails?id=' + item.id
  252. })
  253. },
  254. //去验收
  255. toAcceptance(item) {
  256. uni.navigateTo({
  257. url: '/pages/mineOrders/acceptance?id=' + item.id
  258. })
  259. },
  260. loadmore() {
  261. // 如果当前页数大于等于总页数,状态修改为没有更多了,不再继续往下执行代码
  262. if (this.orderList.length >= this.total) {
  263. this.status = 'nomore';
  264. return;
  265. }
  266. this.status = 'loading'; //状态改为加载中
  267. this.pageNum++;
  268. this.getOrderList();
  269. },
  270. onReachBottom() {
  271. this.loadmore();
  272. },
  273. //下拉刷新回调函数
  274. onPullDownRefresh() {
  275. // wx.setStorageSync('isChangeBanner', true);
  276. this.init();
  277. setTimeout(function() {
  278. uni.stopPullDownRefresh();
  279. }, 1000);
  280. },
  281. }
  282. }
  283. </script>
  284. <style lang="scss" scoped>
  285. .container {
  286. background-color: #f6f6f6;
  287. }
  288. .search-box {
  289. display: flex;
  290. align-items: center;
  291. padding: 20rpx;
  292. }
  293. .order-list {
  294. margin: 20rpx;
  295. .order-item {
  296. margin-bottom: 20rpx;
  297. background-color: #fff;
  298. border-radius: 20rpx;
  299. padding: 10rpx 24rpx 30rpx;
  300. .order-t-box {
  301. display: flex;
  302. justify-content: space-between;
  303. align-items: flex-start;
  304. padding: 20rpx 0;
  305. .order-t-box-l {
  306. .order-name {
  307. font-size: 32rpx;
  308. font-weight: bold;
  309. }
  310. .order-no {
  311. display: flex;
  312. align-items: center;
  313. margin-top: 15rpx;
  314. font-size: 24rpx;
  315. color: #6F6F6F;
  316. .icon {
  317. width: 40rpx;
  318. height: 40rpx;
  319. margin-left: 10rpx;
  320. }
  321. }
  322. }
  323. .order-t-box-r {
  324. display: flex;
  325. align-items: center;
  326. flex-direction: column;
  327. .title {
  328. font-size: 24rpx;
  329. color: #6F6F6F;
  330. }
  331. .price {
  332. margin-top: 15rpx;
  333. font-size: 32rpx;
  334. font-weight: bold;
  335. color: #FF0000;
  336. }
  337. }
  338. }
  339. .order-b-box {
  340. display: flex;
  341. justify-content: space-between;
  342. align-items: center;
  343. padding: 20rpx 0;
  344. .order-b-box-l {
  345. flex: 1;
  346. .order-b-item {
  347. margin-bottom: 15rpx;
  348. &:last-child {
  349. margin-bottom: 0;
  350. }
  351. .title {
  352. font-size: 26rpx;
  353. color: #1A1A1A;
  354. }
  355. .txt {
  356. font-size: 26rpx;
  357. color: #808080;
  358. }
  359. }
  360. }
  361. .order-b-box-r {
  362. width: 110rpx;
  363. text-align: right;
  364. font-size: 24rpx;
  365. color: #0085FF;
  366. .cancle {
  367. color: #FF0000;
  368. }
  369. }
  370. }
  371. .btn-box {
  372. display: flex;
  373. align-items: center;
  374. justify-content: space-between;
  375. margin-top: 15rpx;
  376. .time {
  377. font-size: 24rpx;
  378. color: #6F6F6F;
  379. }
  380. .btn {
  381. width: 160rpx;
  382. height: 60rpx;
  383. line-height: 60rpx;
  384. text-align: center;
  385. background-color: #4B91D1;
  386. color: #fff;
  387. border-radius: 30rpx;
  388. font-size: 24rpx;
  389. }
  390. }
  391. }
  392. }
  393. </style>