login.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view class="container">
  3. <!-- logo区域 -->
  4. <image class="logo" src="/static/logo.png" mode="aspectFill"></image>
  5. <!-- 标题区域 -->
  6. <view class="title">信息采集迎新系统</view>
  7. <!-- <view class="title" v-if="pageValue == 2" @click="ceshi">宿舍选取迎新系统</view>
  8. <view class="title" v-if="pageValue == 3" @click="ceshi">访客预约迎新系统</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">亲爱的同学,欢迎加入校园大家庭!</view>
  35. <view class="pop_text">系统显示您当前的缴费流程尚未完成。</view>
  36. <view class="pop_text">为了确保每位同学都能顺利开启校园生活,</view>
  37. <view class="pop_text">完成缴费后即可解锁宿舍选择功能哦~</view>
  38. <view class="pop_text">期待您早日选定心仪的宿舍,开启美好校园生活!</view>
  39. <view class="pop_btn" @click="handleFinish">去完成缴费</view>
  40. </view>
  41. </uni-popup>
  42. </view>
  43. </template>
  44. <script setup>
  45. import { onLoad } from '@dcloudio/uni-app'
  46. import { ref } from 'vue'
  47. import { loginReq } from '@/api/index.js'
  48. // 页面类型
  49. const pageValue = ref()
  50. // 录取号
  51. const admissNum = ref()
  52. // 身份证号
  53. const cardId = ref()
  54. const popup = ref()
  55. onLoad((options) => {
  56. // console.log(options)
  57. // pageValue.value = options.pageValue
  58. // console.log(pageValue.value)
  59. })
  60. // const ceshi = () => {
  61. // popup.value.open()
  62. // }
  63. // 弹窗关闭图标回调
  64. const handleClose = () => {
  65. popup.value.close()
  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_admissNum = /^\d{8}$/
  84. // if (!reg_admissNum.test(admissNum.value)) {
  85. // uni.showToast({
  86. // title: '录取号为8位数字',
  87. // icon: 'none'
  88. // })
  89. // return
  90. // }
  91. let reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/
  92. if (!reg.test(cardId.value)) {
  93. uni.showToast({
  94. title: '身份证号格式错误',
  95. icon: 'none'
  96. })
  97. return
  98. }
  99. const res = await loginReq({
  100. admissNum: admissNum.value,
  101. cardId: cardId.value
  102. })
  103. // console.log(res)
  104. if (res.code == 200) {
  105. uni.setStorageSync('studentInfo', res.data)
  106. uni.setStorageSync('TOKEN', res.data.token)
  107. // if (pageValue.value == 1) {
  108. // uni.reLaunch({
  109. // url: '/pages/read/read'
  110. // })
  111. // } else if (pageValue.value == 2) {
  112. // // uni.reLaunch({
  113. // // url: '/pages/select/select'
  114. // // })
  115. // popup.value.open()
  116. // } else if (pageValue.value == 3) {
  117. // uni.reLaunch({
  118. // url: '/pages/subscribe/subscribe'
  119. // })
  120. // } else {
  121. // uni.setStorageSync('token', '')
  122. // uni.reLaunch({
  123. // url: '/pages/404/404?message=暂无页面'
  124. // })
  125. // }
  126. uni.reLaunch({
  127. url: '/pages/read/read'
  128. })
  129. }
  130. }
  131. // 去完成缴费回调
  132. const handleFinish = () => {
  133. uni.reLaunch({
  134. url: '/pages/status/status'
  135. })
  136. }
  137. </script>
  138. <style lang="scss" scoped>
  139. .container {
  140. display: flex;
  141. flex-direction: column;
  142. align-items: center;
  143. padding: 0 20rpx;
  144. min-height: 100vh;
  145. background: linear-gradient(180deg, rgba(242, 247, 255, 1) 0%, rgba(242, 247, 255, 0) 100%);
  146. .logo {
  147. margin-top: 80rpx;
  148. width: 143rpx;
  149. height: 143rpx;
  150. }
  151. .title {
  152. margin-top: 28rpx;
  153. font-size: 40rpx;
  154. font-weight: bold;
  155. }
  156. .box {
  157. margin-bottom: 40rpx;
  158. width: 100%;
  159. .box_text {
  160. margin-left: 30rpx;
  161. font-size: 28rpx;
  162. }
  163. .box_input {
  164. padding: 0 40rpx;
  165. margin-top: 10rpx;
  166. height: 100rpx;
  167. border-radius: 8rpx;
  168. background-color: #fff;
  169. .input {
  170. height: 100%;
  171. }
  172. }
  173. }
  174. .btn {
  175. display: flex;
  176. align-items: center;
  177. justify-content: center;
  178. margin-top: 260rpx;
  179. width: 100%;
  180. height: 100rpx;
  181. border-radius: 8rpx;
  182. font-size: 32rpx;
  183. color: #fff;
  184. background-color: #ccc;
  185. }
  186. .active {
  187. background-color: #0061ff;
  188. }
  189. .logo_bg {
  190. position: absolute;
  191. top: -50rpx;
  192. right: -45rpx;
  193. width: 589rpx;
  194. height: 320rpx;
  195. }
  196. .pop {
  197. position: relative;
  198. box-sizing: border-box;
  199. padding: 150rpx 20rpx 50rpx;
  200. width: 659rpx;
  201. height: 728rpx;
  202. border-radius: 15rpx;
  203. background: linear-gradient(180deg, #ebf2ff 0%, #ffffff 100%);
  204. .pop_img {
  205. position: absolute;
  206. top: -103rpx;
  207. left: 227rpx;
  208. width: 206rpx;
  209. height: 206rpx;
  210. }
  211. .pop_close {
  212. position: absolute;
  213. top: 19rpx;
  214. right: 29rpx;
  215. }
  216. .pop_title {
  217. margin-bottom: 28rpx;
  218. font-size: 32rpx;
  219. font-weight: bold;
  220. }
  221. .pop_text {
  222. font-size: 28rpx;
  223. line-height: 50rpx;
  224. }
  225. .pop_btn {
  226. display: flex;
  227. align-items: center;
  228. justify-content: center;
  229. margin: 90rpx auto 0;
  230. width: 543rpx;
  231. height: 100rpx;
  232. color: #fff;
  233. font-size: 32rpx;
  234. border-radius: 8rpx;
  235. background-color: #0061ff;
  236. }
  237. }
  238. }
  239. </style>