zzzz
2024-04-23 b6d88ca4a4b0d74c007fb4c574b1baee4aae062e
src/page/user/yeb.vue
@@ -1,31 +1,35 @@
<template>
  <div class="wrapper">
    <van-nav-bar
      :title="($t('yeb'))"
      :right-text="($t('jl'))"
      :title="$t('yeb')"
      :right-text="$t('jl')"
      left-arrow
      fixed
      @click-left="handleBackClick"
      @click-right="go_yebs"
    />
    <div class="main">
      <div class="ul" v-for="(item, i) in $store.state.yebinfo" :key="i + '_' + item.id">
      <div class="ul" v-for="(item, i) in yebinfo" :key="i + '_' + item.id">
        <div class="li">
          <div class="li-left">
            <h3>{{ item.title }}</h3>
            <div class="li-cont">
              <div class="li-info li-1">
                <span class="li-label">{{ $t('zq') + ':' }}</span>
                <span class="li-value">{{ item.returnTime }} {{ $t('day') }}</span>
                <span class="li-label">{{ $t("周期") + ":" }}</span>
                <span class="li-value"
                  >{{ item.returnTime }} {{ $t("天") }}</span
                >
              </div>
              <div class="li-info">
                <span class="li-label">{{ $t('ll') + ':' }}</span>
                <span class="li-label">{{ $t("ll") + ":" }}</span>
                <span class="li-value">{{ item.returnOfRate }}%</span>
              </div>
            </div>
          </div>
          <div class="li-btn-box">
            <div class="btn" @click="handlePurchase(i)">{{ $t('gm') }}</div>
            <div class="btn" @click="handlePurchase(i, item)">
              {{ $t("gm") }}
            </div>
          </div>
        </div>
      </div>
@@ -33,14 +37,15 @@
    <van-dialog
      width="90%"
      v-model="showPurchase"
      :title="$t('yeb') + $t('gm')" show-cancel-button
      :title="$t('yeb') + $t('gm')"
      show-cancel-button
      :confirmButtonText="$t('qr')"
      :cancelButtonText="$t('qx')"
      @confirm="tosubmit(1,form.account1)"
      @confirm="tosubmit(1, form.account1)"
    >
      <div class="dialog-box">
        <van-field
          v-model="$store.state.userInfo.enableAmt"
          v-model="activeObj.availableBalance"
          type="text"
          :label="$t('ky') + $t('ye')"
          :placeholder="$t('ky') + $t('ye')"
