!126 分享相关完善

Merge pull request !126 from puhui999/master
pull/128/MERGE
芋道源码 2024-12-01 08:58:39 +00:00 committed by Gitee
commit 9616e660a6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
9 changed files with 54 additions and 32 deletions

View File

@ -241,7 +241,7 @@
padding: 20rpx; padding: 20rpx;
color: #fff; color: #fff;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient)); background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
margin-top: 18px; margin-top: 3px;
margin-bottom: 9px; margin-bottom: 9px;
border-top-left-radius: 10px; border-top-left-radius: 10px;
border-bottom-right-radius: 10px; border-bottom-right-radius: 10px;
@ -249,7 +249,7 @@
&.admin { &.admin {
background: #fff; background: #fff;
color: #333; color: #333;
margin-top: 18px; margin-top: 3px;
margin-bottom: 9px; margin-bottom: 9px;
border-radius: 0 10px 10px 10px; border-radius: 0 10px 10px 10px;
} }

View File

@ -76,13 +76,12 @@
shareInfo: {}, shareInfo: {},
}); });
// TODO @puhui999
function onShareGoods(goodsInfo) { function onShareGoods(goodsInfo) {
state.shareInfo = $share.getShareInfo( state.shareInfo = $share.getShareInfo(
{ {
title: goodsInfo.title, title: goodsInfo.name,
image: sheep.$url.cdn(goodsInfo.image), image: sheep.$url.cdn(goodsInfo.picUrl),
desc: goodsInfo.subtitle, desc: goodsInfo.introduction,
params: { params: {
page: '2', page: '2',
query: goodsInfo.id, query: goodsInfo.id,
@ -90,10 +89,10 @@
}, },
{ {
type: 'goods', // type: 'goods', //
title: goodsInfo.title, // title: goodsInfo.name, //
image: sheep.$url.cdn(goodsInfo.image), // image: sheep.$url.cdn(goodsInfo.picUrl), //
price: goodsInfo.price[0], // price: fen2yuan(goodsInfo.price), //
original_price: goodsInfo.original_price, // original_price: fen2yuan(goodsInfo.marketPrice), //
}, },
); );
showShareModal(); showShareModal();

View File

@ -78,6 +78,7 @@
limit="1" limit="1"
mode="grid" mode="grid"
:imageStyles="{ width: '168rpx', height: '168rpx' }" :imageStyles="{ width: '168rpx', height: '168rpx' }"
@success="(payload) => state.accountInfo.accountQrCodeUrl = payload.tempFilePaths[0]"
/> />
</view> </view>
</view> </view>
@ -161,13 +162,14 @@
</template> </template>
<script setup> <script setup>
import { computed, reactive, onBeforeMount } from 'vue'; import { computed, onBeforeMount, reactive } from 'vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
import accountTypeSelect from './components/account-type-select.vue'; import accountTypeSelect from './components/account-type-select.vue';
import { fen2yuan } from '@/sheep/hooks/useGoods'; import { fen2yuan } from '@/sheep/hooks/useGoods';
import TradeConfigApi from '@/sheep/api/trade/config'; import TradeConfigApi from '@/sheep/api/trade/config';
import BrokerageApi from '@/sheep/api/trade/brokerage'; import BrokerageApi from '@/sheep/api/trade/brokerage';
import DictApi from '@/sheep/api/system/dict'; import DictApi from '@/sheep/api/system/dict';
import SLayout from '@/sheep/components/s-layout/s-layout.vue';
const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png'); const headerBg = sheep.$url.css('/static/img/shop/user/withdraw_bg.png');
const statusBarHeight = sheep.$platform.device.statusBarHeight * 2; const statusBarHeight = sheep.$platform.device.statusBarHeight * 2;

View File

@ -71,7 +71,7 @@
<script setup> <script setup>
import sheep from '@/sheep'; import sheep from '@/sheep';
import { onLoad } from '@dcloudio/uni-app'; import { onLoad } from '@dcloudio/uni-app';
import { reactive, ref } from 'vue'; import { reactive } from 'vue';
import OrderApi from '@/sheep/api/trade/order'; import OrderApi from '@/sheep/api/trade/order';
const state = reactive({ const state = reactive({
@ -111,7 +111,7 @@
* @param commentIndex 当前评论的下标 * @param commentIndex 当前评论的下标
*/ */
function uploadSuccess(payload, commentIndex) { function uploadSuccess(payload, commentIndex) {
state.commentList[commentIndex].picUrls = state.commentList[commentIndex].images; state.commentList[commentIndex].picUrls = payload.tempFilePaths;
} }
onLoad(async (options) => { onLoad(async (options) => {

View File

@ -171,7 +171,6 @@
} }
// //
// TODO puhui999: fix
const shareInfo = computed(() => { const shareInfo = computed(() => {
if (isEmpty(unref(activity))) return {}; if (isEmpty(unref(activity))) return {};
return sheep.$platform.share.getShareInfo( return sheep.$platform.share.getShareInfo(
@ -179,7 +178,7 @@
title: activity.value.name, title: activity.value.name,
image: sheep.$url.cdn(state.goodsInfo.picUrl), image: sheep.$url.cdn(state.goodsInfo.picUrl),
params: { params: {
page: '4', page: '6',
query: activity.value.id, query: activity.value.id,
}, },
}, },
@ -187,8 +186,8 @@
type: 'goods', // type: 'goods', //
title: activity.value.name, // title: activity.value.name, //
image: sheep.$url.cdn(state.goodsInfo.picUrl), // image: sheep.$url.cdn(state.goodsInfo.picUrl), //
price: state.goodsInfo.price, // price: (getShowPrice.value.price || 0) + ` + ${getShowPrice.value.point} 积分`, //
marketPrice: state.goodsInfo.marketPrice, // marketPrice: fen2yuan(state.goodsInfo.marketPrice), //
}, },
); );
}); });

View File

@ -137,11 +137,11 @@
</template> </template>
<script setup> <script setup>
import { reactive, computed, ref, unref } from 'vue'; import { computed, reactive, ref, unref } from 'vue';
import { onLoad, onPageScroll } from '@dcloudio/uni-app'; import { onLoad, onPageScroll } from '@dcloudio/uni-app';
import sheep from '@/sheep'; import sheep from '@/sheep';
import { isEmpty, min } from 'lodash-es'; import { isEmpty, min } from 'lodash-es';
import { useDurationTime, formatGoodsSwiper, fen2yuan } from '@/sheep/hooks/useGoods'; import { fen2yuan, formatGoodsSwiper, useDurationTime } from '@/sheep/hooks/useGoods';
import detailNavbar from './components/detail/detail-navbar.vue'; import detailNavbar from './components/detail/detail-navbar.vue';
import detailCellSku from './components/detail/detail-cell-sku.vue'; import detailCellSku from './components/detail/detail-cell-sku.vue';
import detailTabbar from './components/detail/detail-tabbar.vue'; import detailTabbar from './components/detail/detail-tabbar.vue';
@ -214,8 +214,8 @@
type: 'goods', // type: 'goods', //
title: activity.value.name, // title: activity.value.name, //
image: sheep.$url.cdn(state.goodsInfo.picUrl), // image: sheep.$url.cdn(state.goodsInfo.picUrl), //
price: state.goodsInfo.price, // price: fen2yuan(state.goodsInfo.price), //
marketPrice: state.goodsInfo.marketPrice, // marketPrice: fen2yuan(state.goodsInfo.marketPrice), //
}, },
); );
}); });

