index.vue 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420
  1. <template>
  2. <view class="login-page bg-body" :isHeaderFixed="true" :isLoginPage="true" :class="{'dark': isDark}">
  3. <view class="fixed" />
  4. <view class="main-content">
  5. <uni-row class="demo-uni-row">
  6. <cwg-match-media :min-width="991" style="height: 100%;">
  7. <uni-col :xs="24" :sm="24" :md="12" :lg="14" :xl="16" style="height: 100%">
  8. <view class="left-bg">
  9. <view class="left-box">
  10. <view class="inner">
  11. <view class="title w-700">
  12. {{ `${t('newLoop.item12')} ` }}
  13. <text class="color-white" v-t="'newLoop.item13'"></text>
  14. </view>
  15. <view class="text-white" v-t="'newLoop.item14'"></view>
  16. </view>
  17. <view class="left-content">
  18. <view class="des text-white">
  19. <text v-html="t('newSignin.item12')"></text>
  20. <br />
  21. <text v-html="t('newSignin.item12_1')"></text>
  22. <br />
  23. <text v-html="t('newSignin.item10')"></text>
  24. <br />
  25. <text v-html="t('newSignin.item11')"></text>
  26. <br />
  27. <text v-t="'newSignin.item13'"></text>
  28. <!-- <cwg-link type="pdf" :title="'newSignin.item13_1'"-->
  29. <!-- :url="`pdf/Risk-Disclosures-and-Acknowledgements-2020-08.pdf`" target="_blank"-->
  30. <!-- v-t="'newSignin.item13_1'" class="doc-link" />-->
  31. <text v-t="'newSignin.item13_2'"></text>
  32. <!-- <view v-t="'newSignin.item13_3'"></view>
  33. <text v-t="'newSignin.item13_4'"></text> -->
  34. </view>
  35. </view>
  36. <!-- <image src="/static/images/trust-pilot.png" class="img-fluid mt&#45;&#45;10" mode="widthFix"></image>-->
  37. </view>
  38. </view>
  39. </uni-col>
  40. </cwg-match-media>
  41. <uni-col :xs="24" :sm="24" :md="12" :lg="10" :xl="8" class="right-f">
  42. <cwg-match-media :min-width="991">
  43. <view class="global-header-bar pc-header">
  44. <view class="header-inner">
  45. <view class="logo-placeholder"></view> <!-- 左侧可预留放logo或留空 -->
  46. <LoginHeaderGroup text-color="#fff" :icon-color="isDark ? '#fff' : '#97A1C0' " />
  47. </view>
  48. </view>
  49. </cwg-match-media>
  50. <!-- 移动端顶部栏:悬浮在上方,深色文字 -->
  51. <cwg-match-media :max-width="991">
  52. <view class="mobile-header-bar">
  53. <!-- <view class="fixed"/>-->
  54. <LoginHeaderGroup text-color="#fff" :icon-color="isDark ? '#fff' : '#97A1C0' "/>
  55. </view>
  56. </cwg-match-media>
  57. <view class="account">
  58. <view class="company u-flex-y u-flex-y-center">
  59. <image v-if="!isDark" src="/static/images/vu/logo-full.svg" :class="isMobile?'company-icon-mini':'company-icon'" mode="widthFix"></image>
  60. <image v-else src="/static/images/vu/logo-full-white.svg" :class="isMobile?'company-icon-mini':'company-icon'" mode="widthFix"></image>
  61. </view>
  62. <view class="tab-list">
  63. <view v-for="tab in tabs" :key="tab.value" class="tab-item" :class="{ active: activeTab === tab.value }"
  64. @click="handleClick(tab.value)">
  65. <text class="tab-label">{{ tab.text }}</text>
  66. </view>
  67. </view>
  68. <view v-show="activeTab == 1" style="overflow-y: scroll;">
  69. <view class="title">
  70. <view class="tit1">{{ t('newSignin.item1') }}</view>
  71. <view class="tit2">{{ t('newSignin.item2') }}</view>
  72. </view>
  73. <view>
  74. <uni-forms ref="uFormRef" :model="form" labelWidth="200" label-position="top">
  75. <uni-forms-item :label="t('newSignup.item7')" prop="loginName">
  76. <up-input :customStyle="customStyle" v-model="form.loginName" border="none"
  77. :placeholder="t('signin.form.email')">
  78. </up-input>
  79. </uni-forms-item>
  80. <uni-forms-item :label="t('signin.form.password')" prop="password">
  81. <up-input :customStyle="customStyle" v-model="form.password" :type="inputType" border="none"
  82. :placeholder="t('signin.form.password')">
  83. </up-input>
  84. </uni-forms-item>
  85. </uni-forms>
  86. </view>
  87. <view class="u-flex u-flex-between u-flex-y-center mb1">
  88. <view class="check-box">
  89. <up-checkbox-group v-model="remenber" @change="checkboxChange">
  90. <up-checkbox size="18" labelSize="18" labelColor="#666666" activeColor="#ea002a"
  91. :label="t('newSignin.item5')" name="记住我" class="wcg-checkbox"></up-checkbox>
  92. </up-checkbox-group>
  93. </view>
  94. <navigator url="/pages/login/reset" class="account-tip">
  95. <text>{{ t('signin.forget') }}</text>
  96. </navigator>
  97. </view>
  98. <view class="cwg-button">
  99. <u-button type="primary" class="" @click="submit">
  100. {{ t('signin.login') }}
  101. </u-button>
  102. </view>
  103. <view @click="activeTab = 2" class="account-tip">
  104. {{ t('signin.words') }}
  105. <text>{{ t('signin.signup') }}</text>
  106. </view>
  107. </view>
  108. <view v-show="activeTab == 2" style="overflow-y: scroll;">
  109. <view class="title">
  110. <view class="tit1">{{ t('newSignup.item1') }}</view>
  111. <view class="tit2">{{ t('newSignup.item2') }}</view>
  112. </view>
  113. <view>
  114. <uni-forms ref="regForm" :modelValue="formData" :rules="rules" validate-trigger="blur"
  115. label-position="top" label-width="120">
  116. <uni-row :gutter="20" class="formContent">
  117. <uni-col :xs="24" :md="12">
  118. <uni-forms-item name="country" :label="t('newSignup.item3')">
  119. <cwg-combox v-model:value="formData.country" :options="countryOptions" border="none" filterable>
  120. </cwg-combox>
  121. </uni-forms-item>
  122. </uni-col>
  123. <uni-col :xs="24" :md="12">
  124. <uni-forms-item name="phone" :label="t('newSignup.item5')">
  125. <up-input :customStyle="customStyle" v-model="formData.phone" border="none" :placeholder="t('newSignup.item5')"></up-input>
  126. </uni-forms-item>
  127. </uni-col>
  128. <uni-col :xs="24" :md="12">
  129. <uni-forms-item name="birthDate" :label="t('newSignup.item18')">
  130. <uni-datetime-picker type="date" v-model="formData.birthDate"
  131. :placeholder="t('newSignup.item19')" @change="checkAge" />
  132. </uni-forms-item>
  133. </uni-col>
  134. <uni-col :xs="24" :md="12">
  135. <uni-forms-item name="email" :label="t('newSignup.item7')">
  136. <up-input :customStyle="customStyle" v-model="formData.email" :placeholder="t('newSignup.item8')" border="none"
  137. :disabled="!isAgeValid || !formData.birthDate"></up-input>
  138. </uni-forms-item>
  139. </uni-col>
  140. <uni-col :xs="24" :md="24">
  141. <uni-forms-item name="emailCode" :label="t('newSignup.item9')">
  142. <view style="display: flex;">
  143. <view style="flex: 1;">
  144. <up-input :customStyle="customStyle" class="code" border="none" :disabled="!isAgeValid || !formData.birthDate" v-model="formData.emailCode"
  145. :placeholder="t('newSignup.item10')">
  146. </up-input>
  147. </view>
  148. <view class="btn-code" @click="(!isAgeValid || !formData.birthDate) ? '' : handleGetCode()">
  149. {{ getCodeString }}
  150. </view>
  151. </view>
  152. </uni-forms-item>
  153. </uni-col>
  154. <uni-col :xs="24" :md="24">
  155. <view class="agreemnet9">*{{ t('signup.agreemnet9') }}</view>
  156. </uni-col>
  157. <uni-col :xs="24" :md="12">
  158. <uni-forms-item name="password" :label="t('newSignup.item12')">
  159. <up-input border="none" :customStyle="customStyle" v-model.trim="formData.password" :disabled="!isAgeValid || !formData.birthDate"
  160. :placeholder="t('newSignup.item13')" type="password"></up-input>
  161. </uni-forms-item>
  162. <uni-col :xs="24" :md="24">
  163. <uni-forms-item>
  164. <ul class="pwd">
  165. <li :class="{ fit: rule1 }" v-t="'signup.form.rules.1st'"></li>
  166. <li :class="{ fit: rule2 }" v-t="'signup.form.rules.2nd'"></li>
  167. <li :class="{ fit: rule3 }" v-t="'signup.form.rules.3rd'"></li>
  168. </ul>
  169. </uni-forms-item>
  170. </uni-col>
  171. </uni-col>
  172. <uni-col :xs="24" :md="12">
  173. <uni-forms-item v-if="!isRouteHasId" name="linkValue" :label="t('newSignup.item14')">
  174. <up-input border="none" :customStyle="customStyle" v-model.trim="formData.linkValue" :disabled="!isAgeValid || !formData.birthDate"
  175. :placeholder="t('newSignup.item15')" @input="limitAgentIdLength"></up-input>
  176. </uni-forms-item>
  177. </uni-col>
  178. </uni-row>
  179. <uni-forms-item name="agree">
  180. <view class="check-box" @click="toggleAgree">
  181. <up-checkbox-group v-model="agreeGroup" @change="onAgreeChange">
  182. <up-checkbox size="18" labelSize="24" labelColor="#666666" activeColor="#ea002a" name="agree"
  183. class="wcg-checkbox"></up-checkbox>
  184. </up-checkbox-group>
  185. <text class="checkbox-label">{{ t('signup.agree') }}</text>
  186. </view>
  187. </uni-forms-item>
  188. <uni-forms-item name="isSubscribeEmail">
  189. <view class="check-box" @click="toggleSubscribeEmail">
  190. <up-checkbox-group v-model="subscribeEmailGroup" @change="onSubscribeEmailChange">
  191. <up-checkbox size="18" labelSize="24" labelColor="#666666" activeColor="#ea002a"
  192. name="subscribeEmail" class="wcg-checkbox"></up-checkbox>
  193. </up-checkbox-group>
  194. <text class="checkbox-label">{{ t('signup.agree1') }}</text>
  195. </view>
  196. </uni-forms-item>
  197. </uni-forms>
  198. </view>
  199. <view>
  200. <button class="regiset-btn" @click="register">
  201. {{ t('signup.button') }}
  202. </button>
  203. </view>
  204. <view class="login-link">
  205. <text>{{ t('newSignup.item16') }}</text>
  206. <view class="link" @click="activeTab = 1">{{ t('newSignup.item17') }}</view>
  207. </view>
  208. <view class="des-bottom">
  209. <text v-t="'signup.agreemnet1'"></text>
  210. <cwg-link type="pdf" url='pdf/Client_Agreement.pdf' target="_blank" :title="'signup.agreemnet2'"
  211. class="desc-link" />
  212. <text v-t="'signup.agreemnet3'"></text>
  213. <cwg-link type="pdf" url='pdf/Terms&Conditions.pdf' target="_blank" :title="'signup.agreemnet4'"
  214. class="desc-link" />
  215. <text v-t="'signup.agreemnet5'"></text>
  216. <cwg-link type="pdf" url='pdf/Privacy_Policy.pdf' target="_blank" :title="'signup.agreemnet6'"
  217. class="desc-link" />
  218. <text v-t="'signup.agreemnet7'"></text>
  219. </view>
  220. </view>
  221. <cwg-match-media :min-width="791">
  222. <!-- <view class="qr-container">
  223. <view class="qr-title">
  224. <view class="line"></view>
  225. <view class="qr-tit2">{{ t('newSignin.item2') }}</view>
  226. <view class="line"></view>
  227. </view>
  228. <QrCode width="200" height="200" text="cardGuide" :logo="logoImage"></QrCode>
  229. </view> -->
  230. </cwg-match-media>
  231. </view>
  232. </uni-col>
  233. </uni-row>
  234. </view>
  235. <view class="chat-icon" :class="{ 'chat-icon-expanded': isChatIconExpanded, 'chat-icon-hidden': type == 'chat' }"
  236. @click="handleChatIconClick">
  237. <cwg-icon name="chat" color="#fff" />
  238. </view>
  239. </view>
  240. </template>
  241. <script setup>
  242. import { ref, watch, onMounted, computed } from 'vue'
  243. import { onLoad } from '@dcloudio/uni-app'
  244. import QrCode from '@/components/QrCode.vue'
  245. import { post } from '@/utils/request'
  246. import { userToken } from '@/composables/config'
  247. import { userApi } from '@/api/user'
  248. import { ucardApi } from '@/api/ucard'
  249. import { customApi } from '@/service/custom'
  250. import { loginApi } from '@/api/login'
  251. import { countryApi } from '@/api/country'
  252. import Config from '@/config/index'
  253. import { showToast } from '@/utils/toast'
  254. import { useEmailCountdown } from '@/hooks/useEmailCountdown'
  255. import useGlobalStore from '@/stores/use-global-store'
  256. import useUserStore from '@/stores/use-user-store'
  257. import useRouter from '@/hooks/useRouter'
  258. import { useI18n } from 'vue-i18n'
  259. import companyLogo from '@/static/images/logo4.png'
  260. import LoginHeaderGroup from './components/LoginHeaderGroup.vue'
  261. import LiveChatService from '@/utils/liveChat.js'
  262. import { useWindowWidth } from '@/composables/useWindowWidth'
  263. import { openLocalPdf } from '@/utils/pdf.js'
  264. const windowWidth = useWindowWidth(300)
  265. const isMobile = computed(() => windowWidth.value <= 991)
  266. const router = useRouter()
  267. const { t } = useI18n()
  268. const { Code } = Config
  269. const userStore = useUserStore()
  270. const globalStore = useGlobalStore()
  271. const modeStore = computed(() => globalStore.mode)
  272. const isDark = computed(() => globalStore.theme === 'dark')
  273. const tabs = computed(() => [
  274. { text: t('signin.tabs1'), value: 1, },
  275. { text: t('signin.tabs2'), value: 2, },
  276. ])
  277. const activeTab = ref(1)
  278. // ========== 注册表单相关 ==========
  279. const {
  280. time,
  281. text: getCodeString,
  282. canSend,
  283. start,
  284. restore,
  285. } = useEmailCountdown()
  286. const isRouteHasId = ref(false)
  287. const formData = ref({
  288. country: 'CN',
  289. phone: '',
  290. birthDate: '',
  291. email: '',
  292. emailCode: '',
  293. password: '',
  294. linkValue: '',
  295. agree: 0,
  296. isSubscribeEmail: 0,
  297. sourceCode: null,
  298. w: '',
  299. subId: '',
  300. oc: '',
  301. agentId: null,
  302. ibInvalid: null,
  303. })
  304. const rules = {
  305. country: { rules: [{ required: true, errorMessage: t('vaildate.country.empty'), trigger: 'blur' }] },
  306. email: {
  307. rules: [
  308. { required: true, errorMessage: t('vaildate.email.empty'), trigger: 'blur' },
  309. { pattern: Config.Pattern.Email, errorMessage: t('vaildate.email.format'), trigger: 'blur' },
  310. ],
  311. },
  312. emailCode: { rules: [{ required: true, errorMessage: t('vaildate.code.empty'), trigger: 'blur' }] },
  313. password: {
  314. rules: [
  315. { required: true, errorMessage: t('vaildate.password.format'), trigger: 'blur' },
  316. { pattern: Config.Pattern.Password, errorMessage: t('vaildate.password.format'), trigger: 'blur' },
  317. ],
  318. },
  319. agree: {
  320. rules: [
  321. {
  322. validateFunction: (rule, value) => {
  323. if (value) return true
  324. return t('vaildate.agree.empty')
  325. },
  326. trigger: 'change',
  327. },
  328. ],
  329. },
  330. phone: {
  331. rules: [
  332. { required: true, errorMessage: t('vaildate.phone.format'), trigger: 'blur' },
  333. { pattern: Config.Pattern.NonNegInt, errorMessage: t('vaildate.phone.format'), trigger: 'blur' },
  334. ],
  335. },
  336. birthDate: { rules: [{ required: true, errorMessage: t('vaildate.birthDate.empty'), trigger: 'change' }] },
  337. }
  338. const agreeGroup = ref([])
  339. const subscribeEmailGroup = ref([])
  340. const regForm = ref(null)
  341. const mock_options = ref([])
  342. const countryCode = ref('my')
  343. const countryOptions = computed(() => {
  344. return mock_options.value.map(item => ({
  345. text: item.enName,
  346. value: item.code,
  347. disabled: item.isOpenAccount == 0 || item.isOpenAccount === null ? true : false,
  348. }))
  349. })
  350. watch(() => formData.value.agree, (val) => {
  351. agreeGroup.value = val === 1 ? ['agree'] : []
  352. }, { immediate: true })
  353. watch(() => formData.value.isSubscribeEmail, (val) => {
  354. subscribeEmailGroup.value = val === 1 ? ['subscribeEmail'] : []
  355. }, { immediate: true })
  356. const onAgreeChange = (e) => {
  357. formData.value.agree = e && e.length ? 1 : 0
  358. }
  359. const onSubscribeEmailChange = (e) => {
  360. formData.value.isSubscribeEmail = e && e.length ? 1 : 0
  361. }
  362. const toggleAgree = () => {
  363. const next = agreeGroup.value.length ? [] : ['agree']
  364. agreeGroup.value = next
  365. onAgreeChange(next)
  366. }
  367. const toggleSubscribeEmail = () => {
  368. const next = subscribeEmailGroup.value.length ? [] : ['subscribeEmail']
  369. subscribeEmailGroup.value = next
  370. onSubscribeEmailChange(next)
  371. }
  372. const rule1 = computed(() => {
  373. if (!formData.value.password) return false
  374. return /^.{8,16}$/.test(formData.value.password)
  375. })
  376. const rule2 = computed(() => {
  377. return /^(?=.*?[a-z])(?=.*?[A-Z]).*$/.test(formData.value.password)
  378. })
  379. const rule3 = computed(() => {
  380. return /^(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?!.*([~!@&%$^\(\)#_]).*\1.*\1)[A-Za-z0-9~!@&%$^\(\)#_]{8,16}$/.test(
  381. formData.value.password,
  382. )
  383. })
  384. const isAgeValid = computed(() => {
  385. if (!formData.value.birthDate) {
  386. return false
  387. }
  388. const today = new Date()
  389. const birthDate = new Date(formData.value.birthDate)
  390. let age = today.getFullYear() - birthDate.getFullYear()
  391. const monthDiff = today.getMonth() - birthDate.getMonth()
  392. if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
  393. age--
  394. }
  395. return age >= 18
  396. })
  397. const checkAge = () => {
  398. if (formData.value.birthDate && !isAgeValid.value) {
  399. uni.showModal({
  400. title: t('Msg.SystemPrompt'),
  401. content: t('signup.ageRestriction'),
  402. showCancel: false,
  403. confirmText: t('Btn.Confirm'),
  404. success: function (res) {
  405. if (res.confirm) {
  406. }
  407. },
  408. })
  409. }
  410. }
  411. const limitAgentIdLength = (val) => {
  412. if (val == null || val === '') return
  413. const filtered = val.toString().replace(/[^0-9a-zA-Z]/g, '').slice(0, 10)
  414. if (formData.value.linkValue !== filtered) {
  415. formData.value.linkValue = filtered
  416. }
  417. }
  418. onLoad((options) => {
  419. if (options) {
  420. formData.value.sourceCode = options.ex || null
  421. formData.value.w = options.w || ''
  422. formData.value.subId = options.SUBID || ''
  423. formData.value.oc = options.oc || ''
  424. formData.value.email = options.emailAdvertisement || ''
  425. if (options.id) {
  426. isRouteHasId.value = true
  427. formData.value.agentId = Number(options.id)
  428. formData.value.linkValue = options.commission || ''
  429. switch (options.ibInvalid) {
  430. case 'B0':
  431. formData.value.ibInvalid = 0
  432. break
  433. case 'B1':
  434. formData.value.ibInvalid = 1
  435. break
  436. }
  437. }
  438. }
  439. })
  440. const ho = ref('')
  441. // 国家列表
  442. async function getCountry() {
  443. try {
  444. let res = await countryApi.Country({})
  445. if (res.code == 200) {
  446. mock_options.value = res.data
  447. } else {
  448. showToast(res.msg)
  449. }
  450. } catch (error) {
  451. console.error(error)
  452. }
  453. }
  454. const getCountryMsg = async () => {
  455. let res = await countryApi.CountryGet({})
  456. if (res.code == Code.StatusOK) {
  457. countryCode.value = res.msg
  458. } else {
  459. console.log(res)
  460. }
  461. }
  462. async function handleGetCode() {
  463. if (!formData.value.birthDate) {
  464. showToast(t('vaildate.birthDate.empty'))
  465. return
  466. }
  467. if (!isAgeValid.value) {
  468. showToast(t('signup.ageRestriction'))
  469. return
  470. }
  471. if (!formData.value.country) {
  472. showToast(t('vaildate.country.empty'))
  473. return
  474. }
  475. if (!formData.value.email) {
  476. showToast(t('vaildate.email.empty'))
  477. return
  478. }
  479. if (!Config.Pattern.Email.test(formData.value.email)) {
  480. showToast(t('vaildate.email.format'))
  481. return
  482. }
  483. if (!canSend.value) return
  484. await sendEmailCode()
  485. }
  486. async function sendEmailCode() {
  487. try {
  488. const res = await loginApi.Code({
  489. ...formData.value,
  490. })
  491. if (res.code === 200) {
  492. showToast(res.msg, 'success')
  493. start()
  494. return true
  495. } else {
  496. showToast(res.msg,'error')
  497. return false
  498. }
  499. }catch (e) {
  500. showToast(e.msg,'error')
  501. }
  502. }
  503. const register = async () => {
  504. if (countryCode.value == 'MY' || countryCode.value == 'ID') {
  505. showToast('Registration not available for this region')
  506. return
  507. }
  508. regForm.value.validate().then(async (res) => {
  509. const chinaCountryCodes = ['CN']
  510. const isChina = chinaCountryCodes.includes(formData.value.country)
  511. const xSystemValue = isChina ? 'B' : 'A'
  512. let resData = await loginApi.Register(
  513. { ...formData.value },
  514. { headers: { 'X-System': xSystemValue } },
  515. )
  516. if (resData.code == 200) {
  517. showToast(t('Msg.registerSuc'))
  518. registLogin()
  519. } else {
  520. showToast(resData.msg)
  521. }
  522. }).catch(err => {
  523. console.log('表单错误信息:', err)
  524. showToast(err.msg)
  525. return false
  526. })
  527. }
  528. const registLogin = async () => {
  529. try {
  530. let res = await userApi.login({
  531. loginName: formData.value.email,
  532. password: formData.value.password,
  533. })
  534. if (res.code == 200) {
  535. userToken.value = res.data
  536. getRegistLoginInfo()
  537. } else {
  538. showToast(res.msg)
  539. }
  540. } catch (error) {
  541. console.error(error)
  542. }
  543. }
  544. const getRegistLoginInfo = async () => {
  545. try {
  546. let res = await userApi.getUserInfo()
  547. if (res.code == 200) {
  548. userStore.saveUserInfo(res.data)
  549. showToast(t('Msg.LoginSuccess'))
  550. setTimeout(() => {
  551. uni.reLaunch({
  552. url: '/pages/customer/index',
  553. })
  554. }, 1000)
  555. } else {
  556. showToast(t('Msg.SystemError'))
  557. }
  558. } catch (error) {
  559. console.error(error)
  560. }
  561. }
  562. const openUrl = (url) => {
  563. openLocalPdf(url)
  564. }
  565. // ========== 注册表单相关结束 ==========
  566. // 响应式表单数据
  567. const form = ref({
  568. loginName: '',
  569. password: '',
  570. })
  571. function submit() {
  572. if (!form.value.loginName) {
  573. uni.$u.toast(t('signin.form.email'))
  574. return
  575. }
  576. if (!form.value.password) {
  577. uni.$u.toast(t('signin.form.password'))
  578. return
  579. }
  580. handleLogin()
  581. }
  582. const customStyle = {
  583. height: '48px',
  584. 'border-radius': '8px',
  585. background: 'transparent',
  586. padding: '0 20px !important',
  587. position: 'relative',
  588. }
  589. const remenber = ref([])
  590. const checkboxChange = (e) => {
  591. remenber.value = e
  592. }
  593. const fetchUserList = (params) => post('/Login/AcctLogin', params)
  594. const handleClick = (value) => {
  595. activeTab.value = value
  596. }
  597. async function handleLogin() {
  598. try {
  599. const res = await userApi.login({
  600. loginName: form.value.loginName,
  601. password: form.value.password,
  602. })
  603. if (res.code === 200) {
  604. userToken.value = res.data
  605. uni.showToast({ title:t('login.msg0_1'), icon:'success' })
  606. getCustomLoginInfo()
  607. // getCardUserInfo();
  608. reasonsRefusalList()
  609. if (remenber.value.length) {
  610. userStore.saveAccountInfo({
  611. loginName: form.value.loginName,
  612. password: form.value.password,
  613. rememberPassword: true,
  614. })
  615. } else {
  616. userStore.saveAccountInfo({
  617. loginName: '',
  618. password: '',
  619. rememberPassword: false,
  620. })
  621. }
  622. // console.log(1111);
  623. } else {
  624. uni.showToast({ title: res.msg })
  625. // console.log(12112);
  626. }
  627. } catch (error) {
  628. // console.log(error)
  629. uni.showToast({ title: error.msg, icon: 'error' })
  630. // console.log(error, 19089);
  631. }
  632. }
  633. async function getCustomLoginInfo() {
  634. try {
  635. const res = await userApi.getUserInfo()
  636. userStore.saveUserInfo(res.data)
  637. uni.removeStorageSync('systemListCache')
  638. // 登录更新金额
  639. uni.$emit('updatePayment')
  640. // uni.$emit('updateSystemList', 'login')
  641. if (res.code === 200) {
  642. switch (modeStore.value) {
  643. case 'customer':
  644. router.reLaunch('/pages/customer/dashboard')
  645. // router.reLaunch('/pages/customer/index')
  646. break
  647. case 'ib':
  648. router.reLaunch('/pages/ib/index')
  649. break
  650. case 'follow':
  651. router.reLaunch('/pages/follow/index')
  652. break
  653. default:
  654. break
  655. }
  656. } else {
  657. uni.$u.toast(res.msg || t('login.msg0'))
  658. }
  659. } catch (error) {
  660. uni.$u.toast(error.msg || t('login.msg0'),'error')
  661. // console.log(error, 111);
  662. }
  663. }
  664. async function getCardUserInfo() {
  665. try {
  666. const res = await ucardApi.getSingle()
  667. userStore.saveUserInfo(res.data)
  668. if (res.code === 200) {
  669. if (!res.data || res.data.approveStatus != 2) {
  670. router.push('/pages/mine/improve')
  671. } else {
  672. router.push('/pages/card/index')
  673. }
  674. } else {
  675. uni.$u.toast(res.msg || t('login.msg0'))
  676. }
  677. } catch (error) {
  678. // console.log(error, 111);
  679. }
  680. }
  681. async function reasonsRefusalList() {
  682. try {
  683. const res = await customApi.reasonsRefusalList()
  684. if (res.code === 200) {
  685. pickFields(res.data)
  686. } else {
  687. uni.$u.toast(res.msg || t('login.msg0'))
  688. }
  689. } catch (error) {
  690. // console.log(error, 111);
  691. }
  692. }
  693. function pickFields(source, fields = ['content', 'enContent']) {
  694. const result = {}
  695. Object.entries(source).forEach(([key, value]) => {
  696. result[key] = fields.reduce((acc, f) => {
  697. acc[f] = value[f] ?? null
  698. return acc
  699. }, {})
  700. })
  701. userStore.saveReasonsOptions(result)
  702. }
  703. onMounted(() => {
  704. if (uni.getStorageSync('logoutToSystem') == 1) {
  705. uni.removeStorageSync('logoutToSystem')
  706. uni.removeStorageSync('systemListCache')
  707. }
  708. uni.$emit('updateSystemList','login')
  709. const accountInfo = userStore.accountInfo
  710. if (accountInfo?.rememberPassword) {
  711. form.value.loginName = accountInfo?.loginName || ''
  712. form.value.password = accountInfo?.password || ''
  713. remenber.value = ['记住我']
  714. } else {
  715. form.value.loginName = ''
  716. form.value.password = ''
  717. remenber.value = []
  718. }
  719. // 注册表单初始化
  720. getCountry()
  721. getCountryMsg()
  722. const hostParts = window.location.host.split('.')
  723. ho.value = hostParts.length > 1 ? hostParts[1] : ''
  724. })
  725. const inputType = ref('password')
  726. const isChatIconExpanded = ref(false)
  727. // 处理聊天图标点击
  728. const handleChatIconClick = () => {
  729. // 如果还没显示 → 先滑出来
  730. if (!isChatIconExpanded.value) {
  731. isChatIconExpanded.value = true
  732. return
  733. }
  734. if (isMobile.value) {
  735. router.push('/pages/common/chat')
  736. } else {
  737. if (LiveChatService) {
  738. LiveChatService.showChat()
  739. }
  740. }
  741. setTimeout(() => {
  742. isChatIconExpanded.value = false
  743. }, 300)
  744. }
  745. </script>
  746. <style lang="scss" scoped>
  747. @import "@/uni.scss";
  748. :deep(uni-content) {
  749. padding-left: 0 !important;
  750. }
  751. .login-page {
  752. height: 100vh;
  753. border: none;
  754. padding: 0;
  755. position: relative;
  756. display: flex;
  757. flex-direction: column;
  758. }
  759. .chat-icon {
  760. width: px2rpx(50);
  761. height: px2rpx(50);
  762. border-radius: 50%;
  763. background-color: #cf1322;
  764. display: flex;
  765. align-items: center;
  766. justify-content: center;
  767. position: fixed;
  768. bottom: px2rpx(25);
  769. right: px2rpx(-25);
  770. z-index: 999;
  771. cursor: pointer;
  772. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  773. box-shadow: 0 px2rpx(8) px2rpx(20) rgba(0, 0, 0, 0.15);
  774. will-change: transform;
  775. }
  776. .chat-icon:hover {
  777. transform: scale(1.1);
  778. }
  779. .chat-icon-expanded {
  780. bottom: px2rpx(20);
  781. right: px2rpx(20);
  782. transform: scale(1.1);
  783. box-shadow: 0 px2rpx(12) px2rpx(30) rgba(0, 0, 0, 0.2);
  784. }
  785. .chat-icon-hidden {
  786. display: none;
  787. }
  788. .fixed {
  789. width: 100%;
  790. height: var(--status-bar-height);
  791. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  792. z-index: 9;
  793. }
  794. .global-header-bar {
  795. width: 100%;
  796. height: px2rpx(60);
  797. display: flex;
  798. align-items: center;
  799. justify-content: center;
  800. flex-shrink: 0;
  801. z-index: 100;
  802. &.pc-header {
  803. background-color: transparent;
  804. }
  805. .header-inner {
  806. width: 100%;
  807. padding: 0 5%;
  808. display: flex;
  809. justify-content: space-between;
  810. /* 两端对齐,可放logo和组件 */
  811. align-items: center;
  812. }
  813. }
  814. .mobile-header-bar {
  815. //position: absolute;
  816. //top: px2rpx(20);
  817. //right: px2rpx(20);
  818. z-index: 10;
  819. width: 100%;
  820. display: flex;
  821. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  822. justify-content: flex-end;
  823. }
  824. .main-content {
  825. flex: 1;
  826. overflow: hidden;
  827. }
  828. .demo-uni-row {
  829. height: 100%;
  830. margin: 0 !important;
  831. .left-bg {
  832. height: 100%;
  833. min-height: calc(100vh - 120px);
  834. background-image: url(/static/images/login-bg.jpeg);
  835. background-size: cover;
  836. background-position: center;
  837. display: flex;
  838. box-sizing: border-box;
  839. padding: px2rpx(50);
  840. //flex-direction: column;
  841. //align-items: center;
  842. justify-content: center;
  843. .left-box {
  844. display: flex;
  845. flex-direction: column;
  846. justify-content: center;
  847. align-items: flex-start;
  848. width: 60%;
  849. //margin-top: px2rpx(20);
  850. .inner {
  851. width: 100%;
  852. text-align: start;
  853. //margin-bottom: px2rpx(20);
  854. .section-title {
  855. //margin-top: px2rpx(10);
  856. //margin-bottom: px2rpx(10);
  857. }
  858. .title {
  859. margin: 0 0 0 px2rpx(10);
  860. font-size: px2rpx(56);
  861. line-height: 1.2;
  862. color: #fff;
  863. font-weight: 700;
  864. text-align: left;
  865. }
  866. .w-700 {
  867. font-weight: 700;
  868. }
  869. .subtitle {
  870. width: 45%;
  871. font-size: px2rpx(18);
  872. letter-spacing: px2rpx(1);
  873. display: block;
  874. margin-bottom: px2rpx(24);
  875. color: #ffffff;
  876. line-height: px2rpx(15);
  877. font-weight: 500;
  878. padding: px2rpx(10) px2rpx(20);
  879. border-radius: px2rpx(100);
  880. text-transform: uppercase;
  881. background-color: #e61f1e;
  882. text-align: center;
  883. }
  884. .w-40 {
  885. max-width: 40%;
  886. }
  887. .text-white {
  888. margin-top: px2rpx(10);
  889. font-size: px2rpx(18);
  890. margin-bottom: px2rpx(16);
  891. line-height: 1.6;
  892. color: var(--bs-emphasis-color);
  893. }
  894. }
  895. .img-fluid {
  896. width: 400px;
  897. height: 33px;
  898. }
  899. .mt--10 {
  900. margin-top: px2rpx(10);
  901. }
  902. .h1 {
  903. // text-align: center;
  904. color: var(--bs-emphasis-color);
  905. font-size: 30px;
  906. margin-top: 30px;
  907. line-height: 1.5;
  908. }
  909. .h6 {
  910. text-align: start;
  911. line-height: 20px;
  912. color: var(--bs-emphasis-color);
  913. font-size: 14px;
  914. margin-top: 10px;
  915. }
  916. .company {
  917. padding: px2rpx(10) 0 px2rpx(10) 0;
  918. position: relative;
  919. align-items: flex-start !important;
  920. width: 100%;
  921. }
  922. }
  923. .left-content {
  924. width: 100%;
  925. .des {
  926. text-align: start;
  927. line-height: 24px;
  928. color: var(--bs-emphasis-color);
  929. font-size: 14px;
  930. //margin-top: px2rpx(20);
  931. :nth-child(n) {
  932. display: inline;
  933. word-break: break-all;
  934. word-wrap: break-word;
  935. }
  936. .doc-link {
  937. color: var(--color-error);
  938. text-decoration: underline;
  939. margin: 0 px2rpx(4);
  940. }
  941. }
  942. }
  943. }
  944. .right-f {
  945. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  946. padding: 0 px2rpx(24);
  947. height: 100%;
  948. box-sizing: border-box;
  949. .account {
  950. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  951. position: relative;
  952. height: calc(100vh - 120px);
  953. display: flex;
  954. flex-direction: column;
  955. justify-content: center;
  956. padding: 0 10%;
  957. .company {
  958. padding: px2rpx(30) 0 px2rpx(20) 0;
  959. position: relative;
  960. align-items: center !important;
  961. }
  962. .company-icon {
  963. width: px2rpx(234);
  964. }
  965. .company-icon-mini {
  966. width: px2rpx(100);
  967. }
  968. }
  969. }
  970. }
  971. .bottom-box {
  972. width: 100%;
  973. height: 60px;
  974. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  975. display: flex;
  976. justify-content: center;
  977. align-items: center;
  978. color: #000;
  979. .bottom-title {
  980. text-align: center;
  981. font-size: px2rpx(14);
  982. font-weight: 500;
  983. line-height: 1.5;
  984. color: #666666;
  985. }
  986. .ellipsis {
  987. width: px2rpx(200);
  988. white-space: nowrap;
  989. overflow: hidden;
  990. text-overflow: ellipsis;
  991. }
  992. .cwg-button {
  993. width: 120px !important;
  994. padding: px2rpx(4) 0 !important;
  995. }
  996. }
  997. button {
  998. background-color: #ea002a;
  999. font-size: px2rpx(14);
  1000. font-weight: normal;
  1001. height: px2rpx(44);
  1002. line-height: px2rpx(44);
  1003. }
  1004. .right-f .account .company {
  1005. padding: px2rpx(50) 0 px2rpx(200) 0;
  1006. position: relative;
  1007. align-items: flex-start !important;
  1008. }
  1009. .logo {
  1010. margin-left: px2rpx(48);
  1011. }
  1012. .left-bg .company-icon {
  1013. width: px2rpx(234);
  1014. }
  1015. .left-bg .left-content {
  1016. position: relative;
  1017. z-index: 1;
  1018. }
  1019. .title {
  1020. margin: px2rpx(15) 0;
  1021. font-size: px2rpx(24);
  1022. font-weight: bolder;
  1023. color: var(--bs-emphasis-color);
  1024. text-align: center;
  1025. i {
  1026. margin-right: px2rpx(10);
  1027. }
  1028. .tit1 {
  1029. font-size: px2rpx(34);
  1030. line-height: 1.5;
  1031. font-weight: bold;
  1032. color: var(--bs-emphasis-color);
  1033. }
  1034. .tit2 {
  1035. font-size: px2rpx(16);
  1036. line-height: 1.5;
  1037. color: #cecece;
  1038. font-weight: 500;
  1039. }
  1040. }
  1041. .qr-title {
  1042. font-size: px2rpx(16);
  1043. line-height: 1.5;
  1044. color: #cecece;
  1045. font-weight: 500;
  1046. text-align: center;
  1047. margin: px2rpx(40) 0;
  1048. display: flex;
  1049. align-items: center;
  1050. justify-content: center;
  1051. .line {
  1052. flex: 1;
  1053. height: 1px;
  1054. background-color: #e4e4e4;
  1055. }
  1056. .qr-tit2 {
  1057. margin: 0 px2rpx(12);
  1058. }
  1059. }
  1060. .input {
  1061. height: px2rpx(44);
  1062. border-radius: px2rpx(8);
  1063. background: #f7f8fa;
  1064. padding: 0 px2rpx(20) !important;
  1065. position: relative;
  1066. }
  1067. .account-icon {
  1068. width: px2rpx(12);
  1069. height: px2rpx(14) !important;
  1070. margin-right: px2rpx(5);
  1071. }
  1072. :deep(.u-input__content__prefix-icon) {
  1073. height: px2rpx(20);
  1074. }
  1075. .regiset-btn {
  1076. margin: px2rpx(20) 0;
  1077. border-radius: px2rpx(20);
  1078. }
  1079. .account-tip {
  1080. color: #666666;
  1081. font-size: px2rpx(14);
  1082. text-align: center;
  1083. text {
  1084. color: #ea002a;
  1085. }
  1086. }
  1087. :deep(.u-form-item__body) {
  1088. padding: 0 !important;
  1089. padding-bottom: px2rpx(24) !important;
  1090. }
  1091. :deep(.wcg-checkbox) {
  1092. padding: 0 !important;
  1093. }
  1094. .cwg-button {
  1095. padding: px2rpx(34) 0 !important;
  1096. }
  1097. .tab-list {
  1098. width: 100%;
  1099. display: flex;
  1100. align-items: center;
  1101. justify-content: center;
  1102. border-bottom: 1px solid var(--bs-border-color);
  1103. }
  1104. .tab-item {
  1105. width: 50%;
  1106. margin: 0 px2rpx(15);
  1107. padding-right: 0;
  1108. padding-left: 0;
  1109. padding-bottom: 8px;
  1110. text-align: center;
  1111. border-bottom: 2px solid transparent;
  1112. font-weight: 500;
  1113. color: var(--bs-emphasis-color);
  1114. cursor: pointer;
  1115. transition: all 0.3s ease;
  1116. .tab-label {
  1117. font-size: px2rpx(24);
  1118. }
  1119. &:hover,
  1120. &:focus {
  1121. font-weight: 700;
  1122. color: #e32326;
  1123. border-bottom-color: #e32326;
  1124. }
  1125. &.active {
  1126. font-weight: 700;
  1127. color: #e32326;
  1128. border-bottom-color: #e32326;
  1129. }
  1130. }
  1131. /* 注册表单样式 */
  1132. .pwd {
  1133. list-style: none;
  1134. padding-left: 0;
  1135. margin: 0;
  1136. li {
  1137. font-size: px2rpx(12);
  1138. color: var(--bs-heading-color);
  1139. line-height: px2rpx(20);
  1140. position: relative;
  1141. padding-left: px2rpx(16);
  1142. &::before {
  1143. content: '';
  1144. position: absolute;
  1145. left: 0;
  1146. top: 50%;
  1147. transform: translateY(-50%);
  1148. width: px2rpx(6);
  1149. height: px2rpx(6);
  1150. border-radius: 50%;
  1151. background-color: var(--bs-heading-color);
  1152. }
  1153. &.fit {
  1154. color: #67c23a;
  1155. &::before {
  1156. background-color: #67c23a;
  1157. }
  1158. }
  1159. }
  1160. }
  1161. :deep(.formContent) {
  1162. padding: 0 10px;
  1163. .uni-select,
  1164. .uni-combox,
  1165. .uni-easyinput__content,
  1166. //.cwg-combox,
  1167. .uni-date-editor--x {
  1168. padding: 0.5rem px2rpx(10);
  1169. height: 3rem!important;
  1170. //border: none !important;
  1171. border-radius: px2rpx(8);
  1172. }
  1173. .cwg-combox{
  1174. background-color: transparent !important;
  1175. }
  1176. .code{
  1177. .uni-easyinput__content{
  1178. border-radius: px2rpx(8) 0 0 px2rpx(8);
  1179. }
  1180. }
  1181. }
  1182. :deep(.uni-stat-box) {
  1183. height: 100%;
  1184. }
  1185. :deep(.uni-select) {
  1186. height: 100%;
  1187. }
  1188. :deep(.uni-easyinput__content) {
  1189. height: 100%;
  1190. }
  1191. :deep(.uni-date-editor) {
  1192. height: 100%;
  1193. }
  1194. :deep(.uni-date-editor--x) {
  1195. height: 100%;
  1196. }
  1197. .btn-code {
  1198. //margin-left: -10px;
  1199. width: px2rpx(120);
  1200. height: 3rem;
  1201. box-sizing: border-box;
  1202. background-color: #102047;
  1203. //border: 1px solid rgb(229, 229, 229);
  1204. color: #fff;
  1205. text-align: center;
  1206. line-height: 3rem;
  1207. border-radius: 0 25px 25px 0;
  1208. cursor: pointer;
  1209. font-size: 14px;
  1210. flex-shrink: 0;
  1211. }
  1212. .check-box {
  1213. padding: 0 px2rpx(10);
  1214. margin-bottom: px2rpx(10);
  1215. display: flex;
  1216. align-items: center;
  1217. cursor: pointer;
  1218. .checkbox-label {
  1219. font-size: px2rpx(14);
  1220. color: #666666;
  1221. margin-left: px2rpx(8);
  1222. user-select: none;
  1223. }
  1224. :deep(.u-checkbox) {
  1225. display: flex;
  1226. align-items: flex-start;
  1227. }
  1228. }
  1229. .regiset-btn {
  1230. width: 100%;
  1231. height: px2rpx(40);
  1232. line-height: px2rpx(40);
  1233. border-radius: px2rpx(20);
  1234. background-color: var(--color-error);
  1235. color: #fff;
  1236. font-weight: bold;
  1237. }
  1238. .login-link {
  1239. width: 100%;
  1240. margin-top: px2rpx(20);
  1241. text-align: center;
  1242. display: flex;
  1243. align-items: center;
  1244. justify-content: center;
  1245. font-size: px2rpx(16);
  1246. line-height: 1.6;
  1247. }
  1248. .link {
  1249. margin-left: px2rpx(5);
  1250. color: #e61f1e;
  1251. padding-bottom: 2px;
  1252. cursor: pointer;
  1253. font-size: px2rpx(14);
  1254. }
  1255. .agreemnet9 {
  1256. text-align: initial;
  1257. color: #e61f1e;
  1258. }
  1259. .des-bottom {
  1260. margin-top: px2rpx(20);
  1261. line-height: 20px;
  1262. color: #000;
  1263. font-size: 12px;
  1264. .desc-link {
  1265. display: inline-block;
  1266. color: #e61f1e;
  1267. text-decoration: underline;
  1268. }
  1269. }
  1270. </style>