修复分享问题
This commit is contained in:
@@ -70,7 +70,7 @@
|
|||||||
v-else-if="item1.isTemporary &&item1.productName=='签子'"
|
v-else-if="item1.isTemporary &&item1.productName=='签子'"
|
||||||
src="https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/5/b97054debd83486ab7ad8e20ca6a360a.png"
|
src="https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/5/b97054debd83486ab7ad8e20ca6a360a.png"
|
||||||
></u-image>
|
></u-image>
|
||||||
<u-image width="112" height="112" radius="20"
|
<u-image width="56" height="56" radius="10"
|
||||||
:src="'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/table.png'"
|
:src="'https://czg-qr-order.oss-cn-beijing.aliyuncs.com/confirmOrder/table.png'"
|
||||||
mode="heightFix" v-else></u-image>
|
mode="heightFix" v-else></u-image>
|
||||||
<text class="productName"> {{ item1.productName }} </text>
|
<text class="productName"> {{ item1.productName }} </text>
|
||||||
@@ -151,7 +151,7 @@
|
|||||||
uni.cache.set("shopId", item.shopId);
|
uni.cache.set("shopId", item.shopId);
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: "/pages/product/index?type=beforehand&order_id=" + item.id +
|
url: "/pages/product/index?type=beforehand&order_id=" + item.id +
|
||||||
'&one_more_order=1',
|
'&one_more_order=1&shopId='+item.shopId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2456,10 +2456,10 @@
|
|||||||
shareMixin,
|
shareMixin,
|
||||||
handleMixinOnLoad,
|
handleMixinOnLoad,
|
||||||
returnQuery,
|
returnQuery,
|
||||||
jsonToUrl,wxShare,
|
jsonToUrl,
|
||||||
|
wxShare,
|
||||||
returnCommonQuery
|
returnCommonQuery
|
||||||
} from '@/utils/share.js'
|
} from '@/utils/share.js'
|
||||||
import { onShareTimeline } from '@dcloudio/uni-app';
|
|
||||||
// defineOptions({
|
// defineOptions({
|
||||||
// mixins: [shareMixin],
|
// mixins: [shareMixin],
|
||||||
// });
|
// });
|
||||||
@@ -2470,21 +2470,22 @@ import { onShareTimeline } from '@dcloudio/uni-app';
|
|||||||
function shareClick() {
|
function shareClick() {
|
||||||
isGoodsShare.value = true
|
isGoodsShare.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onShare(){
|
async function onShare() {
|
||||||
const queryJson = await returnCommonQuery()
|
const queryJson = await returnCommonQuery()
|
||||||
let query = jsonToUrl(queryJson)
|
let query = jsonToUrl(queryJson)
|
||||||
query += '&type=beforehand'
|
query += '&type=beforehand'
|
||||||
let json={}
|
let json = {}
|
||||||
|
const shopName = uni.cache.get('shopInfo').shopName || ''
|
||||||
if (goodsModalList.value.length && isGoodsShare.value) {
|
if (goodsModalList.value.length && isGoodsShare.value) {
|
||||||
const goods = goodsModalList.value[goodsModalList.value.length - 1].goods
|
const goods = goodsModalList.value[goodsModalList.value.length - 1].goods
|
||||||
query += '&showGoodsId=' + goods.id
|
query += '&showGoodsId=' + goods.id
|
||||||
json.title = goods.name
|
json.title = goods.name + (shopName ? `-${shopName}` : '')
|
||||||
json.imageUrl = goods.coverImg
|
json.imageUrl = goods.coverImg
|
||||||
json.showGoodsId = goods.id
|
json.showGoodsId = goods.id
|
||||||
}else{
|
} else {
|
||||||
json.title=uni.cache.get('shopInfo').shopName||''
|
json.title = shopName
|
||||||
json.imageUrl=uni.cache.get('shopInfo').logo||''
|
json.imageUrl = uni.cache.get('shopInfo').logo || ''
|
||||||
}
|
}
|
||||||
console.log('onShareAppMessage', {
|
console.log('onShareAppMessage', {
|
||||||
query,
|
query,
|
||||||
@@ -2497,9 +2498,9 @@ import { onShareTimeline } from '@dcloudio/uni-app';
|
|||||||
path: '/pages/product/index' + '?' + query
|
path: '/pages/product/index' + '?' + query
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onShareAppMessage(onShare)
|
onShareAppMessage(onShare)
|
||||||
|
|
||||||
onShareTimeline(onShare)
|
onShareTimeline(onShare)
|
||||||
|
|
||||||
const pageOptions = reactive({})
|
const pageOptions = reactive({})
|
||||||
@@ -2513,7 +2514,6 @@ import { onShareTimeline } from '@dcloudio/uni-app';
|
|||||||
shopId: e.shopId || uni.cache.get('shopId')
|
shopId: e.shopId || uni.cache.get('shopId')
|
||||||
})
|
})
|
||||||
const userInfo = userStore.userInfo
|
const userInfo = userStore.userInfo
|
||||||
const shopInfoRes = userStore.shopInfo
|
|
||||||
// //获取用户信息
|
// //获取用户信息
|
||||||
// const userInfo = await APIshopUserInfo({
|
// const userInfo = await APIshopUserInfo({
|
||||||
// shopId: uni.cache.get('shopId')
|
// shopId: uni.cache.get('shopId')
|
||||||
@@ -2522,9 +2522,7 @@ import { onShareTimeline } from '@dcloudio/uni-app';
|
|||||||
// const shopInfoRes = await APIusershopInfodetail({
|
// const shopInfoRes = await APIusershopInfodetail({
|
||||||
// shopId: uni.cache.get('shopId')
|
// shopId: uni.cache.get('shopId')
|
||||||
// });
|
// });
|
||||||
if (shopInfoRes && shopInfoRes.shopInfo) {
|
Object.assign(shopInfo, userStore.shopInfo);
|
||||||
Object.assign(shopInfo, shopInfoRes.shopInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (userInfo && typeof userInfo === 'object') {
|
if (userInfo && typeof userInfo === 'object') {
|
||||||
@@ -2661,7 +2659,7 @@ import { onShareTimeline } from '@dcloudio/uni-app';
|
|||||||
useSocket.setOnMessage(() => {});
|
useSocket.setOnMessage(() => {});
|
||||||
}
|
}
|
||||||
onHide(() => {
|
onHide(() => {
|
||||||
isGoodsShare.value=false
|
isGoodsShare.value = false
|
||||||
closeSocket();
|
closeSocket();
|
||||||
});
|
});
|
||||||
onUnload(() => {
|
onUnload(() => {
|
||||||
|
|||||||
@@ -27,7 +27,10 @@
|
|||||||
</view>
|
</view>
|
||||||
<text class="text">剩余:{{item.quantity}}</text>
|
<text class="text">剩余:{{item.quantity}}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="goods-name">{{item.goodsName}}</view>
|
<view class="goods-name u-flex u-row-between">
|
||||||
|
<text class="u-m-r-30" style="word-break: break-all;">{{item.goodsName}}</text>
|
||||||
|
<ymfShare color="#333" />
|
||||||
|
</view>
|
||||||
<view class="bg-f7" style="height: 24rpx"></view>
|
<view class="bg-f7" style="height: 24rpx"></view>
|
||||||
<view class="desc">
|
<view class="desc">
|
||||||
<view class="u-flex">
|
<view class="u-flex">
|
||||||
@@ -116,6 +119,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import ymfShare from '@/components/ymf-components/ymf-share.vue'
|
||||||
import {
|
import {
|
||||||
computed,
|
computed,
|
||||||
reactive
|
reactive
|
||||||
@@ -335,7 +339,7 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
shareMixin,
|
shareMixin,
|
||||||
handleMixinOnLoad,wxShare,returnQuery
|
handleMixinOnLoad,wxShare,returnQuery ,returnIndexBg,
|
||||||
} from '@/utils/share.js'
|
} from '@/utils/share.js'
|
||||||
// defineOptions({
|
// defineOptions({
|
||||||
// mixins: [shareMixin],
|
// mixins: [shareMixin],
|
||||||
@@ -343,12 +347,13 @@
|
|||||||
|
|
||||||
onShareAppMessage(async(res)=>{
|
onShareAppMessage(async(res)=>{
|
||||||
const query=await returnQuery()
|
const query=await returnQuery()
|
||||||
|
const shopInfo=uni.cache.get('shopInfo')
|
||||||
return wxShare({
|
return wxShare({
|
||||||
...res,
|
...res,
|
||||||
title:item.goodsName,
|
title:item.goodsName +'-'+shopInfo.shopName,
|
||||||
path:'/scoreShop/detail/index'+'?'+query,
|
path:'/scoreShop/detail/index'+'?'+query,
|
||||||
query,
|
query,
|
||||||
imageUrl:item.goodsImageUrl||''
|
imageUrl:item.goodsImageUrl||returnIndexBg()||''
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -31,10 +31,13 @@
|
|||||||
<view class="tab-item" :class="tabActive === 0 ? 'active' : ''" @click="tabActive = 0">优惠券</view>
|
<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 class="tab-item" :class="tabActive === 1 ? 'active' : ''" @click="tabActive = 1">其它商品</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="u-flex gap-20" @click="toggleLayout">
|
<view class="u-flex gap-20">
|
||||||
<image :src="layout === 'block' ? imgs.layout_block : imgs.layout" class="layout" />
|
<view @click="toggleLayout">
|
||||||
|
<image :src="layout === 'block' ? imgs.layout_block : imgs.layout" class="layout" />
|
||||||
|
</view>
|
||||||
<ymfShare size="40rpx" color="#9C571F"></ymfShare>
|
<ymfShare size="40rpx" color="#9C571F"></ymfShare>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
<goodsList :pointsUser="pointsUser" :layout="layout" :list="list" @exchange="exchange"></goodsList>
|
<goodsList :pointsUser="pointsUser" :layout="layout" :list="list" @exchange="exchange"></goodsList>
|
||||||
|
|
||||||
@@ -73,17 +76,17 @@
|
|||||||
|
|
||||||
function back() {
|
function back() {
|
||||||
const pages = getCurrentPages();
|
const pages = getCurrentPages();
|
||||||
if(pages.length<2){
|
if (pages.length < 2) {
|
||||||
uni.switchTab({
|
uni.switchTab({
|
||||||
url: '/pages/index/index'
|
url: '/pages/index/index'
|
||||||
})
|
})
|
||||||
}else{
|
} else {
|
||||||
uni.navigateBack({
|
uni.navigateBack({
|
||||||
delta: 1,
|
delta: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// function exchange(item) {
|
// function exchange(item) {
|
||||||
@@ -148,12 +151,32 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
shareMixin,
|
shareMixin,
|
||||||
handleMixinOnLoad
|
handleMixinOnLoad,
|
||||||
|
returnQuery,
|
||||||
|
jsonToUrl,
|
||||||
|
wxShare,returnIndexBg ,
|
||||||
|
returnCommonQuery
|
||||||
} from '@/utils/share.js'
|
} from '@/utils/share.js'
|
||||||
defineOptions({
|
// defineOptions({
|
||||||
mixins: [shareMixin],
|
// mixins: [shareMixin],
|
||||||
});
|
// });
|
||||||
|
|
||||||
|
async function onShare() {
|
||||||
|
const queryJson = await returnCommonQuery()
|
||||||
|
let query = jsonToUrl(queryJson)
|
||||||
|
let json = {}
|
||||||
|
|
||||||
|
json.title = '积分乐园,好物兑换'
|
||||||
|
json.imageUrl = returnIndexBg()||uni.cache.get('shopInfo').logo || ''
|
||||||
|
return wxShare({
|
||||||
|
query,
|
||||||
|
...json,
|
||||||
|
path: '/scoreShop/index/index' + '?' + query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
onShareAppMessage(onShare)
|
||||||
|
onShareTimeline(onShare)
|
||||||
const options = reactive({
|
const options = reactive({
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -180,6 +203,10 @@
|
|||||||
import {
|
import {
|
||||||
productStore
|
productStore
|
||||||
} from '@/stores/user.js';
|
} from '@/stores/user.js';
|
||||||
|
import {
|
||||||
|
onShareAppMessage
|
||||||
|
} from '@dcloudio/uni-app';
|
||||||
|
import { onShareTimeline } from '@dcloudio/uni-app';
|
||||||
const storeuser = productStore();
|
const storeuser = productStore();
|
||||||
|
|
||||||
|
|
||||||
@@ -200,9 +227,11 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
}
|
}
|
||||||
.gap-20{
|
|
||||||
|
.gap-20 {
|
||||||
gap: 20rpx;
|
gap: 20rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.top {
|
.top {
|
||||||
padding: 138rpx 26rpx 48rpx 42rpx;
|
padding: 138rpx 26rpx 48rpx 42rpx;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|||||||
1
src/auto-imports.d.ts
vendored
1
src/auto-imports.d.ts
vendored
@@ -39,6 +39,7 @@ declare global {
|
|||||||
const onScopeDispose: typeof import('vue')['onScopeDispose']
|
const onScopeDispose: typeof import('vue')['onScopeDispose']
|
||||||
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
|
const onServerPrefetch: typeof import('vue')['onServerPrefetch']
|
||||||
const onShareAppMessage: typeof import('@dcloudio/uni-app')['onShareAppMessage']
|
const onShareAppMessage: typeof import('@dcloudio/uni-app')['onShareAppMessage']
|
||||||
|
const onShareTimeline: typeof import('@dcloudio/uni-app')['onShareTimeline']
|
||||||
const onShow: typeof import('@dcloudio/uni-app')['onShow']
|
const onShow: typeof import('@dcloudio/uni-app')['onShow']
|
||||||
const onUnload: typeof import('@dcloudio/uni-app')['onUnload']
|
const onUnload: typeof import('@dcloudio/uni-app')['onUnload']
|
||||||
const onUnmounted: typeof import('vue')['onUnmounted']
|
const onUnmounted: typeof import('vue')['onUnmounted']
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ export async function returnQuery(query, showkeys) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Promise.resolve(result)
|
return Promise.resolve(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseQueryString(queryString) {
|
function parseQueryString(queryString) {
|
||||||
@@ -189,6 +189,34 @@ export async function handleMixinOnLoad(opt, vm) {
|
|||||||
bindInvite(options)
|
bindInvite(options)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import {
|
||||||
|
isJsonArrayString
|
||||||
|
} from '@/utils/util.js';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回店铺首页图片
|
||||||
|
*/
|
||||||
|
export function returnIndexBg() {
|
||||||
|
try {
|
||||||
|
const orderVIP = uni.cache.get('orderVIP')
|
||||||
|
if (!orderVIP || !orderVIP.shopExtendList) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
if (!isJsonArrayString(orderVIP.shopExtendList[0].value)) {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
return JSON.parse(orderVIP.shopExtendList[0].value)[0]
|
||||||
|
} catch (error) {
|
||||||
|
console.error('orderVIP.shopExtendList[0].value 格式不正确')
|
||||||
|
return ''
|
||||||
|
//TODO handle the exception
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// utils/share.js
|
// utils/share.js
|
||||||
export const shareMixin = {
|
export const shareMixin = {
|
||||||
|
|
||||||
@@ -223,41 +251,25 @@ export const shareMixin = {
|
|||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
async onShareAppMessage(res) {
|
async onShareAppMessage(res) {
|
||||||
// const shopId = uni.cache.get('shopId')
|
|
||||||
// const shopUserInfo = uni.cache.get('shopUserInfo')
|
|
||||||
const shopInfo = uni.cache.get('shopInfo')
|
const shopInfo = uni.cache.get('shopInfo')
|
||||||
// const inviteCode = await autoGetInviteCode({
|
|
||||||
// shopId: shopId,
|
|
||||||
// shopUserId: shopUserInfo.id
|
|
||||||
// })
|
|
||||||
const pages = getCurrentPages();
|
const pages = getCurrentPages();
|
||||||
const currentPage = pages[pages.length - 1];
|
const currentPage = pages[pages.length - 1];
|
||||||
const currentPath = currentPage.route;
|
const currentPath = currentPage.route;
|
||||||
const currentOptions = currentPage.options;
|
const currentOptions = currentPage.options;
|
||||||
|
|
||||||
let sharePath = `/${currentPath}`;
|
let sharePath = `/${currentPath}`;
|
||||||
// const queryJson = {
|
|
||||||
// inviteCode: (inviteCode && inviteCode !== true) ? inviteCode : null,
|
|
||||||
// shopId,
|
|
||||||
// shopUserId: shopUserInfo.id,
|
|
||||||
// }
|
|
||||||
// for (const key in currentOptions) {
|
|
||||||
// if (currentOptions.hasOwnProperty(key)) {
|
|
||||||
// queryJson[key] = encodeURIComponent(currentOptions[key])
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// queryJson.shopId = shopId
|
|
||||||
// queryJson.inviteCode = (inviteCode && inviteCode !== true) ? inviteCode : null
|
|
||||||
// queryJson.shopUserId = shopUserInfo.id
|
|
||||||
|
|
||||||
const query =await returnQuery()
|
|
||||||
|
|
||||||
|
|
||||||
|
const query = await returnQuery()
|
||||||
|
const indexBg = returnIndexBg()
|
||||||
|
console.log('indexBg', indexBg);
|
||||||
|
const imageUrl = indexBg || shopInfo.logo
|
||||||
// 全局默认配置(可被页面覆盖)
|
// 全局默认配置(可被页面覆盖)
|
||||||
const defaultShareConfig = {
|
const defaultShareConfig = {
|
||||||
title: shopInfo.shopName,
|
title: shopInfo.shopName,
|
||||||
path: sharePath + '?' + query,
|
path: sharePath + '?' + query,
|
||||||
imageUrl: shopInfo.logo,
|
imageUrl: imageUrl,
|
||||||
query,
|
query,
|
||||||
// desc: '描述',
|
// desc: '描述',
|
||||||
success: (res) => {
|
success: (res) => {
|
||||||
@@ -270,9 +282,6 @@ export const shareMixin = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 页面自定义配置覆盖全局
|
// 页面自定义配置覆盖全局
|
||||||
const pageShareConfig = this.$options.shareConfig || {};
|
const pageShareConfig = this.$options.shareConfig || {};
|
||||||
console.log('mixIn onShareAppMessage', {
|
console.log('mixIn onShareAppMessage', {
|
||||||
@@ -286,16 +295,12 @@ export const shareMixin = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async onShareTimeline() {
|
async onShareTimeline() {
|
||||||
|
|
||||||
|
|
||||||
// const shopId = uni.cache.get('shopId')
|
|
||||||
// const shopUserInfo = uni.cache.get('shopUserInfo')
|
|
||||||
const shopInfo = uni.cache.get('shopInfo')
|
const shopInfo = uni.cache.get('shopInfo')
|
||||||
// const inviteCode = await autoGetInviteCode({
|
|
||||||
// shopId: shopId,
|
|
||||||
// shopUserId: shopUserInfo.id
|
|
||||||
// })
|
|
||||||
|
|
||||||
const pages = getCurrentPages();
|
const pages = getCurrentPages();
|
||||||
const currentPage = pages[pages.length - 1];
|
const currentPage = pages[pages.length - 1];
|
||||||
@@ -304,26 +309,15 @@ export const shareMixin = {
|
|||||||
|
|
||||||
|
|
||||||
let sharePath = `/${currentPath}`;
|
let sharePath = `/${currentPath}`;
|
||||||
// const queryJson = {
|
|
||||||
// inviteCode: (inviteCode && inviteCode !== true) ? inviteCode : null,
|
|
||||||
// shopId,
|
|
||||||
// shopUserId: shopUserInfo.id,
|
|
||||||
// }
|
|
||||||
// for (const key in currentOptions) {
|
|
||||||
// if (currentOptions.hasOwnProperty(key)) {
|
|
||||||
// queryJson[key] = encodeURIComponent(currentOptions[key])
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// queryJson.shopId = shopId
|
|
||||||
// queryJson.inviteCode = (inviteCode && inviteCode !== true) ? inviteCode : null
|
|
||||||
// queryJson.shopUserId = shopUserInfo.id
|
|
||||||
|
|
||||||
const query = await returnQuery()
|
const query = await returnQuery()
|
||||||
|
const indexBg = returnIndexBg()
|
||||||
|
const imageUrl = indexBg || shopInfo.logo
|
||||||
const defaultTimelineConfig = {
|
const defaultTimelineConfig = {
|
||||||
title: shopInfo.shopName,
|
title: shopInfo.shopName,
|
||||||
path: sharePath + '?' + query,
|
path: sharePath + '?' + query,
|
||||||
imageUrl: shopInfo.logo,
|
imageUrl: imageUrl,
|
||||||
query,
|
query,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ module.exports = defineConfig({
|
|||||||
{
|
{
|
||||||
"@dcloudio/uni-app": [
|
"@dcloudio/uni-app": [
|
||||||
"onShareAppMessage",
|
"onShareAppMessage",
|
||||||
|
"onShareTimeline",
|
||||||
"onLoad",
|
"onLoad",
|
||||||
"onShow",
|
"onShow",
|
||||||
"onHide",
|
"onHide",
|
||||||
|
|||||||
Reference in New Issue
Block a user