fanghuisheng 1 год назад
Родитель
Сommit
9a884a8c19

+ 0 - 0
src/api/common/loginLog.js → src/api/mine/secure/loginLog.js


+ 198 - 0
src/components/oa-scroll/index.vue

@@ -0,0 +1,198 @@
+<template>
+  <scroll-view
+    :scroll-y="true"
+    scroll-with-animation
+    :refresher-threshold="refresherThreshold"
+    :refresher-default-style="refresherDefaultStyle"
+    :refresherEnabled="refresherEnabled"
+    :refresher-triggered="triggered"
+    :refresher-background="refresherBackground"
+    :scroll-top="scrollTop"
+    @refresherrefresh="onRefresh"
+    @scrolltolower="scrolltolower"
+  >
+    <slot name="topLoading" v-if="refresherDefaultStyle === 'none'">
+      <view
+        class="topBox"
+        :style="{
+          marginTop: '-' + refresherThreshold + 'px',
+          height: refresherThreshold + 'px',
+        }"
+      >
+        <view class="loader">
+          <view v-for="(v, i) in 10" :key="v" :style="{ transform: 'rotate(' + i * 36 + 'deg)', animationDelay: v == 10 ? 1 + 's' : '0.' + v + 's' }"> </view>
+        </view>
+        <view class="title">
+          {{ topTis }}
+        </view>
+      </view>
+    </slot>
+    <slot name="default"> </slot>
+    <slot name="bottomLoading">
+      <div
+        class="bottoBox"
+        :style="{
+          marginTop: lowerThreshold + 'px',
+        }"
+        v-if="refresherLoad"
+      >
+        {{ pageSize >= total ? "没有更多啦~" : isScrolltolower }}
+      </div>
+    </slot>
+  </scroll-view>
+</template>
+<script setup>
+import { onReady, onLoad, onShow, onNavigationBarButtonTap, onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
+import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, watchEffect, toRefs, toRef, watch } from "vue";
+
+const emit = defineEmits(["load", "refresh"]);
+const props = defineProps({
+  //当前页数量
+  pageSize: {
+    type: Number,
+    default: 30,
+  },
+  //数据总数
+  total: {
+    type: Number,
+    default: 0,
+  },
+
+  //设置滚动条位置
+  scrollTop: {
+    type: String,
+    default: "",
+  },
+  //是否开启上拉加载
+  refresherLoad: {
+    type: Boolean,
+    default: false,
+  },
+  // 距离底部上拉加载距离
+  lowerThreshold: {
+    type: Number,
+    default: 20,
+  },
+  //是否开启下拉刷新
+  refresherEnabled: {
+    type: Boolean,
+    default: false,
+  },
+  //距离顶部下拉刷新距离
+  refresherThreshold: {
+    type: Number,
+    default: 45,
+  },
+  //是否使用默认下拉刷新样式(支持设置 black、white、none/none 表示不使用默认样式)
+  refresherDefaultStyle: {
+    type: String,
+    default: "black",
+  },
+  //设置自定义下拉刷新区域背景颜色
+  refresherBackground: {
+    type: String,
+    default: "#fff",
+  },
+});
+
+const { pageSize, total, scrollTop, refresherLoad, lowerThreshold, refresherEnabled, refresherThreshold, refresherDefaultStyle, refresherBackground } = toRefs(props);
+
+const defaultOption = reactive({});
+
+const {} = toRefs(defaultOption);
+
+const defaultArray = reactive({
+  triggered: false,
+  topTis: "松手刷新",
+  isScrolltolower: "上拉加载更多",
+});
+
+const { triggered, topTis, isScrolltolower } = toRefs(defaultArray);
+
+/**
+ * @scrollView上拉刷新
+ */
+function onRefresh() {
+  isScrolltolower.value = "上拉加载更多";
+  topTis.value = "努力加载中";
+  //做一个判断,判断triggered 是否为true
+  if (!triggered.value) {
+    triggered.value = true;
+    setTimeout((e) => {
+      triggered.value = false;
+      topTis.value = "松手刷新";
+      emit("refresh");
+    }, 1000);
+  }
+}
+
+/**
+ * @scrollView触底事件
+ */
+function scrolltolower(e) {
+  if (!refresherLoad.value || pageSize.value >= total.value) {
+    return;
+  } else {
+    isScrolltolower.value = "正在加载中~";
+    setTimeout(() => {
+      emit("load");
+      isScrolltolower.value = "上拉加载更多";
+    }, 1000);
+  }
+}
+
+onLoad((option) => {});
+</script>
+
+<style scoped>
+.topBox {
+  width: 100%;
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  color: gray;
+}
+
+.topBox .loader {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  height: 100%;
+  position: relative;
+  margin-top: -25rpx;
+}
+
+.topBox .loader view {
+  width: 2px;
+  height: 6px;
+  background-color: gray;
+  transform-origin: 50% 150%;
+  position: absolute;
+  animation: color-change 1s infinite;
+}
+
+.topBox .title {
+  position: relative;
+  margin-left: 35rpx;
+  color: #909399;
+  font-size: 0.75rem;
+}
+
+@keyframes color-change {
+  from {
+    background-color: gray;
+  }
+
+  to {
+    background-color: white;
+  }
+}
+
+.bottoBox {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  color: #909399;
+  font-size: 0.75rem;
+}
+</style>

