zhengyiming
2025-06-10 e47c70d32e6fa7c9cb16ca19a79338ea36a83e94
fix: v1.4
5个文件已修改
61 ■■■■■ 已修改文件
apps/taro/src/hooks/router.ts 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/subpackages/my/AgentRecruitment/AgentRecruitment.vue 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/subpackages/my/promotionQrcode/InnerPage.vue 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/utils/file.ts 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/utils/page.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
apps/taro/src/hooks/router.ts
@@ -51,6 +51,7 @@
  const appStore = useAppStore();
  const { latestRoute } = storeToRefs(appStore);
  const { blLifeRecharge } = useLifeRechargeContext();
  const system = useSystemStore();
  const router = Taro.useRouter();
@@ -58,6 +59,7 @@
  console.log('router: params', router, blLifeRecharge.accountModel.channlesNum);
  Taro.useTabItemTap((item) => {
    system.setTabIndex(item.index as any);
    Taro.reLaunch({
      url: pathAddExtraParam(item.pagePath, { channelId: blLifeRecharge.accountModel.channlesNum }),
      success() {
apps/taro/src/subpackages/my/AgentRecruitment/AgentRecruitment.vue
@@ -41,6 +41,8 @@
import { Image } from '@tarojs/components';
import Taro from '@tarojs/taro';
import { useLifeRechargeContext } from '@life-payment/core-vue';
import { useUser } from '@/hooks';
import { isH5, isInWeChat } from '@/utils/env';
defineOptions({
  name: 'AgentRecruitment',
@@ -49,11 +51,17 @@
const router = Taro.useRouter();
const promoterIdNumber = router.params?.promoterIdNumber ?? '';
//微信网页授权code 需要重定向获取 会导致多次触发onMounted
const code = router.params.code ?? '';
onMounted(() => {
  if (promoterIdNumber) {
    if (isH5 && isInWeChat) {
      if (!code) setClickCount();
    } else {
    setClickCount();
  }
  }
});
function submit() {
apps/taro/src/subpackages/my/promotionQrcode/InnerPage.vue
@@ -22,6 +22,8 @@
import { CSSProperties, useTemplateRef } from 'vue';
import { OssAssets } from '@/constants';
import { createQrCodeImg } from '@/components/Qrcode/utils/qrcode';
import { downloadBase64File, Message } from '@/utils';
import { isInAlipay } from '@/utils/env';
defineOptions({
  name: 'InnerPage',
@@ -58,9 +60,15 @@
);
function downloadQrcode() {
  Taro.saveImageToPhotosAlbum({
    filePath: link.value,
  });
  // Taro.saveImageToPhotosAlbum({
  //   filePath: link.value,
  // });
  if (isInAlipay) {
    Message.warning('可在浏览器打开此网页下载文件。');
  } else {
    // TODO 还需要做小程序下载的兼容
    downloadBase64File(link.value, '推广二维码');
  }
}
</script>
apps/taro/src/utils/file.ts
@@ -86,3 +86,38 @@
    return fileName;
  });
}
export function downloadBase64File(base64Data: string, filename: string) {
  // 将base64数据分割,获取mime-type
  const [, mime, b64data] = base64Data.match(/^data:([^;]+);base64,(.+)$/);
  // 解码base64数据
  const byteString = atob(b64data);
  const arrayBuffer = new ArrayBuffer(byteString.length);
  const intArray = new Uint8Array(arrayBuffer);
  for (let i = 0; i < byteString.length; i++) {
    intArray[i] = byteString.charCodeAt(i);
  }
  // 创建Blob对象
  const blob = new Blob([intArray], { type: mime });
  //@ts-ignore
  if (typeof navigator !== 'undefined' && navigator.msSaveOrOpenBlob) {
    //@ts-ignore 兼容IE
    navigator.msSaveOrOpenBlob(blob, filename);
  } else {
    // 创建一个临时的a标签用于触发下载
    const a = document.createElement('a');
    const url = window.URL.createObjectURL(blob);
    a.href = url;
    a.download = filename; // 设置下载后的文件名
    document.body.appendChild(a);
    a.click(); // 触发下载
    document.body.removeChild(a);
    setTimeout(() => {
      window.URL.revokeObjectURL(url); // 清除创建的对象URL
    }, 0);
  }
}
apps/taro/src/utils/page.ts
@@ -3,10 +3,10 @@
import { useSystemStoreWithOut } from '@/stores/modules/system';
import { query2object, object2query } from '@life-payment/utils';
import { blLifeRecharge } from './blLifeRecharge';
import { isInAlipay } from '@/utils/env';
export function goBack(delta = 1) {
  const pages = Taro.getCurrentPages();
  const systemStore = useSystemStoreWithOut();
  if (pages.length > 1) {