orderdetails.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <template>
  2. <view class="page">
  3. <view class="order">
  4. <view class="order-info">订单编号:{{item.orderNo}}</view>
  5. <view class="order-info">下单时间:{{item.createTime | formatDateTime}}</view>
  6. <view class="order-info">
  7. 支付方式:
  8. <text v-if="item.payChannel == '1'">微信支付</text>
  9. <text v-if="item.payChannel == '2'">支付宝</text>
  10. <text v-if="item.payChannel == '3'">银联</text>
  11. <text v-if="item.payChannel == '4'">线下支付</text>
  12. </view>
  13. <view class="order-info" v-if="item.payNo">支付流水号:{{item.payNo}}</view>
  14. <view class="order-status">
  15. <view class="status" v-if="item.orderStatus == 1">
  16. <image :src="$getInnerImg+'icon-vipcard.png'" class="status-img" mode="scaleToFill"></image>
  17. <text class="status-text">待付款</text>
  18. </view>
  19. <view class="status" v-if="item.orderStatus == 2">
  20. <image :src="$getInnerImg+'icon-vipcard-green.png'" class="status-img" mode="scaleToFill"></image>
  21. <text class="status-text">已支付</text>
  22. </view>
  23. <view class="order-btn topay" v-if="item.orderStatus == 1&&item.state==1" @click.stop="pay">去支付</view>
  24. <view class="order-btn done" v-if="item.orderStatus == 2" @click="goCertDetails(item.guid)">查看证书</view>
  25. </view>
  26. </view>
  27. <!-- bottom-flex-btn-wrap end -->
  28. <uni-popup ref="popup" type="dialog">
  29. <uni-popup-dialog type="info" :content="popupContent" :duration="2000" :before-close="true" @close="closepopup" @confirm="confirmpopup"></uni-popup-dialog>
  30. </uni-popup>
  31. </view>
  32. </template>
  33. <script>
  34. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  35. import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue';
  36. export default {
  37. components: {
  38. uniPopup,
  39. uniPopupDialog,
  40. },
  41. data() {
  42. return {
  43. $getInnerImg:this.$getInnerImg,
  44. token:'',
  45. tokenhead:'Bearer',
  46. params: {
  47. orderid:'',
  48. },
  49. item:[],
  50. }
  51. },
  52. onShow() {
  53. let serf = this;
  54. this.token = this.$store.state.token;
  55. },
  56. onLoad(option) {
  57. // console.log('option',option);
  58. this.params.orderid = option.orderid;
  59. this.token = this.$store.state.token;
  60. this.getdetails();
  61. },
  62. methods: {
  63. getdetails(){
  64. this.$api.http.get(this.config.apiBaseurl + '/carbon-h5/wap/order/info?orderId='+this.params.orderid,{
  65. header: {
  66. Accept:'application/json',
  67. Authorization: 'Bearer '+ this.token, //注意Bearer后面有一空格
  68. },
  69. }).then(res => {
  70. this.item = res.data.retBody;
  71. console.log('res',JSON.parse(JSON.stringify(this.item)))
  72. }).catch(err =>{
  73. console.log('err',err)
  74. });
  75. },
  76. cancelOrder(){
  77. this.$refs.popup.open();
  78. this.popupContent = '确认取消此订单吗?';
  79. this.popupType = 'cancel';
  80. },
  81. received(){
  82. this.$refs.popup.open();
  83. this.popupContent = '确认收货?';
  84. this.popupType = 'received';
  85. },
  86. closepopup(done){
  87. done()
  88. },
  89. confirmpopup(done,value){
  90. if(this.popupType == 'cancel'){
  91. this.$api.http.post(this.config.apiBaseurl + '/order/cancelUserOrder/?orderId='+this.item.id,{},{
  92. header: {
  93. Accept:'application/json',
  94. Authorization: 'Bearer '+ this.token, //注意Bearer后面有一空格
  95. },
  96. }).then(res => {
  97. this.getdetails();
  98. this.goOrderList(res.data.message);
  99. // console.log('res',res)
  100. }).catch(err =>{
  101. console.log('err',err)
  102. });
  103. }else if(this.popupType == 'received'){
  104. this.$api.http.get(this.config.apiBaseurl + '/order/confirmReceiveOrder/?orderId='+this.item.id,{},{
  105. header: {
  106. Accept:'application/json',
  107. Authorization: 'Bearer '+ this.token, //注意Bearer后面有一空格
  108. },
  109. }).then(res => {
  110. this.getdetails();
  111. this.goOrderList(res.data.message);
  112. // console.log('res',res)
  113. }).catch(err =>{
  114. console.log('err',err)
  115. });
  116. }
  117. done()
  118. },
  119. pay(){
  120. let userInfo = uni.getStorageSync("userInfo");
  121. let params = {
  122. orderId:this.item.id,
  123. payType:this.item.payType,
  124. openid:userInfo.wxUsers.openid,
  125. "tradeType":"test"
  126. }
  127. this.$pay.wxPay(params).then(res =>{
  128. this.getdetails();
  129. this.goOrderList(res.data.message);
  130. // console.log('payres',res);
  131. }).catch(err =>{console.log('err',err);});
  132. },
  133. // 跳转到订单列表
  134. goOrderList(msg){
  135. uni.showToast({
  136. icon:"none",
  137. title:msg,
  138. duration: 2000
  139. });
  140. setTimeout(()=>{
  141. uni.navigateTo({
  142. url: '/pages/usercenter/myorder/myorder',
  143. fail:function(err){
  144. console.log(err)
  145. }
  146. });
  147. },1000)
  148. },
  149. goCertDetails(id){
  150. console.log(id)
  151. uni.navigateTo({
  152. url: '/pages/usercenter/certificateList/certificate/certificate?orderid=' + id,
  153. });
  154. },
  155. }
  156. }
  157. </script>
  158. <style>
  159. @import url("./orderdetails.css");
  160. </style>