import * as api from "@/axios/api"; export default { data() { return { pageNum: 1, pageSize: 10, total: 1, tableData: [], apiInterface: null, // 词典 dictionary: { // 股票类型 gplx: { 0: this.$t("日内"), 2: "IPO", 3: this.$t("hj621"), 4: "AI", }, // ipo类型 ipolx: { 1: this.$t("申购中"), 2: this.$t("hj132"), 3: this.$t("hj133"), 4: this.$t("hj134"), 5: this.$t("hj135"), 6: this.$t("已上市"), }, // 基金类型 jjlx: { 1: this.$t("进行中"), 2: this.$t("已赎回"), }, }, htu: 1, // HK转US汇率 itu: 1, // IN转US汇率 ttu: 1, // TW转US汇率 }; }, watch: { // pageNum() { // this.getList(); // }, // pageSize() { // this.init(); // }, opt: { handler() { this.init(); }, deep: true, }, }, methods: { // 计算当前汇率 rate(type) { let rate = 1; if (type == "HK") rate = this.htu; else if (type == "IN") rate = this.itu; else if (type == "TW") rate = this.ttu; return rate; }, // 初始化 init() { this.pageNum = 1; this.getList(); }, // 获取列表 async getList() { let option = { pageNum: this.pageNum, pageSize: this.pageSize, }; if (this.opt) option = { ...option, ...this.opt }; let data = await this.apiInterface(option); if (data.status === 0) { this.tableData = data.data.list || data.data.records || data.data; this.total = data.data.total; if (this.getListAfter) this.getListAfter(); // 获取列表后,如果方法getListAfter存在,则执行 } // console.log("data", data); }, // 翻页 handleCurrentChange(val) { this.pageNum = val; this.getList(); }, // 获取汇率 async getExchangeRate() { let data = await api.getRateInfo(); data.data && data.data.forEach((item) => { if (item.currency === "HKD" && item.conversionCurrency == "USD") { this.htu = item.rata; } else if ( item.currency === "INR" && item.conversionCurrency == "USD" ) { this.itu = item.rata; } else if ( item.currency === "TWD" && item.conversionCurrency == "USD" ) { this.ttu = item.rata; } }); }, }, };