Bläddra i källkod

feat(core): 添加用户协议相关功能

- 新增 AgreementType 枚举,定义各种用户协议类型
- 实现 toContentHtml 函数,支持带协议类型的页面跳转
- 在登录页面集成用户协议链接
- 添加 fakeThis 函数,用于获取协议内容
- 更新 content-html 页面,支持动态加载协议内容
EvilDragon 1 månad sedan
förälder
incheckning
5857175264

+ 1 - 0
packages/app/src/composables/analysis.ts

@@ -22,6 +22,7 @@ export const useAnalysis = (automatic: boolean, isApp = false) => {
   const option = ref<Record<string, any>>({})
 
   const report = async (type) => {
+    if (!isLogined.value) return
     const duration = automatic
       ? (viewDuration.value = dayjs().diff(viewStartAt.value, 'second'))
       : 0

+ 1 - 5
packages/app/src/core/libs/actions.ts

@@ -5,6 +5,7 @@ import { useRouter } from '../utils/router'
 import { Coupon } from './models'
 import { useMessage } from 'wot-design-uni'
 import { MessageOptions, MessageResult } from 'wot-design-uni/components/wd-message-box/types'
+import {AgreementType} from "@/core/libs/enums";
 
 const toast = (title: string) => uni.showToast({ title, icon: 'none' })
 export const handleUpvoteClick = async (
@@ -58,8 +59,3 @@ export const handleClickInstruction = (
     msg: coupon.couponDO.couponDesc,
   })
 }
-export const toContentHtml = async (option: { title: string }) => {
-  await uni.navigateTo({
-    url: `/pages/common/content-html/index?title=${option.title}`,
-  })
-}

+ 29 - 0
packages/app/src/core/libs/enums.ts

@@ -49,3 +49,32 @@ export enum PointStatus {
    */
   Revoked = 4,
 }
+// TYPE_1(1, "个人微信视频号授权使用协议"),
+//
+//   TYPE_2(2, "筑巢荟服务使用协议"),
+//   TYPE_3(3, "筑巢荟用户注册协议"),
+//   TYPE_4(4, "筑巢荟用户隐私协议"),
+//   TYPE_5(5, "荟务服务使用协议"),
+
+export enum AgreementType {
+  /**
+   * 个人微信视频号授权使用协议
+   */
+  PersonalWeChatVideoAuthorization = 1,
+  /**
+   * 筑巢荟服务使用协议
+   */
+  ZCHServiceAgreement = 2,
+  /**
+   * 筑巢荟用户注册协议
+   */
+  ZCHUserRegistrationAgreement = 3,
+  /**
+   * 筑巢荟用户隐私协议
+   */
+  ZCHUserPrivacyAgreement = 4,
+  /**
+   * 荟务服务使用协议
+   */
+  HuiWuServiceAgreement = 5,
+}

+ 3 - 0
packages/app/src/core/libs/requests.ts

@@ -26,6 +26,7 @@ import {
   ConfirmOrder,
 } from './models'
 import dayjs from 'dayjs'
+import { AgreementType } from '@/core/libs/enums'
 
 export const getUserInfo = () =>
   httpGetMock<any>({
@@ -974,6 +975,8 @@ export const getAgents = () =>
       customerName: string
     }[]
   >('/app-api/member/user/getCustomerServiceList')
+export const fakeThis = (query: { agreement: AgreementType }) =>
+  httpGet<string>('/app-api/infra/file/download', query)
 export const refreshToken = (refreshToken: string) =>
   httpPost<any>('/app-api/member/auth/refresh-token', {}, { refreshToken })
 export const httpGetMock = <T>(data: T) =>

+ 6 - 0
packages/app/src/core/utils/common.ts

@@ -1,4 +1,5 @@
 import dayjs from 'dayjs'
+import {AgreementType} from "@/core/libs/enums";
 export const handleCall = (phone: string) => {
   uni.makePhoneCall({ phoneNumber: phone }).then()
 }
@@ -193,3 +194,8 @@ export const formatDuration = (duration: number) => {
     )}分钟`
   }
 }
+export const toContentHtml = async (option: { title: string; type: AgreementType }) => {
+  await uni.navigateTo({
+    url: `/pages/common/content-html/index?title=${option.title}&type=${option.type}`,
+  })
+}

+ 16 - 8
packages/app/src/pages/common/content-html/index.vue

@@ -1,25 +1,33 @@
 <route lang="json">
 {
-"style": {
-"navigationBarTitleText": "",
-"navigationBarBackgroundColor": "#fff"
-}
+  "style": {
+    "navigationBarTitleText": "",
+    "navigationBarBackgroundColor": "#fff"
+  }
 }
 </route>
 <script setup lang="ts">
 import mpHtml from 'mp-html/dist/uni-app/components/mp-html/mp-html.vue'
+import { fakeThis } from '@/core/libs/requests'
 
-const content = '<div></div>'
-onLoad(async (query?: Record<string | 'title', string>) => {
+const type = ref()
+const { data: content, run: setData } = useRequest(() => fakeThis({ agreement: type.value }))
+onLoad(async (query?: Record<string | 'title' | 'type', string>) => {
   if (query?.title) {
-    console.log(query.title)
-    await uni.setNavigationBarTitle({title: query.title})
+    await uni.setNavigationBarTitle({ title: query.title })
+  }
+  if (query?.type) {
+    type.value = query.type
   }
+  await setData()
 })
 </script>
 
 <template>
   <mpHtml :content="content"></mpHtml>
+  <!--  <web-view-->
+  <!--    :src="`https://www.zhuchaohui.com/app-api/infra/file/download?agreement=${type}`"-->
+  <!--  ></web-view>-->
 </template>
 
 <style scoped lang="scss"></style>

+ 0 - 1
packages/app/src/pages/home/spread/case-shooting/index.vue

@@ -58,7 +58,6 @@ onShareTimeline(() => ({
                 </div>
                 <div class="text-black/60 text-sm font-normal font-['PingFang_SC'] leading-[34px]">
                   {{ String(it.needPoints) == '1' ? '折' : '积分' }}
-
                 </div>
                 <div class="flex-1"></div>
                 <div

+ 10 - 4
packages/app/src/pages/login/index.vue

@@ -6,7 +6,8 @@ style:
 import { testLogin, weixinMiniAppLogin } from '../../core/libs/requests'
 import { logo } from '../../core/libs/svgs'
 import { useUserStore } from '../../store'
-import { toContentHtml } from '@/core/libs/actions'
+import { toContentHtml } from '@/core/utils/common'
+import { AgreementType } from '@/core/libs/enums'
 
 const userStore = useUserStore()
 const { setUserInfo } = userStore
@@ -90,19 +91,24 @@ onLoad(async (query: { type?: 'test' }) => {
             如您点击授权,您将同意并授权
           </span>
           <span
-            @click="toContentHtml({ title: '筑巢荟用户服务协议' })"
+            @click="
+              toContentHtml({
+                title: '筑巢荟用户服务协议',
+                type: AgreementType.HuiWuServiceAgreement,
+              })
+            "
             class="text-[#0cbe7c] text-xs font-normal font-['PingFang_SC'] leading-tight"
           >
             《筑巢荟用户服务协议》、
           </span>
           <span
-            @click="toContentHtml({ title: '隐私政策' })"
+            @click="toContentHtml({ title: '隐私政策', type: AgreementType.PrivacyPolicy })"
             class="text-[#0cbe7c] text-xs font-normal font-['PingFang_SC'] leading-tight"
           >
             《隐私政策》、
           </span>
           <span
-            @click="toContentHtml({ title: '注册协议' })"
+            @click="toContentHtml({ title: '注册协议', type: AgreementType.RegisterAgreement })"
             class="text-[#0cbe7c] text-xs font-normal font-['PingFang_SC'] leading-tight"
           >
             《注册协议》

+ 4 - 2
packages/merchant/src/core/libs/actions.ts

@@ -1,3 +1,5 @@
+import { AgreementType } from '@/core/libs/enums'
+
 const toast = (title: string) => uni.showToast({ title, icon: 'none' })
 
 export const toHomePage = (id: string) => {
@@ -10,8 +12,8 @@ export const toHomePage = (id: string) => {
     })
     .then()
 }
-export const toContentHtml = async (option: { title: string }) => {
+export const toContentHtml = async (option: { title: string; type: AgreementType }) => {
   await uni.navigateTo({
-    url: `/pages/common/content-html/index?title=${option.title}`,
+    url: `/pages/common/content-html/index?title=${option.title}&type=${option.type}`,
   })
 }

+ 22 - 0
packages/merchant/src/core/libs/enums.ts

@@ -36,3 +36,25 @@ export enum NetImages {
   DefaultAvatar = 'https://image.zhuchaohui.com/zhucaohui/0b57771c2fbe60157e592a5b0e51a2b2b6c5263300663ad33efd55b235a2402a.png',
   DefaultPointsHeadBg = 'https://image.zhuchaohui.com/zhucaohui/7442ae6cb5f8ea83269595d4ee621bd21da2c42c23db113f18bd6f25f70572aa.png',
 }
+export enum AgreementType {
+  /**
+   * 个人微信视频号授权使用协议
+   */
+  PersonalWeChatVideoAuthorization = 1,
+  /**
+   * 筑巢荟服务使用协议
+   */
+  ZCHServiceAgreement = 2,
+  /**
+   * 筑巢荟用户注册协议
+   */
+  ZCHUserRegistrationAgreement = 3,
+  /**
+   * 筑巢荟用户隐私协议
+   */
+  ZCHUserPrivacyAgreement = 4,
+  /**
+   * 荟务服务使用协议
+   */
+  HuiWuServiceAgreement = 5,
+}

+ 3 - 0
packages/merchant/src/core/libs/requests.ts

@@ -6,6 +6,7 @@ import {
   Agent,
   AgentTask,
 } from '@designer-hub/app/src/core/libs/models'
+import {AgreementType} from "@/core/libs/enums";
 
 export const httpGetMock = <T>(data: T) =>
   new Promise<IResData<T>>((resolve) => resolve({ code: 1, msg: '', data } as IResData<T>))
@@ -228,3 +229,5 @@ export interface UpdatePasswordData {
  */
 export const updatePassword = (data: UpdatePasswordData) =>
   httpPut('/app-api/member/auth/update-password', data)
+export const fakeThis = (query: { agreement: AgreementType }) =>
+  httpGet<string>('/app-api/infra/file/download', query)

+ 16 - 8
packages/merchant/src/pages/common/content-html/index.vue

@@ -1,25 +1,33 @@
 <route lang="json">
 {
-"style": {
-"navigationBarTitleText": "",
-"navigationBarBackgroundColor": "#fff"
-}
+  "style": {
+    "navigationBarTitleText": "",
+    "navigationBarBackgroundColor": "#fff"
+  }
 }
 </route>
 <script setup lang="ts">
 import mpHtml from 'mp-html/dist/uni-app/components/mp-html/mp-html.vue'
+import { fakeThis } from '@/core/libs/requests'
 
-const content = '<div></div>'
-onLoad(async (query?: Record<string | 'title', string>) => {
+const type = ref()
+const { data: content, run: setData } = useRequest(() => fakeThis({ agreement: type.value }))
+onLoad(async (query?: Record<string | 'title' | 'type', string>) => {
   if (query?.title) {
-    console.log(query.title)
-    await uni.setNavigationBarTitle({title: query.title})
+    await uni.setNavigationBarTitle({ title: query.title })
+  }
+  if (query?.type) {
+    type.value = query.type
   }
+  await setData()
 })
 </script>
 
 <template>
   <mpHtml :content="content"></mpHtml>
+  <!--  <web-view-->
+  <!--    :src="`https://www.zhuchaohui.com/app-api/infra/file/download?agreement=${type}`"-->
+  <!--  ></web-view>-->
 </template>
 
 <style scoped lang="scss"></style>

+ 7 - 1
packages/merchant/src/pages/login/index.vue

@@ -9,6 +9,7 @@ import { login } from '../../core/libs/requests'
 import { useUserStore } from '../../store'
 import { loginAccountIcon, loginPswIcon } from '@designer-hub/assets/src/svgs'
 import { toContentHtml } from '@/core/libs/actions'
+import { AgreementType } from '@/core/libs/enums'
 
 const userStore = useUserStore()
 const { isLogined } = storeToRefs(userStore)
@@ -84,7 +85,12 @@ onShareAppMessage(async () => ({}))
         </span>
         <span
           class="text-[#2357e9] text-xs font-normal font-['PingFang_SC'] leading-tight"
-          @click="toContentHtml({ title: '服务使用协议' })"
+          @click="
+            toContentHtml({
+              title: '服务使用协议',
+              type: AgreementType.HuiWuServiceAgreement,
+            })
+          "
         >
           《服务使用协议》
         </span>