register.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. <template>
  2. <view class="login-wrapper" :style="colorStyle">
  3. <view class="login-top"></view>
  4. <view class="shading">
  5. <image :src="logoUrl" v-if="logoUrl" />
  6. <image src="../static/logo2.png" v-else />
  7. </view>
  8. <view class="whiteBg">
  9. <view class="tips">
  10. <view class="tips-btn on">
  11. <view>注册账号</view>
  12. <view class="line"></view>
  13. </view>
  14. </view>
  15. <view class="list">
  16. <view class="item">
  17. <view class="acea-row row-middle">
  18. <image src="../static/phone_1.png" class="itemImg-add"></image>
  19. <input type="text" placeholder="输入手机号码" v-model="account" maxlength="11" />
  20. </view>
  21. </view>
  22. <view class="item">
  23. <view class="acea-row row-middle">
  24. <image src="../static/phone_1.png" class="itemImg-add"></image>
  25. <input type="text" placeholder="输入邀请码" v-model="spread_spid" maxlength="11" />
  26. </view>
  27. </view>
  28. <view class="item">
  29. <view class="acea-row row-middle">
  30. <image src="../static/code_2.png" class="item-img"></image>
  31. <input type="text" placeholder="填写验证码" maxlength="6" class="codeIput" v-model="captcha" />
  32. <button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''" @click="code">
  33. {{ text }}
  34. </button>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="logon" @click="loginMobile">注册</view>
  39. <!-- #ifdef H5 -->
  40. <view class="logon" style="margin-top: 20rpx;" @click="domApp">下载APP</view>
  41. <!-- #endif -->
  42. <view class="protocol">
  43. <checkbox-group @change='ChangeIsDefault'>
  44. <checkbox :class="inAnimation?'trembling':''" @animationend='inAnimation=false'
  45. :checked="protocol ? true : false" />已阅读并同意 <text class="main-color"
  46. @click="privacy('user')">《用户协议》</text>
  47. 与<text class="main-color" @click="privacy('privacy ')">《隐私协议》</text>
  48. </checkbox-group>
  49. </view>
  50. </view>
  51. <view class="bottom"></view>
  52. <Verify @success="success" :captchaType="'blockPuzzle'" :imgSize="{ width: '330px', height: '155px' }"
  53. ref="verify"></Verify>
  54. <view class="copyright" v-if="copyrightContext">{{copyrightContext}}</view>
  55. </view>
  56. </template>
  57. <script>
  58. import dayjs from "@/plugin/dayjs/dayjs.min.js";
  59. import sendVerifyCode from "@/mixins/SendVerifyCode";
  60. import {
  61. getAppVersion
  62. } from '@/api/api.js';
  63. import {
  64. loginMobile,
  65. registerVerify,
  66. getCodeApi,
  67. getUserInfo,
  68. } from "@/api/user";
  69. import attrs, {
  70. required,
  71. alpha_num,
  72. chs_phone
  73. } from "@/utils/validate";
  74. import {
  75. validatorDefaultCatch
  76. } from "@/utils/dialog";
  77. import {
  78. getLogo
  79. } from "@/api/public";
  80. // import cookie from "@/utils/store/cookie";
  81. import {
  82. VUE_APP_API_URL
  83. } from "@/utils";
  84. // #ifdef APP-PLUS
  85. import {
  86. wechatAppAuth
  87. } from '@/api/api.js'
  88. // #endif
  89. const BACK_URL = "login_back_url";
  90. import colors from '@/mixins/color.js';
  91. import Verify from '../components/verify/verify.vue';
  92. export default {
  93. name: "Login",
  94. components: {
  95. Verify
  96. },
  97. mixins: [sendVerifyCode, colors],
  98. data: function() {
  99. return {
  100. inAnimation: false,
  101. protocol: false,
  102. account: "",
  103. password: "",
  104. spread_spid: '',
  105. captcha: "",
  106. type: "login",
  107. logoUrl: "",
  108. keyCode: "",
  109. keyLock: true,
  110. copyrightContext: ''
  111. };
  112. },
  113. onLoad(res) {
  114. let self = this;
  115. if (res.spid) {
  116. self.spread_spid = res.spid;
  117. }
  118. },
  119. mounted: function() {
  120. // this.getCode();
  121. this.getLogoImage();
  122. this.spread_spid = this.$Cache.get("spid");
  123. if (!this.spid) {
  124. this.spread_spid = this.$Cache.get("spid");
  125. }
  126. },
  127. methods: {
  128. // #ifdef H5
  129. domApp() {
  130. const bool = navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger';
  131. if (bool) {
  132. uni.showModal({
  133. title: '提示',
  134. content: '无法在微信中下载,请用浏览器打开下载',
  135. showCancel: false,
  136. });
  137. } else {
  138. uni.showModal({
  139. title: '下载',
  140. content: '请选择下载类型',
  141. cancelText: 'IOS',
  142. confirmText: 'APK',
  143. success: res => {
  144. if(res.confirm){
  145. getAppVersion().then((res) => {
  146. console.log(res, 'res');
  147. window.open(res.data.apk)
  148. }).catch((err) => {
  149. console.log(err, 'err');
  150. })
  151. }
  152. if(res.cancel){
  153. window.location.href = window.location.protocol + "//" + window.location.host+'home/download/iosdom.mobileconfig'
  154. }
  155. },
  156. fail: () => {},
  157. complete: () => {}
  158. });
  159. }
  160. },
  161. // #endif
  162. ChangeIsDefault(e) {
  163. this.$set(this, 'protocol', !this.protocol);
  164. },
  165. success(data) {
  166. this.$refs.verify.hide()
  167. getCodeApi()
  168. .then(res => {
  169. this.keyCode = res.data.key;
  170. this.getCode(data);
  171. })
  172. .catch(res => {
  173. this.$util.Tips({
  174. title: res
  175. });
  176. });
  177. },
  178. code() {
  179. let that = this
  180. if (!that.protocol) {
  181. this.inAnimation = true
  182. return that.$util.Tips({
  183. title: '请先阅读并同意协议'
  184. });
  185. }
  186. if (!that.account) return that.$util.Tips({
  187. title: '请填写手机号码'
  188. });
  189. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  190. title: '请输入正确的手机号码'
  191. });
  192. this.$refs.verify.show()
  193. },
  194. async getLogoImage() {
  195. let that = this;
  196. getLogo(2).then(res => {
  197. that.logoUrl = res.data.logo_url;
  198. that.copyrightContext = res.data.copyrightContext;
  199. });
  200. },
  201. async loginMobile() {
  202. let that = this;
  203. if (!that.protocol) {
  204. this.inAnimation = true
  205. return that.$util.Tips({
  206. title: '请先阅读并同意协议'
  207. });
  208. }
  209. if (!that.account) return that.$util.Tips({
  210. title: '请填写手机号码'
  211. });
  212. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  213. title: '请输入正确的手机号码'
  214. });
  215. if (!that.captcha) return that.$util.Tips({
  216. title: '请填写验证码'
  217. });
  218. if (!/^[\w\d]+$/i.test(that.captcha)) return that.$util.Tips({
  219. title: '请输入正确的验证码'
  220. });
  221. if (this.keyLock) {
  222. this.keyLock = !this.keyLock
  223. } else {
  224. return that.$util.Tips({
  225. title: '请勿重复点击'
  226. });
  227. }
  228. loginMobile({
  229. phone: that.account,
  230. captcha: that.captcha,
  231. spread_spid: that.spread_spid
  232. })
  233. .then(res => {
  234. let data = res.data;
  235. that.$store.commit("LOGIN", {
  236. 'token': data.token,
  237. 'time': data.expires_time - this.$Cache.time()
  238. });
  239. let backUrl = that.$Cache.get(BACK_URL) || "/pages/index/index";
  240. that.$Cache.clear(BACK_URL);
  241. uni.showToast({
  242. title: '注册成功'
  243. });
  244. getUserInfo().then(res => {
  245. this.keyLock = true
  246. that.$store.commit("SETUID", res.data.uid);
  247. that.$store.commit("UPDATE_USERINFO", res.data);
  248. if (backUrl.indexOf('/pages/users/login/index') !== -1) {
  249. backUrl = '/pages/index/index';
  250. }
  251. // uni.reLaunch({
  252. // url: backUrl
  253. // });
  254. })
  255. })
  256. .catch(res => {
  257. this.keyLock = true
  258. that.$util.Tips({
  259. title: res
  260. });
  261. });
  262. },
  263. async getCode(data) {
  264. console.log('data-------', data);
  265. let that = this;
  266. if (!that.account) return that.$util.Tips({
  267. title: '请填写手机号码'
  268. });
  269. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  270. title: '请输入正确的手机号码'
  271. });
  272. await registerVerify({
  273. phone: that.account,
  274. type: that.type,
  275. key: that.keyCode,
  276. captchaType: 'blockPuzzle',
  277. captchaVerification: data.captchaVerification
  278. })
  279. .then(res => {
  280. that.$util.Tips({
  281. title: res.msg
  282. });
  283. that.sendCode();
  284. })
  285. .catch(res => {
  286. that.$util.Tips({
  287. title: res
  288. });
  289. });
  290. },
  291. privacy(type) {
  292. uni.navigateTo({
  293. url: "/pages/users/privacy/index?type=" + type
  294. })
  295. }
  296. }
  297. };
  298. </script>
  299. <style lang="scss">
  300. .copyright {
  301. width: 650rpx;
  302. position: fixed;
  303. bottom: 30rpx;
  304. left: 50%;
  305. margin-left: -325rpx;
  306. font-size: 20rpx;
  307. color: #999999;
  308. text-align: center;
  309. .domain {
  310. color: #478BF1;
  311. margin-left: 6rpx;
  312. }
  313. }
  314. .itemImg-add {
  315. width: 24rpx;
  316. height: 34rpx;
  317. }
  318. .item-img {
  319. width: 28rpx;
  320. height: 32rpx;
  321. }
  322. /deep/uni-checkbox .uni-checkbox-input {
  323. margin-top: -6rpx;
  324. }
  325. .appLogin {
  326. margin-top: 60rpx;
  327. .hds {
  328. display: flex;
  329. justify-content: center;
  330. align-items: center;
  331. font-size: 24rpx;
  332. color: #B4B4B4;
  333. .line {
  334. width: 68rpx;
  335. height: 1rpx;
  336. background: #CCCCCC;
  337. }
  338. p {
  339. margin: 0 20rpx;
  340. }
  341. }
  342. .btn-wrapper {
  343. display: flex;
  344. align-items: center;
  345. justify-content: center;
  346. margin-top: 30rpx;
  347. .btn {
  348. display: flex;
  349. align-items: center;
  350. justify-content: center;
  351. width: 68rpx;
  352. height: 68rpx;
  353. border-radius: 50%;
  354. }
  355. .apple-btn {
  356. display: flex;
  357. align-items: center;
  358. justify-content: center;
  359. width: 246rpx;
  360. height: 66rpx;
  361. margin-left: 30rpx;
  362. background: #EAEAEA;
  363. border-radius: 34rpx;
  364. font-size: 24rpx;
  365. .icon-s-pingguo {
  366. color: #333;
  367. margin-right: 10rpx;
  368. font-size: 34rpx;
  369. }
  370. }
  371. .iconfont {
  372. font-size: 40rpx;
  373. color: #fff;
  374. }
  375. .wx {
  376. background-color: #61C64F;
  377. }
  378. .mima {
  379. background-color: #28B3E9;
  380. }
  381. .yanzheng {
  382. background-color: #F89C23;
  383. }
  384. .pingguo {
  385. margin-left: 60rpx;
  386. background-color: #000;
  387. }
  388. }
  389. }
  390. .main-color {
  391. color: var(--view-theme);
  392. }
  393. .code img {
  394. width: 100%;
  395. height: 100%;
  396. }
  397. .acea-row.row-middle {
  398. input {
  399. margin-left: 20rpx;
  400. display: block;
  401. }
  402. }
  403. .login-wrapper {
  404. .login-top {
  405. height: 358rpx;
  406. background-color: var(--view-theme);
  407. background-image: url(../static/login.png);
  408. background-size: cover;
  409. background-repeat: no-repeat;
  410. image {
  411. width: 101%;
  412. height: 100%;
  413. }
  414. }
  415. .shading {
  416. display: flex;
  417. align-items: center;
  418. justify-content: center;
  419. width: 100%;
  420. margin-top: -230rpx;
  421. position: relative;
  422. z-index: 8;
  423. image {
  424. width: 180rpx;
  425. height: 180rpx;
  426. top: 40rpx;
  427. }
  428. }
  429. .whiteBg {
  430. background-color: #fff;
  431. margin: -30rpx 56rpx 0rpx 56rpx;
  432. box-shadow: 0px 2px 14px 0px rgba(0, 0, 0, 0.08);
  433. border-radius: 8px;
  434. padding: 60rpx;
  435. position: relative;
  436. z-index: 6;
  437. .tips {
  438. display: flex;
  439. align-items: center;
  440. justify-content: center;
  441. height: 50rpx;
  442. margin: 40rpx;
  443. color: #999;
  444. .tips-btn {
  445. margin: 0 31rpx 0 48rpx;
  446. color: #999999;
  447. font-weight: bold;
  448. font-size: 32rpx;
  449. /* Safari 与 Chrome */
  450. .line {
  451. width: 80rpx;
  452. height: 6rpx;
  453. background: linear-gradient(135deg, var(--view-minorColor) 0%, var(--view-theme) 100%);
  454. border-radius: 2px;
  455. margin: 10rpx auto 0 auto;
  456. animation: myfirst .3s;
  457. -webkit-animation: myfirst .3s;
  458. }
  459. .none {
  460. width: 80rpx;
  461. background: #fff;
  462. height: 6rpx;
  463. }
  464. }
  465. @keyframes myfirst {
  466. 0% {
  467. width: 0rpx;
  468. }
  469. 100% {
  470. width: 80rpx;
  471. }
  472. }
  473. @-webkit-keyframes myfirst
  474. /* Safari 与 Chrome */
  475. {
  476. 0% {
  477. width: 0rpx;
  478. }
  479. 100% {
  480. width: 80rpx;
  481. }
  482. }
  483. .tips-btn.on {
  484. font-size: 36rpx;
  485. color: var(--view-theme);
  486. }
  487. }
  488. .list {
  489. border-radius: 16rpx;
  490. overflow: hidden;
  491. .forgetPwd {
  492. text-align: right;
  493. margin-top: 10rpx;
  494. color: #666666;
  495. font-size: 24rpx;
  496. }
  497. .item {
  498. border-bottom: 1px solid #F0F0F0;
  499. background: #fff;
  500. .row-middle {
  501. position: relative;
  502. padding: 16rpx 25rpx;
  503. input {
  504. flex: 1;
  505. font-size: 28rpx;
  506. height: 80rpx;
  507. }
  508. .code {
  509. position: absolute;
  510. right: 30rpx;
  511. top: 50%;
  512. color: var(--view-theme);
  513. font-size: 26rpx;
  514. transform: translateY(-50%);
  515. }
  516. }
  517. }
  518. }
  519. .logon {
  520. display: flex;
  521. align-items: center;
  522. justify-content: center;
  523. width: 100%;
  524. height: 86rpx;
  525. margin-top: 48rpx;
  526. background: linear-gradient(135deg, var(--view-minorColor) 0%, var(--view-theme) 100%);
  527. border-radius: 120rpx;
  528. color: #FFFFFF;
  529. font-size: 30rpx;
  530. }
  531. }
  532. .protocol {
  533. margin-top: 40rpx;
  534. color: #999999;
  535. font-size: 24rpx;
  536. }
  537. .trembling {
  538. animation: shake 0.6s;
  539. }
  540. @keyframes shake {
  541. 0%,
  542. 100% {
  543. -webkit-transform: translateX(0);
  544. }
  545. 10%,
  546. 30%,
  547. 50%,
  548. 70%,
  549. 90% {
  550. -webkit-transform: translateX(-5rpx);
  551. }
  552. 20%,
  553. 40%,
  554. 60%,
  555. 80% {
  556. -webkit-transform: translateX(5rpx);
  557. }
  558. }
  559. @-o-keyframes shake {
  560. /* Opera */
  561. 0%,
  562. 100% {
  563. -webkit-transform: translateX(0);
  564. }
  565. 10%,
  566. 30%,
  567. 50%,
  568. 70%,
  569. 90% {
  570. -webkit-transform: translateX(-5rpx);
  571. }
  572. 20%,
  573. 40%,
  574. 60%,
  575. 80% {
  576. -webkit-transform: translateX(5rpx);
  577. }
  578. }
  579. @-webkit-keyframes shake {
  580. /* Safari 和 Chrome */
  581. 0%,
  582. 100% {
  583. -webkit-transform: translateX(0);
  584. }
  585. 10%,
  586. 30%,
  587. 50%,
  588. 70%,
  589. 90% {
  590. -webkit-transform: translateX(-5rpx);
  591. }
  592. 20%,
  593. 40%,
  594. 60%,
  595. 80% {
  596. -webkit-transform: translateX(5rpx);
  597. }
  598. }
  599. @-moz-keyframes shake {
  600. /* Firefox */
  601. 0%,
  602. 100% {
  603. -moz-transform: translateX(0);
  604. }
  605. 10%,
  606. 30%,
  607. 50%,
  608. 70%,
  609. 90% {
  610. -moz-transform: translateX(-5rpx);
  611. }
  612. 20%,
  613. 40%,
  614. 60%,
  615. 80% {
  616. -moz-transform: translateX(5rpx);
  617. }
  618. }
  619. }
  620. </style>