bankPay.vue 5.3 KB

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