| | |
| | | <PageLayout title="立即申请" class="applyAgent-page-wrapper" hasBgColor :needAuth="false"> |
| | | <ResultWithoutBG |
| | | remark="我们的运营人员会在5个工作日内联系您沟通代理事宜,请保持电话畅通!" |
| | | tips="注:成功招募代理商,还有最高1000元奖励,详询请咨询:16505012333" |
| | | tips="注:成功招募代理商,还有最高1000元奖励,详询请咨询:18968263725" |
| | | title="提交成功" |
| | | @generate="generate" |
| | | ></ResultWithoutBG> |
| | |
| | | <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', |
| | | }); |
| | | |
| | | function generate() { |
| | | RouteHelper.navigateTo({ |
| | | url: RouterPath.promotionQrcode, |
| | | }); |
| | | const router = Taro.useRouter(); |
| | | const { blLifeRecharge } = useLifeRechargeContext(); |
| | | const consultationId = router.params?.consultationId ?? ''; |
| | | |
| | | 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: consultationId, |
| | | }; |
| | | return await blLifeRecharge.services.getChannelConsultationById(params); |
| | | } catch (error) {} |
| | | } |
| | | |
| | | type CreateOrUpdatePromoterOptions = { |
| | | name?: string; |
| | | phoneNumber?: string; |
| | | }; |
| | | |
| | | async function createOrUpdatePromoter(options: CreateOrUpdatePromoterOptions = {}) { |
| | | try { |
| | | const { name, phoneNumber } = options; |
| | | let params: CreateOrUpdatePromoterInput = { |
| | | userId: blLifeRecharge.accountModel.userId, |
| | | name: name, |
| | | phoneNumber: phoneNumber, |
| | | }; |
| | | return await blLifeRecharge.services.createOrUpdatePromoter(params); |
| | | } catch (error) {} |
| | | } |
| | | |
| | | async function generate() { |
| | | try { |
| | | if (consultationId) { |
| | | let res = await getChannelConsultationById(); |
| | | if (res) { |
| | | let promoterRes = await getPromoter(res.phoneNumber); |
| | | let idNumber: string; |
| | | if (promoterRes?.idNumber) { |
| | | idNumber = promoterRes.idNumber; |
| | | } else { |
| | | let createOrUpdatePromoterRes = await createOrUpdatePromoter({ |
| | | name: res.name, |
| | | phoneNumber: res.phoneNumber, |
| | | }); |
| | | idNumber = createOrUpdatePromoterRes.idNumber; |
| | | } |
| | | if (idNumber) { |
| | | if (res.phoneNumber === blLifeRecharge.accountModel.phoneNumber) { |
| | | blLifeRecharge.accountModel.setUserPromoterIdNumber(idNumber); |
| | | } |
| | | RouteHelper.navigateTo({ |
| | | url: `${RouterPath.promotionQrcode}?promoterIdNumber=${idNumber}`, |
| | | }); |
| | | } |
| | | } |
| | | } |
| | | } catch (error) {} |
| | | } |
| | | </script> |