Browse Source

feat(mine): 微信视频号关联功能

- 在设计师详情页面添加微信视频号关联功能- 实现视频号解绑功能
- 优化视频号打开逻辑,增加错误处理
- 更新相关请求和状态管理
EvilDragon 4 months ago
parent
commit
1ec81412a5

+ 2 - 2
packages/app/src/core/utils/router.ts

@@ -16,9 +16,9 @@ export const useRouter = () => {
       return false
     }
     if (switchTab) {
-      uni.switchTab({ url: path })
+      uni.switchTab({ url })
     } else {
-      uni.navigateTo({ url: path })
+      uni.navigateTo({ url })
     }
   }
   const replace = async (path: string) => {

+ 5 - 4
packages/app/src/pages/mine/homepage/channels/index.vue

@@ -9,7 +9,9 @@ import { storeToRefs } from 'pinia'
 import { pick } from 'radash'
 import { requestToast } from '../../../../core/utils/common'
 import BottomAppBar from '@/components/bottom-app-bar.vue'
+import { useMessage } from 'wot-design-uni'
 
+const { alert } = useMessage()
 const userStore = useUserStore()
 const { userInfo } = storeToRefs(userStore)
 const form = ref<{
@@ -19,10 +21,9 @@ const form = ref<{
 const { data, run: setData } = useRequest(() => getDesignerInfo(userInfo.value.userId))
 const { loading, run: submiting } = useRequest(() => updateDesignerInfo(form.value))
 const handleSubmit = async () => {
-  await requestToast(submiting, {
-    success: true,
-    successTitle: '关联成功',
-  }).then(() => setData())
+  await submiting()
+  await setData()
+  alert({ title: '关联成功', confirmButtonText: '我知道了' })
 }
 onMounted(async () => {
   await setData()

+ 43 - 5
packages/app/src/pages/mine/homepage/index.vue

@@ -13,6 +13,7 @@ import {
   getCircles,
   getDesignerInfo,
   getUserInfoById,
+  updateDesignerInfo,
 } from '../../../core/libs/requests'
 import { useUserStore } from '../../../store'
 import { storeToRefs } from 'pinia'
@@ -83,9 +84,33 @@ const handleMomentDelete = async (id) => {
   })
 }
 const handle2Video = () => {
-  // wx.openChannelsUserProfile({ finderUserName: 'sphtEhk7olIepB0' })
-
-  uni.openChannelsUserProfile({ finderUserName: designerInfo.value?.videoNumber })
+  try {
+    uni.openChannelsUserProfile({ finderUserName: designerInfo.value?.videoNumber })
+  } catch (e) {
+    uni.showToast({
+      title: '打开失败',
+      icon: 'none',
+    })
+  }
+}
+const handleUnbundle = async () => {
+  confirm({
+    title: '警告',
+    msg: '确定要解绑吗?',
+    beforeConfirm: async ({ resolve }) => {
+      await requestToast(
+        () =>
+          updateDesignerInfo({
+            id: designerInfo.value.id,
+            userId: designerInfo.value.userId,
+            videoNumber: '',
+          }),
+        { success: true, successTitle: '解绑成功' },
+      )
+      await setDesignerInfo()
+      resolve(true)
+    },
+  })
 }
 onLoad(async (query: { id: string }) => {
   if (query.id) {
@@ -100,6 +125,9 @@ onLoad(async (query: { id: string }) => {
     viewStartAt.value = new Date()
   }
 })
+onShow(async () => {
+  await setDesignerInfo()
+})
 onUnload(async () => {
   if (!isOwn.value) {
     viewDuration.value = dayjs().diff(viewStartAt.value, 'seconds')
@@ -186,8 +214,18 @@ defineExpose({
         class="bg-gradient-to-t from-[#fdf6ee] to-[#fefdfc] rounded-[10px] border border-[#fff4e6] border-solid flex items-center px-3.5 py-5 gap-3"
         @click="handle2Video"
       >
-        <div class="w-[37.01px] h-[37.01px] bg-[#fa9d3b] rounded-lg">
-          <wd-img width="100%" height="100%" :src="wechatChannels"></wd-img>
+        <div>
+          <div class="w-[37.01px] h-[37.01px] bg-[#fa9d3b] rounded-lg">
+            <wd-img width="100%" height="100%" :src="wechatChannels"></wd-img>
+          </div>
+          <div v-if="(designerInfo?.videoNumber ?? '') !== ''" @click.stop="handleUnbundle">
+            <div
+              class="text-[#da7e1e] text-[9px] font-normal font-['PingFang_SC'] leading-normal flex items-center"
+            >
+              解绑
+              <wd-icon name="arrow-right" size="12"></wd-icon>
+            </div>
+          </div>
         </div>
         <div class="flex-1">
           <div class="text-black/90 text-sm font-normal font-['PingFang SC'] leading-normal">