Browse Source

分享fix

master
jiazhipeng 2 months ago
parent
commit
91e6ad2762
  1. 10
      App.vue
  2. 7
      mixins/myMixins.js
  3. 27
      pages/index/index.vue
  4. 16
      static/js/CommonFunction.js

10
App.vue

@ -4,15 +4,17 @@
console.warn('当前组件仅支持 uni_modules 目录结构 ,请升级 HBuilderX 到 3.1.0 版本以上!')
console.log('App Launch')
// 1
// 1
uni.setStorageSync('SHFlag', true)
this.Post({id:2388},'/api/multimedia/detail').then(res => {
try {
if (res && res.data) {
// let SHFlag = res.data.company_name == 1 ? true : false
let SHFlag = res.data.ext_link == 1 ? true : false
uni.setStorageSync('SHFlag', SHFlag)
} catch(e) {
return
} else {
uni.setStorageSync('SHFlag', false)
}
}
});
},
onShow: function() {

7
mixins/myMixins.js

@ -25,8 +25,9 @@ export const myMixins ={
const pages = getCurrentPages(); // 获取加载的页面
const view = pages[pages.length - 1]; // 获取当前页面的对象
let url = '';
if (view.options.url) {
url = view.options.url;
console.log(view)
if (view.$page.fullPath) {
url = view.options.fullPath;
} else {
url = uni.getStorageSync('webUrl');
}
@ -34,7 +35,7 @@ export const myMixins ={
console.log(111,url,`${view.route}?url=${url}`)
return {
title: '时味苏州', // 分享的名称
path: `${view.route}?url=${url}`, // 将 url 作为参数传递
path: `${view.$page.fullPath}`,
imageUrl: "https://static.ticket.sz-trip.com/uploads/20250818/5ea2c18a15db8a438f2ce642194b6051.jpg",
mpId: 'wx699ed131345cf8dd' // 此处配置微信小程序的 AppId
};

27
pages/index/index.vue

@ -127,7 +127,7 @@
]
},
SHFlag: false,
SHFlag: true,
}
},
@ -135,11 +135,7 @@
},
onShow() {
try {
this.SHFlag = uni.getStorageSync('SHFlag')?true: false
} catch (e) {
this.SHFlag = false
}
this.initSHFlag()
},
//
onHide() {
@ -151,6 +147,25 @@
this.getHeadImg(2378).then(res => {this.CKMap = res})
},
methods: {
initSHFlag () {
let _this = this
//
try {
_this.SHFlag = uni.getStorageSync('SHFlag')?true: false
} catch (e) {
_this.SHFlag = false
}
console.log(_this.SHFlag)
setTimeout(()=>{
try {
_this.SHFlag = uni.getStorageSync('SHFlag')?true: false
} catch (e) {
_this.SHFlag = false
}
console.log(_this.SHFlag)
},500)
},
initRectInfo () {
const sysInfo = uni.getSystemInfoSync()
this.statusBarHeight = sysInfo.statusBarHeight

16
static/js/CommonFunction.js

@ -324,4 +324,20 @@ Vue.prototype.goCartNextPage= function(currentPageIndex){
})
}
}
Vue.prototype.sharePage = function(param) {
const pages = getCurrentPages(); // 获取加载的页面
const view = pages[pages.length - 1]; // 获取当前页面的对象
let shareParam = {
title: '时味苏州', // 分享的名称
path: `${view.$page.fullPath}`,
imageUrl: "https://static.ticket.sz-trip.com/uploads/20250818/5ea2c18a15db8a438f2ce642194b6051.jpg",
mpId: 'wx699ed131345cf8dd', // 此处配置微信小程序的 AppId
...param,
}
return shareParam;
}
Loading…
Cancel
Save