index.vue 18 KB

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