Handy_Cao пре 11 месеци
родитељ
комит
ca346bde85

+ 2 - 2
src/packages/mobile/views/news/list/Index.vue

@@ -3,7 +3,7 @@
     <template #header>
       <app-navbar :title="title" :show-back-button="showBackButton" />
     </template>
-    <Tabs v-model:active="currentColumnId" @change="onClickTab">
+    <Tabs v-if="siteColumns.length != 0" v-model:active="currentColumnId" @change="onClickTab">
       <template v-for="(item, index) in siteColumns" :key="index">
         <Tab :name="item.id" :title="item.columnname" />
       </template>
@@ -37,7 +37,7 @@ defineProps({
   showBackButton: {
     type: Boolean,
     default: true
-  }
+  },
 })
 
 const pullRefreshRef = shallowRef()

+ 11 - 7
src/packages/mobile/views/user/register/Index.vue

@@ -77,7 +77,7 @@
 
 <script lang="ts" setup>
 import { reactive, shallowRef, ref, computed, onMounted } from 'vue'
-import { CellGroup, Cell, Button, Field, Form, FormInstance, Checkbox, showFailToast, showToast, FieldRule, Popup, Picker, PickerConfirmEventParams } from 'vant'
+import { CellGroup, Cell, Button, Field, Form, FormInstance, Checkbox, showFailToast, showToast, FieldRule, Popup, Picker, PickerConfirmEventParams, showSuccessToast } from 'vant'
 import { useCountDown } from '@vant/use'
 import { fullloading, dialog } from '@/utils/vant'
 import { validateRules } from '@/constants/regex'
