order.vue 8.6 KB

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