login.vue 6.5 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">&#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. // 初始化 start
  51. // getUrlCode() {
  52. // var url = location.search
  53. // this.winUrl = url
  54. // var theRequest = new Object()
  55. // if (url.indexOf("?") != -1) {
  56. // var str = url.substr(1)
  57. // var strs = str.split("&")
  58. // for (var i = 0; i < strs.length; i++) {
  59. // theRequest[strs[i].split("=")[0]] = (strs[i].split("=")[1])
  60. // }
  61. // }
  62. // return theRequest
  63. // },
  64. async init(){
  65. window.location.href=this.$BASE_URL+"Login/getFirst1"
  66. },
  67. // async init() {
  68. // let ua = navigator.userAgent.toLowerCase();
  69. // if (ua.match(/MicroMessenger/i) == "micromessenger") {
  70. // var curl2 = window.location.href;
  71. // //是
  72. // var appId = "wx4eab2e3b5531d58b";
  73. // var params = {};
  74. // var CODE = this.getUrlCode();
  75. // var code = CODE['code'];
  76. // if (code) {
  77. // params.code = code;
  78. // const res = await this.$myRequest({
  79. // url: 'Login/getLoginAuthorize',
  80. // data: params
  81. // })
  82. // code = '';
  83. // return "ok";
  84. // }
  85. // var cs = {};
  86. // var curl = window.location.href;
  87. // cs.curl = curl;
  88. // const res1 = await this.$myRequest({
  89. // url: 'Login/getLoginAuthorize',
  90. // data: cs
  91. // })
  92. // var turl = res1.data.turl;
  93. // window.location.href =
  94. // 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx4eab2e3b5531d58b&redirect_uri=' + turl +
  95. // '&response_type=code&scope=snsapi_base&state=abc123#wechat_redirect';
  96. // } else {
  97. // const res = await this.$myRequest({
  98. // url: 'Login/getLoginAuthorize',
  99. // data: params
  100. // })
  101. // }
  102. // },
  103. // 初始化 end
  104. //点击获取验证码
  105. getVerifyCode() {
  106. if (!this.phone) {
  107. uni.showToast({
  108. title: "请输入手机号码...",
  109. icon: "none"
  110. });
  111. return
  112. }
  113. if (!/^1[345678]\d{9}$/.test(this.phone)) {
  114. uni.showToast({
  115. title: "请输入正确的手机号码...",
  116. icon: "none"
  117. });
  118. return
  119. }
  120. this.getVerifyData({
  121. "phone": this.phone
  122. })
  123. //
  124. if (this.codeTime > 0) {
  125. uni.showToast({
  126. title: '不能重复获取',
  127. icon: "none"
  128. });
  129. return;
  130. } else {
  131. this.codeTime = 60
  132. let timer = setInterval(() => {
  133. this.codeTime--;
  134. if (this.codeTime < 1) {
  135. clearInterval(timer);
  136. this.codeTime = 0
  137. }
  138. }, 1000)
  139. }
  140. },
  141. //点击提交按钮
  142. submitRes() {
  143. if (!this.phone) {
  144. uni.showToast({
  145. title: "请输入手机号码...",
  146. icon: "none"
  147. });
  148. return
  149. }
  150. if (!/^1[345678]\d{9}$/.test(this.phone)) {
  151. uni.showToast({
  152. title: "请输入正确的手机号码...",
  153. icon: "none"
  154. });
  155. return
  156. }
  157. if (!this.verify) {
  158. uni.showToast({
  159. title: "请输入验证码...",
  160. icon: "none"
  161. });
  162. return
  163. }
  164. this.getData({
  165. "phone": this.phone,
  166. "VerificationCode": this.verify,
  167. // "VerificationCodeOne": this.VerificationCodeOne
  168. })
  169. },
  170. async getVerifyData(params = {}) {
  171. // alert(1)
  172. const res = await this.$myRequest({
  173. url: 'Login/getVerificationCode',
  174. data: params
  175. })
  176. // this.VerificationCodeOne = eval('(' + res.data + ')').data[0].VerificationCode
  177. },
  178. async getData(params = {}) {
  179. const res = await this.$myRequest({
  180. url: 'Login/setSignUp',
  181. data: params
  182. })
  183. if (res.data.flag == true) {
  184. uni.switchTab({
  185. url: '/pages/index/index'
  186. });
  187. } else {
  188. }
  189. },
  190. }
  191. }
  192. </script>
  193. <style>
  194. .section {
  195. height: 400rpx;
  196. background-image: url(/static/login-bg.png);
  197. background-size: cover;
  198. background-repeat: no-repeat;
  199. }
  200. .content {
  201. height: 434rpx;
  202. text-align: center;
  203. position: relative;
  204. }
  205. .login-box {
  206. height: 600rpx;
  207. position: relative;
  208. top: -150rpx;
  209. background: #fff;
  210. border-radius: 30rpx;
  211. padding: 100rpx 20rpx;
  212. }
  213. .shadow {
  214. box-shadow: 0px 2px 4px rgb(26 26 26 / 10%);
  215. }
  216. .title {
  217. position: absolute;
  218. color: #fff;
  219. font-size: 60rpx;
  220. bottom: 180rpx;
  221. display: block;
  222. width: 100%;
  223. }
  224. input,
  225. button {
  226. width: 100%;
  227. height: 100rpx;
  228. line-height: 100rpx;
  229. opacity: 1;
  230. border: 1px solid #dbdbdb;
  231. border-radius: 100rpx;
  232. background: #fff;
  233. coloe: #333;
  234. margin: 40rpx 0;
  235. font-size: 34rpx;
  236. }
  237. input {
  238. text-indent: 100rpx;
  239. }
  240. .submit {
  241. background: #4074E7;
  242. color: #fff
  243. }
  244. .phone-box,
  245. .password-box {
  246. position: relative;
  247. }
  248. .password-box .verify {
  249. font-size: 30rpx;
  250. color: #999999
  251. }
  252. .left-icon {
  253. position: absolute;
  254. left: 48rpx;
  255. top: 50%;
  256. margin-top: -20rpx;
  257. line-height: 100%;
  258. font-size: 40rpx;
  259. color: #7A7A7A
  260. }
  261. .right-icon {
  262. position: absolute;
  263. right: 48rpx;
  264. top: 50%;
  265. margin-top: -20rpx;
  266. line-height: 100%;
  267. font-size: 40rpx;
  268. }
  269. .right-icon.verify {
  270. margin-top: -10rpx;
  271. color: #4074E7
  272. }
  273. .iconfont {
  274. color: #999
  275. }
  276. </style>