payment.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573
  1. <template>
  2. <view>
  3. <view class="top" v-show="!showSignup">
  4. <image src="https://qnys.chuliu.cc/daweiboshi_szy/1_1615541900_nrG1vctYn8.jpg"
  5. mode="widthFix" style="width: 750rpx;margin-bottom: 60rpx;"></image>
  6. <view class="title">
  7. 第{{ data.season }}届大卫博士创业实战营(直播)
  8. </view>
  9. <view class="time">
  10. 举办时间:{{ data.start + '-' + data.end }}
  11. </view>
  12. <view class="item">
  13. <input maxlength="6" type="number" v-model="sms_code" placeholder="请输入验证码" />
  14. <view v-throttle="2000" class="countdown" :class="status ? 'red2' : 'gray2'" @tap="getCode">
  15. {{ countDown ? `重新获取(${countDown}s)` : '获取验证码' }}
  16. </view>
  17. </view>
  18. <view v-throttle="2000" class="pay_btnSig" :class="status ? 'red' : 'gray'" @click="singup">{{ status ? `支付${data.cost}报名` : '立即支付' }}</view>
  19. </view>
  20. <view v-show="!showSignup && id" class="payB" @click="goUnbank">
  21. 支付不了,重新绑定?
  22. </view>
  23. <view v-show="showSignup" class="voucher">
  24. <image src="../../static/new_my/bg.png" class="bgImg" mode="widthFix" style="width: 750rpx;"></image>
  25. <view class="bgImg">
  26. <text style="margin-top: 30rpx;">第{{ data.season }}届大卫博士创业实战营(直播)</text>
  27. </view>
  28. <view class="voucher_con">
  29. <view class="voucher_icon">
  30. <image src="../../static/icon/success.png" mode="widthFix" style="width: 300rpx;margin-top: 78rpx;">
  31. </image>
  32. <view class="success">报名成功</view>
  33. <view class="timed">
  34. 举办时间:{{ data.start+ '-' +data.end }}
  35. </view>
  36. </view>
  37. <view class="info" v-show="data.pay_status">
  38. <view>
  39. <text>收货人:</text>
  40. <text>{{ info.username }}</text>
  41. </view>
  42. <view>
  43. <text>手机号:</text>
  44. <text>{{ info.mobile }}</text>
  45. </view>
  46. <view>
  47. <text>收货地址:</text>
  48. <text>{{ info.local }}</text>
  49. </view>
  50. <navigator url="./information" class="info_btn">编辑地址</navigator>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import {
  58. GetEnrollInfo_online,
  59. _API_HuiFuCheck_online,
  60. _API_QuickBankPay_online,
  61. _API_QuickBankSms_online,
  62. _API_CheckStatus_online,
  63. GetEnrollUserAddress
  64. } from '@/apis/szy.js';
  65. import {
  66. UploadSzyImg
  67. } from '@/common/util/request'
  68. export default {
  69. data() {
  70. return {
  71. status: false,
  72. info: {},
  73. data: {
  74. season: '',
  75. start: '',
  76. end: '',
  77. name: '',
  78. mobile: '',
  79. cost: '',
  80. local: ''
  81. },
  82. noClick: true,
  83. showSignup: false,
  84. countDown: 0, // 倒计时,
  85. sms_code: '', // 验证码,
  86. id: '',
  87. payId: ''
  88. }
  89. },
  90. onShow() {
  91. this.getInfo()
  92. this.getBank()
  93. // this.getData()
  94. },
  95. computed: {
  96. userinfo() {
  97. return this.$store.state.userinfo
  98. }
  99. },
  100. onPullDownRefresh() {
  101. this.getInfo()
  102. },
  103. methods: {
  104. // 获取地址
  105. getAddress() {
  106. GetEnrollUserAddress().then(res => {
  107. if (res.code === 200) {
  108. this.info = res.data
  109. const data = res.data
  110. this.info.local = data.province + data.city + data.area + data.address
  111. } else {
  112. uni.showModal({
  113. content: res.message || '获取失败',
  114. showCancel: false
  115. })
  116. }
  117. })
  118. },
  119. // 去重新绑定
  120. goUnbank() {
  121. uni.navigateTo({
  122. url: '../zbs/unBank?type=2'
  123. })
  124. },
  125. // 查询绑卡信息
  126. getBank() {
  127. uni.showLoading()
  128. _API_HuiFuCheck_online().then(res => {
  129. uni.hideLoading()
  130. if (res.code == 200) {
  131. this.id = res.data.id
  132. } else if (res.code == 50014) {
  133. this.id = ''
  134. uni.showModal({
  135. title: '提示',
  136. content: '检测到您还未绑定银行卡,请前往绑定',
  137. showCancel: false,
  138. success: (res) => {
  139. if (res.confirm) {
  140. uni.navigateTo({
  141. url: '../zbs/form?type=2'
  142. })
  143. }
  144. }
  145. })
  146. return
  147. } else {
  148. this.id = ''
  149. uni.showModal({
  150. content: res.message || '获取失败',
  151. showCancel: false
  152. });
  153. return false;
  154. }
  155. })
  156. },
  157. // 1.发送验证码
  158. getCode() {
  159. if (!this.status) {
  160. return
  161. }
  162. if (!this.id) {
  163. uni.showModal({
  164. content: '未绑定银行卡',
  165. showCancel: false
  166. })
  167. return
  168. }
  169. let that = this
  170. _API_QuickBankPay_online({ id: this.id }).then(res => {
  171. if (res.code == 200) {
  172. uni.showModal({
  173. content: '验证码发送成功',
  174. showCancel: false,
  175. success: (e) => {
  176. if (e.confirm) {
  177. that.payId = res.data.id
  178. that.countDown = 180;
  179. that.timer = setInterval(() => {
  180. that.countDown--;
  181. if (!that.countDown) {
  182. that.countDown = 0;
  183. clearInterval(that.timer);
  184. }
  185. }, 1000);
  186. }
  187. }
  188. })
  189. } else {
  190. uni.showModal({
  191. content: res.message || '获取验证码失败',
  192. showCancel: false
  193. });
  194. return false;
  195. }
  196. })
  197. },
  198. // 2. 携带验证码支付
  199. singup() {
  200. let that = this
  201. if (!this.status) {
  202. return
  203. }
  204. if (!this.sms_code) {
  205. uni.showModal({
  206. content: '请先输入验证码',
  207. showCancel: false
  208. })
  209. return
  210. }
  211. uni.showModal({
  212. title: '提示',
  213. content: '确定要支付吗?',
  214. success: (res) => {
  215. if (res.confirm) {
  216. _API_QuickBankSms_online({ id: that.payId, sms_code: that.sms_code }).then(res => {
  217. if (res.code == 200) {
  218. if (res.data.status == 0) {
  219. that.SearchStatus()
  220. } else if (res.data.status == 1) {
  221. uni.navigateBack({
  222. delta: 2
  223. })
  224. }
  225. } else {
  226. uni.showModal({
  227. title: '失败',
  228. content: res.message || '获取失败',
  229. showCancel: false
  230. })
  231. return false;
  232. }
  233. })
  234. .catch(err => {})
  235. .finally(() => {
  236. setTimeout(() => {}, 3000)
  237. })
  238. }
  239. }
  240. })
  241. },
  242. // 3. 查询支付状态
  243. SearchStatus() {
  244. let that = this
  245. uni.showLoading({
  246. title: '查询支付状态中...',
  247. mask: true
  248. });
  249. _API_CheckStatus_online({ id: this.payId }).then(res => {
  250. if (res.code == 200) {
  251. if (res.data.status == 1) {
  252. uni.hideLoading()
  253. uni.navigateBack({
  254. delta: 2
  255. })
  256. } else {
  257. that.SearchStatus()
  258. }
  259. } else {
  260. uni.hideLoading()
  261. uni.showModal({
  262. content: res.message || '查询失败',
  263. showCancel: false
  264. })
  265. }
  266. }).catch(err => {
  267. uni.hideLoading()
  268. uni.showModal({
  269. content: err || '查询失败',
  270. showCancel: false
  271. })
  272. })
  273. },
  274. getTimes(data) {
  275. var time = new Date(data)
  276. var year = time.getFullYear()
  277. var month = time.getMonth() + 1 < 10 ? '0' + (time.getMonth() + 1) : time.getMonth() + 1;
  278. var day = time.getDate() < 10 ? '0' + time.getDate() : time.getDate();
  279. var today = year + '.' + month + '.' + day;
  280. return today;
  281. },
  282. // 获取赛季信息
  283. getInfo() {
  284. GetEnrollInfo_online().then(res => {
  285. if (res.code == 200) {
  286. // res.data.enroll_start_time = "2023-12-05 10:30:00" // 报名时间
  287. // res.data.status = 0
  288. this.data = res.data
  289. // uni.setStorageSync("szy_data", res.data)
  290. this.data.start = this.getTimes(res.data.start_time)
  291. this.data.end = this.getTimes(res.data.end_time)
  292. const a = new Date(res.data.enroll_start_time.replace(/-/g,'/')).getTime()
  293. const b = new Date(res.data.enroll_end_time.replace(/-/g,'/')).getTime()
  294. const now = Date.parse(new Date())
  295. if (now > a && now < b && res.data.limit_num > res.data.num) {
  296. this.status = true
  297. }
  298. if (res.data.status == 1 && res.data.pay_status == 1) {
  299. this.getAddress()
  300. this.showSignup = true
  301. } else {
  302. this.showSignup = false
  303. }
  304. } else {
  305. uni.showModal({
  306. content: res.message || '获取失败',
  307. showCancel: false
  308. })
  309. }
  310. })
  311. },
  312. }
  313. }
  314. </script>
  315. <style lang="scss" scoped>
  316. .payB {
  317. margin-top: 30rpx;
  318. text-align: center;
  319. color: #FF232C;
  320. font-weight: bold;
  321. }
  322. .pay {
  323. margin: 0 30rpx 0 30rpx;
  324. border-radius: 16rpx;
  325. background-color: #fff;
  326. padding: 40rpx 20rpx 40rpx 20rpx;
  327. &_title {
  328. font-size: 34rpx;
  329. font-weight: bold;
  330. }
  331. &_time {
  332. margin-top: 20rpx;
  333. font-size: 32rpx;
  334. }
  335. &_btnSig {
  336. margin: 50rpx auto 0;
  337. width: 600rpx;
  338. line-height: 88rpx;
  339. border-radius: 44rpx;
  340. text-align: center;
  341. color: #fff;
  342. font-size: 32rpx;
  343. }
  344. .red {
  345. background: linear-gradient(93deg, #FF232C 0%, #FF571B 100%);
  346. }
  347. .gray {
  348. background-color: #E1E1E1;
  349. }
  350. }
  351. .item {
  352. @include flex();
  353. height: 104rpx;
  354. box-sizing: border-box;
  355. color: $app-sec-text-color;
  356. background: #F8F8F8;
  357. margin: 50rpx 0 40rpx 0;
  358. border-radius: 8rpx;
  359. padding-left: 24rpx;
  360. .login_icon {
  361. width: 36rpx;
  362. height: 44rpx;
  363. }
  364. .icon,
  365. .cuIcon-roundclosefill {
  366. margin: 0 20rpx;
  367. font-size: 36rpx;
  368. }
  369. input {
  370. flex: 1;
  371. height: 104rpx;
  372. margin-left: 15rpx;
  373. }
  374. .countdown {
  375. @include flex();
  376. height: 60rpx;
  377. font-size: 24rpx;
  378. padding: 0 20rpx;
  379. margin-right: 20rpx;
  380. border-radius: 33rpx;
  381. text {
  382. margin-left: 8rpx;
  383. }
  384. }
  385. .red2 {
  386. border: 2rpx solid #FB231F;
  387. color: $base-color;
  388. }
  389. .gray2 {
  390. border: 2rpx solid #999;
  391. color: #999;
  392. }
  393. }
  394. .top {
  395. margin: 0 30rpx 0 30rpx;
  396. border-radius: 16rpx;
  397. background-color: #fff;
  398. padding: 40rpx 20rpx 40rpx 20rpx;
  399. }
  400. .title {
  401. font-size: 34rpx;
  402. font-weight: bold;
  403. }
  404. .time {
  405. margin-top: 20rpx;
  406. font-size: 32rpx;
  407. }
  408. .btnSig {
  409. margin: 50rpx auto 0;
  410. width: 600rpx;
  411. line-height: 88rpx;
  412. border-radius: 44rpx;
  413. text-align: center;
  414. color: #fff;
  415. font-size: 32rpx;
  416. }
  417. .red {
  418. background: linear-gradient(93deg, #FF232C 0%, #FF571B 100%);
  419. }
  420. .gray {
  421. background-color: #E1E1E1;
  422. }
  423. .voucher {
  424. hieght: 100vh;
  425. min-height: 100vh;
  426. width: 100vw;
  427. position: relative;
  428. .bgImg {
  429. height: 100vh;
  430. width: 100vw;
  431. position: fixed;
  432. top: 0;
  433. left: 0;
  434. display: flex;
  435. flex-direction: column;
  436. align-items: center;
  437. font-size: 46rpx;
  438. font-weight: bold;
  439. text {
  440. color: #FFFFFF;
  441. margin-top: 10rpx;
  442. }
  443. }
  444. .voucher_con {
  445. position: fixed;
  446. height: 85%;
  447. width: 100%;
  448. bottom: 0;
  449. left: 0;
  450. background: #fff;
  451. border-top-left-radius: 60rpx;
  452. border-top-right-radius: 60rpx;
  453. .line {
  454. width: 128rpx;
  455. height: 8rpx;
  456. background: #f1f3f5;
  457. margin: 36rpx auto 0;
  458. }
  459. .title {
  460. color: #333;
  461. font-size: 38rpx;
  462. // margin: 48rpx auto 60rpx;
  463. text-align: center;
  464. font-weight: bold;
  465. }
  466. .voucher_icon {
  467. text-align: center;
  468. // image {
  469. // height: 192rpx;
  470. // width: 192rpx;
  471. // margin-bottom: 30rpx;
  472. // }
  473. .success {
  474. margin-top: 18rpx;
  475. font-size: 48rpx;
  476. color: #333;
  477. font-weight: bold;
  478. }
  479. .timed {
  480. margin-top: 36rpx;
  481. font-size: 40rpx;
  482. font-weight: bold;
  483. color: #FF0000;
  484. }
  485. }
  486. .logistics {
  487. width: 250rpx;
  488. height: 68rpx;
  489. margin: 0 auto;
  490. background: rgba(255, 244, 243, 0.39);
  491. border: 2rpx solid #FB231F;
  492. opacity: 1;
  493. border-radius: 44rpx;
  494. color: #FB231F;
  495. }
  496. .info {
  497. margin: 68rpx 50rpx 40rpx 50rpx;
  498. color: #333333;
  499. text {
  500. font-size: 32rpx;
  501. }
  502. >view {
  503. margin-top: 20rpx;
  504. }
  505. &_btn {
  506. margin: 30rpx auto 0 !important;
  507. width: 388rpx;
  508. line-height: 80rpx;
  509. text-align: center;
  510. background: #FFF4F3;
  511. border: 2rpx solid #FB231F;
  512. opacity: 1;
  513. border-radius: 44rpx;
  514. font-size: 30rpx;
  515. font-weight: bold;
  516. color: #FB231F;
  517. }
  518. }
  519. }
  520. }
  521. .bottom {
  522. position: fixed;
  523. bottom: 0;
  524. width: 100%;
  525. height: 100rpx;
  526. padding: 6rpx 30rpx;
  527. background-color: #fff;
  528. border-top: 1px solid #eeeeee;
  529. &-btn {
  530. color: #fff;
  531. text-align: center;
  532. font-size: 32rpx;
  533. font-weight: bold;
  534. line-height: 88rpx;
  535. height: 88rpx;
  536. background: linear-gradient(90deg, #F30000 0%, #FE4815 100%);
  537. opacity: 1;
  538. border-radius: 44px;
  539. }
  540. }
  541. </style>