123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196 |
- <template>
- <view>
- <su-popup :show="state.showShareGuide" :showClose="false" @close="onCloseGuide" />
- <view v-if="state.showShareGuide" class="guide-wrap">
- <image class="guide-image" :src="sheep.$url.static('/static/img/shop/share/share_guide.png')" />
- </view>
- <su-popup :show="show" round="10" :showClose="false" @close="closeShareModal">
-
- <view class="share-box">
- <view class="share-list-box ss-flex">
-
- <button
- v-if="shareConfig.methods.includes('forward')"
- class="share-item share-btn ss-flex-col ss-col-center"
- open-type="share"
- @tap="onShareByForward"
- >
- <image class="share-img" :src="sheep.$url.static('/static/img/shop/share/share_wx.png')" mode="" />
- <text class="share-title">微信好友</text>
- </button>
-
- <button
- v-if="shareConfig.methods.includes('poster')"
- class="share-item share-btn ss-flex-col ss-col-center"
- @tap="onShareByPoster"
- >
- <image
- class="share-img"
- :src="sheep.$url.static('/static/img/shop/share/share_poster.png')"
- mode=""
- />
- <text class="share-title">生成海报</text>
- </button>
-
- <button
- v-if="shareConfig.methods.includes('link')"
- class="share-item share-btn ss-flex-col ss-col-center"
- @tap="onShareByCopyLink"
- >
- <image class="share-img" :src="sheep.$url.static('/static/img/shop/share/share_link.png')" mode="" />
- <text class="share-title">复制链接</text>
- </button>
- </view>
- <view class="share-foot ss-flex ss-row-center ss-col-center" @tap="closeShareModal">
- 取消
- </view>
- </view>
- </su-popup>
-
- <canvas-poster
- ref="SharePosterRef"
- :show="state.showPosterModal"
- :shareInfo="shareInfo"
- @close="state.showPosterModal = false"
- />
- </view>
- </template>
- <script setup>
-
- import { ref, unref, reactive, computed } from 'vue';
- import sheep from '@/sheep';
- import canvasPoster from './canvas-poster/index.vue';
- import { closeShareModal, showAuthModal } from '@/sheep/hooks/useModal';
- const show = computed(() => sheep.$store('modal').share);
- const shareConfig = computed(() => sheep.$store('app').platform.share);
- const SharePosterRef = ref('');
- const props = defineProps({
- shareInfo: {
- type: Object,
- default() {},
- },
- });
- const state = reactive({
- showShareGuide: false,
- showPosterModal: false,
- });
-
- const onShareByPoster = () => {
- closeShareModal();
- if (!sheep.$store('user').isLogin) {
- showAuthModal();
- return;
- }
- console.log(props.shareInfo);
- unref(SharePosterRef).getPoster();
- state.showPosterModal = true;
- };
-
- const onShareByForward = () => {
- closeShareModal();
-
- if (['WechatOfficialAccount', 'H5'].includes(sheep.$platform.name)) {
- state.showShareGuide = true;
- return;
- }
-
-
- uni.share({
- provider: 'weixin',
- scene: 'WXSceneSession',
- type: 0,
- href: props.shareInfo.link,
- title: props.shareInfo.title,
- summary: props.shareInfo.desc,
- imageUrl: props.shareInfo.image,
- success: (res) => {
- console.log('success:' + JSON.stringify(res));
- },
- fail: (err) => {
- console.log('fail:' + JSON.stringify(err));
- },
- });
-
- };
-
- const onShareByCopyLink = () => {
- sheep.$helper.copyText(props.shareInfo.link);
- closeShareModal();
- };
- function onCloseGuide() {
- state.showShareGuide = false;
- }
- </script>
- <style lang="scss" scoped>
- .guide-image {
- right: 30rpx;
- top: 0;
- position: fixed;
- width: 580rpx;
- height: 430rpx;
- z-index: 10080;
- }
- // 分享tool
- .share-box {
- background: $white;
- width: 750rpx;
- border-radius: 30rpx 30rpx 0 0;
- padding-top: 30rpx;
- .share-foot {
- font-size: 24rpx;
- color: $gray-b;
- height: 80rpx;
- border-top: 1rpx solid $gray-e;
- }
- .share-list-box {
- .share-btn {
- background: none;
- border: none;
- line-height: 1;
- padding: 0;
- &::after {
- border: none;
- }
- }
- .share-item {
- flex: 1;
- padding-bottom: 20rpx;
- .share-img {
- width: 70rpx;
- height: 70rpx;
- background: $gray-f;
- border-radius: 50%;
- margin-bottom: 20rpx;
- }
- .share-title {
- font-size: 24rpx;
- color: $dark-6;
- }
- }
- }
- }
- </style>
|