order.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view class="default_page" :style="{'min-height':h+'px', 'padding-top':mt+'px'}">
  3. <cus-header title='我的订单'></cus-header>
  4. <view class="tab adfac">
  5. <view class="tab-pre" :class="{'active':tindex===index}" @click="changeTab(item,index)"
  6. v-for="(item,index) in statusList" :key="index">{{item.name}}</view>
  7. </view>
  8. <view class="list">
  9. <view class="list-pre" v-for="(item,index) in list" :key="index" @click.prevent="handleDetail(item)">
  10. <view class="list-pre-top adfacjb">
  11. <view class="list-pre-top-no">订单号:{{item.orderNo}}</view>
  12. <view class="list-pre-top-status" :class="statusColor[item.orderStatus]">{{statusCfg[item.orderStatus]}}</view>
  13. </view>
  14. <view class="list-pre-info adf">
  15. <view class="list-pre-info-left adfac">
  16. <image class="list-pre-info-left-img" :src="imgBase+'order_img.png'"></image>
  17. <view class="list-pre-info-left-texts">
  18. <view class="list-pre-info-left-texts-num">{{typeCfg[item.type]}}{{item.totalFrequency}}次,剩余{{item.useFrequency}}次可用</view>
  19. <view class="list-pre-info-left-texts-date">有效期至 {{item.expirationTime||' - '}}</view>
  20. </view>
  21. </view>
  22. <view class="list-pre-info-right">¥{{(+item.totalAmount||0).toFixed(2)}}</view>
  23. </view>
  24. <view class="list-pre-btns adf">
  25. <view class="list-pre-btns-pre cancel" v-if="item.orderStatus==0" @click.stop="orderCancel(item)">取消订单</view>
  26. <view class="list-pre-btns-pre" @click.stop="buyAgain">再次购买</view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. data(){
  35. return {
  36. tindex:0,
  37. statusList:[
  38. {state:'',name:'全部'},
  39. {state:'1',name:'已支付'},
  40. {state:'0',name:'待支付'},
  41. {state:'-2',name:'已取消'}
  42. ],
  43. statusCfg:{
  44. '-3':'已退款',
  45. '-2':'已取消',
  46. '-1':'已失效',
  47. 0:'待支付',
  48. 1:'已支付',
  49. 2:'已完成'
  50. },
  51. statusColor:{
  52. 0:'dzf',
  53. 1:'yzf',
  54. 2:'yzf',
  55. '-2':'yqx'
  56. },
  57. typeCfg:{
  58. 1:'基础版',
  59. 2:'专业版'
  60. },
  61. query:{
  62. page:1,
  63. limit:10,
  64. orderStatus:'',
  65. userId:''
  66. },
  67. isOver:false,
  68. list:[]
  69. }
  70. },
  71. onReachBottom() {
  72. if(this.isOver) return
  73. this.getList()
  74. },
  75. onLoad(options) {
  76. try{
  77. this.query.userId = JSON.parse(uni.getStorageSync('userInfo')).id;
  78. this.getList()
  79. }catch(e){
  80. this.query.userId = '';
  81. }
  82. },
  83. methods:{
  84. init(){
  85. this.query.page = 1;
  86. this.isOver = false;
  87. this.list = [];
  88. this.getList()
  89. },
  90. getList(){
  91. this.$api.get('/que/order/page',this.query).then(({data:res})=>{
  92. if(res.code!==0) return this.$showToast(res.msg)
  93. this.list = [...this.list,...res.data.list]
  94. if(this.list.length < res.data.total) this.query.page++
  95. else this.isOver = true
  96. })
  97. },
  98. changeTab(item,index){
  99. this.tindex = index;
  100. this.query.orderStatus = item.state;
  101. this.init()
  102. },
  103. handleDetail(item){
  104. uni.navigateTo({
  105. url:'/pagesMy/orderDetail?id='+item.id
  106. })
  107. },
  108. orderCancel(item){
  109. uni.showModal({
  110. title:'温馨提示',
  111. content:'确定取消该订单?',
  112. success: (res) => {
  113. if(res.confirm){
  114. this.$api.put(`/que/order/closeOrder/${item.orderNo}`).then(({data:res})=>{
  115. if(res.code!==0) return this.$showToast(res.msg)
  116. this.$showToast('取消成功')
  117. this.init();
  118. })
  119. }
  120. }
  121. })
  122. },
  123. buyAgain(){
  124. uni.navigateTo({
  125. url:'/pagesPublish/rechargeCenter'
  126. })
  127. },
  128. }
  129. }
  130. </script>
  131. <style scoped lang="scss">
  132. .default_page{
  133. padding: 0 24rpx 40rpx;
  134. box-sizing: border-box;
  135. background: #F7F7F7;
  136. .tab{
  137. position: fixed;
  138. left: 0;
  139. right: 0;
  140. height: 90rpx;
  141. background: #FFFFFF;
  142. &-pre{
  143. width: 25%;
  144. height: 90rpx;
  145. font-family: PingFangSC, PingFang SC;
  146. font-weight: 400;
  147. font-size: 28rpx;
  148. color: #667E90;
  149. line-height: 90rpx;
  150. text-align: center;
  151. position: relative;
  152. &.active{
  153. font-weight: bold;
  154. font-size: 32rpx;
  155. color: #002846;
  156. &::after{
  157. content: '';
  158. width: 48rpx;
  159. height: 6rpx;
  160. background: linear-gradient( 90deg, #33A7A7 0%, #64BBBB 100%);;
  161. border-radius: 5rpx;
  162. position: absolute;
  163. left: 50%;
  164. margin-left: -24rpx;
  165. bottom: 4rpx;
  166. }
  167. }
  168. }
  169. }
  170. .list{
  171. padding-top: 110rpx;
  172. &-pre{
  173. background: #FFFFFF;
  174. border-radius: 25rpx;
  175. margin-top: 20rpx;
  176. padding: 36rpx 24rpx 29rpx;
  177. &:first-child{
  178. margin-top: 0;
  179. }
  180. &-top{
  181. &-no{
  182. font-family: PingFangSC, PingFang SC;
  183. font-weight: 400;
  184. font-size: 26rpx;
  185. color: #667E90;
  186. line-height: 30rpx;
  187. }
  188. &-status{
  189. padding: 6rpx 13rpx;
  190. border-radius: 6rpx;
  191. font-family: PingFangSC, PingFang SC;
  192. font-weight: 400;
  193. font-size: 24rpx;
  194. line-height: 30rpx;
  195. &.yzf{
  196. color: #33A7A7;
  197. background: rgba(51,167,167,0.08);
  198. }
  199. &.dzf{
  200. color: #FD4F66;
  201. background: rgba(244,101,122,0.1);
  202. }
  203. &.yqx{
  204. color: #667E90;
  205. background: #F0F2F8;
  206. }
  207. }
  208. }
  209. &-info{
  210. margin-top: 16rpx;
  211. border-top: 1rpx solid #EFEFEF;
  212. padding-top: 32rpx;
  213. justify-content: space-between;
  214. &-left{
  215. &-img{
  216. width: 64rpx;
  217. height: 64rpx;
  218. }
  219. &-texts{
  220. margin-left: 20rpx;
  221. &-num{
  222. font-family: PingFang-SC, PingFang-SC;
  223. font-weight: bold;
  224. font-size: 30rpx;
  225. color: #002846;
  226. line-height: 30rpx;
  227. }
  228. &-date{
  229. font-family: PingFangSC, PingFang SC;
  230. font-weight: 400;
  231. font-size: 26rpx;
  232. color: #667E90;
  233. line-height: 30rpx;
  234. margin-top: 20rpx;
  235. }
  236. }
  237. }
  238. &-right{
  239. font-family: PingFang-SC, PingFang-SC;
  240. font-weight: bold;
  241. font-size: 30rpx;
  242. color: #1D2129;
  243. line-height: 30rpx;
  244. text-align: right;
  245. }
  246. }
  247. &-btns{
  248. justify-content: flex-end;
  249. margin-top: 30rpx;
  250. &-pre{
  251. background: linear-gradient( 90deg, #33A7A7 0%, #64BBBB 100%);;
  252. border-radius: 27rpx;
  253. border: 1rpx solid #33A7A7;
  254. font-family: PingFangSC, PingFang SC;
  255. font-weight: 400;
  256. font-size: 24rpx;
  257. color: #FFFFFF;
  258. line-height: 30rpx;
  259. padding: 12rpx 26rpx;
  260. letter-spacing: 2rpx;
  261. margin-left: 30rpx;
  262. &.cancel{
  263. background: #FFFFFF;
  264. border: 1rpx solid #E2E2E2;
  265. color: #95A5B1;
  266. }
  267. }
  268. }
  269. }
  270. }
  271. }
  272. </style>