index.vue 36 KB

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