+ 2 - 0
src/main.js

@@ -18,6 +18,7 @@ import oaTabbar from "@/components/oa-tabbar/index";
 import oaTimeLine from "@/components/oa-timeLine/index"
 import oaTimeLineItem from "@/components/oa-timeLine-item/index"
 import oaUpload from "@/components/oa-upload/index"
+import oaScroll from "@/components/oa-scroll/index"
 
 export function createApp() {
   const app = createSSRApp(App);
@@ -28,6 +29,7 @@ export function createApp() {
   app.component('oa-timeLine', oaTimeLine)
   app.component('oa-timeLine-item', oaTimeLineItem)
   app.component('oa-upload', oaUpload)
+  app.component('oa-scroll', oaScroll)
 
   // 挂载全局json导出
   app.component("downloadExcel", JsonExcel);

+ 7 - 7
src/pages.json

@@ -140,13 +140,6 @@
             "navigationBarTitleText": "应用消息",
             "enablePullDownRefresh": false
           }
-        },
-        {
-          "path": "loginLog/index",
-          "style": {
-            "navigationBarTitleText": "登录日志",
-            "enablePullDownRefresh": false
-          }
         }
       ]
     },
@@ -176,6 +169,13 @@
             "navigationBarTitleText": "账号与安全"
           }
         },
