login.vue 5.8 KB

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