|
@@ -117,9 +117,25 @@ const preCheck = async () => {
|
|
);
|
|
);
|
|
return data;
|
|
return data;
|
|
};
|
|
};
|
|
|
|
+const jsSdkConfig = async () => {
|
|
|
|
+ const { data } = await request.post(
|
|
|
|
+ "archivesService/member/promotionGoods/getJssdk",
|
|
|
|
+ {
|
|
|
|
+ url: location.href,
|
|
|
|
+ promotionGoodsId: route.query.promotionGoodsId,
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ return data;
|
|
|
|
+};
|
|
|
|
+const wxConfig = async () => {
|
|
|
|
+ const { data } = await jsSdkConfig();
|
|
|
|
+ window["wx"]?.config?.(data.config);
|
|
|
|
+ window["wx"]?.error((res) => {
|
|
|
|
+ console.log(res);
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
|
|
const getWeChatAuth = async () => {
|
|
const getWeChatAuth = async () => {
|
|
-
|
|
|
|
const { appId, errMsg, paymentSettingId } = await preCheck();
|
|
const { appId, errMsg, paymentSettingId } = await preCheck();
|
|
if (errMsg) {
|
|
if (errMsg) {
|
|
return showToast(errMsg);
|
|
return showToast(errMsg);
|
|
@@ -134,14 +150,33 @@ const getWeChatAuth = async () => {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+const getOpenId = async () => {
|
|
|
|
+ const { code } = route.query;
|
|
|
|
+ const paymentSettingId = localStorage.getItem("paymentSettingId");
|
|
|
|
+ if (!code) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ const { data } = await request.get(
|
|
|
|
+ `archivesService/member/promotionGoods/getOpenId`,
|
|
|
|
+ {
|
|
|
|
+ params: {
|
|
|
|
+ code,
|
|
|
|
+ paymentSettingId,
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+};
|
|
const init = async () => {
|
|
const init = async () => {
|
|
const { code } = route.query;
|
|
const { code } = route.query;
|
|
const paymentSettingId = localStorage.getItem("paymentSettingId");
|
|
const paymentSettingId = localStorage.getItem("paymentSettingId");
|
|
if (!code || !paymentSettingId) {
|
|
if (!code || !paymentSettingId) {
|
|
- getWeChatAuth()
|
|
|
|
|
|
+ return getWeChatAuth();
|
|
}
|
|
}
|
|
-}
|
|
|
|
-onMounted(() => init())
|
|
|
|
|
|
+ getOpenId()
|
|
|
|
+ wxConfig();
|
|
|
|
+};
|
|
|
|
+onMounted(() => init());
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped></style>
|
|
<style lang="scss" scoped></style>
|