login.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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.captchaId = this.$common.uuid(8);
  100. _form.captchaImage =
  101. this.$constant.BASE_URI +
  102. "/captcha/captchaImage?type=math&captchaId=" +
  103. _form.captchaId +
  104. "&s=" +
  105. Math.random();
  106. },
  107. forgetPsw() {
  108. wx.showModal({
  109. title: "提示!",
  110. content: "管理端修改密码需要拨打客服电话咨询,是否拨打?",
  111. success: function (res) {
  112. if (res.confirm) {
  113. uni.makePhoneCall({
  114. phoneNumber: "13921516068", //电话号码
  115. success: function (e) {},
  116. fail: function (e) {},
  117. });
  118. }
  119. },
  120. });
  121. },
  122. login() {
  123. const _this = this;
  124. if (!this.loginForm.userName || !this.loginForm.password) {
  125. uni.showModal({
  126. title: "提示",
  127. content: "请输入账号和密码",
  128. icon: "error",
  129. showCancel: false,
  130. });
  131. return;
  132. }
  133. let loginForm = {...this.loginForm}
  134. loginForm.password=hexMD5(loginForm.password)
  135. login(loginForm).then((res) => {
  136. if (res.errmsg == "成功") {
  137. uni.showToast({
  138. title: "登录成功",
  139. icon: "none",
  140. mask: true,
  141. duration: 2000,
  142. });
  143. this.$auth.setUser(res.data.token);
  144. this.$auth.setRequestHanderAuth(res.data.requestHanderAuth);
  145. this.$auth.setUserInfo(res.data);
  146. uni.switchTab({
  147. url: "/pages/index/index",
  148. });
  149. } else {
  150. this.captchaImageRefresh(this.loginForm);
  151. }
  152. });
  153. // this.$auth.setUserType(this.$auth.TYPE_FRAME);
  154. },
  155. onShareAppMessage: function () {},
  156. },
  157. };
  158. </script>
  159. <style lang="scss">
  160. .login {
  161. background: white;
  162. height: 100%;
  163. overflow: hidden;
  164. .logTit {
  165. width: 80vw;
  166. left: 10vw;
  167. top: 60vw;
  168. display: flex;
  169. flex-direction: column;
  170. justify-content: center;
  171. align-items: center;
  172. position: absolute;
  173. z-index: 1;
  174. color: rgba(51, 51, 51, 1);
  175. font-size: 4vw;
  176. p {
  177. color: rgba(102, 102, 102, 1);
  178. font-size: 4vw;
  179. margin-top: 0.5vw;
  180. }
  181. .titletxt {
  182. font-size: 48rpx;
  183. font-family: Taipei Sans TC Beta-Bold, Taipei Sans TC Beta;
  184. font-weight: bold;
  185. color: #333333;
  186. }
  187. .titletxt2 {
  188. font-size: 32rpx;
  189. font-family: PingFang SC-Regular, PingFang SC;
  190. font-weight: 400;
  191. color: #666666;
  192. }
  193. }
  194. .logobig {
  195. width: 100vw;
  196. height: 100vh;
  197. position: absolute;
  198. left: 0;
  199. z-index: 0;
  200. }
  201. .loginBox {
  202. width: 70vw;
  203. left: 15vw;
  204. padding-top: 75vw;
  205. position: absolute;
  206. }
  207. .inputBox {
  208. position: relative;
  209. display: flex;
  210. align-items: center;
  211. img {
  212. position: absolute;
  213. width: 7vw;
  214. // padding-top: 40px;
  215. }
  216. .yanzhengImg {
  217. right: 0;
  218. width: 20vw;
  219. height: 10vw;
  220. }
  221. .yanzhengImgBox {
  222. height: 50px;
  223. display: flex;
  224. align-items: center;
  225. }
  226. input {
  227. background: black;
  228. width: 100%;
  229. height: 76rpx;
  230. padding: 5rpx 0 5rpx 70rpx;
  231. background-color: rgba(255, 255, 255, 1);
  232. border: 1rpx solid rgba(29, 24, 188, 0.05);
  233. margin: 5rpx 0;
  234. font-size: 4vw;
  235. }
  236. input::-webkit-input-placeholder {
  237. color: rgba(153, 153, 153, 1);
  238. }
  239. .yanzhengma {
  240. width: 60%;
  241. }
  242. }
  243. .pswBox {
  244. width: 100%;
  245. display: flex;
  246. justify-content: flex-end;
  247. margin: 20px 0;
  248. color: rgba(29, 24, 188, 1);
  249. }
  250. .van-button {
  251. border-radius: 8rpx 8rpx 8rpx 8rpx;
  252. margin-top: 50px;
  253. }
  254. .bottomTips {
  255. width: 100vw;
  256. position: fixed;
  257. bottom: 15px;
  258. text-align: center;
  259. color: #999999;
  260. font-size: 2vw;
  261. }
  262. @media screen and (max-height: 454px) {
  263. .bottomTips {
  264. display: none;
  265. }
  266. }
  267. }
  268. </style>