index.vue 18 KB

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