1
jhzh
2024-08-12 f1dc8f5a7f3a661ce19513a9ad47fe18e3e883ff
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
<!-- 理财账户 -->
<template>
  <div class="right-view">
    <!-- 头部 -->
    <div class="right-header">
      <div class="right-header-box">
        <div>{{ $t("message.user.xianhuozhanghu") }}</div>
        <div>
          <el-button
              type="primary"
              style="width: 100px; margin-right: 10px"
              @click="gotoPage('/recharge')"
          >{{ $t("message.user.chongzhi") }}</el-button
          >
          <button class="light-grey-button" @click="gotoPage('/withdraw')">
            {{ $t("message.user.tixian") }}
          </button>
          <button class="light-grey-button" @click="gotoPage('/exchange')">
            {{ $t("message.user.duihuan") }}
          </button>
        </div>
      </div>
    </div>
    <div class="padding-left-right20">
      <div class="margin-top-bottom20">
        <total-assets :pageType="'financial'"></total-assets>
        <div class="tab-customize-box">
          <el-input v-model="bizhong" style="width: 150px;" :placeholder="$t('message.user.sousuobizhong')"/>
          <el-button type="primary" style="margin-left: 10px;margin-right: 20px;" @click="getList">{{ $t('message.user.chaxun') }}</el-button>
          <el-checkbox v-model="yangCangchecked" :label="$t('message.user.yincangzichan')" size="large" @change="getList" />
        </div>
      </div>
      <div>
        <!-- 理财账户列表 -->
        <el-table
            v-if="heYueType == 0"
            :data="tableData"
            class="width100"
            :header-cell-style="getRowClass"
            :empty-text="$t('message.home.noData')"
        >
          <el-table-column
              prop="name"
              :label="$t('message.user.bizhong')"
              sortable
          ></el-table-column>
          <el-table-column
              :label="$t('message.user.keyong')"
              sortable
          >
            <template #default="{row}">
               <span>{{row.money >= 0? row.money.toFixed(6): row.amount.toFixed(6)}}</span>
            </template>
          </el-table-column>
          <el-table-column
              :label="$t('message.user.dongjie')"
          >
            <template #default="{row}">
              <span>{{row.freeze_money >= 0? row.freeze_money.toFixed(6) : row.freeze_amount.toFixed(6)}}</span>
            </template>
          </el-table-column>
 
          <el-table-column
              :label="$t('message.jiaoyi.suocang')"
          >
            <template #default="{row}">
              <span>{{row.lock_money >= 0? row.lock_money.toFixed(6) : row.lock_amount.toFixed(6)}}</span>
            </template>
          </el-table-column>
          <el-table-column
              :label="$t('message.user.jiedai')"
          >
            <template #default="{row}">
              <span>{{row.frozenAmount >= 0 ? row.frozenAmount.toFixed(6) : ''}}</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!-- 理财订单详情 -->
      <el-dialog
          :title="$t('message.user.dingdanxiangqing')"
          v-model="centerDialogVisible"
          width="50%"
          center
      >
        <div class="dialog-style">
          <div class="dialog-content">
            <p>{{ $t("message.user.tuoguanjine") }}</p>
            <p>{{ $t("message.user.yihuoqushouyi") }}</p>
            <p>{{ $t("message.user.yuqishouyi") }}</p>
            <p>{{ $t("message.user.tuoguanshijian") }}</p>
            <p>{{ $t("message.user.rishouyi") }}</p>
            <p>{{ $t("message.user.qixishijian") }}</p>
            <p>{{ $t("message.user.daoqishijian") }}</p>
            <p>{{ $t("message.user.shengyutianshu") }}</p>
 
            <p>{{ $t("message.user.weiyuejin") }}</p>
            <p>{{ $t("message.user.shuhuibenjin") }}</p>
            <p>{{ $t("message.user.dingdanbianhao") }}</p>
            <p>{{ $t("message.user.dingdanshijian") }}</p>
          </div>
          <div class="dialog-content">
            <p>{{ detailData.amount }}</p>
            <p>{{ detailData.profit }}</p>
            <p>{{ detailData.profit_may }}</p>
            <p>
              {{
                detailData.cycle != 0
                    ? detailData.cycle + $t("message.user.tian")
                    : $t("message.user.wuxianqi")
              }}
            </p>
            <p>{{ detailData.daily_rate }} %</p>
            <p>{{ detailData.earn_timeStr }}</p>
            <p>{{ detailData.stop_timeStr }}</p>
            <p>{{ detailData.days }}</p>
            <p>{{ detailData.default_amount }}</p>
            <p>{{ detailData.principal_amount }}</p>
            <p>{{ detailData.order_no }}</p>
            <p>{{ detailData.create_timeStr }}</p>
          </div>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="centerDialogVisible = false">{{
              $t("message.user.quxiao")
            }}</el-button>
          <el-button type="primary" @click="closeFinance">{{
              $t("message.user.quedingshuhui")
            }}</el-button>
        </span>
      </el-dialog>
      <!-- 矿池锁仓订单详情 -->
      <el-dialog
          :title="$t('message.user.dingdanxiangqing')"
          v-model="minerDialog"
          width="50%"
          center
      >
        <div class="dialog-style">
          <div class="dialog-content">
            <p>{{ $t("message.user.suocangjine") }}</p>
            <p>{{ $t("message.user.yihuoqushouyi") }}</p>
            <p>{{ $t("message.user.yuqishouyi") }}</p>
            <p>{{ $t("message.user.zhouqi") }}</p>
            <p>
              {{ $t("message.user.rishouyi") }}
            </p>
            <p>{{ $t("message.user.qixishijian") }}</p>
            <p>{{ $t("message.user.daoqishijian") }}</p>
            <p>{{ $t("message.user.shengyutianshu") }}</p>
 
            <!-- <p>违约金</p>
                    <p>赎回本金</p> -->
            <p>{{ $t("message.user.dingdanbianhao") }}</p>
            <p>{{ $t("message.user.dingdanshijian") }}</p>
          </div>
          <div class="dialog-content">
            <p>{{ minerDetail.amount }}</p>
            <p>{{ minerDetail.profit }}</p>
            <p>{{ minerDetail.profit_may }}</p>
            <p>
              {{
                minerDetail.cycle != 0
                    ? minerDetail.cycle + $t("message.user.tian")
                    : $t("message.user.wuxianqi")
              }}
            </p>
            <p>{{ minerDetail.daily_rate }} %</p>
            <p>{{ minerDetail.earn_timeStr }}</p>
            <p>{{ minerDetail.stop_timeStr || "--" }}</p>
            <p>{{ minerDetail.days }}</p>
            <!-- <p>{{ minerDetail.default_amount}}</p>
                    <p>{{ minerDetail.principal_amount}}</p> -->
            <p>{{ minerDetail.order_no }}</p>
            <p>{{ minerDetail.create_timeStr }}</p>
          </div>
        </div>
        <span slot="footer" class="dialog-footer">
          <el-button @click="minerDialog = false">{{
              $t("message.user.quxiao")
            }}</el-button>
          <el-button
              type="primary"
              @click="unlock"
              :disabled="!minerDetail.can_close"
          >{{ $t("message.user.jiesuo") }}</el-button
          >
        </span>
      </el-dialog>
    </div>
  </div>
