packageOrderList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <view class="content">
  3. <view class="top-fixed">
  4. <u-tabs
  5. :current="status"
  6. :scrollable="true"
  7. :list="tabs"
  8. lineColor="#C39A58"
  9. @change="tabChange">
  10. </u-tabs>
  11. </view>
  12. <mescroll-body top="88rpx" bottom="0" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :down="downOption" :up="upOption">
  13. <view class="order-box">
  14. <view class="order-item" @click="showDetails(item)" v-for="(item) in dataList">
  15. <view class="top-box" >
  16. <view class="num">订单号:{{item.orderSn}}</view>
  17. <view class="status-box">
  18. <text class="text info" v-if="item.status==1">
  19. {{$getDictLabelName(orderStatusOptions,item.status)}}
  20. </text>
  21. <text class="text success" v-if="item.status>1">
  22. {{$getDictLabelName(orderStatusOptions,item.status)}}
  23. </text>
  24. <text class="text info" v-if="item.status<0">
  25. {{$getDictLabelName(orderStatusOptions,item.status)}}
  26. </text>
  27. </view>
  28. </view>
  29. <view class="package-box">
  30. <view class="left">
  31. <image :src="item.imgUrl"></image>
  32. </view>
  33. <view class="right">
  34. <view class="title">{{item.packageName}}</view>
  35. <view class="desc">
  36. <view class="cycle">用药周期{{item.cycle}}天</view>
  37. <view class="duration">签约时长{{item.duration}}天</view>
  38. </view>
  39. <!-- <view class="price-box">
  40. <view class="price">¥30元/日</view>
  41. <view class="count">6.2w人已购</view>
  42. </view> -->
  43. </view>
  44. </view>
  45. <view class="bottom-box">
  46. <view class="amount-paid">
  47. <text class="label">订单金额:</text>
  48. <view class="price-box">
  49. <view class="unit">¥</view>
  50. <view class="num" >{{item.payPrice.toFixed(2)}}</view>
  51. </view>
  52. </view>
  53. <view class="btn-box">
  54. <view v-if="item.status == 1" class="btn cancel" @click.stop="cancelOrder(item)">取消订单</view>
  55. <view v-if="item.status == 1" class="btn pay" @click.stop="pay(item)">支付订单</view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </mescroll-body>
  61. </view>
  62. </template>
  63. <script>
  64. import {cancelOrder,getMyPackageOrderList,pay} from '@/api/packageOrder'
  65. import {getDictByKey} from '@/api/common.js'
  66. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  67. export default {
  68. mixins: [MescrollMixin],
  69. data() {
  70. return {
  71. orderStatusOptions:[],
  72. searchKey:"",
  73. status:"0",
  74. tabs: [
  75. {name:"全部",id:"0"},
  76. {name:"待支付",id:"1"},
  77. {name:"服务中",id:"2"},
  78. {name:"已完成",id:"3"},
  79. {name:"已取消",id:"-1"},
  80. {name:"已退款",id:"-2"}
  81. ],
  82. mescroll:null,
  83. downOption: { //下拉刷新
  84. use:true,
  85. auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
  86. },
  87. upOption: {
  88. onScroll:false,
  89. use: true, // 是否启用上拉加载; 默认true
  90. page: {
  91. pae: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  92. size: 10 // 每页数据的数量,默认10
  93. },
  94. noMoreSize: 10, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  95. textNoMore:"已经到底了",
  96. empty: {
  97. icon:'https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png',
  98. tip: '暂无数据'
  99. }
  100. },
  101. dataList: []
  102. }
  103. },
  104. onLoad(options) {
  105. if(options.status!=null){
  106. this.status=options.status
  107. }
  108. var that=this;
  109. uni.$on('refreshPackageOrder', () => {
  110. that.mescroll.resetUpScroll()
  111. })
  112. this.getDictByKey("sys_package_order_status");
  113. },
  114. onShow() {
  115. },
  116. methods: {
  117. pay(item){
  118. uni.navigateTo({
  119. url: '/pages_order/packageOrderPay?orderId='+item.orderId
  120. })
  121. },
  122. getDictByKey(key){
  123. var data={key:key}
  124. getDictByKey(data).then(
  125. res => {
  126. if(res.code==200){
  127. if(key=="sys_package_order_status"){
  128. this.orderStatusOptions=res.data;
  129. }
  130. }
  131. },
  132. err => {
  133. }
  134. );
  135. },
  136. cancelOrder(item){
  137. var that=this;
  138. uni.showModal({
  139. title:"提示",
  140. content:"确认取消订单吗?",
  141. showCancel:true,
  142. cancelText:'取消',
  143. confirmText:'确定',
  144. success:res=>{
  145. if(res.confirm){
  146. // 用户点击确定
  147. var data={orderId:item.orderId}
  148. cancelOrder(data).then(
  149. res => {
  150. if(res.code==200){
  151. uni.$emit('refreshPackageOrder');
  152. uni.showToast({
  153. icon:'success',
  154. title: "操作成功",
  155. });
  156. }else{
  157. uni.showToast({
  158. icon:'none',
  159. title: res.msg,
  160. });
  161. }
  162. },
  163. rej => {}
  164. );
  165. }else{
  166. // 否则点击了取消
  167. }
  168. }
  169. })
  170. },
  171. showDetails(item){
  172. uni.navigateTo({
  173. url:"/pages_order/packageOrderDetails?orderId="+item.orderId
  174. })
  175. },
  176. tabChange(item){
  177. this.status=item.id
  178. console.log(item)
  179. this.mescroll.resetUpScroll()
  180. },
  181. mescrollInit(mescroll) {
  182. this.mescroll = mescroll;
  183. },
  184. /*下拉刷新的回调 */
  185. downCallback(mescroll) {
  186. mescroll.resetUpScroll()
  187. },
  188. upCallback(page) {
  189. //联网加载数据
  190. var that = this;
  191. var data = {
  192. status:this.status,
  193. pageNum: page.num,
  194. pageSize: page.size
  195. };
  196. getMyPackageOrderList(data).then(res => {
  197. if(res.code==200){
  198. //设置列表数据
  199. if (page.num == 1) {
  200. that.dataList = res.data.list;
  201. } else {
  202. that.dataList = that.dataList.concat(res.data.list);
  203. }
  204. that.mescroll.endBySize(res.data.list.length, res.data.total);
  205. }else{
  206. uni.showToast({
  207. icon:'none',
  208. title: "请求失败",
  209. });
  210. that.dataList = null;
  211. that.mescroll.endErr();
  212. }
  213. });
  214. }
  215. }
  216. }
  217. </script>
  218. <style lang="scss">
  219. page{
  220. background: #f6f6f6;
  221. }
  222. </style>
  223. <style scoped lang="scss">
  224. .content{
  225. .top-fixed{
  226. width: 100%;
  227. position: fixed;
  228. top: 0;
  229. left: 0;
  230. z-index: 10;
  231. height: 88upx;
  232. background-color: #fff;
  233. }
  234. .order-box{
  235. padding: 20rpx;
  236. width: 100%;
  237. display: flex;
  238. flex-direction: column;
  239. align-items: center;
  240. justify-content: center;
  241. .order-item{
  242. width: 100%;
  243. border-radius: 10rpx;
  244. background-color: #fff;
  245. padding: 30rpx;
  246. margin-bottom: 20rpx;
  247. display: flex;
  248. flex-direction: column;
  249. align-items: flex-start;
  250. justify-content: flex-start;
  251. .top-box{
  252. width: 100%;
  253. display: flex;
  254. align-items: center;
  255. justify-content: space-between;
  256. .num{
  257. font-size: 26upx;
  258. font-family: PingFang SC;
  259. font-weight: 500;
  260. color: #999999;
  261. line-height: 1;
  262. }
  263. .status-box{
  264. display: flex;
  265. align-items: center;
  266. .text{
  267. font-size: 28upx;
  268. font-family: PingFang SC;
  269. font-weight: 500;
  270. line-height: 1;
  271. &.success{
  272. color: #C39A58;
  273. }
  274. &.black{
  275. color: #111111;
  276. }
  277. &.info{
  278. color: #999999;
  279. }
  280. }
  281. }
  282. }
  283. .package-box{
  284. margin-top: 20rpx;
  285. width: 100%;
  286. display: flex;
  287. align-items: flex-start;
  288. justify-content: flex-start;
  289. .left{
  290. width:200rpx;
  291. height:200rpx;
  292. image{
  293. border-radius: 15rpx;
  294. width:100%;
  295. height:100%;
  296. }
  297. }
  298. .right{
  299. height: 200rpx;
  300. display: flex;
  301. flex-direction: column;
  302. align-items: flex-start;
  303. justify-content: flex-start;
  304. padding-left: 15rpx;
  305. width:calc(100% - 200rpx);
  306. .title{
  307. font-weight: bold;
  308. font-size: 34upx;
  309. font-family: PingFang SC;
  310. color: #111;
  311. }
  312. .desc{
  313. margin-top: 15rpx;
  314. display: flex;
  315. align-items: flex-start;
  316. justify-content: flex-start;
  317. .cycle{
  318. background-color: #eee;
  319. border-radius: 30rpx;
  320. padding: 5rpx 15rpx;
  321. font-size: 26upx;
  322. font-family: PingFang SC;
  323. color: #C39A58;
  324. }
  325. .duration{
  326. margin-left: 10rpx;
  327. background-color: #eee;
  328. border-radius: 30rpx;
  329. padding: 5rpx 15rpx;
  330. font-size: 26upx;
  331. font-family: PingFang SC;
  332. color: #C39A58;
  333. }
  334. }
  335. .price-box{
  336. flex: 1;
  337. display: flex;
  338. align-items: flex-end;
  339. justify-content: space-between;
  340. width: 100%;
  341. .price{
  342. padding: 5rpx 10rpx;
  343. background-color: #C39A58;
  344. border-radius: 30rpx;
  345. font-size: 20upx;
  346. font-family: PingFang SC;
  347. color: #ffffff;
  348. }
  349. .count{
  350. font-size: 24upx;
  351. font-family: PingFang SC;
  352. color: #333333;
  353. }
  354. }
  355. }
  356. }
  357. .bottom-box{
  358. margin-top: 20rpx;
  359. width: 100%;
  360. display: flex;
  361. align-items: center;
  362. justify-content: space-between;
  363. .amount-paid{
  364. display: flex;
  365. align-items: center;
  366. .label{
  367. font-size: 24upx;
  368. font-family: PingFang SC;
  369. font-weight: 500;
  370. color: #999999;
  371. line-height: 1;
  372. }
  373. .price-box{
  374. display: flex;
  375. align-items: flex-end;
  376. .unit{
  377. font-size: 24upx;
  378. font-family: PingFang SC;
  379. font-weight: 500;
  380. color: #FF6633;
  381. line-height: 1.2;
  382. margin-right: 4upx;
  383. }
  384. .num{
  385. font-size: 32upx;
  386. font-family: PingFang SC;
  387. font-weight: bold;
  388. color: #FF6633;
  389. line-height: 1;
  390. }
  391. }
  392. }
  393. .btn-box{
  394. box-sizing: border-box;
  395. display: flex;
  396. align-items: center;
  397. .btn{
  398. width: 155upx;
  399. height: 64upx;
  400. line-height: 64upx;
  401. font-size: 26upx;
  402. font-family: PingFang SC;
  403. font-weight: 500;
  404. text-align: center;
  405. border-radius: 32upx;
  406. margin-left: 15upx;
  407. &:first-child{
  408. margin-left: 0;
  409. }
  410. &.cancel{
  411. border: 1px solid #DDDDDD;
  412. color: #666666;
  413. }
  414. &.pay{
  415. background: #C39A58;
  416. color: #FFFFFF;
  417. }
  418. }
  419. }
  420. }
  421. }
  422. }
  423. }
  424. </style>