login.vue 5.0 KB

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