沐梦. пре 15 часа
родитељ
комит
1015717410

+ 15 - 2
components/agreement/index.vue

@@ -5,7 +5,9 @@
         <text class="agreement-title">{{ title || '协议详情' }}</text>
       </view>
       <scroll-view scroll-y class="agreement-body">
-        <rich-text :nodes="content"></rich-text>
+        <view class="agreement-content">
+          <rich-text :nodes="decodedContent"></rich-text>
+        </view>
       </scroll-view>
       <view class="agreement-footer">
         <button class="confirm-btn" @click="handleClose">确 定</button>
@@ -15,6 +17,8 @@
 </template>
 
 <script>
+import { decodeBase64 } from '@/utils/index'
+
 /**
  * 协议详情组件 (纯 UI 组件)
  * @property {Boolean} visible 控制显示隐藏
@@ -38,6 +42,11 @@ export default {
       default: ''
     }
   },
+  computed: {
+    decodedContent() {
+      return decodeBase64(this.content)
+    }
+  },
   methods: {
     /**
      * 关闭弹窗
@@ -88,11 +97,15 @@ export default {
 
 .agreement-body {
   flex: 1;
+  box-sizing: border-box;
+  max-height: 50vh;
+}
+
+.agreement-content {
   padding: 30rpx;
   font-size: 28rpx;
   line-height: 1.6;
   color: #666666;
-  max-height: 50vh;
 }
 
 .agreement-footer {

+ 6 - 0
pages.json

@@ -199,6 +199,12 @@
 				"navigationStyle": "custom"
 			}
 		},
+		{
+			"path": "pages/mine/settings/about/agreement-detail/index",
+			"style": {
+				"navigationStyle": "custom"
+			}
+		},
 		{
 			"path": "pages/mine/wallet/index",
 			"style": {

+ 8 - 2
pages/mine/settings/about/agreement-detail/index.vue

@@ -22,6 +22,7 @@
 
 <script>
 import { getAgreement } from '@/api/system/agreement'
+import { decodeBase64 } from '@/utils/index'
 
 export default {
     data() {
@@ -35,6 +36,9 @@ export default {
         }
     },
     onLoad(options) {
+        if (options.title) {
+            this.title = options.title;
+        }
         if (options.id) {
             this.id = options.id;
             this.loadDetail();
@@ -47,8 +51,10 @@ export default {
             uni.showLoading({ title: '加载中...' });
             try {
                 const res = await getAgreement(this.id);
-                this.title = res.data.title;
-                this.content = res.data.content;
+                if (!this.title) {
+                    this.title = res.data.title;
+                }
+                this.content = decodeBase64(res.data.content);
                 // 设置原生导航栏标题(作为兜底)
                 uni.setNavigationBarTitle({ title: this.title });
             } catch (err) {

+ 4 - 4
pages/mine/settings/about/index.vue

@@ -18,11 +18,11 @@
         </view>
 
         <view class="group-card">
-            <view class="list-item" @click="goToDetail(1)">
+            <view class="list-item" @click="goToDetail(6, '服务协议')">
                 <text class="item-title">服务协议</text>
                 <image class="arrow-icon" src="/static/icons/chevron_right.svg"></image>
             </view>
-            <view class="list-item" @click="goToDetail(2)">
+            <view class="list-item" @click="goToDetail(7, '隐私政策')">
                 <text class="item-title">隐私政策</text>
                 <image class="arrow-icon" src="/static/icons/chevron_right.svg"></image>
             </view>
@@ -56,9 +56,9 @@ export default {
                 delta: 1
             });
         },
-        goToDetail(id) {
+        goToDetail(id, title) {
             uni.navigateTo({
-                url: `/pages/mine/settings/about/agreement-detail/index?id=${id}`
+                url: `/pages/mine/settings/about/agreement-detail/index?id=${id}&title=${title}`
             });
         },
         checkUpdate() {

+ 2 - 2
utils/config.js

@@ -6,8 +6,8 @@
 // API 基础地址(开发环境)
 // export const BASE_URL = 'http://192.168.1.118:8080'
 // export const BASE_URL = 'http://192.168.1.205:8080'
-// export const BASE_URL = 'http://www.hoomeng.pet/api'
-export const BASE_URL = 'http://111.228.46.254/api'
+export const BASE_URL = 'https://www.hoomeng.pet/api'
+// export const BASE_URL = 'http://111.228.46.254/api'
 
 // 履约者App客户端ID(需要在 sys_client 表中配置)
 export const CLIENT_ID = 'fe63fea7be31b0200b496d08bc6b517d'

+ 71 - 0
utils/index.js

@@ -47,3 +47,74 @@ export function displayTime(time) {
   
   return formatTime(date, 'MM-dd HH:mm')
 }
+
+/**
+ * 解密/解码 Base64 字符串为 UTF-8 字符串
+ * @param {string} str - Base64 编码的字符串
+ * @returns {string}
+ */
+export function decodeBase64(str) {
+  if (!str) return ''
+  const cleanStr = String(str).trim().replace(/\s+/g, '')
+  // 检查是否为 base64 格式
+  const isBase64 = /^[A-Za-z0-9+/=]+$/.test(cleanStr)
+  if (!isBase64) return str
+
+  try {
+    // 1. Base64 解码为二进制字符串
+    const atobPolyfill = (s) => {
+      if (typeof atob === 'function') return atob(s)
+      const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
+      let output = ''
+      const clean = s.replace(/=+$/, '')
+      for (let bc = 0, bs, buffer, idx = 0; idx < clean.length; ) {
+        const char = clean.charAt(idx++)
+        const buffer = chars.indexOf(char)
+        if (buffer === -1) throw new Error('Invalid base64 character')
+        bs = bc % 4 ? bs * 64 + buffer : buffer
+        if (bc++ % 4) {
+          output += String.fromCharCode(255 & bs >> (-2 * bc & 6))
+        }
+      }
+      return output
+    }
+
+    const decodedBinary = atobPolyfill(cleanStr)
+
+    // 2. 将二进制字符串解码为 UTF-8 字符串
+    const decodeUtf8 = (bin) => {
+      let result = ''
+      let i = 0
+      while (i < bin.length) {
+        const c1 = bin.charCodeAt(i++)
+        if (c1 < 128) {
+          result += String.fromCharCode(c1)
+        } else if (c1 > 191 && c1 < 224) {
+          const c2 = bin.charCodeAt(i++)
+          result += String.fromCharCode(((c1 & 31) << 6) | (c2 & 63))
+        } else if (c1 > 223 && c1 < 240) {
+          const c2 = bin.charCodeAt(i++)
+          const c3 = bin.charCodeAt(i++)
+          result += String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63))
+        } else {
+          const c2 = bin.charCodeAt(i++)
+          const c3 = bin.charCodeAt(i++)
+          const c4 = bin.charCodeAt(i++)
+          const codepoint = ((c1 & 7) << 18) | ((c2 & 63) << 12) | ((c3 & 63) << 6) | (c4 & 63)
+          if (codepoint > 0xffff) {
+            const offset = codepoint - 0x10000
+            result += String.fromCharCode((offset >> 10) + 0xd800, (offset & 0x3ff) + 0xdc00)
+          } else {
+            result += String.fromCharCode(codepoint)
+          }
+        }
+      }
+      return result
+    }
+
+    return decodeUtf8(decodedBinary)
+  } catch (e) {
+    console.error('Base64 decode failed:', e)
+    return str
+  }
+}