login.vue 7.1 KB

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