From 74953600e30027aa89aec6eeb939a182a2a7ecda Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期一, 09 六月 2025 16:20:05 +0800
Subject: [PATCH] feat: 接口

---
 apps/taro/src/subpackages/my/applyResult/applyResult.vue |   67 ++++++++++++++++++++++++++++++---
 1 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/apps/taro/src/subpackages/my/applyResult/applyResult.vue b/apps/taro/src/subpackages/my/applyResult/applyResult.vue
index 59e712a..c916847 100644
--- a/apps/taro/src/subpackages/my/applyResult/applyResult.vue
+++ b/apps/taro/src/subpackages/my/applyResult/applyResult.vue
@@ -12,19 +12,74 @@
 <script setup lang="ts">
 import { PageLayout } from '@/components';
 import { ResultWithoutBG } from '@life-payment/components';
+import {
+  APIgetChannelConsultationByIdParams,
+  APIgetPromoterParams,
+  CreateOrUpdatePromoterInput,
+  useLifeRechargeContext,
+} from '@life-payment/core-vue';
 import Taro from '@tarojs/taro';
 
 defineOptions({
-  name: 'applyAgent',
+  name: 'applyResult',
 });
 
 const router = Taro.useRouter();
+const { blLifeRecharge } = useLifeRechargeContext();
 
-const promoterIdNumber = router.params?.promoterIdNumber ?? '';
+const channelConsultationId = router.params?.channelConsultationId ?? '';
+console.log('channelConsultationId: ', channelConsultationId);
 
-function generate() {
-  RouteHelper.navigateTo({
-    url: `${RouterPath.generatePromotionCode}?promoterIdNumber=${promoterIdNumber}`,
-  });
+async function getPromoter(phoneNumber: string) {
+  try {
+    let params: APIgetPromoterParams = {
+      phoneNumber: phoneNumber,
+    };
+    return await blLifeRecharge.services.getPromoter(params);
+  } catch (error) {}
+}
+
+async function getChannelConsultationById() {
+  try {
+    let params: APIgetChannelConsultationByIdParams = {
+      id: channelConsultationId,
+    };
+    return await blLifeRecharge.services.getChannelConsultationById(params);
+  } catch (error) {}
+}
+
+async function createOrUpdatePromoter(name: string, phoneNumber: string) {
+  try {
+    let params: CreateOrUpdatePromoterInput = {
+      userId: blLifeRecharge.accountModel.userId,
+      name: name,
+      phoneNumber: phoneNumber,
+    };
+    return await blLifeRecharge.services.createOrUpdatePromoter(params);
+  } catch (error) {}
+}
+
+async function generate() {
+  try {
+    if (channelConsultationId) {
+      let res = await getChannelConsultationById();
+      if (res) {
+        let promoterIdNumber = await getPromoter(res.phoneNumber);
+        if (promoterIdNumber) {
+          RouteHelper.navigateTo({
+            url: `${RouterPath.promotionQrcode}?promoterIdNumber=${promoterIdNumber}`,
+          });
+        } else {
+          let promoterIdNumber = await createOrUpdatePromoter(res.name, res.phoneNumber);
+          if (promoterIdNumber) {
+            RouteHelper.navigateTo({
+              url: `${RouterPath.promotionQrcode}?promoterIdNumber=${res}`,
+            });
+          }
+        }
+      }
+    } else {
+    }
+  } catch (error) {}
 }
 </script>

--
Gitblit v1.9.1