{"ast":null,"code":"import \"vant/es/loading/style\";\nimport _Loading from \"vant/es/loading\";\nimport \"vant/es/tab/style\";\nimport _Tab from \"vant/es/tab\";\nimport \"vant/es/tabs/style\";\nimport _Tabs from \"vant/es/tabs\";\nimport \"vant/es/list/style\";\nimport _List from \"vant/es/list\";\nimport \"core-js/modules/es.array.push.js\";\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n//\n\nimport { _fundRecord } from '@/API/fund.api';\nimport { _getHomeList, _myCoins, _collect, _deleteCollect } from '@/API/home.api';\nimport { mapGetters } from \"vuex\";\nimport { TIME_OUT } from \"@/config\";\nimport { setStorage } from \"@/utils/utis\";\nexport default {\n name: \"search\",\n data() {\n return {\n keywords: '',\n active: 0,\n allFunList: [],\n dataList: [],\n allCurrencyList: [],\n currencyList: [],\n timeout: null,\n collectionList: [],\n isLoading: true\n };\n },\n mounted() {\n this.allFunList = [{\n name: this.$t('理财'),\n icon: require(`../../assets/theme/${this.theme}/image/nav/finance.png`),\n path: '/fm-home'\n }, {\n name: this.$t('充值'),\n icon: require(`../../assets/theme/${this.theme}/image/nav/account.png`),\n // path: '/recharge/rechargePage'\n path: '/recharge/rechargeList'\n }, {\n name: this.$t('合约交易'),\n icon: require(`../../assets/theme/${this.theme}/image/nav/trading.png`),\n path: '/trendDetails/btc'\n }, {\n name: this.$t('闪兑'),\n icon: require(`../../assets/theme/${this.theme}/image/nav/exchange.png`),\n path: '/exchange/exchangePage'\n }];\n this.dataList = this.allFunList;\n if (this.$store.state.user.userInfo.token) {\n this.myCoinsList();\n }\n setTimeout(() => {\n this.fetchQList();\n }, 1000);\n },\n components: {\n [_List.name]: _List,\n [_Tabs.name]: _Tabs,\n [_Tab.name]: _Tab,\n [_Loading.name]: _Loading\n },\n watch: {\n collectionList(val) {\n if (val) {\n this.allCurrencyList.map(item => {\n val.map(item2 => {\n if (item.symbol == item2.symbol) {\n item.isCollection = true;\n }\n });\n });\n this.currencyList.map(item => {\n val.map(item2 => {\n if (item.symbol == item2.symbol) {\n item.isCollection = true;\n }\n });\n });\n }\n }\n },\n computed: {\n ...mapGetters({\n coinArr: 'home/coinArr',\n theme: 'home/theme'\n })\n },\n filters: {},\n beforeDestroy() {\n clearInterval(this.timeout);\n },\n methods: {\n onInput() {\n if (this.active == 1) {\n if (this.keywords) {\n this.dataList = this.dataList.filter(item => {\n return item.name.indexOf(this.keywords) != -1;\n });\n } else {\n this.dataList = this.allFunList;\n }\n }\n },\n cancel() {\n this.$router.go(-1);\n },\n jump(path) {\n this.$router.push(path);\n },\n myCoinsList() {\n _myCoins().then(res => {\n this.collectionList = res;\n });\n },\n onCollect(item) {\n // 收藏,取消收藏\n let _api = _collect;\n if (item.isCollection) {\n _api = _deleteCollect;\n }\n _api(item.symbol).then(() => {\n this.myCoinsList();\n item.collected = !item.collected;\n if (!item.isCollection) {\n this.$toast.success(this.$t('收藏成功'));\n } else {\n this.$toast.success(this.$t('取消收藏'));\n }\n });\n },\n fetchQList() {\n // 获取行情\n _getHomeList(this.coinArr.join(',')).then(res => {\n this.isLoading = false;\n res.map(item => {\n this.$set(item, 'isCollection', false);\n });\n this.allCurrencyList = res;\n this.currencyList = res;\n this.allCurrencyList.map(item => {\n this.collectionList.map(item2 => {\n if (item.symbol == item2.symbol) {\n item.isCollection = true;\n }\n });\n });\n this.currencyList.map(item => {\n this.collectionList.map(item2 => {\n if (item.symbol == item2.symbol) {\n item.isCollection = true;\n }\n });\n });\n if (this.active == 0) {\n if (this.keywords) {\n this.currencyList = this.currencyList.filter(item => {\n return item.name.toUpperCase().indexOf(this.keywords.toUpperCase()) != -1;\n });\n } else {\n this.currencyList = this.allCurrencyList;\n }\n }\n this.timeout = setTimeout(() => {\n this.fetchQList();\n }, 1000);\n });\n if (this.timeout) {\n clearInterval(this.timeout);\n }\n },\n changeValue() {\n console.log(this.dataList);\n this.keywords = '';\n },\n onItemClick(item) {\n setStorage('symbol', item.symbol);\n this.$router.push({\n path: `/perpetualContract/${item.symbol}`\n });\n }\n }\n};","map":null,"metadata":{},"sourceType":"module","externalDependencies":[]}
|