login.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. <template>
  2. <view class="content">
  3. <view class="lang-change" @click="changeLanguage">
  4. <span :class="currentLanguage == 'English' ? 'current' : ''">En</span>
  5. <span class="current">/</span>
  6. <span :class="currentLanguage == '简体中文' ? 'current' : ''">中</span>
  7. <span class="current">/</span>
  8. <span :class="currentLanguage == 'Português' ? 'current' : ''">Pt</span>
  9. <span class="current">/</span>
  10. <span :class="currentLanguage == 'Russian' ? 'current' : ''">RU</span>
  11. <span class="current">/</span>
  12. <span :class="currentLanguage == uzbk ? 'current' : ''">Uz</span>
  13. </view>
  14. <view class="logo">
  15. <image style="height:104rpx;width:104rpx" src="/static/czzn-img/login/logo.png" mode="aspectFit" />
  16. <view class="app-name">{{$t('login.e')}}</view>
  17. </view>
  18. <!-- 账号密码登录 -->
  19. <template v-if="loginType == 1">
  20. <view class="inp_box">
  21. <input type="text" v-model="loginForm.username" @blur="getNameUrl"
  22. :placeholder="this.$t('login.placeholder')" />
  23. </view>
  24. <view class="inp_box" v-if="needCode">
  25. <input type="text" v-model="loginForm.code" @blur="getUrl"
  26. :placeholder="this.$t('login.codePlaceholder')" />
  27. </view>
  28. <view class="inp_box">
  29. <input type="password" v-model="loginForm.password"
  30. :placeholder="this.$t('login.passwordPlaceholder')" />
  31. </view>
  32. </template>
  33. <!-- 手机号登录 -->
  34. <!-- #ifdef MP-WEIXIN-->
  35. <template v-else>
  36. <view class="inp_box">
  37. <input type="text" v-model="phoneLoginForm.mobile" :placeholder="this.$t('login.phonePlaceholder')" />
  38. </view>
  39. <view class="inp_box">
  40. <input v-model="phoneLoginForm.code" :placeholder="this.$t('login.verifyCodePlaceholder')" />
  41. <button :class="time != 0 ? 'load-reget' : ''" @click="getCode" :disabled='time != 0'
  42. class="get-code-btn">{{
  43. isGetCode ? '' : $t("login.getCode") }}{{ time ? `${time}s` : '' }}</button>
  44. </view>
  45. </template>
  46. <!-- #endif -->
  47. <!-- 阅读同意/忘记密码 -->
  48. <view class="agree-forget">
  49. <view class="agree">
  50. <uni-data-checkbox selectedColor="#3275F5" multiple v-model="agree" checked=true :localdata="option">
  51. </uni-data-checkbox>
  52. <span>{{ $t("login.agree") }}</span>
  53. </view>
  54. <span class="forget" @click="toReset" v-if="loginType == 1">{{ $t('login.forgetPassword') }}</span>
  55. </view>
  56. <!-- 登录按钮 -->
  57. <view class="btn-wrap">
  58. <button :class="agree[0] && canLogin ? 'bind-btn' : 'btn-disabled'" :disabled="!(agree[0] && canLogin)"
  59. @click="loginType == 1 ? onAccountLogin() : onPhoneLogin()">{{ $t('login.login') }}</button>
  60. </view>
  61. <!-- 切换登陆方式/注册 -->
  62. <view class="login-opertion">
  63. <!-- <span class="flex" @click="changeLoginType">{{ loginType == 1 ? $t('login.phoneLogin') : $t('login.pwdLogin')
  64. }}</span>
  65. <span class="line"></span> -->
  66. <span class="flex" @click="toRegister">{{ $t('login.register') }}</span>
  67. </view>
  68. <!-- 微信登陆 -->
  69. <!-- #ifdef MP-WEIXIN-->
  70. <view class="divider">
  71. <u-divider text="快捷登陆" textSize="12"></u-divider>
  72. </view>
  73. <view class="wechat-login">
  74. <image src="../../static/czzn-img/login/wechat.png" class="wechat-logo" @click="wechatLogin" />
  75. </view>
  76. <!-- #endif -->
  77. <!-- #ifdef APP-PLUS||H5-->
  78. <!-- <view class="divider">
  79. <u-divider text="服务" textSize="12"></u-divider>
  80. </view>
  81. <view class="app-login">
  82. <image src="/subpages/static/czzn-img/state/server.png" class="app-logo" @click="server" />
  83. <text @click="server">{{ $t('login.server') }}</text>
  84. </view> -->
  85. <!-- #endif -->
  86. </view>
  87. </template>
  88. <script>
  89. import {
  90. publicUrl
  91. } from '../../utils/config'
  92. import {
  93. userLogin,
  94. phoneLogin,
  95. getTelCode,
  96. getTenantByUsername,
  97. getUrlByName,
  98. getUrlByCode,
  99. bindNameCode,
  100. } from "../../api/login"
  101. import {
  102. getUserInfo
  103. } from "../../api/user"
  104. import {
  105. encryption,
  106. getTenantCacheList
  107. } from '../../utils/util'
  108. import {
  109. mapMutations
  110. } from 'vuex';
  111. import {changeUrl} from '../../utils/config'
  112. export default {
  113. data() {
  114. return {
  115. time: 0,
  116. timer: undefined,
  117. isGetCode: false,
  118. loginType: 1,
  119. agree: [1],
  120. option: [{
  121. text: '',
  122. value: 1,
  123. }],
  124. currentLanguage: '',
  125. canLogin: false,
  126. needCode:false,
  127. loginForm: {
  128. username: "",
  129. password: "",
  130. code: "",
  131. randomStr: "blockPuzzle",
  132. },
  133. noRegisterUserName: "", //未注册的
  134. phoneLoginForm: {
  135. mobile: "",
  136. code: "",
  137. },
  138. serverForm: {
  139. type: "2",
  140. ip: "http://5.63.101.254:3789",
  141. // ip:"http://localhost:9999",
  142. },
  143. uzbk:"O'zbekcha",
  144. }
  145. },
  146. onLoad(options) {
  147. if (uni.getStorageSync('CURRENT_LANG') == "en") {
  148. this.currentLanguage = 'English';
  149. } else if (uni.getStorageSync('CURRENT_LANG') == "pt") {
  150. this.currentLanguage = 'Português';
  151. } else if (uni.getStorageSync('CURRENT_LANG') == "uz") {
  152. this.currentLanguage = "O'zbekcha";
  153. } else if (uni.getStorageSync('CURRENT_LANG') == "ru") {
  154. this.currentLanguage = "Russian";
  155. }else {
  156. this.currentLanguage = '简体中文';
  157. }
  158. var server = uni.getStorageSync('server');
  159. this.defServer()
  160. console.log("当前服务器信息、", server);
  161. if (options.username) {
  162. this.loginForm.username = options.username
  163. this.phoneLoginForm.mobile = options.username
  164. this.getTenantUsername()
  165. }
  166. },
  167. methods: {
  168. ...mapMutations({
  169. setUserInfo: 'user/login'
  170. }),
  171. //切换语言
  172. changeLanguage() {
  173. console.log('语言切换')
  174. uni.showActionSheet({
  175. itemList: ["English", "简体中文", "Português","O'zbekcha",'Russian'],
  176. success: res => {
  177. let language = uni.getStorageSync('CURRENT_LANG')
  178. console.log(res.tapIndex,language);
  179. if ((res.tapIndex === 0 && language != 'en') || (res.tapIndex === 1 && language !=
  180. 'zh-Hans') || (res.tapIndex === 2 && language != 'pt') || (res.tapIndex === 3 && language != 'uz') || (res.tapIndex === 4 && language != 'ru')) {
  181. const globalData = getApp().globalData
  182. console.log(globalData, '--------------');
  183. console.log(language);
  184. if (res.tapIndex === 0) {
  185. language = globalData.locale = 'en'
  186. } else if (res.tapIndex === 1) {
  187. language = globalData.locale = 'zh-Hans'
  188. } else if (res.tapIndex === 2) {
  189. language = globalData.locale = 'pt'
  190. } else if (res.tapIndex === 3) {
  191. language = globalData.locale = 'uz'
  192. }else if (res.tapIndex === 4) {
  193. language = globalData.locale = 'ru'
  194. }
  195. uni.setStorageSync('CURRENT_LANG', language)
  196. getApp().globalData.$i18n.locale = language
  197. if (res.tapIndex === 0) {
  198. this.currentLanguage = 'English'
  199. } else if (res.tapIndex === 1) {
  200. this.currentLanguage = '简体中文'
  201. } else if (res.tapIndex === 2) {
  202. this.currentLanguage = 'Português'
  203. } else if (res.tapIndex === 3) {
  204. this.currentLanguage = "O'zbekcha"
  205. }else if (res.tapIndex === 4) {
  206. this.currentLanguage = "Russian"
  207. }
  208. if (uni.setLocale) {
  209. uni.setLocale(language)
  210. }
  211. uni.reLaunch({
  212. url: '/pages/login/login',
  213. complete: () => {
  214. uni.$emit("changeLanguage", language)
  215. }
  216. })
  217. }
  218. },
  219. fail: () => {},
  220. complete: () => {}
  221. });
  222. },
  223. //绑定微信
  224. bindWechat() {
  225. // #ifdef MP-WEIXIN
  226. console.log("当前是微信");
  227. wx.login({
  228. success(result) {
  229. wx.request({
  230. url: publicUrl + '/admin/social/bind?state=E_MINI&code=' + result.code,
  231. method: 'post',
  232. header: {
  233. 'Authorization': 'Bearer ' + uni.getStorageSync('token')
  234. },
  235. success(r) {
  236. console.log(r)
  237. if (r.statusCode == 200) {
  238. wx.showToast({
  239. title: '绑定成功',
  240. icon: "none",
  241. duration: 1000,
  242. })
  243. } else if (r.statusCode != 200 && r.data.error) {
  244. uni.showToast({
  245. title: r.data.error,
  246. icon: 'none',
  247. duration: 2000
  248. })
  249. uni.navigateTo({
  250. url: '/pages/login/chooserole'
  251. })
  252. } else if (r.statusCode != 200 && r.data.msg) {
  253. uni.showToast({
  254. title: r.data.msg,
  255. icon: 'none',
  256. duration: 2000
  257. })
  258. }
  259. }
  260. })
  261. }
  262. })
  263. // #endif
  264. // #ifndef MP-WEIXIN
  265. console.log("当前不是微信");
  266. // #endif
  267. },
  268. //获取验证码
  269. getCode() {
  270. let phone = /^1[3-9]\d{9}$/
  271. if (this.phoneLoginForm.mobile == '') {
  272. uni.showToast({
  273. title: this.$t('login.phonePlaceholder'),
  274. icon: "none",
  275. duration: 2500,
  276. })
  277. } else{
  278. getTelCode(this.phoneLoginForm.mobile).then(res => {
  279. if (res.statusCode === 200) {
  280. this.isGetCode = true
  281. this.time = 60
  282. this.timer = setInterval(() => {
  283. this.time--
  284. if (this.time == 0) {
  285. clearInterval(this.timer)
  286. }
  287. }, 1000)
  288. }
  289. })
  290. }
  291. },
  292. //切换登录方式
  293. changeLoginType() {
  294. if (this.loginType == 1) {
  295. this.loginType = 0
  296. } else if (this.loginType == 0) {
  297. this.loginType = 1
  298. }
  299. },
  300. //去注册
  301. toRegister() {
  302. uni.navigateTo({
  303. url: '/pages/login/chooserole'
  304. })
  305. },
  306. //去重置密码
  307. toReset() {
  308. uni.showModal({
  309. content: this.$t('login.conenct'),
  310. showCancel: false,
  311. })
  312. // uni.navigateTo({
  313. // url: '/pages/login/forgot'
  314. // })
  315. },
  316. //手机验证码登录
  317. onPhoneLogin() {
  318. if (this.phoneLoginForm.mobile == '') {
  319. uni.showToast({
  320. title: this.$t('login.phonePlaceholder'),
  321. icon: "none",
  322. duration: 2500,
  323. })
  324. } else if (this.phoneLoginForm.code == '') {
  325. uni.showToast({
  326. title: this.$t('login.verifyCodePlaceholder'),
  327. icon: "none",
  328. duration: 2500,
  329. })
  330. } else {
  331. let param = {
  332. mobile: 'SMS@' + this.phoneLoginForm.mobile + '@' + this.phoneLoginForm.code,
  333. grant_type: 'mobile'
  334. };
  335. phoneLogin(param).then(res => {
  336. if (res.statusCode === 200) {
  337. uni.setStorageSync('userId', res.data.user_info.id)
  338. uni.setStorageSync('userName', this.loginForm.username)
  339. uni.setStorageSync('token', res.data.access_token)
  340. this.onGetUserInfo(true)
  341. uni.switchTab({
  342. url: "/pages/home/home"
  343. })
  344. uni.showToast({
  345. title: this.$t('login.success'),
  346. icon: "none",
  347. duration: 2500,
  348. })
  349. }
  350. })
  351. }
  352. },
  353. //账号登录
  354. onAccountLogin() {
  355. console.log("登录信息、", this.loginForm);
  356. if (this.noRegisterUserName == this.loginForm.username) {
  357. uni.showModal({
  358. content: this.$t('login.noRegister'),
  359. showCancel: false,
  360. })
  361. return
  362. }
  363. let serverPrefix = uni.getStorageSync("serverPrefix");
  364. if (serverPrefix == undefined || serverPrefix == "" || serverPrefix == null || serverPrefix == "null") {
  365. uni.showModal({
  366. content: "请选择一个服务器",
  367. showCancel: false,
  368. })
  369. return
  370. }
  371. if (this.loginForm.username == '') {
  372. uni.showToast({
  373. title: this.$t('login.placeholder'),
  374. icon: "none",
  375. duration: 2500,
  376. })
  377. } else if (this.loginForm.password == '') {
  378. uni.showToast({
  379. title: this.$t('login.passwordPlaceholder'),
  380. icon: "none",
  381. duration: 2500,
  382. })
  383. } else {
  384. const userInfo = encryption({
  385. data: {
  386. username: this.loginForm.username,
  387. password: this.loginForm.password,
  388. delFlag: '0',
  389. source: 'mini'
  390. },
  391. key: 'pigxpigxpigxpigx',
  392. param: ['password'],
  393. source: 'mini'
  394. })
  395. userLogin(userInfo).then(res => {
  396. if (res.statusCode === 200) {
  397. var userId = res.data.user_id
  398. if (!userId) {
  399. userId = res.data.user_info.id
  400. }
  401. uni.setStorageSync('userId', userId)
  402. uni.setStorageSync('userName', this.loginForm.username)
  403. uni.setStorageSync('token', res.data.access_token)
  404. this.onGetUserInfo(true)
  405. }
  406. })
  407. }
  408. },
  409. //获取用户详情
  410. onGetUserInfo(isBindWebChart) {
  411. getUserInfo().then(res => {
  412. if (res.statusCode == 200 && res.data.code == 0) {
  413. console.log(res);
  414. var userType = res.data.data.sysUser.type;
  415. uni.setStorageSync('userInfo', res.data.data.sysUser)
  416. uni.setStorageSync('tenantInfo', res.data.data.tenantList)
  417. uni.setStorageSync('userType', userType)
  418. uni.setStorageSync('isAuditUser', false)
  419. uni.setStorageSync('isEnterpriseUser', userType == "5" ? true : false)
  420. uni.setStorageSync('isDealerUser', userType == "3" ? true : false)
  421. uni.setStorageSync('isDriverUser', userType == "4" ? true : false)
  422. uni.setStorageSync('isTransUser', userType == "7" ? true : false)
  423. var tenantList = getTenantCacheList();
  424. //默认第一个租户
  425. uni.setStorageSync("currentTenantId", tenantList[0]);
  426. //AUDIT_USER 移动端审核角色
  427. //DEALER_USER 客商角色
  428. //DRIVER_USER 移动端司机
  429. // if (res.data.data.roleCodes) {
  430. // uni.setStorageSync('userRoleCode', res.data.data.roleCodes)
  431. // if (res.data.data.roleCodes.includes("DEALER_USER")) {
  432. // uni.setStorageSync('isDealerUser', true)
  433. // uni.setStorageSync('isAuditUser', false)
  434. // uni.setStorageSync('isDeliverUser', false)
  435. // }
  436. // if (res.data.data.roleCodes.includes("DRIVER_USER")) {
  437. // uni.setStorageSync('isDriverUser', true)
  438. // uni.setStorageSync('isAuditUser', false)
  439. // uni.setStorageSync('isDeliverUser', false)
  440. // }
  441. // if (res.data.data.roleCodes.includes("AUDIT_USER")) {
  442. // uni.setStorageSync('isAuditUser', true)
  443. // uni.setStorageSync('isDealerUser', false)
  444. // uni.setStorageSync('isDriverUser', false)
  445. // }
  446. // }
  447. this.setUserInfo(res.data.data.sysUser)
  448. if (isBindWebChart == true) {
  449. // this.bindWechat() //自动绑定微信
  450. }
  451. console.log("当前登录账户类型、", res.data.data.sysUser.type);
  452. if (uni.getStorageSync('isAuditUser')) {
  453. getApp().globalData.tabIndex = 'approval'
  454. if (uni.getStorageSync("serverStatus") == 1) {
  455. uni.switchTab({
  456. url: "/pages/approval/approvallist"
  457. })
  458. } else {
  459. uni.navigateTo({
  460. url: "/pages/login/chooseEnterp"
  461. })
  462. }
  463. } else {
  464. getApp().globalData.tabIndex = 'home'
  465. uni.switchTab({
  466. url: "/pages/home/home"
  467. })
  468. }
  469. uni.showToast({
  470. title: this.$t('login.success'),
  471. icon: "none",
  472. duration: 2500,
  473. })
  474. } else if (res.statusCode != 200 || res.data.code === 1) {
  475. uni.showToast({
  476. title: res.data.error || res.data.msg,
  477. icon: 'none',
  478. duration: 2000
  479. })
  480. }
  481. })
  482. }, //微信登录
  483. wechatLogin() {
  484. let that = this;
  485. wx.login({
  486. success(res) {
  487. wx.request({
  488. url: publicUrl + '/auth/mobile/token/social?grant_type=mobil&mobile=E_MINI@' +
  489. res.code + '&code=' + res.code,
  490. method: 'post',
  491. header: {
  492. Authorization: 'Basic cGlnOnBpZw==',
  493. },
  494. success(res) {
  495. console.log(res);
  496. if (res.statusCode === 401) {
  497. wx.showModal({
  498. content: '用户未绑定微信,请先登录并绑定账号',
  499. showCancel: true,
  500. success: function(res) {
  501. if (res.confirm) {
  502. uni.removeStorageSync('token')
  503. uni.removeStorageSync('tenantId')
  504. uni.removeStorageSync('userId')
  505. uni.removeStorageSync('userName')
  506. uni.removeStorageSync('userInfo')
  507. uni.removeStorageSync('userType')
  508. uni.removeStorageSync('serverAddress');
  509. uni.removeStorageSync('serverPrefix');
  510. uni.removeStorageSync('tenantInfo')
  511. uni.reLaunch({
  512. url: "/pages/login/login"
  513. })
  514. console.log('用户点击确定');
  515. } else if (res.cancel) {
  516. console.log('用户点击取消');
  517. }
  518. }
  519. })
  520. } else if (res.statusCode === 200) {
  521. console.log("微信登录返回、", res);
  522. uni.setStorageSync('userId', res.data.user_info.id)
  523. uni.setStorageSync('userName', res.data.user_info.username)
  524. uni.setStorageSync('token', res.data.access_token)
  525. that.onGetUserInfo(false)
  526. } else if (res.statusCode != 200 || res.data.code === 1) {
  527. uni.showToast({
  528. title: res.data.error || res.data.msg,
  529. icon: 'none',
  530. duration: 2000
  531. })
  532. }
  533. },
  534. });
  535. },
  536. });
  537. },
  538. //选择服务器
  539. server() {
  540. uni.navigateTo({
  541. url: '/pages/login/server'
  542. })
  543. },
  544. defServer() {
  545. // #ifdef MP-WEIXIN
  546. var tenantVersion = uni.getStorageSync('tenantVersion');
  547. if (tenantVersion != 3) {
  548. uni.setStorageSync('serverStatus', 2);
  549. uni.setStorageSync('serverAddress', this.serverForm.ip);
  550. uni.setStorageSync('server', this.serverForm);
  551. uni.setStorageSync('serverPrefix', "/ymt");
  552. }
  553. // #endif
  554. },
  555. //获取租户
  556. getTenantUsername() {
  557. // let serverPrefix = uni.getStorageSync("serverPrefix");
  558. // if (serverPrefix == undefined || serverPrefix == "" || serverPrefix == null || serverPrefix == "null") {
  559. // uni.showModal({
  560. // content: "请选择一个服务器",
  561. // showCancel: false,
  562. // })
  563. // return
  564. // }
  565. if (
  566. !this.loginForm.username.length ||
  567. this.loginForm.username.length == 0
  568. ) {
  569. return false;
  570. }
  571. getTenantByUsername(this.loginForm.username).then(response => {
  572. let tenantList = response.data.data ? response.data.data : [];
  573. if (tenantList.length != 0) {
  574. this.noRegisterUserName = ""
  575. uni.setStorageSync('tenantId', tenantList[0].id);
  576. if (tenantList[0].cloudAddress) {
  577. // #ifdef MP-WEIXIN
  578. this.serverForm.ip = tenantList[0].cloudAddress;
  579. uni.setStorageSync('tenantVersion', 3);
  580. uni.setStorageSync('serverStatus', 2);
  581. uni.setStorageSync('serverAddress', this.serverForm.ip);
  582. uni.setStorageSync('server', this.serverForm);
  583. uni.setStorageSync('serverPrefix', "/admin");
  584. // #endif
  585. }
  586. this.canLogin = true
  587. } else {
  588. this.noRegisterUserName = this.loginForm.username
  589. uni.showModal({
  590. content: this.$t('login.noRegister'), //未注册用户
  591. icon: 'none',
  592. showCancel: false,
  593. });
  594. this.canLogin = false
  595. }
  596. });
  597. },
  598. //获取Url
  599. getUrl(){
  600. let that = this
  601. if (this.loginForm.username == '') {
  602. uni.showToast({
  603. title: this.$t('login.placeholder'),
  604. icon: "none",
  605. duration: 2500,
  606. })
  607. } else if (this.loginForm.code == '') {
  608. uni.showToast({
  609. title: this.$t('login.codePlaceholder'),
  610. icon: "none",
  611. duration: 2500,
  612. })
  613. } else {
  614. let data = {
  615. username: this.loginForm.username,
  616. companyCode: this.loginForm.code
  617. }
  618. bindNameCode(data).then(res=>{
  619. if (res.statusCode === 200 && res.data.data.code === 0) {
  620. getUrlByCode(this.loginForm.code).then(r=>{
  621. if (res.statusCode === 200 && r.data.code === 0) {
  622. let data = r.data.data
  623. uni.setStorageSync('serverAddress', data.requestUrl);
  624. uni.setStorageSync('serverPrefix', data.methodPrefix);
  625. changeUrl()
  626. that.getTenantUsername()
  627. }else{
  628. uni.showToast({
  629. title: r.data.msg,
  630. icon: "none",
  631. duration: 2500,
  632. })
  633. }
  634. })
  635. }else{
  636. this.canLogin = false
  637. uni.showToast({
  638. title: res.data.data.msg,
  639. icon: "none",
  640. duration: 2500,
  641. })
  642. }
  643. })
  644. }
  645. },
  646. //用户名获取url
  647. getNameUrl(){
  648. if (this.loginForm.username == '') {
  649. uni.showToast({
  650. title: this.$t('login.placeholder'),
  651. icon: "none",
  652. duration: 2500,
  653. })
  654. }else{
  655. getUrlByName(this.loginForm.username).then(res=>{
  656. console.log('1111111111122222222222222',res);
  657. if (res.statusCode === 200 && res.data.code === 0) {
  658. let data = res.data.data
  659. if(data){
  660. uni.setStorageSync('serverAddress', data.requestUrl);
  661. uni.setStorageSync('serverPrefix', data.methodPrefix);
  662. this.needCode = false
  663. this.getTenantUsername()
  664. }else{
  665. uni.showToast({
  666. title: res.data.msg,
  667. icon: "none",
  668. duration: 2500,
  669. })
  670. this.canLogin = false
  671. this.needCode = true
  672. }
  673. }else{
  674. uni.showToast({
  675. title: res.data.msg,
  676. icon: "none",
  677. duration: 2500,
  678. })
  679. }
  680. })
  681. }
  682. }
  683. }
  684. }
  685. </script>
  686. <style>
  687. /* #ifndef APP-NVUE */
  688. view {
  689. display: flex;
  690. box-sizing: border-box;
  691. flex-direction: column;
  692. }
  693. page {
  694. box-sizing: border-box;
  695. padding: 0 48rpx 80rpx;
  696. height: 100%;
  697. }
  698. /* #endif*/
  699. </style>
  700. <style lang="scss" scoped>
  701. @import '../../common/css/login.scss';
  702. </style>