@@ -56,241 +61,153 @@
          :border="false"
        >
          <template #button>
            <span @click="selectAll1">{{ $t('hj160') }}</span>
            <span @click="selectAll1">{{ $t("hj160") }}</span>
          </template>
        </van-field>
        <!-- <mt-field :label="'可用余额'" :placeholder="'可用余额'" type="text" disabled v-model="this.$store.state.userInfo.enableAmt" /> -->
        <!-- <mt-field :label="'购买数量'" name="amt" v-model="form.account1" :placeholder="'购买数量'" type="number">
          <span @click="selectAll1">{{ $t('hj160') }}</span>
        </mt-field> -->
      </div>
    </van-dialog>
    <!-- <mt-navbar v-model="selected" class="custom-navbar" >
      <mt-tab-item id="1" class="warehouse_card" >
        周期:{{ this.$store.state.yebinfo[0].returnTime }}<br>
        利率:{{ this.$store.state.yebinfo[0].returnOfRate }}%
      </mt-tab-item>
      <hr>
      <mt-tab-item id="2" class="warehouse_card">
        周期:{{ this.$store.state.yebinfo[1].returnTime }}<br>
        利率:{{ this.$store.state.yebinfo[1].returnOfRate }}%
      </mt-tab-item>
      <mt-tab-item id="3" class="warehouse_card">
        周期:{{ this.$store.state.yebinfo[2].returnTime }}<br>
        利率:{{ this.$store.state.yebinfo[2].returnOfRate }}%
      </mt-tab-item>
      <mt-tab-item id="4" class="warehouse_card">
        周期:{{ this.$store.state.yebinfo[3].returnTime }}<br>
        利率:{{ this.$store.state.yebinfo[3].returnOfRate }}%
      </mt-tab-item>
    </mt-navbar> -->
    <!-- <mt-tab-container class="order-list" v-model="selected">
        <mt-tab-container-item id="1">
            <div class="form-block">
                <mt-field :label="'可用余额'" :placeholder="'可用余额'" type="text" disabled
                          v-model="this.$store.state.userInfo.enableAmt">
                </mt-field>
            </div>
            <div class="form-block">
                <mt-field :label="'购买数量'" name="amt" v-model="form.account1" :placeholder="'购买数量'" type="number">
                      <span @click="selectAll1">{{ $t('hj160') }}</span>
                </mt-field>
            </div> -->
            <!-- <div class="form-block">
                <mt-field label="资金密码" placeholder="资金密码" type="password" v-model="form.password"></mt-field>
            </div>
            <p class="prompt">资金密码默认为登录密码</p> -->
            <!-- <div class="btnbox">
                <span class="text-center btnok loginout" @click="tosubmit(1,form.account1)">购买余额宝</span>
            </div>
        </mt-tab-container-item>
      <mt-tab-container-item id="2">
        <div class="form-block">
          <mt-field :label="'可用余额'" :placeholder="'可用余额'" type="text" disabled
                    v-model="this.$store.state.userInfo.enableAmt">
          </mt-field>
        </div>
        <div class="form-block">
          <mt-field :label="'购买数量'" name="amt" v-model="form.account1" :placeholder="'购买数量'" type="number">
            <span @click="selectAll1">{{ $t('hj160') }}</span>
          </mt-field>
        </div> -->
        <!-- <div class="form-block">
            <mt-field label="资金密码" placeholder="资金密码" type="password" v-model="form.password"></mt-field>
        </div>
        <p class="prompt">资金密码默认为登录密码</p> -->
        <!-- <div class="btnbox">
          <span class="text-center btnok loginout" @click="tosubmit(2,form.account1)">购买余额宝</span>
        </div>
      </mt-tab-container-item>
      <mt-tab-container-item id="3">
        <div class="form-block">
          <mt-field :label="'可用余额'" :placeholder="'可用余额'" type="text" disabled
                    v-model="this.$store.state.userInfo.enableAmt">
          </mt-field>
        </div>
        <div class="form-block">
          <mt-field :label="'购买数量'" name="amt" v-model="form.account1" :placeholder="'购买数量'" type="number">
            <span @click="selectAll1">{{ $t('hj160') }}</span>
          </mt-field>
        </div> -->
        <!-- <div class="form-block">
            <mt-field label="资金密码" placeholder="资金密码" type="password" v-model="form.password"></mt-field>
        </div>
        <p class="prompt">资金密码默认为登录密码</p> -->
        <!-- <div class="btnbox">
          <span class="text-center btnok loginout" @click="tosubmit(3,form.account1)">购买余额宝</span>
        </div>
      </mt-tab-container-item>
      <mt-tab-container-item id="4">
        <div class="form-block">
          <mt-field :label="'可用余额'" :placeholder="'可用余额'" type="text" disabled
                    v-model="this.$store.state.userInfo.enableAmt">
          </mt-field>
        </div>
        <div class="form-block">
          <mt-field :label="'购买数量'" name="amt" v-model="form.account1" :placeholder="'购买数量'" type="number">
            <span @click="selectAll1">{{ $t('hj160') }}</span>
          </mt-field>
        </div> -->
        <!-- <div class="form-block">
            <mt-field label="资金密码" placeholder="资金密码" type="password" v-model="form.password"></mt-field>
        </div>
        <p class="prompt">资金密码默认为登录密码</p> -->
        <!-- <div class="btnbox">
          <span class="text-center btnok loginout" @click="tosubmit(4)">购买余额宝</span>
        </div>
      </mt-tab-container-item>
    </mt-tab-container> -->
  </div>
