mirror of
https://github.com/ialley-workshop-open/uni-halo.git
synced 2025-05-19 01:50:15 +09:00
update: 删除分享配置,使用微信默认的分享机制
This commit is contained in:
parent
66a39dd723
commit
4d0901b650
62
App.vue
62
App.vue
@ -1,17 +1,15 @@
|
|||||||
<script>
|
<script>
|
||||||
import HaloTokenConfig from '@/config/token.config.js';
|
import HaloTokenConfig from '@/config/token.config.js';
|
||||||
|
|
||||||
// app升级检测(搭配:https://ext.dcloud.net.cn/plugin?id=4470 升级中心)
|
// app升级检测(搭配:https://ext.dcloud.net.cn/plugin?id=4470 升级中心)
|
||||||
import CheckAppUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
|
import CheckAppUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
|
||||||
import {
|
import {CheckWxUpdate} from '@/utils/update.js';
|
||||||
CheckWxUpdate
|
|
||||||
} from '@/utils/update.js';
|
export default {
|
||||||
export default {
|
|
||||||
globalData: {
|
globalData: {
|
||||||
baseApiUrl: HaloTokenConfig.BASE_API
|
baseApiUrl: HaloTokenConfig.BASE_API
|
||||||
},
|
},
|
||||||
onLaunch: function() {
|
onLaunch: function () {
|
||||||
console.log('App Launch');
|
|
||||||
|
|
||||||
// #ifdef APP-PLUS
|
// #ifdef APP-PLUS
|
||||||
CheckAppUpdate();
|
CheckAppUpdate();
|
||||||
@ -22,45 +20,41 @@
|
|||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
uni.$tm.vx.actions('config/fetchConfigs').then((res) => {
|
uni.$tm.vx.actions('config/fetchConfigs').then((res) => {
|
||||||
console.log('正常:', res)
|
|
||||||
// #ifdef MP-WEIXIN
|
|
||||||
uni.$tm.vx.commit('setWxShare', res.shareConfig);
|
|
||||||
// #endif
|
|
||||||
})
|
})
|
||||||
// 启动检查app的配置是否已经就绪,若未就绪则设置默认的
|
// 启动检查app的配置是否已经就绪,若未就绪则设置默认的
|
||||||
uni.$tm.vx.actions('setting/checkAndSetDefaultAppSettings');
|
uni.$tm.vx.actions('setting/checkAndSetDefaultAppSettings');
|
||||||
},
|
},
|
||||||
onShow: function() {
|
onShow: function () {
|
||||||
console.log('App Show');
|
console.log('App Show');
|
||||||
},
|
},
|
||||||
onHide: function() {
|
onHide: function () {
|
||||||
console.log('App Hide');
|
console.log('App Hide');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
// 基础样式
|
// 基础样式
|
||||||
@import './common/styles/app.theme.scss';
|
@import './common/styles/app.theme.scss';
|
||||||
@import './common/styles/app.base.scss';
|
@import './common/styles/app.base.scss';
|
||||||
|
|
||||||
// 引入tmUI2.x样式
|
// 引入tmUI2.x样式
|
||||||
@import './tm-vuetify/mian.min.css';
|
@import './tm-vuetify/mian.min.css';
|
||||||
// 引入tmUI2.x主题包
|
// 引入tmUI2.x主题包
|
||||||
@import './tm-vuetify/scss/theme.css';
|
@import './tm-vuetify/scss/theme.css';
|
||||||
// 引入tmUI2.x预置图标
|
// 引入tmUI2.x预置图标
|
||||||
@import './tm-vuetify/scss/fonts/fontawesome_base64.css';
|
@import './tm-vuetify/scss/fonts/fontawesome_base64.css';
|
||||||
|
|
||||||
// 自定义图标
|
// 自定义图标
|
||||||
@import './common/icons/halocoloriconfont.css';
|
@import './common/icons/halocoloriconfont.css';
|
||||||
@import './common/icons/haloiconfont.css';
|
@import './common/icons/haloiconfont.css';
|
||||||
@import './common/icons/mphtmliconfont.css';
|
@import './common/icons/mphtmliconfont.css';
|
||||||
|
|
||||||
/* #ifndef MP-WEIXIN */
|
/* #ifndef MP-WEIXIN */
|
||||||
@import './common/markdown/markdown.scss';
|
@import './common/markdown/markdown.scss';
|
||||||
/* #endif */
|
/* #endif */
|
||||||
|
|
||||||
page {
|
page {
|
||||||
background-color: #fafafa;
|
background-color: #fafafa;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -42,18 +42,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
haloConfig: {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
handler(newVal) {
|
|
||||||
if (!newVal) return;
|
|
||||||
// #ifdef MP-WEIXIN
|
|
||||||
uni.$tm.vx.commit('setWxShare', newVal.shareConfig);
|
|
||||||
// #endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.fnResetSetAniWaitIndex()
|
this.fnResetSetAniWaitIndex()
|
||||||
},
|
},
|
||||||
|
@ -1,68 +0,0 @@
|
|||||||
// 微信分享配置
|
|
||||||
import HaloTokenConfig from '@/config/token.config.js'
|
|
||||||
import {jsonToUrlParams2} from '@/utils/url.params.js'
|
|
||||||
import utils from '@/utils/index.js'
|
|
||||||
|
|
||||||
export const haloWxShareMixin = {
|
|
||||||
computed: {
|
|
||||||
haloWxShareData() {
|
|
||||||
const configs = this.$tm.vx.getters().getConfigs?.shareConfig;
|
|
||||||
if(!configs) return {};
|
|
||||||
configs.imageUrl = utils.checkImageUrl(configs.imageUrl)
|
|
||||||
return configs
|
|
||||||
}
|
|
||||||
},
|
|
||||||
//#ifdef MP-WEIXIN
|
|
||||||
onShareAppMessage(res) {
|
|
||||||
return {
|
|
||||||
...this.haloWxShareData,
|
|
||||||
success: res => {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
//#endif
|
|
||||||
/* 分享到微信好友 */
|
|
||||||
onShareAppMessage(res) {
|
|
||||||
const promise = new Promise(resolve => {
|
|
||||||
setTimeout(() => {
|
|
||||||
resolve({
|
|
||||||
title: this.haloWxShareData.title,
|
|
||||||
path: this.haloWxShareData.path,
|
|
||||||
})
|
|
||||||
}, 2000)
|
|
||||||
})
|
|
||||||
return {
|
|
||||||
title: this.haloWxShareData.title,
|
|
||||||
path: '',
|
|
||||||
promise
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// 分享到朋友圈-这里封装不够,在页面还要声明一次,否则是拿不到参数的,被分享者在朋友圈打开链接是空的
|
|
||||||
onShareTimeline: function () {
|
|
||||||
return {
|
|
||||||
title: this.haloWxShareData.title,
|
|
||||||
query: {},
|
|
||||||
imageUrl: this.haloWxShareData.imageUrl,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 设置分享信息(需要在页面调用)
|
|
||||||
fnSetWxShareConfig(config = {}) {
|
|
||||||
let currentRoutes = getCurrentPages(); // 获取当前打开过的页面路由数组
|
|
||||||
let currentRoute = currentRoutes[currentRoutes.length - 1].route; //获取当前页面路由(分销思路,分享者点开使用的小程序将获取到分享者的id)
|
|
||||||
let sharePath = currentRoutes
|
|
||||||
if (config.params) {
|
|
||||||
const URLParams = config.params ? jsonToUrlParams2(config.params) : {};
|
|
||||||
sharePath += URLParams
|
|
||||||
}
|
|
||||||
let _config = Object.assign({}, {
|
|
||||||
path: sharePath,
|
|
||||||
copyLink: HaloTokenConfig.BASE_API,
|
|
||||||
query: {}
|
|
||||||
}, config)
|
|
||||||
|
|
||||||
uni.$tm.vx.commit('setWxShare', _config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,7 +14,7 @@ export default {
|
|||||||
onLoad() {
|
onLoad() {
|
||||||
uni.$tm.vx.actions('config/fetchConfigs').then((res) => {
|
uni.$tm.vx.actions('config/fetchConfigs').then((res) => {
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
uni.$tm.vx.commit('setWxShare', res.shareConfig);
|
// uni.$tm.vx.commit('setWxShare', res.shareConfig);
|
||||||
// #endif
|
// #endif
|
||||||
this.fnCheckShowStarted();
|
this.fnCheckShowStarted();
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
|
@ -233,8 +233,6 @@ import commentModal from '@/components/comment-modal/comment-modal.vue';
|
|||||||
import rCanvas from '@/components/r-canvas/r-canvas.vue';
|
import rCanvas from '@/components/r-canvas/r-canvas.vue';
|
||||||
import barrage from '@/components/barrage/barrage.vue';
|
import barrage from '@/components/barrage/barrage.vue';
|
||||||
|
|
||||||
import {haloWxShareMixin} from '@/common/mixins/wxshare.mixin.js';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
tmSkeleton,
|
tmSkeleton,
|
||||||
@ -251,7 +249,6 @@ export default {
|
|||||||
barrage,
|
barrage,
|
||||||
commentModal
|
commentModal
|
||||||
},
|
},
|
||||||
mixins: [haloWxShareMixin],
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
loading: 'loading',
|
loading: 'loading',
|
||||||
@ -394,15 +391,6 @@ export default {
|
|||||||
|
|
||||||
this.fnSetPageTitle('文章详情');
|
this.fnSetPageTitle('文章详情');
|
||||||
this.loading = 'success';
|
this.loading = 'success';
|
||||||
this.fnSetWxShareConfig({
|
|
||||||
title: this.result.spec.title,
|
|
||||||
desc: this.result.content.raw,
|
|
||||||
imageUrl: this.$utils.checkThumbnailUrl(this.result.spec.cover),
|
|
||||||
path: `/pagesA/article-detail/article-detail?name=${this.result.metadata.name}`,
|
|
||||||
copyLink: this.$baseApiUrl,
|
|
||||||
query: {}
|
|
||||||
});
|
|
||||||
|
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.log("错误", err)
|
console.log("错误", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user