|
@@ -108,42 +108,40 @@
|
|
|
// 查询
|
|
|
const search = async () => {
|
|
|
const res = await $api(`login/wxapp/${openid.value}`, 'POST', {});
|
|
|
- if (res.errcode == '0') form.value = res.data
|
|
|
+ if (res.errcode == '0') {
|
|
|
+ form.value = res.data
|
|
|
+ uni.setStorageSync('user', res.data);
|
|
|
+ }
|
|
|
};
|
|
|
// 开始验证
|
|
|
const formSubmit = () => {
|
|
|
if (agree.value) {
|
|
|
if (openid.value) {
|
|
|
uForm.value.validate().then(async res => {
|
|
|
- console.log(form.value);
|
|
|
- if (form.value._id) {
|
|
|
-
|
|
|
- } else {
|
|
|
- uni.getUserProfile({
|
|
|
- desc: '用于展示',
|
|
|
- success: async function (res) {
|
|
|
- let parmas = {
|
|
|
- openid: openid.value,
|
|
|
- nickname: res.userInfo.nickName + moment().valueOf()
|
|
|
- }
|
|
|
- const arr = await $api(`user`, 'POST', { ...form.value, ...parmas });
|
|
|
- if (arr.errcode == '0') {
|
|
|
- uni.setStorageSync('user', arr.data);
|
|
|
- uni.navigateBack({
|
|
|
- delta: 1
|
|
|
- })
|
|
|
- } else {
|
|
|
- uni.showToast({
|
|
|
- title: arr.errmsg,
|
|
|
- icon: 'error'
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- fail: function (err) {
|
|
|
- console.log(err);
|
|
|
+ uni.getUserProfile({
|
|
|
+ desc: '用于展示',
|
|
|
+ success: async function (res) {
|
|
|
+ let parmas = {
|
|
|
+ openid: openid.value,
|
|
|
+ nickname: res.userInfo.nickName + moment().valueOf()
|
|
|
}
|
|
|
- })
|
|
|
- }
|
|
|
+ const arr = await $api(`user`, 'POST', { ...form.value, ...parmas });
|
|
|
+ if (arr.errcode == '0') {
|
|
|
+ uni.setStorageSync('user', arr.data);
|
|
|
+ uni.navigateBack({
|
|
|
+ delta: 1
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: arr.errmsg,
|
|
|
+ icon: 'error'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: function (err) {
|
|
|
+ console.log(err);
|
|
|
+ }
|
|
|
+ })
|
|
|
}).catch(err => {
|
|
|
console.log(err, '校验失败');
|
|
|
})
|