mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 18:03:27 +08:00
uniapp【优化】(分享模块):封装分享请求
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
/** 系统配置 */
|
||||
export * from './systemInfo';
|
||||
export * from './use-loading';
|
||||
export * from './use-share';
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
import { onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
|
||||
import { queryShare } from '@/core/api';
|
||||
import { ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum';
|
||||
import { handleShowToast } from '@/core/utils';
|
||||
import { UserToken } from '@/core/consts';
|
||||
|
||||
interface RequestParam {
|
||||
client ?: ShareClientEnum;
|
||||
url ?: string;
|
||||
type ?: ShareModelEnum;
|
||||
page ?: ShareEnum;
|
||||
params ?: any;
|
||||
token ?: string;
|
||||
}
|
||||
|
||||
export const useShareHook = () => {
|
||||
|
||||
/** 获取分享url */
|
||||
const getShareUrl = (requestParam : RequestParam) => {
|
||||
return new Promise(async (resolve) => {
|
||||
let data = requestParam;
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
data['token'] = uni.getStorageSync(UserToken)
|
||||
}
|
||||
const share = await queryShare(data);
|
||||
if (share.status) {
|
||||
resolve(share.data);
|
||||
} else {
|
||||
handleShowToast(share.msg);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const shareAppMessage = (options : Page.CustomShareContent) => {
|
||||
onShareAppMessage(() => {
|
||||
console.log('onShareAppMessage');
|
||||
return {
|
||||
...options
|
||||
};
|
||||
});
|
||||
return { onShareAppMessage };
|
||||
};
|
||||
|
||||
const shareTimeline = (options : Page.CustomShareContent) => {
|
||||
onShareTimeline(() => {
|
||||
console.log('shareTimeline');
|
||||
return {
|
||||
...options
|
||||
};
|
||||
});
|
||||
return { onShareTimeline };
|
||||
};
|
||||
|
||||
const share = (customShareContent : Page.CustomShareContent, shareTimelineContent ?: Page.CustomShareContent) => {
|
||||
const { onShareAppMessage } = shareAppMessage(customShareContent);
|
||||
const { onShareTimeline } = shareTimeline(shareTimelineContent ? shareTimelineContent : customShareContent);
|
||||
return { onShareAppMessage, onShareTimeline };
|
||||
};
|
||||
|
||||
return { share, getShareUrl, shareAppMessage, shareTimeline };
|
||||
};
|
||||
41
CoreCms.Net.Uni-App/CoreShop/core/utils/handle-share.ts
Normal file
41
CoreCms.Net.Uni-App/CoreShop/core/utils/handle-share.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum';
|
||||
import { UserToken } from '@/core/consts';
|
||||
import { queryShare } from '@/core/api';
|
||||
import { handleShowToast } from '@/core/utils';
|
||||
import { useShopConfigStore } from '@/core/store';
|
||||
|
||||
interface RequestParam {
|
||||
client : ShareClientEnum,
|
||||
url : string,
|
||||
type : ShareModelEnum,
|
||||
page : ShareEnum,
|
||||
params ?: any,
|
||||
token ?: string
|
||||
}
|
||||
|
||||
const getDefaultShareData = () => {
|
||||
const shopConfigStore = useShopConfigStore();
|
||||
return {
|
||||
title: shopConfigStore.config?.shopName,
|
||||
imageUrl: shopConfigStore.config?.shopLogo,
|
||||
path: "/pages/home/home"
|
||||
}
|
||||
}
|
||||
|
||||
const getShareUrl = async (requestParam : RequestParam) => {
|
||||
let data : RequestParam = requestParam;
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
data['token'] = uni.getStorageSync(UserToken)
|
||||
}
|
||||
const share = await queryShare(data);
|
||||
if (share.status) {
|
||||
return share.data;
|
||||
} else {
|
||||
handleShowToast(share.msg);
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
getShareUrl,
|
||||
getDefaultShareData,
|
||||
}
|
||||
@@ -23,4 +23,8 @@ export * from './handle-toast';
|
||||
export * from './handle-advertise-detail';
|
||||
|
||||
export * from './uni-promise';
|
||||
export * from './time-format';
|
||||
export * from './time-format';
|
||||
|
||||
|
||||
/** 处理分享 */
|
||||
export * from './handle-share';
|
||||
@@ -26,19 +26,18 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive } from 'vue';
|
||||
import { onLoad , onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
|
||||
import { queryGoodsDetail, queryCartNum, queryShare, queryGoodsDetailByToken, queryPromotionList, queryAddCart } from '@/core/api';
|
||||
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
|
||||
import { queryGoodsDetail, queryCartNum, queryGoodsDetailByToken, queryPromotionList, queryAddCart } from '@/core/api';
|
||||
import type { Response, GoodsAgentListType, GoodsPromotionType, GoodsSkuListType } from "@/core/models";
|
||||
import { PromotionEnum, AddCartEnum, PaymentTypeEnum, ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum';
|
||||
import { UserToken, shareUrl } from '@/core/consts'
|
||||
import { useCartStore } from '@/core/store';
|
||||
import { handleRouteNavigateTo, handleShowToast } from '@/core/utils';
|
||||
import { handleRouteNavigateTo, handleShowToast, getShareUrl } from '@/core/utils';
|
||||
import GoodsDetail from '@/pages/components/goods-detail/index.vue';
|
||||
import GoodsDetailBottomTabbar from '@/pages/components/goods-detail/components/goods-detail-bottom-tabbar/goods-detail-bottom-tabbar.vue';
|
||||
import GoodsDetailSkuPopup from '@/pages/components/goods-detail/components/goods-detail-sku/goods-detail-sku.vue';
|
||||
import GoodsDetailRecommend from '@/pages/components/goods-detail/components/goods-detail-recommend/goods-detail-recommend.vue';
|
||||
import { useLoginStore } from '@/core/store';
|
||||
import { useShareHook } from '@/core/hooks';
|
||||
|
||||
interface QueryParams {
|
||||
id : number;
|
||||
@@ -122,46 +121,21 @@
|
||||
});
|
||||
}
|
||||
|
||||
/** 获取分享url */
|
||||
// getShareUrl(goodsDetail.data.id);
|
||||
// state.shareUrl = (await useShareHook().getShareUrl({
|
||||
// client: ShareClientEnum.wxMiNiProgram,
|
||||
// url: shareUrl,
|
||||
// type: ShareModelEnum.url,
|
||||
// page: ShareEnum.goods,
|
||||
// params: { goodsId: goodsDetail.data.id, }
|
||||
// }) as string);
|
||||
|
||||
// const { onShareAppMessage, onShareTimeline } = useShareHook().share({ title: 'xxx2', content: 'yyy2' }, { title: '哇哈哈2' });
|
||||
|
||||
/** 获取分享url */
|
||||
state.shareUrl = await getShareUrl({
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.goods,
|
||||
params: { goodsId: goodsDetail.data.id, }
|
||||
})
|
||||
|
||||
/** 如果用户登录,获取购物车数量 */
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
getCartNum();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
const { onShareAppMessage, onShareTimeline } = useShareHook().share({
|
||||
title: state.goodsDetailData.name || '123123',
|
||||
imageUrl: state.goodsDetailData.image || '123',
|
||||
});
|
||||
|
||||
// onShareAppMessage(() => {
|
||||
// return {
|
||||
// title: state.goodsDetailData.name,
|
||||
// imageUrl: state.goodsDetailData.image,
|
||||
// }
|
||||
// });
|
||||
// onShareTimeline(() => {
|
||||
// return {
|
||||
// title: state.goodsDetailData.name,
|
||||
// imageUrl: state.goodsDetailData.image,
|
||||
// }
|
||||
// })
|
||||
|
||||
}
|
||||
|
||||
/** 获取购物车数量 */
|
||||
const getCartNum = async () => {
|
||||
const num : Response<number> = await queryCartNum();
|
||||
@@ -228,43 +202,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取分享url */
|
||||
const getShareUrl = async (goodsId : number) => {
|
||||
let data = {
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.goods,
|
||||
params: { goodsId, }
|
||||
/** 分享 */
|
||||
onShareAppMessage(() => {
|
||||
return {
|
||||
title: state.goodsDetailData.name,
|
||||
imageUrl: state.goodsDetailData.image,
|
||||
path: state.shareUrl
|
||||
}
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
data['token'] = uni.getStorageSync(UserToken)
|
||||
});
|
||||
onShareTimeline(() => {
|
||||
return {
|
||||
title: state.goodsDetailData.name,
|
||||
imageUrl: state.goodsDetailData.image,
|
||||
path: state.shareUrl
|
||||
}
|
||||
const share = await queryShare(data);
|
||||
if (share.status) {
|
||||
state.shareUrl = share.data;
|
||||
|
||||
} else {
|
||||
handleShowToast(share.msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// /** 分享 */
|
||||
// onShareAppMessage(() => {
|
||||
// return {
|
||||
// title: state.goodsDetailData.name,
|
||||
// imageUrl: state.goodsDetailData.image,
|
||||
// path: state.shareUrl
|
||||
// }
|
||||
// });
|
||||
// onShareTimeline(() => {
|
||||
// return {
|
||||
// title: state.goodsDetailData.name,
|
||||
// imageUrl: state.goodsDetailData.image,
|
||||
// path: state.shareUrl
|
||||
// }
|
||||
// });
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -25,15 +25,16 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import { onPageScroll, onShow } from '@dcloudio/uni-app';
|
||||
import { onPageScroll, onShow, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
|
||||
import { queryPageConfig, queryUserInfo } from '@/core/api';
|
||||
import type { Response, PageConfigType, PageConfigItemsType, UserInfoType } from '@/core/models';
|
||||
import CustomPage from '@/pages/components/custom-page/index.vue';
|
||||
import HomeAdpop from '@/pages/components/custom-page/components/home-adpop/home-adpop.vue';
|
||||
import { handleStaticResources, handleRouteNavigateTo } from '@/core/utils';
|
||||
import { handleStaticResources, handleRouteNavigateTo, getShareUrl, getDefaultShareData } from '@/core/utils';
|
||||
import { useSystemInfo, useLoadingFn } from '@/core/hooks';
|
||||
import { UserToken, onHomePageShow } from '@/core/consts';
|
||||
import { UserToken, onHomePageShow, shareUrl } from '@/core/consts';
|
||||
import { useUserInfoStore, useShopConfigStore } from '@/core/store';
|
||||
import { ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum';
|
||||
|
||||
/** 获取项目配置 */
|
||||
const shopConfigStore = useShopConfigStore();
|
||||
@@ -52,10 +53,12 @@
|
||||
coreshopData : Array<PageConfigItemsType>;
|
||||
isScrollTop : boolean;
|
||||
showPage : boolean;
|
||||
shareUrl : string;
|
||||
}>({
|
||||
coreshopData: [],
|
||||
isScrollTop: false,
|
||||
showPage: false,
|
||||
shareUrl: "",
|
||||
})
|
||||
|
||||
onShow(() => {
|
||||
@@ -63,11 +66,18 @@
|
||||
uni.$emit(onHomePageShow);
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
onMounted(async () => {
|
||||
handleuQueryPageConfig()
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
getUserInfo();
|
||||
}
|
||||
|
||||
state.shareUrl = await getShareUrl({
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.index,
|
||||
})
|
||||
})
|
||||
|
||||
async function getPageConfig() {
|
||||
@@ -82,7 +92,7 @@
|
||||
/** 获取用户信息 */
|
||||
const getUserInfo = async () => {
|
||||
const userInfo : Response<UserInfoType> = await queryUserInfo();
|
||||
if(userInfo.status){
|
||||
if (userInfo.status) {
|
||||
userInfoStore.setUserInfo(userInfo?.data);
|
||||
}
|
||||
}
|
||||
@@ -91,6 +101,22 @@
|
||||
const handleSearch = () => {
|
||||
handleRouteNavigateTo('/pages/search/search')
|
||||
}
|
||||
|
||||
/** 分享 */
|
||||
onShareAppMessage(() => {
|
||||
return {
|
||||
title: getDefaultShareData().title,
|
||||
imageUrl: getDefaultShareData().imageUrl,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
onShareTimeline(() => {
|
||||
return {
|
||||
title: getDefaultShareData().title,
|
||||
imageUrl: getDefaultShareData().imageUrl,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -164,8 +164,8 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { reactive } from 'vue';
|
||||
import { onPageScroll, onShow } from '@dcloudio/uni-app';
|
||||
import { handleStaticResources, handleRouteNavigateTo, handleShowToast, handleRouteSwitchTab, hanldeShowModal } from '@/core/utils';
|
||||
import { onPageScroll, onShow ,onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
|
||||
import { handleStaticResources, handleRouteNavigateTo, handleShowToast, handleRouteSwitchTab, hanldeShowModal ,getDefaultShareData} from '@/core/utils';
|
||||
import { queryUserInfo, queryOrderStatusNum, queryUserIsClerk, queryDistributionInfo, queryAgentInfo, queryShopConfigV2 } from '@/core/api';
|
||||
import type { Response, MemberOrderType, UserInfoType, UserIsClerkType, MemberServiceType, ShopConfigType } from '@/core/models';
|
||||
import { useShopConfigStore, useUserInfoStore, useLoginStore } from '@/core/store';
|
||||
@@ -335,9 +335,24 @@
|
||||
userInfoStore.setUserInfo({});
|
||||
handleRouteSwitchTab(RouteSwitchTabEnum.home)
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
/** 分享 */
|
||||
onShareAppMessage(() => {
|
||||
return {
|
||||
title: getDefaultShareData().title,
|
||||
imageUrl: getDefaultShareData().imageUrl,
|
||||
path: 'pages/member/member'
|
||||
}
|
||||
});
|
||||
onShareTimeline(() => {
|
||||
return {
|
||||
title: getDefaultShareData().title,
|
||||
imageUrl: getDefaultShareData().imageUrl,
|
||||
path: 'pages/member/member'
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { handleRouteSwitchTab, handleRouteNavigateTo, handleShowToast } from '@/core/utils';
|
||||
import { handleRouteSwitchTab, handleRouteRedirectTo, handleShowToast } from '@/core/utils';
|
||||
import { queryDeshare } from '@/core/api';
|
||||
import type { Response } from '@/core/models';
|
||||
import { Invitecode } from '@/core/consts';
|
||||
@@ -22,17 +22,19 @@
|
||||
|
||||
const handleShare = async (code : string | number) => {
|
||||
const shareData : Response<any> = await queryDeshare({ code, });
|
||||
console.log('123',shareData)
|
||||
|
||||
if (shareData.status) {
|
||||
uni.setStorageSync(Invitecode, shareData.data?.userShareCode);
|
||||
switch (shareData.data?.page) {
|
||||
switch (Number(shareData.data?.page)) {
|
||||
/** 首页*/
|
||||
case ShareEnum.index:
|
||||
handleRouteSwitchTab();
|
||||
break;
|
||||
/** 商品详情页*/
|
||||
case ShareEnum.goods:
|
||||
case ShareEnum.goods:
|
||||
if (shareData.data?.params?.goodsId) {
|
||||
handleRouteNavigateTo(`/pages/goods/detail?id=${shareData.data?.params?.goodsId}`)
|
||||
handleRouteRedirectTo(`/pages/goods/detail?id=${shareData.data?.params?.goodsId}`)
|
||||
} else {
|
||||
handleRouteSwitchTab();
|
||||
}
|
||||
@@ -40,7 +42,7 @@
|
||||
/** 拼团详情页*/
|
||||
case ShareEnum.pinTuan:
|
||||
if (shareData.data?.params?.groupId && shareData.data?.params?.teamId) {
|
||||
handleRouteNavigateTo(`/pages/subpackage/activity/pinTuan/detail/detail?id=${shareData.data?.params?.groupId}&teamId=${shareData.data?.params?.teamId}`)
|
||||
handleRouteRedirectTo(`/pages/subpackage/activity/pinTuan/detail/detail?id=${shareData.data?.params?.groupId}&teamId=${shareData.data?.params?.teamId}`)
|
||||
} else {
|
||||
handleRouteSwitchTab();
|
||||
}
|
||||
@@ -52,7 +54,7 @@
|
||||
/** 文章页面 */
|
||||
case ShareEnum.article:
|
||||
if (shareData.data?.params?.articleId) {
|
||||
handleRouteNavigateTo(`/pages/subpackage/article/category/category?id=${shareData.data?.params?.articleId}&idType=${shareData.data?.params?.articleType}`)
|
||||
handleRouteRedirectTo(`/pages/subpackage/article/category/category?id=${shareData.data?.params?.articleId}&idType=${shareData.data?.params?.articleType}`)
|
||||
} else {
|
||||
handleRouteSwitchTab();
|
||||
}
|
||||
@@ -60,7 +62,7 @@
|
||||
/** 参团页面 */
|
||||
case ShareEnum.addPinTuan:
|
||||
if (shareData.data?.params?.groupId && shareData.data?.params?.teamId) {
|
||||
handleRouteNavigateTo(`/pages/subpackage/activity/pinTuan/detail/detail?id=${shareData.data?.params?.groupId}&teamId=${shareData.data?.params?.teamId}`)
|
||||
handleRouteRedirectTo(`/pages/subpackage/activity/pinTuan/detail/detail?id=${shareData.data?.params?.groupId}&teamId=${shareData.data?.params?.teamId}`)
|
||||
} else {
|
||||
handleRouteSwitchTab();
|
||||
}
|
||||
@@ -68,7 +70,7 @@
|
||||
/** 自定义页面 */
|
||||
case ShareEnum.page:
|
||||
if (shareData.data?.params?.pageCode) {
|
||||
handleRouteNavigateTo(`/pages/subpackage/custom/custom?code=${shareData.data?.params?.pageCode}`)
|
||||
handleRouteRedirectTo(`/pages/subpackage/custom/custom?code=${shareData.data?.params?.pageCode}`)
|
||||
} else {
|
||||
handleRouteSwitchTab();
|
||||
}
|
||||
@@ -76,7 +78,7 @@
|
||||
/** 智能表单 */
|
||||
case ShareEnum.form:
|
||||
if (shareData.data?.params?.id) {
|
||||
handleRouteNavigateTo(`/pages/subpackage/form/detail/detail?id=${shareData.data?.params?.id}`)
|
||||
handleRouteRedirectTo(`/pages/subpackage/form/detail/detail?id=${shareData.data?.params?.id}`)
|
||||
} else {
|
||||
handleRouteSwitchTab();
|
||||
}
|
||||
@@ -84,7 +86,7 @@
|
||||
/** 团购 */
|
||||
case ShareEnum.group:
|
||||
if (shareData.data?.params?.groupId) {
|
||||
handleRouteNavigateTo(`/pages/subpackage/activity/groupBuying/detail/detail?id=${shareData.data?.params?.groupId}`)
|
||||
handleRouteRedirectTo(`/pages/subpackage/activity/groupBuying/detail/detail?id=${shareData.data?.params?.groupId}`)
|
||||
} else {
|
||||
handleRouteSwitchTab();
|
||||
}
|
||||
@@ -92,7 +94,7 @@
|
||||
/** 秒杀 */
|
||||
case ShareEnum.seckill:
|
||||
if (shareData.data?.params?.groupId) {
|
||||
handleRouteNavigateTo(`/pages/subpackage/activity/seckill/detail/detail?id=${shareData.data?.params?.groupId}`)
|
||||
handleRouteRedirectTo(`/pages/subpackage/activity/seckill/detail/detail?id=${shareData.data?.params?.groupId}`)
|
||||
} else {
|
||||
handleRouteSwitchTab();
|
||||
}
|
||||
@@ -104,7 +106,7 @@
|
||||
/** 接龙*/
|
||||
case ShareEnum.solitaire:
|
||||
if (shareData.data?.params?.id) {
|
||||
handleRouteNavigateTo(`/pages/subpackage/activity/solitaire/detail/detail?id=${shareData.data?.params?.id}`)
|
||||
handleRouteRedirectTo(`/pages/subpackage/activity/solitaire/detail/detail?id=${shareData.data?.params?.id}`)
|
||||
} else {
|
||||
handleRouteSwitchTab();
|
||||
}
|
||||
@@ -112,7 +114,7 @@
|
||||
/** 服务商品*/
|
||||
case ShareEnum.serviceGoods:
|
||||
if (shareData.data?.params?.serviceGoodsId) {
|
||||
handleRouteNavigateTo(`/pages/subpackage/serviceGoods/detail/detail?id=${shareData.data?.params?.serviceGoodsId}`)
|
||||
handleRouteRedirectTo(`/pages/subpackage/serviceGoods/detail/detail?id=${shareData.data?.params?.serviceGoodsId}`)
|
||||
} else {
|
||||
handleRouteSwitchTab();
|
||||
}
|
||||
|
||||
@@ -63,12 +63,12 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref } from 'vue';
|
||||
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
|
||||
import { queryActivityDetial, queryCartNum, queryShare, queryAddCart } from '@/core/api';
|
||||
import { queryActivityDetial, queryCartNum, queryAddCart } from '@/core/api';
|
||||
import { PaymentTypeEnum, ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum';
|
||||
import type { Response } from '@/core/models';
|
||||
import { UserToken, shareUrl } from '@/core/consts'
|
||||
import { useCartStore, useLoginStore } from '@/core/store';
|
||||
import { handleShowToast, handleRouteNavigateTo } from '@/core/utils';
|
||||
import { handleShowToast, handleRouteNavigateTo, getShareUrl } from '@/core/utils';
|
||||
import GoodsDetail from '@/pages/components/goods-detail/index.vue';
|
||||
import GoodsDetailRecommend from '@/pages/components/goods-detail/components/goods-detail-recommend/goods-detail-recommend.vue';
|
||||
import GoodsDetailSkuPopup from '@/pages/components/goods-detail/components/goods-detail-sku/goods-detail-sku.vue';
|
||||
@@ -152,7 +152,16 @@
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
getCartNum();
|
||||
}
|
||||
getShareUrl();
|
||||
|
||||
state.shareUrl = await getShareUrl({
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.group,
|
||||
params: {
|
||||
groupId: state.id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 获取购物车数量 */
|
||||
@@ -196,28 +205,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取分享url */
|
||||
const getShareUrl = async () => {
|
||||
let data = {
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.group,
|
||||
params: {
|
||||
groupId: state.id
|
||||
}
|
||||
}
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
data['token'] = uni.getStorageSync(UserToken)
|
||||
}
|
||||
const share = await queryShare(data);
|
||||
if (share.status) {
|
||||
state.shareUrl = share.data
|
||||
} else {
|
||||
handleShowToast(share.msg);
|
||||
}
|
||||
}
|
||||
|
||||
/** 分享 */
|
||||
onShareAppMessage(() => {
|
||||
return {
|
||||
|
||||
@@ -70,13 +70,13 @@
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { onLoad ,onShareAppMessage,onShareTimeline} from '@dcloudio/uni-app';
|
||||
import { queryPinTuanGoodsDetail, queryCartNum, queryAddCart, queryOrderPinTuanTeamInfo } from '@/core/api';
|
||||
import type { Response } from '@/core/models';
|
||||
import { UserToken } from '@/core/consts'
|
||||
import { UserToken,shareUrl } from '@/core/consts'
|
||||
import { useCartStore, useLoginStore } from '@/core/store';
|
||||
import { PaymentTypeEnum, ShareEnum } from '@/core/enum';
|
||||
import { handleRouteNavigateTo, handleShowToast } from '@/core/utils';
|
||||
import { PaymentTypeEnum, ShareEnum,ShareClientEnum,ShareModelEnum } from '@/core/enum';
|
||||
import { handleRouteNavigateTo, handleShowToast ,getShareUrl} from '@/core/utils';
|
||||
import { deepClone } from '@/uni_modules/uv-ui-tools/libs/function/index.js';
|
||||
|
||||
import GoodsDetail from '@/pages/components/goods-detail/index.vue';
|
||||
@@ -109,6 +109,7 @@
|
||||
isSingleBuy : boolean;
|
||||
btnBuyTitlt : string;
|
||||
teamInfo : any;
|
||||
shareUrl:string;
|
||||
}>({
|
||||
id: 0,
|
||||
goodsDetailData: {},
|
||||
@@ -122,6 +123,7 @@
|
||||
isSingleBuy: true,
|
||||
btnBuyTitlt: "发起拼团",
|
||||
teamInfo: {},
|
||||
shareUrl:"",
|
||||
});
|
||||
|
||||
const loading = ref(false);
|
||||
@@ -129,6 +131,7 @@
|
||||
|
||||
onLoad((query : QueryParams) => {
|
||||
if (query?.teamId) {
|
||||
state.teamId = query?.teamId;
|
||||
state.goodsDetailData = {
|
||||
teamId: query?.teamId
|
||||
};
|
||||
@@ -172,6 +175,18 @@
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
getCartNum();
|
||||
}
|
||||
|
||||
state.shareUrl = await getShareUrl({
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.pinTuan,
|
||||
params: {
|
||||
groupId: state.id,
|
||||
goodsId: state.goodsDetailData.id,
|
||||
teamId: state.teamId
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 获取通过分享进来的拼团数据 */
|
||||
@@ -266,6 +281,22 @@
|
||||
handleShowToast(addCart.msg);
|
||||
}
|
||||
}
|
||||
|
||||
/** 分享 */
|
||||
onShareAppMessage(() => {
|
||||
return {
|
||||
title: state.goodsDetailData.name,
|
||||
imageUrl: state.goodsDetailData.image,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
onShareTimeline(() => {
|
||||
return {
|
||||
title: state.goodsDetailData.name,
|
||||
imageUrl: state.goodsDetailData.image,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import './detail.scss';
|
||||
|
||||
@@ -62,12 +62,12 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref } from 'vue';
|
||||
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
|
||||
import { queryActivityDetial, queryCartNum, queryShare, queryAddCart, queryUserInfo } from '@/core/api';
|
||||
import { queryActivityDetial, queryCartNum, queryShare, queryAddCart } from '@/core/api';
|
||||
import { PaymentTypeEnum, ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum';
|
||||
import type { Response } from '@/core/models';
|
||||
import { UserToken, shareUrl } from '@/core/consts'
|
||||
import { useCartStore, useLoginStore } from '@/core/store';
|
||||
import { handleShowToast, handleRouteNavigateTo } from '@/core/utils';
|
||||
import { handleShowToast, handleRouteNavigateTo, getShareUrl } from '@/core/utils';
|
||||
|
||||
import GoodsDetail from '@/pages/components/goods-detail/index.vue';
|
||||
import GoodsDetailRecommend from '@/pages/components/goods-detail/components/goods-detail-recommend/goods-detail-recommend.vue';
|
||||
@@ -152,7 +152,16 @@
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
getCartNum();
|
||||
}
|
||||
getShareUrl();
|
||||
|
||||
state.shareUrl = await getShareUrl({
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.seckill,
|
||||
params: {
|
||||
groupId: state.id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 获取购物车数量 */
|
||||
@@ -196,28 +205,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取分享url */
|
||||
const getShareUrl = async () => {
|
||||
let data = {
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.seckill,
|
||||
params: {
|
||||
groupId: state.id
|
||||
}
|
||||
}
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
data['token'] = uni.getStorageSync(UserToken)
|
||||
}
|
||||
const share = await queryShare(data);
|
||||
if (share.status) {
|
||||
state.shareUrl = share.data
|
||||
} else {
|
||||
handleShowToast(share.msg);
|
||||
}
|
||||
}
|
||||
|
||||
/** 分享 */
|
||||
onShareAppMessage(() => {
|
||||
return {
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
import type { Response } from '@/core/models';
|
||||
import { UserToken, shareUrl } from '@/core/consts'
|
||||
import { useShopConfigStore, useLoginStore } from '@/core/store';
|
||||
import { handleShowToast, handleRouteNavigateTo } from '@/core/utils';
|
||||
import { handleShowToast, handleRouteNavigateTo, getShareUrl } from '@/core/utils';
|
||||
import { timeFormat } from '@/uni_modules/uv-ui-tools/libs/function/index.js';
|
||||
import CoreshopShare from '@/components/coreshop-share/coreshop-share.vue';
|
||||
|
||||
@@ -154,7 +154,16 @@
|
||||
} else {
|
||||
handleShowToast(solitaireData.msg)
|
||||
}
|
||||
getShareUrl();
|
||||
|
||||
state.shareUrl = await getShareUrl({
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.solitaire,
|
||||
params: {
|
||||
id: state.solitaireInfo.id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 步进器变化 */
|
||||
@@ -232,28 +241,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取分享url */
|
||||
const getShareUrl = async () => {
|
||||
let data = {
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.solitaire,
|
||||
params: {
|
||||
id: state.solitaireInfo.id
|
||||
}
|
||||
}
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
data['token'] = uni.getStorageSync(UserToken)
|
||||
}
|
||||
const share = await queryShare(data);
|
||||
if (share.status) {
|
||||
state.shareUrl = share.data
|
||||
} else {
|
||||
handleShowToast(share.msg);
|
||||
}
|
||||
}
|
||||
|
||||
/** 分享弹框显示与否 */
|
||||
const handleToggleShowShare = () => {
|
||||
_useLoginStore.checkLogin(() => {
|
||||
|
||||
@@ -123,7 +123,7 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive } from 'vue';
|
||||
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
|
||||
import { handleStaticResources, handleRouteNavigateTo, handleRouteRedirectTo, handleShowToast } from '@/core/utils';
|
||||
import { handleStaticResources, handleRouteNavigateTo, handleRouteRedirectTo, handleShowToast, getShareUrl } from '@/core/utils';
|
||||
import { useShopConfigStore } from '@/core/store';
|
||||
import type { Response, UserInfoType } from '@/core/models';
|
||||
import { queryAgentInfo, queryUserInfo, queryShare } from '@/core/api';
|
||||
@@ -165,7 +165,16 @@
|
||||
if (info.data?.verifyStatus != AgentApplyStatus.success) {
|
||||
handleRouteRedirectTo('/pages/subpackage/distribution/apply/index');
|
||||
}
|
||||
getShareUrl();
|
||||
|
||||
state.shareUrl = await getShareUrl({
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.inv,
|
||||
params: {
|
||||
store: state.info.store
|
||||
}
|
||||
})
|
||||
} else {
|
||||
handleShowToast(info.msg)
|
||||
}
|
||||
@@ -195,28 +204,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取分享url */
|
||||
const getShareUrl = async () => {
|
||||
let data = {
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.inv,
|
||||
params: {
|
||||
store: state.info.store
|
||||
}
|
||||
}
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
data['token'] = uni.getStorageSync(UserToken)
|
||||
}
|
||||
const share = await queryShare(data);
|
||||
if (share.status) {
|
||||
state.shareUrl = share.data
|
||||
} else {
|
||||
handleShowToast(share.msg);
|
||||
}
|
||||
}
|
||||
|
||||
/** 分享 */
|
||||
onShareAppMessage(() => {
|
||||
return {
|
||||
|
||||
@@ -78,7 +78,7 @@
|
||||
import { reactive } from 'vue';
|
||||
import { onLoad, onReachBottom, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
|
||||
import { queryAgentStoreInfot, queryShare, queryAgentGoodsPageList } from '@/core/api';
|
||||
import { handleStaticResources, splitArrayByStep, handleShowToast, handleRouteNavigateTo } from '@/core/utils';
|
||||
import { handleStaticResources, splitArrayByStep, handleShowToast, handleRouteNavigateTo, getShareUrl } from '@/core/utils';
|
||||
import type { Response, GoodsType } from '@/core/models';
|
||||
import { ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum';
|
||||
import { shareUrl, UserToken } from '@/core/consts';
|
||||
@@ -112,11 +112,20 @@
|
||||
bannerList: [],
|
||||
})
|
||||
|
||||
onLoad((query : QueryParams) => {
|
||||
onLoad(async (query : QueryParams) => {
|
||||
state.storeId = query.store;
|
||||
getAgentInfo();
|
||||
getShareUrl();
|
||||
getGoodsPageList();
|
||||
|
||||
state.shareUrl = await getShareUrl({
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.agent,
|
||||
params: {
|
||||
store: state.storeId
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
onReachBottom(() => {
|
||||
@@ -201,40 +210,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取分享url */
|
||||
const getShareUrl = async () => {
|
||||
let data = {
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.agent,
|
||||
params: {
|
||||
store: state.storeId
|
||||
}
|
||||
}
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
data['token'] = uni.getStorageSync(UserToken)
|
||||
}
|
||||
const share = await queryShare(data);
|
||||
if (share.status) {
|
||||
state.shareUrl = share.data
|
||||
} else {
|
||||
handleShowToast(share.msg);
|
||||
}
|
||||
}
|
||||
|
||||
/** 分享 */
|
||||
onShareAppMessage(() => {
|
||||
return {
|
||||
title: shopConfigStore.config.shareTitle,
|
||||
imageUrl: shopConfigStore.config.shareImage,
|
||||
title: state.storeInfo?.storeName ? state.storeInfo?.storeName : shopConfigStore.config.shareTitle,
|
||||
imageUrl: state.storeInfo?.storeLogo ? state.storeInfo?.storeLogo : shopConfigStore.config.shareImage,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
onShareTimeline(() => {
|
||||
return {
|
||||
title: shopConfigStore.config.shareTitle,
|
||||
imageUrl: shopConfigStore.config.shareImage,
|
||||
title: state.storeInfo?.storeName ? state.storeInfo?.storeName : shopConfigStore.config.shareTitle,
|
||||
imageUrl: state.storeInfo?.storeLogo ? state.storeInfo?.storeLogo : shopConfigStore.config.shareImage,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
|
||||
import { queryArticleDetail, queryShare, queryNoticeInfo, queryMessageDetil } from '@/core/api';
|
||||
import type { Response, NoticeType } from '@/core/models';
|
||||
import { handleShowToast, handleRouteSwitchTab } from '@/core/utils';
|
||||
import { handleShowToast, handleRouteSwitchTab ,getShareUrl} from '@/core/utils';
|
||||
import { ShareClientEnum, ShareModelEnum, ShareEnum, ArticleDetailEnum } from '@/core/enum';
|
||||
import { UserToken, shareUrl } from '@/core/consts'
|
||||
|
||||
@@ -30,15 +30,16 @@
|
||||
idType : number;
|
||||
id : number;
|
||||
title : string;
|
||||
shareUrl:string;
|
||||
}>({
|
||||
articleDetail: {},
|
||||
idType: 1,
|
||||
id: 0,
|
||||
title: "文章详情"
|
||||
|
||||
title: "文章详情",
|
||||
shareUrl:"",
|
||||
})
|
||||
|
||||
onLoad((query : QueryParams) => {
|
||||
onLoad(async (query : QueryParams) => {
|
||||
state.idType = query?.idType || 1;
|
||||
state.id = query?.id || 0;
|
||||
|
||||
@@ -59,8 +60,17 @@
|
||||
handleRouteSwitchTab();
|
||||
})
|
||||
}
|
||||
/** 获取分享url */
|
||||
getShareUrl();
|
||||
/** 获取分享url */
|
||||
state.shareUrl = await getShareUrl({
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.article,
|
||||
params: {
|
||||
articleId: state.id,
|
||||
articleType: state.idType
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
/** 获取文章详情 */
|
||||
@@ -103,41 +113,18 @@
|
||||
} else {
|
||||
handleShowToast(articleDetail.msg)
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取分享url */
|
||||
const getShareUrl = async () => {
|
||||
let data = {
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.article,
|
||||
params: {
|
||||
articleId: state.id,
|
||||
articleType: state.idType
|
||||
}
|
||||
}
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
data['token'] = uni.getStorageSync(UserToken)
|
||||
}
|
||||
const share = await queryShare(data);
|
||||
if (share.status) {
|
||||
state.shareUrl = share.data
|
||||
} else {
|
||||
handleShowToast(share.msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 分享 */
|
||||
onShareAppMessage(() => {
|
||||
return {
|
||||
title: state.noticeInfo.name,
|
||||
title: state.articleDetail.title,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
onShareTimeline(() => {
|
||||
return {
|
||||
title: state.noticeInfo.name,
|
||||
title: state.articleDetail.title,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
|
||||
@@ -32,16 +32,17 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onPageScroll, onLoad } from '@dcloudio/uni-app';
|
||||
import { onPageScroll, onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
|
||||
import { reactive } from 'vue';
|
||||
import { queryPageConfig, queryUserInfo } from '@/core/api';
|
||||
import type { Response, PageConfigType, PageConfigItemsType, UserInfoType } from '@/core/models';
|
||||
import CustomPage from '@/pages/components/custom-page/index.vue';
|
||||
import HomeAdpop from '@/pages/components/custom-page/components/home-adpop/home-adpop.vue';
|
||||
import { handleStaticResources } from '@/core/utils';
|
||||
import { handleStaticResources, getDefaultShareData, getShareUrl } from '@/core/utils';
|
||||
import { useSystemInfo } from '@/core/hooks';
|
||||
import { UserToken } from '@/core/consts';
|
||||
import { UserToken, shareUrl } from '@/core/consts';
|
||||
import { useUserInfoStore } from '@/core/store';
|
||||
import { ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum';
|
||||
|
||||
interface QueryParams {
|
||||
code : string;
|
||||
@@ -55,9 +56,11 @@
|
||||
const state = reactive<{
|
||||
coreshopData : Array<PageConfigItemsType>;
|
||||
isScrollTop : boolean;
|
||||
shareUrl : string;
|
||||
}>({
|
||||
coreshopData: [],
|
||||
isScrollTop: false,
|
||||
shareUrl: "",
|
||||
})
|
||||
|
||||
onPageScroll((e : any) => {
|
||||
@@ -68,11 +71,18 @@
|
||||
}
|
||||
})
|
||||
|
||||
onLoad((query : QueryParams) => {
|
||||
onLoad(async (query : QueryParams) => {
|
||||
getPageConfig(query?.code);
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
getUserInfo();
|
||||
}
|
||||
|
||||
state.shareUrl = await getShareUrl({
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.index,
|
||||
})
|
||||
})
|
||||
|
||||
const getPageConfig = async (code : string) => {
|
||||
@@ -83,10 +93,26 @@
|
||||
/** 获取用户信息 */
|
||||
const getUserInfo = async () => {
|
||||
const userInfo : Response<UserInfoType> = await queryUserInfo();
|
||||
if(userInfo.status){
|
||||
if (userInfo.status) {
|
||||
userInfoStore.setUserInfo(userInfo?.data);
|
||||
}
|
||||
}
|
||||
|
||||
/** 分享 */
|
||||
onShareAppMessage(() => {
|
||||
return {
|
||||
title: getDefaultShareData().title,
|
||||
imageUrl: getDefaultShareData().imageUrl,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
onShareTimeline(() => {
|
||||
return {
|
||||
title: getDefaultShareData().title,
|
||||
imageUrl: getDefaultShareData().imageUrl,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
@@ -126,7 +126,7 @@
|
||||
import { reactive } from 'vue';
|
||||
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
|
||||
import { queryDistributionInfo, queryUserInfo, queryShare } from '@/core/api';
|
||||
import { handleShowToast, handleStaticResources, handleRouteNavigateTo, handleRouteRedirectTo } from '@/core/utils';
|
||||
import { handleShowToast, handleStaticResources, handleRouteNavigateTo, handleRouteRedirectTo, getShareUrl } from '@/core/utils';
|
||||
import type { Response, UserInfoType } from '@/core/models';
|
||||
import { DistributionApplyStatus, OpenDistributionEnum, ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum';
|
||||
import { useShopConfigStore } from '@/core/store';
|
||||
@@ -167,7 +167,16 @@
|
||||
if (info.data?.verifyStatus != DistributionApplyStatus.success) {
|
||||
handleRouteRedirectTo('/pages/subpackage/distribution/apply/index');
|
||||
}
|
||||
getShareUrl();
|
||||
|
||||
state.shareUrl = await getShareUrl({
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.inv,
|
||||
params: {
|
||||
store: state.info.store
|
||||
}
|
||||
})
|
||||
} else {
|
||||
handleShowToast(info.msg)
|
||||
}
|
||||
@@ -196,40 +205,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取分享url */
|
||||
const getShareUrl = async () => {
|
||||
let data = {
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.inv,
|
||||
params: {
|
||||
store: state.info.store
|
||||
}
|
||||
}
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
data['token'] = uni.getStorageSync(UserToken)
|
||||
}
|
||||
const share = await queryShare(data);
|
||||
if (share.status) {
|
||||
state.shareUrl = share.data
|
||||
} else {
|
||||
handleShowToast(share.msg);
|
||||
}
|
||||
}
|
||||
|
||||
/** 分享 */
|
||||
onShareAppMessage(() => {
|
||||
return {
|
||||
title: shopConfigStore.config.shareTitle,
|
||||
imageUrl: shopConfigStore.config.shareImage,
|
||||
title: state.info?.storeName ? state.info?.storeName : shopConfigStore.config.shareTitle,
|
||||
imageUrl: state.info?.storeLogo ? state.info?.storeLogo : shopConfigStore.config.shareImage,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
onShareTimeline(() => {
|
||||
return {
|
||||
title: shopConfigStore.config.shareTitle,
|
||||
imageUrl: shopConfigStore.config.shareImage,
|
||||
title: state.info?.storeName ? state.info?.storeName : shopConfigStore.config.shareTitle,
|
||||
imageUrl: state.info?.storeLogo ? state.info?.storeLogo : shopConfigStore.config.shareImage,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
|
||||
@@ -112,11 +112,20 @@
|
||||
bannerList: [],
|
||||
})
|
||||
|
||||
onLoad((query : QueryParams) => {
|
||||
onLoad(async (query : QueryParams) => {
|
||||
state.storeId = query.store;
|
||||
getDistributionInfo();
|
||||
getShareUrl();
|
||||
getGoodsPageList();
|
||||
|
||||
state.shareUrl = await getShareUrl({
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.inv,
|
||||
params: {
|
||||
store: state.storeId
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
onReachBottom(() => {
|
||||
@@ -201,40 +210,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取分享url */
|
||||
const getShareUrl = async () => {
|
||||
let data = {
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.inv,
|
||||
params: {
|
||||
store: state.storeId
|
||||
}
|
||||
}
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
data['token'] = uni.getStorageSync(UserToken)
|
||||
}
|
||||
const share = await queryShare(data);
|
||||
if (share.status) {
|
||||
state.shareUrl = share.data
|
||||
} else {
|
||||
handleShowToast(share.msg);
|
||||
}
|
||||
}
|
||||
|
||||
/** 分享 */
|
||||
onShareAppMessage(() => {
|
||||
return {
|
||||
title: shopConfigStore.config.shareTitle,
|
||||
imageUrl: shopConfigStore.config.shareImage,
|
||||
title: state.storeInfo?.storeName ? state.storeInfo?.storeName : shopConfigStore.config.shareTitle,
|
||||
imageUrl: state.storeInfo?.storeLogo ? state.storeInfo?.storeLogo : shopConfigStore.config.shareImage,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
onShareTimeline(() => {
|
||||
return {
|
||||
title: shopConfigStore.config.shareTitle,
|
||||
imageUrl: shopConfigStore.config.shareImage,
|
||||
title: state.storeInfo?.storeName ? state.storeInfo?.storeName : shopConfigStore.config.shareTitle,
|
||||
imageUrl: state.storeInfo?.storeLogo ? state.storeInfo?.storeLogo : shopConfigStore.config.shareImage,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
|
||||
@@ -138,9 +138,9 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref } from 'vue';
|
||||
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
|
||||
import { queryFormDetial, queryUploadImages, queryAddSubmit, queryShare } from '@/core/api';
|
||||
import { queryFormDetial, queryUploadImages, queryAddSubmit } from '@/core/api';
|
||||
import type { Response, CityAddressType } from '@/core/models';
|
||||
import { handleShowToast, handleStaticResources, handleRouteRedirectTo, handleRouteSwitchTab, chooseImage, getSetting } from '@/core/utils';
|
||||
import { handleShowToast, handleStaticResources, handleRouteRedirectTo, handleRouteSwitchTab, chooseImage, getSetting, getShareUrl } from '@/core/utils';
|
||||
import { queryAreas } from '@/core/api';
|
||||
import { useLoginStore } from '@/core/store';
|
||||
import { UserToken, shareUrl } from '@/core/consts';
|
||||
@@ -244,34 +244,20 @@
|
||||
state.swiperList = formInfo.data?.images?.split(',') || [];
|
||||
|
||||
/** 获取分享url */
|
||||
getShareUrl();
|
||||
state.shareUrl = await getShareUrl({
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.form,
|
||||
params: {
|
||||
id: state.id
|
||||
}
|
||||
})
|
||||
} else {
|
||||
handleShowToast(formInfo.msg)
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取分享url */
|
||||
const getShareUrl = async () => {
|
||||
let data = {
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.form,
|
||||
params: {
|
||||
id: state.id
|
||||
}
|
||||
}
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
data['token'] = uni.getStorageSync(UserToken)
|
||||
}
|
||||
const share = await queryShare(data);
|
||||
if (share.status) {
|
||||
state.shareUrl = share.data
|
||||
} else {
|
||||
handleShowToast(share.msg);
|
||||
}
|
||||
}
|
||||
|
||||
/** 组合商品数据传入组件 */
|
||||
const hanldeCombinationGoodsData = (item : any) => {
|
||||
return {
|
||||
|
||||
@@ -14,26 +14,36 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive } from 'vue';
|
||||
import { onLoad, onShareAppMessage, onShareTimeline } from '@dcloudio/uni-app';
|
||||
import { queryNoticeInfo, queryShare } from '@/core/api';
|
||||
import { queryNoticeInfo } from '@/core/api';
|
||||
import type { Response, NoticeType } from '@/core/models';
|
||||
import { handleShowToast } from '@/core/utils';
|
||||
import { handleShowToast, getShareUrl } from '@/core/utils';
|
||||
import { ShareClientEnum, ShareModelEnum, ShareEnum } from '@/core/enum';
|
||||
import { UserToken, shareUrl } from '@/core/consts'
|
||||
import { shareUrl } from '@/core/consts'
|
||||
|
||||
interface QueryParams {
|
||||
id : number;
|
||||
}
|
||||
const state = reactive<{
|
||||
noticeInfo : NoticeType;
|
||||
shareUrl : string;
|
||||
}>({
|
||||
noticeInfo: {},
|
||||
shareUrl: "",
|
||||
})
|
||||
|
||||
onLoad((query : QueryParams) => {
|
||||
onLoad(async (query : QueryParams) => {
|
||||
/** 获取文章详情 */
|
||||
getNoticeInfo(Number(query.id));
|
||||
/** 获取分享url */
|
||||
getShareUrl(Number(query.id));
|
||||
state.shareUrl = await getShareUrl({
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.article,
|
||||
params: {
|
||||
noticeId: String(query.id),
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
/** 获取文章详情 */
|
||||
@@ -50,38 +60,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
/** 获取分享url */
|
||||
const getShareUrl = async (noticeId : number) => {
|
||||
let data = {
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.article,
|
||||
params: {
|
||||
noticeId: String(noticeId),
|
||||
}
|
||||
}
|
||||
if (uni.getStorageSync(UserToken)) {
|
||||
data['token'] = uni.getStorageSync(UserToken)
|
||||
}
|
||||
const share = await queryShare(data);
|
||||
if (share.status) {
|
||||
state.shareUrl = share.data
|
||||
} else {
|
||||
handleShowToast(share.msg);
|
||||
}
|
||||
}
|
||||
|
||||
/** 分享 */
|
||||
onShareAppMessage(() => {
|
||||
return {
|
||||
title: state.noticeInfo.name,
|
||||
title: state.noticeInfo.title,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
onShareTimeline(() => {
|
||||
return {
|
||||
title: state.noticeInfo.name,
|
||||
title: state.noticeInfo.title,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
|
||||
@@ -82,16 +82,17 @@
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { reactive } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { onLoad ,onShareAppMessage,onShareTimeline} from '@dcloudio/uni-app';
|
||||
import type { Response, ServiceGoodsType } from '@/core/models';
|
||||
import { queryServiceDetail, queryAddServiceOrder } from '@/core/api';
|
||||
import { ServiceGoodsOpenEnum, ShareEnum, PaymentTypeEnum } from '@/core/enum';
|
||||
import { handleShowToast, handleRouteNavigateTo } from '@/core/utils';
|
||||
import { useUserInfoStore, useLoginStore } from '@/core/store';
|
||||
import { ServiceGoodsOpenEnum, ShareEnum, PaymentTypeEnum, ShareClientEnum, ShareModelEnum, } from '@/core/enum';
|
||||
import { handleShowToast, handleRouteNavigateTo,getShareUrl } from '@/core/utils';
|
||||
import { useLoginStore } from '@/core/store';
|
||||
import { shareUrl } from '@/core/consts';
|
||||
import GoodsDetail from '@/pages/components/goods-detail/index.vue';
|
||||
import GoodsDetailRecommend from '@/pages/components/goods-detail/components/goods-detail-recommend/goods-detail-recommend.vue';
|
||||
import GoodsDetailBottomTabbar from '@/pages/components/goods-detail/components/goods-detail-bottom-tabbar/goods-detail-bottom-tabbar.vue';
|
||||
|
||||
|
||||
interface QueryParams {
|
||||
id : number;
|
||||
}
|
||||
@@ -104,11 +105,13 @@
|
||||
goodsDetailData : ServiceGoodsType,
|
||||
swiperBanner : Array<string>;
|
||||
goodsDetailContent : string;
|
||||
shareUrl:string;
|
||||
}>({
|
||||
id: 0,
|
||||
goodsDetailData: {},
|
||||
swiperBanner: [],
|
||||
goodsDetailContent: "",
|
||||
shareUrl:"",
|
||||
});
|
||||
|
||||
onLoad((query : QueryParams) => {
|
||||
@@ -138,6 +141,16 @@
|
||||
state.swiperBanner = goodsDetail?.data?.thumbnail?.split(',');
|
||||
/** 商品详情内容 */
|
||||
state.goodsDetailContent = goodsDetail?.data?.contentBody;
|
||||
|
||||
state.shareUrl = await getShareUrl({
|
||||
client: ShareClientEnum.wxMiNiProgram,
|
||||
url: shareUrl,
|
||||
type: ShareModelEnum.url,
|
||||
page: ShareEnum.serviceGoods,
|
||||
params: {
|
||||
serviceGoodsId: state.id,
|
||||
}
|
||||
})
|
||||
} else {
|
||||
handleShowToast(goodsDetail.msg)
|
||||
}
|
||||
@@ -160,6 +173,22 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/** 分享 */
|
||||
onShareAppMessage(() => {
|
||||
return {
|
||||
title: state.goodsDetailData.title,
|
||||
imageUrl: state.goodsDetailData.thumbnail,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
onShareTimeline(() => {
|
||||
return {
|
||||
title: state.goodsDetailData.title,
|
||||
imageUrl: state.goodsDetailData.thumbnail,
|
||||
path: state.shareUrl
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
@import './detail.scss';
|
||||
|
||||
Reference in New Issue
Block a user