login.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714
  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. var tenantList = getTenantCacheList();
  423. //默认第一个租户
  424. uni.setStorageSync("currentTenantId", tenantList[0]);
  425. //AUDIT_USER 移动端审核角色
  426. //DEALER_USER 客商角色
  427. //DRIVER_USER 移动端司机
  428. if (res.data.data.roleCodes) {
  429. uni.setStorageSync('userRoleCode', res.data.data.roleCodes)
  430. if (res.data.data.roleCodes.includes("DEALER_USER")) {
  431. uni.setStorageSync('isDealerUser', true)
  432. uni.setStorageSync('isAuditUser', false)
  433. uni.setStorageSync('isDeliverUser', false)
  434. }
  435. if (res.data.data.roleCodes.includes("DRIVER_USER")) {
  436. uni.setStorageSync('isDriverUser', true)
  437. uni.setStorageSync('isAuditUser', false)
  438. uni.setStorageSync('isDeliverUser', false)
  439. }
  440. if (res.data.data.roleCodes.includes("AUDIT_USER")) {
  441. uni.setStorageSync('isAuditUser', true)
  442. uni.setStorageSync('isDealerUser', false)
  443. uni.setStorageSync('isDriverUser', false)
  444. }
  445. }
  446. this.setUserInfo(res.data.data.sysUser)
  447. if (isBindWebChart == true) {
  448. // this.bindWechat() //自动绑定微信
  449. }
  450. console.log("当前登录账户类型、", res.data.data.sysUser.type);
  451. if (uni.getStorageSync('isAuditUser')) {
  452. getApp().globalData.tabIndex = 'approval'
  453. if (uni.getStorageSync("serverStatus") == 1) {
  454. uni.switchTab({
  455. url: "/pages/approval/approvallist"
  456. })
  457. } else {
  458. uni.navigateTo({
  459. url: "/pages/login/chooseEnterp"
  460. })
  461. }
  462. } else {
  463. getApp().globalData.tabIndex = 'home'
  464. uni.switchTab({
  465. url: "/pages/home/home"
  466. })
  467. }
  468. uni.showToast({
  469. title: this.$t('login.success'),
  470. icon: "none",
  471. duration: 2500,
  472. })
  473. } else if (res.statusCode != 200 || res.data.code === 1) {
  474. uni.showToast({
  475. title: res.data.error || res.data.msg,
  476. icon: 'none',
  477. duration: 2000
  478. })
  479. }
  480. })
  481. }, //微信登录
  482. wechatLogin() {
  483. let that = this;
  484. wx.login({
  485. success(res) {
  486. wx.request({
  487. url: publicUrl + '/auth/mobile/token/social?grant_type=mobil&mobile=E_MINI@' +
  488. res.code + '&code=' + res.code,
  489. method: 'post',
  490. header: {
  491. Authorization: 'Basic cGlnOnBpZw==',
  492. },
  493. success(res) {
  494. console.log(res);
  495. if (res.statusCode === 401) {
  496. wx.showModal({
  497. content: '用户未绑定微信,请先登录并绑定账号',
  498. showCancel: true,
  499. success: function(res) {
  500. if (res.confirm) {
  501. uni.removeStorageSync('token')
  502. uni.removeStorageSync('tenantId')
  503. uni.removeStorageSync('userId')
  504. uni.removeStorageSync('userName')
  505. uni.removeStorageSync('userInfo')
  506. uni.removeStorageSync('userType')
  507. uni.removeStorageSync('serverAddress');
  508. uni.removeStorageSync('serverPrefix');
  509. uni.removeStorageSync('tenantInfo')
  510. uni.reLaunch({
  511. url: "/pages/login/login"
  512. })
  513. console.log('用户点击确定');
  514. } else if (res.cancel) {
  515. console.log('用户点击取消');
  516. }
  517. }
  518. })
  519. } else if (res.statusCode === 200) {
  520. console.log("微信登录返回、", res);
  521. uni.setStorageSync('userId', res.data.user_info.id)
  522. uni.setStorageSync('userName', res.data.user_info.username)
  523. uni.setStorageSync('token', res.data.access_token)
  524. that.onGetUserInfo(false)
  525. } else if (res.statusCode != 200 || res.data.code === 1) {
  526. uni.showToast({
  527. title: res.data.error || res.data.msg,
  528. icon: 'none',
  529. duration: 2000
  530. })
  531. }
  532. },
  533. });
  534. },
  535. });
  536. },
  537. //选择服务器
  538. server() {
  539. uni.navigateTo({
  540. url: '/pages/login/server'
  541. })
  542. },
  543. defServer() {
  544. // #ifdef MP-WEIXIN
  545. var tenantVersion = uni.getStorageSync('tenantVersion');
  546. if (tenantVersion != 3) {
  547. uni.setStorageSync('serverStatus', 2);
  548. uni.setStorageSync('serverAddress', this.serverForm.ip);
  549. uni.setStorageSync('server', this.serverForm);
  550. uni.setStorageSync('serverPrefix', "/ymt");
  551. }
  552. // #endif
  553. },
  554. //获取租户
  555. getTenantUsername() {
  556. // let serverPrefix = uni.getStorageSync("serverPrefix");
  557. // if (serverPrefix == undefined || serverPrefix == "" || serverPrefix == null || serverPrefix == "null") {
  558. // uni.showModal({
  559. // content: "请选择一个服务器",
  560. // showCancel: false,
  561. // })
  562. // return
  563. // }
  564. if (
  565. !this.loginForm.username.length ||
  566. this.loginForm.username.length == 0
  567. ) {
  568. return false;
  569. }
  570. getTenantByUsername(this.loginForm.username).then(response => {
  571. let tenantList = response.data.data ? response.data.data : [];
  572. if (tenantList.length != 0) {
  573. this.noRegisterUserName = ""
  574. uni.setStorageSync('tenantId', tenantList[0].id);
  575. if (tenantList[0].cloudAddress) {
  576. // #ifdef MP-WEIXIN
  577. this.serverForm.ip = tenantList[0].cloudAddress;
  578. uni.setStorageSync('tenantVersion', 3);
  579. uni.setStorageSync('serverStatus', 2);
  580. uni.setStorageSync('serverAddress', this.serverForm.ip);
  581. uni.setStorageSync('server', this.serverForm);
  582. uni.setStorageSync('serverPrefix', "/admin");
  583. // #endif
  584. }
  585. this.canLogin = true
  586. } else {
  587. this.noRegisterUserName = this.loginForm.username
  588. uni.showModal({
  589. content: this.$t('login.noRegister'), //未注册用户
  590. icon: 'none',
  591. showCancel: false,
  592. });
  593. this.canLogin = false
  594. }
  595. });
  596. },
  597. //获取Url
  598. getUrl(){
  599. let that = this
  600. if (this.loginForm.username == '') {
  601. uni.showToast({
  602. title: this.$t('login.placeholder'),
  603. icon: "none",
  604. duration: 2500,
  605. })
  606. } else if (this.loginForm.code == '') {
  607. uni.showToast({
  608. title: this.$t('login.codePlaceholder'),
  609. icon: "none",
  610. duration: 2500,
  611. })
  612. } else {
  613. let data = {
  614. username: this.loginForm.username,
  615. companyCode: this.loginForm.code
  616. }
  617. bindNameCode(data).then(res=>{
  618. if (res.statusCode === 200 && res.data.data.code === 0) {
  619. getUrlByCode(this.loginForm.code).then(r=>{
  620. if (res.statusCode === 200 && r.data.code === 0) {
  621. let data = r.data.data
  622. uni.setStorageSync('serverAddress', data.requestUrl);
  623. uni.setStorageSync('serverPrefix', data.methodPrefix);
  624. changeUrl()
  625. that.getTenantUsername()
  626. }else{
  627. uni.showToast({
  628. title: r.data.msg,
  629. icon: "none",
  630. duration: 2500,
  631. })
  632. }
  633. })
  634. }else{
  635. this.canLogin = false
  636. uni.showToast({
  637. title: res.data.data.msg,
  638. icon: "none",
  639. duration: 2500,
  640. })
  641. }
  642. })
  643. }
  644. },
  645. //用户名获取url
  646. getNameUrl(){
  647. if (this.loginForm.username == '') {
  648. uni.showToast({
  649. title: this.$t('login.placeholder'),
  650. icon: "none",
  651. duration: 2500,
  652. })
  653. }else{
  654. getUrlByName(this.loginForm.username).then(res=>{
  655. console.log('1111111111122222222222222',res);
  656. if (res.statusCode === 200 && res.data.code === 0) {
  657. let data = res.data.data
  658. if(data){
  659. uni.setStorageSync('serverAddress', data.requestUrl);
  660. uni.setStorageSync('serverPrefix', data.methodPrefix);
  661. this.needCode = false
  662. this.getTenantUsername()
  663. }else{
  664. uni.showToast({
  665. title: res.data.msg,
  666. icon: "none",
  667. duration: 2500,
  668. })
  669. this.canLogin = false
  670. this.needCode = true
  671. }
  672. }else{
  673. uni.showToast({
  674. title: res.data.msg,
  675. icon: "none",
  676. duration: 2500,
  677. })
  678. }
  679. })
  680. }
  681. }
  682. }
  683. }
  684. </script>
  685. <style>
  686. /* #ifndef APP-NVUE */
  687. view {
  688. display: flex;
  689. box-sizing: border-box;
  690. flex-direction: column;
  691. }
  692. page {
  693. box-sizing: border-box;
  694. padding: 0 48rpx 80rpx;
  695. height: 100%;
  696. }
  697. /* #endif*/
  698. </style>
  699. <style lang="scss" scoped>
  700. @import '../../common/css/login.scss';
  701. </style>