index.vue 18 KB

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