order.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view class="default_page adffc" :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" v-if="list.length">
  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="handlePublish" v-if="item.orderStatus==1">发布问卷</view>
  27. <view class="list-pre-btns-pre" @click.stop="handlePay(item)" v-if="item.orderStatus==0">立即支付</view>
  28. <view class="list-pre-btns-pre" @click.stop="buyAgain" v-else>再次购买</view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="empty adffcacjc" v-else>
  33. <page-empty text="暂无订单"></page-empty>
  34. </view>
  35. <WechatPay ref="wxPay" @confirmPay="toPay" @cancelPay="cancelPay"></WechatPay>
  36. </view>
  37. </template>
  38. <script>
  39. import PageEmpty from '@/components/pageEmpty/index.vue'
  40. import WechatPay from '@/components/wechatPay/index.vue'
  41. export default {
  42. components:{ PageEmpty, WechatPay },
  43. data(){
  44. return {
  45. tindex:0,
  46. statusList:[
  47. {state:'',name:'全部'},
  48. {state:'1',name:'已支付'},
  49. {state:'0',name:'待支付'},
  50. {state:'-2',name:'已取消'}
  51. ],
  52. statusCfg:{
  53. '-3':'已退款',
  54. '-2':'已取消',
  55. '-1':'已失效',
  56. 0:'待支付',
  57. 1:'已支付',
  58. 2:'已完成'
  59. },
  60. statusColor:{
  61. 0:'dzf',
  62. 1:'yzf',
  63. 2:'yzf',
  64. '-2':'yqx'
  65. },
  66. typeCfg:{
  67. 1:'基础版',
  68. 2:'专业版'
  69. },
  70. query:{
  71. page:1,
  72. limit:10,
  73. orderStatus:'',
  74. userId:''
  75. },
  76. isOver:false,
  77. list:[],
  78. orderNo:''
  79. }
  80. },
  81. onReachBottom() {
  82. if(this.isOver) return
  83. this.getList()
  84. },
  85. onShow() {
  86. if(uni.getStorageSync('userInfo')){
  87. this.query.userId = JSON.parse(uni.getStorageSync('userInfo')).id;
  88. this.init()
  89. }
  90. },
  91. methods:{
  92. init(){
  93. this.query.page = 1;
  94. this.isOver = false;
  95. this.list = [];
  96. this.getList()
  97. },
  98. getList(){
  99. this.$api.get('/que/order/page',this.query).then(({data:res})=>{
  100. if(res.code!==0) return this.$showToast(res.msg)
  101. this.list = [...this.list,...res.data.list]
  102. if(this.list.length < res.data.total) this.query.page++
  103. else this.isOver = true
  104. })
  105. },
  106. changeTab(item,index){
  107. this.tindex = index;
  108. this.query.orderStatus = item.state;
  109. this.init()
  110. },
  111. handleDetail(item){
  112. uni.navigateTo({
  113. url:'/pagesMy/orderDetail?id='+item.id
  114. })
  115. },
  116. orderCancel(item){
  117. uni.showModal({
  118. title:'温馨提示',
  119. content:'确定取消该订单?',
  120. success: (res) => {
  121. if(res.confirm){
  122. this.$api.put(`/que/order/closeOrder/${item.orderNo}`).then(({data:res})=>{
  123. if(res.code!==0) return this.$showToast(res.msg)
  124. this.$showToast('取消成功')
  125. this.init();
  126. })
  127. }
  128. }
  129. })
  130. },
  131. handlePublish(){
  132. uni.reLaunch({
  133. url:'/pages/publish'
  134. })
  135. },
  136. handlePay(item){
  137. this.orderNo = item.orderNo;
  138. this.$refs.wxPay.payShow = true;
  139. },
  140. toPay(){
  141. this.$api.post('/pay/createOrder',{
  142. orderNo:this.orderNo,
  143. openId:JSON.parse(uni.getStorageSync('userInfo')).openId
  144. }).then(({data:res})=>{
  145. if(!res.hasOwnProperty('paySign')) return this.$showToast('支付失败')
  146. this.$refs.wxPay.payShow = false;
  147. this.$wxPay(res).then(result => {
  148. uni.navigateTo({
  149. url:'/pagesPublish/payResult'
  150. })
  151. })
  152. })
  153. },
  154. buyAgain(){
  155. uni.navigateTo({
  156. url:'/pagesPublish/rechargeCenter'
  157. })
  158. },
  159. }
  160. }
  161. </script>
  162. <style scoped lang="scss">
  163. .default_page{
  164. padding: 0 24rpx 40rpx;
  165. box-sizing: border-box;
  166. background: #F7F7F7;
  167. .tab{
  168. position: fixed;
  169. left: 0;
  170. right: 0;
  171. height: 90rpx;
  172. background: #FFFFFF;
  173. &-pre{
  174. width: 25%;
  175. height: 90rpx;
  176. font-family: PingFangSC, PingFang SC;
  177. font-weight: 400;
  178. font-size: 28rpx;
  179. color: #667E90;
  180. line-height: 90rpx;
  181. text-align: center;
  182. position: relative;
  183. &.active{
  184. font-weight: bold;
  185. font-size: 32rpx;
  186. color: #002846;
  187. &::after{
  188. content: '';
  189. width: 48rpx;
  190. height: 6rpx;
  191. background: linear-gradient( 90deg, #33A7A7 0%, #64BBBB 100%);;
  192. border-radius: 5rpx;
  193. position: absolute;
  194. left: 50%;
  195. margin-left: -24rpx;
  196. bottom: 4rpx;
  197. }
  198. }
  199. }
  200. }
  201. .list{
  202. padding-top: 110rpx;
  203. &-pre{
  204. background: #FFFFFF;
  205. border-radius: 25rpx;
  206. margin-top: 20rpx;
  207. padding: 36rpx 24rpx 29rpx;
  208. &:first-child{
  209. margin-top: 0;
  210. }
  211. &-top{
  212. &-no{
  213. font-family: PingFangSC, PingFang SC;
  214. font-weight: 400;
  215. font-size: 26rpx;
  216. color: #667E90;
  217. line-height: 30rpx;
  218. }
  219. &-status{
  220. padding: 6rpx 13rpx;
  221. border-radius: 6rpx;
  222. font-family: PingFangSC, PingFang SC;
  223. font-weight: 400;
  224. font-size: 24rpx;
  225. line-height: 30rpx;
  226. &.yzf{
  227. color: #33A7A7;
  228. background: rgba(51,167,167,0.08);
  229. }
  230. &.dzf{
  231. color: #FD4F66;
  232. background: rgba(244,101,122,0.1);
  233. }
  234. &.yqx{
  235. color: #667E90;
  236. background: #F0F2F8;
  237. }
  238. }
  239. }
  240. &-info{
  241. margin-top: 16rpx;
  242. border-top: 1rpx solid #EFEFEF;
  243. padding-top: 32rpx;
  244. justify-content: space-between;
  245. &-left{
  246. &-img{
  247. width: 64rpx;
  248. height: 64rpx;
  249. }
  250. &-texts{
  251. margin-left: 20rpx;
  252. &-num{
  253. font-family: PingFang-SC, PingFang-SC;
  254. font-weight: bold;
  255. font-size: 30rpx;
  256. color: #002846;
  257. line-height: 30rpx;
  258. }
  259. &-date{
  260. font-family: PingFangSC, PingFang SC;
  261. font-weight: 400;
  262. font-size: 26rpx;
  263. color: #667E90;
  264. line-height: 30rpx;
  265. margin-top: 20rpx;
  266. }
  267. }
  268. }
  269. &-right{
  270. font-family: PingFang-SC, PingFang-SC;
  271. font-weight: bold;
  272. font-size: 30rpx;
  273. color: #1D2129;
  274. line-height: 30rpx;
  275. text-align: right;
  276. }
  277. }
  278. &-btns{
  279. justify-content: flex-end;
  280. margin-top: 30rpx;
  281. &-pre{
  282. background: linear-gradient( 90deg, #33A7A7 0%, #64BBBB 100%);;
  283. border-radius: 27rpx;
  284. border: 1rpx solid #33A7A7;
  285. font-family: PingFangSC, PingFang SC;
  286. font-weight: 400;
  287. font-size: 24rpx;
  288. color: #FFFFFF;
  289. line-height: 30rpx;
  290. padding: 12rpx 26rpx;
  291. letter-spacing: 2rpx;
  292. margin-left: 30rpx;
  293. &.cancel{
  294. background: #FFFFFF;
  295. border: 1rpx solid #E2E2E2;
  296. color: #95A5B1;
  297. }
  298. }
  299. }
  300. }
  301. }
  302. .empty{
  303. padding-top: 110rpx;
  304. flex: 1;
  305. }
  306. }
  307. </style>