|
@@ -43,7 +43,7 @@
|
|
</div>
|
|
</div>
|
|
<div class="relative -top-6 rounded rounded-t-2xl bg-white z-10">
|
|
<div class="relative -top-6 rounded rounded-t-2xl bg-white z-10">
|
|
<div class="p-4 pb-20">
|
|
<div class="p-4 pb-20">
|
|
- <div class="" v-html="goodsDetail.memberCard?.content"></div>
|
|
|
|
|
|
+ <div class="" v-html="goodsDetail.saleSlogan"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
@@ -98,18 +98,30 @@ const handleClose = () => {
|
|
showDialog.value = false;
|
|
showDialog.value = false;
|
|
};
|
|
};
|
|
function onBridgeReady(paySign) {
|
|
function onBridgeReady(paySign) {
|
|
|
|
+ if (!WeixinJSBridge) {
|
|
|
|
+ return showToast("请在微信浏览器中打开");
|
|
|
|
+ }
|
|
WeixinJSBridge.invoke(
|
|
WeixinJSBridge.invoke(
|
|
"getBrandWCPayRequest",
|
|
"getBrandWCPayRequest",
|
|
{
|
|
{
|
|
appId: appId.value, //公众号ID,由商户传入
|
|
appId: appId.value, //公众号ID,由商户传入
|
|
- ...paySign
|
|
|
|
|
|
+ ...paySign,
|
|
},
|
|
},
|
|
function (res) {
|
|
function (res) {
|
|
- console.log(res)
|
|
|
|
|
|
+ console.log(res);
|
|
if (res.err_msg == "get_brand_wcpay_request:ok") {
|
|
if (res.err_msg == "get_brand_wcpay_request:ok") {
|
|
// 使用以上方式判断前端返回,微信团队郑重提示:
|
|
// 使用以上方式判断前端返回,微信团队郑重提示:
|
|
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠,商户需进一步调用后端查单确认支付结果。
|
|
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠,商户需进一步调用后端查单确认支付结果。
|
|
console.log("支付成功");
|
|
console.log("支付成功");
|
|
|
|
+ router.push({
|
|
|
|
+ name: 'promotionPayResult',
|
|
|
|
+ query: {
|
|
|
|
+ promotionGoodsId: route.query.promotionGoodsId,
|
|
|
|
+ promotionSiteId: route.query.promotionSiteId,
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ showToast("支付失败" + res.err_msg);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
);
|
|
);
|
|
@@ -117,15 +129,18 @@ function onBridgeReady(paySign) {
|
|
const handleConfirm = async (mobile, captcha) => {
|
|
const handleConfirm = async (mobile, captcha) => {
|
|
console.log("Payment confirmed");
|
|
console.log("Payment confirmed");
|
|
showDialog.value = false;
|
|
showDialog.value = false;
|
|
- const { data } = await request.post(`/archivesService/member/promotionGoods/paymentParams`, {
|
|
|
|
- promotionGoodsId: route.query.promotionGoodsId,
|
|
|
|
- promotionSiteId: route.query.promotionSiteId,
|
|
|
|
- mobile,
|
|
|
|
- captcha,
|
|
|
|
- openId: openId.value,
|
|
|
|
- });
|
|
|
|
|
|
+ const { data } = await request.post(
|
|
|
|
+ `/archivesService/member/promotionGoods/paymentParams`,
|
|
|
|
+ {
|
|
|
|
+ promotionGoodsId: route.query.promotionGoodsId,
|
|
|
|
+ promotionSiteId: route.query.promotionSiteId,
|
|
|
|
+ mobile,
|
|
|
|
+ captcha,
|
|
|
|
+ openId: openId.value,
|
|
|
|
+ }
|
|
|
|
+ );
|
|
console.log(data.paymentParams);
|
|
console.log(data.paymentParams);
|
|
- data.paymentParams?.paySign && onBridgeReady(data.paymentParams.paySign)
|
|
|
|
|
|
+ data.paymentParams?.paySign && onBridgeReady(data.paymentParams.paySign);
|
|
};
|
|
};
|
|
const buy = () => {
|
|
const buy = () => {
|
|
showDialog.value = true;
|
|
showDialog.value = true;
|
|
@@ -142,44 +157,52 @@ 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 appId = ref(localStorage.getItem("appId"));
|
|
|
|
-const openId = ref("");
|
|
|
|
|
|
+// 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 appId = ref(sessionStorage.getItem("appId"));
|
|
|
|
+const openId = ref("ozZpI7OTqj9cNlHfzAxcJ9MH41V8");
|
|
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);
|
|
|
|
+ route.push({
|
|
|
|
+ name: "error",
|
|
|
|
+ query: {
|
|
|
|
+ msg: errMsg,
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
if (appId) {
|
|
if (appId) {
|
|
//缓存信息
|
|
//缓存信息
|
|
- localStorage.setItem("appId", appId);
|
|
|
|
- localStorage.setItem("paymentSettingId", paymentSettingId);
|
|
|
|
|
|
+ sessionStorage.setItem("appId", appId);
|
|
|
|
+ sessionStorage.setItem("paymentSettingId", paymentSettingId);
|
|
//跳转微信授权
|
|
//跳转微信授权
|
|
|
|
|
|
const redirectUri = encodeURIComponent(location.href);
|
|
const redirectUri = encodeURIComponent(location.href);
|
|
location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_base&state=123#wechat_redirect`;
|
|
location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appId}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_base&state=123#wechat_redirect`;
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ showToast("微信配置不存在");
|
|
};
|
|
};
|
|
const getOpenId = async () => {
|
|
const getOpenId = async () => {
|
|
const { code } = route.query;
|
|
const { code } = route.query;
|
|
- const paymentSettingId = localStorage.getItem("paymentSettingId");
|
|
|
|
|
|
+ const paymentSettingId = sessionStorage.getItem("paymentSettingId");
|
|
if (!code) {
|
|
if (!code) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -192,16 +215,28 @@ const getOpenId = async () => {
|
|
},
|
|
},
|
|
}
|
|
}
|
|
);
|
|
);
|
|
- openId.value = data.openId;
|
|
|
|
|
|
+ if (data.openId) {
|
|
|
|
+ openId.value = data.openId;
|
|
|
|
+ } else {
|
|
|
|
+ showToast("获取openId失败");
|
|
|
|
+ }
|
|
};
|
|
};
|
|
const init = async () => {
|
|
const init = async () => {
|
|
- const { code } = route.query;
|
|
|
|
- const paymentSettingId = localStorage.getItem("paymentSettingId");
|
|
|
|
|
|
+ const { code, promotionGoodsId, promotionSiteId } = route.query;
|
|
|
|
+ if (!promotionSiteId || !promotionGoodsId) {
|
|
|
|
+ return router.push({
|
|
|
|
+ name: "error",
|
|
|
|
+ query: {
|
|
|
|
+ msg: "参数异常",
|
|
|
|
+ },
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ const paymentSettingId = sessionStorage.getItem("paymentSettingId");
|
|
if (!code || !paymentSettingId) {
|
|
if (!code || !paymentSettingId) {
|
|
- return getWeChatAuth();
|
|
|
|
|
|
+ // return getWeChatAuth();
|
|
}
|
|
}
|
|
- getOpenId()
|
|
|
|
- wxConfig();
|
|
|
|
|
|
+ // getOpenId()
|
|
|
|
+ // wxConfig();
|
|
};
|
|
};
|
|
onMounted(() => init());
|
|
onMounted(() => init());
|
|
</script>
|
|
</script>
|