login.vue 6.5 KB

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