index.vue 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436
  1. <template>
  2. <div class="signin-container register-container" style="height: calc(100%)">
  3. <top-color v-show="false"></top-color>
  4. <div class="signin-box register-box">
  5. <!--注册-->
  6. <div v-if="!loginFlag" class="register-center">
  7. <div class="register-title">
  8. <span style="
  9. font-size: 18px;
  10. font-weight: bold;
  11. color: rgba(51, 51, 51, 1);
  12. ">{{ $t('login.zhuc') }}</span>
  13. <span v-if="registerFlag">{{ $t('login.existingAccounts') + '?'
  14. }}<span @click="returnLogin"
  15. style="cursor: pointer; color: #1d6ced; font-weight: 400">{{ $t('login.clickLogin') }}</span></span>
  16. </div>
  17. <el-form v-if="registerFlag" label-position="top" class="register-form" ref="registerForm" :model="registerForm"
  18. :rules="registerFormRules" auto-complete="on">
  19. <!-- 联系人/手机号 -->
  20. <div style="display: flex; justify-content: center">
  21. <el-form-item prop="linkmanName" :label="$t('login.register04')">
  22. <el-input v-model="registerForm.linkmanName" maxlength="20" :placeholder="$t('login.registerVerif04')" />
  23. </el-form-item>
  24. <el-form-item prop="linkmanPhone" :label="$t('login.register05')" style="margin-left: 20px">
  25. <el-input v-model="registerForm.linkmanPhone" maxlength="20" :placeholder="$t('login.registerVerif05')" />
  26. </el-form-item>
  27. </div>
  28. <!-- 密码 -->
  29. <el-form-item prop="password" :label="$t('login.register06')">
  30. <el-input v-model="registerForm.password" type="password" :placeholder="$t('login.verification01')" />
  31. </el-form-item>
  32. <!-- 确认密码 -->
  33. <el-form-item prop="confirmPassword" :label="$t('login.register07')">
  34. <el-input v-model="registerForm.confirmPassword" type="password"
  35. :placeholder="$t('login.verification01')" />
  36. </el-form-item>
  37. <!-- 验证码 -->
  38. <el-form-item prop="veriCode" :label="$t('login.register08')">
  39. <div style="display: flex; justify-content: space-between">
  40. <el-input v-model="registerForm.veriCode" :disabled="disabledFlag" class="code_style"
  41. :placeholder="$t('login.registerVerif08')" />
  42. <div>
  43. <ws-button v-show="verification" type="primary" @click="toSend">{{ $t('login.sendVerification') }}
  44. </ws-button>
  45. <ws-button v-show="!verification" class="retry" disabled>{{ $t('login.retry') }}({{ count }})s
  46. </ws-button>
  47. </div>
  48. </div>
  49. </el-form-item>
  50. <!-- 注册/取消按钮 -->
  51. <div style="display: flex; justify-content: space-between">
  52. <div style="width: 30%">
  53. <el-button :loading="loading" style="width: 100%" @click.native.prevent="handleCancel">
  54. {{ $t('button.cancel') }}
  55. </el-button>
  56. </div>
  57. <div style="width: 67%">
  58. <el-button :loading="registerLoading" type="primary" style="width: 100%"
  59. @click.native.prevent="handleRegister">{{ $t('login.register') }}</el-button>
  60. </div>
  61. </div>
  62. <!-- 描述 -->
  63. <div class="form-tip">
  64. {{ $t('login.registerTip') }}
  65. </div>
  66. </el-form>
  67. <!-- 注册完成的页面 -->
  68. <div v-if="!registerFlag" class="register-form">
  69. <div style="
  70. display: flex;
  71. justify-content: center;
  72. align-items: center;
  73. margin: 80px 0 40px;
  74. ">
  75. <i class="iconfont iconregisterOky" style="color: #1d6ced; font-size: 40px" />
  76. <span class="registerSuccess">
  77. {{ $t('login.registerSuccess') }}</span>
  78. </div>
  79. <p>{{ $t('login.PromptSuccessfulRegistration') }}</p>
  80. <el-button :loading="loading" class="registration-completed" @click.native.prevent="returnToLogin">
  81. {{ $t('login.complete') }}
  82. </el-button>
  83. </div>
  84. </div>
  85. <!--登录-->
  86. <div class="flex" v-if="loginFlag">
  87. <div>
  88. <img style="width: 591px" src="../../../public/img/transport.png" alt="" />
  89. </div>
  90. <!-- 登录框主体 -->
  91. <div class="login-box">
  92. <div class="login-head">
  93. <div class="logo" />
  94. </div>
  95. <div class="login-body">
  96. <!-- 快捷登录
  97. <el-form
  98. ref="loginForm2"
  99. class="fastLoginForm"
  100. :model="queryLoginForm"
  101. :rules="queryRules"
  102. auto-complete="on"
  103. hide-required-asterisk=true
  104. label-position="left"
  105. size="medium">
  106. <el-form-item prop="mobilePhone"
  107. class="userCellPhone" label='+86'>
  108. <el-input v-model="queryLoginForm.mobilePhone"
  109. :placeholder="$t('login.select03')" />
  110. </el-form-item>
  111. <el-form-item prop="veriCode"
  112. class="veriCode">
  113. <div>
  114. <el-input v-model="queryLoginForm.veriCode"
  115. :placeholder="$t('login.select04')" />
  116. </div>
  117. <div>
  118. <el-button style="width: 30%;border-radius: 20px;"
  119. v-if="showVerification"
  120. type="primary"
  121. @click="fastSendVerification">{{ $t('login.sendVerification') }}</el-button>
  122. <el-button style="width: 30%;border-radius: 20px;"
  123. v-if="!showVerification"
  124. disabled>{{ $t('login.retry') }}({{ count }})s</el-button>
  125. </div>
  126. </el-form-item>
  127. <el-button :loading="loading"
  128. type="primary"
  129. class="phone-signIn"
  130. @click.native.prevent="handleFastLogin">{{ $t('login.login') }}</el-button>
  131. </el-form> -->
  132. <ul>
  133. <!-- <li @click="
  134. tabsOne = false
  135. $refs['loginForm2'].resetFields()
  136. " :class="{ selected: !tabsOne }">
  137. {{ $t('login.fastLogin') }}
  138. </li>
  139. <li @click="
  140. tabsOne = true
  141. $refs['loginForm'].resetFields()
  142. " :class="{ selected: tabsOne }">
  143. {{ $t('login.noLogin') }}
  144. </li> -->
  145. </ul>
  146. <el-form v-show="tabsOne" ref="loginForm" :model="loginForm" :rules="getFormRules" auto-complete="on"
  147. label-position="left">
  148. <el-form-item prop="companyName">
  149. <!-- <el-input v-model="loginForm.companyName" :placeholder="$t('login.verification08')" /> -->
  150. <el-select v-model="loginForm.companyName" filterable placeholder="请选择" class="comp-select">
  151. <el-option v-for="item in compOptionList" :key="item.compName" :label="item.compName" :value="item.compName">
  152. </el-option>
  153. </el-select>
  154. </el-form-item>
  155. <el-form-item prop="username">
  156. <el-input ref="username" v-model="loginForm.username" :placeholder="$t('login.select01')"
  157. name="username" type="text" auto-complete="on" />
  158. </el-form-item>
  159. <el-form-item prop="password" style="margin-bottom: 20px">
  160. <el-input :key="passwordType" ref="password" v-model="loginForm.password" :type="passwordType"
  161. :placeholder="$t('login.select02')" name="password" auto-complete="on"
  162. @keyup.enter.native="handleLogin" />
  163. <span class="show-pwd" @click="showPwd">
  164. <i class="iconfont" :class="
  165. passwordType === 'password'
  166. ? 'iconbukejian'
  167. : 'iconkejian'
  168. " />
  169. </span>
  170. </el-form-item>
  171. <el-row>
  172. <div class="remember-information">
  173. <el-checkbox v-model="rememberMe" class="fl">
  174. <span>{{
  175. $t('login.rememberPwd')
  176. }}</span>
  177. </el-checkbox>
  178. <!-- <div class="fr pointer forget-pwd">
  179. <LangSelectText />
  180. <span style="margin: 0 5px">|</span>
  181. <span @click="forgetPassword">{{
  182. $t('login.forgetPwd')
  183. }}</span>
  184. </div> -->
  185. </div>
  186. </el-row>
  187. <div class="sign_up">
  188. <el-button :loading="loading" type="primary" class="signIn-buttom" @click.native.prevent="handleLogin">
  189. {{ $t('login.login') }}
  190. </el-button>
  191. <!-- <span class="register-buttom" @click="toRegister">{{
  192. $t('login.register')
  193. }}</span> -->
  194. </div>
  195. </el-form>
  196. <!-- 快捷登录 -->
  197. <el-form v-show="!tabsOne" ref="loginForm2" class="fastLoginForm" :model="queryLoginForm"
  198. :rules="queryRules" auto-complete="on" label-position="left">
  199. <el-form-item prop="mobilePhone" class="userCellPhone">
  200. <el-input v-model="queryLoginForm.mobilePhone" :placeholder="$t('login.select03')" />
  201. </el-form-item>
  202. <el-form-item prop="veriCode" class="veriCode">
  203. <div>
  204. <el-input v-model="queryLoginForm.veriCode" :placeholder="$t('login.select04')" />
  205. </div>
  206. <div>
  207. <el-button style="width: 30%; border-radius: 20px" v-if="showVerification" type="primary"
  208. @click="fastSendVerification">{{ $t('login.sendVerification') }}</el-button>
  209. <el-button style="width: 30%; border-radius: 20px" v-if="!showVerification" disabled>
  210. {{ $t('login.retry') }}({{ count }})s
  211. </el-button>
  212. </div>
  213. </el-form-item>
  214. <el-button :loading="loading" type="primary" class="phone-signIn" @click.native.prevent="handleFastLogin">
  215. {{ $t('login.login') }}
  216. </el-button>
  217. </el-form>
  218. <div class="make-easier">
  219. <!-- <p>{{ $t('common.makeEasier') }}</p> -->
  220. <!-- <BaseLink @click="goBackstage" :underline="false" type="primary">
  221. &nbsp;&nbsp;{{ $t('common.goBackstage') }}
  222. </BaseLink> -->
  223. </div>
  224. </div>
  225. </div>
  226. </div>
  227. </div>
  228. <!--忘记密码消息弹框盒子-->
  229. <el-dialog class="dialog" :title="$t('login.retrievePassword')" @close="resetForm" :visible.sync="messageBox"
  230. width="30%" center>
  231. <!--弹框主体-->
  232. <el-form ref="forgetDate" :model="forgetDate" :rules="getforgetRules" label-width="100px">
  233. <el-form-item :label="$t('login.phoneNumber') + $t('common.colon')" prop="userCellPhone" class="userCellPhone">
  234. <div style="display: flex">
  235. <el-input v-model="forgetDate.userCellPhone" :placeholder="$t('login.select03')" />
  236. <div class="time-button ml10">
  237. <el-button v-show="showVerification" type="primary" @click="sendVerification">
  238. {{ $t('login.sendVerification') }}
  239. </el-button>
  240. <el-button v-show="!showVerification" class="retry" disabled>{{ $t('login.retry') }}({{ count }})s
  241. </el-button>
  242. </div>
  243. </div>
  244. </el-form-item>
  245. <el-form-item :label="$t('login.verificationCode') + $t('common.colon')" prop="veriCode">
  246. <el-input v-model="forgetDate.veriCode" :placeholder="$t('login.select04')" />
  247. </el-form-item>
  248. <el-form-item :label="$t('login.newPassword') + $t('common.colon')" prop="password">
  249. <el-input v-model="forgetDate.password" :placeholder="$t('login.select05')" />
  250. </el-form-item>
  251. <el-form-item :label="$t('login.confirmPassword') + $t('common.colon')" prop="againPassword">
  252. <el-input v-model="forgetDate.againPassword" :placeholder="$t('login.select06')" />
  253. </el-form-item>
  254. </el-form>
  255. <!--弹框底部-->
  256. <span slot="footer" class="dialog-footer">
  257. <el-button @click="resetForm">{{ $t('showMessage.cancel') }}</el-button>
  258. <el-button type="primary" @click="submitForm">{{
  259. $t('showMessage.saveButton')
  260. }}</el-button>
  261. </span>
  262. </el-dialog>
  263. <!-- 试用到期/停用 -->
  264. <trialDialog v-if="trialDialog" :phone="phone" :trialDialog="trialDialog" @close="trialDialogClose"></trialDialog>
  265. <stopDialog v-if="stopDialog" :phone="phone" :stopDialog="stopDialog" @close="stopDialogClose"></stopDialog>
  266. <verifyDialog v-if="verifyDialog" :phone="phone" :verifyDialog="verifyDialog" @close="verifyDialogClose">
  267. </verifyDialog>
  268. <agreementDialog v-if="dialogAgreement" @close="agreementClose">
  269. </agreementDialog>
  270. <!-- 服务协议 -->
  271. <el-dialog :visible.sync="dialogService" width="35%" custom-class="service" :showClose="true"
  272. :before-close="serviceClose" :closeOnClickModal="true" :appendToBody="true">
  273. <serviceDialog @close="serviceClose"></serviceDialog>
  274. </el-dialog>
  275. </div>
  276. </template>
  277. <script>
  278. import Cookies from 'js-cookie'
  279. import zhJs from '../../lang/zh'
  280. import {
  281. validPassword,
  282. validUserCellPhone,
  283. validUserVeriCode,
  284. } from '@/utils/validate'
  285. // 客服
  286. import serviceDialog from './components/serviceDialog'
  287. // 服务协议
  288. import agreementDialog from './components/agreementDialog'
  289. // 试用到期
  290. import trialDialog from './components/trialDialog'
  291. // 停用
  292. import stopDialog from './components/stopDialog'
  293. //待核实
  294. import verifyDialog from './components/verifyDialog'
  295. import {
  296. register
  297. } from '@/model/signIn/index'
  298. import {
  299. retrievePassword,
  300. sendVeriCode,
  301. sendRegisterCode,
  302. getTenantInfoByUser,
  303. getcompList,
  304. } from '@/model/signIn/index'
  305. import {
  306. EventBus
  307. } from 'base-core-lib'
  308. import LangSelectText from '@/components/LangSelectText'
  309. import topColor from '@/layout/index/top/top-color'
  310. import {
  311. mapActions,
  312. mapGetters
  313. } from 'vuex'
  314. export default {
  315. name: 'Login',
  316. filters: {
  317. phoneFilter(val) {
  318. const reg = /^(.{3}).*(.{4})$/
  319. return val.replace(reg, '$1****$2')
  320. },
  321. },
  322. components: {
  323. LangSelectText,
  324. trialDialog,
  325. stopDialog,
  326. verifyDialog,
  327. agreementDialog,
  328. serviceDialog,
  329. topColor,
  330. },
  331. data() {
  332. const validPasswordRule = (rule, value, callback) => {
  333. if (!validPassword(value)) {
  334. callback(new Error(this.$t('login.verification01')))
  335. } else {
  336. callback()
  337. }
  338. }
  339. const validPasswordRule2 = (rule, value, callback) => {
  340. if (value === '') {
  341. callback(new Error(this.$t('login.verification02')))
  342. } else if (value !== this.forgetDate.password) {
  343. callback(new Error(this.$t('login.verification03')))
  344. } else {
  345. callback()
  346. }
  347. }
  348. const validUserVeriCodeRule = (rule, value, callback) => {
  349. if (!validUserVeriCode(value)) {
  350. callback(new Error(this.$t('login.verification04')))
  351. } else {
  352. callback()
  353. }
  354. }
  355. const validUserCellPhoneRule = (rule, value, callback) => {
  356. if (!validUserCellPhone(value)) {
  357. callback(new Error(this.$t('login.verification05')))
  358. } else {
  359. callback()
  360. }
  361. }
  362. return {
  363. compOptionList: [],
  364. compValue: '黑龙江中天昊元贸易有限公司',
  365. dialogService: false, //客服
  366. dialogAgreement: false, //服务协议
  367. phone: '',
  368. verifyDialog: false,
  369. stopDialog: false,
  370. trialDialog: false, //试用到期/试用未到期
  371. registerLoading: false,
  372. verification: true,
  373. disabledFlag: true,
  374. loginFlag: true,
  375. registerFlag: true,
  376. registerFormRules: {
  377. tenantName: [{
  378. required: true,
  379. message: this.$t('login.registerVerif01'),
  380. trigger: 'blur',
  381. }, ],
  382. tenantEnName: [{
  383. required: true,
  384. message: this.$t('login.registerVerif02'),
  385. trigger: 'blur',
  386. }, ],
  387. compSimpleNameEn: [{
  388. required: true,
  389. message: this.$t('login.registerVerif03'),
  390. trigger: 'blur',
  391. }, ],
  392. linkmanName: [{
  393. required: true,
  394. message: this.$t('login.registerVerif04'),
  395. trigger: 'blur',
  396. }, ],
  397. linkmanPhone: [{
  398. required: true,
  399. trigger: 'blur',
  400. validator: validUserCellPhoneRule.bind(this),
  401. }, ],
  402. password: [{
  403. required: true,
  404. trigger: 'blur',
  405. validator: validPasswordRule,
  406. // validator: validPasswordRule4.bind(this)
  407. }, ],
  408. confirmPassword: [{
  409. required: true,
  410. trigger: 'blur',
  411. validator: validPasswordRule,
  412. // validator: validPasswordRule3.bind(this)
  413. }, ],
  414. veriCode: [{
  415. required: true,
  416. trigger: 'blur',
  417. validator: validUserVeriCodeRule.bind(this),
  418. }, ],
  419. },
  420. // 注册表单
  421. registerForm: {
  422. tenantName: '',
  423. tenantEnName: '',
  424. compSimpleNameEn: '',
  425. tenantSource: '1',
  426. linkmanName: '',
  427. linkmanPhone: '',
  428. password: '',
  429. confirmPassword: '',
  430. veriCode: '',
  431. },
  432. tabsOne: true,
  433. zhArray: [], //国际化数组
  434. timer: null,
  435. loading: false,
  436. rememberMe: true,
  437. showDialog: false,
  438. showVerification: true,
  439. messageBox: false,
  440. passwordType: 'password',
  441. count: '',
  442. userCellPhone: '',
  443. userKind: '',
  444. forgetDate: {
  445. userCellPhone: '',
  446. password: '',
  447. againPassword: '',
  448. veriCode: '',
  449. },
  450. loginForm: {
  451. username: '',
  452. password: '',
  453. companyName: '', // 公司域名
  454. },
  455. queryLoginForm: {
  456. mobilePhone: '',
  457. veriCode: '',
  458. },
  459. queryRules: {
  460. mobilePhone: [{
  461. required: true,
  462. validator: validUserCellPhoneRule,
  463. trigger: 'change',
  464. }, ],
  465. veriCode: [{
  466. required: true,
  467. trigger: 'blur',
  468. validator: validUserVeriCodeRule,
  469. }, ],
  470. },
  471. companyLogoUrl: '',
  472. companyName: '',
  473. getforgetRules: {
  474. userCellPhone: [{
  475. required: true,
  476. trigger: 'blur',
  477. validator: validUserCellPhoneRule,
  478. }, ],
  479. veriCode: [{
  480. required: true,
  481. trigger: 'blur',
  482. validator: validUserVeriCodeRule,
  483. }, ],
  484. password: [{
  485. required: true,
  486. trigger: 'blur',
  487. validator: validPasswordRule,
  488. }, ],
  489. againPassword: [{
  490. required: true,
  491. trigger: 'blur',
  492. validator: validPasswordRule2,
  493. }, ],
  494. },
  495. getFormRules: {
  496. username: [{
  497. required: true,
  498. message: this.$t('login.verification06'),
  499. trigger: 'change',
  500. }, ],
  501. password: [{
  502. required: true,
  503. trigger: 'change',
  504. validator: validPasswordRule,
  505. // validator: validPasswordRule4.bind(this)
  506. }, ],
  507. companyName: {
  508. required: true,
  509. message: this.$t('login.verification08'),
  510. trigger: 'change',
  511. },
  512. },
  513. }
  514. },
  515. computed: {
  516. ...mapGetters(['systemVersion']),
  517. },
  518. mounted() {
  519. this.loginForm.companyName = Cookies.get('ws_login_companyShortName') ?
  520. Cookies.get('ws_login_companyShortName') :
  521. ''
  522. this.loginForm.username = Cookies.get('ws_login_account') ?
  523. Cookies.get('ws_login_account') :
  524. ''
  525. this.loginForm.password = Cookies.get('ws_login_pwd') ?
  526. Cookies.get('ws_login_pwd') :
  527. ''
  528. this.rememberMe = Cookies.get('ws_login_rememberMe') === '1'
  529. localStorage.setItem('ws_login_type', 2)
  530. const arr = JSON.parse(JSON.stringify(zhJs))
  531. this.loop(arr, null)
  532. if (this.loginForm.username === '') {
  533. this.$refs.username.focus()
  534. } else if (this.loginForm.password === '') {
  535. this.$refs.password.focus()
  536. }
  537. this.compList()
  538. },
  539. watch: {
  540. loginFlag(value) {
  541. if (value) {
  542. this.loginForm.domainName = Cookies.get('compSimpleName')
  543. this.loginForm.username = Cookies.get('phone')
  544. }
  545. },
  546. },
  547. methods: {
  548. ...mapActions('user', ['login', 'fastLogin']),
  549. async getTenantUser() {
  550. let newList = {
  551. companyName: this.loginForm.companyName,
  552. username: this.loginForm.username,
  553. password: this.loginForm.password,
  554. }
  555. const response = await getTenantInfoByUser(newList).toPromise()
  556. return response
  557. },
  558. compList() {
  559. getcompList()
  560. .toPromise()
  561. .then((res) => {
  562. console.log('公司下拉列表数据',res)
  563. this.compOptionList = res
  564. })
  565. .catch((err) => {})
  566. },
  567. serviceClose() {
  568. this.dialogService = false
  569. },
  570. agreementClose() {
  571. this.dialogAgreement = false
  572. },
  573. verifyDialogClose() {
  574. this.verifyDialog = false
  575. },
  576. // 停用
  577. stopDialogClose() {
  578. this.stopDialog = false
  579. },
  580. // 试用
  581. trialDialogClose() {
  582. this.trialDialog = false
  583. },
  584. goHome() {
  585. window.open('http://www.yinghaikeji.com', '_blank')
  586. },
  587. goRecordNum() {
  588. window.open('http://beian.miit.gov.cn', '_blank')
  589. },
  590. returnLogin() {
  591. this.$nextTick(function() {
  592. this.$refs.registerForm.resetFields()
  593. })
  594. clearInterval(this.timer)
  595. this.loginFlag = true
  596. },
  597. // 发送验证码
  598. toSend() {
  599. if (this.registerForm.linkmanPhone) {
  600. if (validUserCellPhone(this.registerForm.linkmanPhone)) {
  601. this.disabledFlag = false
  602. clearInterval(this.timer)
  603. this.timer = null
  604. const TIME_COUNT = 60
  605. if (!this.timer) {
  606. this.count = TIME_COUNT
  607. this.verification = false
  608. let data = {
  609. mobilePhone: this.registerForm.linkmanPhone,
  610. }
  611. sendRegisterCode(data)
  612. .toPromise()
  613. .then((res) => {
  614. this.timer = setInterval(() => {
  615. if (this.count > 0 && this.count <= TIME_COUNT) {
  616. this.count--
  617. } else {
  618. this.verification = true
  619. clearInterval(this.timer)
  620. this.timer = null
  621. }
  622. }, 1000)
  623. })
  624. .catch((err) => {
  625. this.verification = true
  626. })
  627. }
  628. } else {
  629. EventBus.$emit('error', this.$t('login.registerVerif09'))
  630. }
  631. } else {
  632. EventBus.$emit('error', this.$t('login.registerVerif05'))
  633. }
  634. },
  635. // 取消
  636. handleCancel() {
  637. clearInterval(this.timer)
  638. this.$nextTick(function() {
  639. this.$refs.registerForm.resetFields()
  640. })
  641. this.loginFlag = true
  642. },
  643. // 注册
  644. handleRegister() {
  645. this.$refs.registerForm.validate((valid) => {
  646. if (valid) {
  647. this.registerLoading = true
  648. register({
  649. ...this.registerForm,
  650. tenantName: this.registerForm.compSimpleNameEn,
  651. tenantEnName: this.registerForm.compSimpleNameEn,
  652. })
  653. .toPromise()
  654. .then((res) => {
  655. Cookies.set('compSimpleName', this.registerForm.compSimpleNameEn)
  656. Cookies.set('phone', this.registerForm.linkmanPhone)
  657. this.registerFlag = false
  658. this.registerLoading = false
  659. })
  660. .catch((error) => {
  661. this.registerLoading = false
  662. })
  663. } else {
  664. return false
  665. }
  666. })
  667. },
  668. toManage() {
  669. window.location.href = this.$store.getters.baseInfo.comanyMgrUrl
  670. },
  671. returnToLogin() {
  672. this.loginFlag = true
  673. },
  674. toRegister() {
  675. this.disabledFlag = true
  676. this.verification = true
  677. this.registerFlag = true
  678. this.$nextTick(function() {
  679. this.$refs.registerForm.resetFields()
  680. })
  681. clearInterval(this.timer)
  682. this.loginFlag = false
  683. },
  684. goBackstage() {
  685. // window.location.href = this.$store.getters.baseInfo.comanyMgrUrl
  686. },
  687. /* 忘记密码*/
  688. forgetPassword() {
  689. this.showVerification = true
  690. this.messageBox = true
  691. },
  692. /* 点击取消*/
  693. resetForm() {
  694. this.messageBox = false
  695. this.forgetDate.userCellPhone = ''
  696. this.forgetDate.veriCode = ''
  697. this.forgetDate.password = ''
  698. this.forgetDate.againPassword = ''
  699. this.$refs.forgetDate.resetFields()
  700. },
  701. /* 点击保存*/
  702. submitForm() {
  703. this.$refs.forgetDate.validate((valid) => {
  704. if (valid) {
  705. const data = {
  706. mobilePhone: this.forgetDate.userCellPhone,
  707. veriCode: this.forgetDate.veriCode,
  708. password: this.forgetDate.againPassword,
  709. }
  710. retrievePassword(data)
  711. .toPromise()
  712. .then((response) => {
  713. EventBus.$emit(
  714. 'success',
  715. this.$t('showMessage.modifySuccessfully')
  716. )
  717. this.messageBox = false
  718. })
  719. .catch((error) => {
  720. if (error.code === 'AUTH_004') {
  721. EventBus.$emit('error', this.$t('message.AUTH_004'))
  722. this.forgetDate.veriCode = ''
  723. } else if (error.code === 'AUTH_006') {
  724. EventBus.$emit('error', this.$t('message.AUTH_006'))
  725. this.forgetDate.againPassword = ''
  726. this.forgetDate.password = ''
  727. }
  728. })
  729. } else {
  730. EventBus.$emit('error', this.$t('showMessage.failToSave'))
  731. return false
  732. }
  733. })
  734. },
  735. /* 点击发送验证码*/
  736. sendVerification() {
  737. if (this.forgetDate.userCellPhone === '') {
  738. EventBus.$emit('error', this.$t('login.registerVerif05'))
  739. } else {
  740. clearInterval(this.timer)
  741. this.timer = null
  742. const TIME_COUNT = 60
  743. if (!this.timer) {
  744. this.count = TIME_COUNT
  745. this.showVerification = false
  746. this.postVerification()
  747. this.timer = setInterval(() => {
  748. if (this.count > 0 && this.count <= TIME_COUNT) {
  749. this.count--
  750. } else {
  751. this.showVerification = true
  752. clearInterval(this.timer)
  753. this.timer = null
  754. }
  755. }, 1000)
  756. }
  757. }
  758. },
  759. /* 发送验证码*/
  760. postVerification() {
  761. sendVeriCode({
  762. mobilePhone: this.forgetDate.userCellPhone
  763. })
  764. .toPromise()
  765. .then((response) => {})
  766. },
  767. /* 点击发送验证码*/
  768. fastSendVerification() {
  769. if (!this.queryLoginForm.mobilePhone) {
  770. EventBus.$emit('error', this.$t('login.verification05'))
  771. return
  772. }
  773. clearInterval(this.timer)
  774. this.timer = null
  775. const TIME_COUNT = 60
  776. if (!this.timer) {
  777. this.count = TIME_COUNT
  778. this.showVerification = false
  779. this.fastPostVerification()
  780. this.timer = setInterval(() => {
  781. if (this.count > 0 && this.count <= TIME_COUNT) {
  782. this.count--
  783. } else {
  784. this.showVerification = true
  785. clearInterval(this.timer)
  786. this.timer = null
  787. }
  788. }, 1000)
  789. }
  790. },
  791. /* 快捷登录发送验证码*/
  792. fastPostVerification() {
  793. sendVeriCode({
  794. mobilePhone: this.queryLoginForm.mobilePhone
  795. })
  796. .toPromise()
  797. .then((response) => {})
  798. // .catch(error => {
  799. // if (error.code === 'AUTH_003') {
  800. // EventBus.$emit('error', this.$t('message.AUTH_003'))
  801. // }
  802. // })
  803. },
  804. showPwd() {
  805. if (this.passwordType === 'password') {
  806. this.passwordType = ''
  807. } else {
  808. this.passwordType = 'password'
  809. }
  810. this.$nextTick(() => {
  811. this.$refs.password.focus()
  812. })
  813. },
  814. handleLogin() {
  815. this.$refs.loginForm.validate(async (valid) => {
  816. if (valid) {
  817. const res = await this.login(this.loginForm)
  818. localStorage.setItem('ws_login_type', 2)
  819. Cookies.set('ws_login_companyShortName', this.loginForm.companyName, {
  820. expires: 365,
  821. })
  822. Cookies.set('ws_login_account', this.loginForm.username, {
  823. expires: 365,
  824. })
  825. if (this.rememberMe) {
  826. Cookies.set('ws_login_pwd', this.loginForm.password, {
  827. expires: 365,
  828. })
  829. Cookies.set('ws_login_rememberMe', 1, {
  830. expires: 365
  831. })
  832. } else {
  833. Cookies.remove('ws_login_companyShortName')
  834. Cookies.remove('ws_login_account')
  835. Cookies.remove('ws_login_pwd')
  836. Cookies.set('ws_login_rememberMe', 0, {
  837. expires: 365
  838. })
  839. }
  840. const redirect = this.$route.query.redirect
  841. if (redirect) {
  842. this.$router.push(redirect)
  843. } else {
  844. this.$router.push('/')
  845. }
  846. const data = await this.getTenantUser()
  847. localStorage.setItem(
  848. 'ws_login_getTenantInfoByUser',
  849. JSON.stringify({
  850. ...data,
  851. loginInfo: res
  852. })
  853. )
  854. localStorage.setItem(
  855. 'ws_login_accountId',
  856. JSON.stringify(res.accountId)
  857. )
  858. } else {
  859. return false
  860. }
  861. })
  862. },
  863. loop(arr, father) {
  864. for (let i in arr) {
  865. if (typeof arr[i] == 'object') {
  866. if (father) {
  867. this.loop(arr[i], father + '.' + i)
  868. } else {
  869. this.loop(arr[i], i)
  870. }
  871. } else {
  872. let obj = {
  873. key: father + '.' + i,
  874. value: arr[i],
  875. }
  876. this.zhArray.push(obj)
  877. }
  878. }
  879. localStorage.setItem(
  880. 'InterNational_zh_array',
  881. JSON.stringify(this.zhArray)
  882. )
  883. },
  884. // 快捷登录
  885. handleFastLogin() {
  886. this.$refs['loginForm2'].validate(async (valid) => {
  887. if (valid) {
  888. const res = await this.fastLogin(this.queryLoginForm)
  889. localStorage.setItem('ws_login_type', 2)
  890. const redirect = this.$route.query.redirect
  891. if (redirect) {
  892. this.$router.push(redirect)
  893. } else {
  894. this.$router.push('/')
  895. }
  896. const {
  897. data
  898. } = await this.getTenantUser()
  899. localStorage.setItem(
  900. 'ws_login_getTenantInfoByUser',
  901. JSON.stringify({
  902. ...data,
  903. loginInfo: res
  904. })
  905. )
  906. localStorage.setItem(
  907. 'ws_login_accountId',
  908. JSON.stringify(res.accountId)
  909. )
  910. }
  911. })
  912. },
  913. },
  914. }
  915. </script>
  916. <style lang="scss" scoped>
  917. $svg: #a7a8a9;
  918. $dark_gray: #889aa4;
  919. .signin-container {
  920. display: flex;
  921. flex-direction: column;
  922. align-items: center;
  923. justify-content: center;
  924. min-height: 100%;
  925. width: 100%;
  926. background-repeat: no-repeat;
  927. background-position: center center;
  928. background-size: cover;
  929. overflow: hidden;
  930. .register-center {
  931. .register-title {
  932. padding-bottom: 20px;
  933. border-bottom: 1px solid #ccc;
  934. display: flex;
  935. justify-content: space-between;
  936. align-items: center;
  937. }
  938. .register-form {
  939. padding: 20px 30px;
  940. .form-tip {
  941. margin-top: 20px;
  942. color: #999999;
  943. font-size: 12px;
  944. }
  945. p {
  946. font-size: 14px;
  947. color: #333333;
  948. padding-bottom: 100px;
  949. line-height: 24px;
  950. }
  951. .registration-completed {
  952. width: 100%;
  953. border: 1px solid #1e6ced;
  954. background-color: #edf4ff;
  955. color: #1e6ced;
  956. }
  957. }
  958. /deep/ .el-form-item.is-required:not(.is-no-asterisk)>.el-form-item__label:before,
  959. .el-form-item.is-required:not(.is-no-asterisk) .el-form-item__label-wrap>.el-form-item__label:before {
  960. content: '';
  961. }
  962. /deep/ .el-form-item__content {
  963. line-height: 32px;
  964. }
  965. /deep/ .el-form-item__error {
  966. padding: 2px;
  967. }
  968. /deep/ .el-form-item__label {
  969. line-height: 12px;
  970. }
  971. /deep/ .el-input__inner {
  972. height: 34px;
  973. }
  974. /deep/ .el-form-item {
  975. margin-bottom: 20px;
  976. }
  977. .code_style {
  978. /*/deep/ .el-input{*/
  979. width: 65% !important;
  980. /*}*/
  981. }
  982. max-width: 480px;
  983. margin: 0 auto;
  984. width: 100%;
  985. background-color: #fff;
  986. padding: 20px;
  987. border-radius: 8px;
  988. .login-title {
  989. font-size: 26px;
  990. text-align: center;
  991. padding: 2%;
  992. color: #666;
  993. margin-bottom: 10%;
  994. display: inline-block;
  995. }
  996. .remember-information {
  997. cursor: pointer;
  998. padding-bottom: 50px;
  999. .forget-pwd {
  1000. display: inline-block;
  1001. white-space: nowrap;
  1002. color: #999;
  1003. font-size: 12px;
  1004. line-height: 19px;
  1005. }
  1006. }
  1007. .svg-container {
  1008. color: $svg;
  1009. width: 30px;
  1010. position: absolute;
  1011. height: 32px;
  1012. line-height: 32px;
  1013. border-radius: 8px;
  1014. top: 0;
  1015. left: 0;
  1016. z-index: 9;
  1017. }
  1018. .show-pwd {
  1019. position: absolute;
  1020. right: 14px;
  1021. top: 0;
  1022. font-size: 16px;
  1023. color: $dark_gray;
  1024. cursor: pointer;
  1025. user-select: none;
  1026. }
  1027. }
  1028. .login-box {
  1029. width: 420px;
  1030. display: flex;
  1031. flex-direction: column;
  1032. .login-head {
  1033. display: flex;
  1034. flex-direction: column;
  1035. align-items: center;
  1036. color: #fff;
  1037. font-size: 16px;
  1038. .logo {
  1039. background-image: url('../../../public/img/logo.png');
  1040. background-position: center center;
  1041. background-repeat: no-repeat;
  1042. width: 260px;
  1043. height: 68px;
  1044. background-size: 100% 100%;
  1045. }
  1046. &>span {
  1047. text-align: center;
  1048. }
  1049. }
  1050. .login-body {
  1051. display: flex;
  1052. padding: 5px 30px 15px;
  1053. flex-direction: column;
  1054. align-items: center;
  1055. height: 410px;
  1056. z-index: 1000;
  1057. position: relative;
  1058. &>ul {
  1059. color: #fff;
  1060. width: 100%;
  1061. list-style: none;
  1062. display: flex;
  1063. flex-direction: row;
  1064. flex-wrap: nowrap;
  1065. justify-content: center;
  1066. padding: 0;
  1067. margin: 0 0 32px 0;
  1068. li {
  1069. padding: 10px 0px;
  1070. cursor: pointer;
  1071. font-size: 18px;
  1072. &:nth-child(1) {
  1073. margin-right: 40px;
  1074. }
  1075. }
  1076. .selected {
  1077. border-bottom: 2px solid #fff;
  1078. font-weight: 600;
  1079. }
  1080. }
  1081. &>form {
  1082. align-self: center;
  1083. width: 100%;
  1084. /deep/.el-input__inner {
  1085. text-indent: 12px;
  1086. background-color: transparent;
  1087. border-left: none;
  1088. border-top: none;
  1089. border-right: none;
  1090. border-radius: 0;
  1091. border: 1px solid #e5e8ed!important;
  1092. color: #000;
  1093. padding: 0;
  1094. padding: 5px 10px;
  1095. border-radius: 30px;
  1096. }
  1097. /deep/ .el-input__inner::-webkit-input-placeholder {
  1098. color: #e5e8ed;
  1099. font-weight: bold;
  1100. }
  1101. /deep/.userCellPhone {
  1102. position: relative;
  1103. .el-form-item__label {
  1104. position: absolute;
  1105. top: 12px;
  1106. left: 9px;
  1107. }
  1108. .el-input__inner {
  1109. text-indent: 34px !important;
  1110. }
  1111. }
  1112. }
  1113. & .fastLoginForm {
  1114. margin-top: 38px;
  1115. }
  1116. .qiye {
  1117. background-image: url('../../assets/images/page/login/qiye.png');
  1118. background-repeat: no-repeat;
  1119. background-position: center center;
  1120. background-size: 55%;
  1121. }
  1122. .veriCode {
  1123. position: relative;
  1124. & /deep/.el-form-item__content {
  1125. display: flex;
  1126. flex-direction: row;
  1127. &>div:nth-child(1) {
  1128. width: 100%;
  1129. }
  1130. &>div:nth-child(2) {
  1131. width: 36%;
  1132. margin-left: 15px;
  1133. position: absolute;
  1134. right: 1px;
  1135. & .el-button {
  1136. width: 100% !important;
  1137. background: #fff;
  1138. border: 1px solid #fff;
  1139. color: #7cbe25;
  1140. span {
  1141. border-left: 1px solid #e9ecf0;
  1142. padding: 0 20px;
  1143. }
  1144. }
  1145. }
  1146. }
  1147. }
  1148. .remember-information {
  1149. cursor: pointer;
  1150. padding-bottom: 50px;
  1151. .forget-pwd {
  1152. display: inline-block;
  1153. white-space: nowrap;
  1154. // color: #fff;
  1155. font-size: 12px;
  1156. line-height: 19px;
  1157. }
  1158. }
  1159. .svg-container {
  1160. color: #a7a8a9;
  1161. width: 30px;
  1162. position: absolute;
  1163. height: 32px;
  1164. line-height: 32px;
  1165. border-radius: 8px;
  1166. top: 0;
  1167. left: 0;
  1168. z-index: 9;
  1169. text-align: center;
  1170. }
  1171. .show-pwd {
  1172. position: absolute;
  1173. right: 14px;
  1174. top: 0;
  1175. font-size: 16px;
  1176. color: #889aa4;
  1177. cursor: pointer;
  1178. user-select: none;
  1179. }
  1180. .make-easier {
  1181. display: flex;
  1182. color: #fff;
  1183. font-size: 12px;
  1184. text-align: center;
  1185. line-height: 32px;
  1186. p {
  1187. margin: 0;
  1188. }
  1189. span {
  1190. display: block;
  1191. color: #4489f9;
  1192. cursor: pointer;
  1193. font-weight: 600;
  1194. }
  1195. }
  1196. }
  1197. }
  1198. .login-footer {
  1199. text-align: center;
  1200. color: #9a9a9a;
  1201. padding: 2% 0;
  1202. font-size: 12px;
  1203. min-width: 456px;
  1204. &>ul {
  1205. display: flex;
  1206. margin: 0;
  1207. padding: 0;
  1208. width: 100%;
  1209. list-style: none;
  1210. flex-direction: row;
  1211. justify-content: center;
  1212. padding: 0 120px;
  1213. li {
  1214. padding: 0px 20px;
  1215. border-right: 1px solid #9a9a9a;
  1216. // cursor: pointer;
  1217. }
  1218. // TODO:英文还没有设计好先不上
  1219. // li:hover {
  1220. // color: #4489f9;
  1221. // }
  1222. &>li:last-child {
  1223. border-right: none;
  1224. }
  1225. }
  1226. .nav {
  1227. display: flex;
  1228. flex-direction: row;
  1229. justify-content: center;
  1230. }
  1231. .copyright {
  1232. padding: 5px 0;
  1233. }
  1234. .version {
  1235. font-weight: bold;
  1236. padding: 4% 0;
  1237. display: block;
  1238. color: #666;
  1239. font-size: 15px;
  1240. }
  1241. .project-name {
  1242. font-weight: 600;
  1243. font-size: 16px;
  1244. }
  1245. }
  1246. }
  1247. .register-container {
  1248. overflow: auto;
  1249. .register-box {
  1250. margin: 20px 0;
  1251. }
  1252. .signin-box {
  1253. z-index: 100;
  1254. display: flex;
  1255. flex-direction: column;
  1256. justify-content: center;
  1257. }
  1258. }
  1259. .login-box {
  1260. width: 420px;
  1261. margin: 0 auto;
  1262. }
  1263. @-webkit-keyframes animate-cloud {
  1264. from {
  1265. background-position: 600px 100%;
  1266. }
  1267. to {
  1268. background-position: 0 100%;
  1269. }
  1270. }
  1271. @-moz-keyframes animate-cloud {
  1272. from {
  1273. background-position: 600px 100%;
  1274. }
  1275. to {
  1276. background-position: 0 100%;
  1277. }
  1278. }
  1279. @-ms-keyframes animate-cloud {
  1280. from {
  1281. background-position: 600px 100%;
  1282. }
  1283. to {
  1284. background-position: 0 100%;
  1285. }
  1286. }
  1287. @-o-keyframes animate-cloud {
  1288. from {
  1289. background-position: 600px 100%;
  1290. }
  1291. to {
  1292. background-position: 0 100%;
  1293. }
  1294. }
  1295. //新增
  1296. .sign_up {
  1297. text-align: center;
  1298. width: 100%;
  1299. .signIn-buttom {
  1300. width: 75%;
  1301. margin-bottom: 10px;
  1302. border-radius: 20px;
  1303. }
  1304. .register-buttom {
  1305. width: 15%;
  1306. margin: 0 auto;
  1307. // color: #fff;
  1308. display: block;
  1309. text-align: center;
  1310. font-size: 12px;
  1311. cursor: pointer;
  1312. }
  1313. }
  1314. .phone-signIn {
  1315. width: 100%;
  1316. border-radius: 20px;
  1317. display: block;
  1318. margin: 0 auto;
  1319. background: #7cbe25;
  1320. color: #fff;
  1321. border: 1px solid #7cbe25;
  1322. padding: 20px !important;
  1323. line-height: 2px;
  1324. }
  1325. .registerSuccess {
  1326. font-size: 30px;
  1327. height: 28px;
  1328. margin-left: 9px;
  1329. line-height: 24px;
  1330. font-weight: bold;
  1331. color: rgb(51, 51, 51);
  1332. }
  1333. /deep/ .service {
  1334. border-radius: 7px !important;
  1335. /deep/ .el-dialog__header {
  1336. display: none;
  1337. }
  1338. /deep/ .el-dialog__body {
  1339. padding: 0 !important;
  1340. }
  1341. }
  1342. .signin-box {
  1343. >>>.el-form-item__label {
  1344. line-height: 12px !important;
  1345. }
  1346. }
  1347. .comp-select{
  1348. width: 100%;
  1349. }
  1350. </style>