login.vue 6.3 KB

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