login.vue 4.9 KB

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