1
zzzz
2024-04-24 2007ac8b95033bccbc7bc1e048e896757611e8f7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<template>
  <div class="wrapper">
    <van-nav-bar
      :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 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("周期") + ":" }}</span>
                <span class="li-value"
                  >{{ item.returnTime }} {{ $t("天") }}</span
                >
              </div>
              <div class="li-info">
                <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, item)">
              {{ $t("gm") }}
            </div>
          </div>
        </div>
      </div>
    </div>
    <van-dialog
      width="90%"
      v-model="showPurchase"
      :title="$t('yeb') + $t('gm')"
      show-cancel-button
      :confirmButtonText="$t('qr')"
      :cancelButtonText="$t('qx')"
      @confirm="tosubmit(1, form.account1)"
    >
      <div class="dialog-box">
        <van-field
          v-model="activeObj.availableBalance"
          type="text"
          :label="$t('ky') + $t('ye')"
          :placeholder="$t('ky') + $t('ye')"
          readonly
          :border="false"
        />
        <van-field
          v-model="form.account1"
          type="number"
          name="amt"
          :label="$t('gm') + $t('sl')"
          :placeholder="$t('gm') + $t('sl')"
          :border="false"
        >
          <template #button>
            <span @click="selectAll1">{{ $t("hj160") }}</span>
          </template>
        </van-field>
      </div>
    </van-dialog>
  </div>
</template>
 
<script>
import * as api from "@/axios/api";
import { Notify } from "vant";
 
export default {
  components: {},
  data() {
    return {
      selected: "1", // 选中
      typeindex: "",
      form: {
        account1: "",
        account2: "",
        account3: "",
        account4: "",
        password: "",
      },
      userInfo: {
        realName: "",
      },
      yebinfo: [],
      showPurchase: false,
      activeObj: {},
      gmObj: {},
    };
  },
  watch: {},
  computed: {},
  created() {
    this.getProductSetting();
  },
  mounted() {
    if (this.$route.query.type) {
      this.selected = this.$route.query.type + "";
    }
    this.getUserInfo();
    this.getYebInfo();
    this.getMoneys();
  },
  methods: {
    // 获取帐户资产
    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));
        obj.availableBalance = this.$toLocaleString(
          obj.availableBalance,
          false
        );
        this.activeObj = obj;
        // console.log(obj, "0000000", this.tabsArr);
      }
    },
    // 购买弹窗控制
    handlePurchase(e, item) {
      console.log(e);
      this.typeindex = e + 1;
      this.gmObj = item;
      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);
      }
    },
    handleBackClick() {
      this.$router.go(-1);
    },
    selectAll1() {
      // 选择全部
      this.form.account1 = this.$store.state.userInfo.enableAmt;
    },
    selectAll2() {
      // 选择全部
      this.form.account2 = this.$store.state.userInfo.enableIndexAmt;
    },
    selectAll3() {
      // 选择全部
      this.form.account3 = this.$store.state.userInfo.enableAmt;
    },
    selectAll4() {
      // 选择全部
      this.form.account4 = this.$store.state.userInfo.enableFuturesAmt;
    },
    isInteger(obj) {
      return obj % 1 === 0;
    },
    async tosubmit(id, money) {
      if (!this.isInteger(money)) {
        Notify({ type: "warning", message: this.$t("regpInt") });
        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.gmObj.id,
        money: money,
      };
      let data1 = await api.BuyYeb(opt);
      console.log(data1, "====");
      if (data1.status === 0) {
        Notify({ type: "success", message: data1.data });
        this.$router.push("/yebs");
      } else {
        Notify({ type: "warning", message: data1.data });
      }
    },
    async getUserInfo() {
      // 获取用户信息
      let data = await api.getUserInfo();
      if (data.status === 0) {
        this.$store.state.userInfo = data.data;
      } else {
        Notify({ type: "warning", message: data.data });
      }
    },
    async getYebInfo() {
      // 获取用户信息
      let data = await api.getYebInfo();
 
      if (data.status === 0) {
        this.yebinfo = data.data;
        this.$store.state.yebinfo = data.data;
      } else {
        Notify({ type: "warning", message: data.data });
      }
    },
  },
};
</script>
<style lang="less" scoped>
/deep/ .van-nav-bar {
  height: 64px !important;
  background: linear-gradient(to bottom, #45acff, #287df5);
  .van-nav-bar__content {
    height: 64px !important;
  }
  .van-nav-bar__title,
  .van-nav-bar__text {
    color: #ffffff;
    font-size: 24px;
  }
  .van-icon {
    color: #ffffff;
    font-size: 24px;
  }
}
.wrapper {
  width: 100%;
  height: 100%;
  background: #f1f2f6;
  .main {
    margin-top: 64px;
    height: calc(100% - 84px);
    overflow-y: auto;
    .ul {
      margin: 15px;
      padding: 20px;
      border: 1px solid #eeeeee;
      background: #ffffff;
      border-radius: 8px;
      .li {
        font-size: 18px;
        display: flex;
        justify-content: space-between;
        .li-left {
          h3 {
            display: flex;
            padding-bottom: 20px;
          }
          .li-cont {
            display: flex;
            .li-1 {
              margin-right: 20px;
            }
          }
        }
        .li-btn-box {
          display: flex;
          align-items: center;
          .btn {
            color: #287df5;
            font-size: 18px;
          }
        }
      }
    }
  }
}
/deep/ .van-dialog__header {
  font-size: 24px;
  margin-bottom: 15px;
}
.dialog-box {
  padding: 10px;
  margin: 20px 0;
  // background: rgb(245, 245, 245);
  .van-field {
    font-size: 18px;
    color: #666666;
    margin-top: 20px;
  }
}
</style>