index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. <script setup>
  2. import { ref, onMounted, computed } from 'vue'
  3. import QrCode from '@/components/QrCode.vue'
  4. import { post } from '@/utils/request'
  5. import { userToken } from '@/composables/config'
  6. import { userApi } from '@/api/user'
  7. import { ucardApi } from '@/api/ucard'
  8. import { customApi } from '@/service/custom'
  9. import useGlobalStore from '@/stores/use-global-store'
  10. import useUserStore from '@/stores/use-user-store'
  11. import useRouter from '@/hooks/useRouter'
  12. import { useI18n } from 'vue-i18n'
  13. import companyLogo from '@/static/images/logo4.png'
  14. import LoginHeaderGroup from './components/LoginHeaderGroup.vue'
  15. const router = useRouter()
  16. const { t } = useI18n()
  17. const userStore = useUserStore()
  18. const globalStore = useGlobalStore()
  19. const modeStore = computed(() => globalStore.mode)
  20. // 响应式表单数据
  21. const form = ref({
  22. loginName: '',
  23. password: '',
  24. })
  25. function submit() {
  26. if (!form.value.loginName) {
  27. uni.$u.toast(t('signin.form.email'))
  28. return
  29. }
  30. if (!form.value.password) {
  31. uni.$u.toast(t('signin.form.password'))
  32. return
  33. }
  34. handleLogin()
  35. }
  36. const customStyle = {
  37. height: '44px',
  38. 'border-radius': '8px',
  39. background: '#f7f8fa',
  40. padding: '0 20px !important',
  41. position: 'relative',
  42. }
  43. const remenber = ref([])
  44. const checkboxChange = (e) => {
  45. remenber.value = e
  46. }
  47. const fetchUserList = (params) => post('/Login/AcctLogin', params)
  48. async function handleLogin() {
  49. try {
  50. const res = await userApi.login({
  51. loginName: form.value.loginName,
  52. password: form.value.password,
  53. })
  54. if (res.code === 200) {
  55. userToken.value = res.data
  56. uni.$u.toast(t('login.msg0_1'))
  57. getCustomLoginInfo()
  58. // getCardUserInfo();
  59. reasonsRefusalList()
  60. if (remenber.value.length) {
  61. userStore.saveAccountInfo({
  62. loginName: form.value.loginName,
  63. password: form.value.password,
  64. rememberPassword: true,
  65. })
  66. } else {
  67. userStore.saveAccountInfo({
  68. loginName: '',
  69. password: '',
  70. rememberPassword: false,
  71. })
  72. }
  73. // console.log(1111);
  74. } else {
  75. uni.showToast({ title: res.msg })
  76. // console.log(12112);
  77. }
  78. } catch (error) {
  79. // console.log(error, 19089);
  80. }
  81. }
  82. async function getCustomLoginInfo() {
  83. try {
  84. const res = await userApi.getUserInfo()
  85. userStore.saveUserInfo(res.data)
  86. if (res.code === 200) {
  87. router.reLaunch(modeStore.value === 'customer' ? '/pages/customer/index' : '/pages/ib/index')
  88. } else {
  89. uni.$u.toast(res.msg || t('login.msg0'))
  90. }
  91. } catch (error) {
  92. // console.log(error, 111);
  93. }
  94. }
  95. async function getCardUserInfo() {
  96. try {
  97. const res = await ucardApi.getSingle()
  98. userStore.saveUserInfo(res.data)
  99. if (res.code === 200) {
  100. if (!res.data || res.data.approveStatus != 2) {
  101. router.push('/pages/mine/improve')
  102. } else {
  103. router.push('/pages/card/index')
  104. }
  105. } else {
  106. uni.$u.toast(res.msg || t('login.msg0'))
  107. }
  108. } catch (error) {
  109. // console.log(error, 111);
  110. }
  111. }
  112. async function reasonsRefusalList() {
  113. try {
  114. const res = await customApi.reasonsRefusalList()
  115. if (res.code === 200) {
  116. pickFields(res.data)
  117. } else {
  118. uni.$u.toast(res.msg || t('login.msg0'))
  119. }
  120. } catch (error) {
  121. // console.log(error, 111);
  122. }
  123. }
  124. function pickFields(source, fields = ['content', 'enContent']) {
  125. const result = {}
  126. Object.entries(source).forEach(([key, value]) => {
  127. result[key] = fields.reduce((acc, f) => {
  128. acc[f] = value[f] ?? null
  129. return acc
  130. }, {})
  131. })
  132. userStore.saveReasonsOptions(result)
  133. }
  134. onMounted(() => {
  135. const hostParts = window.location.host.split('.')
  136. ho.value = hostParts.length > 1 ? hostParts[1] : ''
  137. const accountInfo = userStore.accountInfo
  138. if (accountInfo?.rememberPassword) {
  139. form.value.loginName = accountInfo?.loginName || ''
  140. form.value.password = accountInfo?.password || ''
  141. remenber.value = ['记住我']
  142. } else {
  143. form.value.loginName = ''
  144. form.value.password = ''
  145. remenber.value = []
  146. }
  147. })
  148. const inputType = ref('password')
  149. const ho = ref('')
  150. </script>
  151. <template>
  152. <view class="login-page" :isHeaderFixed="true" :isLoginPage="true">
  153. <view class="main-content">
  154. <cwg-match-media :min-width="991">
  155. <view class="global-header-bar pc-header">
  156. <view class="header-inner">
  157. <view class="logo-placeholder"></view> <!-- 左侧可预留放logo或留空 -->
  158. <LoginHeaderGroup text-color="#fff" icon-color="#fff" />
  159. </view>
  160. </view>
  161. </cwg-match-media>
  162. <!-- 移动端顶部栏:悬浮在上方,深色文字 -->
  163. <cwg-match-media :max-width="991">
  164. <view class="mobile-header-bar">
  165. <LoginHeaderGroup text-color="#141d22" icon-color="#141d22" />
  166. </view>
  167. </cwg-match-media>
  168. <uni-row class="demo-uni-row">
  169. <cwg-match-media :min-width="991">
  170. <uni-col :xs="24" :sm="24" :md="12" :lg="14" :xl="16">
  171. <view class="left-bg">
  172. <view class="left-box">
  173. <view class="inner">
  174. <view class="section-title">
  175. <text class="bg-secondary-opacity subtitle w-40" v-t="'newLoop.item11'"></text>
  176. </view>
  177. <view class="title w-700">
  178. {{`${t('newLoop.item12')} `}}
  179. <text class="color-white" v-t="'newLoop.item13'"></text>
  180. </view>
  181. <view class="text-white" v-t="'newLoop.item14'"></view>
  182. </view>
  183. <image src="/static/images/trust-pilot.png" class="img-fluid mt--10" mode="widthFix"></image>
  184. <view class="left-content">
  185. <view class="des text-white">
  186. <text v-html="t('newSignin.item12')"></text>
  187. <br />
  188. <text v-html="t('newSignin.item12_1')"></text>
  189. <br />
  190. <text v-html="t('newSignin.item10')"></text>
  191. <br />
  192. <text v-html="t('newSignin.item11')"></text>
  193. <br />
  194. <text v-t="'newSignin.item13'"></text>
  195. <a
  196. :href="`https://www.${ho}.com/doc/Risk-Disclosures-and-Acknowledgements-2020-08.pdf`"
  197. target="_blank"
  198. v-t="'newSignin.item13_1'"
  199. class="doc-link"
  200. ></a>
  201. <text v-t="'newSignin.item13_2'"></text>
  202. <!-- <view v-t="'newSignin.item13_3'"></view>
  203. <text v-t="'newSignin.item13_4'"></text> -->
  204. </view>
  205. </view>
  206. </view>
  207. </view>
  208. </uni-col>
  209. </cwg-match-media>
  210. <uni-col :xs="24" :sm="24" :md="12" :lg="10" :xl="8" class="right-f">
  211. <view class="account">
  212. <cwg-match-media :max-width="991">
  213. <view class="company u-flex-y u-flex-y-center">
  214. <image src="/static/images/logo.png" class="company-icon" mode="widthFix"></image>
  215. </view>
  216. </cwg-match-media>
  217. <view class="title">
  218. <view class="tit1">{{ t('newSignin.item1') }}</view>
  219. <view class="tit2">{{ t('newSignin.item2') }}</view>
  220. </view>
  221. <view>
  222. <up-form :model="form" ref="uFormRef">
  223. <up-form-item label="" prop="loginName">
  224. <up-input :customStyle="customStyle" v-model="form.loginName" border="none"
  225. :placeholder="t('signin.form.email')">
  226. <template #prefix>
  227. <cwg-icon name="email-outline" :size="20" color="#000" />
  228. </template>
  229. </up-input>
  230. </up-form-item>
  231. <up-form-item label="" prop="password">
  232. <up-input :customStyle="customStyle" v-model="form.password" :type="inputType" border="none"
  233. :placeholder="t('signin.form.password')">
  234. <template #prefix>
  235. <cwg-icon name="lock-outline" :size="20" color="#000" />
  236. </template>
  237. </up-input>
  238. </up-form-item>
  239. </up-form>
  240. </view>
  241. <view class="u-flex u-flex-between u-flex-y-center mb1">
  242. <view class="check-box">
  243. <up-checkbox-group v-model="remenber" @change="checkboxChange">
  244. <up-checkbox size="14" labelSize="14" labelColor="#666666" activeColor="#ea002a"
  245. :label="t('newSignin.item5')" name="记住我" class="wcg-checkbox"></up-checkbox>
  246. </up-checkbox-group>
  247. </view>
  248. <navigator url="/pages/login/reset" class="account-tip">
  249. <text>{{ t('signin.forget') }}</text>
  250. </navigator>
  251. </view>
  252. <view class="cwg-button">
  253. <u-button type="primary" class="" @click="submit">
  254. {{ t('signin.login') }}
  255. </u-button>
  256. </view>
  257. <navigator url="/pages/login/regist" class="account-tip">
  258. {{ t('signin.words') }}
  259. <text>{{ t('signin.signup') }}</text>
  260. </navigator>
  261. <cwg-match-media :min-width="791">
  262. <!-- <view class="qr-container">
  263. <view class="qr-title">
  264. <view class="line"></view>
  265. <view class="qr-tit2">{{ t('newSignin.item2') }}</view>
  266. <view class="line"></view>
  267. </view>
  268. <QrCode width="200" height="200" text="cardGuide" :logo="logoImage"></QrCode>
  269. </view> -->
  270. </cwg-match-media>
  271. </view>
  272. </uni-col>
  273. </uni-row>
  274. </view>
  275. </view>
  276. </template>
  277. <style lang="scss" scoped>
  278. @import "@/uni.scss";
  279. :deep(uni-content) {
  280. padding-left: 0 !important;
  281. }
  282. .login-page {
  283. height: 100vh;
  284. border: none;
  285. padding: 0;
  286. position: relative;
  287. display: flex;
  288. flex-direction: column;
  289. }
  290. .global-header-bar {
  291. width: 100%;
  292. height: px2rpx(60);
  293. display: flex;
  294. align-items: center;
  295. justify-content: center;
  296. flex-shrink: 0;
  297. z-index: 100;
  298. &.pc-header {
  299. background-color: transparent;
  300. }
  301. .header-inner {
  302. width: 100%;
  303. padding: 0 5%;
  304. display: flex;
  305. justify-content: space-between; /* 两端对齐,可放logo和组件 */
  306. align-items: center;
  307. }
  308. }
  309. .mobile-header-bar {
  310. position: absolute;
  311. top: px2rpx(20);
  312. right: px2rpx(20);
  313. z-index: 10;
  314. }
  315. .main-content {
  316. flex: 1;
  317. overflow: hidden;
  318. background-image: url(/static/images/login-bg.gif);
  319. background-repeat: no-repeat;
  320. background-size: cover;
  321. background-position: center center;
  322. }
  323. .demo-uni-row {
  324. height: 100%;
  325. margin: 0 !important;
  326. .left-bg {
  327. height: 100%;
  328. min-height: calc(100vh - 120px);
  329. display: flex;
  330. flex-direction: column;
  331. align-items: center;
  332. .left-box {
  333. display: flex;
  334. flex-direction: column;
  335. justify-content: center;
  336. align-items: flex-start;
  337. width: 60%;
  338. //margin-top: px2rpx(20);
  339. .inner {
  340. width: 100%;
  341. text-align: start;
  342. margin-bottom: px2rpx(20);
  343. .section-title {
  344. margin-top: px2rpx(10);
  345. margin-bottom: px2rpx(10);
  346. }
  347. .title {
  348. font-size: px2rpx(50);
  349. line-height: 1;
  350. color: #fff;
  351. font-weight: 700;
  352. }
  353. .w-700 {
  354. font-weight: 700;
  355. }
  356. .subtitle {
  357. width: 45%;
  358. font-size: px2rpx(18);
  359. letter-spacing: px2rpx(1);
  360. display: block;
  361. margin-bottom: px2rpx(24);
  362. color: #ffffff;
  363. line-height: px2rpx(15);
  364. font-weight: 500;
  365. padding: px2rpx(10) px2rpx(20);
  366. border-radius: px2rpx(100);
  367. text-transform: uppercase;
  368. background-color: #e61f1e;
  369. text-align: center;
  370. }
  371. .w-40 {
  372. max-width: 40%;
  373. }
  374. .text-white {
  375. margin-top: px2rpx(10);
  376. font-size: px2rpx(14);
  377. line-height: 1.6;
  378. color: #fff;
  379. }
  380. }
  381. .img-fluid {
  382. width: 100%;
  383. max-width: px2rpx(240);
  384. }
  385. .mt--10 {
  386. margin-top: px2rpx(10);
  387. }
  388. .h1 {
  389. // text-align: center;
  390. color: #fff;
  391. font-size: 30px;
  392. margin-top: 30px;
  393. line-height: 1.5;
  394. }
  395. .h6 {
  396. text-align: start;
  397. line-height: 20px;
  398. color: #fff;
  399. font-size: 14px;
  400. margin-top: 10px;
  401. }
  402. .company {
  403. padding: px2rpx(10) 0 px2rpx(10) 0;
  404. position: relative;
  405. align-items: flex-start !important;
  406. width: 100%;
  407. }
  408. }
  409. .left-content {
  410. width: 100%;
  411. .des {
  412. text-align: start;
  413. line-height: 24px;
  414. color: #fff;
  415. font-size: 14px;
  416. margin-top: px2rpx(20);
  417. :nth-child(n) {
  418. display: inline;
  419. word-break: break-all;
  420. word-wrap: break-word;
  421. }
  422. .doc-link {
  423. color: var(--color-error);
  424. text-decoration: underline;
  425. margin: 0 px2rpx(4);
  426. }
  427. }
  428. }
  429. }
  430. .right-f {
  431. background-color: var(--color-white);
  432. padding: 0 px2rpx(24);
  433. height: 100%;
  434. box-sizing: border-box;
  435. .account {
  436. background-color: var(--color-white);
  437. position: relative;
  438. height: calc(100vh - 120px);
  439. display: flex;
  440. flex-direction: column;
  441. justify-content: center;
  442. padding: 0 10%;
  443. .company {
  444. padding: px2rpx(50) 0 px2rpx(20) 0;
  445. position: relative;
  446. align-items: center !important;
  447. }
  448. .company-icon {
  449. width: px2rpx(234);
  450. }
  451. }
  452. }
  453. }
  454. .bottom-box {
  455. width: 100%;
  456. height: 60px;
  457. background-color: var(--color-white);
  458. display: flex;
  459. justify-content: center;
  460. align-items: center;
  461. color: #000;
  462. .bottom-title {
  463. text-align: center;
  464. font-size: px2rpx(14);
  465. font-weight: 500;
  466. line-height: 1.5;
  467. color: #666666;
  468. }
  469. .ellipsis {
  470. width: px2rpx(200);
  471. white-space: nowrap;
  472. overflow: hidden;
  473. text-overflow: ellipsis;
  474. }
  475. .cwg-button {
  476. width: 120px !important;
  477. padding: px2rpx(4) 0 !important;
  478. }
  479. }
  480. button {
  481. background-color: #ea002a;
  482. font-size: px2rpx(14);
  483. font-weight: normal;
  484. height: px2rpx(44);
  485. line-height: px2rpx(44);
  486. }
  487. .right-f .account .company {
  488. padding: px2rpx(50) 0 px2rpx(200) 0;
  489. position: relative;
  490. align-items: flex-start !important;
  491. }
  492. .logo {
  493. margin-left: px2rpx(48);
  494. }
  495. .left-bg .company-icon {
  496. width: px2rpx(234);
  497. }
  498. .left-bg .left-content {
  499. position: relative;
  500. z-index: 1;
  501. }
  502. .title {
  503. margin: px2rpx(32) 0;
  504. font-size: px2rpx(24);
  505. font-weight: bolder;
  506. color: #e4e4e4;
  507. text-align: center;
  508. i {
  509. margin-right: px2rpx(10);
  510. }
  511. .tit1 {
  512. font-size: px2rpx(34);
  513. line-height: 1.5;
  514. font-weight: bold;
  515. color: #000000;
  516. }
  517. .tit2 {
  518. font-size: px2rpx(16);
  519. line-height: 1.5;
  520. color: #cecece;
  521. font-weight: 500;
  522. }
  523. }
  524. .qr-title {
  525. font-size: px2rpx(16);
  526. line-height: 1.5;
  527. color: #cecece;
  528. font-weight: 500;
  529. text-align: center;
  530. margin: px2rpx(40) 0;
  531. display: flex;
  532. align-items: center;
  533. justify-content: center;
  534. .line {
  535. flex: 1;
  536. height: 1px;
  537. background-color: #e4e4e4;
  538. }
  539. .qr-tit2 {
  540. margin: 0 px2rpx(12);
  541. }
  542. }
  543. .input {
  544. height: px2rpx(44);
  545. border-radius: px2rpx(8);
  546. background: #f7f8fa;
  547. padding: 0 px2rpx(20) !important;
  548. position: relative;
  549. }
  550. .account-icon {
  551. width: px2rpx(12);
  552. height: px2rpx(14) !important;
  553. margin-right: px2rpx(5);
  554. }
  555. :deep(.u-input__content__prefix-icon) {
  556. height: px2rpx(20);
  557. }
  558. .regiset-btn {
  559. margin: px2rpx(20) 0;
  560. }
  561. .account-tip {
  562. color: #666666;
  563. font-size: px2rpx(14);
  564. text-align: center;
  565. text {
  566. color: #ea002a;
  567. }
  568. }
  569. :deep(.u-form-item__body) {
  570. padding: 0 !important;
  571. padding-bottom: px2rpx(24) !important;
  572. }
  573. :deep(.wcg-checkbox) {
  574. padding: 0 !important;
  575. }
  576. .cwg-button {
  577. padding: px2rpx(34) 0 !important;
  578. }
  579. </style>