| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- <template>
- <view class="container">
- <view class="wrapper">
- <view class="input-content">
- <!-- <view class="cu-form-group"
- style="border: 2upx solid whitesmoke;margin-bottom: 20px;border-radius: 30px">
- <view class="title text-black">用户名</view>
- <input :value="userName" placeholder="请输入用户名" data-key="userName" @input="inputChange" />
- </view> -->
- <view class="cu-form-group"
- style="border: 2upx solid whitesmoke;margin-bottom: 20px;border-radius: 30px">
- <view class="title text-black">手机号</view>
- <input type="number" :value="phone" placeholder="请输入手机号" maxlength="11" data-key="phone"
- @input="inputChange" />
- </view>
- <view class="cu-form-group padding-right-xs"
- style="border: 2upx solid whitesmoke;margin-bottom: 20px;border-radius: 30px">
- <text class="title text-black">验证码</text>
- <input type="number" :value="code" placeholder="请输入验证码" maxlength="6" data-key="code"
- @input="inputChange" @confirm="toLogin" />
- <button class="send-msg" @click="sendMsg" :disabled="sending">{{ sendTime }}</button>
- </view>
- <view class="cu-form-group"
- style="border: 2upx solid whitesmoke;margin-bottom: 20px;border-radius: 30px">
- <text class="title text-black">设置密码</text>
- <input type="password" :value="password" placeholder="请设置密码" placeholder-class="input-empty"
- maxlength="20" minlength="6" data-key="password" @input="inputChange" @confirm="toLogin" />
- </view>
- <view class="cu-form-group"
- style="border: 2upx solid whitesmoke;margin-bottom: 20px;border-radius: 30px">
- <text class="title text-black">邀请码</text>
- <input type="" maxlength="6" :value="invitation" placeholder="请填写邀请码(选填)"
- data-key="invitation" @input="inputChange" @confirm="toLogin" />
- </view>
- </view>
- <button class="confirm-btn" @click="toLogin">立即注册</button>
- <view class="footer">
- <text @tap="isShowAgree" class="cuIcon"
- :class="showAgree ? 'cuIcon-radiobox' : 'cuIcon-round'">同意</text>
- <!-- 协议地址 -->
- <navigator url="/my/setting/mimi" open-type="navigate">《隐私政策》</navigator>
- 和
- <navigator url="/my/setting/xieyi" open-type="navigate">《用户协议》</navigator>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- userName: '',
- showAgree: false,
- code: '',
- phone: '',
- password: '',
- required: '否',
- sending: false,
- sendTime: '获取验证码',
- count: 60,
- relation: "",
- state: '',
- invitation: '',
- platform: ''
- };
- },
- onLoad() {
- this.invitation = this.$queue.getData('inviterCode') ? this.$queue.getData('inviterCode') : '';
- // #ifdef APP-PLUS
- this.platform = 'app'
- //#endif
- //#ifdef H5
- this.platform = 'H5'
- // #endif
- },
- methods: {
- showMa() {
- //查询官方邀请码
- this.$Request.getT('/app/common/type/4').then(res => {
- if (res.code == 0) {
- this.invitationCode = res.data.value;
- }
- });
- },
- // 注册邀请码必填
- invitationMa() {
- this.$Request.getT('/app/common/type/3').then(res => {
- if (res.code == 0) {
- this.required = res.data.value;
- }
- });
- },
- // 获取新用户优惠券数量
- newMa() {
- this.$Request.getT('/app/common/type/119').then(res => {
- if (res.code == 0) {
- this.amount = res.data.value;
- }
- });
- },
- isShowAgree() {
- //是否选择协议
- this.showAgree = !this.showAgree;
- },
- sendMsg() {
- const {
- phone
- } = this;
- if (!phone) {
- this.$queue.showToast('请输入手机号');
- } else if (phone.length !== 11) {
- this.$queue.showToast('请输入正确的手机号');
- } else {
- this.$queue.showLoading('正在发送验证码...');
- this.$Request.getT('/app/Login/sendMsg/' + phone + '/gzg' ).then(res => {
- if (res.code === 0) {
- this.sending = true;
- this.$queue.showToast('验证码发送成功请注意查收');
- this.countDown();
- uni.hideLoading();
- } else {
- uni.hideLoading();
- uni.showModal({
- showCancel: false,
- title: '短信发送失败',
- content: res.msg ? res.msg : '请一分钟后再获取验证码'
- });
- }
- });
- }
- },
- countDown() {
- const {
- count
- } = this;
- if (count === 1) {
- this.count = 60;
- this.sending = false;
- this.sendTime = '获取验证码';
- } else {
- this.count = count - 1;
- this.sending = true;
- this.sendTime = count - 1 + '秒后重新获取';
- setTimeout(this.countDown.bind(this), 1000);
- }
- },
- inputChange(e) {
- const key = e.currentTarget.dataset.key;
- this[key] = e.detail.value;
- },
- navBack() {
- uni.navigateBack();
- },
- navTo(url) {
- uni.navigateTo({
- url
- });
- },
- toLogin() {
- const {
- userName,
- phone,
- password,
- code,
- showAgree,
- invitation,
- } = this;
- // if (!userName) {
- // this.$queue.showToast('请输入用户名');
- // } else
- if (!phone) {
- this.$queue.showToast('请输入手机号');
- } else if (!code) {
- this.$queue.showToast('请输入验证码');
- } else if (!password) {
- this.$queue.showToast('请设置密码');
- } else if (password.length < 6) {
- this.$queue.showToast('密码位数必须大于六位');
- } else if (!showAgree) {
- this.$queue.showToast('请同意《用户协议》和《隐私政策》');
- } else {
- this.logining = true;
- this.$queue.showLoading('注册中...');
- this.$Request.post(`/app/Login/registerCode`, {
- userName: userName,
- password: password,
- phone: phone,
- openId: this.$queue.getData('openid') ? this.$queue.getData('openid') : '',
- inviterCode: this.invitation,
- platform: this.platform,
- msg: code
- }).then(res => {
- if (res.code === 0) {
- this.$queue.showToast('注册成功');
-
- this.$queue.setData("token", res.token);
- this.$queue.setData('userId', res.user.userId);
- this.$queue.setData('userName', res.user.userName);
- this.$queue.setData('phone', res.user.phone);
- this.$queue.setData('avatar', res.user.avatar?res.user.avatar: '../../static/logo.png');
- this.getUserInfo()
- setTimeout(function() {
- uni.switchTab({
- url:'/pages/index/index'
- })
- },1000)
- } else {
- uni.hideLoading();
- uni.showModal({
- showCancel: false,
- title: '注册失败',
- content: res.msg
- });
- }
- });
- }
- },
- //获取用户信息
- getUserInfo() {
- this.$Request.get("/app/user/selectUserById").then(res => {
- if (res.code == 0) {
- uni.hideLoading()
- this.$queue.setData('avatar', res.data.avatar?res.data.avatar:'../../static/logo.png');
- this.$queue.setData('userId', res.data.userId);
- this.$queue.setData('userName', res.data.userName);
- this.$queue.setData('phone', res.data.phone);
- this.$queue.setData("invitationCode", res.user.invitationCode);
- this.$queue.setData("inviterCode", res.user.inviterCode);
-
- this.userName = res.data.userName
- this.invitationCode = res.data.invitationCode
- uni.setStorageSync('invitationCode', res.data.invitationCode)
- setTimeout(function() {
- uni.switchTab({
- url:'/pages/index/index'
- })
- },1000)
- } else {
- uni.showModal({
- showCancel: false,
- title: '登录失败',
- content: res.msg
- });
- this.$queue.logout();
- }
- });
- }
- }
- };
- </script>
- <style lang="scss">
- .cu-form-group{
- background: #F6F6F6;
- }
- page {
- height: 100%;
- background: #FFFFFF !important;
- }
- .footer {
- padding-left: 140upx;
- margin-top: 32upx;
- text-align: center;
- display: flex;
- // color: #FFFFFF;
- }
- .send-msg {
- border-radius: 30px;
- color: #222;
- height: 30px;
- font-size: 10px;
- line-height: 30px;
- background: linear-gradient( 143deg, #FFE6EE 0%, #FF9AB2 100%);
- }
- .container {
- padding-top: 32upx;
- position: relative;
- width: 100%;
- height: 100%;
- overflow: hidden;
- background: #ffffff!important;
- }
- .wrapper {
- position: relative;
- z-index: 90;
- background: #ffffff;
- padding-bottom: 20px;
- }
- .input-content {
- padding: 32upx 80upx;
- }
- .confirm-btn {
- width: 582rpx;
- height: 100rpx;
- line-height: 100rpx;
- text-aligh:center;
- background: linear-gradient( 143deg, #FFE6EE 0%, #FF9AB2 100%);
- border-radius: 86rpx 86rpx 86rpx 86rpx;
- font-weight: bold;
- font-size: 32rpx;
- color: #222222;
- }
- </style>
|