index.vue 16 KB

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