orderdetails.vue 4.4 KB

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