@@ -289,12 +289,16 @@ const formSubmit = () => {
         }
       }).then((res) => {
         if (res.code === 0) {
-          // 等待3秒后查询注册红包
-          setTimeout(() => {
-            getRegisterMoney(res.taaccount[0].accountid).finally(() => {
-              hideLoading()
-            })
-          }, 3000)
+          if (res.taaccount.length != 0) {
+            // 等待3秒后查询注册红包
+            setTimeout(() => {
+              getRegisterMoney(res.taaccount[0].accountid).finally(() => {
+                hideLoading()
+              })
+            }, 3000)
+          } else {
+            showSuccessToast('您的注册申请已提交!')
+          }
         } else {
           showFailToast(res.message)
         }

+ 17 - 3
src/packages/sjgj/router/index.ts

@@ -52,12 +52,14 @@ const routes: Array<RouteRecordRaw> = [
           {
             path: 'news',
             name: 'home-news',
-            component: () => import('@mobile/views/news/list/Index.vue'),
+            component: () => import('../../sjgj/views/news/list/Index.vue'),
             meta: {
               ignoreAuth: true,
             },
             props: {
-              showBackButton: false
+              showBackButton: false,
+              columnid: 2,
+              title: '研报'
             }
           },
           {
@@ -142,7 +144,19 @@ const routes: Array<RouteRecordRaw> = [
       {
         path: '',
         name: 'news-list',
-        component: () => import('@mobile/views/news/list/Index.vue'),
+        component: () => import('../../sjgj/views/news/list/Index.vue'),
+        meta: {
+          ignoreAuth: true,
+        },
+        props: {
+          title: '业务公告',
+          columnid: 1
+        }
+      },
+      {
+        path: 'detail',
+        name: 'news-detail',
+        component: () => import('@mobile/views/news/detail/Index.vue'),
         meta: {
           ignoreAuth: true,
         },

+ 14 - 0
src/packages/sjgj/views/home/index.less

@@ -0,0 +1,14 @@
+.home {
+    .app-tabbar {
+        background: var(--tabbar-background) !important;
+        margin-top: auto;
+
+        .app-iconfont {
+            color: var(--tabbar-icon);
+
+            &.is-active {
+                color: var(--tabbar-icon-active);
+            }
+        }
+    }
+}

+ 95 - 3
src/packages/sjgj/views/home/index.vue

@@ -1,7 +1,99 @@
 <template>
-  <home-view />
+  <div ref="homeRef" class="home g-flex">
+    <router-view v-slot="{ Component }">
+      <RouterTransition :css="cssTransition">
+        <!-- 缓存所有组件 -->
+        <keep-alive>
+          <component class="g-flex__body" :is="Component" />
+        </keep-alive>
+      </RouterTransition>
+    </router-view>
+    <app-tabbar class="home-tabbar" :data-list="tabList" :data-index="currentTab" @click="onTabClick" />
+    <app-updater />
+  </div>
 </template>
 
 <script lang="ts" setup>
-import HomeView from '../../../sbyj/views/home/index.vue'
-</script>
+import { shallowRef, nextTick, watch, onMounted, computed } from 'vue'
+import { Tabbar } from '@mobile/components/base/tabbar/types'
+import { useNavigation } from '@mobile/router/navigation'
+import { useLoginStore } from '@/stores'
+import AppTabbar from '@mobile/components/base/tabbar/index.vue'
+import AppUpdater from '@mobile/components/base/updater/index.vue'
+import RouterTransition from '@mobile/components/base/router-transition/index.vue'
+import eventBus from '@/services/bus'
+
+const { route, routerTo } = useNavigation()
+const loginStore = useLoginStore()
+const homeRef = shallowRef<HTMLDivElement>()
+const cssTransition = shallowRef(true) // 是否使用css动画
+const currentTab = shallowRef(0)
+
+const tabIndex = computed(() => tabList.findIndex((e) => e.name === route.name))
+
+const tabList: Tabbar[] = [
+  {
+    name: 'home-index',
+    label: '首页',
+    icon: 'g-icon-home--line',
+    activeIcon: 'g-icon-home--fill',
+  },
+  {
+    name: 'home-market',
+    label: '行情',
+    icon: 'g-icon-quote--line',
+    activeIcon: 'g-icon-quote--fill',
+  },
+  {
+    name: 'home-news',
+    label: '研报',
+    icon: 'g-icon-news--line',
+    activeIcon: 'g-icon-news--fill',
+  },
+  {
+    name: 'home-mine',
+    label: '我的',
+    icon: 'g-icon-mine--line',
+    activeIcon: 'g-icon-mine--fill',
+  }
+]
+
+const onTabClick = (index: number) => {
+  const { name } = tabList[index]
+  if (name !== 'home-mine' || loginStore.token) {
+    routerTo(name, true)
+  } else {
+    routerTo('user-login')
+  }
+}
+
+// 接收行情服务连接状态通知
+eventBus.$on('QuoteServerStatusNotify', (status) => {
+  const el = homeRef.value?.querySelector('.app-tabbar__item--home-market .app-iconfont__label') as HTMLSpanElement
+  if (el) {
+    if (status) {
+      el.style.removeProperty('text-decoration')
+    } else {
+      el.style.setProperty('text-decoration', 'underline')
+    }
+  }
+})
+
+watch(() => route.name, () => {
+  if (tabIndex.value > -1) {
+    cssTransition.value = false
+    currentTab.value = tabIndex.value
+  }
+  nextTick(() => {
+    cssTransition.value = true
+  })
+})
+
+onMounted(() => {
+  currentTab.value = tabIndex.value
+})
+</script>
+
+<style lang="less">
+@import './index.less';
+</style>

+ 19 - 15
src/packages/sjgj/views/home/main/index.vue

@@ -13,13 +13,14 @@
     </div>
     <PullRefresh class="home-main__container" v-model="refreshing" @refresh="onRefresh">
       <app-block>
-        <Cell title="通知公告" value="更多" :to="{ name: 'notice-list' }" icon="volume" is-link />
+        <Cell title="通知公告" value="更多" :to="{ name: 'notice-list' }" icon="volume" is-link>
+          <template #title>
+            <Badge :offset="[10, 8]" :dot="noticeStore.unreadList.length > 0">{{ $t('routes.notice') }}</Badge>
+          </template>
+        </Cell>
       </app-block>
       <app-block class="home-main__iconbar bg">
         <ul>
-          <li @click="routerTo('home-market', true)">
-            <Iconfont label-direction="bottom" icon="g-icon-quote--line">行情</Iconfont>
-          </li>
           <li @click="routerTo('order-list')">
             <Iconfont label-direction="bottom" icon="g-icon-order--line">持有订单</Iconfont>
           </li>
@@ -29,8 +30,6 @@
           <li @click="routerTo('pickup-list')">
             <Iconfont label-direction="bottom" icon="g-icon-pickup--line">提料订单</Iconfont>
           </li>
-        </ul>
-        <ul>
           <li @click="routerTo('inventory-list')">
             <Iconfont label-direction="bottom" icon="g-icon-inventory">我的库存</Iconfont>
           </li>
@@ -38,11 +37,11 @@
       </app-block>
       <app-block class="home-main__news">
         <CellGroup class="article">
-          <Cell class="home-main__titlebar" title="市场资讯" value="更多" icon="fire" @click="routerTo('home-news', true)"
+          <Cell class="home-main__titlebar" title="业务公告" value="更多" icon="fire" @click="routerTo('news-list')"
             is-link />
           <template v-for="(item, index) in newsList" :key="index">
-            <Cell class="article-item" :title="item.data.content" :value="formatDate(item.time, 'MM/DD')"
-              @click="routerTo('home-news', true)" />
+            <Cell class="article-item" :title="item.title" :value="formatDate(item.publishdate, 'MM/DD')"
+              @click="routerTo('news-list')" />
           </template>
         </CellGroup>
       </app-block>
@@ -52,19 +51,21 @@
 
 <script lang="ts" setup>
 import { shallowRef } from "vue";
-import { Cell, CellGroup, PullRefresh } from "vant";
+import { Cell, CellGroup, PullRefresh, Badge } from "vant";
 import { formatDate } from "@/filters";
 import { useNavigation } from '@mobile/router/navigation';
-import { queryImageConfigs, getJ10News } from "@/services/api/common";
-import { useGlobalStore } from '@/stores'
+import { queryImageConfigs } from "@/services/api/common";
+import { useNoticeStore, useGlobalStore } from '@/stores'
 import Banner from '@mobile/components/base/banner/index.vue'
 import Iconfont from '@/components/base/iconfont/index.vue'
+import { queryNewTitles } from "@/services/api/news";
 
 const { routerTo } = useNavigation()
+const noticeStore = useNoticeStore()
 const globalStore = useGlobalStore()
 const refreshing = shallowRef(false) // 是否处于加载中状态
 const topBanners = shallowRef<string[]>([]) // 轮播图列表
-const newsList = shallowRef<Model.J10NewsRsp[]>([]) // 资讯列表
+const newsList = shallowRef<Model.NewTitlesRsp[]>([]) // 资讯列表
 
 // 下拉刷新
 const onRefresh = () => {
@@ -75,10 +76,13 @@ const onRefresh = () => {
   }).then((res) => {
     topBanners.value = res.data.map((e) => e.imagepath)
   })
+
   // 市场资讯
-  getJ10News({
+  queryNewTitles({
     data: {
-      limit: 10
+      columnid: 1,
+      page: 1,
+      pagesize: 10
     }
   }).then((res) => {
     newsList.value = res.data

+ 87 - 0
src/packages/sjgj/views/news/list/Index.vue

@@ -0,0 +1,87 @@
+<template>
+  <app-view class="news-list" flex>
+    <template #header>
+      <app-navbar :title="title" :show-back-button="showBackButton" />
+    </template>
+    <app-pull-refresh ref="pullRefreshRef" class="news-list__container" v-model:loading="loading" v-model:error="error"
+      v-model:pageIndex="pageIndex" :page-count="pageCount" @refresh="onRefresh">
+      <Empty v-if="!dataList.length" />
+      <template v-for="(item, index) in dataList" :key="index">
+        <Cell class="article-item" title-class="article-item__title" value-class="article-item__time"
+          :title="item.title" :value="formatDate(item.publishdate, 'MM/DD')"
+          :to="{ name: 'news-detail', query: { id: item.id } }" />
+      </template>
+    </app-pull-refresh>
+  </app-view>
+</template>
+
+<script lang="ts" setup>
+import { shallowRef } from 'vue'
+import { Cell, Empty } from 'vant'
+import { formatDate } from '@/filters'
+import { useRequest } from '@/hooks/request'
+import { i18n } from "@/stores";
+import { querySiteColumnDetail } from '@/services/api/news'
+import AppPullRefresh from '@mobile/components/base/pull-refresh/index.vue'
+
+const props = defineProps({
+  title: {
+    type: String,
+    default: i18n.global.t('routes.news')
+  },
+  showBackButton: {
+    type: Boolean,
+    default: true
+  },
+  columnid: {
+    type: Number,
+    default: 1
+  }
+})
+
+const pullRefreshRef = shallowRef()
+const dataList = shallowRef<Model.SiteColumnDetailRsp[]>([])
+// const siteColumns = shallowRef<Model.SiteColumnConfigRsp[]>([])
+// const currentColumnId = shallowRef(0)
+const error = shallowRef(false)
+
+/// 查询栏目配置
+// const getSiteColumnConfig = querySiteColumnConfig().then((res) => {
+//   siteColumns.value = res.data
+//   /// 默认第一个
+//   if (res.data.length) {
+//     currentColumnId.value = res.data[0].id
+//   }
+// })
+
+const { loading, pageIndex, pageCount, run } = useRequest(querySiteColumnDetail, {
+  manual: true,
+  params: {
+    pagesize: 20,
+  },
+  onSuccess: (res) => {
+    if (pageIndex.value === 1) {
+      dataList.value = []
+    }
+    dataList.value.push(...res.data)
+  },
+  onError: () => {
+    error.value = true
+  }
+})
+
+const onRefresh = () => {
+  // getSiteColumnConfig.then(() => {
+    run({ columnid: props.columnid })
+  // })
+}
+
+// Tab触发
+// const onClickTab = () => {
+//   pullRefreshRef.value?.refresh()
+// }
+</script>
+
+<style lang="less">
+@import './index.less';
+</style>

+ 20 - 0
src/packages/sjgj/views/news/list/index.less

@@ -0,0 +1,20 @@
+@import '@mobile//assets/themes/base/mixin.less';
+
+.news-list {
+    &__container {
+        padding-top: 10px;
+
+        .article-item {
+            &__title {
+                span {
+                    .mixin-text-overflow()
+                }
+            }
+
+            &__time {
+                flex: initial;
+                margin-left: 24px;
+            }
+        }
+    }
+}