<template>
|
<view class="content">
|
<button class="share" open-type="share" >分享</button>
|
</view>
|
</template>
|
|
<script>
|
import { ref, reactive, toRefs, onMounted, getCurrentInstance } from "vue";
|
import { onLoad, onShow, onHide, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app'
|
import { useBasicInfoStore } from "../../store/basicInfo"
|
export default {
|
setup() {
|
const userStore = useBasicInfoStore()
|
const { proxy } = getCurrentInstance();
|
const state = reactive({
|
|
})
|
|
onMounted(() => {
|
Init();
|
});
|
|
const Init = () => {
|
|
}
|
|
|
onShareAppMessage((res) => {
|
// 分享事件来源:button(页面内分享按钮)、menu(右上角分享按钮)
|
if (res.from === 'button') {// 来自页面内分享按钮
|
return {
|
//分享标题
|
title: shopDetailsData.value?.GoodsName,
|
//页面 path
|
path: '/pages/index/index',
|
// 分享图标
|
// imageUr: shopDetailsData.value?.GoodsCoverImg,
|
success: function (res) {
|
// 转发成功
|
console.log('res', res);
|
},
|
fail: function (res) {
|
// 转发失败
|
console.log('res', res);
|
|
}
|
}
|
} else {
|
return {
|
title: shopDetailsData.value?.GoodsName,
|
path: '/pages/index/index',
|
//imageUr: shopDetailsData.value?.GoodsCoverImg
|
}
|
}
|
})
|
|
|
|
|
|
|
|
return { ...toRefs(state), userStore }
|
}
|
}
|
|
|
|
</script>
|
|
<style scoped lang="scss">
|
.center {
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
}
|
|
.content {
|
@extend .center;
|
height: 100vh;
|
width: 100%;
|
background-color: #f5f5f5;
|
}
|
|
.share {
|
width: 80%;
|
margin-top: 60rpx;
|
background-color: #eabb38;
|
color: #fff;
|
}
|
</style>
|