regist.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. <script setup>
  2. import { ref, reactive, watch,onMounted } from 'vue'
  3. import { post, get } from '@/utils/request'
  4. import { useRequest } from '@/composables/useRequest'
  5. import { useI18n } from 'vue-i18n'
  6. import { useEmailCountdown } from '@/hooks/useEmailCountdown'
  7. import { ucardApi } from '@/api/ucard'
  8. import { showToast } from '@/utils/toast'
  9. const SendCodeByPhone = (params) => post('/Common/SendCodeByPhone', params)
  10. const PhoneLoginReg = (params) => post('/Login/PhoneLoginReg', params)
  11. const { t } = useI18n()
  12. const {
  13. time,
  14. text: getCodeString,
  15. canSend,
  16. start,
  17. restore
  18. } = useEmailCountdown()
  19. // 响应式表单数据
  20. const formData = ref({
  21. country: '',
  22. birthDate:'',
  23. code: '',
  24. password: '',
  25. agentId: null,
  26. agentValue: '',
  27. userType: 4,
  28. userTypeName: '全民营销',
  29. readName: '',
  30. agree: '',
  31. })
  32. const ho = ref('')
  33. // 账号类型
  34. const accountType = ref(1)
  35. const columnsAgent = ref([])
  36. const columnsType = ref([
  37. {
  38. text: '中介',
  39. value: 3,
  40. },
  41. {
  42. text: '全民营销',
  43. value: 4,
  44. },
  45. ])
  46. // 校验规则
  47. const rules = {
  48. mobile: [
  49. {
  50. required: true,
  51. message: '请输入用户名或手机号',
  52. trigger: ['change', 'blur'],
  53. },
  54. {
  55. // 自定义验证函数,见上说明
  56. validator: (rule, value, callback) => {
  57. // 上面有说,返回true表示校验通过,返回false表示不通过
  58. // uni.$u.test.mobile()就是返回true或者false的
  59. return uni.$u.test.mobile(value)
  60. },
  61. message: '手机号码不正确',
  62. // 触发器可以同时用blur和change
  63. trigger: ['change', 'blur'],
  64. },
  65. ],
  66. code: [
  67. {
  68. required: true,
  69. message: '请输入验证码',
  70. trigger: ['change', 'blur'],
  71. },
  72. ],
  73. password: [
  74. {
  75. required: true,
  76. message: '请输入密码',
  77. trigger: ['change', 'blur'],
  78. },
  79. ],
  80. readName: [
  81. {
  82. required: true,
  83. message: '请输入真实姓名',
  84. trigger: ['change', 'blur'],
  85. },
  86. ],
  87. agentValue: [
  88. {
  89. required: true,
  90. message: '请选择中介',
  91. trigger: ['change', 'blur'],
  92. },
  93. ],
  94. }
  95. const tips = ref('')
  96. const value = ref('')
  97. const seconds = ref(60)
  98. const uCodeRef = ref(null)
  99. const timer = ref(59)
  100. const interval = ref(null)
  101. watch(value, (newValue, oldValue) => {
  102. // console.log('v-model', newValue);
  103. })
  104. const codeChange = (text) => {
  105. tips.value = text
  106. }
  107. const change = (e) => {
  108. // console.log("change", e);
  109. }
  110. const showAgent = ref(false)
  111. const confirmAgent = (e) => {
  112. // console.log("e: ", e);
  113. form.value.agentValue = e.value[0].text
  114. form.value.agentId = e.value[0].value
  115. showAgent.value = false
  116. }
  117. const showType = ref(false)
  118. const confirmType = (e) => {
  119. // console.log("e: ", e);
  120. form.value.userTypeName = e.value[0].text
  121. form.value.userType = e.value[0].value
  122. if (form.value.userType == 4) {
  123. form.value.agentValue = ''
  124. form.value.agentId = ''
  125. }
  126. showType.value = false
  127. }
  128. const uFormRef = ref(null)
  129. // 切换注册账号类型
  130. const changeAccountType = (type) => {
  131. if (accountType.value !== type) accountType.value = type
  132. }
  133. // 获取验证码按钮点击
  134. async function handleGetCode() {
  135. if (!canSend.value) return
  136. await sendEmailCode();
  137. }
  138. // 发送邮箱验证码
  139. async function sendEmailCode() {
  140. const res = await ucardApi.getBlockchainWithdrawSendEmailCode({
  141. ...formData.value,
  142. });
  143. if (res.code === 200) {
  144. showToast(t("Msg.CodeSuccess"));
  145. start()
  146. return true;
  147. } else {
  148. showToast(t("Msg.CodeFail"));
  149. return false;
  150. }
  151. }
  152. const aloneChecked = ref(false)
  153. const getRichText = (url) => {
  154. uni.navigateTo({
  155. url,
  156. })
  157. }
  158. const GetAgencys = (params) => get('/Buss/GetAgencys', params)
  159. const { data, loading, error, refresh } = useRequest(GetAgencys, {
  160. initialParams: {},
  161. immediate: true, // 默认立即执行
  162. })
  163. onMounted(()=>{
  164. const hostParts = window.location.host.split('.')
  165. ho.value = hostParts.length > 1 ? hostParts[1] : ''
  166. })
  167. watch([loading, error], () => {
  168. if (!loading.value) {
  169. // 加载完成
  170. if (error.value) {
  171. // console.log("请求失败: ", error.value); // 打印错误信息
  172. } else {
  173. // console.log("请求成功: ", data.value); // 成功时获取数据
  174. columnsAgent.value = data.value.map((item) => {
  175. return {
  176. text: item.name,
  177. value: item.id,
  178. }
  179. })
  180. }
  181. }
  182. })
  183. </script>
  184. <template>
  185. <cwg-page-wrapper class="regist-page" :isHeaderFixed="true" :isLoginPage="true">
  186. <uni-row class="content">
  187. <uni-col :span="20" :offset="2" :sm="{ span: 14 , offset:5}">
  188. <view class="logo">
  189. <image src="/static/images/logo.png" class="company-icon" mode="widthFix"></image>
  190. </view>
  191. <!-- 账号类型-->
  192. <view class="account-type">
  193. <view class="type-btn" @click="changeAccountType(1)" :class="{active:accountType === 1}">Open Live Account
  194. </view>
  195. <view class="type-btn" @click="changeAccountType(2)" :class="{active:accountType === 2}">Register Demo
  196. Account
  197. </view>
  198. </view>
  199. <view class="account-tip">
  200. <view class="title">{{ accountType === 1 ? 'Open Live Account' : 'Register Demo Account' }}</view>
  201. <view class="tip">
  202. {{ accountType === 1 ? 'Please enter your required information' : 'Register Demo Account' }}
  203. </view>
  204. </view>
  205. <uni-forms ref="form" :modelValue="formData" validate-trigger="blur" label-position="top" label-width="120">
  206. <uni-row :gutter="20" class="formContent">
  207. <uni-col :xs="24" :md="12">
  208. <uni-forms-item name="country" :label="t('newSignup.item3')">
  209. <uni-data-select class="formStyle" v-model="formData.country">
  210. </uni-data-select>
  211. </uni-forms-item>
  212. </uni-col>
  213. <uni-col :xs="24" :md="12">
  214. <uni-forms-item name="phone" :label="t('newSignup.item5')">
  215. <uni-easyinput class="formStyle" v-model="formData.phone"></uni-easyinput>
  216. </uni-forms-item>
  217. </uni-col>
  218. <uni-col :xs="24" :md="12">
  219. <uni-forms-item name="birthDate" :label="t('newSignup.item18')">
  220. <uni-datetime-picker class="formStyle" type="date" v-model="formData.birthDate" :placeholder="t('newSignup.item19')"/>
  221. </uni-forms-item>
  222. </uni-col>
  223. <uni-col :xs="24" :md="12">
  224. <uni-forms-item name="email" :label="t('newSignup.item7')">
  225. <uni-easyinput class="formStyle" v-model="formData.email" :placeholder="t('newSignup.item8')"></uni-easyinput>
  226. </uni-forms-item>
  227. </uni-col>
  228. <uni-col :xs="24" :md="12">
  229. <uni-forms-item name="code" :label="t('newSignup.item7')">
  230. <uni-easyinput class="formStyle" v-model="formData.code" :placeholder="t('newSignup.item8')">
  231. <template #right>
  232. <view class="btn-code" @click="handleGetCode">{{getCodeString}}</view>
  233. </template>
  234. </uni-easyinput>
  235. </uni-forms-item>
  236. </uni-col>
  237. </uni-row>
  238. </uni-forms>
  239. <view class="check-box">
  240. <up-checkbox-group v-model="formData.agree">
  241. <up-checkbox size="14" labelSize="14" labelColor="#666666" activeColor="#ea002a" v-model="formData.agree" :label="t('signup.agree')" name="" class="wcg-checkbox"></up-checkbox>
  242. </up-checkbox-group>
  243. </view>
  244. <view class="check-box">
  245. <up-checkbox-group v-model="formData.isSubscribeEmail">
  246. <up-checkbox size="14" labelSize="14" labelColor="#666666" activeColor="#ea002a" v-model="formData.isSubscribeEmail" :label="t('signup.agree1')" name="" class="wcg-checkbox"></up-checkbox>
  247. </up-checkbox-group>
  248. </view>
  249. <view>
  250. <u-button class="regiset-btn">
  251. {{t('signup.button')}}
  252. </u-button>
  253. </view>
  254. <view class="or-title">
  255. <view class="line"></view>
  256. <view class="qr-tit2">OR</view>
  257. <view class="line"></view>
  258. </view>
  259. <uni-row :gutter="20">
  260. <uni-col :xs="24" :md="12">
  261. <u-button class="login-btn">
  262. {{t('signup.button')}}
  263. </u-button>
  264. </uni-col>
  265. <uni-col :xs="24" :md="12">
  266. <u-button class="login-btn">
  267. {{t('signup.button')}}
  268. </u-button>
  269. </uni-col>
  270. </uni-row>
  271. </uni-col>
  272. </uni-row>
  273. <view class="des">
  274. <view>
  275. {{t('newSignin.item12')}}
  276. </view><br />
  277. <view>
  278. {{t('newSignin.item10')}}
  279. </view><br />
  280. <view>
  281. {{t('newSignin.item11')}}
  282. </view><br />
  283. <view>{{ t('newSignin.item13') }}</view>
  284. <a
  285. :href="`https://www.${ho}.com/doc/Risk-Disclosures-and-Acknowledgements-2020-08.pdf`"
  286. target="_blank"
  287. >
  288. {{ t('newSignin.item13_1') }}
  289. </a>
  290. <view>{{ t('newSignin.item13_2') }}</view>
  291. <view>{{ t('newSignin.item13_3') }}</view>
  292. <view>{{ t('newSignin.item13_4') }}</view>
  293. </view>
  294. </cwg-page-wrapper>
  295. </template>
  296. <style lang="scss">
  297. </style>
  298. <style lang="scss" scoped>
  299. @import "@/uni.scss";
  300. .regist-page {
  301. height: 100vh;
  302. border: none;
  303. padding: 0;
  304. }
  305. .content {
  306. //display: flex;
  307. .logo {
  308. width: 100%;
  309. margin-top: px2rpx(40);
  310. display: flex;
  311. align-items: center;
  312. justify-content: center;
  313. }
  314. .company-icon {
  315. width: px2rpx(234);
  316. }
  317. .account-type {
  318. width: 100%;
  319. margin-top: px2rpx(20);
  320. padding: px2rpx(10);
  321. background-color: $uni-bg-color-hover;
  322. height: px2rpx(60);
  323. box-sizing: border-box;
  324. border-radius: px2rpx(20);
  325. display: flex;
  326. align-items: center;
  327. .type-btn {
  328. width: 50%;
  329. text-align: center;
  330. height: px2rpx(40);
  331. border-radius: px2rpx(20);
  332. line-height: px2rpx(40);
  333. font-size: px2rpx(18);
  334. cursor: pointer;
  335. &.active {
  336. background-color: var(--primary-color);
  337. }
  338. }
  339. }
  340. }
  341. .formStyle {
  342. height: px2rpx(40);
  343. }
  344. .account-tip {
  345. width: 100%;
  346. text-align: center;
  347. margin: px2rpx(30) 0;
  348. .title {
  349. font-size: px2rpx(26);
  350. font-weight: bold;
  351. }
  352. .tip {
  353. margin-top: px2rpx(5);
  354. color: var(--gray);
  355. }
  356. }
  357. .formContent{
  358. padding: 0 10px;
  359. }
  360. // 修改表单组件高度。
  361. :deep(.uni-stat-box){
  362. height: 100%;
  363. }
  364. :deep(.uni-select){
  365. height: 100%;
  366. }
  367. :deep(.uni-easyinput__content){
  368. height: 100%;
  369. }
  370. :deep(.uni-date-editor){
  371. height: 100%;
  372. }
  373. :deep(.uni-date-editor--x){
  374. height: 100%;
  375. }
  376. .btn-code{
  377. width: 30%;
  378. height: 100%;
  379. background-color: #102047;
  380. border: 1px solid #f0f0f0;
  381. color: #fff;
  382. text-align: center;
  383. line-height: px2rpx(40);
  384. border-radius: 0 4px 4px 0;
  385. }
  386. .check-box{
  387. padding: 0 px2rpx(10);
  388. margin-bottom: px2rpx(10);
  389. :deep(.u-checkbox){
  390. display: flex;
  391. align-items: flex-start;
  392. }
  393. }
  394. .regiset-btn{
  395. width: 100%;
  396. height: px2rpx(40);
  397. border-radius: px2rpx(20);
  398. background-color: #DE002D;
  399. color: #fff;
  400. font-weight: bold;
  401. }
  402. .or-title {
  403. font-size: px2rpx(16);
  404. line-height: 1.5;
  405. color: #333;
  406. font-weight: 500;
  407. text-align: center;
  408. margin: px2rpx(20) 0 px2rpx(18) 0;
  409. display: flex;
  410. align-items: center;
  411. justify-content: center;
  412. .line {
  413. flex: 1;
  414. height: 1px;
  415. background-color: #e4e4e4;
  416. }
  417. .qr-tit2 {
  418. margin: 0 px2rpx(12);
  419. }
  420. }
  421. .login-btn{
  422. width: 100%;
  423. height: px2rpx(40);
  424. border-radius: px2rpx(20);
  425. background-color: #1EBF42;
  426. color: #fff;
  427. font-weight: bold;
  428. margin-bottom: px2rpx(20);
  429. }
  430. .code-text {
  431. padding-right: px2rpx(20);
  432. }
  433. .des {
  434. width: 100%;
  435. box-sizing: border-box;
  436. text-align: start;
  437. line-height: 20px;
  438. color: #000;
  439. font-size: 12px;
  440. padding: px2rpx(20) px2rpx(30);
  441. //display: none;
  442. :nth-child(n){
  443. display: inline;
  444. word-break:break-all;
  445. word-wrap:break-word;
  446. }
  447. a {
  448. color: #e61f1e;
  449. }
  450. }
  451. :deep(.u-text__value) {
  452. color: #ea002a !important;
  453. font-size: px2rpx(14) !important;
  454. }
  455. </style>