login.vue 5.1 KB

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