小程序登录接口对接,接口响应拦截调整

This commit is contained in:
Double-_-Z 2025-07-22 00:36:54 +08:00
parent be3dfbf46e
commit bb450be04f
6 changed files with 57 additions and 73 deletions

View File

@ -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;
} }
}, },

View File

@ -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/';// 测试环境

View File

@ -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 {

View File

@ -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('网络请求错误!');
} }
} }

View File

@ -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
View 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) // 对需要加密的数据进行加密
}