调整分享部分方法,修改点餐页分享
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<view class="relative">
|
||||
<slot v-if="$slots.default" name="default"></slot>
|
||||
<up-icon v-else name="share-square" bold color="#333" size="36rpx"></up-icon>
|
||||
<up-icon v-else name="share-square" bold :color="color" :size="size"></up-icon>
|
||||
<view class="absolute share-box">
|
||||
<button open-type="share" @click="shareClick">分享</button>
|
||||
</view>
|
||||
@@ -10,6 +10,16 @@
|
||||
|
||||
<script setup>
|
||||
const emits = defineEmits(['shareClick'])
|
||||
const props = defineProps({
|
||||
size: {
|
||||
type: String,
|
||||
default: '36rpx'
|
||||
},
|
||||
color:{
|
||||
type: String,
|
||||
default: '#333'
|
||||
}
|
||||
})
|
||||
|
||||
function shareClick() {
|
||||
emits('shareClick')
|
||||
|
||||
@@ -364,15 +364,15 @@
|
||||
await handleMixinOnLoad(options)
|
||||
console.log('shopInfo', uni.cache.get('shopInfo'));
|
||||
console.log('【页面】开始处理自身业务逻辑');
|
||||
setTimeout(() => {
|
||||
showPageLoading.value = false;
|
||||
getUnReadMsgCount();
|
||||
}, 800);
|
||||
|
||||
onPageShow()
|
||||
} else {
|
||||
onPageShow()
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
showPageLoading.value = false;
|
||||
getUnReadMsgCount();
|
||||
}, 800);
|
||||
});
|
||||
|
||||
async function onPageShow() {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</up-swiper>
|
||||
<view class="shop_sku_name u-flex u-row-between">
|
||||
<view class="u-line-1" style="max-width: 600rpx;">{{ goods.name }}</view>
|
||||
<ymfShare />
|
||||
<ymfShare @shareClick="shareClick" />
|
||||
</view>
|
||||
<view class="shop_sku_description" v-if="isSkuGoods">
|
||||
{{ goods.shortTitle ? goods.shortTitle : '' }}
|
||||
@@ -506,8 +506,10 @@
|
||||
swiperCurrent.value = e.current;
|
||||
}
|
||||
|
||||
const emits = defineEmits(['prveImgs', 'websocketsendMessage', 'close', 'modalAdd'])
|
||||
|
||||
const emits = defineEmits(['prveImgs', 'websocketsendMessage', 'close', 'modalAdd','shareClick'])
|
||||
function shareClick(){
|
||||
emits('shareClick',props.goods)
|
||||
}
|
||||
function prveImgs(images, currentUrl) {
|
||||
emits('prveImgs', images, currentUrl)
|
||||
}
|
||||
|
||||
@@ -573,17 +573,13 @@
|
||||
<Loading :isLoading="!useSocket.isConnected" />
|
||||
<ModalList></ModalList>
|
||||
<recommendGoodsModal v-if="isDataLoaded" @onBuyClick="onBuyClick"></recommendGoodsModal>
|
||||
|
||||
<view
|
||||
v-for="(item,index) in goodsModalList" :key="index"
|
||||
>
|
||||
<goodsModal :key="index" v-model="item.show" :goods="item.goods" @prveImgs="prveImgs" @close="goodsModalClose(index)"
|
||||
@websocketsendMessage="websocketsendMessage"
|
||||
@modalAdd="modalAdd"
|
||||
:GoodsIDInCartNumMap="GoodsIDInCartNumMap"
|
||||
></goodsModal>
|
||||
|
||||
<view v-for="(item,index) in goodsModalList" :key="index">
|
||||
<goodsModal :key="index" v-model="item.show" :goods="item.goods" @prveImgs="prveImgs"
|
||||
@shareClick="shareClick" @close="goodsModalClose(index)" @websocketsendMessage="websocketsendMessage"
|
||||
@modalAdd="modalAdd" :GoodsIDInCartNumMap="GoodsIDInCartNumMap"></goodsModal>
|
||||
</view>
|
||||
|
||||
|
||||
<xbSwiperPreview :visable="showPrveImg" :imgs="prveImgsList" @update:visable="updateShowPrveImg">
|
||||
</xbSwiperPreview>
|
||||
<!-- 显示选择人数popup -->
|
||||
@@ -749,7 +745,9 @@
|
||||
useCartStore
|
||||
} from '@/stores/order.js';
|
||||
import {
|
||||
computed, provide, reactive
|
||||
computed,
|
||||
provide,
|
||||
reactive
|
||||
} from 'vue';
|
||||
const cartStore = useCartStore();
|
||||
/**
|
||||
@@ -874,11 +872,11 @@
|
||||
* 返回购物车对应的商品数量
|
||||
*/
|
||||
function returnGoodsImCartNum(goods) {
|
||||
if(!goods){
|
||||
if (!goods) {
|
||||
return 0
|
||||
}
|
||||
if (GoodsIDInCartNumMap.value.hasOwnProperty(goods.id)) {
|
||||
return GoodsIDInCartNumMap.value[goods.id]
|
||||
return GoodsIDInCartNumMap.value[goods.id]
|
||||
}
|
||||
return 0
|
||||
}
|
||||
@@ -1369,13 +1367,14 @@
|
||||
let res = await APIminiAppinfo(item.id);
|
||||
prveImgs(res.images);
|
||||
}
|
||||
|
||||
const goodsModalList=ref([])
|
||||
|
||||
function goodsModalClose(index){
|
||||
goodsModalList.value.splice(index,1)
|
||||
|
||||
const goodsModalList = ref([])
|
||||
|
||||
function goodsModalClose(index) {
|
||||
goodsModalList.value.splice(index, 1)
|
||||
}
|
||||
function modalAdd(item){
|
||||
|
||||
function modalAdd(item) {
|
||||
clickspecifications(item)
|
||||
}
|
||||
|
||||
@@ -1395,8 +1394,8 @@
|
||||
|
||||
if (item.isSoldStock == 1 || (item.isSaleTime == 0 && !item.isSaleTimeshow)) {
|
||||
return uni.showToast({
|
||||
title:'商品已下架或不在可售时间内',
|
||||
icon:'none'
|
||||
title: '商品已下架或不在可售时间内',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1444,11 +1443,12 @@
|
||||
specifications.item.amountcartNumber = 0;
|
||||
// showShopsku.value = true;
|
||||
goodsModalList.value.push({
|
||||
show:true,
|
||||
goods:{
|
||||
show: true,
|
||||
goods: {
|
||||
...specifications.item,
|
||||
/*过滤掉只有一个规格且下架的商品或者skuList为空的商品*/
|
||||
relatedRecommendJson:(specifications.item.relatedRecommendJson||[]).filter(v=>v.skuList&&v.skuList.length)
|
||||
relatedRecommendJson: (specifications.item.relatedRecommendJson || []).filter(v => v
|
||||
.skuList && v.skuList.length)
|
||||
}
|
||||
})
|
||||
};
|
||||
@@ -1685,20 +1685,20 @@
|
||||
// 返回商品对应sku数据
|
||||
|
||||
function cartInit(arr) {
|
||||
|
||||
|
||||
const result = []
|
||||
cartStore.carts = arr.map(v => {
|
||||
const goods = cartStore.allGoodsArr.find(g => g.id == v.product_id)
|
||||
const goodsSkuList = goods ? goods.skuList : []
|
||||
const findSku = goodsSkuList.find(sku => sku.id == v.sku_id)
|
||||
const memberPrice = findSku ? findSku.memberPrice : 0
|
||||
const is_temporary=v.is_temporary||v.isTemporary
|
||||
const is_temporary = v.is_temporary || v.isTemporary
|
||||
const is_time_discount = limitUtils.canUseLimitTimeDiscount({
|
||||
...v,
|
||||
memberPrice
|
||||
}, cartStore.limitTimeDiscount, shopInfo,
|
||||
shopUserInfo.value, 'product_id');
|
||||
if (!goods&&!is_temporary) {
|
||||
if (!goods && !is_temporary) {
|
||||
console.log('删除未匹配到的商品', {
|
||||
id: v.id,
|
||||
operate_type: "del",
|
||||
@@ -2195,7 +2195,7 @@
|
||||
// 列表请求
|
||||
const productqueryProduct = async () => {
|
||||
cartStore.goodsIsloading = false;
|
||||
allGoodsArr.value=[]
|
||||
allGoodsArr.value = []
|
||||
try {
|
||||
shopProductList.hots = await productminiApphotsquery();
|
||||
shopProductList.productInfo = await APIgroupquery();
|
||||
@@ -2238,7 +2238,7 @@
|
||||
// console.log('allGoodsArr', allGoodsArr);
|
||||
// console.log('shopProductList', shopProductList);
|
||||
console.log('cartStore.carts', cartStore.carts)
|
||||
cartStore.allGoodsArr=allGoodsArr.value
|
||||
cartStore.allGoodsArr = allGoodsArr.value
|
||||
if (cartStore.carts.length > 0) {
|
||||
cartInit(cartStore.carts);
|
||||
}
|
||||
@@ -2260,6 +2260,16 @@
|
||||
}, 1000);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (pageOptions.showGoodsId) {
|
||||
const item = allGoodsArr.value.find(v => v.id == pageOptions.showGoodsId)
|
||||
if (item) {
|
||||
clickspecifications(item)
|
||||
}
|
||||
pageOptions.showGoodsId = null
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
provide('cartStore', cartStore);
|
||||
@@ -2440,36 +2450,70 @@
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
import {
|
||||
shareMixin,
|
||||
handleMixinOnLoad,returnQuery
|
||||
handleMixinOnLoad,
|
||||
returnQuery,
|
||||
jsonToUrl,
|
||||
returnCommonQuery
|
||||
} from '@/utils/share.js'
|
||||
defineOptions({
|
||||
mixins: [shareMixin],
|
||||
});
|
||||
import { onShareTimeline } from '@dcloudio/uni-app';
|
||||
// defineOptions({
|
||||
// mixins: [shareMixin],
|
||||
// });
|
||||
|
||||
|
||||
let isGoodsShare = ref(false)
|
||||
|
||||
function shareClick() {
|
||||
isGoodsShare.value = true
|
||||
}
|
||||
|
||||
onShareAppMessage((res)=>{
|
||||
let query=returnQuery()
|
||||
query+='&type=beforehand'
|
||||
return {
|
||||
...res,
|
||||
...query,
|
||||
path: '/pages/product/index' + '?' + query,
|
||||
query,
|
||||
async function onShare(){
|
||||
const queryJson = await returnCommonQuery()
|
||||
let query = jsonToUrl(queryJson)
|
||||
query += '&type=beforehand'
|
||||
let json={}
|
||||
if (goodsModalList.value.length && isGoodsShare.value) {
|
||||
const goods = goodsModalList.value[goodsModalList.value.length - 1].goods
|
||||
query += '&showGoodsId=' + goods.id
|
||||
json.title = goods.name
|
||||
json.imageUrl = goods.coverImg
|
||||
json.showGoodsId = goods.id
|
||||
}else{
|
||||
json.title=uni.cache.get('shopInfo').shopName||''
|
||||
json.imageUrl=uni.cache.get('shopInfo').logo||''
|
||||
}
|
||||
})
|
||||
console.log('onShareAppMessage', {
|
||||
query,
|
||||
...json,
|
||||
path: '/pages/product/index' + '?' + query
|
||||
});
|
||||
return {
|
||||
query,
|
||||
...json,
|
||||
path: '/pages/product/index' + '?' + query
|
||||
}
|
||||
}
|
||||
|
||||
const pageOptions=reactive({})
|
||||
onShareAppMessage(onShare)
|
||||
|
||||
onShareTimeline(onShare)
|
||||
|
||||
const pageOptions = reactive({})
|
||||
onLoad(async (e) => {
|
||||
Object.assign(pageOptions,e)
|
||||
Object.assign(pageOptions, e)
|
||||
if (e.type) {
|
||||
orderType.value = e.type;
|
||||
}
|
||||
await handleMixinOnLoad(e)
|
||||
const userInfo= userStore.userInfo
|
||||
const shopInfoRes=userStore.shopInfo
|
||||
await handleMixinOnLoad({
|
||||
...e,
|
||||
shopId: e.shopId || uni.cache.get('shopId')
|
||||
})
|
||||
const userInfo = userStore.userInfo
|
||||
const shopInfoRes = userStore.shopInfo
|
||||
// //获取用户信息
|
||||
// const userInfo = await APIshopUserInfo({
|
||||
// shopId: uni.cache.get('shopId')
|
||||
@@ -2617,6 +2661,7 @@
|
||||
useSocket.setOnMessage(() => {});
|
||||
}
|
||||
onHide(() => {
|
||||
isGoodsShare.value=false
|
||||
closeSocket();
|
||||
});
|
||||
onUnload(() => {
|
||||
|
||||
@@ -31,8 +31,9 @@
|
||||
<view class="tab-item" :class="tabActive === 0 ? 'active' : ''" @click="tabActive = 0">优惠券</view>
|
||||
<view class="tab-item" :class="tabActive === 1 ? 'active' : ''" @click="tabActive = 1">其它商品</view>
|
||||
</view>
|
||||
<view class="u-flex" @click="toggleLayout">
|
||||
<view class="u-flex gap-20" @click="toggleLayout">
|
||||
<image :src="layout === 'block' ? imgs.layout_block : imgs.layout" class="layout" />
|
||||
<ymfShare size="40rpx" color="#9C571F"></ymfShare>
|
||||
</view>
|
||||
</view>
|
||||
<goodsList :pointsUser="pointsUser" :layout="layout" :list="list" @exchange="exchange"></goodsList>
|
||||
@@ -44,6 +45,7 @@
|
||||
</view>
|
||||
</template>
|
||||
<script setup>
|
||||
import ymfShare from '@/components/ymf-components/ymf-share.vue'
|
||||
import * as pointGoodsApi from "@/common/api/order/pointGoods.js";
|
||||
import goodsList from "./components/goods-list.vue";
|
||||
import {
|
||||
@@ -87,12 +89,13 @@
|
||||
// }
|
||||
|
||||
function toDetail() {
|
||||
if(!pointsUser.value||!pointsUser.value.id){
|
||||
return
|
||||
if (!pointsUser.value || !pointsUser.value.id) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
uni.navigateTo({
|
||||
url: '/pages/user/member/billDetails?type=2&shopId=' + query.shopId + '&id=' + (pointsUser.value?pointsUser.value.id :
|
||||
url: '/pages/user/member/billDetails?type=2&shopId=' + query.shopId + '&id=' + (pointsUser.value ?
|
||||
pointsUser.value.id :
|
||||
'')
|
||||
})
|
||||
}
|
||||
@@ -132,7 +135,21 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
onLoad((opt) => {
|
||||
|
||||
|
||||
import {
|
||||
shareMixin,
|
||||
handleMixinOnLoad
|
||||
} from '@/utils/share.js'
|
||||
defineOptions({
|
||||
mixins: [shareMixin],
|
||||
});
|
||||
|
||||
const options = reactive({
|
||||
|
||||
})
|
||||
onLoad(async (opt) => {
|
||||
Object.assign(options, opt)
|
||||
query.shopId = opt.shopId || ''
|
||||
})
|
||||
watch(() => tabActive.value, (newval, oldval) => {
|
||||
@@ -151,8 +168,19 @@
|
||||
query.page++
|
||||
getList();
|
||||
})
|
||||
onShow(() => {
|
||||
refresh()
|
||||
import {
|
||||
productStore
|
||||
} from '@/stores/user.js';
|
||||
const storeuser = productStore();
|
||||
|
||||
|
||||
onShow(async () => {
|
||||
if (!storeuser.isHasLogin) {
|
||||
await handleMixinOnLoad(options)
|
||||
refresh()
|
||||
} else {
|
||||
refresh()
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<style scoped lang="scss">
|
||||
@@ -163,7 +191,9 @@
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.gap-20{
|
||||
gap: 20rpx;
|
||||
}
|
||||
.top {
|
||||
padding: 138rpx 26rpx 48rpx 42rpx;
|
||||
display: flex;
|
||||
|
||||
@@ -547,12 +547,14 @@ export const productStore = defineStore("product", {
|
||||
},
|
||||
|
||||
async pageOnload() {
|
||||
console.log('开始加载必须数据')
|
||||
//登录
|
||||
await this.actionslogin()
|
||||
//获取会员信息
|
||||
await this.actionsproductqueryProduct()
|
||||
//获取店铺信息
|
||||
await this.getShopInfo()
|
||||
console.log('必须数据加载完毕')
|
||||
},
|
||||
async getShopInfo(shopId) {
|
||||
const shopRes = await APIusershopInfodetail({
|
||||
|
||||
@@ -62,7 +62,42 @@ export function wxShare(par) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function returnQuery(query) {
|
||||
export async function returnCommonQuery() {
|
||||
const shopId = uni.cache.get('shopId')
|
||||
const shopUserInfo = uni.cache.get('shopUserInfo')
|
||||
const shopInfo = uni.cache.get('shopInfo')
|
||||
const inviteCode = await autoGetInviteCode({
|
||||
shopId: shopId,
|
||||
shopUserId: shopUserInfo.id
|
||||
})
|
||||
|
||||
const queryJson = {
|
||||
inviteCode: (inviteCode && inviteCode !== true) ? inviteCode : null,
|
||||
shopId,
|
||||
shopUserId: shopUserInfo.id,
|
||||
}
|
||||
return Promise.resolve(queryJson)
|
||||
}
|
||||
|
||||
export function jsonToUrl(json) {
|
||||
let result = ''
|
||||
for (let key in json) {
|
||||
if (json[key]) {
|
||||
if (result === '') {
|
||||
result += `${key}=${json[key]}`
|
||||
} else {
|
||||
result += `&${key}=${json[key]}`
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} query 参数对象
|
||||
* @param {Array} showkeys 需要显示的key不包括公共参数
|
||||
*/
|
||||
export async function returnQuery(query, showkeys) {
|
||||
|
||||
|
||||
const shopId = uni.cache.get('shopId')
|
||||
@@ -88,7 +123,11 @@ export async function returnQuery(query) {
|
||||
}
|
||||
for (const key in currentOptions) {
|
||||
if (currentOptions.hasOwnProperty(key)) {
|
||||
queryJson[key] = encodeURIComponent(currentOptions[key])
|
||||
if (showkeys && Array.isArray(showkeys) && showkeys.includes(key)) {
|
||||
queryJson[key] = encodeURIComponent(currentOptions[key])
|
||||
} else {
|
||||
queryJson[key] = encodeURIComponent(currentOptions[key])
|
||||
}
|
||||
}
|
||||
}
|
||||
queryJson.shopId = shopId
|
||||
@@ -105,7 +144,7 @@ export async function returnQuery(query) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
return Promise.resolve(result)
|
||||
}
|
||||
|
||||
function parseQueryString(queryString) {
|
||||
@@ -211,7 +250,7 @@ export const shareMixin = {
|
||||
// queryJson.inviteCode = (inviteCode && inviteCode !== true) ? inviteCode : null
|
||||
// queryJson.shopUserId = shopUserInfo.id
|
||||
|
||||
const query = returnQuery()
|
||||
const query =await returnQuery()
|
||||
|
||||
|
||||
// 全局默认配置(可被页面覆盖)
|
||||
@@ -279,7 +318,7 @@ export const shareMixin = {
|
||||
// queryJson.inviteCode = (inviteCode && inviteCode !== true) ? inviteCode : null
|
||||
// queryJson.shopUserId = shopUserInfo.id
|
||||
|
||||
const query = returnQuery()
|
||||
const query = await returnQuery()
|
||||
|
||||
const defaultTimelineConfig = {
|
||||
title: shopInfo.shopName,
|
||||
|
||||
Reference in New Issue
Block a user