| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- <template>
- <app-view class="home-main">
- <template #header>
- <app-navbar title="多元世纪" :show-back-button="false" />
- </template>
- <div class="home-main__banner">
- <Swipe :autoplay="5000" indicator-color="white" lazy-render>
- <SwipeItem v-for="(item, index) in topBanners" :key="index">
- <img :src="getFileUrl(item.imagepath)" />
- </SwipeItem>
- </Swipe>
- </div>
- <PullRefresh class="home-main__container" v-model="refreshing" @refresh="onRefresh">
- <app-block>
- <Cell title="通知公告" value="更多" :to="{ name: 'notice-list' }" icon="volume" is-link />
- </app-block>
- <app-block class="home-main__iconbar bg">
- <ul>
- <li @click="switchTab(1)">
- <img src="@mobile/assets/icons/cpjs.svg" />
- <span>预售竞拍</span>
- </li>
- <li @click="routerTo('ballot-list')">
- <img src="@mobile/assets/icons/cpjs.svg" />
- <span>预售中签</span>
- </li>
- <li @click="switchTab(2)">
- <img src="@mobile/assets/icons/cpjg.svg" />
- <span>定金转让</span>
- </li>
- <li @click="routerTo('swap-list')">
- <img src="@mobile/assets/icons/ptgz.svg" />
- <span>掉期贸易</span>
- </li>
- </ul>
- <ul>
- <li @click="switchTab(3)">
- <img src="@mobile/assets/icons/wdrw.svg" />
- <span>订单挂牌</span>
- </li>
- <li @click="routerTo('pricing-list')">
- <img src="@mobile/assets/icons/ccwl.svg" />
- <span>挂牌点价</span>
- </li>
- <li @click="routerTo('spot-list')">
- <img src="@mobile/assets/icons/htzr.svg" />
- <span>现货贸易</span>
- </li>
- <li @click="routerTo('market-list')">
- <img src="@mobile/assets/icons/ccwl.svg" />
- <span>参考行情</span>
- </li>
- </ul>
- </app-block>
- <app-block class="home-main__market" v-if="spotQuoteList.length">
- <Cell class="home-main__titlebar" value="更多" :to="{ name: 'MarketSpot' }" is-link>
- <template #title>
- <img src="@mobile/assets/icons/spot.png" />
- <span>现货行情</span>
- <span>({{ currentSpotQuote.spotmonth }})</span>
- </template>
- </Cell>
- <section class="scrollbar">
- <Swipe :autoplay="8000" :show-indicators="false" :touchable="false" vertical @change="onSpotChange">
- <SwipeItem v-for="(item, i) in spotQuoteList" :key="i">
- <ul @click="openNewsDetails(item.relatedid)">
- <li>
- <span>{{ item.spotsrc }}</span>
- </li>
- <li>
- <span>{{ item.spotname }}招标价 </span>
- <span class="g-color--up">{{ item.spotprice }} 元/吨</span>
- </li>
- <li>
- <span>采购量 </span>
- <span class="g-color--up">{{ item.spotqty }} 吨</span>
- </li>
- </ul>
- </SwipeItem>
- </Swipe>
- </section>
- </app-block>
- <app-block v-if="false">
- <section class="scrollbar">
- <h4 class="scrollbar-title">
- <img src="@mobile/assets/icons/futures.png" />
- <span>期货行情</span>
- </h4>
- <Swipe :autoplay="8000" :show-indicators="false" :touchable="false" vertical>
- <SwipeItem
- v-for="({ goodsname, last, lasttime, presettle, change, amplitude, holdvolume, lastvolume, decimalplace }, i) in dataList"
- :key="i">
- <ul>
- <li>{{ goodsname }}</li>
- <li style="color:#999">{{ formatDate(lasttime, 'HH:mm') }}</li>
- <li :class="handlePriceColor(last, presettle)">{{ handleNumberValue(formatDecimal(last, decimalplace))
- }}
- </li>
- <li :class="handlePriceColor(last, presettle)">{{ handleNumberValue(formatDecimal(change, decimalplace))
- }}</li>
- <li :class="handlePriceColor(last, presettle)">{{ parsePercent(amplitude) }}</li>
- <li :class="handlePriceColor(last, presettle)">{{ changeUnit(lastvolume) }}</li>
- <li :class="handlePriceColor(last, presettle)">{{ changeUnit(holdvolume) }}</li>
- </ul>
- </SwipeItem>
- </Swipe>
- </section>
- </app-block>
- <app-block class="home-main__banner home-main__banner--body" v-if="false">
- <Swipe :autoplay="5000" indicator-color="white" lazy-render>
- <SwipeItem v-for="(item, index) in bodyBanners" :key="index">
- <img :src="getFileUrl(item.imagepath)" />
- </SwipeItem>
- </Swipe>
- </app-block>
- <app-block class="home-main__news">
- <CellGroup class="article">
- <Cell class="home-main__titlebar" value="更多" :to="{ name: 'news-list' }" is-link>
- <template #title>
- <img src="@mobile/assets/icons/fire.png" />
- <span>市场资讯</span>
- </template>
- </Cell>
- <template v-for="(item, index) in newsList" :key="index">
- <Cell class="article-item" :title="item.title" :value="formatDate(item.publishdate, 'MM/DD')"
- :to="{ name: 'news-detail', query: { id: item.id } }" />
- </template>
- </CellGroup>
- </app-block>
- </PullRefresh>
- </app-view>
- </template>
- <script lang="ts" setup>
- import { shallowRef, computed } from "vue";
- import { Cell, CellGroup, Swipe, SwipeItem, PullRefresh } from "vant";
- import { formatDecimal, getFileUrl, formatDate, handlePriceColor, parsePercent, handleNumberValue, changeUnit } from "@/filters";
- import { useNavigation } from "@/hooks/navigation";
- import { queryImageConfigs } from "@/services/api/common";
- import { queryNewTitles } from "@/services/api/news";
- import { useFuturesList } from "@/business/market";
- import { queryMarketRun } from "@/services/api/goods";
- import { queryThjSpotQuoteConfig } from "@/services/api/market";
- import { useLoginStore } from '@/stores'
- const loginStore = useLoginStore();
- const { router, routerTo, setGlobalUrlParams } = useNavigation();
- const { dataList } = useFuturesList();
- const refreshing = shallowRef(false); // 是否处于加载中状态
- const topBanners = shallowRef<Model.ImageConfigsRsp[]>([]); // 轮播图列表
- const bodyBanners = shallowRef<Model.ImageConfigsRsp[]>([]); // 轮播图列表
- const newsList = shallowRef<Model.NewTitlesRsp[]>([]); // 资讯列表
- const spotQuoteList = shallowRef<Model.ThjSpotQuoteConfigRsp[]>([]); // 现货行情
- const spotQuoteIndex = shallowRef(0) // 当前现货行情索引
- const marketRun = shallowRef<Partial<Model.MarketRunRsp>>({}); // 市场
- // 当前现货行情
- const currentSpotQuote = computed(() => spotQuoteList.value[spotQuoteIndex.value])
- // 跳转导航页面
- const switchTab = (tabIndex: number) => {
- if (loginStore.token) {
- setGlobalUrlParams({ tabIndex })
- switch (tabIndex) {
- case 1:
- routerTo('home-presale', true)
- break
- case 2:
- routerTo('home-transfer', true)
- break
- case 3:
- routerTo('home-goods', true)
- break
- }
- } else {
- routerTo('user-login')
- }
- }
- // 打开新闻详情
- const openNewsDetails = (id: number) => {
- if (id) {
- router.push({ name: 'news-detail', query: { id } })
- }
- }
- // 现货行情轮播变化
- const onSpotChange = (index: number) => {
- spotQuoteIndex.value = index
- }
- // 下拉刷新
- const onRefresh = () => {
- if (!topBanners.value.length) {
- queryImageConfigs({
- data: {
- imageType: 1,
- }
- }).then((res) => {
- topBanners.value = res.data
- })
- }
- // if (!bodyBanners.value.length) {
- // queryImageConfigs({
- // imageType: 10,
- // }).then((res) => {
- // bodyBanners.value = res.data
- // })
- // }
- // 现货行情
- queryThjSpotQuoteConfig().then((res) => {
- spotQuoteList.value = res.data
- })
- // 市场资讯
- queryNewTitles({
- data: {
- page: 1,
- pagesize: 10,
- }
- }).then((res) => {
- newsList.value = res.data
- }).finally(() => {
- refreshing.value = false
- })
- }
- // 市场信息
- queryMarketRun().then((res) => {
- marketRun.value = res.data[0]
- })
- onRefresh()
- </script>
- <style lang="less">
- @import "./index.less";
- </style>
|