bankPay.vue 5.2 KB

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