login.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. <template>
  2. <div class="login">
  3. <img
  4. src="https://www.idea-co-sf.com/gardenProduct/image/logobig.png"
  5. alt=""
  6. class="logobig"
  7. />
  8. <div class="logTit">
  9. <span class="titletxt">园区管理平台产品化</span>
  10. <p class="titletxt2">(管理端)</p>
  11. </div>
  12. <div class="logintype" v-if="loginStatus">
  13. <div
  14. @click="changeLoginType('个人')"
  15. :class="loginType == '个人' ? 'checkbox ischecked' : 'checkbox'"
  16. >
  17. 个人
  18. </div>
  19. <div
  20. @click="changeLoginType('管理')"
  21. :class="loginType == '管理' ? 'checkbox ischecked' : 'checkbox'"
  22. >
  23. 管理
  24. </div>
  25. </div>
  26. <div class="loginBox" v-if="loginType == '个人'">
  27. <div class="inputBox">
  28. <img
  29. src="https://www.idea-co-sf.com/gardenProduct/image/comicon.png"
  30. alt=""
  31. style="height: 60rpx"
  32. />
  33. <input
  34. type="text"
  35. placeholder="请输入账号"
  36. v-model="loginForm.userName"
  37. />
  38. </div>
  39. <div class="inputBox">
  40. <img
  41. src="https://www.idea-co-sf.com/gardenProduct/image/pswicon.svg"
  42. alt=""
  43. />
  44. <input
  45. type="password"
  46. placeholder="请输入密码"
  47. v-model="loginForm.password"
  48. />
  49. </div>
  50. <div class="inputBox">
  51. <img
  52. src="https://www.idea-co-sf.com/gardenProduct/image/yzmicon.svg"
  53. alt=""
  54. />
  55. <input
  56. type="text"
  57. placeholder="验证码"
  58. class="yanzhengma"
  59. v-model="loginForm.code"
  60. />
  61. <img
  62. :src="loginForm.captchaImage"
  63. @click="captchaImageRefresh(loginForm)"
  64. class="yanzhengImg"
  65. />
  66. </div>
  67. <div class="pswBox" @click="forgetPsw()">
  68. <p>忘记密码?</p>
  69. </div>
  70. <div>
  71. <van-button
  72. type="default"
  73. class="loginbtn"
  74. size="large"
  75. color="#1f1fbe"
  76. @click="UserLogin"
  77. >登 录</van-button
  78. >
  79. </div>
  80. <!-- <div style="display: flex; justify-content: space-between">
  81. <van-button
  82. style="margin-top: 15rpx; width: 49%"
  83. type="default"
  84. size="large"
  85. color="#1f1fbe"
  86. @click="gozhfw"
  87. >前往智慧法务</van-button
  88. >
  89. <van-button
  90. style="margin-top: 15rpx; width: 49%"
  91. type="default"
  92. size="large"
  93. color="#1f1fbe"
  94. @click="goqy"
  95. >前往企业端</van-button
  96. >
  97. </div> -->
  98. </div>
  99. <div class="loginBox" v-if="loginType == '管理'">
  100. <div class="inputBox">
  101. <img
  102. src="https://www.idea-co-sf.com/gardenProduct/image/comicon.png"
  103. alt=""
  104. style="height: 60rpx"
  105. />
  106. <input
  107. type="text"
  108. placeholder="请输入账号"
  109. v-model="loginForm.userName"
  110. />
  111. </div>
  112. <div class="inputBox">
  113. <img
  114. src="https://www.idea-co-sf.com/gardenProduct/image/pswicon.svg"
  115. alt=""
  116. />
  117. <input
  118. type="password"
  119. placeholder="请输入密码"
  120. v-model="loginForm.password"
  121. />
  122. </div>
  123. <div class="inputBox">
  124. <img
  125. src="https://www.idea-co-sf.com/gardenProduct/image/yzmicon.svg"
  126. alt=""
  127. />
  128. <input
  129. type="text"
  130. placeholder="验证码"
  131. class="yanzhengma"
  132. v-model="loginForm.code"
  133. />
  134. <img
  135. :src="loginForm.captchaImage"
  136. @click="captchaImageRefresh(loginForm)"
  137. class="yanzhengImg"
  138. />
  139. </div>
  140. <div class="pswBox" @click="forgetPsw()">
  141. <p>忘记密码?</p>
  142. </div>
  143. <div>
  144. <van-button
  145. type="default"
  146. class="loginbtn"
  147. size="large"
  148. color="#1f1fbe"
  149. @click="login"
  150. >登 录</van-button
  151. >
  152. </div>
  153. <!-- <div style="display: flex; justify-content: space-between">
  154. <van-button
  155. style="margin-top: 15rpx; width: 49%"
  156. type="default"
  157. size="large"
  158. color="#1f1fbe"
  159. @click="gozhfw"
  160. >前往智慧法务</van-button
  161. >
  162. <van-button
  163. style="margin-top: 15rpx; width: 49%"
  164. type="default"
  165. size="large"
  166. color="#1f1fbe"
  167. @click="goqy"
  168. >前往企业端</van-button
  169. >
  170. </div> -->
  171. </div>
  172. <div class="bottomTips">
  173. 2022@copyrigtht IOT - Park-tech. supported by 中国移动
  174. </div>
  175. <van-dialog id="van-toast" />
  176. </div>
  177. </template>
  178. <script>
  179. import Dialog from "../..//wxcomponents/weapp/dist/dialog/dialog.js";
  180. import { login, loginByCompany } from "@/js_sdk/http.js";
  181. export default {
  182. data() {
  183. return {
  184. loginStatus: true,
  185. loginType: "个人",
  186. loginForm: {
  187. userName: "",
  188. password: "",
  189. code: "",
  190. type: "FRAME",
  191. captchaId: "",
  192. captchaImage: "",
  193. rememberMe: true,
  194. },
  195. };
  196. },
  197. mounted() {
  198. // login()
  199. this.captchaImageRefresh(this.loginForm);
  200. },
  201. methods: {
  202. changeLoginType(e) {
  203. console.log(this.loginType);
  204. this.loginStatus = false;
  205. this.loginType = e;
  206. this.loginStatus = true;
  207. },
  208. getPhoneNumber(e) {
  209. wx.login({
  210. success(res) {
  211. console.log(res);
  212. let data = {
  213. loginCode: res.code,
  214. phoneCode: e.detail.code,
  215. };
  216. loginByWeixin2(data).then((e) => {
  217. console.log(e.data.user);
  218. wx.setStorageSync("USERINFO", JSON.stringify(e.data.user));
  219. uni.switchTab({
  220. url: "/pages/index/index",
  221. });
  222. });
  223. },
  224. });
  225. },
  226. goqy() {
  227. uni.navigateTo({
  228. url: "/pages/subPackages/gocompnay/index",
  229. });
  230. },
  231. gozhfw() {
  232. wx.navigateToMiniProgram({
  233. appId: "wx15404cced62d7b37",
  234. success(res) {
  235. // 打开成功
  236. },
  237. fail(e) {
  238. console.log(e);
  239. },
  240. });
  241. },
  242. captchaImageRefresh: function (_form) {
  243. _form.captchaId = this.$common.uuid(8);
  244. _form.captchaImage =
  245. this.$constant.BASE_URI +
  246. "/captcha/captchaImage?type=math&captchaId=" +
  247. _form.captchaId +
  248. "&s=" +
  249. Math.random();
  250. },
  251. forgetPsw() {
  252. wx.showModal({
  253. title: "提示!",
  254. content: "管理端修改密码需要拨打客服电话咨询,是否拨打?",
  255. success: function (res) {
  256. if (res.confirm) {
  257. uni.makePhoneCall({
  258. phoneNumber: "", //电话号码
  259. success: function (e) {},
  260. fail: function (e) {},
  261. });
  262. }
  263. },
  264. });
  265. },
  266. UserLogin() {
  267. const _this = this;
  268. if (!this.loginForm.userName || !this.loginForm.password) {
  269. uni.showModal({
  270. title: "提示",
  271. content: "请输入账号和密码",
  272. icon: "error",
  273. showCancel: false,
  274. });
  275. return;
  276. }
  277. wx.login({
  278. success(e) {
  279. console.log(e);
  280. _this.loginForm.loginCode = e.code;
  281. loginByCompany(_this.loginForm).then((res) => {
  282. if (res.msg == "正常") {
  283. uni.showToast({
  284. title: "登录成功",
  285. icon: "none",
  286. mask: true,
  287. duration: 2000,
  288. });
  289. wx.setStorageSync("USERINFO", JSON.stringify(res.user_));
  290. uni.switchTab({
  291. url: "/pages/index/index",
  292. });
  293. } else {
  294. _this.captchaImageRefresh(_this.loginForm);
  295. }
  296. });
  297. },
  298. });
  299. // this.$auth.setUserType(this.$auth.TYPE_FRAME);
  300. },
  301. login() {
  302. const _this = this;
  303. if (!this.loginForm.userName || !this.loginForm.password) {
  304. uni.showModal({
  305. title: "提示",
  306. content: "请输入账号和密码",
  307. icon: "error",
  308. showCancel: false,
  309. });
  310. return;
  311. }
  312. wx.login({
  313. success(e) {
  314. console.log(e);
  315. _this.loginForm.loginCode = e.code;
  316. login(_this.loginForm).then((res) => {
  317. console.log(res);
  318. if (res.errmsg == "成功") {
  319. uni.showToast({
  320. title: "登录成功",
  321. icon: "none",
  322. mask: true,
  323. duration: 2000,
  324. });
  325. console.log(res.data.user);
  326. wx.setStorageSync("USERINFO", JSON.stringify(res.data.user));
  327. uni.switchTab({
  328. url: "/pages/index/index",
  329. });
  330. } else {
  331. _this.captchaImageRefresh(_this.loginForm);
  332. }
  333. });
  334. },
  335. });
  336. // this.$auth.setUserType(this.$auth.TYPE_FRAME);
  337. },
  338. onShareAppMessage: function () {},
  339. },
  340. };
  341. </script>
  342. <style lang="scss">
  343. .login {
  344. background: white;
  345. height: 100%;
  346. overflow: hidden;
  347. .logintype {
  348. width: 100%;
  349. display: flex;
  350. position: absolute;
  351. top: 76vw;
  352. justify-content: center;
  353. .checkbox {
  354. padding: 15rpx 20rpx;
  355. border: 1px solid #1f1fbe;
  356. border-radius: 0.2rem;
  357. color: #1f1fbe;
  358. width: 28.5%;
  359. text-align: center;
  360. }
  361. .ischecked {
  362. background: #1f1fbe;
  363. color: white;
  364. }
  365. }
  366. .logTit {
  367. width: 80vw;
  368. left: 10vw;
  369. top: 60vw;
  370. display: flex;
  371. flex-direction: column;
  372. justify-content: center;
  373. align-items: center;
  374. position: absolute;
  375. z-index: 1;
  376. color: rgba(51, 51, 51, 1);
  377. font-size: 4vw;
  378. p {
  379. color: rgba(102, 102, 102, 1);
  380. font-size: 4vw;
  381. margin-top: 0.5vw;
  382. }
  383. .titletxt {
  384. font-size: 48rpx;
  385. font-family: Taipei Sans TC Beta-Bold, Taipei Sans TC Beta;
  386. font-weight: bold;
  387. color: #333333;
  388. }
  389. .titletxt2 {
  390. font-size: 32rpx;
  391. font-family: PingFang SC-Regular, PingFang SC;
  392. font-weight: 400;
  393. color: #666666;
  394. }
  395. }
  396. .logobig {
  397. width: 100vw;
  398. height: 100vh;
  399. position: absolute;
  400. left: 0;
  401. z-index: 0;
  402. }
  403. .loginBox {
  404. width: 70vw;
  405. left: 15vw;
  406. top: 85vw;
  407. position: absolute;
  408. }
  409. .inputBox {
  410. position: relative;
  411. display: flex;
  412. align-items: center;
  413. img {
  414. position: absolute;
  415. width: 7vw;
  416. // padding-top: 40px;
  417. }
  418. .yanzhengImg {
  419. right: 0;
  420. width: 20vw;
  421. height: 10vw;
  422. }
  423. .yanzhengImgBox {
  424. height: 50px;
  425. display: flex;
  426. align-items: center;
  427. }
  428. input {
  429. background: black;
  430. width: 100%;
  431. height: 76rpx;
  432. padding: 5rpx 0 5rpx 70rpx;
  433. background-color: rgba(255, 255, 255, 1);
  434. border: 1rpx solid rgba(29, 24, 188, 0.05);
  435. margin: 5rpx 0;
  436. font-size: 4vw;
  437. }
  438. input::-webkit-input-placeholder {
  439. color: rgba(153, 153, 153, 1);
  440. }
  441. .yanzhengma {
  442. width: 60%;
  443. }
  444. }
  445. .pswBox {
  446. width: 100%;
  447. display: flex;
  448. justify-content: flex-end;
  449. margin: 20px 0;
  450. color: rgba(29, 24, 188, 1);
  451. }
  452. .van-button {
  453. margin-top: 15rpx;
  454. border-radius: 60px;
  455. }
  456. .loginbtn {
  457. margin-top: 50rpx;
  458. }
  459. .bottomTips {
  460. width: 100vw;
  461. position: fixed;
  462. bottom: 15px;
  463. text-align: center;
  464. color: #999999;
  465. font-size: 2vw;
  466. }
  467. @media screen and (max-height: 454px) {
  468. .bottomTips {
  469. display: none;
  470. }
  471. }
  472. }
  473. </style>