login.vue 11 KB

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