fix: 微信登录接口修改。

This commit is contained in:
tianyongbao
2026-01-18 20:24:59 +08:00
parent b1bc6c174c
commit 927ff2ab36
5 changed files with 41 additions and 26 deletions

View File

@@ -17,6 +17,12 @@ export const API_VERSION = {
// 当前使用的API版本修改此处可快速切换版本
export const CURRENT_VERSION = API_VERSION.V2
// 认证配置
export const AUTH_CONFIG = {
CLIENT_ID: '428a8310cd442757ae699df5d894f051',
TENANT_ID: '111111',
}
/**
* 接口路径配置
* 结构:{ v1: 'C#接口路径', v2: 'Java接口路径' }
@@ -36,12 +42,11 @@ const API_PATHS = {
// 微信手机号登录
LOGIN_WECHAT: {
v1: '/api/login/use_wechat',
v2: '/fishery/login/wechat',
v2: '/auth/wechat_login',
},
// 登出
LOGOUT: {
v1: '/api/user-center/logout',
v2: '/fishery/auth/logout',
v2: '/auth/logout',
},
},
@@ -347,17 +352,14 @@ const API_PATHS = {
PAY: {
// 支付选项页面
OPTIONS: {
v1: '/api/tenpay/get_pay_item',
v2: '/fishery/pay/options',
v2: '/weixin/pay/get_pay_item',
},
// 创建支付订单
CREATE_ORDER: {
v1: '/api/tenpay/create_order',
v2: '/fishery/pay/order',
v2: '/weixin/pay/create_order',
},
// 微信支付
WECHAT_PAY: {
v1: 'https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi',
v2: 'https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi', // 微信官方接口不变
},
},

View File

@@ -1,5 +1,5 @@
import httpService from '@/utils/request'
import API from './config'
import API, { AUTH_CONFIG } from './config'
// 短信登录
export function loginSms(phonenumber, code) {
@@ -7,8 +7,8 @@ export function loginSms(phonenumber, code) {
phonenumber:phonenumber,
smsCode:code,
grantType:"sms",
clientId:"428a8310cd442757ae699df5d894f051",
tenantId:"111111",
clientId: AUTH_CONFIG.CLIENT_ID,
tenantId: AUTH_CONFIG.TENANT_ID,
}
return httpService.post(API.AUTH.LOGIN_SMS(), {data})
}
@@ -20,7 +20,12 @@ export function smsCode(phonenumber) {
// 微信手机号登录
export function loginWxToPhone(data) {
return httpService.post(API.AUTH.LOGIN_WECHAT(), {data})
const params = {
...data,
clientId: AUTH_CONFIG.CLIENT_ID,
tenantId: AUTH_CONFIG.TENANT_ID,
}
return httpService.post(API.AUTH.LOGIN_WECHAT(), {data: params})
}
// 登出

View File

@@ -204,10 +204,8 @@ function save() {
isLoading.value = true
updateWarnPhone(params).then((res: any) => {
if (res.code == 200) {
state.type = "success";
state.show = true;
state.msg = "保存成功";
getWarnPhoneList();
}
}).finally(()=>{
isLoading.value = false

View File

@@ -162,22 +162,31 @@ function wxLogin(e) {
loginWxToPhone(params)
.then((res) => {
console.log('登录接口返回:', res);
if (res.statusCode == 200) {
if (res.code == 200) {
// 存储 token
if (res.data.access_token) {
Taro.setStorageSync("Access-Token", res.data.access_token);
Taro.setStorageSync("X-Access-Token", res.data.access_token);
}
Taro.setStorageSync(
"ReTime",
res.data.createdTime
? formatDate(new Date(res.data.createdTime))
: formatDate(new Date())
);
Taro.setStorageSync("UserName", res.data.nickName || loginForm.phonenumber);
Taro.setStorageSync("Phone", loginForm.phonenumber);
Taro.setStorageSync("LoginType", "1");
Taro.setStorageSync("UserId", res.data.userId || "");
Taro.setStorageSync("UnLogin", 2);
Taro.setStorageSync("UserName", res.data.userName);
Taro.setStorageSync("Phone", res.data.mobilePhone);
Taro.setStorageSync("UserId", res.data.id);
store.updateRootUserId(res.data.id);
store.updateUserId(res.data.id);
store.updateUnLogin(2);
store.updateRootUserName(res.data.userName);
store.updateLoginStatus(0);
store.updateUnLogin(2);
store.updateRootUserId(res.data.userId || "");
store.updateUserId(res.data.userId || "");
store.updateRootUserName(res.data.nickName || loginForm.phonenumber);
state.msg = "登录成功";
state.msg = "登录成功";
state.show = true;
Taro.switchTab({

View File

@@ -11,8 +11,9 @@ const getBaseUrl = () => {
// BASE_URL = 'https://www.qdintc.com/fishery-api' // 线上调试后端
BASE_URL = 'http://127.0.0.1:8080' // 本地调试后端地址
} else {
BASE_URL = 'https://api.yuceyun.cn' //填写你的请求域名
// BASE_URL = 'https://dev.yuceyun.cn' //测试环境
// BASE_URL = 'https://api.yuceyun.cn' //填写你的请求域名
// BASE_URL = 'https://www.qdintc.com/fishery-api' // 测试环境
BASE_URL = 'http://127.0.0.1:8080' // 本地调试后端地址
// BASE_URL = 'http://47.102.210.182:6678' //测试环境
}
return BASE_URL