From b8f0ee65a13110694e3883d3cbd30959351cd2cb Mon Sep 17 00:00:00 2001 From: Mrx <18278715334@163.com> Date: Wed, 11 Feb 2026 18:05:13 +0800 Subject: [PATCH] f --- .env.development | 5 +- src/auto-imports.d.ts | 8 ++- src/components.d.ts | 1 + src/components/EmptyState.vue | 12 ++++ src/components/GzhQrcode.vue | 6 +- src/components/Payment.vue | 61 +++++++++++----- src/composables/useShare.ts | 44 ++++++++++++ src/main.ts | 24 +++++++ src/pages.json | 2 +- src/pages/agent.vue | 3 + src/pages/agentVipApply.vue | 29 ++------ src/pages/index.vue | 45 ++++++++++++ src/pages/login.vue | 2 +- src/pages/me.vue | 48 +++++++++++-- src/pages/promoteDetails.vue | 6 +- src/pages/rewardsDetails.vue | 6 +- src/pages/withdrawDetails.vue | 14 +--- src/static/image/ai_qinggan.png | Bin 60107 -> 0 bytes src/static/image/alipay_icon.svg | 1 - src/static/image/apple.svg | 1 - src/static/image/banner.png | Bin 145096 -> 71257 bytes src/static/image/bg_2.png | Bin 37001 -> 0 bytes src/static/image/bg_icon.png | Bin 20154 -> 0 bytes src/static/image/empty.svg | 76 +------------------- src/static/image/footbanner.jpg | Bin 0 -> 114773 bytes src/static/image/gdrqgx_icon.svg | 1 - src/static/image/grbl_icon.svg | 1 - src/static/image/grss_icon.svg | 1 - src/static/image/gzh_qrcode.jpg | Bin 27959 -> 0 bytes src/static/image/icon_bg copy.svg | 1 - src/static/image/icon_bg.svg | 1 - src/static/image/icon_bz.svg | 1 - src/static/image/icon_bz_2.svg | 1 - src/static/image/icon_index_apistore.svg | 1 - src/static/image/icon_index_chacheliang.svg | 1 - src/static/image/icon_share_friends.svg | 2 +- src/static/image/icon_share_img.svg | 2 +- src/static/image/icon_share_url.svg | 2 +- src/static/image/icon_share_wechat.svg | 2 +- src/static/image/icon_tg copy.svg | 1 - src/static/image/icon_tg.svg | 1 - src/static/image/icon_xj copy.svg | 1 - src/static/image/icon_xj.svg | 1 - src/static/image/invitation_agent_apply.png | Bin 377999 -> 175635 bytes src/static/image/login_bg.png | Bin 26897 -> 26532 bytes src/static/image/logo.jpg | Bin 127143 -> 0 bytes src/static/image/logo.png | Bin 0 -> 268451 bytes src/static/image/shot_nonal.png | Bin 20685 -> 18108 bytes src/static/image/shot_svip.png | Bin 22737 -> 22523 bytes src/static/image/shot_vip.png | Bin 21303 -> 18942 bytes src/static/qrcode/tydatagzh.jpg | Bin 0 -> 27653 bytes src/utils/format.js | 16 +++++ vite.config.ts | 2 +- 53 files changed, 257 insertions(+), 176 deletions(-) create mode 100644 src/components/EmptyState.vue create mode 100644 src/composables/useShare.ts delete mode 100644 src/static/image/ai_qinggan.png delete mode 100644 src/static/image/alipay_icon.svg delete mode 100644 src/static/image/apple.svg delete mode 100644 src/static/image/bg_2.png delete mode 100644 src/static/image/bg_icon.png create mode 100644 src/static/image/footbanner.jpg delete mode 100644 src/static/image/gdrqgx_icon.svg delete mode 100644 src/static/image/grbl_icon.svg delete mode 100644 src/static/image/grss_icon.svg delete mode 100644 src/static/image/gzh_qrcode.jpg delete mode 100644 src/static/image/icon_bg copy.svg delete mode 100644 src/static/image/icon_bg.svg delete mode 100644 src/static/image/icon_bz.svg delete mode 100644 src/static/image/icon_bz_2.svg delete mode 100644 src/static/image/icon_index_apistore.svg delete mode 100644 src/static/image/icon_index_chacheliang.svg delete mode 100644 src/static/image/icon_tg copy.svg delete mode 100644 src/static/image/icon_tg.svg delete mode 100644 src/static/image/icon_xj copy.svg delete mode 100644 src/static/image/icon_xj.svg delete mode 100644 src/static/image/logo.jpg create mode 100644 src/static/image/logo.png create mode 100644 src/static/qrcode/tydatagzh.jpg create mode 100644 src/utils/format.js diff --git a/.env.development b/.env.development index 95a9f74..b0cae10 100644 --- a/.env.development +++ b/.env.development @@ -1,5 +1,6 @@ -# 开发环境配置 -VITE_APP_BASE_URL=https://www.tianyuandb.com +# 开发环境配置(仅 dev 时生效,打包 build 时不会使用此文件) +# 本地后端 hm-server 默认端口 8888 +VITE_APP_BASE_URL=http://127.0.0.1:8888 # 是否启用调试模式 VITE_APP_DEBUG=true diff --git a/src/auto-imports.d.ts b/src/auto-imports.d.ts index cff0e12..c0ac146 100644 --- a/src/auto-imports.d.ts +++ b/src/auto-imports.d.ts @@ -38,6 +38,7 @@ declare global { const eagerComputed: typeof import('@vueuse/core')['eagerComputed'] const effectScope: typeof import('vue')['effectScope'] const extendRef: typeof import('@vueuse/core')['extendRef'] + const formatExpiryTime: typeof import('./utils/format.js')['formatExpiryTime'] const getCurrentInstance: typeof import('vue')['getCurrentInstance'] const getCurrentScope: typeof import('vue')['getCurrentScope'] const h: typeof import('vue')['h'] @@ -51,6 +52,7 @@ declare global { const isRef: typeof import('vue')['isRef'] const makeDestructurable: typeof import('@vueuse/core')['makeDestructurable'] const markRaw: typeof import('vue')['markRaw'] + const maskName: typeof import('./utils/format.js')['maskName'] const nextTick: typeof import('vue')['nextTick'] const onActivated: typeof import('vue')['onActivated'] const onAddToFavorites: typeof import('@dcloudio/uni-app')['onAddToFavorites'] @@ -257,7 +259,7 @@ declare global { const useScroll: typeof import('@vueuse/core')['useScroll'] const useScrollLock: typeof import('@vueuse/core')['useScrollLock'] const useSessionStorage: typeof import('@vueuse/core')['useSessionStorage'] - const useShare: typeof import('@vueuse/core')['useShare'] + const useShare: typeof import('./composables/useShare')['useShare'] const useSlots: typeof import('vue')['useSlots'] const useSorted: typeof import('@vueuse/core')['useSorted'] const useSpeechRecognition: typeof import('@vueuse/core')['useSpeechRecognition'] @@ -361,6 +363,7 @@ declare module 'vue' { readonly eagerComputed: UnwrapRef readonly effectScope: UnwrapRef readonly extendRef: UnwrapRef + readonly formatExpiryTime: UnwrapRef readonly getCurrentInstance: UnwrapRef readonly getCurrentScope: UnwrapRef readonly h: UnwrapRef @@ -374,6 +377,7 @@ declare module 'vue' { readonly isRef: UnwrapRef readonly makeDestructurable: UnwrapRef readonly markRaw: UnwrapRef + readonly maskName: UnwrapRef readonly nextTick: UnwrapRef readonly onActivated: UnwrapRef readonly onAddToFavorites: UnwrapRef @@ -579,7 +583,7 @@ declare module 'vue' { readonly useScroll: UnwrapRef readonly useScrollLock: UnwrapRef readonly useSessionStorage: UnwrapRef - readonly useShare: UnwrapRef + readonly useShare: UnwrapRef readonly useSlots: UnwrapRef readonly useSorted: UnwrapRef readonly useSpeechRecognition: UnwrapRef diff --git a/src/components.d.ts b/src/components.d.ts index eaaddaf..c8a81f1 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -8,6 +8,7 @@ export {} declare module 'vue' { export interface GlobalComponents { AgentApplicationForm: typeof import('./components/AgentApplicationForm.vue')['default'] + EmptyState: typeof import('./components/EmptyState.vue')['default'] GzhQrcode: typeof import('./components/GzhQrcode.vue')['default'] Payment: typeof import('./components/Payment.vue')['default'] PriceInputPopup: typeof import('./components/PriceInputPopup.vue')['default'] diff --git a/src/components/EmptyState.vue b/src/components/EmptyState.vue new file mode 100644 index 0000000..590ea02 --- /dev/null +++ b/src/components/EmptyState.vue @@ -0,0 +1,12 @@ + + + diff --git a/src/components/GzhQrcode.vue b/src/components/GzhQrcode.vue index fd8cf54..9aa3a03 100644 --- a/src/components/GzhQrcode.vue +++ b/src/components/GzhQrcode.vue @@ -46,8 +46,8 @@ function handleMaskClick() { // 预览图片 function previewImage() { uni.previewImage({ - urls: ['/static/image/gzh_qrcode.jpg'], - current: '/static/image/gzh_qrcode.jpg' + urls: ['/static/qrcode/tydatagzh.jpg'], + current: '/static/qrcode/tydatagzh.jpg' }) } @@ -66,7 +66,7 @@ function previewImage() { diff --git a/src/components/Payment.vue b/src/components/Payment.vue index b12799b..ae4c6e2 100644 --- a/src/components/Payment.vue +++ b/src/components/Payment.vue @@ -66,9 +66,13 @@ const orderNo = ref('') const discountPrice = ref(false) // 是否应用折扣 async function getPayment() { + if (!props.id) { + toast.error('订单信息异常,请重试') + return + } try { const res = await payment({ - id: props.id, + id: String(props.id), pay_method: 'wechat', pay_type: props.type, }) @@ -76,24 +80,44 @@ async function getPayment() { if (res.data) { orderNo.value = res.data.order_no - // 微信支付 - const paymentData = res.data.prepay_data || res.data - + // 微信支付 - 兼容多种返回格式(wechatpay-go 返回 appId/timeStamp/nonceStr/package/signType/paySign) + const paymentData = res.data.prepay_data || res.data.prepayData || res.data + // 若 prepay_data 是字符串则解析 + const data = typeof paymentData === 'string' ? (() => { try { return JSON.parse(paymentData) } catch { return {} } })() : (paymentData || {}) + + const timeStamp = data.timeStamp || data.timestamp || data.time_stamp + const nonceStr = data.nonceStr || data.noncestr || data.nonce_str + const packageVal = data.package + const signType = data.signType || data.sign_type || 'MD5' + const paySign = data.paySign || data.pay_sign || data.sign + + // 校验必要参数 + if (!timeStamp || !nonceStr || !packageVal || !paySign) { + console.error('支付参数不完整,原始数据:', JSON.stringify(data)) + toast.error('支付参数异常,请联系客服') + return + } + // #ifdef MP-WEIXIN uni.requestPayment({ provider: 'wxpay', - timeStamp: paymentData.timeStamp || paymentData.timestamp, - nonceStr: paymentData.nonceStr || paymentData.noncestr, - package: paymentData.package, - signType: paymentData.signType || 'MD5', - paySign: paymentData.paySign || paymentData.sign, + timeStamp: String(timeStamp), + nonceStr: String(nonceStr), + package: String(packageVal), + signType: String(signType), + paySign: String(paySign), success: (result) => { toast.success('支付成功') + show.value = false handlePaymentSuccess() }, fail: (error) => { - toast.error('支付失败') + toast.error(error.errMsg || '支付失败') console.error('支付失败:', error) + // 用户取消不关闭弹窗,方便重试 + if (error.errMsg && !error.errMsg.includes('cancel')) { + show.value = false + } } }) // #endif @@ -103,20 +127,22 @@ async function getPayment() { provider: 'wxpay', orderInfo: { appid: paymentData.appid, - noncestr: paymentData.nonceStr || paymentData.noncestr, - package: paymentData.package, + noncestr: nonceStr, + package: packageVal, partnerid: paymentData.partnerid, prepayid: paymentData.prepayid, - timestamp: paymentData.timeStamp || paymentData.timestamp, - sign: paymentData.paySign || paymentData.sign + timestamp: timeStamp, + sign: paySign }, success: (result) => { toast.success('支付成功') + show.value = false handlePaymentSuccess() }, fail: (error) => { toast.error('支付失败') console.error('支付失败:', error) + show.value = false } }) // #endif @@ -126,6 +152,7 @@ async function getPayment() { WeixinJSBridge.invoke('getBrandWCPayRequest', paymentData, function (result) { if (result.err_msg === 'get_brand_wcpay_request:ok') { toast.success('支付成功') + show.value = false handlePaymentSuccess() } else { toast.error('支付失败') @@ -136,14 +163,12 @@ async function getPayment() { } // #endif } else { - toast.error('获取支付信息失败') + toast.error(res.msg || '获取支付信息失败') } } catch (error) { console.error('支付请求失败:', error) - toast.error('支付请求失败') + toast.error(error?.data?.msg || error?.msg || '支付请求失败') } - - show.value = false } function handlePaymentSuccess() { diff --git a/src/composables/useShare.ts b/src/composables/useShare.ts new file mode 100644 index 0000000..986253c --- /dev/null +++ b/src/composables/useShare.ts @@ -0,0 +1,44 @@ +/** + * 小程序分享:分享给好友、分享到朋友圈 + * 在页面 setup 中调用 useShare(options) 即可启用右上角菜单的「转发」与「分享到朋友圈」 + */ + +const DEFAULT_TITLE = '天远数据 - 大数据报告查询' +const DEFAULT_IMAGE_URL = '' // 留空则微信使用页面截图 + +export interface UseShareOptions { + /** 分享标题(好友 + 朋友圈) */ + title?: string + /** 分享给好友时的跳转路径,如 /pages/index */ + path?: string + /** 分享图 URL(可选,不填用截图) */ + imageUrl?: string + /** 分享到朋友圈时的 query,如 from=timeline */ + query?: string +} + +export function useShare(options: UseShareOptions = {}) { + const title = options.title ?? DEFAULT_TITLE + let path = options.path ?? '' + if (!path && typeof getCurrentPages === 'function') { + const pages = getCurrentPages() + const last = pages[pages.length - 1] as { route?: string } + if (last?.route) path = '/' + last.route + } + const imageUrl = options.imageUrl ?? DEFAULT_IMAGE_URL + const query = options.query ?? '' + + // 分享给好友/群 + onShareAppMessage(() => ({ + title, + path: path || undefined, + imageUrl: imageUrl || undefined, + })) + + // 分享到朋友圈(仅微信小程序支持) + onShareTimeline(() => ({ + title, + query: query || undefined, + imageUrl: imageUrl || undefined, + })) +} diff --git a/src/main.ts b/src/main.ts index 6967ea5..33251e4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -4,8 +4,32 @@ import 'uno.css' import '@/app.scss' import { setupRouterGuard } from '@/utils/routerGuard' +const DEFAULT_SHARE_TITLE = '天远数据 - 大数据报告查询,即刻赚佣金' + +// 全局分享:所有页面右上角「转发」「分享到朋友圈」使用统一默认配置 +const shareMixin = { + onShareAppMessage() { + let path = '/pages/index' + if (typeof getCurrentPages === 'function') { + const pages = getCurrentPages() + const last = pages[pages.length - 1] as { route?: string } + if (last?.route) path = '/' + last.route + } + return { + title: DEFAULT_SHARE_TITLE, + path, + } + }, + onShareTimeline() { + return { + title: DEFAULT_SHARE_TITLE, + } + }, +} + export function createApp() { const app = createSSRApp(App) + app.mixin(shareMixin) // 初始化路由守卫 setupRouterGuard() diff --git a/src/pages.json b/src/pages.json index d1d252a..c010754 100644 --- a/src/pages.json +++ b/src/pages.json @@ -158,4 +158,4 @@ }, "__esModule": true, "subPackages": [] -} +} \ No newline at end of file diff --git a/src/pages/agent.vue b/src/pages/agent.vue index 2443b60..c44be1b 100644 --- a/src/pages/agent.vue +++ b/src/pages/agent.vue @@ -3,6 +3,9 @@ import { ref, computed } from 'vue' import { getAgentRevenue } from '@/api/apis' import GzhQrcode from '@/components/GzhQrcode.vue' +// 分享给好友、分享到朋友圈 +useShare({ title: '天远数据 - 资产与收益' }) + // 日期选项映射 const dateRangeMap = { today: 'today', diff --git a/src/pages/agentVipApply.vue b/src/pages/agentVipApply.vue index 9b76ee8..d8632dc 100644 --- a/src/pages/agentVipApply.vue +++ b/src/pages/agentVipApply.vue @@ -384,6 +384,7 @@ import { ref, onMounted, reactive, computed } from 'vue' import { useToast } from 'wot-design-uni' import { activateAgentMembership } from '@/apis/agent' +import { formatExpiryTime } from '@/utils/format' // 使用 wot-design-ui 的 toast const toast = useToast() @@ -744,25 +745,9 @@ async function applyVip() { type: selectedType.value.toUpperCase(), }) - if (res.code === 200) { - if (res.data.id) { - payID.value = res.data.id - showPayment.value = true - uni.requestPayment({ - "provider": "wxpay", - "orderInfo": { - "appid": "wx499********7c70e", // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致 - "noncestr": "c5sEwbaNPiXAF3iv", // 随机字符串 - "package": "Sign=WXPay", // 固定值 - "partnerid": "148*****52", // 微信支付商户号 - "prepayid": "wx202254********************fbe90000", // 统一下单订单号 - "timestamp": 1597935292, // 时间戳(单位:秒) - "sign": "A842B45937F6EFF60DEC7A2EAA52D5A0" // 签名,这里用的 MD5/RSA 签名 - }, - success(res) { }, - fail(e) { } - }) - } + if (res.code === 200 && res.data?.id) { + payID.value = String(res.data.id) + showPayment.value = true } else { toast.error(res.msg || '申请失败') } @@ -771,12 +756,6 @@ async function applyVip() { toast.error('网络请求失败,请稍后重试') } } - -function formatExpiryTime(expiryTimeStr) { - if (!expiryTimeStr) return '未知' - // 从格式化字符串中提取日期部分 - return expiryTimeStr.split(' ')[0] // 假设格式是 "YYYY-MM-DD HH:MM:SS" -}