Browse Source

添加小程序二维码

yangg 2 months ago
parent
commit
b1c6d42771
1 changed files with 6 additions and 15 deletions
  1. 6 15
      src/views/position/list/index.vue

+ 6 - 15
src/views/position/list/index.vue

@@ -55,22 +55,13 @@ async function generateQRCode(row: { id: string | number }) {
 		qrCodeVisible.value = true;
 		qrCodeUrl.value = ''; // 清空之前的二维码
 		
-		// 获取微信 access_token
-		const tokenResponse = await axios.get(`${import.meta.env.VITE_API_WX_URL}cgi-bin/token?grant_type=client_credential&appid=${'wxc9655eeaa3223b75'}&secret=${'c0f031b6e07ded1928fded435a913902'}`);
-		console.log(tokenResponse.data);
-		const accessToken = tokenResponse.data.access_token;
-		
-		if (!accessToken) {
-			throw new Error('获取微信 access_token 失败');
-		}
-		
-		// 调用后端API获取二维码
-		const response = await axios.post(`${import.meta.env.VITE_API_WX_URL}wxa/getwxacodeunlimit`, {
-			access_token: '91_vR3iqZvlk-YaoqEC3SBdDfITzvjeWzgkF9ybSIXMsR0Zvt7hSxnVgyVZXF0wXOOMqHxurxk_p5ggiZYVkDoueGuVGwJVU4NtZOb6q7Hxy035AhjOF0fN94-2DSUJQFeAFAFMB',
-			scene: `id=${row.id}`, // 传递角色ID或其他需要的参数
-			page: 'pages/position/detail', // 小程序中的页面路径
+		// 调用系统API获取二维码
+		const response = await axios.post(`${import.meta.env.VITE_API_URL}/api/system/wechat/qrcode`, {
+			scene: `id=${row.id}`,
+			page: 'pages/index/index',
 			width: 430,
-			is_hyaline: true
+			auto_color: false,
+			is_hyaline: false
 		}, {
 			responseType: 'blob' // 接收二进制数据
 		});