联调接口
This commit is contained in:
@@ -2,7 +2,7 @@ export const TOKEN_KEY = 'token';
|
|||||||
export const AGREEWELCOME_KEY="agreewelcome";
|
export const AGREEWELCOME_KEY="agreewelcome";
|
||||||
|
|
||||||
// clientId 默认写2
|
// clientId 默认写2
|
||||||
export const CLIENT_ID=2;
|
export const CLIENT_ID="2";
|
||||||
// #区分内外网 //1-内网,2-外网
|
// #区分内外网 //1-内网,2-外网
|
||||||
export const NETWORK_ENV=1;
|
export const NETWORK_ENV=1;
|
||||||
|
|
||||||
|
|||||||
@@ -128,8 +128,6 @@ let selectBindStatus = async ()=>{
|
|||||||
if(deviceId.value){
|
if(deviceId.value){
|
||||||
let res = await getBindStatus({uniqCode:deviceId.value})
|
let res = await getBindStatus({uniqCode:deviceId.value})
|
||||||
bindStatus.value = res.bindStatus;
|
bindStatus.value = res.bindStatus;
|
||||||
console.log("111bindStatus=>",bindStatus.value)
|
|
||||||
|
|
||||||
//bindStatus=4-----已绑定成功,跳转用户登录页面
|
//bindStatus=4-----已绑定成功,跳转用户登录页面
|
||||||
if(bindStatus.value==4){
|
if(bindStatus.value==4){
|
||||||
if (userStore.isLogin) {
|
if (userStore.isLogin) {
|
||||||
@@ -149,7 +147,6 @@ let selectBindStatus = async ()=>{
|
|||||||
let refreshBindStatus = async ()=>{
|
let refreshBindStatus = async ()=>{
|
||||||
let res = await getBindStatus({uniqCode:deviceId.value})
|
let res = await getBindStatus({uniqCode:deviceId.value})
|
||||||
bindStatus.value = res.bindStatus;
|
bindStatus.value = res.bindStatus;
|
||||||
console.log("222bindStatus=>",bindStatus.value)
|
|
||||||
if(bindStatus.value==2){
|
if(bindStatus.value==2){
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
@@ -196,9 +193,8 @@ const submitForm = async() => {
|
|||||||
form2.value.validate().then(async param => {
|
form2.value.validate().then(async param => {
|
||||||
btnLoading.value = true;
|
btnLoading.value = true;
|
||||||
deviceId.value = uuidv4();
|
deviceId.value = uuidv4();
|
||||||
let cilentId = `${CLIENT_ID || 2}`;
|
let clientId = `${CLIENT_ID || 2}`;
|
||||||
let password = encryptObj.Encrypt(param.username + cilentId + "," + param.password);
|
let password = encryptObj.Encrypt(param.username + clientId + "," + param.password);
|
||||||
console.log("password=>",password)
|
|
||||||
|
|
||||||
let systemInfo = uni.getSystemInfoSync()
|
let systemInfo = uni.getSystemInfoSync()
|
||||||
let params = {
|
let params = {
|
||||||
@@ -215,9 +211,7 @@ const submitForm = async() => {
|
|||||||
// #endif
|
// #endif
|
||||||
osAndroidApiLevel:systemInfo.osAndroidAPILevel
|
osAndroidApiLevel:systemInfo.osAndroidAPILevel
|
||||||
}
|
}
|
||||||
console.log("params=>",params)
|
|
||||||
let res = await authDeviceApply(params);
|
let res = await authDeviceApply(params);
|
||||||
console.log("authDeviceApply=>",res)
|
|
||||||
btnLoading.value = false;
|
btnLoading.value = false;
|
||||||
uni.setStorageSync('app_device_id', deviceId.value)
|
uni.setStorageSync('app_device_id', deviceId.value)
|
||||||
bindStatus.value = res.bindStatus;//默认为 2-等待审核
|
bindStatus.value = res.bindStatus;//默认为 2-等待审核
|
||||||
@@ -243,7 +237,6 @@ let getLocalIPInUniApp=()=>{
|
|||||||
if (info.cellular && info.cellular.ipAddress) {
|
if (info.cellular && info.cellular.ipAddress) {
|
||||||
ips.push(info.cellular.ipAddress);
|
ips.push(info.cellular.ipAddress);
|
||||||
}
|
}
|
||||||
console.log(1111,ips)
|
|
||||||
resolve(ips.length ? ips : ['无法获取本地IP']);
|
resolve(ips.length ? ips : ['无法获取本地IP']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -346,7 +339,9 @@ const handleSubmit=()=>{
|
|||||||
authCode:authCode.value
|
authCode:authCode.value
|
||||||
}
|
}
|
||||||
subLoading.value=true;
|
subLoading.value=true;
|
||||||
|
console.log("param=>",param)
|
||||||
authInputCode(param).then(res=>{
|
authInputCode(param).then(res=>{
|
||||||
|
console.log("authInputCode=>",res)
|
||||||
uni.reLaunch({ url: '/pages/login/login' })
|
uni.reLaunch({ url: '/pages/login/login' })
|
||||||
}).finally(()=>{
|
}).finally(()=>{
|
||||||
subLoading.value = false;
|
subLoading.value = false;
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ onLoad(async(opt) => {
|
|||||||
|
|
||||||
// 检查版本是否是最新的
|
// 检查版本是否是最新的
|
||||||
let getOSVesion = async()=>{
|
let getOSVesion = async()=>{
|
||||||
let systemInfo = uni.getSystemInfoSync(); console.log(systemInfo.osName)
|
let systemInfo = uni.getSystemInfoSync();
|
||||||
let param = {
|
let param = {
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
verNumber:systemInfo.appWgtVersion,//当前版本号
|
verNumber:systemInfo.appWgtVersion,//当前版本号
|
||||||
@@ -88,9 +88,7 @@ let getOSVesion = async()=>{
|
|||||||
appVersion.value = param.verNumber;
|
appVersion.value = param.verNumber;
|
||||||
// console.log("appVersion=>",appVersion)
|
// console.log("appVersion=>",appVersion)
|
||||||
versionData.value = param;
|
versionData.value = param;
|
||||||
console.log("versionCheck=>param=>",param)
|
|
||||||
let data = await versionCheck(param);
|
let data = await versionCheck(param);
|
||||||
console.log("versionCheck=>",data)
|
|
||||||
newVersion.value = data.verNumber;
|
newVersion.value = data.verNumber;
|
||||||
downloadURL.value = data.downloadUrl;
|
downloadURL.value = data.downloadUrl;
|
||||||
|
|
||||||
@@ -123,25 +121,25 @@ const selectDeviceId = async()=>{
|
|||||||
},2000)
|
},2000)
|
||||||
}else{
|
}else{
|
||||||
let res = await getBindStatus({uniqCode:deviceId});
|
let res = await getBindStatus({uniqCode:deviceId});
|
||||||
console.log("getBindStatus=>",res)
|
|
||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
// 检查是否已登录 并 获取用户信息
|
|
||||||
// if (userStore.isLogin) {
|
|
||||||
// 绑定状态(1=已提交、2=等待审核、3=审核通过、4=绑定成功、5=审核拒绝)
|
// 绑定状态(1=已提交、2=等待审核、3=审核通过、4=绑定成功、5=审核拒绝)
|
||||||
if(res.bindStatus == 4){
|
if(res.bindStatus == 4){
|
||||||
|
// 检查是否已登录 并 获取用户信息
|
||||||
|
if (userStore.isLogin) {
|
||||||
uni.reLaunch({
|
uni.reLaunch({
|
||||||
url: '/pages/home/home',
|
url: '/pages/home/home',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}else{
|
||||||
|
uni.reLaunch({
|
||||||
|
url: '/pages/login/login',
|
||||||
|
});
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
uni.reLaunch({
|
uni.reLaunch({
|
||||||
url: '/pages/deviceAuth/deviceAuth',
|
url: '/pages/deviceAuth/deviceAuth',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// }else{
|
|
||||||
// uni.reLaunch({
|
|
||||||
// url: '/pages/login/login',
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
},2000)
|
},2000)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,6 @@ import { ref,onMounted } from 'vue';
|
|||||||
import { onLoad } from '@dcloudio/uni-app';
|
import { onLoad } from '@dcloudio/uni-app';
|
||||||
import customTabs from '@/components/customTabs.vue';
|
import customTabs from '@/components/customTabs.vue';
|
||||||
import {isPhoneNumber} from '@/utils/validate';
|
import {isPhoneNumber} from '@/utils/validate';
|
||||||
import {showAlert} from '@/utils/message';
|
|
||||||
import { getVerifyCode,login } from '@/api/auth';
|
import { getVerifyCode,login } from '@/api/auth';
|
||||||
import cache from '@/utils/cache';
|
import cache from '@/utils/cache';
|
||||||
import { AGREEWELCOME_KEY } from '@/enums/cacheEnums';
|
import { AGREEWELCOME_KEY } from '@/enums/cacheEnums';
|
||||||
@@ -103,8 +102,8 @@ const tabList = ['验证码登录', '账号登录'];
|
|||||||
// 验证码登录
|
// 验证码登录
|
||||||
const form = ref(null);
|
const form = ref(null);
|
||||||
const formData = ref({
|
const formData = ref({
|
||||||
phone: '15112345600',
|
phone: '',
|
||||||
verifyCode: '123456',
|
verifyCode: '',
|
||||||
loginType:0
|
loginType:0
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -188,8 +187,8 @@ let resetCountdown =()=>{
|
|||||||
// 账号登录
|
// 账号登录
|
||||||
const form2 = ref(null);
|
const form2 = ref(null);
|
||||||
const formData2 = ref({
|
const formData2 = ref({
|
||||||
username: '445',
|
username: '',
|
||||||
password: '123456',
|
password: '',
|
||||||
loginType:1
|
loginType:1
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -230,7 +229,7 @@ const submitForm = () => {
|
|||||||
if(activeTab.value===0){
|
if(activeTab.value===0){
|
||||||
form.value.validate().then(async param => {
|
form.value.validate().then(async param => {
|
||||||
// 2.调用登录接口
|
// 2.调用登录接口
|
||||||
param.loginType = activeTab.value; console.log('表单数据00:', param);
|
param.loginType = activeTab.value;
|
||||||
let res = await login(param)
|
let res = await login(param)
|
||||||
// 3.登录后存储token
|
// 3.登录后存储token
|
||||||
userStore.login(res);
|
userStore.login(res);
|
||||||
@@ -244,12 +243,11 @@ const submitForm = () => {
|
|||||||
// 用户名和密码登录
|
// 用户名和密码登录
|
||||||
form2.value.validate().then(async param => {
|
form2.value.validate().then(async param => {
|
||||||
param.loginType = activeTab.value;
|
param.loginType = activeTab.value;
|
||||||
let cilentId = `${CLIENT_ID || 2}`;
|
let clientId = `${CLIENT_ID || "2"}`;
|
||||||
let password = encryptObj.Encrypt(param.username + cilentId + "," + param.password);
|
let password = encryptObj.Encrypt(param.username + clientId + "," + param.password);
|
||||||
param.password = password;
|
param.password = password;
|
||||||
param.uniqCode = uni.getStorageSync('app_device_id');//先从缓存取之后处理
|
param.uniqCode = 'bf52f71a-a951-43c3-a63d-0927d7854955'// uni.getStorageSync('app_device_id');//先从缓存取之后处理
|
||||||
|
param.clientId = clientId;
|
||||||
console.log("login->param->",param)
|
|
||||||
let res = await login(param);
|
let res = await login(param);
|
||||||
userStore.login(res);
|
userStore.login(res);
|
||||||
uni.switchTab({ url: '/pages/home/home' })
|
uni.switchTab({ url: '/pages/home/home' })
|
||||||
|
|||||||
@@ -113,17 +113,7 @@ onLoad(async(opt) => {
|
|||||||
// 1.头部导航栏
|
// 1.头部导航栏
|
||||||
const navBarPaddingTop = ref(0);
|
const navBarPaddingTop = ref(0);
|
||||||
let appVersion = ref("1.0.0");//当前版本号
|
let appVersion = ref("1.0.0");//当前版本号
|
||||||
onMounted(() => {
|
|
||||||
navBarPaddingTop.value = getNavBarPaddingTop() * 2;
|
|
||||||
|
|
||||||
let systemInfo = uni.getSystemInfoSync();
|
|
||||||
// #ifdef APP-PLUS
|
|
||||||
appVersion.value=systemInfo.appWgtVersion; //当前版本号
|
|
||||||
// #endif
|
|
||||||
// #ifdef H5
|
|
||||||
appVersion.value=systemInfo.appVersion;
|
|
||||||
// #endif
|
|
||||||
})
|
|
||||||
|
|
||||||
// 下拉刷新
|
// 下拉刷新
|
||||||
const mescrollRef = ref(null);
|
const mescrollRef = ref(null);
|
||||||
@@ -158,7 +148,6 @@ const selectUserInfo = async ()=>{
|
|||||||
let data = await getUserInfo({});
|
let data = await getUserInfo({});
|
||||||
userObj.value = data;
|
userObj.value = data;
|
||||||
}
|
}
|
||||||
selectUserInfo()
|
|
||||||
|
|
||||||
// 3.退出登录
|
// 3.退出登录
|
||||||
const handleLoginOut = async ()=>{
|
const handleLoginOut = async ()=>{
|
||||||
@@ -168,14 +157,25 @@ const handleLoginOut = async ()=>{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 4.跳转到版本
|
// 4.跳转到版本
|
||||||
const handleVersion=()=>{
|
const handleVersion=()=>{
|
||||||
uni.navigateTo({url:'/pages/userinfo/version'})
|
uni.navigateTo({url:'/pages/userinfo/version'})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
navBarPaddingTop.value = getNavBarPaddingTop() * 2;
|
||||||
|
|
||||||
|
let systemInfo = uni.getSystemInfoSync();
|
||||||
|
// #ifdef APP-PLUS
|
||||||
|
appVersion.value=systemInfo.appWgtVersion; //当前版本号
|
||||||
|
// #endif
|
||||||
|
// #ifdef H5
|
||||||
|
appVersion.value=systemInfo.appVersion;
|
||||||
|
// #endif
|
||||||
|
|
||||||
|
selectUserInfo()
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -26,10 +26,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { onLoad } from '@dcloudio/uni-app';
|
||||||
import { ref, onMounted } from 'vue'
|
import { ref, onMounted } from 'vue'
|
||||||
import customHeader from '@/components/customHeader.vue'
|
import customHeader from '@/components/customHeader.vue'
|
||||||
import { versionCheck } from '@/api/auth.js';
|
import { versionCheck } from '@/api/auth.js';
|
||||||
import { getNavBarPaddingTop } from '@/utils/system.js'
|
import { getNavBarPaddingTop } from '@/utils/system.js'
|
||||||
|
import { formatIOS } from '@/utils/status.js'
|
||||||
|
|
||||||
|
// 初始load页面
|
||||||
|
onLoad(async(opt) => {
|
||||||
|
getOSVesion();
|
||||||
|
});
|
||||||
|
|
||||||
// 1.头部导航栏
|
// 1.头部导航栏
|
||||||
let navBarPaddingTop = ref(0);
|
let navBarPaddingTop = ref(0);
|
||||||
@@ -38,29 +45,24 @@ let newVersion = ref('1.0.0');//最新版本号
|
|||||||
let remark = ref('');//更新内容
|
let remark = ref('');//更新内容
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
navBarPaddingTop.value = getNavBarPaddingTop() * 2;
|
navBarPaddingTop.value = getNavBarPaddingTop() * 2;
|
||||||
getOSVesion();
|
|
||||||
})
|
})
|
||||||
let getOSVesion = async()=>{
|
let getOSVesion = async()=>{
|
||||||
let systemInfo = uni.getSystemInfoSync();
|
let systemInfo = uni.getSystemInfoSync();
|
||||||
let param = {
|
let param = {
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
appVersion:systemInfo.appWgtVersion,//当前版本号
|
verNumber:systemInfo.appWgtVersion,//当前版本号
|
||||||
// #endif
|
// #endif
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
appVersion : systemInfo.appVersion,
|
verNumber : systemInfo.appVersion,
|
||||||
// #endif
|
// #endif
|
||||||
deviceType:systemInfo.model,//型号
|
os: formatIOS(systemInfo.osName),//操作系统 Android IOS
|
||||||
os: systemInfo.osName,//操作系统 Android IOS
|
|
||||||
osVersion:systemInfo.osVersion,//操作系统版本
|
|
||||||
resolution:systemInfo.windowWidth+"*"+systemInfo.windowHeight,//分辨率
|
|
||||||
trademark:systemInfo.deviceBrand,//设备品牌
|
|
||||||
uniqueCode:systemInfo.deviceId//设备ID
|
|
||||||
}
|
}
|
||||||
// 当前手机版本
|
// 当前手机版本
|
||||||
appVersion.value = param.appVersion;
|
appVersion.value = param.appVersion;
|
||||||
// console.log("appVersion=>",appVersion)
|
console.log("appVersion=>",appVersion)
|
||||||
let data = await versionCheck(param);
|
let data = await versionCheck(param);
|
||||||
newVersion.value = data.latestVersion;
|
newVersion.value = data.verNumber;
|
||||||
|
downloadURL.value = data.downloadUrl;
|
||||||
remark.value = data.remark //|| '全新的UI界面 优化了签到/打卡功能,整体流程更加简洁清晰 搜索功能全面升级 修复了已知BUG'
|
remark.value = data.remark //|| '全新的UI界面 优化了签到/打卡功能,整体流程更加简洁清晰 搜索功能全面升级 修复了已知BUG'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,11 +71,11 @@ const handleDown = ()=>{
|
|||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
// 跳转到应用商店或下载最新版本的页面
|
// 跳转到应用商店或下载最新版本的页面
|
||||||
plus.runtime.openURL(downloadURL.value);
|
plus.runtime.openURL(downloadURL.value);
|
||||||
// if (versionData.value.os == 'ios'){
|
if (versionData.value.os == 'ios'){
|
||||||
// plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
|
plus.ios.import("UIApplication").sharedApplication().performSelector("exit")
|
||||||
// } else if (versionData.value.os == 'android'){
|
} else if (versionData.value.os == 'android'){
|
||||||
plus.runtime.quit();
|
plus.runtime.quit();
|
||||||
// }
|
}
|
||||||
// #endif
|
// #endif
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { getToken, setToken,clearToken } from '../utils/auth'
|
import { getToken, setToken,clearToken } from '../utils/auth'
|
||||||
import { getUserInfo } from '../api/auth'
|
import { getUserInfo,logout } from '../api/auth'
|
||||||
|
|
||||||
|
|
||||||
export const useUserStore = new defineStore({
|
export const useUserStore = new defineStore({
|
||||||
id: 'userStore',
|
id: 'userStore',
|
||||||
@@ -26,12 +25,15 @@ export const useUserStore = new defineStore({
|
|||||||
},
|
},
|
||||||
// 登录
|
// 登录
|
||||||
login(userinfo) {
|
login(userinfo) {
|
||||||
this.token = userinfo.token
|
let token = userinfo.access_token;
|
||||||
setToken(userinfo.token)
|
this.token = token
|
||||||
|
setToken(token)
|
||||||
|
userinfo.token = token;
|
||||||
this.userInfo = userinfo
|
this.userInfo = userinfo
|
||||||
},
|
},
|
||||||
// 退出
|
// 退出
|
||||||
logout() {
|
async logout() {
|
||||||
|
await logout();
|
||||||
this.token = ''
|
this.token = ''
|
||||||
this.userInfo = {}
|
this.userInfo = {}
|
||||||
clearToken();
|
clearToken();
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export const showAlert = (content, title = '提示',showCancel=false,succFun) =>
|
|||||||
success: function (res) {
|
success: function (res) {
|
||||||
if (res.confirm) {
|
if (res.confirm) {
|
||||||
// console.log('用户点击确定');
|
// console.log('用户点击确定');
|
||||||
succFun();
|
if(succFun)succFun();
|
||||||
} else if (res.cancel) {
|
} else if (res.cancel) {
|
||||||
// console.log('用户点击取消');
|
// console.log('用户点击取消');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ const message = useMessage();
|
|||||||
const requestHooks = {
|
const requestHooks = {
|
||||||
// 请求拦截器
|
// 请求拦截器
|
||||||
requestInterceptorsHook(options, config) {
|
requestInterceptorsHook(options, config) {
|
||||||
// console.log("request=>",options,config)
|
console.log("request=>",options);
|
||||||
|
// console.log("request=>config=>",config)
|
||||||
const { urlPrefix, baseUrl, withToken, isAuth } = config;
|
const { urlPrefix, baseUrl, withToken, isAuth } = config;
|
||||||
options.header = options.header ?? {};
|
options.header = options.header ?? {};
|
||||||
if (urlPrefix) {
|
if (urlPrefix) {
|
||||||
@@ -20,7 +21,7 @@ const requestHooks = {
|
|||||||
if (baseUrl) {
|
if (baseUrl) {
|
||||||
options.url = `${baseUrl}${options.url}`;
|
options.url = `${baseUrl}${options.url}`;
|
||||||
}
|
}
|
||||||
const token = getToken();
|
const token = getToken(); console.log("token=>",token)
|
||||||
if (withToken && !options.header.token) {
|
if (withToken && !options.header.token) {
|
||||||
options.header.token = token;
|
options.header.token = token;
|
||||||
}
|
}
|
||||||
@@ -28,7 +29,8 @@ const requestHooks = {
|
|||||||
},
|
},
|
||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
responseInterceptorsHook(response, config) {
|
responseInterceptorsHook(response, config) {
|
||||||
// console.log("response=>",response,config)
|
console.log("response=>",response)
|
||||||
|
// console.log("response=>config=>",config)
|
||||||
const { isTransformResponse, isReturnDefaultResponse, isAuth } = config;
|
const { isTransformResponse, isReturnDefaultResponse, isAuth } = config;
|
||||||
|
|
||||||
if (isReturnDefaultResponse) {
|
if (isReturnDefaultResponse) {
|
||||||
|
|||||||
Reference in New Issue
Block a user