|
|
|
@ -75,6 +75,7 @@ import * as w6s from 'szient-js-sdk'; |
|
|
|
import sha1 from 'crypto-js/sha1'; |
|
|
|
import { getEnterpriseMerchantAuthorization, getSiqLoginAuth, getSiqLoginAuthMock, siqCode, getCarouselBannerList, getSystemNoticeList } from '../../../api/enterprise'; |
|
|
|
import 'vant/es/toast/style'; |
|
|
|
import Vconsolefrom from 'vconsole'; |
|
|
|
|
|
|
|
const { useCommon } = $globalStore; |
|
|
|
const router = useRouter(); |
|
|
|
@ -202,6 +203,8 @@ const hasUserInfo = () => { |
|
|
|
}; |
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
console.log("企业端 Home onMounted"); |
|
|
|
new Vconsolefrom(); |
|
|
|
//debugger; |
|
|
|
console.log(useCommon.firstLoad); |
|
|
|
console.log(useCommon); |
|
|
|
@ -229,6 +232,8 @@ onMounted(() => { |
|
|
|
access_secret = success.data.accessSecret; |
|
|
|
} |
|
|
|
|
|
|
|
console.log("获取深i企认证信息成功", { access_key, access_secret }); |
|
|
|
|
|
|
|
const nonce = generateRandomNumber(); |
|
|
|
const timestamp = `${Date.now()}`; |
|
|
|
|
|
|
|
@ -243,73 +248,23 @@ onMounted(() => { |
|
|
|
console.log("获取深i企认证信息错误!", "access_key 或 access_secret 为空"); |
|
|
|
} |
|
|
|
|
|
|
|
// ========== 模拟深i企登录:使用 w6s.init mock 模式 ========== |
|
|
|
const route = router.currentRoute.value; |
|
|
|
const mockLogin = route.query.mockLogin; |
|
|
|
const mockLoginFrom = route.query.mockLoginFrom; |
|
|
|
if (mockLogin === 'true' && mockLoginFrom === 'siq') { |
|
|
|
const userInfoStr = decodeURIComponent(route.query.userInfo || ''); |
|
|
|
const userInfo = JSON.parse(userInfoStr); |
|
|
|
console.log("模拟深i企登录, 用户信息:", userInfo); |
|
|
|
|
|
|
|
// 使用 w6s SDK 内置的 mock 机制,设置 mockData 模拟 config 鉴权和 getAuthCode 认证 |
|
|
|
w6s.init({ |
|
|
|
mock: true, |
|
|
|
debug: true, |
|
|
|
mockData: { |
|
|
|
config: { |
|
|
|
config: () => ({ success: true }) |
|
|
|
}, |
|
|
|
szient: { |
|
|
|
getAuthCode: () => ({ |
|
|
|
result: { result: { code: 'MOCK_SIQ_' + userInfo.userId } } |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
// mock 模式下 w6s API 仅通过 Promise 返回(不触发 success 回调),使用 then 链处理 |
|
|
|
w6s.config({}) |
|
|
|
.then((res) => { |
|
|
|
console.log("模拟鉴权成功", res); |
|
|
|
return w6s.szient.getAuthCode({}); |
|
|
|
}) |
|
|
|
.then((res) => { |
|
|
|
console.log("模拟认证成功, code:", res.result.result.code); |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
getSiqLoginAuthMock({ userId: userInfo.userId }, resolve, reject); |
|
|
|
}); |
|
|
|
}) |
|
|
|
.then((success) => { |
|
|
|
useCommon.SET_USER_PHONENUMBER(success.data.phonenumber.toString()); |
|
|
|
useCommon.SET_USER_ID(success.data.userId); |
|
|
|
useCommon.SET_USER_ENTERPRISE_NUMBER(success.data.enterpriseNumber); |
|
|
|
useCommon.SET_TOKEN(success.data.token); |
|
|
|
console.log("模拟深i企登录成功", success.data); |
|
|
|
isLoading.value = false; |
|
|
|
useCommon.SET_IS_FIRST_LOAD(false); |
|
|
|
getEnterpriseMerchant(success.data.enterpriseNumber.toString(), success.data.phonenumber.toString()); |
|
|
|
}) |
|
|
|
.catch((err) => { |
|
|
|
console.error("模拟深i企登录失败:", err); |
|
|
|
isLoading.value = false; |
|
|
|
}); |
|
|
|
return; |
|
|
|
} |
|
|
|
console.log("生成鉴权参数", { nonce, timestamp, signature }); |
|
|
|
|
|
|
|
// ========== 深i企登录:生产环境模式 ========== |
|
|
|
console.log("开始w6s鉴权,参数:", { access_key, nonce, timestamp, signature }); |
|
|
|
w6s.config({ |
|
|
|
access_key: access_key, |
|
|
|
nonce: nonce, |
|
|
|
timestamp: timestamp, |
|
|
|
signature: signature, |
|
|
|
}).then((res) => { |
|
|
|
console.log("鉴权", res); |
|
|
|
console.log("鉴权成功", res); |
|
|
|
}).catch((err) => { |
|
|
|
console.log("鉴权", err); |
|
|
|
console.log("鉴权失败", err); |
|
|
|
}); |
|
|
|
|
|
|
|
w6s.ready(() => { |
|
|
|
console.log("w6s ready"); |
|
|
|
w6s.header.setTitle('深圳市行政执法监督码'); |
|
|
|
w6s.szient.getAuthCode({ |
|
|
|
success: function (res) { |
|
|
|
@ -334,12 +289,12 @@ onMounted(() => { |
|
|
|
isLoading.value = false; |
|
|
|
} |
|
|
|
}, error => { |
|
|
|
console.log("error : " + error) |
|
|
|
console.log("认证失败", error) |
|
|
|
}) |
|
|
|
}, |
|
|
|
fail: function (err) { |
|
|
|
console.log(err) |
|
|
|
console.log("认证", err); |
|
|
|
console.log("认证失败", err); |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
|