bankPay.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <view>
  3. <view style="padding-top: 50rpx;">
  4. <view class="pay">
  5. <image src="https://qnys.chuliu.cc/daweiboshi_szy/1_1615541900_nrG1vctYn8.jpg"
  6. mode="widthFix" style="width: 750rpx;margin-bottom: 60rpx;"></image>
  7. <!-- <image src="https://qnys.chuliu.cc/daweiboshi_szy/photo_2024-09-12%2018.14.49.jpeg"
  8. mode="widthFix" style="width: 750rpx;margin-bottom: 60rpx;"></image> -->
  9. <view class="pay_title">
  10. 第{{ data.season }}届大卫博士创业实战营
  11. </view>
  12. <view class="item">
  13. <input maxlength="6" type="number" v-model="sms_code" placeholder="请输入验证码" />
  14. <view v-throttle="2000" class="countdown" @tap="getCode">
  15. {{ countDown ? `重新获取(${countDown}s)` : '获取验证码' }}
  16. </view>
  17. </view>
  18. <view v-throttle="2000" class="pay_btnSig" :class="status ? 'red' : 'gray'" @click="singup">支付{{ data.cost }}报名</view>
  19. </view>
  20. <view class="payB" @click="goUnbank">
  21. 支付不了,重新绑定?
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import { getSignPackage } from '@/apis/app.js';
  28. import { _API_HuiFuCheck, _API_QuickBankPay, _API_QuickBankSms, _API_CheckStatus } from '../../apis/szy.js';
  29. const jweixin = require('jweixin-module');
  30. export default {
  31. data() {
  32. return {
  33. status: true,
  34. countDown: 0, // 倒计时,
  35. sms_code: '', // 验证码,
  36. id: '',
  37. payId: '',
  38. // data: {}
  39. }
  40. },
  41. computed: {
  42. data() {
  43. return this.$store.state.singup.szy_data
  44. }
  45. },
  46. onLoad(option) {
  47. this.id = option.id
  48. // this.data = uni.getStorageSync("szy_data")
  49. },
  50. methods: {
  51. // 去重新绑定
  52. goUnbank() {
  53. uni.navigateTo({
  54. url: '../zbs/unBank?type=2'
  55. })
  56. },
  57. // 1.发送验证码
  58. getCode() {
  59. let that = this
  60. uni.showModal({
  61. title: '提示',
  62. content: '该短信用于实战营报名费用的支付验证。',
  63. success: function (res) {
  64. if (res.confirm) {
  65. _API_QuickBankPay({ id: that.id }).then(res => {
  66. if (res.code == 200) {
  67. uni.showModal({
  68. content: '验证码发送成功',
  69. showCancel: false,
  70. success: (e) => {
  71. if (e.confirm) {
  72. that.payId = res.data.id
  73. that.countDown = 180;
  74. that.timer = setInterval(() => {
  75. that.countDown--;
  76. if (!that.countDown) {
  77. that.countDown = 0;
  78. clearInterval(that.timer);
  79. }
  80. }, 1000);
  81. }
  82. }
  83. })
  84. } else {
  85. uni.showModal({
  86. content: res.message || '获取验证码失败',
  87. showCancel: false
  88. });
  89. return false;
  90. }
  91. })
  92. } else if (res.cancel) {
  93. }
  94. }
  95. });
  96. },
  97. // 2. 携带验证码支付
  98. singup() {
  99. let that = this
  100. if (!this.sms_code) {
  101. uni.showModal({
  102. content: '请先输入验证码',
  103. showCancel: false
  104. })
  105. return
  106. }
  107. uni.showModal({
  108. title: '提示',
  109. content: '确定要支付吗?',
  110. success: (res) => {
  111. if (res.confirm) {
  112. _API_QuickBankSms({ id: that.payId, sms_code: that.sms_code }).then(res => {
  113. if (res.code == 200) {
  114. if (res.data.status == 0) {
  115. that.SearchStatus()
  116. } else if (res.data.status == 1) {
  117. // uni.navigateBack({
  118. // delta: 2
  119. // })
  120. uni.reLaunch({
  121. url: '/pages/payment-xx/payment'
  122. });
  123. }
  124. } else {
  125. uni.showModal({
  126. title: '失败',
  127. content: res.message || '获取失败',
  128. showCancel: false
  129. })
  130. return false;
  131. }
  132. })
  133. .catch(err => {})
  134. .finally(() => {
  135. setTimeout(() => {}, 3000)
  136. })
  137. }
  138. }
  139. })
  140. },
  141. // 3. 查询支付状态
  142. SearchStatus() {
  143. let that = this
  144. uni.showLoading({
  145. title: '查询支付状态中...',
  146. mask: true
  147. });
  148. _API_CheckStatus({ id: this.payId }).then(res => {
  149. if (res.code == 200) {
  150. if (res.data.status == 1) {
  151. uni.hideLoading()
  152. // uni.navigateBack({
  153. // delta: 2
  154. // })
  155. uni.reLaunch({
  156. url: '/pages/payment-xx/payment'
  157. });
  158. } else {
  159. that.SearchStatus()
  160. }
  161. } else {
  162. uni.hideLoading()
  163. uni.showModal({
  164. content: res.message || '查询失败',
  165. showCancel: false
  166. })
  167. }
  168. }).catch(err => {
  169. uni.hideLoading()
  170. uni.showModal({
  171. content: err || '查询失败',
  172. showCancel: false
  173. })
  174. })
  175. }
  176. }
  177. }
  178. </script>
  179. <style>
  180. page {
  181. background-color: #F5F5F5;
  182. }
  183. </style>
  184. <style lang="scss" scoped>
  185. .payB {
  186. margin-top: 30rpx;
  187. text-align: center;
  188. color: #FF232C;
  189. font-weight: bold;
  190. }
  191. .pay {
  192. margin: 0 30rpx 0 30rpx;
  193. border-radius: 16rpx;
  194. background-color: #fff;
  195. padding: 40rpx 20rpx 40rpx 20rpx;
  196. &_title {
  197. font-size: 34rpx;
  198. font-weight: bold;
  199. }
  200. &_time {
  201. margin-top: 20rpx;
  202. font-size: 32rpx;
  203. }
  204. &_btnSig {
  205. margin: 50rpx auto 0;
  206. width: 600rpx;
  207. line-height: 88rpx;
  208. border-radius: 44rpx;
  209. text-align: center;
  210. color: #fff;
  211. font-size: 32rpx;
  212. }
  213. .red {
  214. background: linear-gradient(93deg, #FF232C 0%, #FF571B 100%);
  215. }
  216. .gray {
  217. background-color: #E1E1E1;
  218. }
  219. }
  220. .item {
  221. @include flex();
  222. height: 104rpx;
  223. box-sizing: border-box;
  224. color: $app-sec-text-color;
  225. background: #F8F8F8;
  226. margin: 50rpx 0 40rpx 0;
  227. border-radius: 8rpx;
  228. padding-left: 24rpx;
  229. .login_icon {
  230. width: 36rpx;
  231. height: 44rpx;
  232. }
  233. .icon,
  234. .cuIcon-roundclosefill {
  235. margin: 0 20rpx;
  236. font-size: 36rpx;
  237. }
  238. input {
  239. flex: 1;
  240. height: 104rpx;
  241. margin-left: 15rpx;
  242. }
  243. .countdown {
  244. @include flex();
  245. height: 60rpx;
  246. font-size: 24rpx;
  247. padding: 0 20rpx;
  248. border: 2rpx solid #FB231F;
  249. margin-right: 20rpx;
  250. border-radius: 33rpx;
  251. color: $base-color;
  252. text {
  253. margin-left: 8rpx;
  254. }
  255. }
  256. }
  257. </style>