register.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  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. window.open('https://www.senyinkj.cn//register/index.html')
  139. // uni.showModal({
  140. // title: '下载',
  141. // content: '请选择下载类型',
  142. // cancelText: 'IOS',
  143. // confirmText: 'APK',
  144. // success: res => {
  145. // if(res.confirm){
  146. // getAppVersion().then((res) => {
  147. // console.log(res, 'res');
  148. // window.open(res.data.apk)
  149. // }).catch((err) => {
  150. // console.log(err, 'err');
  151. // })
  152. // }
  153. // if(res.cancel){
  154. // window.location.href = window.location.protocol + "//" + window.location.host+'home/download/iosdom.mobileconfig'
  155. // }
  156. // },
  157. // fail: () => {},
  158. // complete: () => {}
  159. // });
  160. }
  161. },
  162. // #endif
  163. ChangeIsDefault(e) {
  164. this.$set(this, 'protocol', !this.protocol);
  165. },
  166. success(data) {
  167. this.$refs.verify.hide()
  168. getCodeApi()
  169. .then(res => {
  170. this.keyCode = res.data.key;
  171. this.getCode(data);
  172. })
  173. .catch(res => {
  174. this.$util.Tips({
  175. title: res
  176. });
  177. });
  178. },
  179. code() {
  180. let that = this
  181. if (!that.protocol) {
  182. this.inAnimation = true
  183. return that.$util.Tips({
  184. title: '请先阅读并同意协议'
  185. });
  186. }
  187. if (!that.account) return that.$util.Tips({
  188. title: '请填写手机号码'
  189. });
  190. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  191. title: '请输入正确的手机号码'
  192. });
  193. this.$refs.verify.show()
  194. },
  195. async getLogoImage() {
  196. let that = this;
  197. getLogo(2).then(res => {
  198. that.logoUrl = res.data.logo_url;
  199. that.copyrightContext = res.data.copyrightContext;
  200. });
  201. },
  202. async loginMobile() {
  203. let that = this;
  204. if (!that.protocol) {
  205. this.inAnimation = true
  206. return that.$util.Tips({
  207. title: '请先阅读并同意协议'
  208. });
  209. }
  210. if (!that.account) return that.$util.Tips({
  211. title: '请填写手机号码'
  212. });
  213. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  214. title: '请输入正确的手机号码'
  215. });
  216. if (!that.captcha) return that.$util.Tips({
  217. title: '请填写验证码'
  218. });
  219. if (!/^[\w\d]+$/i.test(that.captcha)) return that.$util.Tips({
  220. title: '请输入正确的验证码'
  221. });
  222. if (this.keyLock) {
  223. this.keyLock = !this.keyLock
  224. } else {
  225. return that.$util.Tips({
  226. title: '请勿重复点击'
  227. });
  228. }
  229. loginMobile({
  230. phone: that.account,
  231. captcha: that.captcha,
  232. spread_spid: that.spread_spid
  233. })
  234. .then(res => {
  235. let data = res.data;
  236. that.$store.commit("LOGIN", {
  237. 'token': data.token,
  238. 'time': data.expires_time - this.$Cache.time()
  239. });
  240. let backUrl = that.$Cache.get(BACK_URL) || "/pages/index/index";
  241. that.$Cache.clear(BACK_URL);
  242. uni.showToast({
  243. title: '注册成功'
  244. });
  245. getUserInfo().then(res => {
  246. this.keyLock = true
  247. that.$store.commit("SETUID", res.data.uid);
  248. that.$store.commit("UPDATE_USERINFO", res.data);
  249. if (backUrl.indexOf('/pages/users/login/index') !== -1) {
  250. backUrl = '/pages/index/index';
  251. }
  252. // uni.reLaunch({
  253. // url: backUrl
  254. // });
  255. })
  256. })
  257. .catch(res => {
  258. this.keyLock = true
  259. that.$util.Tips({
  260. title: res
  261. });
  262. });
  263. },
  264. async getCode(data) {
  265. console.log('data-------', data);
  266. let that = this;
  267. if (!that.account) return that.$util.Tips({
  268. title: '请填写手机号码'
  269. });
  270. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
  271. title: '请输入正确的手机号码'
  272. });
  273. await registerVerify({
  274. phone: that.account,
  275. type: that.type,
  276. key: that.keyCode,
  277. captchaType: 'blockPuzzle',
  278. captchaVerification: data.captchaVerification
  279. })
  280. .then(res => {
  281. that.$util.Tips({
  282. title: res.msg
  283. });
  284. that.sendCode();
  285. })
  286. .catch(res => {
  287. that.$util.Tips({
  288. title: res
  289. });
  290. });
  291. },
  292. privacy(type) {
  293. uni.navigateTo({
  294. url: "/pages/users/privacy/index?type=" + type
  295. })
  296. }
  297. }
  298. };
  299. </script>
  300. <style lang="scss">
  301. .copyright {
  302. width: 650rpx;
  303. position: fixed;
  304. bottom: 30rpx;
  305. left: 50%;
  306. margin-left: -325rpx;
  307. font-size: 20rpx;
  308. color: #999999;
  309. text-align: center;
  310. .domain {
  311. color: #478BF1;
  312. margin-left: 6rpx;
  313. }
  314. }
  315. .itemImg-add {
  316. width: 24rpx;
  317. height: 34rpx;
  318. }
  319. .item-img {
  320. width: 28rpx;
  321. height: 32rpx;
  322. }
  323. /deep/uni-checkbox .uni-checkbox-input {
  324. margin-top: -6rpx;
  325. }
  326. .appLogin {
  327. margin-top: 60rpx;
  328. .hds {
  329. display: flex;
  330. justify-content: center;
  331. align-items: center;
  332. font-size: 24rpx;
  333. color: #B4B4B4;
  334. .line {
  335. width: 68rpx;
  336. height: 1rpx;
  337. background: #CCCCCC;
  338. }
  339. p {
  340. margin: 0 20rpx;
  341. }
  342. }
  343. .btn-wrapper {
  344. display: flex;
  345. align-items: center;
  346. justify-content: center;
  347. margin-top: 30rpx;
  348. .btn {
  349. display: flex;
  350. align-items: center;
  351. justify-content: center;
  352. width: 68rpx;
  353. height: 68rpx;
  354. border-radius: 50%;
  355. }
  356. .apple-btn {
  357. display: flex;
  358. align-items: center;
  359. justify-content: center;
  360. width: 246rpx;
  361. height: 66rpx;
  362. margin-left: 30rpx;
  363. background: #EAEAEA;
  364. border-radius: 34rpx;
  365. font-size: 24rpx;
  366. .icon-s-pingguo {
  367. color: #333;
  368. margin-right: 10rpx;
  369. font-size: 34rpx;
  370. }
  371. }
  372. .iconfont {
  373. font-size: 40rpx;
  374. color: #fff;
  375. }
  376. .wx {
  377. background-color: #61C64F;
  378. }
  379. .mima {
  380. background-color: #28B3E9;
  381. }
  382. .yanzheng {
  383. background-color: #F89C23;
  384. }
  385. .pingguo {
  386. margin-left: 60rpx;
  387. background-color: #000;
  388. }
  389. }
  390. }
  391. .main-color {
  392. color: var(--view-theme);
  393. }
  394. .code img {
  395. width: 100%;
  396. height: 100%;
  397. }
  398. .acea-row.row-middle {
  399. input {
  400. margin-left: 20rpx;
  401. display: block;
  402. }
  403. }
  404. .login-wrapper {
  405. .login-top {
  406. height: 358rpx;
  407. background-color: var(--view-theme);
  408. background-image: url(../static/login.png);
  409. background-size: cover;
  410. background-repeat: no-repeat;
  411. image {
  412. width: 101%;
  413. height: 100%;
  414. }
  415. }
  416. .shading {
  417. display: flex;
  418. align-items: center;
  419. justify-content: center;
  420. width: 100%;
  421. margin-top: -230rpx;
  422. position: relative;
  423. z-index: 8;
  424. image {
  425. width: 180rpx;
  426. height: 180rpx;
  427. top: 40rpx;
  428. }
  429. }
  430. .whiteBg {
  431. background-color: #fff;
  432. margin: -30rpx 56rpx 0rpx 56rpx;
  433. box-shadow: 0px 2px 14px 0px rgba(0, 0, 0, 0.08);
  434. border-radius: 8px;
  435. padding: 60rpx;
  436. position: relative;
  437. z-index: 6;
  438. .tips {
  439. display: flex;
  440. align-items: center;
  441. justify-content: center;
  442. height: 50rpx;
  443. margin: 40rpx;
  444. color: #999;
  445. .tips-btn {
  446. margin: 0 31rpx 0 48rpx;
  447. color: #999999;
  448. font-weight: bold;
  449. font-size: 32rpx;
  450. /* Safari 与 Chrome */
  451. .line {
  452. width: 80rpx;
  453. height: 6rpx;
  454. background: linear-gradient(135deg, var(--view-minorColor) 0%, var(--view-theme) 100%);
  455. border-radius: 2px;
  456. margin: 10rpx auto 0 auto;
  457. animation: myfirst .3s;
  458. -webkit-animation: myfirst .3s;
  459. }
  460. .none {
  461. width: 80rpx;
  462. background: #fff;
  463. height: 6rpx;
  464. }
  465. }
  466. @keyframes myfirst {
  467. 0% {
  468. width: 0rpx;
  469. }
  470. 100% {
  471. width: 80rpx;
  472. }
  473. }
  474. @-webkit-keyframes myfirst
  475. /* Safari 与 Chrome */
  476. {
  477. 0% {
  478. width: 0rpx;
  479. }
  480. 100% {
  481. width: 80rpx;
  482. }
  483. }
  484. .tips-btn.on {
  485. font-size: 36rpx;
  486. color: var(--view-theme);
  487. }
  488. }
  489. .list {
  490. border-radius: 16rpx;
  491. overflow: hidden;
  492. .forgetPwd {
  493. text-align: right;
  494. margin-top: 10rpx;
  495. color: #666666;
  496. font-size: 24rpx;
  497. }
  498. .item {
  499. border-bottom: 1px solid #F0F0F0;
  500. background: #fff;
  501. .row-middle {
  502. position: relative;
  503. padding: 16rpx 25rpx;
  504. input {
  505. flex: 1;
  506. font-size: 28rpx;
  507. height: 80rpx;
  508. }
  509. .code {
  510. position: absolute;
  511. right: 30rpx;
  512. top: 50%;
  513. color: var(--view-theme);
  514. font-size: 26rpx;
  515. transform: translateY(-50%);
  516. }
  517. }
  518. }
  519. }
  520. .logon {
  521. display: flex;
  522. align-items: center;
  523. justify-content: center;
  524. width: 100%;
  525. height: 86rpx;
  526. margin-top: 48rpx;
  527. background: linear-gradient(135deg, var(--view-minorColor) 0%, var(--view-theme) 100%);
  528. border-radius: 120rpx;
  529. color: #FFFFFF;
  530. font-size: 30rpx;
  531. }
  532. }
  533. .protocol {
  534. margin-top: 40rpx;
  535. color: #999999;
  536. font-size: 24rpx;
  537. }
  538. .trembling {
  539. animation: shake 0.6s;
  540. }
  541. @keyframes shake {
  542. 0%,
  543. 100% {
  544. -webkit-transform: translateX(0);
  545. }
  546. 10%,
  547. 30%,
  548. 50%,
  549. 70%,
  550. 90% {
  551. -webkit-transform: translateX(-5rpx);
  552. }
  553. 20%,
  554. 40%,
  555. 60%,
  556. 80% {
  557. -webkit-transform: translateX(5rpx);
  558. }
  559. }
  560. @-o-keyframes shake {
  561. /* Opera */
  562. 0%,
  563. 100% {
  564. -webkit-transform: translateX(0);
  565. }
  566. 10%,
  567. 30%,
  568. 50%,
  569. 70%,
  570. 90% {
  571. -webkit-transform: translateX(-5rpx);
  572. }
  573. 20%,
  574. 40%,
  575. 60%,
  576. 80% {
  577. -webkit-transform: translateX(5rpx);
  578. }
  579. }
  580. @-webkit-keyframes shake {
  581. /* Safari 和 Chrome */
  582. 0%,
  583. 100% {
  584. -webkit-transform: translateX(0);
  585. }
  586. 10%,
  587. 30%,
  588. 50%,
  589. 70%,
  590. 90% {
  591. -webkit-transform: translateX(-5rpx);
  592. }
  593. 20%,
  594. 40%,
  595. 60%,
  596. 80% {
  597. -webkit-transform: translateX(5rpx);
  598. }
  599. }
  600. @-moz-keyframes shake {
  601. /* Firefox */
  602. 0%,
  603. 100% {
  604. -moz-transform: translateX(0);
  605. }
  606. 10%,
  607. 30%,
  608. 50%,
  609. 70%,
  610. 90% {
  611. -moz-transform: translateX(-5rpx);
  612. }
  613. 20%,
  614. 40%,
  615. 60%,
  616. 80% {
  617. -moz-transform: translateX(5rpx);
  618. }
  619. }
  620. }
  621. </style>