View File

@ -60,12 +60,11 @@
/** /**
* 模板组件 - 提供页面公共组件属性方法 * 模板组件 - 提供页面公共组件属性方法
*/ */
import { computed, reactive, ref } from 'vue'; import { computed } from 'vue';
import sheep from '@/sheep'; import sheep from '@/sheep';
import { isEmpty } from 'lodash-es'; import { isEmpty } from 'lodash-es';
import { onShow } from '@dcloudio/uni-app';
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
import { onShareAppMessage } from '@dcloudio/uni-app'; import { onShareAppMessage, onShareTimeline, onShow } from '@dcloudio/uni-app';
// #endif // #endif
const props = defineProps({ const props = defineProps({
@ -191,7 +190,11 @@
}); });
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
// uni.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline'],
});
//
onShareAppMessage(() => { onShareAppMessage(() => {
return { return {
title: shareInfo.value.title, title: shareInfo.value.title,
@ -199,6 +202,14 @@
imageUrl: shareInfo.value.image, imageUrl: shareInfo.value.image,
}; };
}); });
//
onShareTimeline(() => {
return {
title: shareInfo.value.title,
query: shareInfo.value.path,
imageUrl: shareInfo.value.image,
};
});
// #endif // #endif
onShow(() => { onShow(() => {

View File

@ -47,19 +47,18 @@ const getShareInfo = (
// 配置分享链接地址 // 配置分享链接地址
shareInfo.link = buildSpmLink(query, shareConfig.linkAddress); shareInfo.link = buildSpmLink(query, shareConfig.linkAddress);
// 配置页面地址带参数 // 配置页面地址带参数
shareInfo.path = buildSpmPath(query); shareInfo.path = buildSpmPath();
// 配置转发参数 // 配置转发参数
if (shareConfig.methods.includes('forward')) { if (shareConfig.methods.includes('forward')) {
// TODO puhui999: forward 这块有点问题
if (shareConfig.forwardInfo.title === '' || shareConfig.forwardInfo.image === '') { if (shareConfig.forwardInfo.title === '' || shareConfig.forwardInfo.image === '') {
console.log('请在平台设置中配置转发信息'); console.log('请在平台设置中配置默认转发信息');
} }
// 设置自定义分享信息 // 设置自定义分享信息
shareInfo.title = scene.title || shareConfig.forwardInfo.title; shareInfo.title = scene.title || shareConfig.forwardInfo.title;
shareInfo.image = $url.cdn(scene.image || shareConfig.forwardInfo.image); shareInfo.image = $url.cdn(scene.image || shareConfig.forwardInfo.image);
shareInfo.desc = scene.desc || shareConfig.forwardInfo.subtitle; shareInfo.desc = scene.desc || shareConfig.forwardInfo.subtitle;
shareInfo.path = buildSpmPath(scene.path, query); shareInfo.path = buildSpmPath(query);
} }
return shareInfo; return shareInfo;
@ -100,7 +99,7 @@ const buildSpmQuery = (params) => {
const buildSpmPath = (query) => { const buildSpmPath = (query) => {
// 默认是主页,页面 page例如 pages/index/index根路径前不要填加 / // 默认是主页,页面 page例如 pages/index/index根路径前不要填加 /
// 不能携带参数参数请放在scene字段里如果不填写这个字段默认跳主页面。scancode_time为系统保留参数不允许配置 // 不能携带参数参数请放在scene字段里如果不填写这个字段默认跳主页面。scancode_time为系统保留参数不允许配置
return `pages/index/index`; return typeof query === 'undefined' ? `pages/index/index` : `pages/index/index?${query}`;
}; };
// 构造分享链接 // 构造分享链接
@ -148,7 +147,7 @@ const decryptSpm = (spm) => {
shareParams.page = '/pages/goods/seckill'; shareParams.page = '/pages/goods/seckill';
query = shareParamsArray[2].split(','); query = shareParamsArray[2].split(',');
shareParams.query = { shareParams.query = {
id: query[1], id: query[0],
}; };
break; break;
case '5': case '5':
@ -158,6 +157,13 @@ const decryptSpm = (spm) => {
id: shareParamsArray[2], id: shareParamsArray[2],
}; };
break; break;
case '6':
// 积分商品
shareParams.page = '/pages/goods/point';
shareParams.query = {
id: shareParamsArray[2],
};
break;
} }
shareParams.platform = platformMap[shareParamsArray[3] - 1]; shareParams.platform = platformMap[shareParamsArray[3] - 1];
shareParams.from = fromMap[shareParamsArray[4] - 1]; shareParams.from = fromMap[shareParamsArray[4] - 1];

View File

@ -71,13 +71,18 @@ const app = defineStore({
}; };
this.platform = { this.platform = {
share: { share: {
methods: ['poster', 'link'], methods: ['forward', 'poster', 'link'],
linkAddress: 'http://127.0.0.1:3000', // TODO 芋艿:可以考虑改到 .env 那 linkAddress: 'http://127.0.0.1:3000', // TODO 芋艿:可以考虑改到 .env 那
posterInfo: { posterInfo: {
user_bg: '/static/img/shop/config/user-poster-bg.png', user_bg: '/static/img/shop/config/user-poster-bg.png',
goods_bg: '/static/img/shop/config/goods-poster-bg.png', goods_bg: '/static/img/shop/config/goods-poster-bg.png',
groupon_bg: '/static/img/shop/config/groupon-poster-bg.png', groupon_bg: '/static/img/shop/config/groupon-poster-bg.png',
}, },
forwardInfo: {
title: '',
image: '',
desc: '',
},
}, },
bind_mobile: 0, bind_mobile: 0,
}; };