小程序登录接口对接,接口响应拦截调整
This commit is contained in:
parent
be3dfbf46e
commit
bb450be04f
@ -26,7 +26,7 @@
|
|||||||
:custom-style="{borderRadius: '8rpx',background: '#2563EB',
|
:custom-style="{borderRadius: '8rpx',background: '#2563EB',
|
||||||
color:'#FFFFFF',fontWeight: '500',fontSize:'32rpx',fontFamily:'Roboto',
|
color:'#FFFFFF',fontWeight: '500',fontSize:'32rpx',fontFamily:'Roboto',
|
||||||
padding:'40rpx 0',marginTop:'42rpx',opacity: isDisable ? 0.6 : 1}"
|
padding:'40rpx 0',marginTop:'42rpx',opacity: isDisable ? 0.6 : 1}"
|
||||||
>登 录</u-button>
|
@click="submit">登 录</u-button>
|
||||||
<view class="login-form-change" @click="currentLoginType=(currentLoginType+1)%2">
|
<view class="login-form-change" @click="currentLoginType=(currentLoginType+1)%2">
|
||||||
切换至{{ currentLoginType ? '用户' : '飞行员' }}登录
|
切换至{{ currentLoginType ? '用户' : '飞行员' }}登录
|
||||||
</view>
|
</view>
|
||||||
@ -42,6 +42,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import lwTopnav from '@/components/lw-topnav/lw-topnav.vue';
|
import lwTopnav from '@/components/lw-topnav/lw-topnav.vue';
|
||||||
import configService from '@/common/config.service.js';
|
import configService from '@/common/config.service.js';
|
||||||
|
import { encrypt } from '@/utils/rsaEncrypt'
|
||||||
export default {
|
export default {
|
||||||
// #ifdef MP
|
// #ifdef MP
|
||||||
options: {
|
options: {
|
||||||
@ -126,7 +127,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
// 提交
|
// 提交
|
||||||
submit(){
|
async submit(){
|
||||||
if(!this.isAgreed){
|
if(!this.isAgreed){
|
||||||
this.$refs.uToast.show({type: 'warning',title: "请阅读并勾选同意协议!"});
|
this.$refs.uToast.show({type: 'warning',title: "请阅读并勾选同意协议!"});
|
||||||
return;
|
return;
|
||||||
@ -134,51 +135,37 @@ export default {
|
|||||||
try{
|
try{
|
||||||
let that = this;
|
let that = this;
|
||||||
this.dotLoading = true;
|
this.dotLoading = true;
|
||||||
// this.$refs.loginForm.validate(async(valid) => {
|
const isA = that.currentLoginType===1;
|
||||||
// if (valid) {
|
let res = await that.$api[isA?'aLogin':'bLogin']
|
||||||
// // 判断注册或登录的表单值,进行调整匹配
|
({...that.loginForm,password:encrypt(that.loginForm.password)});
|
||||||
// if(!that.current) delete that.loginForm.confirmPassword;
|
if(!res){
|
||||||
// let res = await that.$api[that.current?'register':'login'](that.loginForm);
|
that.$refs.uToast.show({type: 'error',title: "账号或密码错误!"});
|
||||||
// if(res.success){
|
}else{
|
||||||
// if(!that.current){
|
// 存储登录记录
|
||||||
// // 存储登录记录
|
uni.setStorageSync('loginMemory',JSON.stringify({...that.loginForm,timer: new Date()}));
|
||||||
// uni.setStorageSync('loginMemory',JSON.stringify({
|
that.$u.vuex('vuex_token', res.token);
|
||||||
// username: that.loginForm.username,
|
// that.$u.vuex('vuex_token', 'fbc545a91cc94fe89296828a25a7e08e@9085553879028596738');
|
||||||
// password: that.loginForm.password,
|
await that.$u.vuex('user_message', JSON.stringify(res.user.user));
|
||||||
// timer: new Date()
|
if(that.nextUrl===''){
|
||||||
// }));
|
uni.navigateBack({complete() {
|
||||||
// that.$u.vuex('vuex_token', res.data.token);
|
setTimeout(()=>{
|
||||||
// // that.$u.vuex('vuex_token', 'fbc545a91cc94fe89296828a25a7e08e@9085553879028596738');
|
uni.showToast({icon: 'none', title: '登录成功!'});
|
||||||
// await that.$u.vuex('user_message', JSON.stringify(res.data.user));
|
},600)
|
||||||
// if(that.nextUrl===''){
|
}})
|
||||||
// uni.navigateBack({complete() {
|
}else{
|
||||||
// setTimeout(()=>{
|
uni.redirectTo({
|
||||||
// uni.showToast({icon: 'none', title: '登录成功!'});
|
url: that.nextUrl,
|
||||||
// },600)
|
complete() {
|
||||||
// }})
|
setTimeout(()=>{
|
||||||
// }else{
|
uni.showToast({icon: 'none', title: '登录成功!'});
|
||||||
// uni.redirectTo({
|
},600)
|
||||||
// url: that.nextUrl,
|
}
|
||||||
// complete() {
|
});
|
||||||
// setTimeout(()=>{
|
}
|
||||||
// uni.showToast({icon: 'none', title: '登录成功!'});
|
}
|
||||||
// },600)
|
}catch(e){
|
||||||
// }
|
that.$refs.uToast.show({type: 'error',title: "处理失败!"});
|
||||||
// });
|
}finally{
|
||||||
// }
|
|
||||||
// }else{
|
|
||||||
// that.$refs.uToast.show({type: 'success',title: "注册成功,请登录"});
|
|
||||||
// that.current = 0;
|
|
||||||
// }
|
|
||||||
// that.$refs.loginForm.resetFields();
|
|
||||||
// }else{
|
|
||||||
// that.$refs.uToast.show({type: 'error',
|
|
||||||
// title: that.current?`${res.data}!`:"手机号或密码错误!"});
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}catch(e){}
|
|
||||||
finally{
|
|
||||||
this.dotLoading = false;
|
this.dotLoading = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
// 接口环境
|
// 接口环境
|
||||||
|
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
let BASE_URL = '/aerocraftApi';
|
let BASE_URL = '/aerocraftAdminApi';
|
||||||
// #endif
|
// #endif
|
||||||
// #ifdef APP-PLUS ||MP
|
// #ifdef APP-PLUS ||MP
|
||||||
let BASE_URL = 'http://8.138.171.103/aerocraftApi';// 测试环境
|
let BASE_URL = 'http://8.138.171.103/aerocraftAdminApi';// 测试环境
|
||||||
// let BASE_URL = 'https://www.ylemai.cn/aerocraftApi';// 正式环境
|
// let BASE_URL = 'https://www.ylemai.cn/aerocraftAdminApi';// 正式环境
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
let IP = 'http://8.138.171.103/';// 测试环境
|
let IP = 'http://8.138.171.103/';// 测试环境
|
||||||
|
@ -3,32 +3,15 @@ import configService from '@/common/config.service.js';
|
|||||||
const install = (Vue, vm) => {
|
const install = (Vue, vm) => {
|
||||||
|
|
||||||
// 用户管理
|
// 用户管理
|
||||||
vm.$api.wxLogin = async (params = {}) => await vm.$u.get('/acUser/wxPhoneLogin', params);// 手机号一键登录
|
vm.$api.aLogin = async (params = {}) => await vm.$u.post('/auth/login/a', params);// 飞行员端登录
|
||||||
vm.$api.login = async (params = {}) => await vm.$u.get('/acUser/phoneLogin', params);// 手机号登录
|
vm.$api.bLogin = async (params = {}) => await vm.$u.post('/auth/login/b', params);// 用户端登录
|
||||||
vm.$api.logOut = async () => await vm.$u.get('/acUser/logout');// 用户登出
|
vm.$api.logOut = async () => await vm.$u.get('/auth/logout');// 用户登出
|
||||||
vm.$api.register = async (params = {}) => await vm.$u.get('/acUser/phoneRegister', params);// 手机号注册
|
|
||||||
vm.$api.getCurrency = async () => await vm.$u.get('/paVipCurrency');// 用户余额查询
|
|
||||||
vm.$api.getConsumption = async (params = {}) => await vm.$u.get('/paConsumption',params);// 用户消费记录查询
|
|
||||||
|
|
||||||
// 轮播图管理
|
// 轮播图管理
|
||||||
vm.$api.allBanners = async () => await vm.$u.get('/cpBanner/all');// 获取全部轮播图
|
vm.$api.allBanners = async () => await vm.$u.get('/cpBanner/all');// 获取全部轮播图
|
||||||
|
|
||||||
// 图片管理
|
|
||||||
vm.$api.getCpPhotoById = async (params = {}) => await vm.$u.get('/cpPhoto/all', params);// 根据标签id查询全部图片
|
|
||||||
vm.$api.singlePhotoById = async (id) => await vm.$u.get(`/cpPhoto/${id}`);// 根据图片id查询单个图片
|
|
||||||
|
|
||||||
// 文章管理(查询协议)
|
// 文章管理(查询协议)
|
||||||
vm.$api.getArticles = async (params = {}) => await vm.$u.get('/cpArticle', params);// 分页查询文章
|
vm.$api.getArticles = async (params = {}) => await vm.$u.get('/cpArticle', params);// 分页查询文章
|
||||||
|
|
||||||
// 留言板
|
|
||||||
vm.$api.addMessage = async (params = {}) => await vm.$u.post('/cpMessage', params);// 添加留言
|
|
||||||
|
|
||||||
// 附件管理
|
|
||||||
vm.$api.getOssSignal = async () => await vm.$u.get('/enAttachment/getOssSignal');// 获取OSS Url临时签名
|
|
||||||
|
|
||||||
// 标签管理
|
|
||||||
vm.$api.getLabels = async (moduleid) => await vm.$u.get(`/cpLabel/moduleid/${moduleid}`);// 查询模块下的标签
|
|
||||||
vm.$api.singleLabel = async (id) => await vm.$u.get(`/cpLabel/${id}`);// 查询单个标签
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -34,7 +34,7 @@ const install = (Vue, vm) => {
|
|||||||
// return false;
|
// return false;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
config.header.token = vm.$store.state.vuex_token;
|
config.header.Authorization = vm.$store.state.vuex_token;
|
||||||
// if (config.method == 'POST') {
|
// if (config.method == 'POST') {
|
||||||
// config.data['__token__'] = vm.vuex__token__;
|
// config.data['__token__'] = vm.vuex__token__;
|
||||||
// }
|
// }
|
||||||
@ -84,7 +84,7 @@ const install = (Vue, vm) => {
|
|||||||
return res.data;
|
return res.data;
|
||||||
} else {
|
} else {
|
||||||
console.error(res)
|
console.error(res)
|
||||||
vm.$u.toast('网络请求错误!');
|
// vm.$u.toast('网络请求错误!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
background: linear-gradient(180deg, #96fe11 0%, #f0fdbf 100%);
|
background: linear-gradient(180deg, #a8f0ee 0%, #f0fdbf 100%);
|
||||||
transform:scale(0);
|
transform:scale(0);
|
||||||
animation:animloader 1.5s infinite ease-in-out;
|
animation:animloader 1.5s infinite ease-in-out;
|
||||||
}
|
}
|
||||||
|
14
utils/rsaEncrypt.js
Normal file
14
utils/rsaEncrypt.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
|
||||||
|
|
||||||
|
// 密钥对生成 http://web.chacuo.net/netrsakeypair
|
||||||
|
|
||||||
|
const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBANL378k3RiZHWx5AfJqdH9xRNBmD9wGD\n' +
|
||||||
|
'2iRe41HdTNF8RUhNnHit5NpMNtGL0NPTSSpPjjI1kJfVorRvaQerUgkCAwEAAQ=='
|
||||||
|
|
||||||
|
// 加密
|
||||||
|
export function encrypt(txt) {
|
||||||
|
const encryptor = new JSEncrypt()
|
||||||
|
encryptor.setPublicKey(publicKey) // 设置公钥
|
||||||
|
return encryptor.encrypt(txt) // 对需要加密的数据进行加密
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user