|
@@ -14,6 +14,7 @@
|
|
|
import { defineComponent, ref } from "vue";
|
|
|
import wx from "weixin-js-sdk-ts";
|
|
|
import { openApi } from "@/api/index";
|
|
|
+import wxSign from '@/utils/wxSign';
|
|
|
export default defineComponent({
|
|
|
setup() {
|
|
|
openApi
|
|
@@ -22,22 +23,23 @@ export default defineComponent({
|
|
|
|
|
|
})
|
|
|
.then((res) => {
|
|
|
- let wxConfig = {
|
|
|
- debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
|
|
|
- appId: res.data.data.appId as string, // 必填,公众号的唯一标识
|
|
|
- timestamp: res.data.data.timestamp as number, // 必填,生成签名的时间戳
|
|
|
- nonceStr: res.data.data.nonceStr as string, // 必填,生成签名的随机串
|
|
|
- signature: res.data.data.signature as string, // 必填,签名
|
|
|
- jsApiList: ["previewImage"], // 必填,需要使用的JS接口列表
|
|
|
- openTagList: ["wx-open-launch-weapp"], // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
|
|
|
- };
|
|
|
- console.log(wxConfig);
|
|
|
+ // let wxConfig = {
|
|
|
+ // debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
|
|
|
+ // appId: res.data.data.appId as string, // 必填,公众号的唯一标识
|
|
|
+ // timestamp: res.data.data.timestamp as number, // 必填,生成签名的时间戳
|
|
|
+ // nonceStr: res.data.data.nonceStr as string, // 必填,生成签名的随机串
|
|
|
+ // signature: res.data.data.signature as string, // 必填,签名
|
|
|
+ // jsApiList: ["previewImage"], // 必填,需要使用的JS接口列表
|
|
|
+ // openTagList: ["wx-open-launch-weapp"], // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
|
|
|
+ // };
|
|
|
+ let timestamp = wxSign.createTimeStamp()
|
|
|
+ let nonceStr = wxSign.createNonceStr()
|
|
|
wx.config({
|
|
|
debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
|
|
|
- appId:"wx67ca1b8c9816ef28", // 必填,公众号的唯一标识
|
|
|
- timestamp: 1650277776, // 必填,生成签名的时间戳
|
|
|
- nonceStr: "zlc5xtjhzo", // 必填,生成签名的随机串
|
|
|
- signature: "19f330ab086ad33382903f0e8b20568a5baaf3f9", // 必填,签名
|
|
|
+ appId:res.data.data.appId as string, // 必填,公众号的唯一标识
|
|
|
+ timestamp: timestamp, // 必填,生成签名的时间戳
|
|
|
+ nonceStr: nonceStr, // 必填,生成签名的随机串
|
|
|
+ signature: wxSign.calcSignature(res.data.data.ticket,nonceStr,timestamp,window.location.href), // 必填,签名
|
|
|
jsApiList: ["previewImage"], // 必填,需要使用的JS接口列表
|
|
|
openTagList: ["wx-open-launch-weapp"], // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
|
|
|
});
|