Compare commits

..

2 Commits

Author SHA1 Message Date
e6c7ffa46c fix(index): 优化外链提示及删除复制咨询模板功能
- 替换小程序内外链打开方式提示为弹窗提醒用户手动复制
- 删除复制咨询模板功能及相关按钮
- 修改联系我们文案,突出直接电话沟通或需求反馈
- 移除无用导入的复制文本工具函数copyText
2026-06-30 18:18:38 +08:00
482cff5ece fix(utils): 优化小程序端复制文本功能体验
- 小程序端直接调用原生 wx.setClipboardData,避免 Taro Promise 封装问题
- 避免微信小程序重复显示复制成功提示和误报复制失败
- 失败时仅在小程序端输出错误日志,非小程序端显示提示
- 修改首页外链跳转逻辑,支持相对路径跳转,小程序内外链复制提示提升用户体验
- 更新项目内剪切板使用规范文档,说明复制行为调整及符合相应规范要求
2026-06-30 18:18:13 +08:00
3 changed files with 23 additions and 21 deletions

View File

@@ -47,3 +47,15 @@
- **原因**: 项目没有声明微信小程序原生全局对象 `wx` 的类型 - **原因**: 项目没有声明微信小程序原生全局对象 `wx` 的类型
- **修复**: 在 `types/global.d.ts` 中添加 `declare const wx: any;` 全局类型声明 - **修复**: 在 `types/global.d.ts` 中添加 `declare const wx: any;` 全局类型声明
- **验证**: `tsc` 不再报 `common.ts` 相关错误,`npx taro build --type weapp` 构建成功 - **验证**: `tsc` 不再报 `common.ts` 相关错误,`npx taro build --type weapp` 构建成功
## 去掉首页「复制咨询模板」按钮及复制逻辑
- **问题**: `wx.setClipboardData` 在小程序开发者工具中报 `no permission` 错误,且审核对复制功能敏感
- **修复**:
- 移除 `src/pages/index/index.tsx` 中的 `copyConsultTemplate` 函数
- 删除「复制咨询模板」按钮,只保留「电话咨询」
- 修改联系我们区域文案,去掉「复制咨询模板」相关描述
- `openMaybeLink` 中外链不再调用 `copyText`,改为 `Taro.showModal` 提示用户手动复制到浏览器打开
- 移除首页对 `copyText` 的 import
- **验证**: `npx taro build --type weapp` 构建成功,首页无复制相关调用
- **备注**: 项目其他页面仍有复制功能(如礼品卡分享、优惠券分享、订单号复制、密钥复制等),如需要可继续逐个移除

View File

@@ -3,7 +3,6 @@ import { View, Text } from '@tarojs/components'
import { useMemo, useState } from 'react' import { useMemo, useState } from 'react'
import { Button } from '@nutui/nutui-react-taro' import { Button } from '@nutui/nutui-react-taro'
import { useConfig } from '@/hooks/useConfig' import { useConfig } from '@/hooks/useConfig'
import { copyText } from '@/utils/common'
import './index.scss' import './index.scss'
function Home() { function Home() {
@@ -76,28 +75,19 @@ function Home() {
Taro.navigateTo({ url }) Taro.navigateTo({ url })
return return
} }
// 外链在小程序内无法直接打开,复制链接降低认知成本 // 小程序内无法直接打开外链,提示用户手动复制到浏览器
if (/^https?:\/\//i.test(abs)) { if (/^https?:\/\//i.test(abs)) {
copyText(abs) Taro.showModal({
title: '提示',
content: '该链接需要在浏览器中打开,请点击确认后手动复制链接访问。',
showCancel: false,
confirmText: '知道了'
})
return return
} }
Taro.showToast({ title: '请在 PC 端访问该入口', icon: 'none', duration: 1600 }) Taro.showToast({ title: '请在 PC 端访问该入口', icon: 'none', duration: 1600 })
} }
const copyConsultTemplate = () => {
const tel = config?.tel ? `\n联系电话${config.tel}` : ''
const text =
'【需求咨询】\n' +
'1) 想开通哪些产品:企业官网 / 电商 / 小程序 / 其他\n' +
'2) 是否需要模板/插件市场:是 / 否\n' +
'3) 是否需要“支付即开通”:是 / 否\n' +
'4) 交付方式SaaS / 私有化 / 混合\n' +
'5) 合规/部署要求:\n' +
'6) 期望上线时间:\n' +
tel
copyText(text)
}
const callPhone = () => { const callPhone = () => {
const tel = (config?.tel || '').trim() const tel = (config?.tel || '').trim()
if (!tel) { if (!tel) {
@@ -456,7 +446,7 @@ function Home() {
<View className="section__head"> <View className="section__head">
<Text className="section__title"></Text> <Text className="section__title"></Text>
<Text className="section__desc"> <Text className="section__desc">
SaaS/ SaaS/
</Text> </Text>
</View> </View>
@@ -492,9 +482,6 @@ function Home() {
</View> </View>
<View className="contactActions"> <View className="contactActions">
<Button type="default" block onClick={copyConsultTemplate}>
</Button>
<Button type="primary" block onClick={callPhone}> <Button type="primary" block onClick={callPhone}>
</Button> </Button>

3
types/global.d.ts vendored
View File

@@ -69,6 +69,9 @@ declare const API_BASE_URL: string;
declare const APP_NAME: string; declare const APP_NAME: string;
declare const DEBUG: string; declare const DEBUG: string;
// 微信小程序原生全局对象 wx
declare const wx: any;
// 基础类型定义 // 基础类型定义
declare global { declare global {
/** 通用ID类型 */ /** 通用ID类型 */