wupengfei
2 天以前 0224735fb1cba46f6549adfa1f60ffd6b5041b72
packages/components/src/views/GasBillRecharge/GasBillRechargeStep3.vue
@@ -6,63 +6,82 @@
    label-position="top"
    class="order-bill-recharge electric"
  >
    <NutFormItem class="bole-form-item" prop="currentUserAccountId">
      <NutRadioGroup
        v-model="form.currentUserAccountId"
        direction="horizontal"
        class="par-account-list"
        v-if="userAccountAllList.length > 0"
        @change="handleUserAccountChange"
      >
        <NutRadio :label="item.id" shape="button" v-for="item in userAccountAllList" :key="item.id"
          >{{ item.city }}-{{ item.content }}</NutRadio
    <Chunk borderRadiusSmall :hasPaddingBottom="false">
      <NutFormItem class="bole-form-item user-account-form-item" prop="currentUserAccountId">
        <NutRadioGroup
          v-model="form.currentUserAccountId"
          direction="horizontal"
          class="par-account-list"
          v-if="userAccountAllList.length > 0"
          @change="handleUserAccountChange"
        >
      </NutRadioGroup>
      <AccountCard
        v-if="userAccountAllList.length > 0"
        title="充值户号"
        :content="`${form.areaList?.[1] ?? ''} ${form.gasAccount}`"
        :remark="form.remark"
      >
        <template #action>
          <div class="account-card-action" @click="handleAddUserAccount">新增</div>
        </template>
      </AccountCard>
      <AccountAddCard text="新增户号" v-else @click="handleAddUserAccount" />
    </NutFormItem>
          <NutRadio
            :label="item.id"
            shape="button"
            v-for="item in userAccountAllList"
            :key="item.id"
            >{{ item.city }}-{{ item.content }}</NutRadio
          >
        </NutRadioGroup>
        <AccountCardV2
          v-if="userAccountAllList.length > 0"
          :content="`${form.areaList?.[1] ?? ''} ${form.gasAccount}`"
          :remark="form.remark"
          :showEditBtn="!!form.currentUserAccountId"
          @add="handleAddUserAccount"
          @edit="emit('editUserAccount', form.currentUserAccountId)"
        >
        </AccountCardV2>
        <AccountAddCardV2
          content="去添加充值户号"
          remark="添加户号将保存在生活缴费进行管理"
          tip="添加正确户号"
          v-else
          @click="handleAddUserAccount"
        />
      </NutFormItem>
    </Chunk>
    <NutFormItem label="选择充值金额" class="bole-form-item" prop="parValue" required>
      <NutRadioGroup v-model="form.parValue" direction="horizontal" class="parValue-radio-group">
        <NutRadio
          :label="Number(item)"
          :key="item"
          shape="button"
          v-for="item in gasValueList"
          class="parValue-item"
        >
          <div class="parValue-item-inner">
            <div class="amount-wrapper">
              <div class="amount">{{ item }}</div>
              <div class="unit">元</div>
            </div>
            <div class="price-wrapper">
              <div class="price-text">折后</div>
              <div class="price">
                {{ blLifeRecharge.getRechargeParValue(item, lifePayGasRate) }}元
    <Chunk borderRadiusSmall :hasPaddingBottom="false" title="选择充值金额">
      <NutFormItem class="bole-form-item" prop="parValue" required>
        <NutRadioGroup v-model="form.parValue" direction="horizontal" class="parValue-radio-group">
          <NutRadio
            :label="Number(item)"
            :key="item"
            shape="button"
            v-for="item in gasValueList"
            class="parValue-item"
          >
            <div class="parValue-item-inner">
              <div class="amount-wrapper">
                <div class="amount">{{ item }}</div>
                <div class="unit">元</div>
              </div>
              <div class="price-wrapper">
                <div class="price-text">折后</div>
                <div class="price">
                  {{ blLifeRecharge.getRechargeParValue(item, lifePayGasRate) }}元
                </div>
              </div>
              <div class="discountTag" v-if="lifePayGasRate > 0">{{ lifePayGasRate }}折</div>
              <img :src="IconSelect" class="discount-icon" />
            </div>
            <div class="discountTag">{{ lifePayGasRate }}折</div>
          </div>
        </NutRadio>
      </NutRadioGroup>
    </NutFormItem>
          </NutRadio>
        </NutRadioGroup>
      </NutFormItem>
    </Chunk>
    <SelectPayTypeFormItem
      v-model="form.lifePayType"
      :showWeixinPay="showWeixinPay"
      :showAliPay="showAliPay"
    ></SelectPayTypeFormItem>
    <div class="common-content">
      <nut-button class="recharge-button" type="primary" @click="handleSubmit">
      <nut-button
        class="recharge-button recharge-button-linear"
        type="primary"
        @click="handleSubmit"
      >
        <div class="recharge-button-inner">
          <div>¥{{ realParValue }}</div>
          <div class="recharge-button-text">立即充值</div>
