index.vue 17 KB

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