index.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413
  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--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" 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. <uni-easyinput v-model="formData.phone"></uni-easyinput>
  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. <uni-easyinput v-model="formData.email" :placeholder="t('newSignup.item8')"
  137. :disabled="!isAgeValid || !formData.birthDate"></uni-easyinput>
  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. <uni-easyinput class="code" :disabled="!isAgeValid || !formData.birthDate" v-model="formData.emailCode"
  145. :placeholder="t('newSignup.item10')">
  146. </uni-easyinput>
  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. <uni-easyinput v-model.trim="formData.password" :disabled="!isAgeValid || !formData.birthDate"
  160. :placeholder="t('newSignup.item13')" type="password"></uni-easyinput>
  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. <uni-easyinput v-model.trim="formData.linkValue" :disabled="!isAgeValid || !formData.birthDate"
  175. :placeholder="t('newSignup.item15')" @input="limitAgentIdLength"></uni-easyinput>
  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. <u-button class="regiset-btn" @click="register">
  201. {{ t('signup.button') }}
  202. </u-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. const res = await loginApi.Code({
  488. ...formData.value,
  489. })
  490. if (res.code === 200) {
  491. showToast(t('Msg.CodeSuccess'))
  492. start()
  493. return true
  494. } else {
  495. showToast(t('Msg.CodeFail'))
  496. return false
  497. }
  498. }
  499. const register = async () => {
  500. if (countryCode.value == 'MY' || countryCode.value == 'ID') {
  501. showToast('Registration not available for this region')
  502. return
  503. }
  504. regForm.value.validate().then(async (res) => {
  505. const chinaCountryCodes = ['CN']
  506. const isChina = chinaCountryCodes.includes(formData.value.country)
  507. const xSystemValue = isChina ? 'B' : 'A'
  508. let resData = await loginApi.Register(
  509. { ...formData.value },
  510. { headers: { 'X-System': xSystemValue } },
  511. )
  512. if (resData.code == 200) {
  513. showToast(t('Msg.registerSuc'))
  514. registLogin()
  515. } else {
  516. showToast(resData.msg)
  517. }
  518. }).catch(err => {
  519. console.log('表单错误信息:', err)
  520. showToast(err.msg)
  521. return false
  522. })
  523. }
  524. const registLogin = async () => {
  525. try {
  526. let res = await userApi.login({
  527. loginName: formData.value.email,
  528. password: formData.value.password,
  529. })
  530. if (res.code == 200) {
  531. userToken.value = res.data
  532. getRegistLoginInfo()
  533. } else {
  534. showToast(res.msg)
  535. }
  536. } catch (error) {
  537. console.error(error)
  538. }
  539. }
  540. const getRegistLoginInfo = async () => {
  541. try {
  542. let res = await userApi.getUserInfo()
  543. if (res.code == 200) {
  544. userStore.saveUserInfo(res.data)
  545. showToast(t('Msg.LoginSuccess'))
  546. setTimeout(() => {
  547. uni.reLaunch({
  548. url: '/pages/customer/index',
  549. })
  550. }, 1000)
  551. } else {
  552. showToast(t('Msg.SystemError'))
  553. }
  554. } catch (error) {
  555. console.error(error)
  556. }
  557. }
  558. const openUrl = (url) => {
  559. openLocalPdf(url)
  560. }
  561. // ========== 注册表单相关结束 ==========
  562. // 响应式表单数据
  563. const form = ref({
  564. loginName: '',
  565. password: '',
  566. })
  567. function submit() {
  568. if (!form.value.loginName) {
  569. uni.$u.toast(t('signin.form.email'))
  570. return
  571. }
  572. if (!form.value.password) {
  573. uni.$u.toast(t('signin.form.password'))
  574. return
  575. }
  576. handleLogin()
  577. }
  578. const customStyle = {
  579. height: '51px',
  580. 'border-radius': '8px',
  581. // background: '#f7f8fa',
  582. padding: '0 20px !important',
  583. position: 'relative',
  584. }
  585. const remenber = ref([])
  586. const checkboxChange = (e) => {
  587. remenber.value = e
  588. }
  589. const fetchUserList = (params) => post('/Login/AcctLogin', params)
  590. const handleClick = (value) => {
  591. activeTab.value = value
  592. }
  593. async function handleLogin() {
  594. try {
  595. const res = await userApi.login({
  596. loginName: form.value.loginName,
  597. password: form.value.password,
  598. })
  599. if (res.code === 200) {
  600. userToken.value = res.data
  601. uni.$u.toast(t('login.msg0_1'))
  602. getCustomLoginInfo()
  603. // getCardUserInfo();
  604. reasonsRefusalList()
  605. if (remenber.value.length) {
  606. userStore.saveAccountInfo({
  607. loginName: form.value.loginName,
  608. password: form.value.password,
  609. rememberPassword: true,
  610. })
  611. } else {
  612. userStore.saveAccountInfo({
  613. loginName: '',
  614. password: '',
  615. rememberPassword: false,
  616. })
  617. }
  618. // console.log(1111);
  619. } else {
  620. uni.showToast({ title: res.msg })
  621. // console.log(12112);
  622. }
  623. } catch (error) {
  624. // console.log(error)
  625. uni.showToast({ title: error.msg, icon: 'none' })
  626. // console.log(error, 19089);
  627. }
  628. }
  629. async function getCustomLoginInfo() {
  630. try {
  631. const res = await userApi.getUserInfo()
  632. userStore.saveUserInfo(res.data)
  633. uni.removeStorageSync('systemListCache')
  634. // 登录更新金额
  635. uni.$emit('updatePayment')
  636. // uni.$emit('updateSystemList', 'login')
  637. if (res.code === 200) {
  638. switch (modeStore.value) {
  639. case 'customer':
  640. router.reLaunch('/pages/customer/index')
  641. break
  642. case 'ib':
  643. router.reLaunch('/pages/ib/index')
  644. break
  645. case 'follow':
  646. router.reLaunch('/pages/follow/index')
  647. break
  648. default:
  649. break
  650. }
  651. } else {
  652. uni.$u.toast(res.msg || t('login.msg0'))
  653. }
  654. } catch (error) {
  655. // console.log(error, 111);
  656. }
  657. }
  658. async function getCardUserInfo() {
  659. try {
  660. const res = await ucardApi.getSingle()
  661. userStore.saveUserInfo(res.data)
  662. if (res.code === 200) {
  663. if (!res.data || res.data.approveStatus != 2) {
  664. router.push('/pages/mine/improve')
  665. } else {
  666. router.push('/pages/card/index')
  667. }
  668. } else {
  669. uni.$u.toast(res.msg || t('login.msg0'))
  670. }
  671. } catch (error) {
  672. // console.log(error, 111);
  673. }
  674. }
  675. async function reasonsRefusalList() {
  676. try {
  677. const res = await customApi.reasonsRefusalList()
  678. if (res.code === 200) {
  679. pickFields(res.data)
  680. } else {
  681. uni.$u.toast(res.msg || t('login.msg0'))
  682. }
  683. } catch (error) {
  684. // console.log(error, 111);
  685. }
  686. }
  687. function pickFields(source, fields = ['content', 'enContent']) {
  688. const result = {}
  689. Object.entries(source).forEach(([key, value]) => {
  690. result[key] = fields.reduce((acc, f) => {
  691. acc[f] = value[f] ?? null
  692. return acc
  693. }, {})
  694. })
  695. userStore.saveReasonsOptions(result)
  696. }
  697. onMounted(() => {
  698. if (uni.getStorageSync('logoutToSystem') == 1) {
  699. uni.removeStorageSync('logoutToSystem')
  700. uni.removeStorageSync('systemListCache')
  701. }
  702. uni.$emit('updateSystemList','login')
  703. const accountInfo = userStore.accountInfo
  704. if (accountInfo?.rememberPassword) {
  705. form.value.loginName = accountInfo?.loginName || ''
  706. form.value.password = accountInfo?.password || ''
  707. remenber.value = ['记住我']
  708. } else {
  709. form.value.loginName = ''
  710. form.value.password = ''
  711. remenber.value = []
  712. }
  713. // 注册表单初始化
  714. getCountry()
  715. getCountryMsg()
  716. const hostParts = window.location.host.split('.')
  717. ho.value = hostParts.length > 1 ? hostParts[1] : ''
  718. })
  719. const inputType = ref('password')
  720. const isChatIconExpanded = ref(false)
  721. // 处理聊天图标点击
  722. const handleChatIconClick = () => {
  723. // 如果还没显示 → 先滑出来
  724. if (!isChatIconExpanded.value) {
  725. isChatIconExpanded.value = true
  726. return
  727. }
  728. if (isMobile.value) {
  729. router.push('/pages/common/chat')
  730. } else {
  731. if (LiveChatService) {
  732. LiveChatService.showChat()
  733. }
  734. }
  735. setTimeout(() => {
  736. isChatIconExpanded.value = false
  737. }, 300)
  738. }
  739. </script>
  740. <style lang="scss" scoped>
  741. @import "@/uni.scss";
  742. :deep(uni-content) {
  743. padding-left: 0 !important;
  744. }
  745. .login-page {
  746. height: 100vh;
  747. border: none;
  748. padding: 0;
  749. position: relative;
  750. display: flex;
  751. flex-direction: column;
  752. }
  753. .chat-icon {
  754. width: px2rpx(50);
  755. height: px2rpx(50);
  756. border-radius: 50%;
  757. background-color: #cf1322;
  758. display: flex;
  759. align-items: center;
  760. justify-content: center;
  761. position: fixed;
  762. bottom: px2rpx(25);
  763. right: px2rpx(-25);
  764. z-index: 999;
  765. cursor: pointer;
  766. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  767. box-shadow: 0 px2rpx(8) px2rpx(20) rgba(0, 0, 0, 0.15);
  768. will-change: transform;
  769. }
  770. .chat-icon:hover {
  771. transform: scale(1.1);
  772. }
  773. .chat-icon-expanded {
  774. bottom: px2rpx(20);
  775. right: px2rpx(20);
  776. transform: scale(1.1);
  777. box-shadow: 0 px2rpx(12) px2rpx(30) rgba(0, 0, 0, 0.2);
  778. }
  779. .chat-icon-hidden {
  780. display: none;
  781. }
  782. .fixed {
  783. width: 100%;
  784. height: var(--status-bar-height);
  785. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  786. z-index: 9;
  787. }
  788. .global-header-bar {
  789. width: 100%;
  790. height: px2rpx(60);
  791. display: flex;
  792. align-items: center;
  793. justify-content: center;
  794. flex-shrink: 0;
  795. z-index: 100;
  796. &.pc-header {
  797. background-color: transparent;
  798. }
  799. .header-inner {
  800. width: 100%;
  801. padding: 0 5%;
  802. display: flex;
  803. justify-content: space-between;
  804. /* 两端对齐,可放logo和组件 */
  805. align-items: center;
  806. }
  807. }
  808. .mobile-header-bar {
  809. //position: absolute;
  810. //top: px2rpx(20);
  811. //right: px2rpx(20);
  812. z-index: 10;
  813. width: 100%;
  814. display: flex;
  815. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  816. justify-content: flex-end;
  817. }
  818. .main-content {
  819. flex: 1;
  820. overflow: hidden;
  821. }
  822. .demo-uni-row {
  823. height: 100%;
  824. margin: 0 !important;
  825. .left-bg {
  826. height: 100%;
  827. min-height: calc(100vh - 120px);
  828. background-image: url(/static/images/login-bg.jpeg);
  829. background-size: cover;
  830. background-position: center;
  831. display: flex;
  832. box-sizing: border-box;
  833. padding: px2rpx(50);
  834. //flex-direction: column;
  835. //align-items: center;
  836. justify-content: center;
  837. .left-box {
  838. display: flex;
  839. flex-direction: column;
  840. justify-content: center;
  841. align-items: flex-start;
  842. width: 60%;
  843. //margin-top: px2rpx(20);
  844. .inner {
  845. width: 100%;
  846. text-align: start;
  847. //margin-bottom: px2rpx(20);
  848. .section-title {
  849. //margin-top: px2rpx(10);
  850. //margin-bottom: px2rpx(10);
  851. }
  852. .title {
  853. margin: 0 0 0 px2rpx(10);
  854. font-size: px2rpx(56);
  855. line-height: 1.2;
  856. color: #fff;
  857. font-weight: 700;
  858. text-align: left;
  859. }
  860. .w-700 {
  861. font-weight: 700;
  862. }
  863. .subtitle {
  864. width: 45%;
  865. font-size: px2rpx(18);
  866. letter-spacing: px2rpx(1);
  867. display: block;
  868. margin-bottom: px2rpx(24);
  869. color: #ffffff;
  870. line-height: px2rpx(15);
  871. font-weight: 500;
  872. padding: px2rpx(10) px2rpx(20);
  873. border-radius: px2rpx(100);
  874. text-transform: uppercase;
  875. background-color: #e61f1e;
  876. text-align: center;
  877. }
  878. .w-40 {
  879. max-width: 40%;
  880. }
  881. .text-white {
  882. margin-top: px2rpx(10);
  883. font-size: px2rpx(18);
  884. margin-bottom: px2rpx(16);
  885. line-height: 1.6;
  886. color: var(--bs-emphasis-color);
  887. }
  888. }
  889. .img-fluid {
  890. width: 400px;
  891. height: 33px;
  892. }
  893. .mt--10 {
  894. margin-top: px2rpx(10);
  895. }
  896. .h1 {
  897. // text-align: center;
  898. color: var(--bs-emphasis-color);
  899. font-size: 30px;
  900. margin-top: 30px;
  901. line-height: 1.5;
  902. }
  903. .h6 {
  904. text-align: start;
  905. line-height: 20px;
  906. color: var(--bs-emphasis-color);
  907. font-size: 14px;
  908. margin-top: 10px;
  909. }
  910. .company {
  911. padding: px2rpx(10) 0 px2rpx(10) 0;
  912. position: relative;
  913. align-items: flex-start !important;
  914. width: 100%;
  915. }
  916. }
  917. .left-content {
  918. width: 100%;
  919. .des {
  920. text-align: start;
  921. line-height: 24px;
  922. color: var(--bs-emphasis-color);
  923. font-size: 14px;
  924. //margin-top: px2rpx(20);
  925. :nth-child(n) {
  926. display: inline;
  927. word-break: break-all;
  928. word-wrap: break-word;
  929. }
  930. .doc-link {
  931. color: var(--color-error);
  932. text-decoration: underline;
  933. margin: 0 px2rpx(4);
  934. }
  935. }
  936. }
  937. }
  938. .right-f {
  939. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  940. padding: 0 px2rpx(24);
  941. height: 100%;
  942. box-sizing: border-box;
  943. .account {
  944. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  945. position: relative;
  946. height: calc(100vh - 120px);
  947. display: flex;
  948. flex-direction: column;
  949. justify-content: center;
  950. padding: 0 10%;
  951. .company {
  952. padding: px2rpx(30) 0 px2rpx(20) 0;
  953. position: relative;
  954. align-items: center !important;
  955. }
  956. .company-icon {
  957. width: px2rpx(234);
  958. }
  959. .company-icon-mini {
  960. width: px2rpx(100);
  961. }
  962. }
  963. }
  964. }
  965. .bottom-box {
  966. width: 100%;
  967. height: 60px;
  968. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  969. display: flex;
  970. justify-content: center;
  971. align-items: center;
  972. color: #000;
  973. .bottom-title {
  974. text-align: center;
  975. font-size: px2rpx(14);
  976. font-weight: 500;
  977. line-height: 1.5;
  978. color: #666666;
  979. }
  980. .ellipsis {
  981. width: px2rpx(200);
  982. white-space: nowrap;
  983. overflow: hidden;
  984. text-overflow: ellipsis;
  985. }
  986. .cwg-button {
  987. width: 120px !important;
  988. padding: px2rpx(4) 0 !important;
  989. }
  990. }
  991. button {
  992. background-color: #ea002a;
  993. font-size: px2rpx(14);
  994. font-weight: normal;
  995. height: px2rpx(44);
  996. line-height: px2rpx(44);
  997. }
  998. .right-f .account .company {
  999. padding: px2rpx(50) 0 px2rpx(200) 0;
  1000. position: relative;
  1001. align-items: flex-start !important;
  1002. }
  1003. .logo {
  1004. margin-left: px2rpx(48);
  1005. }
  1006. .left-bg .company-icon {
  1007. width: px2rpx(234);
  1008. }
  1009. .left-bg .left-content {
  1010. position: relative;
  1011. z-index: 1;
  1012. }
  1013. .title {
  1014. margin: px2rpx(15) 0;
  1015. font-size: px2rpx(24);
  1016. font-weight: bolder;
  1017. color: var(--bs-emphasis-color);
  1018. text-align: center;
  1019. i {
  1020. margin-right: px2rpx(10);
  1021. }
  1022. .tit1 {
  1023. font-size: px2rpx(34);
  1024. line-height: 1.5;
  1025. font-weight: bold;
  1026. color: var(--bs-emphasis-color);
  1027. }
  1028. .tit2 {
  1029. font-size: px2rpx(16);
  1030. line-height: 1.5;
  1031. color: #cecece;
  1032. font-weight: 500;
  1033. }
  1034. }
  1035. .qr-title {
  1036. font-size: px2rpx(16);
  1037. line-height: 1.5;
  1038. color: #cecece;
  1039. font-weight: 500;
  1040. text-align: center;
  1041. margin: px2rpx(40) 0;
  1042. display: flex;
  1043. align-items: center;
  1044. justify-content: center;
  1045. .line {
  1046. flex: 1;
  1047. height: 1px;
  1048. background-color: #e4e4e4;
  1049. }
  1050. .qr-tit2 {
  1051. margin: 0 px2rpx(12);
  1052. }
  1053. }
  1054. .input {
  1055. height: px2rpx(44);
  1056. border-radius: px2rpx(8);
  1057. background: #f7f8fa;
  1058. padding: 0 px2rpx(20) !important;
  1059. position: relative;
  1060. }
  1061. .account-icon {
  1062. width: px2rpx(12);
  1063. height: px2rpx(14) !important;
  1064. margin-right: px2rpx(5);
  1065. }
  1066. :deep(.u-input__content__prefix-icon) {
  1067. height: px2rpx(20);
  1068. }
  1069. .regiset-btn {
  1070. margin: px2rpx(20) 0;
  1071. border-radius: px2rpx(20);
  1072. }
  1073. .account-tip {
  1074. color: #666666;
  1075. font-size: px2rpx(14);
  1076. text-align: center;
  1077. text {
  1078. color: #ea002a;
  1079. }
  1080. }
  1081. :deep(.u-form-item__body) {
  1082. padding: 0 !important;
  1083. padding-bottom: px2rpx(24) !important;
  1084. }
  1085. :deep(.wcg-checkbox) {
  1086. padding: 0 !important;
  1087. }
  1088. .cwg-button {
  1089. padding: px2rpx(34) 0 !important;
  1090. }
  1091. .tab-list {
  1092. width: 100%;
  1093. display: flex;
  1094. align-items: center;
  1095. justify-content: center;
  1096. border-bottom: 1px solid var(--bs-border-color);
  1097. }
  1098. .tab-item {
  1099. width: 50%;
  1100. margin: 0 px2rpx(15);
  1101. padding-right: 0;
  1102. padding-left: 0;
  1103. padding-bottom: 8px;
  1104. text-align: center;
  1105. border-bottom: 2px solid transparent;
  1106. font-weight: 500;
  1107. color: var(--bs-emphasis-color);
  1108. cursor: pointer;
  1109. transition: all 0.3s ease;
  1110. .tab-label {
  1111. font-size: px2rpx(24);
  1112. }
  1113. &:hover,
  1114. &:focus {
  1115. font-weight: 700;
  1116. color: #e32326;
  1117. border-bottom-color: #e32326;
  1118. }
  1119. &.active {
  1120. font-weight: 700;
  1121. color: #e32326;
  1122. border-bottom-color: #e32326;
  1123. }
  1124. }
  1125. /* 注册表单样式 */
  1126. .pwd {
  1127. list-style: none;
  1128. padding-left: 0;
  1129. margin: 0;
  1130. li {
  1131. font-size: px2rpx(12);
  1132. color: var(--bs-heading-color);
  1133. line-height: px2rpx(20);
  1134. position: relative;
  1135. padding-left: px2rpx(16);
  1136. &::before {
  1137. content: '';
  1138. position: absolute;
  1139. left: 0;
  1140. top: 50%;
  1141. transform: translateY(-50%);
  1142. width: px2rpx(6);
  1143. height: px2rpx(6);
  1144. border-radius: 50%;
  1145. background-color: var(--bs-heading-color);
  1146. }
  1147. &.fit {
  1148. color: #67c23a;
  1149. &::before {
  1150. background-color: #67c23a;
  1151. }
  1152. }
  1153. }
  1154. }
  1155. :deep(.formContent) {
  1156. padding: 0 10px;
  1157. .uni-select,
  1158. .uni-combox,
  1159. .uni-easyinput__content,
  1160. //.cwg-combox,
  1161. .uni-date-editor--x {
  1162. padding: 0.5rem px2rpx(10);
  1163. height: 3rem!important;
  1164. //border: none !important;
  1165. border-radius: px2rpx(8);
  1166. }
  1167. .cwg-combox{
  1168. background-color: transparent !important;
  1169. }
  1170. .code{
  1171. .uni-easyinput__content{
  1172. border-radius: px2rpx(8) 0 0 px2rpx(8);
  1173. }
  1174. }
  1175. }
  1176. :deep(.uni-stat-box) {
  1177. height: 100%;
  1178. }
  1179. :deep(.uni-select) {
  1180. height: 100%;
  1181. }
  1182. :deep(.uni-easyinput__content) {
  1183. height: 100%;
  1184. }
  1185. :deep(.uni-date-editor) {
  1186. height: 100%;
  1187. }
  1188. :deep(.uni-date-editor--x) {
  1189. height: 100%;
  1190. }
  1191. .btn-code {
  1192. //margin-left: -10px;
  1193. width: px2rpx(120);
  1194. height: 3rem;
  1195. box-sizing: border-box;
  1196. background-color: #102047;
  1197. //border: 1px solid rgb(229, 229, 229);
  1198. color: #fff;
  1199. text-align: center;
  1200. line-height: 3rem;
  1201. border-radius: 0 25px 25px 0;
  1202. cursor: pointer;
  1203. font-size: 14px;
  1204. flex-shrink: 0;
  1205. }
  1206. .check-box {
  1207. padding: 0 px2rpx(10);
  1208. margin-bottom: px2rpx(10);
  1209. display: flex;
  1210. align-items: center;
  1211. cursor: pointer;
  1212. .checkbox-label {
  1213. font-size: px2rpx(14);
  1214. color: #666666;
  1215. margin-left: px2rpx(8);
  1216. user-select: none;
  1217. }
  1218. :deep(.u-checkbox) {
  1219. display: flex;
  1220. align-items: flex-start;
  1221. }
  1222. }
  1223. .regiset-btn {
  1224. width: 100%;
  1225. height: px2rpx(40);
  1226. border-radius: px2rpx(20);
  1227. background-color: var(--color-error);
  1228. color: #fff;
  1229. font-weight: bold;
  1230. }
  1231. .login-link {
  1232. width: 100%;
  1233. margin-top: px2rpx(20);
  1234. text-align: center;
  1235. display: flex;
  1236. align-items: center;
  1237. justify-content: center;
  1238. font-size: px2rpx(16);
  1239. line-height: 1.6;
  1240. }
  1241. .link {
  1242. margin-left: px2rpx(5);
  1243. color: #e61f1e;
  1244. padding-bottom: 2px;
  1245. cursor: pointer;
  1246. font-size: px2rpx(14);
  1247. }
  1248. .agreemnet9 {
  1249. text-align: initial;
  1250. color: #e61f1e;
  1251. }
  1252. .des-bottom {
  1253. margin-top: px2rpx(20);
  1254. line-height: 20px;
  1255. color: #000;
  1256. font-size: 12px;
  1257. .desc-link {
  1258. display: inline-block;
  1259. color: #e61f1e;
  1260. text-decoration: underline;
  1261. }
  1262. }
  1263. </style>