login.vue 19 KB

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