flat: 添加微信分享卡片
This commit is contained in:
32
App.vue
32
App.vue
@@ -3,7 +3,9 @@ import { reactive, inject, onMounted } from 'vue';
|
||||
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app';
|
||||
import useUserStore from './stores/useUserStore';
|
||||
import useDictStore from './stores/useDictStore';
|
||||
import { setupWechatShare, generateShareLink } from '@/utils/wechatShare.js';
|
||||
const { $api, navTo, appendScriptTagElement } = inject('globalFunction');
|
||||
import config from '@/config.js';
|
||||
|
||||
onLaunch((options) => {
|
||||
useDictStore().getDictData();
|
||||
@@ -26,15 +28,10 @@ onLaunch((options) => {
|
||||
|
||||
onMounted(() => {
|
||||
// #ifndef MP-WEIXIN
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
appendScriptTagElement('./static/js/jweixin-1.4.0.js').then(() => {
|
||||
console.log('✅ 微信 JSSDK 加载完成');
|
||||
});
|
||||
} else {
|
||||
appendScriptTagElement('/static/js/jweixin-1.4.0.js').then(() => {
|
||||
console.log('✅ 微信 JSSDK 加载完成');
|
||||
});
|
||||
}
|
||||
appendScriptTagElement('https://qd.zhaopinzao8dian.com/file/csn/jweixin-1.4.0.js').then(() => {
|
||||
console.log('✅ 微信 JSSDK 加载完成');
|
||||
signatureFn();
|
||||
});
|
||||
// #endif
|
||||
});
|
||||
|
||||
@@ -45,6 +42,17 @@ onShow(() => {
|
||||
onHide(() => {
|
||||
console.log('App Hide');
|
||||
});
|
||||
|
||||
function signatureFn() {
|
||||
const link = generateShareLink();
|
||||
// console.log('首页link:', link);
|
||||
setupWechatShare({
|
||||
title: config.shareConfig.title,
|
||||
desc: config.shareConfig.desc,
|
||||
link: link,
|
||||
imgUrl: config.shareConfig.imgUrl,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
@@ -81,19 +89,19 @@ uni-modal,
|
||||
|
||||
@font-face {
|
||||
font-family: PingFangSC-Regular;
|
||||
src: url('/static/font/PingFangSC-Regular.woff2') format('woff2');
|
||||
src: url('https://qd.zhaopinzao8dian.com/file/csn/PingFangSC-Regular.woff2') format('woff2');
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: PingFangSC-Medium;
|
||||
src: url('/static/font/PingFangSC-Medium.woff2') format('woff2');
|
||||
src: url('https://qd.zhaopinzao8dian.com/file/csn/PingFangSC-Medium.woff2') format('woff2');
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: DIN-Medium;
|
||||
src: url('/static/font/DIN-Medium.woff2') format('woff2');
|
||||
src: url('https://qd.zhaopinzao8dian.com/file/csn/DIN-Medium.woff2') format('woff2');
|
||||
font-display: swap;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user