代码优化
This commit is contained in:
parent
4ccddee396
commit
5b19340974
2
App.vue
2
App.vue
|
|
@ -15,7 +15,7 @@
|
|||
onShow: function() {
|
||||
// ios是否在审核
|
||||
http.request({
|
||||
url: 'app/common/type/919',
|
||||
url: 'common/type/919',
|
||||
}).then(res => {
|
||||
if (res.code == 0) {
|
||||
uni.setStorageSync('isExamine', res.data.value)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
import http from '@/http/http.js'
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
export const login = (data) => {
|
||||
return http.request({
|
||||
url: '/Login/registerCode',
|
||||
method: 'POST',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
*/
|
||||
export const setSendMsg = (mobile,type) => {
|
||||
return http.request({
|
||||
url: '/Login/sendMsg/' + mobile + '/'+type
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
export const registerCode = (params) => {
|
||||
return http.request({
|
||||
url: '/Login/registerCode',
|
||||
params: params
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
import http from '@/http/http.js'
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*/
|
||||
export const selectUserById = (data) => {
|
||||
return http.request({
|
||||
url: '/user/selectUserById',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@ const env='test' //test , production,local
|
|||
|
||||
export const encryptKey='1234567890123456' // http数据加解密的key
|
||||
|
||||
export const apiUrl='/czg/'
|
||||
export const apiUrl='/czg/app'
|
||||
export const h5Config = {
|
||||
production: 'https://dj-h5.hnsiyao.cn',
|
||||
test: 'https://web-api.hnsiyao.cn',
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ const loadingShowTime = 200
|
|||
|
||||
function getHeader() {
|
||||
const headerObject = {}
|
||||
headerObject["token"] = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyNjkyNSIsImlhdCI6MTczNTg4OTk5NCwiZXhwIjoxNzM2NDk0Nzk0fQ.j-KFEE1FHckmFCO8UA884RBWvpMv8MfEGj7GPGf3kVo6sHeORl043Yle_w7HdTZKPpQqSr2LQLCq_rUxG4qqwA'
|
||||
// headerObject["token"] = uni.getStorageSync('token')
|
||||
// headerObject["token"] = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIyNjkyNSIsImlhdCI6MTczNTg4OTk5NCwiZXhwIjoxNzM2NDk0Nzk0fQ.j-KFEE1FHckmFCO8UA884RBWvpMv8MfEGj7GPGf3kVo6sHeORl043Yle_w7HdTZKPpQqSr2LQLCq_rUxG4qqwA'
|
||||
headerObject["token"] = uni.getStorageSync('token')
|
||||
return headerObject
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,21 +8,21 @@
|
|||
<view style="font-size: 58rpx;font-weight: bold;color: #333;margin-bottom: 48rpx;">重置密码</view>
|
||||
<view class="cu-form-group">
|
||||
<view class="title">手机号</view>
|
||||
<input class="input" type="number" :value="mobile" placeholder="请输入手机号" maxlength="11" data-key="mobile"
|
||||
<input class="input" type="number" :value="data.mobile" placeholder="请输入手机号" maxlength="11" data-key="mobile"
|
||||
@input="inputChange" />
|
||||
</view>
|
||||
<view class="cu-form-group">
|
||||
<text class="title">验证码</text>
|
||||
<view class="input flex">
|
||||
<input type="number" :value="code" placeholder="请输入验证码" maxlength="6" data-key="code"
|
||||
<input type="number" :value="data.code" placeholder="请输入验证码" maxlength="6" data-key="code"
|
||||
@input="inputChange" @confirm="reset" />
|
||||
<button class="send-msg" @click="sendMsg" :disabled="sending">{{ sendTime }}</button>
|
||||
<button class="send-msg" @click="sendMsg" :disabled="data.sending">{{ data.sendTime }}</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="cu-form-group">
|
||||
<text class="title">设置密码</text>
|
||||
<input class="input" type="password" :value="password" placeholder="请设置新密码" placeholder-class="input-empty"
|
||||
<input class="input" type="password" :value="data.password" placeholder="请设置新密码" placeholder-class="input-empty"
|
||||
maxlength="20" minlength="6" data-key="password" @input="inputChange" @confirm="reset" />
|
||||
</view>
|
||||
<button class="confirm-btn" @click="reset">立即重置</button>
|
||||
|
|
@ -32,169 +32,148 @@
|
|||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script setup>
|
||||
import { reactive } from 'vue';
|
||||
import { onLoad} from '@dcloudio/uni-app'
|
||||
import http from '@/http/http.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
code: '',
|
||||
mobile: '',
|
||||
password: '',
|
||||
sending: false,
|
||||
sendTime: '获取验证码',
|
||||
count: 60,
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
*/
|
||||
sendMsg() {
|
||||
if (!this.mobile) {
|
||||
let data = reactive({
|
||||
code: '',
|
||||
mobile: '',
|
||||
password: '',
|
||||
sending: false,
|
||||
sendTime: '获取验证码',
|
||||
count: 60,
|
||||
})
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
*/
|
||||
function sendMsg() {
|
||||
if (!data.mobile) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else if (data.mobile.length !== 11) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else {
|
||||
uni.showLoading({
|
||||
title: '正在发送验证码...'
|
||||
})
|
||||
http.request({
|
||||
url:'app/Login/sendMsg/' + data.mobile + '/forget',
|
||||
}).then(res => {
|
||||
if ( res.code == 0 ) {
|
||||
data.sending = true;
|
||||
uni.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else if (this.mobile.length !== 11) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
title: '验证码发送成功请注意查收',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
data.countDown();
|
||||
} else {
|
||||
uni.showLoading({
|
||||
title: '正在发送验证码...'
|
||||
})
|
||||
http.request({
|
||||
url:'app/Login/sendMsg/' + this.mobile + '/forget',
|
||||
}).then(res => {
|
||||
if ( res.code == 0 ) {
|
||||
this.sending = true;
|
||||
uni.showToast({
|
||||
title: '验证码发送成功请注意查收',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
this.countDown();
|
||||
} else {
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '短信发送失败',
|
||||
content: res.msg ? res.msg : '请一分钟后再获取验证码'
|
||||
});
|
||||
}
|
||||
|
||||
uni.hideLoading();
|
||||
})
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 验证码倒计时
|
||||
*/
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取手机号/验证码/密码
|
||||
* @param {Object} e
|
||||
*/
|
||||
inputChange(e) {
|
||||
const key = e.currentTarget.dataset.key;
|
||||
this[key] = e.detail.value;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
reset() {
|
||||
const {
|
||||
mobile,
|
||||
password,
|
||||
code
|
||||
} = this;
|
||||
if (!mobile) {
|
||||
// this.$queue.showToast("请输入手机号");
|
||||
uni.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else if (!code) {
|
||||
// this.$queue.showToast("密码位数必须大于六位");
|
||||
uni.showToast({
|
||||
title: '请输入验证码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else if (!password) {
|
||||
// this.$queue.showToast("请设置密码");
|
||||
uni.showToast({
|
||||
title: '请输入密码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else {
|
||||
this.loginIng = true;
|
||||
// this.$queue.showLoading("正在修改密码中...");
|
||||
uni.showLoading({
|
||||
title: '正在修改密码中...'
|
||||
})
|
||||
http.request({
|
||||
url: 'app/Login/forgetPwd?pwd=' + password + '&phone=' + mobile + '&msg=' + code,
|
||||
method: 'post'
|
||||
}).then(
|
||||
res => {
|
||||
// this.$Request.postJson("/appLogin/forgetPwd",{
|
||||
// pwd: password,
|
||||
// phone: mobile,
|
||||
// msg: code
|
||||
// }).then(res => {
|
||||
uni.hideLoading();
|
||||
if (res.code === 0) {
|
||||
uni.showToast({
|
||||
title: '密码找回成功',
|
||||
icon: 'none'
|
||||
});
|
||||
setTimeout(function() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/login'
|
||||
});
|
||||
}, 1000)
|
||||
|
||||
} else {
|
||||
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '密码找回失败',
|
||||
content: res.msg,
|
||||
});
|
||||
}
|
||||
});
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '短信发送失败',
|
||||
content: res.msg ? res.msg : '请一分钟后再获取验证码'
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
uni.hideLoading();
|
||||
})
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码倒计时
|
||||
*/
|
||||
function countDown() {
|
||||
if (data.count === 1) {
|
||||
data.count = 60;
|
||||
data.sending = false;
|
||||
data.sendTime = '获取验证码';
|
||||
} else {
|
||||
data.count = count - 1;
|
||||
data.sending = true;
|
||||
data.sendTime = count - 1 + '秒后重新获取';
|
||||
setTimeout(data.countDown.bind(data), 1000);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取手机号/验证码/密码
|
||||
* @param {Object} e
|
||||
*/
|
||||
function inputChange(e) {
|
||||
const key = e.currentTarget.dataset.key;
|
||||
data[key] = e.detail.value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
function reset() {
|
||||
|
||||
if (!data.mobile) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else if (!data.code) {
|
||||
uni.showToast({
|
||||
title: '请输入验证码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else if (!data.password) {
|
||||
uni.showToast({
|
||||
title: '请输入密码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else {
|
||||
data.loginIng = true;
|
||||
uni.showLoading({
|
||||
title: '正在修改密码中...'
|
||||
})
|
||||
http.request({
|
||||
url: 'app/Login/forgetPwd?pwd=' + data.password + '&phone=' + data.mobile + '&msg=' + data.code,
|
||||
method: 'post'
|
||||
}).then(
|
||||
res => {
|
||||
|
||||
uni.hideLoading();
|
||||
if (res.code === 0) {
|
||||
uni.showToast({
|
||||
title: '密码找回成功',
|
||||
icon: 'none'
|
||||
});
|
||||
setTimeout(function() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/login'
|
||||
});
|
||||
}, 1000)
|
||||
|
||||
} else {
|
||||
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '密码找回失败',
|
||||
content: res.msg,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" >
|
||||
|
|
|
|||
|
|
@ -9,14 +9,14 @@
|
|||
|
||||
<view class="cu-form-group">
|
||||
<view class="title">手机号</view>
|
||||
<input class="input" type="number" :value="mobile" placeholder="请输入手机号" maxlength="11" data-key="mobile"
|
||||
<input class="input" type="number" :value="data.mobile" placeholder="请输入手机号" maxlength="11" data-key="mobile"
|
||||
@input="inputChange" />
|
||||
</view>
|
||||
|
||||
<view class="cu-form-group">
|
||||
<text class="title">密码</text>
|
||||
<view class="input flex">
|
||||
<input class="input" type="password" :value="password" placeholder="请输入密码" placeholder-class="input-empty"
|
||||
<view class="input flex" style="padding-left: 0;">
|
||||
<input class="input" type="password" :value="data.password" placeholder="请输入密码" placeholder-class="input-empty"
|
||||
maxlength="20" minlength="6" data-key="password" @input="inputChange" @confirm="toLogin" />
|
||||
<text class="send-msg" @click="forget" style="flex-shrink: 0;">忘记密码</text>
|
||||
</view>
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
</view>
|
||||
<view class="footerView">
|
||||
<u-checkbox-group>
|
||||
<u-checkbox v-model="checked" label-size='24upx' shape="circle" @change="radioChange"></u-checkbox>
|
||||
<u-checkbox v-model="data.checked" label-size='24upx' shape="circle" @change="radioChange"></u-checkbox>
|
||||
</u-checkbox-group>
|
||||
<view>同意</view>
|
||||
<!-- 协议地址 -->
|
||||
|
|
@ -45,135 +45,121 @@
|
|||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import http from '@/http/http.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
mobile: '',
|
||||
password: '',
|
||||
checked: false
|
||||
};
|
||||
},
|
||||
onLoad() {
|
||||
if (uni.getStorageSync('isSafeView')) {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '您正在使用无痕浏览,可能导致登录状态失效,建议切换浏览模式',
|
||||
})
|
||||
uni.setStorageSync("isSafeView", null)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
register() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/register'
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 忘记密码
|
||||
*/
|
||||
forget() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/forgetPwd'
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取手机号/密码
|
||||
* @param {Object} e
|
||||
*/
|
||||
inputChange(e) {
|
||||
const key = e.currentTarget.dataset.key;
|
||||
this[key] = e.detail.value;
|
||||
},
|
||||
|
||||
/**
|
||||
* 同意协议
|
||||
* @param {Object} e
|
||||
*/
|
||||
radioChange(e) {
|
||||
this.checked = e
|
||||
},
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
toLogin() {
|
||||
if (!this.checked) {
|
||||
uni.showToast({
|
||||
title: '请阅读并同意《隐私政策》和《用户服务协议》',
|
||||
icon: 'none',
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
const { mobile, password } = this;
|
||||
console.log(this.mobile)
|
||||
if (!mobile) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none',
|
||||
})
|
||||
} else if (mobile.length != 11) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none',
|
||||
})
|
||||
} else if (!password) {
|
||||
uni.showToast({
|
||||
title: '请输入密码',
|
||||
icon: 'none',
|
||||
})
|
||||
} else {
|
||||
uni.showLoading({
|
||||
title: '正在登录中...',
|
||||
})
|
||||
http.request({
|
||||
url: 'app/Login/registerCode?password=' + password + '&phone=' + mobile,
|
||||
method: 'post'
|
||||
}).then(res => {
|
||||
console.log(res)
|
||||
if (res.code === 0) {
|
||||
uni.setStorageSync('token', res.token)
|
||||
uni.setStorageSync('userId', res.user.userId)
|
||||
uni.setStorageSync('userName', res.user.userName)
|
||||
uni.setStorageSync('avatar', res.user.avatar ? res.user.avatar : '../../static/default/avatar.png')
|
||||
uni.setStorageSync('phone', res.user.phone)
|
||||
uni.setStorageSync('invitationCode', res.user.invitationCode)
|
||||
uni.setStorageSync('sex', res.user.sex)
|
||||
uni.setStorageSync('userId', res.user.userId)
|
||||
//设置渠道码
|
||||
if (res.user.qdCode) {
|
||||
uni.setStorageSync('qdCode', res.user.qdCode)
|
||||
}
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'none'
|
||||
})
|
||||
uni.reLaunch({
|
||||
url:'/pages/index/index'
|
||||
})
|
||||
} else{
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
<script setup>
|
||||
import { reactive } from 'vue';
|
||||
import { onLoad} from '@dcloudio/uni-app'
|
||||
import { login } from '@/api/login/login.js';
|
||||
let data = reactive({
|
||||
mobile: '',
|
||||
password: '',
|
||||
checked: false
|
||||
})
|
||||
|
||||
onLoad(() => {
|
||||
|
||||
})
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
function register () {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/register'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 忘记密码
|
||||
*/
|
||||
function forget () {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/forgetPwd'
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取手机号/密码
|
||||
*/
|
||||
function inputChange (e) {
|
||||
const key = e.currentTarget.dataset.key;
|
||||
data[key] = e.detail.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同意协议
|
||||
*/
|
||||
function radioChange (e) {
|
||||
data.checked = e
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
async function toLogin () {
|
||||
if (!data.checked) {
|
||||
uni.showToast({
|
||||
title: '请阅读并同意《隐私政策》和《用户服务协议》',
|
||||
icon: 'none',
|
||||
})
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
const { mobile, password } = data;
|
||||
if (!mobile) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none',
|
||||
})
|
||||
} else if (mobile.length != 11) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none',
|
||||
})
|
||||
} else if (!password) {
|
||||
uni.showToast({
|
||||
title: '请输入密码',
|
||||
icon: 'none',
|
||||
})
|
||||
} else {
|
||||
uni.showLoading({
|
||||
title: '正在登录中...',
|
||||
})
|
||||
let res = await login({
|
||||
password: password,
|
||||
phone: mobile
|
||||
})
|
||||
|
||||
if (res.code === 0) {
|
||||
uni.setStorageSync('token', res.token)
|
||||
uni.setStorageSync('userId', res.user.userId)
|
||||
uni.setStorageSync('userName', res.user.userName)
|
||||
uni.setStorageSync('avatar', res.user.avatar ? res.user.avatar : '../../static/default/avatar.png')
|
||||
uni.setStorageSync('phone', res.user.phone)
|
||||
uni.setStorageSync('invitationCode', res.user.invitationCode)
|
||||
uni.setStorageSync('sex', res.user.sex)
|
||||
uni.setStorageSync('userId', res.user.userId)
|
||||
//设置渠道码
|
||||
if (res.user.qdCode) {
|
||||
uni.setStorageSync('qdCode', res.user.qdCode)
|
||||
}
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'none'
|
||||
})
|
||||
uni.reLaunch({
|
||||
url:'/pages/index/index'
|
||||
})
|
||||
} else{
|
||||
uni.hideLoading();
|
||||
uni.showToast({
|
||||
title: res.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
|||
|
|
@ -9,21 +9,21 @@
|
|||
|
||||
<view class="cu-form-group">
|
||||
<view class="title">手机号</view>
|
||||
<input class="input" type="number" :value="mobile" placeholder="请输入手机号" maxlength="11" data-key="mobile"
|
||||
<input class="input" type="number" :value="data.mobile" placeholder="请输入手机号" maxlength="11" data-key="mobile"
|
||||
@input="inputChange" />
|
||||
</view>
|
||||
<view class="cu-form-group">
|
||||
<text class="title">验证码</text>
|
||||
<view class="input flex">
|
||||
<input type="number" :value="code" placeholder="请输入验证码" maxlength="6" data-key="code"
|
||||
<input type="number" :value="data.code" placeholder="请输入验证码" maxlength="6" data-key="code"
|
||||
@input="inputChange" @confirm="toRegister" />
|
||||
<button class="send-msg" @click="sendMsg" :disabled="sending">{{ sendTime }}</button>
|
||||
<button class="send-msg" @click="sendMsg" :disabled="data.sending">{{ data.sendTime }}</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="cu-form-group">
|
||||
<text class="title">设置密码</text>
|
||||
<input class="input" type="password" :value="password" placeholder="请设置新密码" placeholder-class="input-empty"
|
||||
<input class="input" type="password" :value="data.password" placeholder="请设置新密码" placeholder-class="input-empty"
|
||||
maxlength="20" minlength="6" data-key="password" @input="inputChange" @confirm="toRegister" />
|
||||
</view>
|
||||
<button class="confirm-btn" @click="toRegister">注册</button>
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
</view>
|
||||
<view class="footerView">
|
||||
<u-checkbox-group>
|
||||
<u-checkbox v-model="checked" label-size='24upx' shape="circle" @change="radioChange"></u-checkbox>
|
||||
<u-checkbox v-model="data.checked" label-size='24upx' shape="circle" @change="radioChange"></u-checkbox>
|
||||
</u-checkbox-group>
|
||||
<view>注册即同意</view>
|
||||
<!-- 协议地址 -->
|
||||
|
|
@ -43,238 +43,240 @@
|
|||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script setup>
|
||||
import { reactive } from 'vue';
|
||||
import { onLoad} from '@dcloudio/uni-app'
|
||||
import http from '@/http/http.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
code: '',
|
||||
mobile: '',
|
||||
password: '',
|
||||
sending: false,
|
||||
sendTime: '获取验证码',
|
||||
count: 60,
|
||||
relation: "",
|
||||
invitation: '',
|
||||
registerCode: '',
|
||||
qdCodeion: '', //渠道码
|
||||
checked: false,
|
||||
};
|
||||
},
|
||||
onLoad( options ) {
|
||||
if (uni.getStorageSync('qdCodeion')) { this.qdCodeion = uni.getStorageSync('qdCodeion') }
|
||||
if (options.qdCode) { this.qdCodeion = options.qdCode }
|
||||
if (options.invitation ) { this.invitation = options.invitation }
|
||||
|
||||
http.request({
|
||||
url:'app/common/type/3',
|
||||
}).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.registerCode = res.data.value
|
||||
}
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
*/
|
||||
sendMsg() {
|
||||
if (!this.mobile) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else if (this.mobile.length !== 11) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else {
|
||||
uni.showLoading({
|
||||
title: '正在发送验证码...'
|
||||
})
|
||||
http.request({
|
||||
url:'app/Login/sendMsg/' + this.mobile + '/login',
|
||||
}).then(res => {
|
||||
if ( res.code == 0 ) {
|
||||
this.sending = true;
|
||||
uni.showToast({
|
||||
title: '验证码发送成功请注意查收',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
this.countDown();
|
||||
} else {
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '短信发送失败',
|
||||
content: res.msg ? res.msg : '请一分钟后再获取验证码'
|
||||
});
|
||||
}
|
||||
|
||||
uni.hideLoading();
|
||||
})
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 验证码倒计时
|
||||
*/
|
||||
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);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取注册值
|
||||
* @param {Object} e
|
||||
*/
|
||||
inputChange(e) {
|
||||
const key = e.currentTarget.dataset.key;
|
||||
this[key] = e.detail.value;
|
||||
},
|
||||
|
||||
/**
|
||||
* 是否同意协议
|
||||
* @param {Object} e
|
||||
*/
|
||||
radioChange(e) {
|
||||
this.checked = e
|
||||
},
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
toLogin() {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
import {setSendMsg} from '@/api/login/login.js';
|
||||
let data = reactive({
|
||||
code: '',
|
||||
mobile: '',
|
||||
password: '',
|
||||
sending: false,
|
||||
sendTime: '获取验证码',
|
||||
count: 60,
|
||||
relation: "",
|
||||
invitation: '',
|
||||
registerCode: '',
|
||||
qdCodeion: '', //渠道码
|
||||
checked: false,
|
||||
})
|
||||
|
||||
onLoad(( options ) => {
|
||||
if (uni.getStorageSync('qdCodeion')) { data.qdCodeion = uni.getStorageSync('qdCodeion') }
|
||||
if (options.qdCode) { data.qdCodeion = options.qdCode }
|
||||
if (options.invitation ) { data.invitation = options.invitation }
|
||||
|
||||
http.request({
|
||||
url:'app/common/type/3',
|
||||
}).then(res => {
|
||||
if (res.code == 0) {
|
||||
data.registerCode = res.data.value
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
*/
|
||||
async function sendMsg () {
|
||||
if (!data.mobile) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else if (data.mobile.length !== 11) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else {
|
||||
uni.showLoading({
|
||||
title: '正在发送验证码...'
|
||||
})
|
||||
let res = await setSendMsg(data.mobile,'login')
|
||||
console.log(res)
|
||||
if ( res.code == 0 ) {
|
||||
data.sending = true;
|
||||
uni.showToast({
|
||||
title: '验证码发送成功请注意查收',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
data.countDown();
|
||||
} else {
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '短信发送失败',
|
||||
content: res.msg ? res.msg : '请一分钟后再获取验证码'
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
toRegister() {
|
||||
const {
|
||||
mobile,
|
||||
password,
|
||||
code,
|
||||
checked,
|
||||
invitation,
|
||||
registerCode,
|
||||
qdCodeion
|
||||
} = this;
|
||||
if (!mobile) {
|
||||
uni.showToast({
|
||||
title: '请输入账号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!code) {
|
||||
uni.showToast({
|
||||
title: '请输入验证码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!password) {
|
||||
uni.showToast({
|
||||
title: '请设置密码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (password.length < 6) {
|
||||
uni.showToast({
|
||||
title: '密码位数必须大于六位',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (invitation.length == 0 && registerCode == '是') {
|
||||
uni.showToast({
|
||||
title: '请输入邀请码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!checked) {
|
||||
uni.showToast({
|
||||
title: '请先同意《隐私政策》和《用户协议》',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
this.logining = true;
|
||||
uni.showLoading({
|
||||
title: '注册中...'
|
||||
})
|
||||
let platform = ''
|
||||
// #ifdef APP
|
||||
platform = 'app'
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
platform = 'h5'
|
||||
// #endif
|
||||
http.request({
|
||||
url: 'app/Login/registerCode?password=' + password + '&phone=' + mobile + '&msg=' + code +
|
||||
'&inviterCode=' + invitation + '&platform=' + platform + '&qdCode=' + qdCodeion,
|
||||
method: 'post'
|
||||
}).then(res => {
|
||||
console.log(res)
|
||||
if (res.code === 0) {
|
||||
uni.setStorageSync('token', res.token)
|
||||
uni.setStorageSync('userId', res.user.userId)
|
||||
uni.setStorageSync('phone', res.user.phone)
|
||||
uni.setStorageSync('invitationCode', res.user.invitationCode)
|
||||
//设置渠道码
|
||||
if (res.user.qdCod) {
|
||||
uni.setStorageSync('qdCod', res.user.qdCod)
|
||||
}
|
||||
|
||||
uni.showToast({
|
||||
title: '注册成功',
|
||||
icon: 'none'
|
||||
})
|
||||
setTimeout(function() {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
}, 1000)
|
||||
} else {
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '注册失败',
|
||||
content: res.msg
|
||||
});
|
||||
}
|
||||
uni.hideLoading();
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
uni.hideLoading();
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 验证码倒计时
|
||||
*/
|
||||
function countDown() {
|
||||
if (data.count === 1) {
|
||||
data.count = 60;
|
||||
data.sending = false;
|
||||
data.sendTime = '获取验证码';
|
||||
} else {
|
||||
data.count = count - 1;
|
||||
data.sending = true;
|
||||
data.sendTime = count - 1 + '秒后重新获取';
|
||||
setTimeout(data.countDown.bind(data), 1000);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取注册值
|
||||
* @param {Object} e
|
||||
*/
|
||||
function inputChange(e) {
|
||||
const key = e.currentTarget.dataset.key;
|
||||
data[key] = e.detail.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否同意协议
|
||||
* @param {Object} e
|
||||
*/
|
||||
function radioChange(e) {
|
||||
data.checked = e
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*/
|
||||
function toLogin() {
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
async function toRegister() {
|
||||
const {
|
||||
mobile,
|
||||
password,
|
||||
code,
|
||||
checked,
|
||||
invitation,
|
||||
registerCode,
|
||||
qdCodeion
|
||||
} = this;
|
||||
if (!mobile) {
|
||||
uni.showToast({
|
||||
title: '请输入账号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!code) {
|
||||
uni.showToast({
|
||||
title: '请输入验证码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!password) {
|
||||
uni.showToast({
|
||||
title: '请设置密码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (password.length < 6) {
|
||||
uni.showToast({
|
||||
title: '密码位数必须大于六位',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (invitation.length == 0 && registerCode == '是') {
|
||||
uni.showToast({
|
||||
title: '请输入邀请码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!checked) {
|
||||
uni.showToast({
|
||||
title: '请先同意《隐私政策》和《用户协议》',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
data.logining = true;
|
||||
uni.showLoading({
|
||||
title: '注册中...'
|
||||
})
|
||||
let platform = ''
|
||||
// #ifdef APP
|
||||
platform = 'app'
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
platform = 'h5'
|
||||
// #endif
|
||||
|
||||
|
||||
let res = await registerCode({
|
||||
password: password,
|
||||
phone: mobile,
|
||||
msg: code,
|
||||
inviterCode: invitation,
|
||||
platform: platform,
|
||||
qdCode: qdCodeion,
|
||||
})
|
||||
|
||||
if (res.code === 0) {
|
||||
uni.setStorageSync('token', res.token)
|
||||
uni.setStorageSync('userId', res.user.userId)
|
||||
uni.setStorageSync('phone', res.user.phone)
|
||||
uni.setStorageSync('invitationCode', res.user.invitationCode)
|
||||
//设置渠道码
|
||||
if (res.user.qdCod) {
|
||||
uni.setStorageSync('qdCod', res.user.qdCod)
|
||||
}
|
||||
|
||||
uni.showToast({
|
||||
title: '注册成功',
|
||||
icon: 'none'
|
||||
})
|
||||
setTimeout(function() {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
});
|
||||
}, 1000)
|
||||
} else {
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '注册失败',
|
||||
content: res.msg
|
||||
});
|
||||
}
|
||||
uni.hideLoading();
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" >
|
||||
|
|
|
|||
|
|
@ -52,244 +52,234 @@
|
|||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script setup>
|
||||
import { reactive } from 'vue';
|
||||
import { onLoad} from '@dcloudio/uni-app'
|
||||
import http from '@/http/http.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
code: '',
|
||||
mobile: '',
|
||||
password: '',
|
||||
sending: false,
|
||||
sendTime: '获取验证码',
|
||||
count: 60,
|
||||
relation: "",
|
||||
invitation: '',
|
||||
registerCode: '',
|
||||
qdCodeion: '',
|
||||
checked: false,
|
||||
};
|
||||
},
|
||||
onLoad(e) {
|
||||
let relation = e.invitation
|
||||
if (relation) {
|
||||
this.relation = relation;
|
||||
this.invitation = relation;
|
||||
let data = reactive({
|
||||
code: '',
|
||||
mobile: '',
|
||||
password: '',
|
||||
sending: false,
|
||||
sendTime: '获取验证码',
|
||||
count: 60,
|
||||
relation: "",
|
||||
invitation: '',
|
||||
registerCode: '',
|
||||
qdCodeion: '', //渠道码
|
||||
checked: false,
|
||||
})
|
||||
|
||||
onLoad(( options ) => {
|
||||
let relation = e.invitation
|
||||
if (relation) {
|
||||
this.relation = relation;
|
||||
this.invitation = relation;
|
||||
}
|
||||
if (e.qdCode) {
|
||||
this.qdCodeion = e.qdCode
|
||||
}
|
||||
http.request({
|
||||
url:'app/common/type/3',
|
||||
}).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.registerCode = res.data.value
|
||||
}
|
||||
if (e.qdCode) {
|
||||
this.qdCodeion = e.qdCode
|
||||
});
|
||||
})
|
||||
|
||||
/**
|
||||
* 是否同意协议
|
||||
* @param {Object} e
|
||||
*/
|
||||
function radioChange(e) {
|
||||
this.checked = e
|
||||
}
|
||||
|
||||
function showMa() {
|
||||
//查询官方邀请码
|
||||
this.$Request.getT('/common/type/88').then(res => {
|
||||
if (res.code == 0) {
|
||||
this.invitation = res.data.value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function sendMsg() {
|
||||
const {
|
||||
mobile
|
||||
} = this;
|
||||
if (!mobile) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else if (mobile.length !== 11) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else {
|
||||
uni.showLoading({
|
||||
title: '正在发送验证码...'
|
||||
})
|
||||
http.request({
|
||||
url:'app/common/type/3',
|
||||
url:'app/Login/sendMsg/' + mobile + '/login',
|
||||
}).then(res => {
|
||||
if (res.code == 0) {
|
||||
this.registerCode = res.data.value
|
||||
}
|
||||
});
|
||||
|
||||
},
|
||||
methods: {
|
||||
|
||||
/**
|
||||
* 是否同意协议
|
||||
* @param {Object} e
|
||||
*/
|
||||
radioChange(e) {
|
||||
this.checked = e
|
||||
},
|
||||
|
||||
showMa() {
|
||||
//查询官方邀请码
|
||||
this.$Request.getT('/common/type/88').then(res => {
|
||||
if (res.code == 0) {
|
||||
this.invitation = res.data.value;
|
||||
}
|
||||
});
|
||||
},
|
||||
sendMsg() {
|
||||
const {
|
||||
mobile
|
||||
} = this;
|
||||
if (!mobile) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else if (mobile.length !== 11) {
|
||||
uni.showToast({
|
||||
title: '请输入正确的手机号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
} else {
|
||||
uni.showLoading({
|
||||
title: '正在发送验证码...'
|
||||
})
|
||||
http.request({
|
||||
url:'app/Login/sendMsg/' + mobile + '/login',
|
||||
}).then(res => {
|
||||
if (res.code === 0) {
|
||||
this.sending = true;
|
||||
uni.showToast({
|
||||
title: '验证码发送成功请注意查收',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
this.countDown();
|
||||
} else {
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '短信发送失败',
|
||||
content: res.msg ? res.msg : '请一分钟后再获取验证码'
|
||||
});
|
||||
}
|
||||
|
||||
uni.hideLoading();
|
||||
})
|
||||
|
||||
}
|
||||
},
|
||||
countDown() {
|
||||
const {
|
||||
count
|
||||
} = this;
|
||||
if (count === 1) {
|
||||
this.count = 60;
|
||||
this.sending = false;
|
||||
this.sendTime = '获取验证码';
|
||||
} else {
|
||||
this.count = count - 1;
|
||||
if (res.code === 0) {
|
||||
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() {
|
||||
console.log("123");
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
});
|
||||
},
|
||||
toRegister() {
|
||||
const {
|
||||
mobile,
|
||||
password,
|
||||
code,
|
||||
checked,
|
||||
invitation,
|
||||
registerCode,
|
||||
qdCodeion
|
||||
} = this;
|
||||
if (!mobile) {
|
||||
uni.showToast({
|
||||
title: '请输入账号',
|
||||
title: '验证码发送成功请注意查收',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
this.countDown();
|
||||
} else {
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '短信发送失败',
|
||||
content: res.msg ? res.msg : '请一分钟后再获取验证码'
|
||||
});
|
||||
}
|
||||
if (!code) {
|
||||
uni.showToast({
|
||||
title: '请输入验证码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!password) {
|
||||
uni.showToast({
|
||||
title: '请设置密码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (password.length < 6) {
|
||||
uni.showToast({
|
||||
title: '密码位数必须大于六位',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (invitation.length == 0 && registerCode == '是') {
|
||||
uni.showToast({
|
||||
title: '请输入邀请码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!checked) {
|
||||
uni.showToast({
|
||||
title: '请先同意《隐私政策》和《用户协议》',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
this.logining = true;
|
||||
uni.showLoading({
|
||||
title: '注册中...'
|
||||
})
|
||||
let platform = ''
|
||||
// #ifdef APP
|
||||
platform = 'app'
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
platform = 'h5'
|
||||
// #endif
|
||||
http.request({
|
||||
url: 'app/Login/registerCode?password=' + password + '&phone=' + mobile + '&msg=' + code +
|
||||
'&inviterCode=' + invitation + '&platform=' + platform + '&qdCode=' + qdCodeion,
|
||||
method: 'post'
|
||||
}).then(res => {
|
||||
if (res.code === 0) {
|
||||
// this.$queue.remove('invitation');
|
||||
uni.setStorageSync('token', res.token)
|
||||
uni.setStorageSync('userId', res.user.userId)
|
||||
uni.setStorageSync('phone', res.user.phone)
|
||||
uni.setStorageSync('invitationCode', res.user.invitationCode)
|
||||
//设置渠道码
|
||||
if (res.user.qdCode) {
|
||||
uni.setStorageSync('qdCode', res.user.qdCode)
|
||||
}
|
||||
uni.showToast({
|
||||
title: '注册成功',
|
||||
icon: 'none'
|
||||
})
|
||||
setTimeout(function() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/appEq'
|
||||
})
|
||||
}, 1000)
|
||||
} else {
|
||||
uni.hideLoading();
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '注册失败',
|
||||
content: res.msg
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
uni.hideLoading();
|
||||
})
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
function 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);
|
||||
}
|
||||
}
|
||||
|
||||
function inputChange(e) {
|
||||
const key = e.currentTarget.dataset.key;
|
||||
this[key] = e.detail.value;
|
||||
}
|
||||
|
||||
function toLogin() {
|
||||
console.log("123");
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
});
|
||||
}
|
||||
|
||||
function toRegister() {
|
||||
const {
|
||||
mobile,
|
||||
password,
|
||||
code,
|
||||
checked,
|
||||
invitation,
|
||||
registerCode,
|
||||
qdCodeion
|
||||
} = this;
|
||||
if (!mobile) {
|
||||
uni.showToast({
|
||||
title: '请输入账号',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!code) {
|
||||
uni.showToast({
|
||||
title: '请输入验证码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!password) {
|
||||
uni.showToast({
|
||||
title: '请设置密码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (password.length < 6) {
|
||||
uni.showToast({
|
||||
title: '密码位数必须大于六位',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (invitation.length == 0 && registerCode == '是') {
|
||||
uni.showToast({
|
||||
title: '请输入邀请码',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!checked) {
|
||||
uni.showToast({
|
||||
title: '请先同意《隐私政策》和《用户协议》',
|
||||
icon: 'none',
|
||||
duration: 1000
|
||||
})
|
||||
return
|
||||
}
|
||||
this.logining = true;
|
||||
uni.showLoading({
|
||||
title: '注册中...'
|
||||
})
|
||||
let platform = ''
|
||||
// #ifdef APP
|
||||
platform = 'app'
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
platform = 'h5'
|
||||
// #endif
|
||||
http.request({
|
||||
url: 'app/Login/registerCode?password=' + password + '&phone=' + mobile + '&msg=' + code +
|
||||
'&inviterCode=' + invitation + '&platform=' + platform + '&qdCode=' + qdCodeion,
|
||||
method: 'post'
|
||||
}).then(res => {
|
||||
if (res.code === 0) {
|
||||
// this.$queue.remove('invitation');
|
||||
uni.setStorageSync('token', res.token)
|
||||
uni.setStorageSync('userId', res.user.userId)
|
||||
uni.setStorageSync('phone', res.user.phone)
|
||||
uni.setStorageSync('invitationCode', res.user.invitationCode)
|
||||
//设置渠道码
|
||||
if (res.user.qdCode) {
|
||||
uni.setStorageSync('qdCode', res.user.qdCode)
|
||||
}
|
||||
uni.showToast({
|
||||
title: '注册成功',
|
||||
icon: 'none'
|
||||
})
|
||||
setTimeout(function() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/appEq'
|
||||
})
|
||||
}, 1000)
|
||||
} else {
|
||||
uni.hideLoading();
|
||||
uni.showModal({
|
||||
showCancel: false,
|
||||
title: '注册失败',
|
||||
content: res.msg
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
|||
|
|
@ -3,18 +3,18 @@
|
|||
<up-cell-group>
|
||||
<up-cell title="头像">
|
||||
<template #value>
|
||||
<image :src="userInfo.avatar?userInfo.avatar:'../../static/default/avatar.png'" mode="" @click="uploadImg"
|
||||
<image :src="data.userInfo.avatar?data.userInfo.avatar:'../../static/default/avatar.png'" mode="" @click="uploadImg"
|
||||
style="width: 111rpx;height: 111rpx;border-radius: 50%;"></image>
|
||||
</template>
|
||||
</up-cell>
|
||||
<up-cell title="用户名">
|
||||
<template #value>
|
||||
<input v-model="userInfo.userName" align="right" placeholder="请输入用户名" />
|
||||
<input v-model="data.userInfo.userName" align="right" placeholder="请输入用户名" />
|
||||
</template>
|
||||
</up-cell>
|
||||
<up-cell title="手机">
|
||||
<template #value>
|
||||
<input :disabled="userInfo.phone?true:false" v-model="userInfo.phone" align="right" placeholder="请输入联系电话" />
|
||||
<input :disabled="data.userInfo.phone?true:false" v-model="data.userInfo.phone" align="right" placeholder="请输入联系电话" />
|
||||
</template>
|
||||
</up-cell>
|
||||
</up-cell-group>
|
||||
|
|
@ -22,144 +22,141 @@
|
|||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
<script setup>
|
||||
import { reactive } from 'vue';
|
||||
import { onShow} from '@dcloudio/uni-app'
|
||||
import config from '@/commons/config.js';
|
||||
import http from '@/http/http.js';
|
||||
export default {
|
||||
data() {
|
||||
return{
|
||||
userInfo: {
|
||||
avatar: '',
|
||||
userName: '',
|
||||
phone: '',
|
||||
}
|
||||
}
|
||||
},
|
||||
onLoad( options ) {
|
||||
this.getUserInfo()
|
||||
},
|
||||
|
||||
methods: {
|
||||
/**
|
||||
* 获取个人信息
|
||||
*/
|
||||
getUserInfo() {
|
||||
http.request({
|
||||
url:'app/user/selectUserById',
|
||||
}).then(res => {
|
||||
this.userInfo = res.data
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 上次头像
|
||||
*/
|
||||
uploadImg() {
|
||||
let that = this;
|
||||
var url = null;
|
||||
uni.showActionSheet({
|
||||
// itemList按钮的文字接受的是数组
|
||||
itemList: ["查看头像", "从相册选择图片"],
|
||||
success(e) {
|
||||
var index = e.tapIndex
|
||||
console.log(index)
|
||||
if (index === 0) {
|
||||
// 用户点击了预览当前图片
|
||||
// 可以自己实现当前头像链接的读取
|
||||
let url = that.headImg;
|
||||
let arr = []
|
||||
arr.push(url)
|
||||
uni.previewImage({
|
||||
// 预览功能图片也必须是数组的
|
||||
urls: arr
|
||||
})
|
||||
} else if (index === 1) {
|
||||
uni.chooseImage({
|
||||
count: 1, //默认9
|
||||
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
||||
sourceType: ['album'], //从相册选择
|
||||
success: function(res) {
|
||||
uni.showLoading({
|
||||
title: '上传中...'
|
||||
});
|
||||
uni.uploadFile({
|
||||
url: config.baseApiUrl + 'alioss/upload',
|
||||
filePath: res.tempFilePaths[0],
|
||||
name: 'file',
|
||||
success: uploadFileRes => {
|
||||
url = JSON.parse(uploadFileRes.data);
|
||||
console.log(url)
|
||||
this.userInfo.avatar = url.data
|
||||
uni.hideLoading();
|
||||
|
||||
}
|
||||
});
|
||||
import {selectUserById} from '@/api/user/user.js';
|
||||
|
||||
let data = reactive({
|
||||
userInfo: {
|
||||
avatar: '',
|
||||
userName: '',
|
||||
phone: '',
|
||||
}
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
// console.log(1)
|
||||
getUserInfo()
|
||||
})
|
||||
|
||||
/**
|
||||
* 获取个人信息
|
||||
*/
|
||||
async function getUserInfo () {
|
||||
let res = await selectUserById()
|
||||
if ( res.code == 0 ) {
|
||||
data.userInfo = res.data
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传头像
|
||||
*/
|
||||
function uploadImg () {
|
||||
var url = null;
|
||||
uni.showActionSheet({
|
||||
// itemList按钮的文字接受的是数组
|
||||
itemList: ["查看头像", "从相册选择图片"],
|
||||
success(e) {
|
||||
var index = e.tapIndex
|
||||
console.log(index)
|
||||
if (index === 0) {
|
||||
// 用户点击了预览当前图片
|
||||
// 可以自己实现当前头像链接的读取
|
||||
let url = data.userInfo.avatar;
|
||||
let arr = []
|
||||
arr.push(url)
|
||||
uni.previewImage({
|
||||
// 预览功能图片也必须是数组的
|
||||
urls: arr
|
||||
})
|
||||
} else if (index === 1) {
|
||||
uni.chooseImage({
|
||||
count: 1, //默认9
|
||||
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
|
||||
sourceType: ['album'], //从相册选择
|
||||
success: function(res) {
|
||||
uni.showLoading({
|
||||
title: '上传中...'
|
||||
});
|
||||
uni.uploadFile({
|
||||
url: config.baseApiUrl + 'alioss/upload',
|
||||
filePath: res.tempFilePaths[0],
|
||||
name: 'file',
|
||||
success: uploadFileRes => {
|
||||
url = JSON.parse(uploadFileRes.data);
|
||||
console.log(url)
|
||||
data.userInfo.avatar = url.data
|
||||
uni.hideLoading();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
save() {
|
||||
if (!this.userInfo.userName) {
|
||||
uni.showToast({
|
||||
title: "用户名不能为空",
|
||||
icon: "none"
|
||||
})
|
||||
return
|
||||
});
|
||||
}
|
||||
if (!this.userInfo.phone) {
|
||||
uni.showToast({
|
||||
title: "手机号不能空",
|
||||
icon: "none"
|
||||
})
|
||||
return
|
||||
}
|
||||
if (this.checkPhone(this.userInfo.phone) == false) {
|
||||
uni.showToast({
|
||||
title: "手机号格式不正确",
|
||||
icon: "none"
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
title: '温馨提示',
|
||||
content: '确定保存信息',
|
||||
confirmColor: '#ff7581',
|
||||
success: e => {
|
||||
if (e.confirm) {
|
||||
http.request({
|
||||
url:'app/user/updateUsers',
|
||||
method: 'post',
|
||||
data: {
|
||||
userName: this.userInfo.userName,
|
||||
avatar: this.userInfo.avatar,
|
||||
phone: this.userInfo.phone,
|
||||
}
|
||||
}).then(res => {
|
||||
uni.showToast({
|
||||
title: '保存成功',
|
||||
icon: "none"
|
||||
})
|
||||
setTimeout(function() {
|
||||
uni.navigateBack()
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
//根据正则验证手机号是否正确包括校验长度
|
||||
checkPhone(phone) {
|
||||
return /^1[3456789]\d{9}$/.test(phone);
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存
|
||||
*/
|
||||
function save () {
|
||||
if (!data.userInfo.userName) {
|
||||
uni.showToast({
|
||||
title: "用户名不能为空",
|
||||
icon: "none"
|
||||
})
|
||||
return
|
||||
}
|
||||
if (!data.userInfo.phone) {
|
||||
uni.showToast({
|
||||
title: "手机号不能空",
|
||||
icon: "none"
|
||||
})
|
||||
return
|
||||
}
|
||||
if (checkPhone(data.userInfo.phone) == false) {
|
||||
uni.showToast({
|
||||
title: "手机号格式不正确",
|
||||
icon: "none"
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
title: '温馨提示',
|
||||
content: '确定保存信息',
|
||||
confirmColor: '#ff7581',
|
||||
success: e => {
|
||||
if (e.confirm) {
|
||||
http.request({
|
||||
url:'app/user/updateUsers',
|
||||
method: 'post',
|
||||
data: {
|
||||
userName: data.userInfo.userName,
|
||||
avatar: data.userInfo.avatar,
|
||||
phone: data.userInfo.phone,
|
||||
}
|
||||
}).then(res => {
|
||||
uni.showToast({
|
||||
title: '保存成功',
|
||||
icon: "none"
|
||||
})
|
||||
setTimeout(function() {
|
||||
uni.navigateBack()
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function checkPhone(phone) {
|
||||
return /^1[3456789]\d{9}$/.test(phone);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue