packageOrderList.vue 10 KB

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