</template>
<script>
// import '@/assets/style/common.less'
import * as api from '@/axios/api'
import { Toast } from 'mint-ui'
// import { getYebs } from '@/axios/api'
import * as api from "@/axios/api";
import { Toast } from "mint-ui";
export default {
  components: {
  },
  data () {
  components: {},
  data() {
    return {
      selected: '1', // 选中
      typeindex:'',
      selected: "1", // 选中
      typeindex: "",
      form: {
        account1: '',
        account2: '',
        account3: '',
        account4: '',
        password: ''
        account1: "",
        account2: "",
        account3: "",
        account4: "",
        password: "",
      },
      userInfo: {
        realName: ''
        realName: "",
      },
      yebinfo: [],
      showPurchase: false
    }
      showPurchase: false,
      activeObj: {},
      gmObj: {},
    };
  },
  watch: {},
  computed: {},
  created () {
    this.getProductSetting()
  created() {
    this.getProductSetting();
  },
  mounted () {
  mounted() {
    if (this.$route.query.type) {
      this.selected = this.$route.query.type + ''
      this.selected = this.$route.query.type + "";
    }
    this.getUserInfo()
    this.getYebInfo()
    this.getUserInfo();
    this.getYebInfo();
    this.getMoneys();
  },
  methods: {
    // 购买弹窗控制
    handlePurchase (e) {
      console.log(e);
      this.typeindex = e+1
      this.showPurchase = true
    },
    go_yebs () {
      this.$router.push('/yebs')
    },
    async getProductSetting () {
      let data = await api.getProductSetting()
      console.log(data)
      if (data.status === 0) {
        this.$store.state.settingForm = data.data
        if (!this.$store.state.settingForm.indexDisplay) {
          this.selected = '3'
        }
      } else {
        this.$message.error(data.msg)
    // 获取帐户资产
    async getMoneys() {
      const res = await api.getMoney();
      if (res.status === 0) {
        console.log(res.data);
        let obj = res.data.filter((item) => item.accectType == "IN")[0];
        obj.availableBalance = Number(obj.availableBalance).toFixed(2);
        // console.log(Number(obj.availableBalance).toFixed(2));
        this.activeObj = obj;
        // console.log(obj, "0000000", this.tabsArr);
      }
    },
    handleBackClick () {
      this.$router.go(-1)
    // 购买弹窗控制
    handlePurchase(e, item) {
      console.log(e);
      this.typeindex = e + 1;
      this.gmObj = item;
      this.showPurchase = true;
    },
    selectAll1 () {
    go_yebs() {
      this.$router.push("/yebs");
    },
    async getProductSetting() {
      let data = await api.getProductSetting();
      console.log(data);
      if (data.status === 0) {
        this.$store.state.settingForm = data.data;
        if (!this.$store.state.settingForm.indexDisplay) {
          this.selected = "3";
        }
      } else {
        this.$message.error(data.msg);
      }
    },
    handleBackClick() {
      this.$router.go(-1);
    },
    selectAll1() {
      // 选择全部
      this.form.account1 = this.$store.state.userInfo.enableAmt
      this.form.account1 = this.$store.state.userInfo.enableAmt;
    },
    selectAll2 () {
    selectAll2() {
      // 选择全部
      this.form.account2 = this.$store.state.userInfo.enableIndexAmt
      this.form.account2 = this.$store.state.userInfo.enableIndexAmt;
    },
    selectAll3 () {
    selectAll3() {
      // 选择全部
      this.form.account3 = this.$store.state.userInfo.enableAmt
      this.form.account3 = this.$store.state.userInfo.enableAmt;
    },
    selectAll4 () {
    selectAll4() {
      // 选择全部
      this.form.account4 = this.$store.state.userInfo.enableFuturesAmt
      this.form.account4 = this.$store.state.userInfo.enableFuturesAmt;
    },
    isInteger (obj) {
      return obj % 1 === 0
    isInteger(obj) {
      return obj % 1 === 0;
    },
    async tosubmit (id, money) {
    async tosubmit(id, money) {
      if (!this.isInteger(money)) {
        Toast('请输入整数')
        return
        Toast("请输入整数");
        return;
      }
      // 融资转指数
      let opt = {
        // amt: this.selected === '1' ? this.form.account1 : this.selected === '2' ? this.form.account2 : this.selected === '3' ? this.form.account3 : this.form.account4,
        // type: this.selected // 1 融资转指数 2 指数转融资
        eId: this.typeindex,
        money: money
      }
      let data1 = await api.BuyYeb(opt)
        eId: this.gmObj.id,
        money: money,
      };
      let data1 = await api.BuyYeb(opt);
      if (data1.status === 0) {
        Toast(data1.data)
        this.$router.push('/yebs')
        Toast(data1.data);
        this.$router.push("/yebs");
      } else {
        Toast(data1.data)
        Toast(data1.data);
      }
    },
    async getUserInfo () {
    async getUserInfo() {
      // 获取用户信息
      let data = await api.getUserInfo()
      let data = await api.getUserInfo();
      if (data.status === 0) {
        this.$store.state.userInfo = data.data
        this.$store.state.userInfo = data.data;
      } else {
        Toast(data.msg)
        Toast(data.msg);
      }
    },
    async getYebInfo () {
    async getYebInfo() {
      // 获取用户信息
      let data = await api.getYebInfo()
      let data = await api.getYebInfo();
      if (data.status === 0) {
        this.$store.state.yebinfo = data.data
        this.yebinfo = data.data;
        this.$store.state.yebinfo = data.data;
      } else {
        Toast(data.msg)
        Toast(data.msg);
      }
    }
  }
}
    },
  },
};
</script>
<style lang="less" scoped>
/deep/ .van-nav-bar {
@@ -299,12 +216,13 @@
  .van-nav-bar__content {
    height: 64px !important;
  }
  .van-nav-bar__title, .van-nav-bar__text {
    color: #FFFFFF;
  .van-nav-bar__title,
  .van-nav-bar__text {
    color: #ffffff;
    font-size: 24px;
  }
  .van-icon {
    color: #FFFFFF;
    color: #ffffff;
    font-size: 24px;
  }
}
@@ -319,8 +237,8 @@
    .ul {
      margin: 15px;
      padding: 20px;
      border: 1px solid #EEEEEE;
      background: #FFFFFF;
      border: 1px solid #eeeeee;
      background: #ffffff;
      border-radius: 8px;
      .li {
        font-size: 18px;