备份
This commit is contained in:
@@ -45,6 +45,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import customHttp from "@/common/customHttp.js"
|
||||
import { Base64 } from 'js-base64';
|
||||
|
||||
export default {
|
||||
data() {
|
||||
@@ -146,91 +148,51 @@
|
||||
return Math.floor(Math.random() * (max - min + 1)) + min
|
||||
},
|
||||
sublogin(e) {
|
||||
var rules = {
|
||||
phone: {
|
||||
rules: [{
|
||||
checkType: "required",
|
||||
errorMsg: "请填写手机号码"
|
||||
}, {
|
||||
checkType: "phone",
|
||||
errorMsg: "请填写正确的手机号码"
|
||||
}]
|
||||
},
|
||||
password: {
|
||||
rules: [{
|
||||
checkType: "required",
|
||||
errorMsg: "请输入密码"
|
||||
}, {
|
||||
checkType: "string",
|
||||
checkRule: "4,6",
|
||||
errorMsg: "至少输入4-6位"
|
||||
}]
|
||||
},
|
||||
code: {
|
||||
rules: [{
|
||||
checkType: "required",
|
||||
errorMsg: "请输入验证码"
|
||||
}]
|
||||
}
|
||||
};
|
||||
// var formData = e.detail.value;
|
||||
var formData = JSON.parse(JSON.stringify(this.form));
|
||||
var checkRes = this.$zmmFormCheck.check(formData, rules);
|
||||
// #ifdef APP-PLUS
|
||||
var cid = plus.push.getClientInfo().clientid
|
||||
formData['cid'] = cid
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
// todo
|
||||
var cid = ''
|
||||
formData['cid'] = cid
|
||||
// #endif
|
||||
uni.setStorageSync('cid', cid);
|
||||
console.log(cid)
|
||||
if (checkRes) {
|
||||
if (!this.agree) {
|
||||
uni.showToast({
|
||||
title: '请先同意《隐私及服务协议》',
|
||||
icon: 'none'
|
||||
});
|
||||
return;
|
||||
}
|
||||
uni.showLoading()
|
||||
formData.loginType = 1
|
||||
|
||||
this.$http.request({ //手机+验证码
|
||||
url: '/v1/login',
|
||||
method: 'POST',
|
||||
data: JSON.stringify(formData),
|
||||
success: (res) => {
|
||||
if (res.data.code == 200) {
|
||||
this.loginDone(res.data.data)
|
||||
}
|
||||
|
||||
customHttp.customHttp.post('/api/im/app/login', {
|
||||
"username": this.form.userName,
|
||||
"password":Base64.encode(this.form.password)
|
||||
}, {
|
||||
params: {},
|
||||
/* 会加在url上 */
|
||||
header: {},
|
||||
/* 会与全局header合并,如有同名属性,局部覆盖全局 */
|
||||
dataType: 'json',
|
||||
// 注:如果局部custom与全局custom有同名属性,则后面的属性会覆盖前面的属性,相当于Object.assign(全局,局部)
|
||||
custom: {
|
||||
target: "znzq"
|
||||
}, // 可以加一些自定义参数,在拦截器等地方使用。比如这里我加了一个auth,可在拦截器里拿到,如果true就传token
|
||||
}).then(res => {
|
||||
console.log("=========获取到数据")
|
||||
console.log(res)
|
||||
if (res.statusCode == 200) {
|
||||
if (res.data.code == 200) {
|
||||
this.loginDone(res.data.result)
|
||||
}
|
||||
});
|
||||
}
|
||||
}).catch(err => {
|
||||
|
||||
})
|
||||
|
||||
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: this.$zmmFormCheck.error,
|
||||
icon: "none",
|
||||
position: 'bottom'
|
||||
});
|
||||
}
|
||||
},
|
||||
loginDone(data) {
|
||||
uni.setStorageSync('appId', data.appId);
|
||||
uni.setStorageSync('im_userId', data.userId);
|
||||
uni.setStorageSync('userId', data.userId);
|
||||
uni.setStorageSync('im_userId', data.id);
|
||||
uni.setStorageSync('userId', data.id);
|
||||
uni.setStorageSync('im_userCSign', data.userSign);
|
||||
uni.setStorageSync('im_imUserSign', data.imUserSign);
|
||||
uni.setStorageSync('imUserSign', data.imUserSign);
|
||||
|
||||
uni.setStorageSync('token', data.token);
|
||||
uni.setStorageSync('hd_token', data.token);
|
||||
|
||||
uni.reLaunch({
|
||||
url: '../tabbar1/index'
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -333,4 +295,4 @@
|
||||
width: 300rpx;
|
||||
margin-top: 120rpx;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
Reference in New Issue
Block a user