login.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <view class="section">
  3. <!-- <view class="bg"><image src="static/login-bg.png.png" style="width:64rpx;height:64rpx"></image></view> -->
  4. <view class="text-area content">
  5. <text class="title">智慧消防</text>
  6. </view>
  7. <form class="padding-lg flex flex-direction">
  8. <view class="login-box shadow ">
  9. <view class="phone-box">
  10. <input type="text" placeholder="请输入手机号码" onfocus="this.placeholder=''" v-model="phone">
  11. <span class="icon iconfont left-icon">&#xe64f;</span>
  12. <span class="icon iconfont right-icon">&#xe610;</span>
  13. </view>
  14. <view class="password-box">
  15. <input type="text" placeholder="请输入验证码" v-model="verify">
  16. <text class="icon iconfont left-icon">&#xe86a;</text>
  17. <view @click="getVerifyCode">
  18. <text class="right-icon verify">{{!codeTime?'获取验证码':codeTime+'s'}}</text>
  19. </view>
  20. </view>
  21. <view class="btn-area">
  22. <button class="submit" @click="submitRes">提 交 </button>
  23. </view>
  24. </view>
  25. </form>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. codeTime: 0,
  33. phone: '',
  34. verify: '',
  35. // VerificationCodeOne: ''
  36. }
  37. },
  38. onLoad(option) {
  39. // if(option.flag){
  40. // }else{
  41. // //this.init()
  42. // }
  43. uni.setNavigationBarColor({
  44. frontColor: "#ffffff", //文字颜色
  45. backgroundColor: "#4866DF", //底部背景色
  46. })
  47. },
  48. methods: {
  49. // async init(){
  50. // window.location.href=this.$BASE_URL+"Login/getFirst1"
  51. // },
  52. //点击获取验证码
  53. getVerifyCode() {
  54. if (!this.phone) {
  55. uni.showToast({
  56. title: "请输入手机号码...",
  57. icon: "none"
  58. });
  59. return
  60. }
  61. if (!/^1(?:3\d|4[4-9]|5[0-35-9]|6[67]|7[013-8]|8\d|9\d)\d{8}$/.test(this.phone)) {
  62. uni.showToast({
  63. title: "请输入正确的手机号码...",
  64. icon: "none"
  65. });
  66. return
  67. }
  68. this.getVerifyData({
  69. "phone": this.phone
  70. })
  71. //
  72. if (this.codeTime > 0) {
  73. uni.showToast({
  74. title: '不能重复获取',
  75. icon: "none"
  76. });
  77. return;
  78. } else {
  79. this.codeTime = 60
  80. let timer = setInterval(() => {
  81. this.codeTime--;
  82. if (this.codeTime < 1) {
  83. clearInterval(timer);
  84. this.codeTime = 0
  85. }
  86. }, 1000)
  87. }
  88. },
  89. //点击提交按钮
  90. submitRes() {
  91. if (!this.phone) {
  92. uni.showToast({
  93. title: "请输入手机号码...",
  94. icon: "none"
  95. });
  96. return
  97. }
  98. if (!/^1(?:3\d|4[4-9]|5[0-35-9]|6[67]|7[013-8]|8\d|9\d)\d{8}$/.test(this.phone)) {
  99. uni.showToast({
  100. title: "请输入正确的手机号码...",
  101. icon: "none"
  102. });
  103. return
  104. }
  105. if (!this.verify) {
  106. uni.showToast({
  107. title: "请输入验证码...",
  108. icon: "none"
  109. });
  110. return
  111. }
  112. this.getData({
  113. "phone": this.phone,
  114. "VerificationCode": this.verify,
  115. // "VerificationCodeOne": this.VerificationCodeOne
  116. })
  117. },
  118. async getVerifyData(params = {}) {
  119. // alert(1)
  120. const res = await this.$myRequest2({
  121. url: 'Login/getVerificationCode',
  122. data: params
  123. })
  124. // this.VerificationCodeOne = eval('(' + res.data + ')').data[0].VerificationCode
  125. },
  126. async getData(params = {}) {
  127. const res = await this.$myRequest2({
  128. url: 'Login/setSignUp',
  129. data: params
  130. })
  131. uni.setStorageSync("token", res.data.data);
  132. if (res.data.flag == true) {
  133. uni.reLaunch({
  134. url: '/pages/index/index'
  135. });
  136. } else {
  137. }
  138. },
  139. }
  140. }
  141. </script>
  142. <style>
  143. .section {
  144. height: 400rpx;
  145. background-image: url(../../static/login-bg.png);
  146. background-size: cover;
  147. background-repeat: no-repeat;
  148. }
  149. .bg{
  150. width:100%;
  151. height:400rpx;
  152. position: absolute;
  153. z-index: 0;
  154. }
  155. .content {
  156. height: 434rpx;
  157. text-align: center;
  158. position: relative;
  159. }
  160. .login-box {
  161. height: 600rpx;
  162. position: relative;
  163. top: -150rpx;
  164. background: #fff;
  165. border-radius: 30rpx;
  166. padding: 100rpx 20rpx;
  167. }
  168. .shadow {
  169. box-shadow: 0px 2px 4px rgb(26 26 26 / 10%);
  170. }
  171. .title {
  172. position: absolute;
  173. color: #fff;
  174. font-size: 60rpx;
  175. bottom: 180rpx;
  176. display: block;
  177. width: 100%;
  178. }
  179. input,
  180. button {
  181. width: 100%;
  182. height: 100rpx;
  183. line-height: 100rpx;
  184. opacity: 1;
  185. border: 1px solid #dbdbdb;
  186. border-radius: 100rpx;
  187. background: #fff;
  188. coloe: #333;
  189. margin: 40rpx 0;
  190. font-size: 34rpx;
  191. }
  192. input {
  193. text-indent: 100rpx;
  194. }
  195. .submit {
  196. background: #4074E7;
  197. color: #fff
  198. }
  199. .phone-box,
  200. .password-box {
  201. position: relative;
  202. }
  203. .password-box .verify {
  204. font-size: 30rpx;
  205. color: #999999
  206. }
  207. .left-icon {
  208. position: absolute;
  209. left: 48rpx;
  210. top: 50%;
  211. margin-top: -20rpx;
  212. line-height: 100%;
  213. font-size: 40rpx;
  214. color: #7A7A7A
  215. }
  216. .right-icon {
  217. position: absolute;
  218. right: 48rpx;
  219. top: 50%;
  220. margin-top: -20rpx;
  221. line-height: 100%;
  222. font-size: 40rpx;
  223. }
  224. .right-icon.verify {
  225. margin-top: -10rpx;
  226. color: #4074E7
  227. }
  228. .iconfont {
  229. color: #999
  230. }
  231. </style>