login.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <div class="login">
  3. <img src="../../common/assets/image/logobig.png" alt="" class="logobig" />
  4. <div class="logTit">
  5. <span class="titletxt">智慧红沙湾园区管理</span>
  6. <p class="titletxt2">(管理端)</p>
  7. </div>
  8. <div class="loginBox">
  9. <div class="inputBox">
  10. <img
  11. src="../../common/assets/image/comicon.png"
  12. alt=""
  13. style="height: 60rpx"
  14. />
  15. <input
  16. type="text"
  17. placeholder="请输入账号"
  18. v-model="loginForm.userName"
  19. />
  20. </div>
  21. <div class="inputBox">
  22. <img src="../../common/assets/image/pswicon.svg" alt="" />
  23. <input
  24. type="password"
  25. placeholder="请输入密码"
  26. v-model="loginForm.password"
  27. />
  28. </div>
  29. <div class="inputBox">
  30. <img src="../../common/assets/image/yzmicon.svg" alt="" />
  31. <input
  32. type="text"
  33. placeholder="验证码"
  34. class="yanzhengma"
  35. v-model="loginForm.code"
  36. />
  37. <img
  38. :src="loginForm.captchaImage"
  39. @click="captchaImageRefresh(loginForm)"
  40. class="yanzhengImg"
  41. />
  42. </div>
  43. <div class="pswBox" @click="forgetPsw()">
  44. <p>忘记密码?</p>
  45. </div>
  46. <div>
  47. <van-button
  48. type="default"
  49. class="loginbtn"
  50. size="large"
  51. color="#1f1fbe"
  52. @click="login"
  53. >登 录</van-button
  54. >
  55. <van-button
  56. type="default"
  57. class="loginbtn"
  58. size="large"
  59. color="#1f1fbe"
  60. @click="wxlogin"
  61. >微信账号一键登录</van-button
  62. >
  63. <van-button type="default" size="large" color="#1f1fbe" @click="goqy"
  64. >前往企业端</van-button
  65. >
  66. <div
  67. @click="gozhfw"
  68. style="text-align: center; margin-top: 15rpx; color: #1f1fbe"
  69. >
  70. 前往智慧法务
  71. </div>
  72. </div>
  73. <div style="display: flex; justify-content: space-between">
  74. <!-- <van-button
  75. style="margin-top: 15rpx; width: 49%"
  76. type="default"
  77. size="large"
  78. color="#1f1fbe"
  79. @click="gozhfw"
  80. >前往智慧法务</van-button
  81. > -->
  82. </div>
  83. </div>
  84. <div class="bottomTips">
  85. 2022@copyrigtht IOT - Park-tech. supported by 中国移动
  86. </div>
  87. <van-dialog id="van-toast" />
  88. </div>
  89. </template>
  90. <script>
  91. import Dialog from "../..//wxcomponents/weapp/dist/dialog/dialog.js";
  92. import { login } from "@/js_sdk/http.js";
  93. export default {
  94. data() {
  95. return {
  96. loginForm: {
  97. userName: "",
  98. password: "",
  99. code: "",
  100. type: "FRAME",
  101. captchaId: "",
  102. captchaImage: "",
  103. rememberMe: true,
  104. },
  105. };
  106. },
  107. mounted() {
  108. // login()
  109. this.captchaImageRefresh(this.loginForm);
  110. },
  111. methods: {
  112. async wxlogin() {
  113. let _this = this;
  114. wx.login({
  115. success: async function (res) {
  116. let data = await login({ openCode: res.code });
  117. console.log(data);
  118. _this.$auth.setUser(data.data.token);
  119. _this.$auth.setUserInfo(data.data);
  120. uni.switchTab({
  121. url: "/pages/index/index",
  122. });
  123. },
  124. });
  125. },
  126. goqy() {
  127. uni.navigateTo({
  128. url: "/pages/gocompnay/index",
  129. });
  130. },
  131. gozhfw() {
  132. wx.navigateToMiniProgram({
  133. appId: "wx9919d022c184462b",
  134. success(res) {
  135. // 打开成功
  136. },
  137. fail(e) {
  138. console.log(e);
  139. },
  140. });
  141. },
  142. captchaImageRefresh: function (_form) {
  143. _form.captchaId = this.$common.uuid(8);
  144. _form.captchaImage =
  145. this.$constant.BASE_URI +
  146. "/captcha/captchaImage?type=math&captchaId=" +
  147. _form.captchaId +
  148. "&s=" +
  149. Math.random();
  150. },
  151. forgetPsw() {
  152. wx.showModal({
  153. title: "提示!",
  154. content: "管理端修改密码需要拨打客服电话15061150110咨询,是否拨打?",
  155. success: function (res) {
  156. if (res.confirm) {
  157. uni.makePhoneCall({
  158. phoneNumber: "15061150110", //电话号码
  159. success: function (e) {},
  160. fail: function (e) {},
  161. });
  162. }
  163. },
  164. });
  165. },
  166. login() {
  167. const _this = this;
  168. if (!this.loginForm.userName || !this.loginForm.password) {
  169. uni.showModal({
  170. title: "提示",
  171. content: "请输入账号和密码",
  172. icon: "error",
  173. showCancel: false,
  174. });
  175. return;
  176. }
  177. login(this.loginForm).then((res) => {
  178. if (res.errmsg == "成功") {
  179. uni.showToast({
  180. title: "登录成功",
  181. icon: "none",
  182. mask: true,
  183. duration: 2000,
  184. });
  185. this.$auth.setUser(res.data.token);
  186. this.$auth.setUserInfo(res.data);
  187. uni.switchTab({
  188. url: "/pages/index/index",
  189. });
  190. } else {
  191. this.captchaImageRefresh(this.loginForm);
  192. }
  193. });
  194. // this.$auth.setUserType(this.$auth.TYPE_FRAME);
  195. },
  196. onShareAppMessage: function () {},
  197. },
  198. };
  199. </script>
  200. <style lang="scss">
  201. .login {
  202. background: white;
  203. height: 100%;
  204. overflow: hidden;
  205. .logTit {
  206. width: 80vw;
  207. left: 10vw;
  208. top: 45vw;
  209. display: flex;
  210. flex-direction: column;
  211. justify-content: center;
  212. align-items: center;
  213. position: absolute;
  214. z-index: 1;
  215. color: rgba(51, 51, 51, 1);
  216. font-size: 4vw;
  217. p {
  218. color: rgba(102, 102, 102, 1);
  219. font-size: 4vw;
  220. margin-top: 0.5vw;
  221. }
  222. .titletxt {
  223. font-size: 48rpx;
  224. font-family: Taipei Sans TC Beta-Bold, Taipei Sans TC Beta;
  225. font-weight: bold;
  226. color: #333333;
  227. }
  228. .titletxt2 {
  229. font-size: 32rpx;
  230. font-family: PingFang SC-Regular, PingFang SC;
  231. font-weight: 400;
  232. color: #666666;
  233. }
  234. }
  235. .logobig {
  236. width: 100vw;
  237. height: 100vh;
  238. position: absolute;
  239. left: 0;
  240. z-index: 0;
  241. }
  242. .loginBox {
  243. width: 70vw;
  244. left: 15vw;
  245. padding-top: 60vw;
  246. position: absolute;
  247. }
  248. .inputBox {
  249. position: relative;
  250. display: flex;
  251. align-items: center;
  252. img {
  253. position: absolute;
  254. width: 7vw;
  255. // padding-top: 40px;
  256. }
  257. .yanzhengImg {
  258. right: 0;
  259. width: 20vw;
  260. height: 10vw;
  261. }
  262. .yanzhengImgBox {
  263. height: 50px;
  264. display: flex;
  265. align-items: center;
  266. }
  267. input {
  268. background: black;
  269. width: 100%;
  270. height: 76rpx;
  271. padding: 5rpx 0 5rpx 70rpx;
  272. background-color: rgba(255, 255, 255, 1);
  273. border: 1rpx solid rgba(29, 24, 188, 0.05);
  274. margin: 5rpx 0;
  275. font-size: 4vw;
  276. }
  277. input::-webkit-input-placeholder {
  278. color: rgba(153, 153, 153, 1);
  279. }
  280. .yanzhengma {
  281. width: 60%;
  282. }
  283. }
  284. .pswBox {
  285. width: 100%;
  286. display: flex;
  287. justify-content: flex-end;
  288. margin: 20px 0;
  289. color: rgba(29, 24, 188, 1);
  290. }
  291. .van-button {
  292. margin-top: 15rpx;
  293. border-radius: 60px;
  294. }
  295. .loginbtn {
  296. margin-top: 50rpx;
  297. }
  298. .bottomTips {
  299. width: 100vw;
  300. position: fixed;
  301. bottom: 15px;
  302. text-align: center;
  303. color: #999999;
  304. font-size: 2vw;
  305. }
  306. @media screen and (max-height: 454px) {
  307. .bottomTips {
  308. display: none;
  309. }
  310. }
  311. }
  312. </style>