feat(分享功能): 添加微信小程序分享跳转功能并优化分享链接处理

在RankListMini组件中添加微信小程序分享跳转功能,使用redirectTo方法
优化indexNewsInfo页面的分享链接处理逻辑,移除冗余代码
This commit is contained in:
34701892@qq.com 2025-12-25 17:25:49 +08:00
parent 2dc59ae87d
commit 7cd93926f8
2 changed files with 27 additions and 12 deletions

View File

@ -150,7 +150,7 @@ const props = defineProps({
default: () => {}, default: () => {},
}, },
}); });
import wx from "weixin-js-sdk";
const clickItem = ref({}); const clickItem = ref({});
function goDetail(item) { function goDetail(item) {
clickItem.value = item; clickItem.value = item;
@ -168,6 +168,19 @@ function goDetail(item) {
uni.navigateTo({ uni.navigateTo({
url: `/pages/detail/indexNewsInfo?id=${item.news_id}&phone=${phone}&userType=${userType}`, url: `/pages/detail/indexNewsInfo?id=${item.news_id}&phone=${phone}&userType=${userType}`,
}); });
let shareUrl =
"https://cankao.cs.com.cn/jnh/#/pages/detail/indexNewsInfo?id=" +
// "http://localhost:8881/jnh/#/pages/detail/indexNewsInfo?id=" +
item.news_id +
"&phone=" +
uni.getStorageSync("token") +
"&userType=" +
userType.value;
wx.miniProgram.redirectTo({
url: "/pages/webView/index?url=" + encodeURIComponent(shareUrl),
});
} }
const LoginShow = ref(false); const LoginShow = ref(false);

View File

@ -153,17 +153,19 @@ onLoad(async (option: any) => {
} }
} }
let shareUrl = // if (option?.into) {
"https://cankao.cs.com.cn/jnh/#/pages/detail/indexNewsInfo?id=" + // let shareUrl =
option.id + // "https://cankao.cs.com.cn/jnh/#/pages/detail/indexNewsInfo?id=" +
"&phone=" + // option.id +
uni.getStorageSync("token") + // "&phone=" +
"&userType=" + // uni.getStorageSync("token") +
userType.value; // "&userType=" +
// userType.value +
wx.miniProgram.navigateTo({ // "&into=1";
url: "/pages/webView/index?url=" + encodeURIComponent(shareUrl), // wx.miniProgram.navigateTo({
}); // url: "/pages/webView/index?url=" + encodeURIComponent(shareUrl),
// });
// }
}); });
const newList = async (columnId: number) => { const newList = async (columnId: number) => {