zhangyujun 3 роки тому
батько
коміт
c002ac6cce
4 змінених файлів з 37 додано та 11 видалено
  1. 2 1
      src/api/index.ts
  2. 16 0
      src/api/modules/openApi.ts
  3. 1 0
      src/views/classify/index.vue
  4. 18 10
      src/views/mini/index.vue

+ 2 - 1
src/api/index.ts

@@ -6,4 +6,5 @@ export * from "./modules/testScores";
 export * from "./modules/collectionAndWrong";
 export * from "./modules/branch";
 export * from "./modules/cashOut";
-export * from "./modules/lighting";
+export * from "./modules/lighting";
+export * from "./modules/openApi";

+ 16 - 0
src/api/modules/openApi.ts

@@ -0,0 +1,16 @@
+import request from "../request";
+import { AxiosPromise } from "axios";
+
+class Wx {
+	jspapi(params:{
+		url:string
+	}): AxiosPromise<any> {
+		return request({
+			url: "/open-api/wx/gzh/jspapi",
+			params,
+			method:'GET'
+
+		});
+	}
+}
+export const openApi  = new Wx()

+ 1 - 0
src/views/classify/index.vue

@@ -2,6 +2,7 @@
 	<m-nav-bar :title="query.title" />
 	<div class="cell-box">
 		<van-cell
+			
 			class="cell"
 			:title="item.placeIssueName || item.classIssueName || item.excellIssueName || item.sequeIssueName"
 			is-link

+ 18 - 10
src/views/mini/index.vue

@@ -11,18 +11,26 @@
 <script lang="ts">
 import { defineComponent, ref } from "vue";
 import wx from "weixin-js-sdk-ts";
+import { openApi } from "@/api/index";
 export default defineComponent({
 	setup() {
-		
-		wx.config({
-			debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
-			appId: "wx67ca1b8c9816ef28", // 必填,公众号的唯一标识
-			timestamp: 1649745213, // 必填,生成签名的时间戳
-			nonceStr: "cpIofYwgtzqzFAId0VgFqY9fEGd6WNhM", // 必填,生成签名的随机串
-			signature: "386bfe37a60c5e97ddd174024af4ffa2af9ae24f", // 必填,签名
-			jsApiList: ['previewImage'], // 必填,需要使用的JS接口列表
-			openTagList: ["wx-open-launch-weapp"], // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
-		});
+		openApi
+			.jspapi({
+				url: window.location.href,
+			})
+			.then((res) => {
+				console.log(res)
+				wx.config({
+					debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印
+					appId: res.data.data.appId, // 必填,公众号的唯一标识
+					timestamp: res.data.data.timestamp, // 必填,生成签名的时间戳
+					nonceStr: res.data.data.nonceStr, // 必填,生成签名的随机串
+					signature: res.data.data.signature, // 必填,签名
+					jsApiList: ["previewImage"], // 必填,需要使用的JS接口列表
+					openTagList: ["wx-open-launch-weapp"], // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
+				});
+			});
+
 		let isWxReady = ref(false);
 		let weappHtml = ref("");
 		return {