register.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672
  1. <template>
  2. <view class="login">
  3. <header-logo></header-logo>
  4. <view class="login-main" v-if="step == 1">
  5. <div class="title">
  6. <!-- Sign Up -->
  7. {{ $t('login.registertips') }}
  8. </div>
  9. <div class="tip">
  10. <!-- We will send on otp to your Mobile phone -->
  11. {{ $t('login.lab36') }}
  12. </div>
  13. <u--form labelPosition="left" :rules="rules" ref="uForm" :model="userInfo">
  14. <u-form-item prop="mobile" borderBottom ref="item1">
  15. <u--input placeholderStyle="color: #4E4E4E" color="#4E4E4E" fontSize="16px" v-model="userInfo.mobile" :placeholder="$t('login.lab1')" border="none">
  16. <template slot="prefix">
  17. <div class="code-box" @click="regionShow = true">
  18. <img class="thumbnail" :src="thumbnail" alt="">
  19. <div>+ {{ code }}</div>
  20. </div>
  21. </template>
  22. </u--input>
  23. </u-form-item>
  24. </u--form>
  25. <div class="checkbox" @click="checked = !checked">
  26. <div class="no" v-if="!checked"></div>
  27. <img v-show="checked" class="img" src="/static/image/login/checked.png" alt="">
  28. {{ $t('login.lab24') }} &nbsp;<a class="line" @click.stop="$toUrl('/pages/login/agreement?type=1')">{{ $t('login.lab25') }}</a>&nbsp; {{ $t('login.lab26') }} &nbsp;<a class="line" @click.stop="$toUrl('/pages/login/agreement?type=2')">{{ $t('login.lab27') }}</a>&nbsp; {{ $t('login.lab28') }}
  29. </div>
  30. <div class="btn" @click="stepTwo">
  31. <!-- Continue -->
  32. {{ $t('login.lab37') }}
  33. </div>
  34. <u-divider :text="$t('login.lab46')" textColor="#4E4E4E" lineColor="#dddddd" textSize="16px"></u-divider>
  35. <div class="btn1">
  36. <img class="google" src="/static/image/login/google.png" alt="">
  37. {{ $t('login.lab38') }}
  38. <div id="google_id" data-client_id="798741970259-knrm21b19bmeh2miosrs11vkqilo5lo3.apps.googleusercontent.com"
  39. data-context="signin"
  40. data-auto_select="true"
  41. data-itp_support="true"
  42. data-auto_prompt="false"
  43. allow_parent_origin="https://m.onecric.tv">
  44. </div>
  45. </div>
  46. <!-- <div class="btn2" @click="faceLogin">
  47. <img class="google" src="/static/image/login/face.png" alt="">
  48. {{ $t('login.lab39') }}
  49. </div> -->
  50. </view>
  51. <view class="login-main" v-if="step == 2">
  52. <div class="title">
  53. <!-- Enter the 6 digit OTP -->
  54. {{ $t('login.lab3') }}
  55. </div>
  56. <div class="tip">{{ $t('login.lab4') }} +{{ code }} {{ userInfo.mobile }}</div>
  57. <div class="lab">
  58. <!-- In Case You Don't Find It, Check Your Junk Information. -->
  59. {{ $t('login.lab5') }}
  60. </div>
  61. <u--form labelPosition="left" :rules="rules" ref="uForm" :model="userInfo">
  62. <u-form-item prop="code" ref="item1">
  63. <u-code-input size="84rpx" hairline borderColor="#959595" fontSize="16px" space="37rpx" v-model="userInfo.code" mode="line"></u-code-input>
  64. </u-form-item>
  65. </u--form>
  66. <div class="fixed">
  67. <div class="box_btn_2">
  68. <div class="down-box" v-if="!timeFinish">
  69. <!-- Resend OTP IN -->
  70. {{ $t('login.lab6') }}
  71. <u-count-down @finish="timeFinishFun" :autoStart="autoStart" name="down" :time="2 * 60 * 1000" format="mm:ss"></u-count-down></div>
  72. <div class="down-box" v-if="timeFinish"><div class="Resend" @click="stepTwo">
  73. <!-- Resend -->
  74. {{ $t('login.lab7') }}
  75. </div></div>
  76. <div class="btn" @click="stepThree">
  77. <!-- verify -->
  78. {{ $t('login.lab8') }}
  79. </div>
  80. </div>
  81. </div>
  82. </view>
  83. <view class="login-main1" v-if="step == 3">
  84. <div class="top flex">
  85. <div class="flex" @click="stepBack">
  86. <u-icon name="arrow-left" color="#ffffff" size="16px" bold></u-icon>
  87. <!-- Sign Up -->
  88. {{ $t('login.registertips') }}
  89. </div>
  90. </div>
  91. <div class="section">
  92. <div class="tip">+{{ code }} {{ userInfo.mobile }}</div>
  93. <u--form labelPosition="left" :rules="rules" ref="uForm" :model="userInfo">
  94. <u-form-item prop="password" borderBottom ref="item1">
  95. <u--input placeholderStyle="color: #4E4E4E" color="#4E4E4E" fontSize="16px" :type="!pwshow ? 'password' : 'text'" v-model="userInfo.password" :placeholder="$t('login.lab40')" border="none">
  96. <img class="pwd" slot="prefix" src="/static/image/login/pwd.svg" alt="">
  97. </u--input>
  98. </u-form-item>
  99. </u--form>
  100. <div class="checkbox" @click="pwshow = !pwshow">
  101. <div class="no" v-if="!pwshow"></div>
  102. <img v-show="pwshow" class="img" src="/static/image/login/checked.png" alt="">
  103. <!-- Show Password -->
  104. {{ $t('login.lab41') }}
  105. </div>
  106. <div class="text">
  107. <!-- Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. -->
  108. {{ $t('login.lab42') }}
  109. </div>
  110. <div class="checkbox bold" @click="checked1 = !checked1">
  111. <div class="no" v-if="!checked1"></div>
  112. <img v-show="checked1" class="img" src="/static/image/login/checked.png" alt="">
  113. <!-- I have read and agree to the -->
  114. {{ $t('login.lab43') }}
  115. <a class="line" @click.stop="$toUrl('/pages/login/agreement?type=1')">
  116. <!-- Terms of Use -->
  117. {{ $t('login.lab44') }}
  118. </a>
  119. </div>
  120. </div>
  121. <div class="fixed">
  122. <div class="btn" @click="registered">
  123. <!-- Sign Up -->
  124. {{ $t('login.registertips') }}
  125. </div>
  126. <div class="create">
  127. <!-- Already have an account? -->
  128. {{ $t('login.lab45') }}
  129. <a class="router" @click.stop="$toUrl('/pages/login/login')">
  130. <!-- Log In -->
  131. {{ $t('login.login') }}
  132. </a></div>
  133. </div>
  134. </view>
  135. <u-overlay :show="regionShow" @close="close" @open="open" :closeable="regionShow">
  136. <selectRegion :tournamentList="tournamentList" @close="close" @checkboxChange="checkboxChange"></selectRegion>
  137. </u-overlay>
  138. </view>
  139. </template>
  140. <script>
  141. import selectRegion from '../components/selectRegion/index.vue'
  142. export default {
  143. components: {
  144. selectRegion
  145. },
  146. data() {
  147. return {
  148. userInfo: {
  149. mobile: "",
  150. password: "",
  151. code: ''
  152. },
  153. pwshow: false,
  154. rules: {},
  155. checked: false,
  156. checked1: false,
  157. step: 1,
  158. tournamentList: [],
  159. code: '',
  160. searchname: '',
  161. thumbnail: "",
  162. country_code: "",
  163. regionShow: false,
  164. autoStart: true,
  165. timeFinish: true,
  166. }
  167. },
  168. created() {
  169. this.get_cricket_tournament("");
  170. },
  171. beforeDestroy () {
  172. window.removeEventListener("load", this.gload);
  173. },
  174. mounted() {
  175. window.addEventListener("load", this.gload);
  176. },
  177. methods: {
  178. gload() {
  179. this.googleInit(this.handleCredentialResponse)
  180. // this.faceInit()
  181. },
  182. googleInit(fn) {
  183. if (window.google && window.google.accounts) {
  184. window.google.accounts.id.initialize({
  185. client_id: "798741970259-knrm21b19bmeh2miosrs11vkqilo5lo3.apps.googleusercontent.com",
  186. callback: fn,
  187. });
  188. const dom = document.getElementById("google_id");
  189. window.google.accounts.id.renderButton(dom, {
  190. type: "standard",
  191. shape: "square",
  192. theme: "",
  193. width: dom.offsetWidth + 'px',
  194. logo_alignment: "center",
  195. text: "signin_with",
  196. size: "large"
  197. });
  198. } else {
  199. }
  200. },
  201. decodeJwtResponse(token) { //加密
  202. const strings = token.split(".");
  203. return JSON.parse(
  204. decodeURIComponent(
  205. escape(window.atob(strings[1].replace(/-/g, "+").replace(/_/g, "/")))
  206. )
  207. );
  208. },
  209. handleCredentialResponse(response) {
  210. if (response) {
  211. const responsePayload = this.decodeJwtResponse(response.credential);
  212. uni.showLoading({
  213. title: this.$t('common.lab'),
  214. });
  215. let obj = {
  216. id: responsePayload.sub,
  217. name: responsePayload.name,
  218. photo: responsePayload.picture,
  219. device_type: 'h5',
  220. }
  221. uni.$u.http
  222. .get("/api/v1/google_login", {
  223. params: obj,
  224. }).then(res => {
  225. uni.showToast({
  226. title: this.$t('login.lab35'),
  227. icon: "success",
  228. });
  229. this.$store.state.info = res;
  230. this.$store.state.isLogin = 1;
  231. uni.setStorage({
  232. key: "information",
  233. data: res,
  234. });
  235. this.$store.dispatch("getQiNiu");
  236. uni.switchTab({
  237. url: '/pages/Live/Live'
  238. })
  239. }).finally(() => {
  240. uni.hideLoading();
  241. });
  242. }
  243. return true;
  244. },
  245. faceInit() {
  246. if (!window.FB) {
  247. return
  248. }
  249. FB.init({
  250. appId: '606811134721321',
  251. status: true,
  252. oauth: true,
  253. cookie: true,
  254. xfbml: true,
  255. version: 'v16.0'
  256. });
  257. FB.getLoginStatus((response) => {
  258. console.error("status", response);
  259. }, {scope: 'public_profile,email,user_likes', return_scopes: true, auth_type: 'reauthenticate', auth_nonce: '{random-nonce}'})
  260. },
  261. faceLogin() {
  262. if (!window.FB) {
  263. return
  264. }
  265. FB.login((response) => {
  266. if (response.status == 'connected') {
  267. this.$nextTick(() => {
  268. this.getFaceInfo(response);
  269. });
  270. }
  271. }, {scope: 'public_profile,email,user_likes', return_scopes: true, auth_type: 'reauthenticate', auth_nonce: '{random-nonce}'});
  272. },
  273. getFaceInfo(callbackRes) {
  274. console.error('Welcome! Fetching your information.... ', callbackRes);
  275. var token = callbackRes&&callbackRes.authResponse&&callbackRes.authResponse.accessToken || null;
  276. // var uid = callbackRes&&callbackRes.authResponse&&callbackRes.authResponse.userID || null;
  277. const params = {};
  278. if(token){
  279. params.access_token = token;
  280. }
  281. FB.api('/me?fields=email', 'get', params, (response) => {
  282. // console.error('Successful login for: ' + response.name, response);
  283. if(response.email){
  284. }
  285. });
  286. // FB.api('/me/permissions', 'get', params, function(response) {
  287. // console.error(response, "uid-permissions");
  288. // });
  289. },
  290. stepTwo() {
  291. if (!this.checked) {
  292. uni.$u.toast(
  293. this.$t('login.lab32')
  294. );
  295. return
  296. }
  297. if (!this.userInfo.mobile) {
  298. uni.$u.toast(this.$t('login.lab33'));
  299. return
  300. }
  301. uni.showLoading({
  302. title: this.$t('common.lab'),
  303. });
  304. let mobile = this.code + '-' + this.userInfo.mobile
  305. uni.$u.http.get('/api/v1/getcode', {
  306. params: {
  307. type: 1,
  308. mobile: mobile
  309. }
  310. }).then(res => {
  311. uni.$u.toast(this.$t('login.lab13'));
  312. this.step = 2
  313. this.timeFinish = false
  314. }).finally(() => {
  315. uni.hideLoading();
  316. });
  317. },
  318. stepThree() {
  319. if (!this.userInfo.code || this.userInfo.code.length < 6) {
  320. uni.$u.toast(this.$t('login.lab14'));
  321. return
  322. }
  323. uni.showLoading({
  324. title: this.$t('common.lab'),
  325. });
  326. let mobile = this.code + '-' + this.userInfo.mobile
  327. uni.$u.http.get('/api/v1/verify_code', {
  328. params: {
  329. code: this.userInfo.code,
  330. mobile: mobile
  331. }
  332. }).then(res => {
  333. this.step = 3
  334. this.timeFinish = true
  335. }).finally(() => {
  336. uni.hideLoading();
  337. });
  338. },
  339. registered() {
  340. if (!this.checked1) {
  341. uni.$u.toast(
  342. "Please agree to the User Agreement"
  343. );
  344. return
  345. }
  346. if (!this.userInfo.password) {
  347. uni.$u.toast("Please enter your password");
  348. return
  349. }
  350. uni.showLoading({
  351. title: this.$t('common.lab')
  352. })
  353. var obj = JSON.parse(JSON.stringify(this.userInfo));
  354. var adgroup_id = localStorage.getItem('adgroup_id');
  355. var agency_id = localStorage.getItem('agency_id');
  356. var code = localStorage.getItem('agency_code');
  357. adgroup_id && (obj.adgroup_id = JSON.parse(adgroup_id));
  358. agency_id && (obj.agency_id = JSON.parse(agency_id));
  359. code && (obj.code = JSON.parse(code));
  360. uni.$u.http.get('/api/v1/registered', {
  361. params: {
  362. ...obj,
  363. mobile: this.code + '-' + this.userInfo.mobile,
  364. }
  365. }).then(res => {
  366. uni.showToast({
  367. title: this.$t('login.lab13'),
  368. icon: "success"
  369. })
  370. this.step = 1
  371. this.userInfo.code = ''
  372. this.userInfo.password = ''
  373. this.userInfo.mobile = ''
  374. this.$toUrl('/pages/login/login')
  375. }).finally(() => {
  376. uni.hideLoading();
  377. });
  378. },
  379. get_cricket_tournament(value) {
  380. uni.$u.http
  381. .post(`/api/universal/getHot?code=${value}`, {})
  382. .then((res) => {
  383. this.tournamentList = res.CountryCode || [];
  384. if (this.searchname) {
  385. return
  386. }
  387. this.searchname = res.CountryCode[0].name;
  388. this.country_code = res.CountryCode[0].country_code;
  389. this.thumbnail = res.CountryCode[0].thumbnail;
  390. this.code = res.CountryCode[0].code;
  391. })
  392. .catch((res) => {});
  393. },
  394. checkboxChange(item) {
  395. this.searchname = item.name;
  396. this.country_code = item.country_code;
  397. this.thumbnail = item.thumbnail;
  398. this.code = item.code;
  399. this.regionShow = false;
  400. },
  401. close() {
  402. this.regionShow = false;
  403. },
  404. open() {
  405. },
  406. timeFinishFun() {
  407. this.timeFinish = true
  408. },
  409. stepBack() {
  410. this.step = 2
  411. this.userInfo.code = ''
  412. this.userInfo.password = ''
  413. }
  414. }
  415. }
  416. </script>
  417. <style lang="scss" scoped>
  418. .login-main {
  419. padding: 8vh 16px 30rpx;
  420. .title {
  421. font-weight: 600;
  422. font-size: 18px;
  423. color: #242424;
  424. margin-bottom: 16px;
  425. line-height: 1;
  426. }
  427. .tip {
  428. font-weight: 400;
  429. font-size: 14px;
  430. color: #4E4E4E;
  431. line-height: 1;
  432. }
  433. .u-form {
  434. padding-top: 5.5vh;
  435. }
  436. .pwd {
  437. height: 16px;
  438. display: block;
  439. }
  440. .show {
  441. display: block;
  442. cursor: pointer;
  443. width: 20px;
  444. }
  445. /deep/ .u-input__content__prefix-icon {
  446. margin-right: 12px;
  447. }
  448. /deep/ .u-input__content__subfix-icon {
  449. padding-right: 5px;
  450. }
  451. .checkbox {
  452. position: relative;
  453. padding-left: 28px;
  454. font-weight: 400;
  455. font-size: 12px;
  456. color: #4E4E4E;
  457. margin-bottom: 26px;
  458. margin-top: 16px;
  459. .no {
  460. width: 14px;
  461. height: 14px;
  462. border: 1px solid #B1B1B1;
  463. border-radius: 3px;
  464. position: absolute;
  465. left: 0;
  466. top: 1px;
  467. }
  468. .line {
  469. text-decoration: underline;
  470. margin: 0 3px;
  471. }
  472. .img {
  473. width: 16px;
  474. position: absolute;
  475. left: 0;
  476. top: 1px;
  477. }
  478. }
  479. .u-divider {
  480. margin: 40px 0;
  481. }
  482. .btn1 {
  483. background-color: #F1F6F7;
  484. border-radius: 4px;
  485. height: 52px;
  486. display: flex;
  487. align-items: center;
  488. justify-content: center;
  489. position: relative;
  490. font-weight: 500;
  491. font-size: 16px;
  492. color: #242424;
  493. margin-bottom: 26px;
  494. .google {
  495. width: 14px;
  496. margin-right: 6px;
  497. }
  498. #google_id {
  499. position: absolute;
  500. top: 0;
  501. left: 0;
  502. bottom: 0;
  503. right: 0;
  504. opacity: 0;
  505. }
  506. }
  507. .btn2 {
  508. background-color: #6563FF;
  509. border-radius: 4px;
  510. height: 52px;
  511. display: flex;
  512. align-items: center;
  513. justify-content: center;
  514. font-weight: 500;
  515. font-size: 16px;
  516. color: #fff;
  517. position: relative;
  518. .google {
  519. height: 14px;
  520. margin-right: 6px;
  521. }
  522. .fb-login-button {
  523. position: absolute;
  524. top: 0;
  525. left: 0;
  526. bottom: 0;
  527. right: 0;
  528. opacity: 0;
  529. }
  530. }
  531. .code-box {
  532. display: flex;
  533. align-items: center;
  534. .thumbnail {
  535. width: 30px;
  536. margin-right: 11px;
  537. }
  538. }
  539. .lab {
  540. font-weight: 400;
  541. font-size: 12px;
  542. color: #4E4E4E;
  543. margin-top: 32px;
  544. line-height: 1;
  545. }
  546. }
  547. .box_btn_2 {
  548. .down-box {
  549. display: flex;
  550. align-items: center;
  551. justify-content: center;
  552. font-weight: 400;
  553. font-size: 14px;
  554. color: #4E4E4E;
  555. margin-bottom: 16px;
  556. }
  557. .u-count-down {
  558. margin-left: 3px;
  559. }
  560. .Resend {
  561. font-weight: 900;
  562. color: #DE2D01;
  563. }
  564. }
  565. .login-main1 {
  566. .top {
  567. background-color: #262E4A;
  568. height: 40px;
  569. font-weight: 500;
  570. font-size: 16px;
  571. padding: 0 16px;
  572. color: #fff;
  573. .u-icon {
  574. margin-right: 10px;
  575. }
  576. }
  577. .section {
  578. padding: 32px 16px 0;
  579. .tip {
  580. font-weight: 400;
  581. font-size: 14px;
  582. line-height: 1;
  583. color: #4E4E4E;
  584. }
  585. }
  586. .u-form {
  587. padding-top: 9vh;
  588. }
  589. .pwd {
  590. height: 16px;
  591. display: block;
  592. }
  593. .checkbox {
  594. position: relative;
  595. padding-left: 28px;
  596. font-weight: 400;
  597. font-size: 12px;
  598. color: #4E4E4E;
  599. margin-bottom: 16px;
  600. margin-top: 16px;
  601. .no {
  602. width: 14px;
  603. height: 14px;
  604. border: 1px solid #B1B1B1;
  605. border-radius: 3px;
  606. position: absolute;
  607. left: 0;
  608. top: 1px;
  609. }
  610. .img {
  611. width: 16px;
  612. position: absolute;
  613. left: 0;
  614. top: 1px;
  615. }
  616. .line {
  617. color: #FA3301;
  618. margin-left: 3px;
  619. }
  620. }
  621. .bold {
  622. font-weight: 600;
  623. }
  624. /deep/ .u-input__content__prefix-icon {
  625. margin-right: 12px;
  626. }
  627. .text {
  628. font-weight: 400;
  629. font-size: 12px;
  630. color: #4E4E4E;
  631. line-height: 16px;
  632. }
  633. .create {
  634. font-weight: 400;
  635. font-size: 14px;
  636. text-align: center;
  637. color: #1F1F1F;
  638. margin-top: 26px;
  639. .router {
  640. color: #FA3301;
  641. margin-left: 3px;
  642. }
  643. }
  644. }
  645. .btn {
  646. cursor: pointer;
  647. background: linear-gradient(94.25deg, #FF3300 -3.08%, #D22A00 100%);
  648. border-radius: 4px;
  649. height: 52px;
  650. display: flex;
  651. align-items: center;
  652. justify-content: center;
  653. font-weight: 500;
  654. font-size: 16px;
  655. color: #fff;
  656. }
  657. .fixed {
  658. position: fixed;
  659. left: 0;
  660. right: 0;
  661. padding: 16px;
  662. bottom: 20px;
  663. background-color: #fff;
  664. }
  665. </style>