login.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <div class="login">
  3. <img
  4. src="https://www.idea-co-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-co-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-co-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-co-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. methods: {
  126. changeLoginType(e) {
  127. console.log(this.loginType);
  128. this.loginStatus = false;
  129. this.loginType = e;
  130. this.loginStatus = true;
  131. },
  132. getPhoneNumber(e) {
  133. wx.login({
  134. success(res) {
  135. console.log(res);
  136. let data = {
  137. loginCode: res.code,
  138. phoneCode: e.detail.code,
  139. };
  140. loginByWeixin2(data).then((e) => {
  141. console.log(e.data.user);
  142. wx.setStorageSync("USERINFO", JSON.stringify(e.data.user));
  143. uni.switchTab({
  144. url: "/pages/index/index",
  145. });
  146. });
  147. },
  148. });
  149. },
  150. goqy() {
  151. uni.navigateTo({
  152. url: "/pages/subPackages/gocompnay/index",
  153. });
  154. },
  155. gozhfw() {
  156. wx.navigateToMiniProgram({
  157. appId: "wx15404cced62d7b37",
  158. success(res) {
  159. // 打开成功
  160. },
  161. fail(e) {
  162. console.log(e);
  163. },
  164. });
  165. },
  166. captchaImageRefresh: function (_form) {
  167. _form.captchaId = this.$common.uuid(8);
  168. _form.captchaImage =
  169. this.$constant.BASE_URI +
  170. "/captcha/captchaImage?type=math&captchaId=" +
  171. _form.captchaId +
  172. "&s=" +
  173. Math.random();
  174. },
  175. forgetPsw() {
  176. wx.showModal({
  177. title: "提示!",
  178. content: "管理端修改密码需要拨打客服电话咨询,是否拨打?",
  179. success: function (res) {
  180. if (res.confirm) {
  181. uni.makePhoneCall({
  182. phoneNumber: "", //电话号码
  183. success: function (e) {},
  184. fail: function (e) {},
  185. });
  186. }
  187. },
  188. });
  189. },
  190. loginClick(){
  191. if(this.loginType==='企业用户'){
  192. this.UserLogin()
  193. }else{
  194. this.login()
  195. }
  196. },
  197. UserLogin() {
  198. const _this = this;
  199. if (!this.loginForm.userName || !this.loginForm.password) {
  200. uni.showModal({
  201. title: "提示",
  202. content: "请输入账号和密码",
  203. icon: "error",
  204. showCancel: false,
  205. });
  206. return;
  207. }
  208. wx.login({
  209. success(e) {
  210. console.log(e);
  211. _this.loginForm.loginCode = e.code;
  212. loginByCompany(_this.loginForm).then((res) => {
  213. if (res.msg == "正常") {
  214. uni.showToast({
  215. title: "登录成功",
  216. icon: "none",
  217. mask: true,
  218. duration: 2000,
  219. });
  220. wx.setStorageSync("USERINFO", JSON.stringify(res.user_));
  221. uni.switchTab({
  222. url: "/pages/index/index",
  223. });
  224. } else {
  225. _this.captchaImageRefresh(_this.loginForm);
  226. }
  227. });
  228. },
  229. });
  230. // this.$auth.setUserType(this.$auth.TYPE_FRAME);
  231. },
  232. login() {
  233. const _this = this;
  234. if (!this.loginForm.userName || !this.loginForm.password) {
  235. uni.showModal({
  236. title: "提示",
  237. content: "请输入账号和密码",
  238. icon: "error",
  239. showCancel: false,
  240. });
  241. return;
  242. }
  243. wx.login({
  244. success(e) {
  245. console.log(e);
  246. _this.loginForm.loginCode = e.code;
  247. login(_this.loginForm).then((res) => {
  248. console.log(res);
  249. if (res.errmsg == "成功") {
  250. uni.showToast({
  251. title: "登录成功",
  252. icon: "none",
  253. mask: true,
  254. duration: 2000,
  255. });
  256. console.log(res.data.user);
  257. wx.setStorageSync("USERINFO", JSON.stringify(res.data.user));
  258. uni.switchTab({
  259. url: "/pages/index/index",
  260. });
  261. } else {
  262. _this.captchaImageRefresh(_this.loginForm);
  263. }
  264. });
  265. },
  266. });
  267. // this.$auth.setUserType(this.$auth.TYPE_FRAME);
  268. },
  269. onShareAppMessage: function () {},
  270. },
  271. };
  272. </script>
  273. <style lang="scss">
  274. .login {
  275. background: white;
  276. height: 100%;
  277. overflow: hidden;
  278. .logTit {
  279. width: 80vw;
  280. left: 10vw;
  281. top: 60vw;
  282. display: flex;
  283. flex-direction: column;
  284. justify-content: center;
  285. align-items: center;
  286. position: absolute;
  287. z-index: 1;
  288. color: rgba(51, 51, 51, 1);
  289. font-size: 4vw;
  290. p {
  291. color: rgba(102, 102, 102, 1);
  292. font-size: 4vw;
  293. margin-top: 0.5vw;
  294. }
  295. .titletxt {
  296. font-size: 48rpx;
  297. font-family: Taipei Sans TC Beta-Bold, Taipei Sans TC Beta;
  298. font-weight: bold;
  299. color: #333333;
  300. }
  301. .titletxt2 {
  302. font-size: 32rpx;
  303. font-family: PingFang SC-Regular, PingFang SC;
  304. font-weight: 400;
  305. color: #666666;
  306. }
  307. }
  308. .logobig2 {
  309. width: 100vw;
  310. height: 400rpx;
  311. position: absolute;
  312. left: 0;
  313. z-index: 0;
  314. }
  315. .loginBox {
  316. width: 86vw;
  317. left: 7vw;
  318. top: 156rpx;
  319. position: absolute;
  320. }
  321. .inputBox {
  322. position: relative;
  323. display: flex;
  324. align-items: center;
  325. margin-bottom: 30rpx;
  326. img {
  327. position: absolute;
  328. width: 7vw;
  329. // padding-top: 40px;
  330. }
  331. .yanzhengImg {
  332. right: 0 !important;
  333. width: 20vw;
  334. height: 10vw;
  335. }
  336. .yanzhengImgBox {
  337. height: 50px;
  338. display: flex;
  339. align-items: center;
  340. }
  341. input {
  342. background: black;
  343. width: 100%;
  344. height: 76rpx;
  345. padding: 5rpx 0 5rpx 92rpx;
  346. border: 1rpx solid rgba(29, 24, 188, 0.05);
  347. margin: 5rpx 0;
  348. font-size: 32rpx;
  349. background: rgba(243, 245, 249, 1) !important;
  350. border-radius: 16rpx;
  351. }
  352. .b-palceholder {
  353. color: rgba(179, 179, 179, 1);
  354. }
  355. .yanzhengma {
  356. width: 100%;
  357. }
  358. }
  359. .pswBox {
  360. width: 100%;
  361. display: flex;
  362. justify-content: flex-end;
  363. margin: 20px 0;
  364. color: rgba(29, 24, 188, 1);
  365. }
  366. .van-button {
  367. margin-top: 15rpx;
  368. border-radius: 60px;
  369. }
  370. .loginbtn {
  371. margin-top: 50rpx;
  372. border-radius: 16rpx !important;
  373. padding: 24rpx;
  374. background: rgba(3, 101, 249, 1);
  375. color: white;
  376. font-size: 36rpx;
  377. }
  378. .bottomTips {
  379. width: 100vw;
  380. position: fixed;
  381. bottom: 100rpx;
  382. text-align: center;
  383. color: #999999;
  384. font-size: 28rpx;
  385. }
  386. @media screen and (max-height: 454px) {
  387. .bottomTips {
  388. display: none;
  389. }
  390. }
  391. .loginBody{
  392. background: white;
  393. border-radius: 16px 16px 0 0;
  394. position: relative;
  395. top: 336rpx;
  396. height: 1112rpx;
  397. .loginTypeBox{
  398. display: flex;
  399. justify-content: space-evenly;
  400. font-size: 40rpx;
  401. padding-top: 48rpx;
  402. color: rgba(86, 93, 106, 1);
  403. }
  404. .loginTypeItem{
  405. position: relative;
  406. .bottomLine{
  407. width: 40px;
  408. height: 6px;
  409. background: linear-gradient( 90deg, #0365F9 0%, #85B5FF 100%);
  410. border-radius: 3px 3px 3px 3px;
  411. position: absolute;
  412. bottom: 0;
  413. z-index: 0;
  414. left: 40rpx;
  415. }
  416. .loginTypeName{
  417. position: relative;
  418. z-index: 1;
  419. }
  420. .ischecked {
  421. color: rgba(6, 35, 59, 1);
  422. font-weight: 600;
  423. }
  424. }
  425. }
  426. }
  427. </style>