payExternal.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <template>
  2. <view class="">
  3. <!-- #ifdef MP-ALIPAY -->
  4. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="支付中" leftIconSize="0"></u-navbar>
  5. <!-- #endif -->
  6. <!-- #ifdef MP-WEIXIN -->
  7. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="支付中"></u-navbar>
  8. <!-- #endif -->
  9. <!-- #ifndef MP-WEIXIN || MP-ALIPAY -->
  10. <view v-if="pagesNum > 1">
  11. <u-navbar :placeholder="true" bgColor="#fff" :autoBack="true" :border="true" title="支付中" />
  12. </view>
  13. <view v-else>
  14. <u-navbar leftIconSize="0" :placeholder="true" bgColor="#fff" :border="true" title="支付中">
  15. <view class="nav-left flex" slot="left" @click="$toIndex()">
  16. <u-icon name="arrow-left" size="20" color="#333"></u-icon>
  17. </view>
  18. </u-navbar>
  19. </view>
  20. <!-- #endif -->
  21. <!-- <web-view :src='info'></web-view> -->
  22. <view class="btn" v-if="paystatus == 0">
  23. <u-button class="btn1" @click="openPay(1)" text="前往支付" shape="circle"></u-button>
  24. </view>
  25. <view class="btn" v-else>
  26. <u-button class="btn1" @click="toPurchase" text="我已支付" shape="circle"></u-button>
  27. <u-button class="btn2" @click="openPay(2)" text="还未支付" shape="circle"></u-button>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. import $http from '@/utils/request.js'
  33. export default {
  34. data() {
  35. return {
  36. info: 'https://openapi.ysepay.com/gateway.do?',
  37. pagesNum: '',
  38. orderId: '',
  39. paystatus: 0,
  40. }
  41. },
  42. onShow() {
  43. this.pagesNum = getCurrentPages().length
  44. this.paystatus = sessionStorage.getItem('paystatus') ? 1 : 0
  45. },
  46. onLoad(opthios) {
  47. if(opthios.orderId){
  48. this.orderId = opthios.orderId
  49. }
  50. if(opthios.viewUrl){
  51. let data = JSON.parse(decodeURIComponent(opthios.viewUrl))
  52. Object.keys(data).forEach(item=>{
  53. this.info = this.info + item + '=' + encodeURIComponent(data[item]) + '&'
  54. })
  55. }
  56. // location.href = this.info
  57. // window.open(this.info);
  58. },
  59. onUnload() {
  60. sessionStorage.removeItem('paystatus');
  61. },
  62. methods: {
  63. openPay(e) {
  64. if(e == 1){
  65. sessionStorage.setItem('paystatus', '1');
  66. window.open(this.info);
  67. }else{
  68. window.open(this.info);
  69. }
  70. },
  71. toPurchase() {
  72. let _this = this
  73. uni.showLoading({
  74. title: '加载中'
  75. });
  76. $http.post('/api/v1/mp/user/ticket/query', {
  77. orderId: this.orderId,
  78. }).then(res => {
  79. uni.hideLoading();
  80. if (res.code == 0) {
  81. uni.redirectTo({
  82. url: `/packagePrize/purchase/index?boxId=${ res.data.boxId }&orderId=${ this.orderId }&isTry=0`
  83. })
  84. }else {
  85. uni.$u.toast(res.msg);
  86. }
  87. }).catch(() => {
  88. uni.hideLoading();
  89. })
  90. },
  91. }
  92. }
  93. </script>
  94. <style lang="scss" scoped>
  95. .btn {
  96. margin: 156rpx 41rpx 0 41rpx;
  97. .btn1 {
  98. background: linear-gradient(180deg, #FEA052 0%, #FF8D2F 100%);
  99. border-radius: 2px;
  100. color: #FFFFFF;
  101. }
  102. .btn2 {
  103. margin-top: 51rpx;
  104. border-radius: 2px;
  105. background-color: #EFEFEF;
  106. color: #666666;
  107. }
  108. }
  109. </style>