packageOrderList.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <template>
  2. <view class="content">
  3. <view class="top-fixed">
  4. <u-tabs
  5. :scrollable="true"
  6. :list="tabs"
  7. :current="status"
  8. lineColor="#FF5C03"
  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. this.status = options.status || '0'
  106. var that=this;
  107. uni.$on('refreshPackageOrder', () => {
  108. that.mescroll.resetUpScroll()
  109. })
  110. this.getDictByKey("sys_package_order_status");
  111. },
  112. onShow() {
  113. },
  114. methods: {
  115. pay(item){
  116. uni.navigateTo({
  117. url: '/pages/store/packageOrderPay?orderId='+item.orderId
  118. })
  119. },
  120. getDictByKey(key){
  121. var data={key:key}
  122. getDictByKey(data).then(
  123. res => {
  124. if(res.code==200){
  125. if(key=="sys_package_order_status"){
  126. this.orderStatusOptions=res.data;
  127. }
  128. }
  129. },
  130. err => {
  131. }
  132. );
  133. },
  134. cancelOrder(item){
  135. var that=this;
  136. uni.showModal({
  137. title:"提示",
  138. content:"确认取消订单吗?",
  139. showCancel:true,
  140. cancelText:'取消',
  141. confirmText:'确定',
  142. success:res=>{
  143. if(res.confirm){
  144. // 用户点击确定
  145. var data={orderId:item.orderId}
  146. cancelOrder(data).then(
  147. res => {
  148. if(res.code==200){
  149. uni.$emit('refreshPackageOrder');
  150. uni.showToast({
  151. icon:'success',
  152. title: "操作成功",
  153. });
  154. }else{
  155. uni.showToast({
  156. icon:'none',
  157. title: res.msg,
  158. });
  159. }
  160. },
  161. rej => {}
  162. );
  163. }else{
  164. // 否则点击了取消
  165. }
  166. }
  167. })
  168. },
  169. showDetails(item){
  170. uni.navigateTo({
  171. url:"/pages/store/packageOrderDetails?orderId="+item.orderId
  172. })
  173. },
  174. tabChange(item){
  175. this.status=item.id
  176. console.log(item)
  177. this.mescroll.resetUpScroll()
  178. },
  179. mescrollInit(mescroll) {
  180. this.mescroll = mescroll;
  181. },
  182. /*下拉刷新的回调 */
  183. downCallback(mescroll) {
  184. mescroll.resetUpScroll()
  185. },
  186. upCallback(page) {
  187. //联网加载数据
  188. var that = this;
  189. var data = {
  190. status:this.status,
  191. pageNum: page.num,
  192. pageSize: page.size
  193. };
  194. getMyPackageOrderList(data).then(res => {
  195. if(res.code==200){
  196. //设置列表数据
  197. if (page.num == 1) {
  198. that.dataList = res.data.list;
  199. } else {
  200. that.dataList = that.dataList.concat(res.data.list);
  201. }
  202. that.mescroll.endBySize(res.data.list.length, res.data.total);
  203. }else{
  204. uni.showToast({
  205. icon:'none',
  206. title: "请求失败",
  207. });
  208. that.dataList = null;
  209. that.mescroll.endErr();
  210. }
  211. });
  212. }
  213. }
  214. }
  215. </script>
  216. <style lang="scss">
  217. page{
  218. background: #f6f6f6;
  219. }
  220. </style>
  221. <style scoped lang="scss">
  222. .content{
  223. .top-fixed{
  224. width: 100%;
  225. position: absolute;
  226. top: 0;
  227. left: 0;
  228. z-index: 10;
  229. height: 88upx;
  230. background-color: #fff;
  231. }
  232. .order-box{
  233. padding: 20rpx;
  234. width: 100%;
  235. display: flex;
  236. flex-direction: column;
  237. align-items: center;
  238. justify-content: center;
  239. .order-item{
  240. width: 100%;
  241. border-radius: 10rpx;
  242. background-color: #fff;
  243. padding: 30rpx;
  244. margin-bottom: 20rpx;
  245. display: flex;
  246. flex-direction: column;
  247. align-items: flex-start;
  248. justify-content: flex-start;
  249. .top-box{
  250. width: 100%;
  251. display: flex;
  252. align-items: center;
  253. justify-content: space-between;
  254. .num{
  255. font-size: 26upx;
  256. font-family: PingFang SC;
  257. font-weight: 500;
  258. color: #999999;
  259. line-height: 1;
  260. }
  261. .status-box{
  262. display: flex;
  263. align-items: center;
  264. .text{
  265. font-size: 28upx;
  266. font-family: PingFang SC;
  267. font-weight: 500;
  268. line-height: 1;
  269. &.success{
  270. color: #C39A58;
  271. }
  272. &.black{
  273. color: #111111;
  274. }
  275. &.info{
  276. color: #999999;
  277. }
  278. }
  279. }
  280. }
  281. .package-box{
  282. margin-top: 20rpx;
  283. width: 100%;
  284. display: flex;
  285. align-items: flex-start;
  286. justify-content: flex-start;
  287. .left{
  288. width:200rpx;
  289. height:200rpx;
  290. image{
  291. border-radius: 15rpx;
  292. width:100%;
  293. height:100%;
  294. }
  295. }
  296. .right{
  297. height: 200rpx;
  298. display: flex;
  299. flex-direction: column;
  300. align-items: flex-start;
  301. justify-content: flex-start;
  302. padding-left: 15rpx;
  303. width:calc(100% - 200rpx);
  304. .title{
  305. font-weight: bold;
  306. font-size: 34upx;
  307. font-family: PingFang SC;
  308. color: #111;
  309. }
  310. .desc{
  311. margin-top: 15rpx;
  312. display: flex;
  313. align-items: flex-start;
  314. justify-content: flex-start;
  315. .cycle{
  316. background-color: #eee;
  317. border-radius: 30rpx;
  318. padding: 5rpx 15rpx;
  319. font-size: 26upx;
  320. font-family: PingFang SC;
  321. color: #FF5C03;
  322. }
  323. .duration{
  324. margin-left: 10rpx;
  325. background-color: #eee;
  326. border-radius: 30rpx;
  327. padding: 5rpx 15rpx;
  328. font-size: 26upx;
  329. font-family: PingFang SC;
  330. color: #FF5C03;
  331. }
  332. }
  333. .price-box{
  334. flex: 1;
  335. display: flex;
  336. align-items: flex-end;
  337. justify-content: space-between;
  338. width: 100%;
  339. .price{
  340. padding: 5rpx 10rpx;
  341. background-color: #FF5C03;
  342. border-radius: 30rpx;
  343. font-size: 20upx;
  344. font-family: PingFang SC;
  345. color: #ffffff;
  346. }
  347. .count{
  348. font-size: 24upx;
  349. font-family: PingFang SC;
  350. color: #333333;
  351. }
  352. }
  353. }
  354. }
  355. .bottom-box{
  356. margin-top: 20rpx;
  357. width: 100%;
  358. display: flex;
  359. align-items: center;
  360. justify-content: space-between;
  361. .amount-paid{
  362. display: flex;
  363. align-items: center;
  364. .label{
  365. font-size: 24upx;
  366. font-family: PingFang SC;
  367. font-weight: 500;
  368. color: #999999;
  369. line-height: 1;
  370. }
  371. .price-box{
  372. display: flex;
  373. align-items: flex-end;
  374. .unit{
  375. font-size: 24upx;
  376. font-family: PingFang SC;
  377. font-weight: 500;
  378. color: #FF6633;
  379. line-height: 1.2;
  380. margin-right: 4upx;
  381. }
  382. .num{
  383. font-size: 32upx;
  384. font-family: PingFang SC;
  385. font-weight: bold;
  386. color: #FF6633;
  387. line-height: 1;
  388. }
  389. }
  390. }
  391. .btn-box{
  392. box-sizing: border-box;
  393. display: flex;
  394. align-items: center;
  395. .btn{
  396. width: 155upx;
  397. height: 64upx;
  398. line-height: 64upx;
  399. font-size: 26upx;
  400. font-family: PingFang SC;
  401. font-weight: 500;
  402. text-align: center;
  403. border-radius: 32upx;
  404. margin-left: 15upx;
  405. &:first-child{
  406. margin-left: 0;
  407. }
  408. &.cancel{
  409. border: 1px solid #DDDDDD;
  410. color: #666666;
  411. }
  412. &.pay{
  413. background: #FF5C03;
  414. color: #FFFFFF;
  415. }
  416. }
  417. }
  418. }
  419. }
  420. }
  421. }
  422. </style>