payment.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <view style="padding-top: 50rpx;">
  3. <view class="top" v-if="!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 v-if="data.status == 1" class="btnSig gray">已获取名额</view>
  13. <view v-else class="btnSig" :class="status ? 'red' : 'gray'" v-throttle="2000" @click="singup">点击获取名额</view>
  14. </view>
  15. <view class="voucher" v-else>
  16. <image src="../../static/new_my/bg.png" class="bgImg" mode="widthFix" style="width: 750rpx;"></image>
  17. <view class="bgImg">
  18. <text style="margin-top: 30rpx;">第{{ data.season }}届大卫博士创业实战营</text>
  19. </view>
  20. <view class="voucher_con">
  21. <view class="voucher_icon">
  22. <image src="../../static/icon/success.png" mode="widthFix" style="width: 300rpx;margin-top: 78rpx;">
  23. </image>
  24. <view class="success">报名成功</view>
  25. <view class="timed">
  26. 举办时间:{{ data.start+ '-' +data.end }}
  27. </view>
  28. <view class="timed">
  29. <view class="left">人脸照片:</view>
  30. <view class="right">
  31. <image v-if="data.path" :src="data.path" @click="initFace" mode="widthFix" style="width: 160rpx;height: 160rpx;">
  32. </image>
  33. <image v-else src="../../static/icon/uploadF.png" mode="widthFix" style="width: 160rpx;"
  34. @click="initFace"></image>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. import {
  44. _API_payment,
  45. _API_SearchStatus,
  46. GetEnrollInfo
  47. } from '@/apis/szy.js';
  48. import {
  49. UploadSzyImg
  50. } from '@/common/util/request'
  51. export default {
  52. data() {
  53. return {
  54. status: false,
  55. data: {
  56. season: '',
  57. start: '',
  58. end: '',
  59. name: '',
  60. mobile: '',
  61. cost: '',
  62. local: ''
  63. },
  64. noClick: true,
  65. showSignup: false,
  66. }
  67. },
  68. onLoad() {
  69. this.getInfo()
  70. // this.getData()
  71. },
  72. computed: {
  73. userinfo() {
  74. return this.$store.state.userinfo
  75. }
  76. },
  77. onPullDownRefresh() {
  78. this.getInfo()
  79. },
  80. methods: {
  81. initFace() {
  82. uni.chooseImage({
  83. count: 1, //默认9
  84. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  85. sourceType: ['album'], //从相册选择
  86. success: res => {
  87. const tempFilePaths = res.tempFilePaths;
  88. uni.uploadFile({
  89. url: UploadSzyImg,
  90. filePath: tempFilePaths[0],
  91. name: 'image',
  92. header: {
  93. Authorization: 'Bearer ' + this.$store.state.app.token
  94. },
  95. success: (res) => {
  96. const data = JSON.parse(res.data)
  97. if (data.code == 200) {
  98. this.getInfo()
  99. } else {
  100. uni.showToast({
  101. title: res.message || '上传失败',
  102. icon: 'none'
  103. })
  104. }
  105. },
  106. fail: err => {
  107. uni.showToast({
  108. title: '上传失败1',
  109. icon: 'none'
  110. })
  111. }
  112. });
  113. }
  114. })
  115. },
  116. getTimes(data) {
  117. var time = new Date(data)
  118. var year = time.getFullYear()
  119. var month = time.getMonth() + 1 < 10 ? '0' + (time.getMonth() + 1) : time.getMonth() + 1;
  120. var day = time.getDate() < 10 ? '0' + time.getDate() : time.getDate();
  121. var today = year + '.' + month + '.' + day;
  122. return today;
  123. },
  124. // 支付状态
  125. SearchStatus() {
  126. uni.showLoading({
  127. mask: true
  128. })
  129. _API_SearchStatus().then(res => {
  130. uni.hideLoading()
  131. if (res.code == 200) {
  132. this.getInfo()
  133. } else {
  134. uni.showModal({
  135. content: res.message || '获取失败',
  136. showCancel: false
  137. })
  138. }
  139. })
  140. },
  141. // 获取赛季信息
  142. getInfo() {
  143. GetEnrollInfo().then(res => {
  144. if (res.code == 200) {
  145. // res.data.enroll_start_time = "2023-12-23 10:30:00" // 报名时间
  146. // res.data.enroll_end_time = "2023-12-24 12:30:00" // 报名时间
  147. this.data = res.data
  148. uni.setStorageSync("szy_data", res.data)
  149. this.data.start = this.getTimes(res.data.start_time)
  150. this.data.end = this.getTimes(res.data.end_time)
  151. const a = new Date(res.data.enroll_start_time.replace(/-/g,'/')).getTime()
  152. const b = new Date(res.data.enroll_end_time.replace(/-/g,'/')).getTime()
  153. const now = Date.parse(new Date())
  154. if (now > a && now < b && res.data.limit_num > res.data.num) {
  155. this.status = true
  156. }
  157. if (res.data.status == 1 && res.data.pay_status == 1) {
  158. this.showSignup = true
  159. } else if (res.data.status == 1 && res.data.pay_status == 0) {
  160. this.showSignup = false
  161. uni.navigateTo({
  162. url: './singup'
  163. })
  164. } else {
  165. this.showSignup = false
  166. }
  167. } else {
  168. uni.showModal({
  169. content: res.message || '获取失败',
  170. showCancel: false
  171. })
  172. }
  173. })
  174. },
  175. singup() {
  176. if (!this.status && !this.data.status) {
  177. return
  178. }
  179. let that = this
  180. uni.showModal({
  181. title: '提示',
  182. content: '确定要获取名额吗?',
  183. success: (res) => {
  184. if (res.confirm) {
  185. _API_payment().then(res => {
  186. if (res.code == 200) {
  187. // that.SearchStatus()
  188. uni.navigateTo({
  189. url: './singup'
  190. })
  191. } else {
  192. uni.showModal({
  193. title: '失败',
  194. content: res.message || '获取失败',
  195. showCancel: false
  196. })
  197. return false;
  198. }
  199. })
  200. .catch(err => {})
  201. .finally(() => {
  202. setTimeout(() => {}, 3000)
  203. })
  204. }
  205. }
  206. })
  207. }
  208. }
  209. }
  210. </script>
  211. <style lang="scss" scoped>
  212. .top {
  213. margin: 0 30rpx 0 30rpx;
  214. border-radius: 16rpx;
  215. background-color: #fff;
  216. padding: 40rpx 20rpx 40rpx 20rpx;
  217. }
  218. .title {
  219. font-size: 34rpx;
  220. font-weight: bold;
  221. }
  222. .time {
  223. margin-top: 20rpx;
  224. font-size: 32rpx;
  225. }
  226. .btnSig {
  227. margin: 50rpx auto 0;
  228. width: 600rpx;
  229. line-height: 88rpx;
  230. border-radius: 44rpx;
  231. text-align: center;
  232. color: #fff;
  233. font-size: 32rpx;
  234. }
  235. .red {
  236. background: linear-gradient(93deg, #FF232C 0%, #FF571B 100%);
  237. }
  238. .gray {
  239. background-color: #E1E1E1;
  240. }
  241. .voucher {
  242. hieght: 100vh;
  243. min-height: 100vh;
  244. width: 100vw;
  245. position: relative;
  246. .bgImg {
  247. height: 100vh;
  248. width: 100vw;
  249. position: fixed;
  250. top: 0;
  251. left: 0;
  252. display: flex;
  253. flex-direction: column;
  254. align-items: center;
  255. font-size: 46rpx;
  256. font-weight: bold;
  257. text {
  258. color: #FFFFFF;
  259. margin-top: 10rpx;
  260. }
  261. }
  262. .voucher_con {
  263. position: fixed;
  264. height: 85%;
  265. width: 100%;
  266. bottom: 0;
  267. left: 0;
  268. background: #fff;
  269. border-top-left-radius: 60rpx;
  270. border-top-right-radius: 60rpx;
  271. .line {
  272. width: 128rpx;
  273. height: 8rpx;
  274. background: #f1f3f5;
  275. margin: 36rpx auto 0;
  276. }
  277. .title {
  278. color: #333;
  279. font-size: 38rpx;
  280. // margin: 48rpx auto 60rpx;
  281. text-align: center;
  282. font-weight: bold;
  283. }
  284. .voucher_icon {
  285. text-align: center;
  286. // image {
  287. // height: 192rpx;
  288. // width: 192rpx;
  289. // margin-bottom: 30rpx;
  290. // }
  291. .success {
  292. margin-top: 18rpx;
  293. font-size: 48rpx;
  294. color: #333;
  295. font-weight: bold;
  296. }
  297. .timed {
  298. margin-top: 36rpx;
  299. font-size: 30rpx;
  300. font-weight: bold;
  301. // color: #FF0000;
  302. display: flex;
  303. padding-left: 60rpx;
  304. }
  305. }
  306. .logistics {
  307. width: 250rpx;
  308. height: 68rpx;
  309. margin: 0 auto;
  310. background: rgba(255, 244, 243, 0.39);
  311. border: 2rpx solid #FB231F;
  312. opacity: 1;
  313. border-radius: 44rpx;
  314. color: #FB231F;
  315. }
  316. .info {
  317. margin: 68rpx 50rpx 40rpx 50rpx;
  318. color: #333333;
  319. text {
  320. font-size: 32rpx;
  321. }
  322. >view {
  323. margin-top: 20rpx;
  324. }
  325. }
  326. }
  327. }
  328. .bottom {
  329. position: fixed;
  330. bottom: 0;
  331. width: 100%;
  332. height: 100rpx;
  333. padding: 6rpx 30rpx;
  334. background-color: #fff;
  335. border-top: 1px solid #eeeeee;
  336. &-btn {
  337. color: #fff;
  338. text-align: center;
  339. font-size: 32rpx;
  340. font-weight: bold;
  341. line-height: 88rpx;
  342. height: 88rpx;
  343. background: linear-gradient(90deg, #F30000 0%, #FE4815 100%);
  344. opacity: 1;
  345. border-radius: 44px;
  346. }
  347. }
  348. </style>