login.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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 class="right-icon verify" @click="getVerifyCode">获取验证码</view>
  17. </view>
  18. <view class="btn-area">
  19. <button class="submit" @click="submitRes">提 交 </button>
  20. </view>
  21. </view>
  22. </form>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. phone:'',
  30. verify:'',
  31. VerificationCodeOne:''
  32. }
  33. },
  34. onLoad() {
  35. uni.setNavigationBarColor({
  36. frontColor: "#ffffff", //文字颜色
  37. backgroundColor: "#4866DF", //底部背景色
  38. })
  39. uni.setNavigationBarTitle({
  40. title: '登录'
  41. });
  42. this.getLoginAuthorize()
  43. },
  44. methods: {
  45. //短信验证码验证
  46. getVerifyCode(){
  47. if(!this.phone){
  48. uni.showToast({
  49. title: "请输入手机号码...",
  50. icon:"none"
  51. });
  52. }else if (!/^1[345678]\d{9}$/.test(this.phone)){
  53. uni.showToast({
  54. title: "请输入正确的手机号码...",
  55. icon:"none"
  56. });
  57. }else{
  58. this.getVerifyData({"phone":this.phone})
  59. }
  60. },
  61. async getVerifyData(ming = {}) {
  62. const res = await this.$myRequest({
  63. url: 'Login/getVerificationCode',
  64. data:ming
  65. })
  66. console.log('res.data')
  67. console.log(res.data)
  68. console.log(eval('(' + res.data + ')'))
  69. // this.VerificationCodeOne=eval('(' + res.data + ')').data[0].VerificationCode
  70. },
  71. // 登录提交按钮
  72. submitRes(){
  73. if(!this.phone){
  74. uni.showToast({
  75. title: "请输入手机号码...",
  76. icon:"none"
  77. });
  78. return
  79. }
  80. if (!/^1[345678]\d{9}$/.test(this.phone)){
  81. uni.showToast({
  82. title: "请输入正确的手机号码...",
  83. icon:"none"
  84. });
  85. return
  86. }
  87. if (!this.verify){
  88. uni.showToast({
  89. title: "请输入验证码...",
  90. icon:"none"
  91. });
  92. return
  93. }
  94. this.getData({"phone":this.phone,"VerificationCode":this.verify,"VerificationCodeOne":this.VerificationCodeOne})
  95. },
  96. async getData(ming = {}) {
  97. const res = await this.$myRequest({
  98. url: 'Login/setSignUp',
  99. data:ming
  100. })
  101. console.log(res)
  102. console.log(res.data.flag)
  103. if(res.data.flag==true){
  104. alert(1)
  105. uni.switchTab({
  106. url: '/pages/index/index'
  107. });
  108. }
  109. },
  110. //登录页初始化
  111. async getLoginAuthorize() {
  112. const res = await this.$myRequest({
  113. url: 'Login/getLoginAuthorize',
  114. })
  115. // console.log('res')
  116. // console.log(res)
  117. },
  118. }
  119. }
  120. </script>
  121. <style>
  122. .section {
  123. height: 400rpx;
  124. background-image: url(/static/login-bg.png);
  125. background-size: cover;
  126. background-repeat: no-repeat;
  127. }
  128. .content {
  129. height: 434rpx;
  130. text-align: center;
  131. position: relative;
  132. }
  133. .login-box {
  134. height: 600rpx;
  135. position: relative;
  136. top: -150rpx;
  137. background: #fff;
  138. border-radius: 30rpx;
  139. padding: 100rpx 20rpx;
  140. }
  141. .shadow {
  142. box-shadow: 1px 1px 4px rgb(26 26 26 / 10%);
  143. }
  144. .title {
  145. position: absolute;
  146. color: #fff;
  147. font-size: 60rpx;
  148. bottom: 180rpx;
  149. display: block;
  150. width: 100%;
  151. }
  152. input,
  153. button {
  154. width: 100%;
  155. height: 100rpx;
  156. line-height: 100rpx;
  157. opacity: 1;
  158. border: 1px solid #dbdbdb;
  159. border-radius: 100rpx;
  160. background: #fff;
  161. coloe: #333;
  162. margin: 40rpx 0;
  163. font-size: 34rpx;
  164. }
  165. input {
  166. text-indent: 100rpx;
  167. }
  168. .submit {
  169. background: #4074E7;
  170. color: #fff
  171. }
  172. .phone-box,
  173. .password-box {
  174. position: relative;
  175. }
  176. .phone-box text,
  177. .password-box text {
  178. font-size: 38rpx;
  179. color: #999999
  180. }
  181. .left-icon {
  182. position: absolute;
  183. left: 48rpx;
  184. top: 50%;
  185. margin-top: -20rpx;
  186. line-height: 100%
  187. }
  188. .right-icon {
  189. position: absolute;
  190. right: 48rpx;
  191. top: 50%;
  192. margin-top: -20rpx;
  193. line-height: 100%
  194. }
  195. .right-icon.verify {
  196. margin-top: -10rpx;
  197. color: #4074E7
  198. }
  199. .iconfont {
  200. color: #999
  201. }
  202. /* 底部 */
  203. .box {
  204. display: none;
  205. position: fixed;
  206. bottom: 0;
  207. width: 100%;
  208. border-top: 1px solid pink
  209. }
  210. .cuIcon-cu-image .iconfont {
  211. width: 38rpx;
  212. height: 38rpx;
  213. display: inline-block;
  214. margin-bottom: 10rpx;
  215. }
  216. .text-gray {
  217. font-size: 26rpx;
  218. }
  219. </style>