payExternal.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. let data = sessionStorage.getItem('viewUrlData')
  51. data = JSON.parse(data)
  52. Object.keys(data).forEach(item=>{
  53. this.info = this.info + item + '=' + encodeURIComponent(data[item]) + '&'
  54. })
  55. // if(opthios.viewUrl){
  56. // let data = JSON.parse(decodeURIComponent(opthios.viewUrl))
  57. // Object.keys(data).forEach(item=>{
  58. // this.info = this.info + item + '=' + encodeURIComponent(data[item]) + '&'
  59. // })
  60. // }
  61. // location.href = this.info
  62. // window.open(this.info);
  63. },
  64. onUnload() {
  65. sessionStorage.removeItem('paystatus');
  66. sessionStorage.removeItem('viewUrlData');
  67. },
  68. methods: {
  69. openPay(e) {
  70. if(e == 1){
  71. sessionStorage.setItem('paystatus', '1');
  72. window.open(this.info);
  73. }else{
  74. window.open(this.info);
  75. }
  76. },
  77. toPurchase() {
  78. let _this = this
  79. uni.showLoading({
  80. title: '加载中'
  81. });
  82. $http.post('/api/v1/mp/user/ticket/query', {
  83. orderId: this.orderId,
  84. }).then(res => {
  85. uni.hideLoading();
  86. if (res.code == 0) {
  87. if(res.data.status != 3) {
  88. uni.showToast({
  89. title: '支付成功',
  90. icon: 'success',
  91. duration: 2000
  92. })
  93. setTimeout(() => {
  94. uni.redirectTo({
  95. url: `/packagePrize/purchase/index?boxId=${ res.data.boxId }&orderId=${ this.orderId }&isTry=0`
  96. })
  97. }, 500)
  98. }else {
  99. uni.$u.toast('盲票已开奖');
  100. setTimeout(() => {
  101. uni.switchTab({
  102. url: `/pages/index/index`
  103. })
  104. }, 500)
  105. }
  106. }else {
  107. uni.$u.toast(res.msg);
  108. }
  109. }).catch(() => {
  110. uni.hideLoading();
  111. })
  112. },
  113. }
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. .btn {
  118. margin: 156rpx 41rpx 0 41rpx;
  119. .btn1 {
  120. background: linear-gradient(180deg, #FEA052 0%, #FF8D2F 100%);
  121. border-radius: 2px;
  122. color: #FFFFFF;
  123. }
  124. .btn2 {
  125. margin-top: 51rpx;
  126. border-radius: 2px;
  127. background-color: #EFEFEF;
  128. color: #666666;
  129. }
  130. }
  131. </style>