Commit 65086a7d authored by chenkai@duiba.com.cn's avatar chenkai@duiba.com.cn

Merge branch 'dev' of gitlab2.dui88.com:fh/20250528_FHQ1 into dev

parents 59ec1d02 78d11b62
assets/reservation-images/s-1.png

70.8 KB | W: | H:

assets/reservation-images/s-1.png

65 KB | W: | H:

assets/reservation-images/s-1.png
assets/reservation-images/s-1.png
assets/reservation-images/s-1.png
assets/reservation-images/s-1.png
  • 2-up
  • Swipe
  • Onion skin
assets/reservation-images/s-2.png

95.7 KB | W: | H:

assets/reservation-images/s-2.png

93.1 KB | W: | H:

assets/reservation-images/s-2.png
assets/reservation-images/s-2.png
assets/reservation-images/s-2.png
assets/reservation-images/s-2.png
  • 2-up
  • Swipe
  • Onion skin
assets/reservation-images/sign.png

58.7 KB | W: | H:

assets/reservation-images/sign.png

45.5 KB | W: | H:

assets/reservation-images/sign.png
assets/reservation-images/sign.png
assets/reservation-images/sign.png
assets/reservation-images/sign.png
  • 2-up
  • Swipe
  • Onion skin
assets/reservation-images/success.png

33.3 KB | W: | H:

assets/reservation-images/success.png

29.2 KB | W: | H:

