Bläddra i källkod

优化:优惠券分享布局调整

haiyang 1 vecka sedan
förälder
incheckning
a57dcffbdf
6 ändrade filer med 17 tillägg och 42 borttagningar
  1. 1 1
      src/api/home.ts
  2. 1 1
      src/api/login.ts
  3. 2 2
      src/api/me.ts
  4. 0 27
      src/api/receiveCoupon.ts
  5. 12 10
      src/pages-A/sharePage/index.vue
  6. 1 1
      src/store/inviteQCCode.ts

+ 1 - 1
src/api/home.ts

@@ -1,5 +1,5 @@
 import type { AccountCount, CouponList, CouponSituation } from '@/api/types/coupon'
 import type { AccountCount, CouponList, CouponSituation } from '@/api/types/coupon'
-import { API_DOMAINS, http } from '@/http/alova'
+import { http } from '@/http/alova'
 
 
 /**
 /**
  *
  *

+ 1 - 1
src/api/login.ts

@@ -1,6 +1,6 @@
 import type { IAuthLoginRes, ICaptcha, IDoubleTokenRes, IUpdateInfo, IUpdatePassword, IUserInfoRes } from './types/login'
 import type { IAuthLoginRes, ICaptcha, IDoubleTokenRes, IUpdateInfo, IUpdatePassword, IUserInfoRes } from './types/login'
 // import { http } from '@/http/http'
 // import { http } from '@/http/http'
-import { API_DOMAINS, http } from '@/http/alova'
+import { http } from '@/http/alova'
 
 
 /**
 /**
  * 登录表单
  * 登录表单

+ 2 - 2
src/api/me.ts

@@ -1,8 +1,8 @@
 import type {
 import type {
     couponIssuerApplyByAddResponse,
     couponIssuerApplyByAddResponse,
     CouponIssuerApplyByIdResponse,
     CouponIssuerApplyByIdResponse,
-    ShareStateResponse,
-    InviteListResponse
+    InviteListResponse,
+    ShareStateResponse
 } from '@/api/types/me'
 } from '@/api/types/me'
 import { http } from '@/http/alova'
 import { http } from '@/http/alova'
 
 

+ 0 - 27
src/api/receiveCoupon.ts

@@ -19,33 +19,6 @@ export function getCouponShareLink(params) {
     })
     })
 }
 }
 
 
-// 生成微信小程序码
-export function getWxacode(token, id) {
-    return uni.request({
-        url: `https://api.weixin.qq.com/wxa/getwxacode?access_token=${token}`,
-        method: 'POST',
-        data: {
-            "path": `pages/home/home?couponCenter_shareId=${id}`,
-            "env_version": 'release',
-            "width": 280,
-        },
-        contentType: ContentTypeEnum.JSON,
-        responseType: 'arraybuffer',
-    })
-}
-
-export function getWxToken() {
-    return uni.request({
-        url: 'https://api.weixin.qq.com/cgi-bin/token',
-        method: 'GET',
-        data: {
-            "grant_type": 'client_credential',
-            "appid": 'wxab9634bf98628a03',
-            "secret": 'b0f8b0c5372fb825be9cf3d89c3fb28c',
-        },
-    })
-}
-
 export function getWxQcCode(params) {
 export function getWxQcCode(params) {
     return http.Post('/couponCenter/APP/shareRecord/createQRCode', params, {
     return http.Post('/couponCenter/APP/shareRecord/createQRCode', params, {
         responseType: 'arraybuffer',
         responseType: 'arraybuffer',

+ 12 - 10
src/pages-A/sharePage/index.vue

@@ -179,7 +179,7 @@ async function getWxacodeBase64() {
         shareType: 'COUPON',
         shareType: 'COUPON',
         sharePath: 'pages/home/home',
         sharePath: 'pages/home/home',
         shareContentId: shareId.value,
         shareContentId: shareId.value,
-        width: 360,
+        width: 290,
     })
     })
     console.log('res:', res)
     console.log('res:', res)
     const contentType = res.header['Content-Type'] || res.header['content-type']
     const contentType = res.header['Content-Type'] || res.header['content-type']
@@ -364,7 +364,7 @@ function drawTitle(ctx, width, height, scale) {
 // 绘制优惠券金额
 // 绘制优惠券金额
 function drawCouponAmount(ctx, width, height, scale) {
 function drawCouponAmount(ctx, width, height, scale) {
     const centerX = width / 2
     const centerX = width / 2
-    const bottomY = 220 * scale
+    const bottomY = 230 * scale
     ctx.textBaseline = 'bottom' // 设置文本基线为底部对齐
     ctx.textBaseline = 'bottom' // 设置文本基线为底部对齐
 
 
     if (couponDetail.value.type === '2') {
     if (couponDetail.value.type === '2') {
@@ -398,7 +398,7 @@ function drawCouponAmount(ctx, width, height, scale) {
         // 绘制"折"字(与数字间距8px,垂直位置微调使视觉对齐)
         // 绘制"折"字(与数字间距8px,垂直位置微调使视觉对齐)
         ctx.font = unitFont
         ctx.font = unitFont
         // 根据字体大小比例微调"折"字的y坐标,使其视觉上与数字底部对齐
         // 根据字体大小比例微调"折"字的y坐标,使其视觉上与数字底部对齐
-        const unitY = bottomY - (72 - 36) * scale * 0.15 // 微调垂直位置
+        const unitY = bottomY - (72 - 36) * scale * 0.35 // 微调垂直位置
         ctx.fillText(unit, startX + numberWidth + 8 * scale, unitY)
         ctx.fillText(unit, startX + numberWidth + 8 * scale, unitY)
     }
     }
     else if (couponDetail.value.type === '3') {
     else if (couponDetail.value.type === '3') {
@@ -417,6 +417,8 @@ function drawCouponAmount(ctx, width, height, scale) {
         ctx.font = symbolFont
         ctx.font = symbolFont
         const symbol = '¥'
         const symbol = '¥'
         const symbolWidth = ctx.measureText(symbol).width
         const symbolWidth = ctx.measureText(symbol).width
+        console.log('symbolWidth:', ctx.measureText(symbol))
+        // const symbolHeight = ctx.measureText(symbol).height
 
 
         // 计算总宽度
         // 计算总宽度
         const totalWidth = symbolWidth + numberWidth + 8 * scale // 8px间距(减小间距)
         const totalWidth = symbolWidth + numberWidth + 8 * scale // 8px间距(减小间距)
@@ -427,13 +429,13 @@ function drawCouponAmount(ctx, width, height, scale) {
         // 绘制"¥"符号(垂直位置微调使视觉对齐)
         // 绘制"¥"符号(垂直位置微调使视觉对齐)
         ctx.textAlign = 'left'
         ctx.textAlign = 'left'
         // 根据字体大小比例微调"¥"符号的y坐标,使其视觉上与数字底部对齐
         // 根据字体大小比例微调"¥"符号的y坐标,使其视觉上与数字底部对齐
-        const symbolY = bottomY - (72 - 36) * scale * 0.15 // 微调垂直位置
+        const symbolY = bottomY - (72 - 36) * scale * 0.25 // 微调垂直位置
         ctx.fillText(symbol, startX, symbolY)
         ctx.fillText(symbol, startX, symbolY)
 
 
         // 绘制数字
         // 绘制数字
         ctx.fillStyle = '#FF6B35'
         ctx.fillStyle = '#FF6B35'
         ctx.font = numberFont
         ctx.font = numberFont
-        ctx.fillText(number, startX + symbolWidth + 8 * scale, symbolY)
+        ctx.fillText(number, startX + symbolWidth + 8 * scale, bottomY)
     }
     }
 
 
     // 恢复默认文本对齐方式
     // 恢复默认文本对齐方式
@@ -535,14 +537,14 @@ function drawCouponDescription(ctx, width, height, scale) {
 async function drawQRCodeArea(ctx, canvas, qrCodeImg, width, height, scale) {
 async function drawQRCodeArea(ctx, canvas, qrCodeImg, width, height, scale) {
     const qrSize = 180 * scale
     const qrSize = 180 * scale
     const qrX = (width - qrSize) / 2
     const qrX = (width - qrSize) / 2
-    const qrY = 450 * scale
+    const qrY = 435 * scale
 
 
     // 1. 优化卡片样式:使用更柔和的阴影和渐变背景
     // 1. 优化卡片样式:使用更柔和的阴影和渐变背景
     ctx.shadowColor = 'rgba(0, 0, 0, 0.08)'
     ctx.shadowColor = 'rgba(0, 0, 0, 0.08)'
     ctx.shadowBlur = 15 * scale
     ctx.shadowBlur = 15 * scale
     ctx.shadowOffsetY = 8 * scale
     ctx.shadowOffsetY = 8 * scale
 
 
-    drawRoundRect(ctx, qrX - 30 * scale, qrY - 30 * scale, qrSize + 60 * scale, qrSize + 80 * scale, 20 * scale)
+    drawRoundRect(ctx, qrX - 30 * scale, qrY - 30 * scale, qrSize + 60 * scale, qrSize + 106 * scale, 20 * scale)
 
 
     // 使用柔和的白色背景,增加卡片层次感
     // 使用柔和的白色背景,增加卡片层次感
     ctx.fillStyle = '#FFFFFF'
     ctx.fillStyle = '#FFFFFF'
@@ -717,17 +719,17 @@ async function drawQRCodeArea(ctx, canvas, qrCodeImg, width, height, scale) {
     // 增加辅助文字,让提示更清晰
     // 增加辅助文字,让提示更清晰
     ctx.fillStyle = '#9E9E9E'
     ctx.fillStyle = '#9E9E9E'
     ctx.font = `${16 * scale}px -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif`
     ctx.font = `${16 * scale}px -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif`
-    ctx.fillText('领取专属优惠券', width / 2, qrY + qrSize + 65 * scale)
+    ctx.fillText('领取专属优惠券', width / 2, qrY + qrSize + 60 * scale)
 }
 }
 
 
 // 绘制底部信息
 // 绘制底部信息
 function drawFooter(ctx, width, height, scale) {
 function drawFooter(ctx, width, height, scale) {
     // 计算二维码区域的位置
     // 计算二维码区域的位置
     const qrSize = 200 * scale
     const qrSize = 200 * scale
-    const qrY = 440 * scale
+    const qrY = 435 * scale
 
 
     // 底部信息显示在二维码下方,与二维码提示文字保持适当间距
     // 底部信息显示在二维码下方,与二维码提示文字保持适当间距
-    const footerY = qrY + qrSize + 80 * scale // 在"长按识别二维码领取"文字下方40*scale处
+    const footerY = qrY + qrSize + 80 * scale // 在"长按识别小程序码领取"文字下方40*scale处
 
 
     ctx.fillStyle = '#999999'
     ctx.fillStyle = '#999999'
     ctx.font = `${16 * scale}px sans-serif`
     ctx.font = `${16 * scale}px sans-serif`

+ 1 - 1
src/store/inviteQCCode.ts

@@ -48,7 +48,7 @@ export const useInviteCodeStore = defineStore('inviteCode', () => {
         const res = await getWxQcCode({
         const res = await getWxQcCode({
             shareType: 'INVITE',
             shareType: 'INVITE',
             sharePath: 'pages/home/home',
             sharePath: 'pages/home/home',
-            width: 360,
+            width: 290,
         })
         })
 
 
         const contentType = res.header['Content-Type'] || res.header['content-type']
         const contentType = res.header['Content-Type'] || res.header['content-type']