• zhangsan's avatar
    1 · e355679b
    zhangsan authored
    e355679b
rydsjd.vue 2.72 KB
<template>
  <div class="ryds-page">
    <pay-up ref="payUpRef" />
    <div class="step-container" v-if="userInfo.a1">
      <var-steps direction="vertical" :active="userInfo.a3">
        <var-step v-for="(step, stepIndex) in getSteps(userInfo)" :key="stepIndex">
          <template #default>
            <div class="step-content">
              <span class="step-text">{{ step.text }}</span>
              <var-button 
                v-if="step.amount && stepIndex === userInfo.a3" 
                type="danger" 
                size="small"
                @click="handlePay(step)"
              >
                立即缴纳
              </var-button>
            </div>
          </template>
        </var-step>
      </var-steps>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import request from '@/utils/request'
import payUp from '@/components/payUp.vue'

interface UserInfo {
  a1: string
  a2: string
  a3: string
  a4: string
  id: string
}

const payUpRef = ref(null)
const userInfo = ref<UserInfo>({
  a1: '',
  a2: '',
  a3: '',
  a4: '',
  id: ''
})

// 步骤配置
const baseSteps = [
  { text: '邀请好友' },
  { text: '正在审核' },
  { text: '审核失败' },
  { text: '跳过审核', amount: 600 },
  { text: '正在下发' },
  { text: '立即到帐', amount: 300 },
  { text: '入款中' }
]

const getSteps = (info: UserInfo) => {
  return baseSteps.filter((item, index) => index <= parseInt(info.a3) || 0)
}

// 获取用户申请信息
const fetchUserInfo = async () => {
  try {
    const res = await request.get('/business/businessYw2/getByUserOne')
    if (res.result) {
      userInfo.value = {
        ...res.result,
        a3: parseInt(res.result.a3) || 0
      }
    }
  } catch (error) {
    console.error('获取用户信息失败:', error)
  }
}

// 处理支付
const handlePay = (step: { amount: number; text: string }) => {
  payUpRef.value?.open({
    amount: step.amount,
    payTitle: step.text,
    payType: 2,
    productId: userInfo.value.id,
    needPassword: false
  })
}

onMounted(() => {
  fetchUserInfo()
})
</script>

<style scoped lang="scss">
.ryds-page {
  height: inherit;
  box-sizing: border-box;
  background: url('@/static/cbg1.png') no-repeat center center;
  background-size: 100% 100%;
  padding: 20px;
}

.step-container {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
}

.step-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.step-text {
  font-size: 14px;
  color: #323233;
}

:deep(.van-step) {
  .van-step__circle {
    background-color: #1989fa;
    border-color: #1989fa;
  }

  .van-step__line {
    background-color: #1989fa;
  }
}

:deep(.van-step--vertical) {
  padding: 10px 10px 10px 0;
}
</style>