@@ -116,14 +135,16 @@
import { useGetRate, useGetGasParValue, useSetUserAccountBySelect } from '../../hooks';
import { useGasBillRechargeContext, GasUserAccountExtraProperties } from './context';
import { FormValidator, initLifePayType } from '../../utils';
import AccountAddCard from '../../components/Card/AccountAddCard.vue';
import AccountCard from '../../components/Card/AccountCard.vue';
import AccountAddCardV2 from '../../components/Card/AccountAddCardV2.vue';
import AccountCardV2 from '../../components/Card/AccountCardV2.vue';
import RechargeTipsView from '../../components/RechargeTipsView/RechargeTipsView.vue';
import ConfirmDialog from '../../components/Dialog/ConfirmDialog.vue';
import ConfirmDialogInfoItem from '../../components/Dialog/ConfirmDialogInfoItem.vue';
import SelectPayTypeFormItem from '../../components/SelectPayTypeFormItem/SelectPayTypeFormItem.vue';
import { useSelectPayType, useGetPayStatusByOrderNo } from '../../hooks/selectPayType';
import { RechargeProps } from '../PhoneBillRecharge/types';
import Chunk from '../../components/Layout/Chunk.vue';
import IconSelect from '../../assets/recharge/icon-select.png';
defineOptions({
  name: 'GasBillRechargeStep3',
@@ -136,6 +157,8 @@
const emit = defineEmits<{
  (e: 'goPay', orderNo: string): void;
  (e: 'paySuccess', orderNo: string): void;
  (e: 'missName', userAccountId: string): void;
  (e: 'editUserAccount', userAccountId: string): void;
}>();
const { goTo } = useGasBillRechargeContext();
@@ -155,6 +178,7 @@
  remark: '',
  areaList: [] as string[],
  lifePayType: initLifePayType(props.isInWeChat, props.isInAlipay),
  name: '',
});
const { userAccountAllList, handleUserAccountChange } = useSetUserAccountBySelect({
@@ -169,6 +193,7 @@
    form.gasOrgType = currentUserAccount.operators;
    form.remark = currentUserAccount.remark;
    form.name = currentUserAccountExtraProperties.name ?? '';
    const gasParValueItem = gasParValueList.value.find((x) => x.gasOrgCode === form.gasOrgType);
    if (gasParValueItem && gasParValueItem.parValue.every((x) => Number(x) !== form.parValue)) {
      form.parValue = 0;
@@ -208,6 +233,10 @@
  if (!formRef.value) return;
  formRef.value.validate().then(({ valid, errors }: any) => {
    if (valid) {
      if (!form.name) {
        emit('missName', form.currentUserAccountId);
        return;
      }
      recharge();
    }
  });
@@ -220,7 +249,7 @@
}
const { state, invokeAliPay, invokeWeixinPay } = useSelectPayType({
  getOpenId: props.getOpenId,
  getOpenId: toRef(props, 'getOpenId'),
  isInWeChat: toRef(props, 'isInWeChat'),
  isH5: toRef(props, 'isH5'),
  appId: toRef(props, 'appId'),
@@ -239,6 +268,7 @@
        gasAccount: form.gasAccount,
        province: form.areaList?.[0] ?? '',
        city: form.areaList?.[1] ?? '',
        // name: form.name,
      },
    };
    let res = await blLifeRecharge.services.createLifePayGasOrder(params);