assets/reservation-images/success.png
assets/reservation-images/success.png
assets/reservation-images/success.png
assets/reservation-images/success.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -134,12 +134,13 @@ const generateQrcodeFunc = async () => { ...@@ -134,12 +134,13 @@ const generateQrcodeFunc = async () => {
console.warn('recordId 未传入,无法生成二维码') console.warn('recordId 未传入,无法生成二维码')
return return
} }
console.warn('recordId', props.recordId)
try { try {
const result = await generateQRCode({ const result = await generateQRCode({
scene: `id=${props.recordId}`, scene: `id=${props.recordId}`,
page: `pages/XingmaLabDetailPage/XingmaLabDetailPage`, page: `pages/XingmaLabDetailPage/XingmaLabDetailPage`,
envVersion: 'release'//trial develop envVersion: 'trial'//trial develop release
}) })
if (result && result.ok && result.data && result.data.qrCodeBase64) { if (result && result.ok && result.data && result.data.qrCodeBase64) {
...@@ -283,7 +284,7 @@ const handleDownload = async () => { ...@@ -283,7 +284,7 @@ const handleDownload = async () => {
const imageBgX = (posterWidth - imageBgW) / 2 const imageBgX = (posterWidth - imageBgW) / 2
const imageBgY = (120 / 750) * screenWidth const imageBgY = (120 / 750) * screenWidth
await drawImage(ctx, `${$baseUrl}homepage/Q3Res/xingmaLabPosterImgBg.png`, imageBgX, imageBgY, imageBgW, imageBgH) await drawImage(ctx, `${$baseUrl}homepage/Q3Res/xingmaLabPosterImgBg2.png`, imageBgX, imageBgY, imageBgW, imageBgH)
// 绘制主图片(自适应模式,保持宽高比) // 绘制主图片(自适应模式,保持宽高比)
if (props.imageUrl) { if (props.imageUrl) {
...@@ -319,17 +320,26 @@ const handleDownload = async () => { ...@@ -319,17 +320,26 @@ const handleDownload = async () => {
// 二维码位置:图片区域右下角,距离右边 22rpx,距离底部 26rpx // 二维码位置:图片区域右下角,距离右边 22rpx,距离底部 26rpx
const qrcodeX = imageBgX + imageBgW - qrcodeSize - (22 / 750) * screenWidth const qrcodeX = imageBgX + imageBgW - qrcodeSize - (22 / 750) * screenWidth
const qrcodeY = imageBgY + imageBgH - qrcodeSize - (26 / 750) * screenWidth const qrcodeY = imageBgY + imageBgH - qrcodeSize - (26 / 750) * screenWidth
// 稍微缩小二维码尺寸以去除边框(缩小 8%,相当于去除 4% 的边框)
const qrcodeDrawSize = qrcodeSize * 0.92
const qrcodeDrawX = qrcodeX + (qrcodeSize - qrcodeDrawSize) / 2
const qrcodeDrawY = qrcodeY + (qrcodeSize - qrcodeDrawSize) / 2
console.log('开始绘制二维码:', { console.log('开始绘制二维码:', {
qrcodeX, qrcodeX,
qrcodeY, qrcodeY,
qrcodeSize, qrcodeSize,
qrcodeDrawSize,
imageBgX, imageBgX,
imageBgY, imageBgY,
imageBgW, imageBgW,
imageBgH, imageBgH,
qrcodeImageUrl: qrcodeImageUrl.value.substring(0, 50) + '...' qrcodeImageUrl: qrcodeImageUrl.value.substring(0, 50) + '...'
}) })
await drawImage(ctx, qrcodeImageUrl.value, qrcodeX, qrcodeY, qrcodeSize, qrcodeSize)
// 绘制二维码,使用稍微缩小的尺寸以去除边框
await drawQRCodeImage(ctx, qrcodeImageUrl.value, qrcodeDrawX, qrcodeDrawY, qrcodeDrawSize, qrcodeDrawSize)
console.log('二维码绘制完成') console.log('二维码绘制完成')
} else { } else {
console.warn('二维码图片 URL 为空,无法绘制') console.warn('二维码图片 URL 为空,无法绘制')
...@@ -552,6 +562,110 @@ const calculateFitSize = (imageWidth, imageHeight, containerWidth, containerHeig ...@@ -552,6 +562,110 @@ const calculateFitSize = (imageWidth, imageHeight, containerWidth, containerHeig
return { drawWidth, drawHeight, drawX, drawY } return { drawWidth, drawHeight, drawX, drawY }
} }
// 绘制二维码图片(去除边框)
const drawQRCodeImage = (ctx, src, x, y, w, h) => {
return new Promise((resolve) => {
// 获取图片路径(Base64 需要转换)
const getImagePath = () => {
if (src.startsWith('data:image')) {
return base64ToTempFilePath(src)
} else {
return Promise.resolve(src)
}
}
getImagePath().then((imagePath) => {
// 获取图片信息
return getImageInfo(imagePath).then((info) => {
// 二维码通常是正方形,如果图片有边框,计算裁剪区域
// 假设二维码图片可能有边框,尝试裁剪掉边缘部分
// 如果图片宽高比接近 1:1,可能是标准二维码,直接绘制
// 如果图片明显不是正方形,可能需要裁剪
const isSquare = Math.abs(info.width - info.height) < 10
const minSize = Math.min(info.width, info.height)
// 如果图片是正方形且尺寸合理,直接绘制
if (isSquare && minSize > 200) {
if (imagePath.startsWith('http')) {
uni.downloadFile({
url: imagePath,
success: (res) => {
if (res.statusCode === 200) {
ctx.drawImage(res.tempFilePath, x, y, w, h)
resolve()
} else {
console.warn('二维码图片下载失败')
resolve()
}
},
fail: () => {
console.warn('二维码图片下载失败')
resolve()
}
})
} else {
ctx.drawImage(imagePath, x, y, w, h)
resolve()
}
} else {
// 图片可能有边框,尝试裁剪掉 5% 的边缘
// 注意:uni-app canvas 可能不支持 9 参数 drawImage
// 这里先尝试直接绘制,如果仍有边框问题,可能需要后端处理
if (imagePath.startsWith('http')) {
uni.downloadFile({
url: imagePath,
success: (res) => {
if (res.statusCode === 200) {
// 直接绘制,让 canvas 自动处理
ctx.drawImage(res.tempFilePath, x, y, w, h)
resolve()
} else {
console.warn('二维码图片下载失败')
resolve()
}
},
fail: () => {
console.warn('二维码图片下载失败')
resolve()
}
})
} else {
ctx.drawImage(imagePath, x, y, w, h)
resolve()
}
}
}).catch(() => {
// 如果获取图片信息失败,直接绘制
if (imagePath.startsWith('http')) {
uni.downloadFile({
url: imagePath,
success: (res) => {
if (res.statusCode === 200) {
ctx.drawImage(res.tempFilePath, x, y, w, h)
resolve()
} else {
console.warn('二维码图片下载失败')
resolve()
}
},
fail: () => {
console.warn('二维码图片下载失败')
resolve()
}
})
} else {
ctx.drawImage(imagePath, x, y, w, h)
resolve()
}
})
}).catch((err) => {
console.error('二维码图片处理失败:', err)
resolve() // 即使失败也继续
})
})
}
// 绘制图片到 canvas(异步加载图片) // 绘制图片到 canvas(异步加载图片)
const drawImage = (ctx, src, x, y, w, h, fitMode = false) => { const drawImage = (ctx, src, x, y, w, h, fitMode = false) => {
return new Promise((resolve) => { return new Promise((resolve) => {
...@@ -777,7 +891,6 @@ const drawImage = (ctx, src, x, y, w, h, fitMode = false) => { ...@@ -777,7 +891,6 @@ const drawImage = (ctx, src, x, y, w, h, fitMode = false) => {
height: 586rpx; height: 586rpx;
z-index: 1; z-index: 1;
object-fit: contain; object-fit: contain;
margin: 26rpx;
box-sizing: border-box; box-sizing: border-box;
} }
...@@ -796,6 +909,7 @@ const drawImage = (ctx, src, x, y, w, h, fitMode = false) => { ...@@ -796,6 +909,7 @@ const drawImage = (ctx, src, x, y, w, h, fitMode = false) => {
color: #000000; color: #000000;
width: 450rpx; width: 450rpx;
height: 40rpx; height: 40rpx;
line-height: 40rpx;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
......
{ {
"name" : "20250528_FHQ1", "name": "20250528_FHQ1",
"appid" : "__UNI__35659A6", "appid": "__UNI__35659A6",
"description" : "", "description": "",
"versionName" : "1.0.0", "versionName": "1.0.0",
"versionCode" : "100", "versionCode": "100",
"transformPx" : false, "transformPx": false,
/* 5+App特有相关 */ /* 5+App特有相关 */
"app-plus" : { "app-plus": {
"usingComponents" : true, "usingComponents": true,
"nvueStyleCompiler" : "uni-app", "nvueStyleCompiler": "uni-app",
"compilerVersion" : 3, "compilerVersion": 3,
"splashscreen" : { "splashscreen": {
"alwaysShowBeforeRender" : true, "alwaysShowBeforeRender": true,
"waiting" : true, "waiting": true,
"autoclose" : true, "autoclose": true,
"delay" : 0 "delay": 0
}, },
/* 模块配置 */ /* 模块配置 */
"modules" : {}, "modules": {},
/* 应用发布信息 */ /* 应用发布信息 */
"distribute" : { "distribute": {
/* android打包配置 */ /* android打包配置 */
"android" : { "android": {
"permissions" : [ "permissions": [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>", "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>", "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
...@@ -41,45 +41,56 @@ ...@@ -41,45 +41,56 @@
] ]
}, },
/* ios打包配置 */ /* ios打包配置 */
"ios" : {}, "ios": {},
/* SDK配置 */ /* SDK配置 */
"sdkConfigs" : { "sdkConfigs": {
"share" : {} "share": {}
} }
} }
}, },
/* 快应用特有相关 */ /* 快应用特有相关 */
"quickapp" : {}, "quickapp": {},
/* 小程序特有相关 */ /* 小程序特有相关 */
"mp-weixin" : { "mp-weixin": {
"appid" : "wxc83b55d61c7fc51d", "appid": "wxc83b55d61c7fc51d",
"setting" : { "setting": {
"urlCheck" : false, "urlCheck": false,
"minified" : true, "minified": true,
"postcss" : true, "postcss": true,
"es6" : true "es6": true
}, },
"usingComponents" : true, "usingComponents": true,
"permission" : { "permission": {
"scope.userLocation" : { "scope.userLocation": {
"desc" : "请允许获取位置信息,用于提供附近服务" "desc": "请允许获取位置信息,用于提供附近服务"
} }
}, },
"requiredBackgroundModes" : [ "share" ], "requiredBackgroundModes": [
"embeddedAppIdList" : [ "wx4205ec55b793245e", "wxab14ac8f684ad962" ] "share"
],
"embeddedAppIdList": [
"wx4205ec55b793245e",
"wxab14ac8f684ad962"
],
"optimization": {
"subpackages": true,
"minimize": true
}
}, },
"mp-alipay" : { "mp-alipay": {
"usingComponents" : true "usingComponents": true
}, },
"mp-baidu" : { "mp-baidu": {
"usingComponents" : true "usingComponents": true
}, },
"mp-toutiao" : { "mp-toutiao": {
"usingComponents" : true "usingComponents": true
}, },
"uniStatistics" : { "uniStatistics": {
"enable" : false "enable": false
}, },
"vueVersion" : "3", "vueVersion": "3",
"requiredPrivateInfos" : [ "chooseAddress" ] "requiredPrivateInfos": [
"chooseAddress"
]
} }
\ No newline at end of file
...@@ -358,6 +358,43 @@ ...@@ -358,6 +358,43 @@
} }
} }
// 从 scene 参数中解析 id
const parseIdFromScene = (scene) => {
if (!scene || typeof scene !== 'string') {
return ''
}
try {
// 先对 scene 字符串进行 URL 解码
const decodedScene = decodeURIComponent(scene)
// scene 格式可能是 "id=xxx" 或 "id=xxx&other=yyy"
const params = decodedScene.split('&')
for (const param of params) {
const [key, value] = param.split('=')
if (key === 'id' && value) {
// value 可能也需要解码(如果 value 本身也被编码了)
return decodeURIComponent(value)
}
}
} catch (error) {
console.warn('解析 scene 参数失败:', error)
// 如果解码失败,尝试直接解析原始 scene
const params = scene.split('&')
for (const param of params) {
const [key, value] = param.split('=')
if (key === 'id' && value) {
try {
return decodeURIComponent(value)
} catch (e) {
return value
}
}
}
}
return ''
}
// 页面初始化逻辑 // 页面初始化逻辑
const initPage = async () => { const initPage = async () => {
console.log('🔍 initPage:页面初始化逻辑'); console.log('🔍 initPage:页面初始化逻辑');
...@@ -379,11 +416,56 @@ ...@@ -379,11 +416,56 @@
// 调用 home 接口获取登录状态 // 调用 home 接口获取登录状态
await homeStore.loadHomeInfo() await homeStore.loadHomeInfo()
// 获取页面跳转参数中的 id 和 index // 获取页面跳转参数中的 id
const pages = getCurrentPages() const pages = getCurrentPages()
const currentPage = pages[pages.length - 1] const currentPage = pages[pages.length - 1]
console.log('🔍 currentPage:', currentPage); console.log('🔍 currentPage:', currentPage);
const id = currentPage.options?.id || ''
// 优先从 options.id 获取
let id = currentPage.options?.id || ''
// 如果 options.id 不存在,尝试从 scene 参数中解析
if (!id) {
// 尝试从 currentPage.options.scene 获取
const scene = currentPage.options?.scene || ''
if (scene) {
id = parseIdFromScene(scene)
console.log('🔍 从 currentPage.options.scene 解析到 id:', id)
}
// 如果还是没有,尝试从 wx.getLaunchOptionsSync() 获取(扫码进入场景)
if (!id) {
try {
const launchOptions = wx.getLaunchOptionsSync()
if (launchOptions && launchOptions.scene) {
// 如果是扫码场景(scene 值为 1047 或 1048),从 query 中获取 scene 参数
if (launchOptions.scene === 1047 || launchOptions.scene === 1048) {
const sceneParam = launchOptions.query?.scene || ''
if (sceneParam) {
id = parseIdFromScene(sceneParam)
console.log('🔍 从 launchOptions.query.scene 解析到 id:', id)
}
}
}
} catch (error) {
console.warn('获取 launchOptions 失败:', error)
}
}
// 如果还是没有,尝试从 wx.getEnterOptionsSync() 获取
if (!id) {
try {
const enterOptions = wx.getEnterOptionsSync()
if (enterOptions && enterOptions.query && enterOptions.query.scene) {
id = parseIdFromScene(enterOptions.query.scene)
console.log('🔍 从 enterOptions.query.scene 解析到 id:', id)
}
} catch (error) {
console.warn('获取 enterOptions 失败:', error)
}
}
}
if (id) { if (id) {
console.log('🔍 获取到页面参数 id:', id) console.log('🔍 获取到页面参数 id:', id)
recordId.value = id // 立即保存ID,确保分享时能获取到 recordId.value = id // 立即保存ID,确保分享时能获取到
......
...@@ -139,7 +139,7 @@ const isBackApp = ref(false); ...@@ -139,7 +139,7 @@ const isBackApp = ref(false);
const taskId = ref(0); const taskId = ref(0);
const shareOptions = { const shareOptions = {
0: { 0: {
title: '8000万中国妈妈信赖的育儿品牌', title: '8500万中国妈妈信赖的育儿品牌',
path: '/pages/index/index?pageType=home', path: '/pages/index/index?pageType=home',
imageUrl: $baseUrl + 'share/share_home0901.jpg', imageUrl: $baseUrl + 'share/share_home0901.jpg',
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment