payment_xs.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. <template>
  2. <view style="padding-top: 50rpx;">
  3. <view v-if="!showSignup">
  4. <view class="top">
  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="title">
  8. 第{{ data.season }}届大卫博士创业实战营(线上)
  9. </view>
  10. <view class="time">
  11. 举办时间:{{ data.start + '-' + data.end }}
  12. </view>
  13. <view v-if="data.status == 1" class="btnSig gray">已获取名额</view>
  14. <view v-else class="btnSig" :class="status ? 'red' : 'gray'" v-throttle="2000" @click="singup">点击获取名额</view>
  15. </view>
  16. </view>
  17. <view class="voucher" v-else>
  18. <image src="../../static/new_my/bg.png" class="bgImg" mode="widthFix" style="width: 750rpx;"></image>
  19. <view class="bgImg">
  20. <text style="margin-top: 30rpx;">第{{ data.season }}届大卫博士创业实战营(线上)</text>
  21. </view>
  22. <view class="voucher_con">
  23. <view class="voucher_icon">
  24. <image src="../../static/icon/success.png" mode="widthFix" style="width: 300rpx;margin-top: 78rpx;">
  25. <!-- <image :src="`../../static/icon/${data.pay_status ? 'success' : 'show'}.png`" mode="widthFix" style="width: 300rpx;margin-top: 78rpx;"> -->
  26. </image>
  27. <view class="success">{{ data.pay_status ? '报名成功' : '报名成功,请把钱转给老大' }}</view>
  28. <view class="timed">
  29. 举办时间:{{ data.start+ '-' +data.end }}
  30. </view>
  31. </view>
  32. <view class="info" v-show="data.pay_status">
  33. <view>
  34. <text>收货人:</text>
  35. <text>{{ info.username }}</text>
  36. </view>
  37. <view>
  38. <text>手机号:</text>
  39. <text>{{ info.mobile }}</text>
  40. </view>
  41. <view>
  42. <text>收货地址:</text>
  43. <text>{{ info.local }}</text>
  44. </view>
  45. <navigator url="./information" class="info_btn">编辑地址</navigator>
  46. </view>
  47. </view>
  48. </view>
  49. <!-- <view class="bottom" v-if="showSignup">
  50. <view class="bottom-btn" @click="goBack">返回首页</view>
  51. <view v-else class="bottom-btn" v-throttle="2000" @click="singup">立即支付</view>
  52. </view> -->
  53. </view>
  54. </template>
  55. <script>
  56. import {
  57. _API_payment,
  58. _API_SearchStatus,
  59. GetEnrollInfo,
  60. GetEnrollUserAddress,
  61. GetSzyGiftInfo
  62. } from '@/apis/szy.js';
  63. export default {
  64. data() {
  65. return {
  66. showTip: false,
  67. status: false,
  68. info: {},
  69. data: {
  70. season: '',
  71. start: '',
  72. end: '',
  73. username: '',
  74. mobile: '',
  75. cost: '',
  76. local: ''
  77. },
  78. noClick: true,
  79. showSignup: false,
  80. }
  81. },
  82. onShow() {
  83. this.getInfo()
  84. },
  85. computed: {
  86. userinfo() {
  87. return this.$store.state.userinfo
  88. }
  89. },
  90. onPullDownRefresh() {
  91. this.getInfo()
  92. },
  93. methods: {
  94. // 查看物流信息
  95. toLogistics() {
  96. uni.navigateTo({
  97. url: "/pages/szy-logistics/szy-logistics?info=" + JSON.stringify(this.logInfo)
  98. })
  99. },
  100. // 返回首页
  101. goBack() {
  102. uni.switchTab({
  103. url: '/pages/index/index'
  104. })
  105. },
  106. // 获取赛季信息
  107. getInfo() {
  108. GetEnrollInfo().then(res => {
  109. if (res.code == 200) {
  110. // console.log(res.data)
  111. // res.data.status = 1
  112. // res.data.pay_status = 1
  113. this.data = res.data
  114. this.data.start = this.getTimes(res.data.start_time)
  115. this.data.end = this.getTimes(res.data.end_time)
  116. // res.data.enroll_start_time = '2023-10-15 10:30:00'
  117. const a = new Date(res.data.enroll_start_time.replace(/-/g,'/')).getTime()
  118. const b = new Date(res.data.enroll_end_time.replace(/-/g,'/')).getTime()
  119. const now = Date.parse(new Date())
  120. if (now > a && now < b && res.data.limit_num > res.data.num) {
  121. this.status = true
  122. }
  123. if (res.data.status == 1) {
  124. this.showSignup = true
  125. } else {
  126. this.showSignup = false
  127. }
  128. if (res.data.pay_status) {
  129. this.getAddress()
  130. }
  131. } else {
  132. uni.showModal({
  133. content: res.message || '获取失败',
  134. showCancel: false
  135. })
  136. }
  137. })
  138. },
  139. getAddress() {
  140. GetEnrollUserAddress().then(res => {
  141. if (res.code === 200) {
  142. this.info = res.data
  143. const data = res.data
  144. this.info.local = data.province + data.city + data.area + data.address
  145. } else {
  146. uni.showModal({
  147. content: res.message || '获取失败',
  148. showCancel: false
  149. })
  150. }
  151. })
  152. },
  153. getTimes(data) {
  154. var time = new Date(data.replace(/-/g,'/'))
  155. var year = time.getFullYear()
  156. var month = time.getMonth() + 1 < 10 ? '0' + (time.getMonth() + 1) : time.getMonth() + 1;
  157. var day = time.getDate() < 10 ? '0' + time.getDate() : time.getDate();
  158. var today = year + '.' + month + '.' + day;
  159. return today;
  160. },
  161. // 支付状态
  162. SearchStatus() {
  163. uni.showLoading({
  164. mask: true
  165. })
  166. _API_SearchStatus().then(res => {
  167. uni.hideLoading()
  168. if (res.code == 200) {
  169. this.getInfo()
  170. } else {
  171. uni.showModal({
  172. content: res.message || '获取失败',
  173. showCancel: false
  174. })
  175. }
  176. })
  177. },
  178. //WeixinJSBridge判断
  179. wxJsPay(data, callback_succ_func, callback_error_func) {
  180. if (typeof WeixinJSBridge == 'undefined') {
  181. if (document.addEventListener) {
  182. document.addEventListener('WeixinJSBridgeReady', this.jsApiCall, false);
  183. } else if (document.attachEvent) {
  184. document.attachEvent('WeixinJSBridgeReady', this.jsApiCall);
  185. document.attachEvent('onWeixinJSBridgeReady', this.jsApiCall);
  186. }
  187. } else {
  188. this.jsApiCall(data, callback_succ_func, callback_error_func);
  189. }
  190. },
  191. //调起支付
  192. jsApiCall(data, callback_succ_func, callback_error_func) {
  193. let that = this
  194. //使用原生的,避免初始化appid问题
  195. WeixinJSBridge.invoke(
  196. 'getBrandWCPayRequest', {
  197. appId: data.appId,
  198. timeStamp: data.timestamp,
  199. nonceStr: data.nonceStr,
  200. package: data.package,
  201. signType: data.signType,
  202. paySign: data.paySign
  203. },
  204. function(res) {
  205. var msg = res.err_msg ? res.err_msg : res.errMsg;
  206. switch (msg) {
  207. //支付成功时
  208. case 'get_brand_wcpay_request:ok':
  209. if (callback_succ_func) {
  210. uni.showModal({
  211. title: '支付成功',
  212. showCancel: false
  213. })
  214. callback_succ_func(res);
  215. }
  216. break;
  217. default:
  218. //支付失败时
  219. WeixinJSBridge.log('支付失败!' + msg + ',请返回重试.');
  220. if (callback_error_func) {
  221. callback_error_func({
  222. msg: msg
  223. });
  224. }
  225. break;
  226. }
  227. }
  228. );
  229. },
  230. singup() {
  231. if (!this.status && !this.data.status) {
  232. return
  233. }
  234. let that = this
  235. uni.showModal({
  236. title: '提示',
  237. content: '确定要获取名额吗?',
  238. success: (res) => {
  239. if (res.confirm) {
  240. _API_payment().then(res => {
  241. if (res.code == 200) {
  242. that.SearchStatus()
  243. } else {
  244. uni.showModal({
  245. title: '失败',
  246. content: res.message || '获取失败',
  247. showCancel: false
  248. })
  249. return false;
  250. }
  251. })
  252. .catch(err => {})
  253. .finally(() => {
  254. setTimeout(() => {}, 3000)
  255. })
  256. }
  257. }
  258. })
  259. }
  260. },
  261. }
  262. </script>
  263. <style>
  264. </style>
  265. <style lang="scss" scoped>
  266. .top {
  267. margin: 0 30rpx 0 30rpx;
  268. border-radius: 16rpx;
  269. background-color: #fff;
  270. padding: 40rpx 20rpx 40rpx 20rpx;
  271. }
  272. .tip {
  273. font-size: 36rpx;
  274. text-align: center;
  275. font-weight: bold;
  276. margin-top: 30rpx;
  277. color: #FB231F;
  278. }
  279. .title {
  280. font-size: 34rpx;
  281. font-weight: bold;
  282. }
  283. .time {
  284. margin-top: 20rpx;
  285. font-size: 32rpx;
  286. }
  287. .btnSig {
  288. margin: 50rpx auto 0;
  289. width: 600rpx;
  290. line-height: 88rpx;
  291. border-radius: 44rpx;
  292. text-align: center;
  293. color: #fff;
  294. font-size: 32rpx;
  295. }
  296. .red {
  297. background: linear-gradient(93deg, #FF232C 0%, #FF571B 100%);
  298. }
  299. .gray {
  300. background-color: #E1E1E1;
  301. }
  302. .voucher {
  303. hieght: 100vh;
  304. min-height: 100vh;
  305. width: 100vw;
  306. position: relative;
  307. .bgImg {
  308. height: 100vh;
  309. width: 100vw;
  310. position: fixed;
  311. top: 0;
  312. left: 0;
  313. display: flex;
  314. flex-direction: column;
  315. align-items: center;
  316. font-size: 46rpx;
  317. font-weight: bold;
  318. text {
  319. color: #FFFFFF;
  320. margin-top: 10rpx;
  321. }
  322. }
  323. .voucher_con {
  324. position: fixed;
  325. height: 85%;
  326. width: 100%;
  327. bottom: 0;
  328. left: 0;
  329. background: #fff;
  330. border-top-left-radius: 60rpx;
  331. border-top-right-radius: 60rpx;
  332. .line {
  333. width: 128rpx;
  334. height: 8rpx;
  335. background: #f1f3f5;
  336. margin: 36rpx auto 0;
  337. }
  338. .title {
  339. color: #333;
  340. font-size: 38rpx;
  341. // margin: 48rpx auto 60rpx;
  342. text-align: center;
  343. font-weight: bold;
  344. }
  345. .voucher_icon {
  346. text-align: center;
  347. // image {
  348. // height: 192rpx;
  349. // width: 192rpx;
  350. // margin-bottom: 30rpx;
  351. // }
  352. .success {
  353. margin-top: 18rpx;
  354. font-size: 48rpx;
  355. color: #333;
  356. font-weight: bold;
  357. }
  358. .timed {
  359. margin-top: 36rpx;
  360. font-size: 40rpx;
  361. font-weight: bold;
  362. color: #FF0000;
  363. }
  364. }
  365. .logistics {
  366. width: 250rpx;
  367. height: 68rpx;
  368. margin: 0 auto;
  369. background: rgba(255, 244, 243, 0.39);
  370. border: 2rpx solid #FB231F;
  371. opacity: 1;
  372. border-radius: 44rpx;
  373. color: #FB231F;
  374. }
  375. .info {
  376. margin: 68rpx 50rpx 40rpx 50rpx;
  377. color: #333333;
  378. text {
  379. font-size: 32rpx;
  380. }
  381. >view {
  382. margin-top: 20rpx;
  383. }
  384. &_btn {
  385. margin: 30rpx auto 0 !important;
  386. width: 388rpx;
  387. line-height: 80rpx;
  388. text-align: center;
  389. background: #FFF4F3;
  390. border: 2rpx solid #FB231F;
  391. opacity: 1;
  392. border-radius: 44rpx;
  393. font-size: 30rpx;
  394. font-weight: bold;
  395. color: #FB231F;
  396. }
  397. }
  398. }
  399. }
  400. .bottom {
  401. position: fixed;
  402. bottom: 0;
  403. width: 100%;
  404. height: 100rpx;
  405. padding: 6rpx 30rpx;
  406. background-color: #fff;
  407. border-top: 1px solid #eeeeee;
  408. &-btn {
  409. color: #fff;
  410. text-align: center;
  411. font-size: 32rpx;
  412. font-weight: bold;
  413. line-height: 88rpx;
  414. height: 88rpx;
  415. background: linear-gradient(90deg, #F30000 0%, #FE4815 100%);
  416. opacity: 1;
  417. border-radius: 44px;
  418. }
  419. }
  420. </style>