login.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <view class="container">
  3. <!-- logo区域 -->
  4. <image class="logo" src="/static/logo.png" mode="aspectFill"></image>
  5. <!-- 标题区域 -->
  6. <view class="title" v-if="pageValue == 1">信息采集迎新系统</view>
  7. <view class="title" v-if="pageValue == 2">宿舍选取迎新系统</view>
  8. <view class="title" v-if="pageValue == 3">访客预约迎新系统</view>
  9. <!-- 录取号区域 -->
  10. <view class="box">
  11. <view class="box_text">录取号</view>
  12. <view class="box_input">
  13. <input class="input" type="text" placeholder="请输入录取号" placeholder-style="color:#CCCCCC;font-size:28rpx" v-model="admissNum" />
  14. </view>
  15. </view>
  16. <!-- 身份证号区域 -->
  17. <view class="box">
  18. <view class="box_text">身份证号</view>
  19. <view class="box_input">
  20. <input class="input" type="text" placeholder="请输入身份证号" placeholder-style="color:#CCCCCC;font-size:28rpx" v-model="cardId" />
  21. </view>
  22. </view>
  23. <!-- 登录按钮区域 -->
  24. <view class="btn" :class="{ active: admissNum && cardId }" @click="handleLogin">授权登录</view>
  25. <!-- 背景图片区域 -->
  26. <image class="logo_bg" src="/static/logo-bg.png" mode="aspectFill"></image>
  27. <!-- 弹窗区域 -->
  28. <uni-popup ref="popup" :is-mask-click="false">
  29. <view class="pop">
  30. <image class="pop_img" src="/static/3.png" mode="aspectFill"></image>
  31. <!-- 关闭图标 -->
  32. <uni-icons class="pop_close" type="closeempty" color="#808080" size="20" @click="handleClose"></uni-icons>
  33. <view class="pop_title">温馨提示</view>
  34. <view class="pop_text" v-if="pageValue == 2">{{ tips.chooseDormitory }}</view>
  35. <view class="pop_text" v-if="pageValue == 3">{{ tips.carOrder }}</view>
  36. <view class="pop_btn" @click="handleFinish">去完成缴费</view>
  37. </view>
  38. </uni-popup>
  39. </view>
  40. </template>
  41. <script setup>
  42. import { onLoad } from '@dcloudio/uni-app'
  43. import { ref } from 'vue'
  44. import { loginReq } from '@/api/index.js'
  45. import { getSettingsInfoReq } from '@/api/index.js'
  46. // 页面类型
  47. const pageValue = ref()
  48. // 录取号
  49. const admissNum = ref()
  50. // 身份证号
  51. const cardId = ref()
  52. const popup = ref()
  53. const tips = ref({})
  54. onLoad((options) => {
  55. pageValue.value = options.pageValue
  56. // 获取设置数据
  57. getSettingsInfo()
  58. })
  59. // 获取设置数据
  60. const getSettingsInfo = async () => {
  61. const res = await getSettingsInfoReq()
  62. // console.log(res)
  63. if (res.code == 200) {
  64. tips.value = res.data
  65. }
  66. }
  67. // 授权登录按钮回调
  68. const handleLogin = async () => {
  69. if (!admissNum.value) {
  70. uni.showToast({
  71. title: '请输入录取号',
  72. icon: 'none'
  73. })
  74. return
  75. }
  76. if (!cardId.value) {
  77. uni.showToast({
  78. title: '请输入身份证号',
  79. icon: 'none'
  80. })
  81. return
  82. }
  83. let reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
  84. if (!reg.test(cardId.value)) {
  85. uni.showToast({
  86. title: '身份证号格式错误',
  87. icon: 'none'
  88. })
  89. return
  90. }
  91. const res = await loginReq({
  92. admissNum: admissNum.value,
  93. cardId: cardId.value
  94. })
  95. // console.log(res)
  96. if (res.code == 200) {
  97. uni.setStorageSync('studentInfo', res.data)
  98. uni.setStorageSync('TOKEN', res.data.token)
  99. if (pageValue.value == 1) {
  100. const studentInfo = uni.getStorageSync('studentInfo')
  101. if (studentInfo.fillStatus == '已填报') {
  102. uni.reLaunch({
  103. url: '/pages/myMsg/myMsg'
  104. })
  105. } else {
  106. uni.reLaunch({
  107. url: '/pages/read/read'
  108. })
  109. }
  110. } else if (pageValue.value == 2 || pageValue.value == 3) {
  111. let { isPay } = res.data
  112. // console.log(isPay)
  113. if (isPay == 0) {
  114. popup.value.open()
  115. } else if (isPay == 1) {
  116. if (pageValue.value == 2) {
  117. uni.reLaunch({
  118. url: '/pages/select/select'
  119. })
  120. } else {
  121. uni.reLaunch({
  122. url: '/pages/subscribe/subscribe'
  123. })
  124. }
  125. } else {
  126. uni.showToast({
  127. title: '暂无缴费信息',
  128. icon: 'none'
  129. })
  130. }
  131. } else {
  132. uni.setStorageSync('token', '')
  133. uni.reLaunch({
  134. url: '/pages/404/404?message=暂无页面'
  135. })
  136. }
  137. }
  138. }
  139. // 弹窗关闭图标回调
  140. const handleClose = () => {
  141. popup.value.close()
  142. }
  143. // 去完成缴费回调
  144. const handleFinish = () => {
  145. window.location.href = `https://pay.ncjti.edu.cn`
  146. }
  147. </script>
  148. <style lang="scss" scoped>
  149. .container {
  150. position: relative;
  151. display: flex;
  152. flex-direction: column;
  153. align-items: center;
  154. box-sizing: border-box;
  155. padding: 0 20rpx;
  156. width: 100%;
  157. min-height: 100vh;
  158. background: linear-gradient(180deg, rgba(242, 247, 255, 1) 0%, rgba(242, 247, 255, 0) 100%);
  159. overflow: hidden;
  160. .logo {
  161. margin-top: 80rpx;
  162. width: 143rpx;
  163. height: 143rpx;
  164. }
  165. .title {
  166. margin-top: 28rpx;
  167. font-size: 40rpx;
  168. font-weight: bold;
  169. }
  170. .box {
  171. margin-bottom: 40rpx;
  172. width: 100%;
  173. .box_text {
  174. margin-left: 30rpx;
  175. font-size: 28rpx;
  176. }
  177. .box_input {
  178. padding: 0 40rpx;
  179. margin-top: 10rpx;
  180. height: 100rpx;
  181. border-radius: 8rpx;
  182. background-color: #fff;
  183. .input {
  184. height: 100%;
  185. }
  186. }
  187. }
  188. .btn {
  189. display: flex;
  190. align-items: center;
  191. justify-content: center;
  192. margin-top: 260rpx;
  193. width: 100%;
  194. height: 100rpx;
  195. border-radius: 8rpx;
  196. font-size: 32rpx;
  197. color: #fff;
  198. background-color: #ccc;
  199. }
  200. .active {
  201. background-color: #0061ff;
  202. }
  203. .logo_bg {
  204. position: absolute;
  205. top: -50rpx;
  206. right: -45rpx;
  207. width: 589rpx;
  208. height: 320rpx;
  209. }
  210. .pop {
  211. position: relative;
  212. box-sizing: border-box;
  213. padding: 150rpx 20rpx 50rpx;
  214. width: 659rpx;
  215. height: 728rpx;
  216. border-radius: 15rpx;
  217. background: linear-gradient(180deg, #ebf2ff 0%, #ffffff 100%);
  218. .pop_img {
  219. position: absolute;
  220. top: -103rpx;
  221. left: 227rpx;
  222. width: 206rpx;
  223. height: 206rpx;
  224. }
  225. .pop_close {
  226. position: absolute;
  227. top: 19rpx;
  228. right: 29rpx;
  229. }
  230. .pop_title {
  231. margin-bottom: 28rpx;
  232. font-size: 32rpx;
  233. font-weight: bold;
  234. }
  235. .pop_text {
  236. font-size: 28rpx;
  237. line-height: 50rpx;
  238. }
  239. .pop_btn {
  240. display: flex;
  241. align-items: center;
  242. justify-content: center;
  243. margin: 90rpx auto 0;
  244. width: 543rpx;
  245. height: 100rpx;
  246. color: #fff;
  247. font-size: 32rpx;
  248. border-radius: 8rpx;
  249. background-color: #0061ff;
  250. }
  251. }
  252. }
  253. </style>