+        {
+          "path": "secure/loginLog/index",
+          "style": {
+            "navigationBarTitleText": "登录日志",
+            "enablePullDownRefresh": false
+          }
+        },
         {
           "path": "avatar/index",
           "style": {

+ 0 - 139
src/pages/common/loginLog/index.vue

@@ -1,139 +0,0 @@
-<template>
-  <scroll-view class="scroll-height" :scroll-y="true" :data-theme="'theme-' + proxy.$settingStore.themeColor.name" @scrolltolower="scrolltolower">
-    <view class="loginLog-container">
-      <u-empty v-show="dataList.length <= 0" text="暂无数据" mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png"> </u-empty>
-      <view class="container-area" v-show="dataList.length > 0">
-        <view class="container-area-content" v-for="data in dataList" :key="data">
-          <view class="container-area-content-img">
-            <image style="width: 35px; height: 35px" :src="'/static/images/404.png'" mode="aspectFill"></image>
-          </view>
-          <view class="container-area-content-center">
-            <view
-              :style="{
-                fontSize: '15px',
-                color: data.status == '0' ? '#16bf00' : 'red',
-              }"
-              >{{ data.status == "0" ? "登录成功" : "登录失败" }}</view
-            >
-            <view>登陆时间:{{ data.accessTime }}</view>
-            <view>访问IP:{{ data.ipaddr }}</view>
-            <view>登录地址:未知</view>
-            <view>登录方式:未知</view>
-            <view>系统型号:未知</view>
-            <view v-if="data.status == '1'">登录失败原因:{{ data.msg }}</view>
-          </view>
-        </view>
-
-        <u-loadmore :status="status" @click="scrolltolower" />
-      </view>
-    </view>
-  </scroll-view>
-</template>
-
-<script setup>
-import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
-import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
-import { publicStores, useStores } from "@/store/modules/index";
-
-import { loginLogList } from "@/api/common/loginLog.js";
-
-const useStore = useStores();
-
-const { proxy } = getCurrentInstance();
-
-const dataList = ref([]);
-const status = ref("loadmore");
-const pageSize = ref(20);
-const current = ref(1);
-const total = ref(0);
-
-/**
- * @初始化
- */
-function init() {
-  selectListApi();
-}
-
-/**
- * @通知公告列表
- * @api接口调用
- */
-function selectListApi() {
-  loginLogList({
-    pageNum: current.value,
-    pageSize: pageSize.value,
-    userName: "admin",
-  }).then((requset) => {
-    if (requset.status === "SUCCESS") {
-      dataList.value = requset.data.rows;
-      total.value = requset.data.total;
-
-      if (total.value == dataList.value.length) {
-        status.value = "nomore";
-      }
-    }
-  });
-}
-
-/**
- * @scrollView触底事件
- */
-function scrolltolower(e) {
-  if (total.value == dataList.value.length) {
-    status.value = "nomore";
-    return;
-  } else {
-    status.value = "loading";
-    pageSize.value += 10;
-    setTimeout(() => {
-      selectListApi();
-    }, 1000);
-  }
-}
-
-onLoad((options) => {
-  init();
-});
-
-onReady(() => {});
-
-onShow(() => {
-  //调用系统主题颜色
-  proxy.$settingStore.systemThemeColor([1]);
-});
-
-// 自定义导航事件
-onNavigationBarButtonTap((e) => {
-  if (e.float == "right") {
-    proxy.$tab.navigateTo("/pages/mine/setting/index");
-  }
-});
-</script>
-
-<style lang="scss" scoped>
-:deep(.uni-page-head__title) {
-  opacity: 1 !important;
-}
-
-.loginLog-container {
-  padding-bottom: 1px;
-
-  .container-area {
-    &-content {
-      display: flex;
-      border-bottom: 1px solid #909399;
-
-      &-img {
-        margin: auto 15px auto 15px;
-      }
-
-      &-center {
-        width: 100%;
-        font-size: 13px;
-        color: #909399;
-        padding: 15px 0 15px 0;
-      }
-    }
-  }
-}
-</style>

+ 1 - 1
src/pages/mine/secure/index.vue

@@ -40,7 +40,7 @@
       </view>
 
       <view class="menu-list margin-t-0 margin-lr-0">
-        <view class="list-cell list-cell-arrow" @click=" proxy.$tab.navigateTo(`/pages/common/loginLog/index`)">
+        <view class="list-cell list-cell-arrow" @click="proxy.$tab.navigateTo(`/pages/mine/secure/loginLog/index`)">
           <view class="menu-item-box">
             <view class="title">登录日志</view>
           </view>

+ 133 - 0
src/pages/mine/secure/loginLog/index.vue

@@ -0,0 +1,133 @@
+<template>
+  <oa-scroll :pageSize="pageSize" :total="total" :refresherLoad="true" :refresherEnabled="true" :refresherDefaultStyle="'none'" :refresherThreshold="44" @load="load" @refresh="refresh">
+    <template #default>
+      <view class="loginLog-container" :data-theme="'theme-' + proxy.$settingStore.themeColor.name">
+        <view class="container-area">
+          <view class="container-area-content" v-for="data in dataList" :key="data">
+            <view class="container-area-content-img">
+              <image style="width: 35px; height: 35px" :src="'/static/images/404.png'" mode="aspectFill"></image>
+            </view>
+            <view class="container-area-content-center">
+              <view
+                :style="{
+                  fontSize: '15px',
+                  color: data.status == '0' ? '#16bf00' : 'red',
+                }"
+                >{{ data.status == "0" ? "登录成功" : "登录失败" }}</view
+              >
+              <view>登陆时间:{{ data.accessTime }}</view>
+              <view>访问IP:{{ data.ipaddr }}</view>
+              <!-- <view>登录地址:未知</view>
+              <view>登录方式:未知</view>
+              <view>系统型号:未知</view> -->
+              <view v-if="data.status == '1'">登录失败原因:{{ data.msg }}</view>
+            </view>
+          </view>
+        </view>
+      </view>
+    </template>
+  </oa-scroll>
+</template>
+
+<script setup>
+import { onLoad, onShow, onReady, onHide, onLaunch, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
+import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
+import { publicStores, useStores } from "@/store/modules/index";
+
+import { loginLogList } from "@/api/mine/secure/loginLog.js";
+
+const useStore = useStores();
+
+const { proxy } = getCurrentInstance();
+
+const dataList = ref([]);
+const pageSize = ref(20);
+const current = ref(1);
+const total = ref(0);
+
+/**
+ * @初始化
+ */
+function init() {
+  selectListApi();
+}
+
+/**
+ * @scrollView加载数据
+ */
+function load() {
+  pageSize.value += 10;
+  selectListApi();
+}
+
+/**
+ * @scrollView刷新数据
+ */
+function refresh() {
+  pageSize.value = 20;
+  total.value = 0;
+  selectListApi();
+}
+
+/**
+ * @通知公告列表
+ * @api接口调用
+ */
+function selectListApi() {
+  loginLogList({
+    pageNum: current.value,
+    pageSize: pageSize.value,
+    userName: useStore.$state.user.userName,
+  }).then((requset) => {
+    if (requset.status === "SUCCESS") {
+      dataList.value = requset.data.rows;
+      total.value = requset.data.total;
+    }
+  });
+}
+
+onLoad((options) => {
+  init();
+});
+
+onReady(() => {});
+
+onShow(() => {
+  //调用系统主题颜色
+  proxy.$settingStore.systemThemeColor([1]);
+});
+
+// 自定义导航事件
+onNavigationBarButtonTap((e) => {
+  if (e.float == "right") {
+    proxy.$tab.navigateTo("/pages/mine/setting/index");
+  }
+});
+</script>
+<style lang="scss" scoped>
+:deep(.uni-page-head__title) {
+  opacity: 1 !important;
+}
+
+.loginLog-container {
+  padding-bottom: 1px;
+
+  .container-area {
+    &-content {
+      display: flex;
+      border-bottom: 1px solid #909399;
+
+      &-img {
+        margin: auto 15px auto 15px;
+      }
+
+      &-center {
+        width: 100%;
+        font-size: 13px;
+        color: #909399;
+        padding: 15px 0 15px 0;
+      }
+    }
+  }
+}
+</style>