|
@@ -14,13 +14,12 @@
|
|
|
import { defineComponent, ref } from "vue";
|
|
|
import wx from "weixin-js-sdk-ts";
|
|
|
import { openApi } from "@/api/index";
|
|
|
-import wxSign from '@/utils/wxSign';
|
|
|
+import wxSign from "@/utils/wxSign";
|
|
|
export default defineComponent({
|
|
|
setup() {
|
|
|
openApi
|
|
|
.jspapi({
|
|
|
- url: encodeURIComponent(window.location.href.split('#')[0]),
|
|
|
-
|
|
|
+ url: encodeURIComponent(window.location.href.split("#")[0]),
|
|
|
})
|
|
|
.then((res) => {
|
|
|
// let wxConfig = {
|
|
@@ -32,26 +31,36 @@ export default defineComponent({
|
|
|
// jsApiList: ["previewImage"], // 必填,需要使用的JS接口列表
|
|
|
// openTagList: ["wx-open-launch-weapp"], // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
|
|
|
// };
|
|
|
- let timestamp = wxSign.createTimeStamp()
|
|
|
- let nonceStr = wxSign.createNonceStr()
|
|
|
+ let timestamp = wxSign.createTimeStamp();
|
|
|
+ let nonceStr = wxSign.createNonceStr();
|
|
|
wx.config({
|
|
|
- debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
|
|
|
- appId:res.data.data.appId as string, // 必填,公众号的唯一标识
|
|
|
+ debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
|
|
|
+ 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接口列表
|
|
|
+ signature: wxSign.calcSignature(res.data.data.ticket, nonceStr, timestamp, window.location.href), // 必填,签名
|
|
|
+ jsApiList: ["previewImage", "openLocation"], // 必填,需要使用的JS接口列表
|
|
|
openTagList: ["wx-open-launch-weapp"], // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
|
|
|
});
|
|
|
|
|
|
wx.error(({ errMsg }) => {
|
|
|
weappHtml.value = errMsg;
|
|
|
wx.ready(() => {
|
|
|
- wx.scanQRCode({
|
|
|
- needResult: 1,
|
|
|
- scanType: ["qrCode", "barCode"],
|
|
|
- success(res) {},
|
|
|
- });
|
|
|
+ // wx.scanQRCode({
|
|
|
+ // needResult: 1,
|
|
|
+ // scanType: ["qrCode", "barCode"],
|
|
|
+ // success(res) {},
|
|
|
+ // });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ wx.ready(() => {
|
|
|
+ wx.openLocation({
|
|
|
+ latitude: 118.0, // 纬度,浮点数,范围为90 ~ -90
|
|
|
+ longitude: 32.0, // 经度,浮点数,范围为180 ~ -180。
|
|
|
+ name: "", // 位置名
|
|
|
+ address: "", // 地址详情说明
|
|
|
+ scale: 20, // 地图缩放级别,整型值,范围从1~28。默认为最大
|
|
|
+ infoUrl: "", // 在查看位置界面底部显示的超链接,可点击跳转
|
|
|
});
|
|
|
});
|
|
|
});
|