index.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406
  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.$emit('updateSystemList', 'login')
  634. if (res.code === 200) {
  635. switch (modeStore.value) {
  636. case 'customer':
  637. router.reLaunch('/pages/customer/index')
  638. break
  639. case 'ib':
  640. router.reLaunch('/pages/ib/index')
  641. break
  642. case 'follow':
  643. router.reLaunch('/pages/follow/index')
  644. break
  645. default:
  646. break
  647. }
  648. } else {
  649. uni.$u.toast(res.msg || t('login.msg0'))
  650. }
  651. } catch (error) {
  652. // console.log(error, 111);
  653. }
  654. }
  655. async function getCardUserInfo() {
  656. try {
  657. const res = await ucardApi.getSingle()
  658. userStore.saveUserInfo(res.data)
  659. if (res.code === 200) {
  660. if (!res.data || res.data.approveStatus != 2) {
  661. router.push('/pages/mine/improve')
  662. } else {
  663. router.push('/pages/card/index')
  664. }
  665. } else {
  666. uni.$u.toast(res.msg || t('login.msg0'))
  667. }
  668. } catch (error) {
  669. // console.log(error, 111);
  670. }
  671. }
  672. async function reasonsRefusalList() {
  673. try {
  674. const res = await customApi.reasonsRefusalList()
  675. if (res.code === 200) {
  676. pickFields(res.data)
  677. } else {
  678. uni.$u.toast(res.msg || t('login.msg0'))
  679. }
  680. } catch (error) {
  681. // console.log(error, 111);
  682. }
  683. }
  684. function pickFields(source, fields = ['content', 'enContent']) {
  685. const result = {}
  686. Object.entries(source).forEach(([key, value]) => {
  687. result[key] = fields.reduce((acc, f) => {
  688. acc[f] = value[f] ?? null
  689. return acc
  690. }, {})
  691. })
  692. userStore.saveReasonsOptions(result)
  693. }
  694. onMounted(() => {
  695. uni.$emit('updateSystemList','login')
  696. const accountInfo = userStore.accountInfo
  697. if (accountInfo?.rememberPassword) {
  698. form.value.loginName = accountInfo?.loginName || ''
  699. form.value.password = accountInfo?.password || ''
  700. remenber.value = ['记住我']
  701. } else {
  702. form.value.loginName = ''
  703. form.value.password = ''
  704. remenber.value = []
  705. }
  706. // 注册表单初始化
  707. getCountry()
  708. getCountryMsg()
  709. const hostParts = window.location.host.split('.')
  710. ho.value = hostParts.length > 1 ? hostParts[1] : ''
  711. })
  712. const inputType = ref('password')
  713. const isChatIconExpanded = ref(false)
  714. // 处理聊天图标点击
  715. const handleChatIconClick = () => {
  716. // 如果还没显示 → 先滑出来
  717. if (!isChatIconExpanded.value) {
  718. isChatIconExpanded.value = true
  719. return
  720. }
  721. if (isMobile.value) {
  722. router.push('/pages/common/chat')
  723. } else {
  724. if (LiveChatService) {
  725. LiveChatService.showChat()
  726. }
  727. }
  728. setTimeout(() => {
  729. isChatIconExpanded.value = false
  730. }, 300)
  731. }
  732. </script>
  733. <style lang="scss" scoped>
  734. @import "@/uni.scss";
  735. :deep(uni-content) {
  736. padding-left: 0 !important;
  737. }
  738. .login-page {
  739. height: 100vh;
  740. border: none;
  741. padding: 0;
  742. position: relative;
  743. display: flex;
  744. flex-direction: column;
  745. }
  746. .chat-icon {
  747. width: px2rpx(50);
  748. height: px2rpx(50);
  749. border-radius: 50%;
  750. background-color: #cf1322;
  751. display: flex;
  752. align-items: center;
  753. justify-content: center;
  754. position: fixed;
  755. bottom: px2rpx(25);
  756. right: px2rpx(-25);
  757. z-index: 999;
  758. cursor: pointer;
  759. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  760. box-shadow: 0 px2rpx(8) px2rpx(20) rgba(0, 0, 0, 0.15);
  761. will-change: transform;
  762. }
  763. .chat-icon:hover {
  764. transform: scale(1.1);
  765. }
  766. .chat-icon-expanded {
  767. bottom: px2rpx(20);
  768. right: px2rpx(20);
  769. transform: scale(1.1);
  770. box-shadow: 0 px2rpx(12) px2rpx(30) rgba(0, 0, 0, 0.2);
  771. }
  772. .chat-icon-hidden {
  773. display: none;
  774. }
  775. .fixed {
  776. width: 100%;
  777. height: var(--status-bar-height);
  778. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  779. z-index: 9;
  780. }
  781. .global-header-bar {
  782. width: 100%;
  783. height: px2rpx(60);
  784. display: flex;
  785. align-items: center;
  786. justify-content: center;
  787. flex-shrink: 0;
  788. z-index: 100;
  789. &.pc-header {
  790. background-color: transparent;
  791. }
  792. .header-inner {
  793. width: 100%;
  794. padding: 0 5%;
  795. display: flex;
  796. justify-content: space-between;
  797. /* 两端对齐,可放logo和组件 */
  798. align-items: center;
  799. }
  800. }
  801. .mobile-header-bar {
  802. //position: absolute;
  803. //top: px2rpx(20);
  804. //right: px2rpx(20);
  805. z-index: 10;
  806. width: 100%;
  807. display: flex;
  808. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  809. justify-content: flex-end;
  810. }
  811. .main-content {
  812. flex: 1;
  813. overflow: hidden;
  814. }
  815. .demo-uni-row {
  816. height: 100%;
  817. margin: 0 !important;
  818. .left-bg {
  819. height: 100%;
  820. min-height: calc(100vh - 120px);
  821. background-image: url(/static/images/login-bg.jpeg);
  822. background-size: cover;
  823. background-position: center;
  824. display: flex;
  825. box-sizing: border-box;
  826. padding: px2rpx(50);
  827. //flex-direction: column;
  828. //align-items: center;
  829. justify-content: center;
  830. .left-box {
  831. display: flex;
  832. flex-direction: column;
  833. justify-content: center;
  834. align-items: flex-start;
  835. width: 60%;
  836. //margin-top: px2rpx(20);
  837. .inner {
  838. width: 100%;
  839. text-align: start;
  840. //margin-bottom: px2rpx(20);
  841. .section-title {
  842. //margin-top: px2rpx(10);
  843. //margin-bottom: px2rpx(10);
  844. }
  845. .title {
  846. margin: 0 0 0 px2rpx(10);
  847. font-size: px2rpx(56);
  848. line-height: 1.2;
  849. color: #fff;
  850. font-weight: 700;
  851. text-align: left;
  852. }
  853. .w-700 {
  854. font-weight: 700;
  855. }
  856. .subtitle {
  857. width: 45%;
  858. font-size: px2rpx(18);
  859. letter-spacing: px2rpx(1);
  860. display: block;
  861. margin-bottom: px2rpx(24);
  862. color: #ffffff;
  863. line-height: px2rpx(15);
  864. font-weight: 500;
  865. padding: px2rpx(10) px2rpx(20);
  866. border-radius: px2rpx(100);
  867. text-transform: uppercase;
  868. background-color: #e61f1e;
  869. text-align: center;
  870. }
  871. .w-40 {
  872. max-width: 40%;
  873. }
  874. .text-white {
  875. margin-top: px2rpx(10);
  876. font-size: px2rpx(18);
  877. margin-bottom: px2rpx(16);
  878. line-height: 1.6;
  879. color: var(--bs-emphasis-color);
  880. }
  881. }
  882. .img-fluid {
  883. width: 400px;
  884. height: 33px;
  885. }
  886. .mt--10 {
  887. margin-top: px2rpx(10);
  888. }
  889. .h1 {
  890. // text-align: center;
  891. color: var(--bs-emphasis-color);
  892. font-size: 30px;
  893. margin-top: 30px;
  894. line-height: 1.5;
  895. }
  896. .h6 {
  897. text-align: start;
  898. line-height: 20px;
  899. color: var(--bs-emphasis-color);
  900. font-size: 14px;
  901. margin-top: 10px;
  902. }
  903. .company {
  904. padding: px2rpx(10) 0 px2rpx(10) 0;
  905. position: relative;
  906. align-items: flex-start !important;
  907. width: 100%;
  908. }
  909. }
  910. .left-content {
  911. width: 100%;
  912. .des {
  913. text-align: start;
  914. line-height: 24px;
  915. color: var(--bs-emphasis-color);
  916. font-size: 14px;
  917. //margin-top: px2rpx(20);
  918. :nth-child(n) {
  919. display: inline;
  920. word-break: break-all;
  921. word-wrap: break-word;
  922. }
  923. .doc-link {
  924. color: var(--color-error);
  925. text-decoration: underline;
  926. margin: 0 px2rpx(4);
  927. }
  928. }
  929. }
  930. }
  931. .right-f {
  932. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  933. padding: 0 px2rpx(24);
  934. height: 100%;
  935. box-sizing: border-box;
  936. .account {
  937. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  938. position: relative;
  939. height: calc(100vh - 120px);
  940. display: flex;
  941. flex-direction: column;
  942. justify-content: center;
  943. padding: 0 10%;
  944. .company {
  945. padding: px2rpx(30) 0 px2rpx(20) 0;
  946. position: relative;
  947. align-items: center !important;
  948. }
  949. .company-icon {
  950. width: px2rpx(234);
  951. }
  952. .company-icon-mini {
  953. width: px2rpx(100);
  954. }
  955. }
  956. }
  957. }
  958. .bottom-box {
  959. width: 100%;
  960. height: 60px;
  961. background-color: rgba(var(--bs-body-bg-rgb), var(--bs-bg-opacity)) !important;
  962. display: flex;
  963. justify-content: center;
  964. align-items: center;
  965. color: #000;
  966. .bottom-title {
  967. text-align: center;
  968. font-size: px2rpx(14);
  969. font-weight: 500;
  970. line-height: 1.5;
  971. color: #666666;
  972. }
  973. .ellipsis {
  974. width: px2rpx(200);
  975. white-space: nowrap;
  976. overflow: hidden;
  977. text-overflow: ellipsis;
  978. }
  979. .cwg-button {
  980. width: 120px !important;
  981. padding: px2rpx(4) 0 !important;
  982. }
  983. }
  984. button {
  985. background-color: #ea002a;
  986. font-size: px2rpx(14);
  987. font-weight: normal;
  988. height: px2rpx(44);
  989. line-height: px2rpx(44);
  990. }
  991. .right-f .account .company {
  992. padding: px2rpx(50) 0 px2rpx(200) 0;
  993. position: relative;
  994. align-items: flex-start !important;
  995. }
  996. .logo {
  997. margin-left: px2rpx(48);
  998. }
  999. .left-bg .company-icon {
  1000. width: px2rpx(234);
  1001. }
  1002. .left-bg .left-content {
  1003. position: relative;
  1004. z-index: 1;
  1005. }
  1006. .title {
  1007. margin: px2rpx(15) 0;
  1008. font-size: px2rpx(24);
  1009. font-weight: bolder;
  1010. color: var(--bs-emphasis-color);
  1011. text-align: center;
  1012. i {
  1013. margin-right: px2rpx(10);
  1014. }
  1015. .tit1 {
  1016. font-size: px2rpx(34);
  1017. line-height: 1.5;
  1018. font-weight: bold;
  1019. color: var(--bs-emphasis-color);
  1020. }
  1021. .tit2 {
  1022. font-size: px2rpx(16);
  1023. line-height: 1.5;
  1024. color: #cecece;
  1025. font-weight: 500;
  1026. }
  1027. }
  1028. .qr-title {
  1029. font-size: px2rpx(16);
  1030. line-height: 1.5;
  1031. color: #cecece;
  1032. font-weight: 500;
  1033. text-align: center;
  1034. margin: px2rpx(40) 0;
  1035. display: flex;
  1036. align-items: center;
  1037. justify-content: center;
  1038. .line {
  1039. flex: 1;
  1040. height: 1px;
  1041. background-color: #e4e4e4;
  1042. }
  1043. .qr-tit2 {
  1044. margin: 0 px2rpx(12);
  1045. }
  1046. }
  1047. .input {
  1048. height: px2rpx(44);
  1049. border-radius: px2rpx(8);
  1050. background: #f7f8fa;
  1051. padding: 0 px2rpx(20) !important;
  1052. position: relative;
  1053. }
  1054. .account-icon {
  1055. width: px2rpx(12);
  1056. height: px2rpx(14) !important;
  1057. margin-right: px2rpx(5);
  1058. }
  1059. :deep(.u-input__content__prefix-icon) {
  1060. height: px2rpx(20);
  1061. }
  1062. .regiset-btn {
  1063. margin: px2rpx(20) 0;
  1064. border-radius: px2rpx(20);
  1065. }
  1066. .account-tip {
  1067. color: #666666;
  1068. font-size: px2rpx(14);
  1069. text-align: center;
  1070. text {
  1071. color: #ea002a;
  1072. }
  1073. }
  1074. :deep(.u-form-item__body) {
  1075. padding: 0 !important;
  1076. padding-bottom: px2rpx(24) !important;
  1077. }
  1078. :deep(.wcg-checkbox) {
  1079. padding: 0 !important;
  1080. }
  1081. .cwg-button {
  1082. padding: px2rpx(34) 0 !important;
  1083. }
  1084. .tab-list {
  1085. width: 100%;
  1086. display: flex;
  1087. align-items: center;
  1088. justify-content: center;
  1089. border-bottom: 1px solid var(--bs-border-color);
  1090. }
  1091. .tab-item {
  1092. width: 50%;
  1093. margin: 0 px2rpx(15);
  1094. padding-right: 0;
  1095. padding-left: 0;
  1096. padding-bottom: 8px;
  1097. text-align: center;
  1098. border-bottom: 2px solid transparent;
  1099. font-weight: 500;
  1100. color: var(--bs-emphasis-color);
  1101. cursor: pointer;
  1102. transition: all 0.3s ease;
  1103. .tab-label {
  1104. font-size: px2rpx(24);
  1105. }
  1106. &:hover,
  1107. &:focus {
  1108. font-weight: 700;
  1109. color: #e32326;
  1110. border-bottom-color: #e32326;
  1111. }
  1112. &.active {
  1113. font-weight: 700;
  1114. color: #e32326;
  1115. border-bottom-color: #e32326;
  1116. }
  1117. }
  1118. /* 注册表单样式 */
  1119. .pwd {
  1120. list-style: none;
  1121. padding-left: 0;
  1122. margin: 0;
  1123. li {
  1124. font-size: px2rpx(12);
  1125. color: var(--bs-heading-color);
  1126. line-height: px2rpx(20);
  1127. position: relative;
  1128. padding-left: px2rpx(16);
  1129. &::before {
  1130. content: '';
  1131. position: absolute;
  1132. left: 0;
  1133. top: 50%;
  1134. transform: translateY(-50%);
  1135. width: px2rpx(6);
  1136. height: px2rpx(6);
  1137. border-radius: 50%;
  1138. background-color: var(--bs-heading-color);
  1139. }
  1140. &.fit {
  1141. color: #67c23a;
  1142. &::before {
  1143. background-color: #67c23a;
  1144. }
  1145. }
  1146. }
  1147. }
  1148. :deep(.formContent) {
  1149. padding: 0 10px;
  1150. .uni-select,
  1151. .uni-combox,
  1152. .uni-easyinput__content,
  1153. //.cwg-combox,
  1154. .uni-date-editor--x {
  1155. padding: 0.5rem px2rpx(10);
  1156. height: 3rem!important;
  1157. //border: none !important;
  1158. border-radius: px2rpx(8);
  1159. }
  1160. .cwg-combox{
  1161. background-color: transparent !important;
  1162. }
  1163. .code{
  1164. .uni-easyinput__content{
  1165. border-radius: px2rpx(8) 0 0 px2rpx(8);
  1166. }
  1167. }
  1168. }
  1169. :deep(.uni-stat-box) {
  1170. height: 100%;
  1171. }
  1172. :deep(.uni-select) {
  1173. height: 100%;
  1174. }
  1175. :deep(.uni-easyinput__content) {
  1176. height: 100%;
  1177. }
  1178. :deep(.uni-date-editor) {
  1179. height: 100%;
  1180. }
  1181. :deep(.uni-date-editor--x) {
  1182. height: 100%;
  1183. }
  1184. .btn-code {
  1185. //margin-left: -10px;
  1186. width: px2rpx(120);
  1187. height: 3rem;
  1188. box-sizing: border-box;
  1189. background-color: #102047;
  1190. //border: 1px solid rgb(229, 229, 229);
  1191. color: #fff;
  1192. text-align: center;
  1193. line-height: 3rem;
  1194. border-radius: 0 25px 25px 0;
  1195. cursor: pointer;
  1196. font-size: 14px;
  1197. flex-shrink: 0;
  1198. }
  1199. .check-box {
  1200. padding: 0 px2rpx(10);
  1201. margin-bottom: px2rpx(10);
  1202. display: flex;
  1203. align-items: center;
  1204. cursor: pointer;
  1205. .checkbox-label {
  1206. font-size: px2rpx(14);
  1207. color: #666666;
  1208. margin-left: px2rpx(8);
  1209. user-select: none;
  1210. }
  1211. :deep(.u-checkbox) {
  1212. display: flex;
  1213. align-items: flex-start;
  1214. }
  1215. }
  1216. .regiset-btn {
  1217. width: 100%;
  1218. height: px2rpx(40);
  1219. border-radius: px2rpx(20);
  1220. background-color: var(--color-error);
  1221. color: #fff;
  1222. font-weight: bold;
  1223. }
  1224. .login-link {
  1225. width: 100%;
  1226. margin-top: px2rpx(20);
  1227. text-align: center;
  1228. display: flex;
  1229. align-items: center;
  1230. justify-content: center;
  1231. font-size: px2rpx(16);
  1232. line-height: 1.6;
  1233. }
  1234. .link {
  1235. margin-left: px2rpx(5);
  1236. color: #e61f1e;
  1237. padding-bottom: 2px;
  1238. cursor: pointer;
  1239. font-size: px2rpx(14);
  1240. }
  1241. .agreemnet9 {
  1242. text-align: initial;
  1243. color: #e61f1e;
  1244. }
  1245. .des-bottom {
  1246. margin-top: px2rpx(20);
  1247. line-height: 20px;
  1248. color: #000;
  1249. font-size: 12px;
  1250. .desc-link {
  1251. display: inline-block;
  1252. color: #e61f1e;
  1253. text-decoration: underline;
  1254. }
  1255. }
  1256. </style>