</template>
<script>
import totalAssets from "./components/totalAssets.vue";
import Axios2 from "@/api/wallet.js";
export default {
  components: { totalAssets },
  name: "spot",
  data() {
    return {
      yangCangchecked:'',
      bizhong:'',
      MenuChooseIndex: 1,
      total: 0,
      tableData: [], //理财列表数据
      mineData: [], //矿池锁仓列表数据
      heYueType: 0,
      centerDialogVisible: false,
      detailData: {}, //理财详情数据
      orderId: "", //理财订单id
      minerDialog: false,
      minerDetail: {}, //矿机详情数据
      minerId: "",
    };
  },
  mounted() {
    // if(this.$route.query.type){
    //   this.heYueType = this.$route.query.type;
    // }
    this.getAssetsAll();
    this.getList();
    this.getMineList();
  },
  methods: {
    gotoPage(path) {
      this.$router.push(path);
    },
    ChooseHeYueType(index) {
      this.heYueType = index;
    },
    //理财账户列表数据
    getList() {
      Axios2.getWalletList({}).then((res) => {
        let result = res.data
        let tableData = []
        for (let key in result){
          result[key].name = key
          tableData.push(result[key])
        }
        if (this.bizhong){
          this.tableData = tableData.filter(item => item.name == this.bizhong)
          return
        }
        if (this.yangCangchecked){
          this.tableData = tableData.filter(item => (item.money || item.amount ))
          return
        }
        this.tableData = tableData
      });
    },
    //矿池锁仓列表
    getMineList() {
      // Axios2.listMinerOrder({
      //   state: 1,
      //   page_no: 1,
      // }).then((res) => {
      //   this.mineData = res.data;
      // });
    },
    //理财详情
    goDetail(order_no, id) {
      this.orderId = id;
      this.centerDialogVisible = true;
      Axios2.goDetail({
        order_no: order_no,
      }).then((res) => {
        this.detailData = res.data;
      });
    },
    //赎回理财
    closeFinance() {
      let that = this;
      that
          .$confirm(
              this.$t("message.user.xianzaishifoushuhui"),
              this.$t("message.user.tishi"),
              {
                confirmButtonText: this.$t("message.user.queding"),
                cancelButtonText: this.$t("message.user.quxiao"),
                type: "warning",
              }
          )
          .then(() => {
            Axios2.financeOrderOfClosOrder({
              id: that.orderId,
            }).then((res) => {
              if (res.code == 0) {
                that.$message({
                  type: "success",
                  message: this.$t("message.user.shuihuichenggong"),
                });
              }
              that.centerDialogVisible = false;
              that.getList();
              that.$router.push({
                path: "/order/financialOrder",
                query: {
                  type: "financial",
                },
              });
            });
          })
          .catch(() => {
            that.$message({
              type: "info",
              message: this.$t("message.user.yiquxiao"),
            });
            that.centerDialogVisible = false;
          });
    },
    //矿池详情
    goMineDetail(order_no, id) {
      this.minerDialog = true;
      this.minerId = order_no;
 
      Axios2.goMineDetail({
        order_no: order_no,
      }).then((res) => {
        this.minerDetail = res.data;
      });
    },
    //解锁
    unlock() {
      let that = this;
      that
          .$confirm(
              this.$t("message.user.shifouxianzaijiesuo"),
              this.$t("message.user.tishi"),
              {
                confirmButtonText: this.$t("message.user.queding"),
                cancelButtonText: this.$t("message.user.quxiao"),
                type: "warning",
              }
          )
          .then(() => {
            Axios2.minerOrderOfClosOrder({
              order_no: that.minerId,
            }).then((res) => {
              if (res.code == 0) {
                that.$message({
                  type: "success",
                  message: this.$t("message.user.jiesuochenggong"),
                });
                that.heYueType = 1;
              }
              that.minerDialog = false;
              that.getMineList();
              that.$router.push({
                path: "/order/financialOrder",
                query: {
                  type: "miner",
                },
              });
            });
          })
          .catch(() => {
            that.$message({
              type: "info",
              message: this.$t("message.user.yiquxiao"),
            });
            that.minerDialog = false;
          });
    },
    //给表头设置背景颜色
    getRowClass({ rowIndex, columnIndex }) {
      if (rowIndex == 0) {
        return { background: "#f8f8f9" };
      }
    },
 
    //总账户资产
    getAssetsAll() {
      Axios2.getAllAssets().then((res) => {
        if (res.code == 0) {
          this.total = res.data.total;
        }
      });
    },
    goHistory() {
      this.$router.push({
        path: "/order/financialOrder",
      });
    },
    getLocalLan() {
      var lang = JSON.parse(localStorage.getItem("lang"));
      // 简体中文:miner_name,繁体:miner_name_cn miner_name_en
      if (lang == "en") {
        return "miner_name_en";
      } else if (lang == "cht") {
        return "miner_name_cn";
      } else if (lang == "zh-CN") {
        return "miner_name";
      }
      return "miner_name_en";
    },
  },
};
</script>
<style scoped lang="css">
/* @import url("../../assets/wallet/walletOverview.css");
@import url("../../assets/global.css"); */
 
.table_all >>> th.el-table__cell {
  background-color: #fafafa;
}
.tab-customize-box{
  display: flex;
  align-items: center;
}
</style>