| | |
| | | import { Form as NutForm, FormItem as NutFormItem, Input as NutInput } from '@nutui/nutui-taro'; |
| | | import { FormRules } from '@nutui/nutui-taro/dist/types/__VUE/form/types'; |
| | | import { reactive, ref } from 'vue'; |
| | | import { useLifeRechargeContext } from '@life-payment/core-vue'; |
| | | import { CreateOrUpdatePromoterInput, useLifeRechargeContext } from '@life-payment/core-vue'; |
| | | import { FormValidator } from '../../utils'; |
| | | |
| | | defineOptions({ |
| | | name: 'ApplyAgentView', |
| | | name: 'GeneratePromotionCodeView', |
| | | }); |
| | | |
| | | const emit = defineEmits<{ |
| | | (e: 'submit'): void; |
| | | (e: 'submit', data: string): void; |
| | | }>(); |
| | | |
| | | const form = reactive({ |
| | |
| | | if (!formRef.value) return; |
| | | formRef.value.validate().then(({ valid, errors }: any) => { |
| | | if (valid) { |
| | | refundUserLifePayOrder(); |
| | | createOrUpdatePromoter(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | async function refundUserLifePayOrder() { |
| | | async function createOrUpdatePromoter() { |
| | | try { |
| | | // let params = { |
| | | // userId: blLifeRecharge.accountModel.userId, |
| | | // refundApplyRemark: form.refundApplyRemark, |
| | | // }; |
| | | // let res = await blLifeRecharge.services.refundUserLifePayOrder(params); |
| | | emit('submit'); |
| | | let params: CreateOrUpdatePromoterInput = { |
| | | userId: blLifeRecharge.accountModel.userId, |
| | | name: form.name, |
| | | phoneNumber: form.phoneNumber, |
| | | }; |
| | | let res = await blLifeRecharge.services.createOrUpdatePromoter(params); |
| | | if (res) { |
| | | if (params.phoneNumber === blLifeRecharge.accountModel.phoneNumber) { |
| | | blLifeRecharge.accountModel.setUserPromoterIdNumber(res.idNumber); |
| | | } |
| | | emit('submit', res.idNumber); |
| | | } |
| | | } catch (error) {} |
| | | } |
| | | |