123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- <template>
- <view class="register-box">
- <Navbar title='注册'></Navbar>
- <image class="logo" :src="static ? static + 'logo.png' : ''" mode="heightFix"></image>
- <view class="tip">设置密码</view>
- <viow class="sub-tip">欢迎注册账号</viow>
- <view class="phone-box input-box">
- <IconText :code="`\ue898`" color="#999" size="14"></IconText>
- <uni-easyinput type="password" :inputBorder="false" v-model="password" placeholder="输入密码"></uni-easyinput>
- </view>
- <view class="password-box input-box">
- <IconText :code="`\ue898`" color="#999" size="14"></IconText>
- <uni-easyinput type="password" :inputBorder="false" v-model="repassword" placeholder="再次输入密码">
- </uni-easyinput>
- </view>
- <view class="btn">
- 密码支持6-16位数字与字母的组合
- </view>
- <view class="register-btn" @click="handleRegister">注册</view>
- <!-- #ifndef H5 -->
- <!-- <view class="agree">
- 注册登录即表示接受<text @click="handleAgree"> 《用户协议》</text>
- </view> -->
- <!-- #endif -->
- <uni-popup ref="agreement" :safe-area="false">
- <scroll-view class="agreement-box" :scroll-y="true">
- <view class="title">{{ agreement.title }}</view>
- <view class="content-styl" v-html="agreement.content"></view>
- </scroll-view>
- </uni-popup>
- </view>
- </template>
- <script lang="ts">
- import {
- Component,
- Prop,
- Vue
- } from 'vue-property-decorator';
- import {
- OSS_STATIC
- } from '@/common/constants';
- import agreement from './agreement';
- import pubKey from './pubKey';
- import {
- types
- } from '@/common/store/index';
- // @ts-ignore
- import JSEncrypt from '@/common/jsencrypt.js';
- import {
- namespace
- } from 'vuex-class';
- const baseModule = namespace('base');
- @Component({})
- export default class Password extends Vue {
- @baseModule.Getter('_referrerId') referrerId: any;
- @baseModule.Mutation(types.SET_TOKEN) setToken: any;
- link: string = '';
- static: string = OSS_STATIC;
- password: any = null;
- repassword: any = null;
- agreement: {
- title: string;content: string
- } = agreement;
- handleAgree() {
- (this.$refs.agreement as any).open('bottom');
- }
- handleRegister() {
- if (!this.repassword || !this.password) {
- uni.showToast({
- title: '请输入密码',
- icon: 'none'
- })
- return;
- }
- if (this.password !== this.repassword) {
- uni.showToast({
- title: '您输入的密码不一致',
- icon: 'none'
- })
- return;
- }
- // uni.showLoading({
- // title: '加载中',
- // });
- let pass = this.rsa(this.password);
- this.$http
- .post({
- url: this.$api.register,
- data: {
- auth: {
- sid: 0,
- agent: 1,
- genre: 0,
- way: 2,
- env: 0,
- identity: this.$Route.query.phone,
- password: pass,
- sys: 0
- },
- // timeStamp: time,
- third: {
- smsToken: this.$Route.query.token,
- referrer: +uni.getStorageSync('referrerId') || 0,
- }
- },
- })
- .then((res: any) => {
- // uni.hideLoading();
- this.setToken(res.token);
- uni.setStorageSync('referrerId', '');
- // #ifdef H5
- this.$Router.replace({
- path: '/packages/login/register-success',
- query: {
- phone: this.$Route.query.phone
- }
- })
- // #endif
- // #ifndef H5
- // this.$Router.back(1);
- this.$Router.pushTab({
- path: '/pages/front/front'
- })
- // #endif
- }, (err: any) => {
- // uni.hideLoading();
- console.log(err);
- });
- }
- rsa(pass: string) {
- console.log('加密前', pass)
- var encryptor = new JSEncrypt() // 创建加密对象实例
- encryptor.setPublicKey(pubKey) //设置公钥
- return encryptor.encrypt(pass) || '加密失败'
- }
- }
- </script>
- <style>
- .uni-easyinput__content {
- background: transparent !important;
- }
- </style>
- <style lang="scss" scoped>
- .register-box {
- // padding: 0 vw(24);
- @include flex-y(flex-start, center);
- background: #fff;
- min-height: 100vh;
- box-sizing: border-box;
- .logo {
- // width: vw(90);
- height: vw(72);
- border-radius: vw(45);
- margin-top: vw(36);
- }
-
- .tip {
- margin-top: vw(10);
- @include word-vw(30, #333);
- }
-
- .sub-tip {
- margin-top: vw(6);
- @include word-vw(14, #999);
- }
- .input-box {
- height: vw(52);
- width: vw(335);
- background: #F5F5F5;
- border-radius: vw(10);
- margin-top: vw(16);
- @include flex-x(flex-start);
- padding: 0 vw(24);
- box-sizing: border-box;
- .uni-easyinput__content {
- background: #F5F5F5;
- }
- .code-btn {
- @include word-vw(14, $btn-color);
- }
- }
- .phone-box {
- margin-top: 25%;
- }
- .btn {
- margin-top: vw(18);
- @include word-vw(14, #999);
- margin-right: vw(24);
- }
- .register-btn {
- height: vw(48);
- width: vw(335);
- background: $btn-color;
- border-radius: vw(10);
- @include word-vw(18, #fff);
- @include flex-x(center);
- margin-top: vw(32);
- }
- .agree {
- // width: 100%;
- @include word-vw(14, #666);
- margin-top: vw(25);
- text-align: center;
- position: absolute;
- bottom: vw(36);
- text {
- color: #E6644E;
- }
- }
- //用户协议
- .agreement-box {
- overflow: hidden;
- // overflow-y: auto;
- height: vw(480);
- background: #fff;
- border-top-left-radius: vw(5);
- border-top-right-radius: vw(5);
- padding-bottom: vw(30);
- box-sizing: border-box;
- .title {
- margin: vw(24) 0 vw(30);
- text-align: center;
- @include word-vw(16, $gray3);
- }
- .content-styl {
- @include word-vw(14, $gray6);
- line-height: vw(24);
- padding: 0 vw(15);
- }
- }
- }
- </style>
|