orderdetails.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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(item)">去支付</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(item){
  120. let self = this;
  121. console.log('pay item',item);
  122. let userInfo = uni.getStorageSync("userInfo");
  123. console.log('userInfo',userInfo);
  124. // return
  125. let params = {
  126. orderId:item.guid,
  127. // payType:item.payType,
  128. openid:userInfo.wxId,
  129. "tradeType":"test"
  130. };
  131. this.$api.http.post(this.config.apiBaseurl + "/carbon-h5/wechat/pay",params,{
  132. header: {
  133. Accept:'application/json',
  134. Authorization: 'Bearer '+ this.token, //注意Bearer后面有一空格
  135. },
  136. }).then(res=>{
  137. uni.requestPayment({
  138. provider: 'wxpay',
  139. timeStamp:res.data.retBody.timeStamp,
  140. nonceStr: res.data.retBody.nonceStr,
  141. package: res.data.retBody.packageValue,
  142. signType: 'MD5',
  143. paySign: res.data.retBody.paySign,
  144. success: function (res) {
  145. self.downCallback();
  146. console.log('success:' + JSON.stringify(res));
  147. },
  148. fail: function (err) {
  149. console.log('fail:' + JSON.stringify(err));
  150. }
  151. });
  152. }).catch( err =>{
  153. console.log('pay err',err)
  154. })
  155. },
  156. // 跳转到订单列表
  157. goOrderList(msg){
  158. uni.showToast({
  159. icon:"none",
  160. title:msg,
  161. duration: 2000
  162. });
  163. setTimeout(()=>{
  164. uni.navigateTo({
  165. url: '/pages/usercenter/myorder/myorder',
  166. fail:function(err){
  167. console.log(err)
  168. }
  169. });
  170. },1000)
  171. },
  172. goCertDetails(id){
  173. console.log(id)
  174. uni.navigateTo({
  175. url: '/pages/usercenter/certificateList/certificate/certificate?orderid=' + id,
  176. });
  177. },
  178. }
  179. }
  180. </script>
  181. <style>
  182. @import url("./orderdetails.css");
  183. </style>