Browse Source

✨ feat: 公告功能上线

Pchen. 5 months ago
parent
commit
649e174d6d

+ 1 - 1
src/App.vue

@@ -21,7 +21,7 @@
 import { ref, onMounted } from 'vue'
 import storage from 'store'
 import { Modal, Message } from '@arco-design/web-vue'
-import { getAppVersion } from '@/api/user'
+import { getAppVersion } from '@/api/public'
 
 const mobile = ref(false)
 

+ 21 - 0
src/api/public.js

@@ -0,0 +1,21 @@
+import request from '../utils/request'
+
+const api = {
+  AppVersion: '/Public/GetAppVersion',
+  GetNotice: '/Public/GetNotice'
+}
+
+export function getAppVersion() {
+  return request({
+    url: api.AppVersion,
+    method: 'get'
+  })
+}
+
+export function GetNotice(parameter) {
+  return request({
+    url: api.GetNotice,
+    method: 'get',
+    params: parameter
+  })
+}

+ 0 - 8
src/api/user.js

@@ -1,7 +1,6 @@
 import request from '../utils/request'
 
 const api = {
-  AppVersion: '/Public/GetAppVersion',
   ChangeUsername: '/User/ChangeUsername',
   ChangePassword: '/User/ChangePassword',
   UserInfo: '/User/Info',
@@ -13,13 +12,6 @@ const api = {
   AdminGetReqLogDetail: '/Admin/User/GetReqLogDetail'
 }
 
-export function getAppVersion() {
-  return request({
-    url: api.AppVersion,
-    method: 'get'
-  })
-}
-
 export function ChangeUsername(parameter) {
   return request({
     url: api.ChangeUsername,

+ 13 - 0
src/pages/lepao/accountList/index.vue

@@ -95,6 +95,8 @@
         </a-col>
       </a-row>
 
+      <a-alert v-if="notice" style="margin-bottom: 15px;">{{ notice }}</a-alert>
+
       <a-table :data="data" :bordered="false" hoverable class="table" :loading="loading" expandable :scroll="{
         x: 1600
       }" :pagination="{
@@ -293,6 +295,10 @@ import { IconSearch } from '@arco-design/web-vue/es/icon'
 import userCard from '@/components/userCard/userCard.vue'
 import { isElectron } from '@/utils/electron'
 import faceModal from '@/components/FaceModal/faceModal.vue'
+import { useRoute } from 'vue-router'
+import { getNotice } from '@/utils/util'
+
+const notice = ref('')
 
 const email = ref([])
 const faceInfo = ref({})
@@ -548,6 +554,12 @@ const getAccounts = async () => {
   }
 }
 
+const GetNotice = async () => {
+  const { path } = useRoute()
+  const res = await getNotice(path)
+  notice.value = res
+}
+
 const SingleRun = async (item) => {
   if (item.state !== 1)
     return Notification.warning({
@@ -633,6 +645,7 @@ const stopPolling = () => {
 
 onMounted(async () => {
   getAccountsAsync()
+  GetNotice()
   startPolling()
 })
 

+ 12 - 1
src/pages/lepao/lepaoRecords/index.vue

@@ -46,7 +46,7 @@
         </a-col>
       </a-row>
 
-      <a-alert>仅保存成功上传至乐跑服务器的跑步记录。未成功的跑步(含状态无效)不会扣除账户乐跑次数。</a-alert>
+      <a-alert v-if="notice" style="margin-bottom: 15px;">{{ notice }}</a-alert>
 
       <a-table :data="data" :bordered="false" hoverable class="table" :loading="loading" :pagination="{
         showPageSize: true,
@@ -153,6 +153,16 @@ import { lepaoRecords } from '@/api/lepao'
 import { Notification } from '@arco-design/web-vue'
 import { IconSearch } from '@arco-design/web-vue/es/icon'
 import { useUserStore } from '@/store/modules/user'
+import { useRoute } from 'vue-router'
+import { getNotice } from '@/utils/util'
+
+const notice = ref('')
+
+const GetNotice = async () => {
+  const { path } = useRoute()
+  const res = await getNotice(path)
+  notice.value = res
+}
 
 const data = ref([])
 const loading = ref(false)
@@ -250,6 +260,7 @@ function formatSecondsToMinSec(totalSeconds) {
 }
 
 getRecords()
+GetNotice()
 </script>
 
 <style scoped lang="less">

+ 40 - 4
src/pages/power/accountList.vue

@@ -10,7 +10,7 @@
         添加提醒任务
       </a-button>
 
-      <a-alert style="margin-top: 15px;">电费单价:¥0.54/千瓦时。仅保存最近180天的电费变更记录。电费余额每30分钟更新一次,添加任务后开始记录。</a-alert>
+      <a-alert v-if="notice" style="margin-top: 15px;">{{ notice }}</a-alert>
 
       <a-table :data="data" :columns="columns" :bordered="false" hoverable class="table" :loading="loading" :scroll="{
         x: 1600
@@ -84,8 +84,14 @@
 
   <!-- 电费变更记录 -->
   <a-modal v-model:visible="listVisible" title="电费变更记录" esc-to-close closable width="auto" hide-cancel>
-    <a-table :data="changeList" :columns="listColumns" stripe hoverable :loading="listLoading"
-      :pagination="{ showPageSize: true, showJumper: true, defaultPageSize: 15 }">
+    <a-table :data="changeList" :columns="listColumns" stripe hoverable :loading="listLoading" :pagination="{
+      showPageSize: true,
+      showJumper: true,
+      showTotal: true,
+      pageSize: pagination.pagesize,
+      current: pagination.current,
+      total: pagination.total
+    }" @page-change="handlePageChange" @page-size-change="handlePageSizeChange">
       <template #balance="{ record }">
         ¥{{ record.balance }}
       </template>
@@ -95,7 +101,7 @@
       <template #change="{ record }">
         <a-tag :color="Number(record.balance) < Number(record.old_balance) ? 'red' : 'green'">¥{{ Number(record.balance
           - record.old_balance).toFixed(2)
-          }}</a-tag>
+        }}</a-tag>
       </template>
       <template #time="{ record }">
         {{ stramptoTime(record.time) }}
@@ -108,16 +114,44 @@
 import { ref, reactive, onMounted, h } from 'vue'
 import { getPowerData, addAccount, deleteAccount, getAccount, getChangeRecord } from '@/api/power'
 import { Modal, Notification, Message } from '@arco-design/web-vue'
+import { useRoute } from 'vue-router'
+import { getNotice } from '@/utils/util'
+
+const notice = ref('')
+
+const GetNotice = async () => {
+  const { path } = useRoute()
+  const res = await getNotice(path)
+  notice.value = res
+}
 
 const data = ref([])
 const loading = ref(false)
 
 const listVisible = ref(false)
+const pagination = reactive({
+  total: 0,
+  current: 1,
+  pagesize: 15
+})
+
+// 分页 - 页码变化
+const handlePageChange = (page) => {
+  pagination.current = page
+}
+
+// 分页 - 每页条数变化
+const handlePageSizeChange = (size) => {
+  pagination.pagesize = size
+  pagination.current = 1 // 页大小变化后回到第一页
+}
+
 const changeList = ref([])
 const listLoading = ref(false)
 const GetChangeRecord = async (id) => {
   try {
     listLoading.value = true
+    pagination.current = 1
     listVisible.value = true
     changeList.value = []
     const res = await getChangeRecord({ id })
@@ -127,6 +161,7 @@ const GetChangeRecord = async (id) => {
         content: res?.msg ?? '请稍后再试'
       })
     changeList.value = res.data
+    pagination.total = res.data.length
   } catch (error) {
     Notification.error({
       title: '获取电费变更记录失败!',
@@ -397,6 +432,7 @@ const stramptoTime = (time) => {
 onMounted(() => {
   GetPowerData('buildlist')
   getAccounts()
+  GetNotice()
 })
 
 </script>

+ 14 - 0
src/pages/qxs/getBookList.vue

@@ -45,6 +45,8 @@
                 </div>
             </div>
 
+            <a-alert v-if="notice" style="margin-top: 15px;">{{ notice }}</a-alert>
+
             <a-watermark :content="['RunForge', 'xxoo365.top']" :alpha="0.5">
                 <a-table :data="data" stripe hoverable :pagination="false" column-resizable class="table"
                     :loading="loading" :columns="columns">
@@ -81,6 +83,18 @@
 import { ref, reactive, h } from 'vue'
 import { GetBookList, GetBookImg } from '@/api/qxs'
 import { Notification, Modal, Button } from '@arco-design/web-vue'
+import { useRoute } from 'vue-router'
+import { getNotice } from '@/utils/util'
+
+const notice = ref('')
+
+const GetNotice = async () => {
+  const { path } = useRoute()
+  const res = await getNotice(path)
+  notice.value = res
+}
+
+GetNotice()
 
 const form = reactive({
     username: '',

+ 13 - 0
src/pages/service/orderList.vue

@@ -10,6 +10,8 @@
                 提交工单
             </a-button>
 
+            <a-alert v-if="notice" style="margin-top: 15px;">{{ notice }}</a-alert>
+
             <a-table :data="data" stripe hoverable column-resizable class="table" :loading="loading" :columns="columns"
                 :pagination="{
                     showPageSize: true,
@@ -57,6 +59,16 @@
 import { ref, reactive, onMounted } from 'vue'
 import { orderList } from '@/api/workOrder'
 import { Notification } from '@arco-design/web-vue'
+import { useRoute } from 'vue-router'
+import { getNotice } from '@/utils/util'
+
+const notice = ref('')
+
+const GetNotice = async () => {
+  const { path } = useRoute()
+  const res = await getNotice(path)
+  notice.value = res
+}
 
 const pagination = reactive({
     total: 0,
@@ -135,6 +147,7 @@ const handlePageSizeChange = (size) => {
 
 onMounted(() => {
     getOrderList()
+    GetNotice()
 })
 
 const stramptoTime = (time) => {

+ 12 - 0
src/pages/store/goodsList/index.vue

@@ -5,6 +5,7 @@
         <userCard type="goods"/>
 
         <a-card title="商品列表" style="margin-top: 20px;">
+            <a-alert v-if="notice" style="margin-bottom: 15px;">{{ notice }}</a-alert>
             <a-list hoverable :loading="loading">
                 <a-list-item v-for="(item, index) in data" :key="index">
                     <div class="list">
@@ -36,6 +37,16 @@ import { ref } from 'vue'
 import { getGoodsList } from '@/api/goods'
 import { Notification } from '@arco-design/web-vue'
 import userCard from '@/components/userCard/userCard.vue'
+import { useRoute } from 'vue-router'
+import { getNotice } from '@/utils/util'
+
+const notice = ref('')
+
+const GetNotice = async () => {
+  const { path } = useRoute()
+  const res = await getNotice(path)
+  notice.value = res
+}
 
 const data = ref([])
 const loading = ref(false)
@@ -61,6 +72,7 @@ const getGoods = async () => {
 }
 
 getGoods()
+GetNotice()
 </script>
 
 <style lang="less" scoped>

+ 13 - 0
src/pages/store/orders/orderList/index.vue

@@ -3,6 +3,8 @@
   <div class="container">
     <Breadcrumb :items="['云商城', '我的订单']" />
     <a-card title="我的订单">
+      <a-alert v-if="notice" style="margin-bottom: 15px;">{{ notice }}</a-alert>
+
       <a-table :data="data" stripe hoverable column-resizable class="table" :loading="loading"
         :pagination="{ showPageSize: true, showJumper: true, defaultPageSize: 15 }">
 
@@ -92,6 +94,16 @@ import { ref, h } from 'vue'
 import { getMyOrder } from '@/api/order'
 import { Notification } from '@arco-design/web-vue'
 import { IconSearch } from '@arco-design/web-vue/es/icon'
+import { useRoute } from 'vue-router'
+import { getNotice } from '@/utils/util'
+
+const notice = ref('')
+
+const GetNotice = async () => {
+  const { path } = useRoute()
+  const res = await getNotice(path)
+  notice.value = res
+}
 
 const data = ref([])
 const loading = ref(false)
@@ -132,6 +144,7 @@ function getPayType(type) {
 }
 
 GetMyOrder()
+GetNotice()
 </script>
 
 <style scoped lang="less">

+ 20 - 5
src/utils/util.js

@@ -1,6 +1,21 @@
-export function timeFix () {
-    const time = new Date()
-    const hour = time.getHours()
-    return hour < 9 ? '早上好' : hour <= 11 ? '上午好' : hour <= 13 ? '中午好' : hour < 20 ? '下午好' : '晚上好'
+import { GetNotice } from '@/api/public'
+
+export function timeFix() {
+  const time = new Date()
+  const hour = time.getHours()
+  return hour < 9 ? '早上好' : hour <= 11 ? '上午好' : hour <= 13 ? '中午好' : hour < 20 ? '下午好' : '晚上好'
+}
+
+export async function getNotice(key) {
+  try {
+    const res = await GetNotice({ key })
+    if (!res || res.code !== 0) {
+      console.log(`获取公告失败:${res?.msg ?? ''}`)
+      return ''
+    }
+    return res.msg ?? ''
+  } catch (error) {
+    console.log('获取公告失败:', error)
+    return ''
   }
-  
+}