orderdetails.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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 && item.state ==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.state == 0">
  20. <image :src="$getInnerImg+'icon-vipcard.png'" class="status-img" mode="scaleToFill"></image>
  21. <text class="status-text">已失效</text>
  22. </view>
  23. <view class="status" v-if="item.orderStatus == 2">
  24. <image :src="$getInnerImg+'icon-vipcard-green.png'" class="status-img" mode="scaleToFill"></image>
  25. <text class="status-text">已支付</text>
  26. </view>
  27. <view class="order-btn topay" v-if="item.orderStatus == 1&&item.state==1" @click.stop="pay(item)">去支付</view>
  28. <view class="order-btn done" v-if="item.orderStatus == 2" @click="goCertDetails(item.guid)">查看证书</view>
  29. </view>
  30. </view>
  31. <!-- bottom-flex-btn-wrap end -->
  32. <uni-popup ref="popup" type="dialog">
  33. <uni-popup-dialog type="info" :content="popupContent" :duration="2000" :before-close="true" @close="closepopup" @confirm="confirmpopup"></uni-popup-dialog>
  34. </uni-popup>
  35. </view>
  36. </template>
  37. <script>
  38. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  39. import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue';
  40. export default {
  41. components: {
  42. uniPopup,
  43. uniPopupDialog,
  44. },
  45. data() {
  46. return {
  47. $getInnerImg:this.$getInnerImg,
  48. token:'',
  49. tokenhead:'Bearer',
  50. params: {
  51. orderid:'',
  52. },
  53. item:[],
  54. }
  55. },
  56. onShow() {
  57. let serf = this;
  58. this.token = this.$store.state.token;
  59. },
  60. onLoad(option) {
  61. // console.log('option',option);
  62. this.params.orderid = option.orderid;
  63. this.token = this.$store.state.token;
  64. this.getdetails();
  65. },
  66. methods: {
  67. getdetails(){
  68. this.$api.http.get(this.config.apiBaseurl + '/carbon-h5/wap/order/info?orderId='+this.params.orderid,{
  69. header: {
  70. Accept:'application/json',
  71. Authorization: 'Bearer '+ this.token, //注意Bearer后面有一空格
  72. },
  73. }).then(res => {
  74. this.item = res.data.retBody;
  75. console.log('res',JSON.parse(JSON.stringify(this.item)))
  76. }).catch(err =>{
  77. console.log('err',err)
  78. });
  79. },
  80. cancelOrder(){
  81. this.$refs.popup.open();
  82. this.popupContent = '确认取消此订单吗?';
  83. this.popupType = 'cancel';
  84. },
  85. received(){
  86. this.$refs.popup.open();
  87. this.popupContent = '确认收货?';
  88. this.popupType = 'received';
  89. },
  90. closepopup(done){
  91. done()
  92. },
  93. confirmpopup(done,value){
  94. if(this.popupType == 'cancel'){
  95. this.$api.http.post(this.config.apiBaseurl + '/order/cancelUserOrder/?orderId='+this.item.id,{},{
  96. header: {
  97. Accept:'application/json',
  98. Authorization: 'Bearer '+ this.token, //注意Bearer后面有一空格
  99. },
  100. }).then(res => {
  101. this.getdetails();
  102. this.goOrderList(res.data.message);
  103. // console.log('res',res)
  104. }).catch(err =>{
  105. console.log('err',err)
  106. });
  107. }else if(this.popupType == 'received'){
  108. this.$api.http.get(this.config.apiBaseurl + '/order/confirmReceiveOrder/?orderId='+this.item.id,{},{
  109. header: {
  110. Accept:'application/json',
  111. Authorization: 'Bearer '+ this.token, //注意Bearer后面有一空格
  112. },
  113. }).then(res => {
  114. this.getdetails();
  115. this.goOrderList(res.data.message);
  116. // console.log('res',res)
  117. }).catch(err =>{
  118. console.log('err',err)
  119. });
  120. }
  121. done()
  122. },
  123. pay(item){
  124. let self = this;
  125. console.log('pay item',item);
  126. let userInfo = uni.getStorageSync("userInfo");
  127. console.log('userInfo',userInfo);
  128. // return
  129. let params = {
  130. orderId:item.guid,
  131. // payType:item.payType,
  132. openid:userInfo.wxId,
  133. "tradeType":"test"
  134. };
  135. this.$api.http.post(this.config.apiBaseurl + "/carbon-h5/wechat/pay",params,{
  136. header: {
  137. Accept:'application/json',
  138. Authorization: 'Bearer '+ this.token, //注意Bearer后面有一空格
  139. },
  140. }).then(res=>{
  141. uni.requestPayment({
  142. provider: 'wxpay',
  143. timeStamp:res.data.retBody.timeStamp,
  144. nonceStr: res.data.retBody.nonceStr,
  145. package: res.data.retBody.packageValue,
  146. signType: 'MD5',
  147. paySign: res.data.retBody.paySign,
  148. success: function (res) {
  149. self.downCallback();
  150. console.log('success:' + JSON.stringify(res));
  151. },
  152. fail: function (err) {
  153. console.log('fail:' + JSON.stringify(err));
  154. }
  155. });
  156. }).catch( err =>{
  157. console.log('pay err',err)
  158. })
  159. },
  160. // 跳转到订单列表
  161. goOrderList(msg){
  162. uni.showToast({
  163. icon:"none",
  164. title:msg,
  165. duration: 2000
  166. });
  167. setTimeout(()=>{
  168. uni.navigateTo({
  169. url: '/pages/usercenter/myorder/myorder',
  170. fail:function(err){
  171. console.log(err)
  172. }
  173. });
  174. },1000)
  175. },
  176. goCertDetails(id){
  177. console.log(id)
  178. uni.navigateTo({
  179. url: '/pages/usercenter/certificateList/certificate/certificate?orderid=' + id,
  180. });
  181. },
  182. }
  183. }
  184. </script>
  185. <style>
  186. @import url("./orderdetails.css");
  187. </style>