Browse Source

代码优化

fanghuisheng 1 year ago
parent
commit
dfa95a484b
3 changed files with 121 additions and 128 deletions
  1. 15 30
      src/pages/common/customManage/index.vue
  2. 104 93
      src/pages/index.vue
  3. 2 5
      src/plugins/common.plugins.js

+ 15 - 30
src/pages/common/customManage/index.vue

@@ -40,27 +40,21 @@
             <view class="menu-item-box" style="font-size: 16px; font-weight: 600; color: #000000">
               <view> {{ data.projectName }} </view>
             </view>
-            <view class="menu-item-box" style="font-size: 13px">
-              <view style="width: 50%"> 项目编号:{{ data.projectId }} </view>
-              <view style="width: 50%"> 到期时间:{{ data.expireTime ? data.expireTime.split("T")[0] : "" }} </view>
-            </view>
-            <view class="menu-item-box" style="font-size: 13px">
-              <view style="width: 50%"> 客户负责人:{{ data.customPerson }} </view>
-              <view style="width: 50%"> 维保费:¥{{ data.maintainAmount }} </view>
-            </view>
-            <view class="menu-item-box" style="font-size: 13px">
-              <view style="width: 50%; display: flex">
+            <view class="menu-item-box" style="font-size: 13px; flex-flow: row wrap">
+              <view style="min-width: 50%"> 项目编号:{{ data.projectId }} </view>
+              <view style="min-width: 50%"> 到期时间:{{ data.expireTime ? data.expireTime.split("T")[0] : "" }} </view>
+              <view style="min-width: 50%"> 客户负责人:{{ data.customPerson }} </view>
+              <view style="min-width: 50%"> 维保费:¥{{ data.maintainAmount }} </view>
+              <view style="min-width: 50%; display: flex; white-space: nowrap">
                 客户电话:{{ data.phone }}
                 <view class="iconfont ucicon-a-copy menu-icon" style="font-size: 14px; color: #909399; margin-left: 5px" @click="copy(data.phone)"> </view>
               </view>
-              <view style="width: 50%">
+              <view style="min-width: 50%">
                 状态:
                 <span :style="`color: ${data.maintainStatus == 1 ? '#16bf00' : 'red'} `">
                   {{ data.maintainStatus == 1 ? "使用中" : "已到期" }}
                 </span>
               </view>
-            </view>
-            <view class="menu-item-box" style="font-size: 13px">
               <view> 客户地址: {{ data.customAddress }} </view>
             </view>
           </view>
@@ -91,26 +85,24 @@ const data = reactive({
       value: "",
     },
     {
-      label: "7天",
-      value: 7,
+      label: "30天内到期",
+      value: 30,
     },
     {
-      label: "30天",
-      value: 30,
+      label: "60天内到期",
+      value: 60,
     },
     {
-      label: "90天",
+      label: "90天内到期",
       value: 90,
     },
   ],
   radioValue: "",
-  startTime: "",
-  endTime: "",
   projectName: "",
   dropdownShow: false,
 });
 
-const { radioList, radioValue, startTime, endTime, projectName, dropdownShow } = toRefs(data);
+const { radioList, radioValue, projectName, dropdownShow } = toRefs(data);
 
 /**
  * @初始化
@@ -128,8 +120,8 @@ function selectListApi() {
     projectName: projectName.value,
     current: current.value,
     size: pageSize.value,
-    endTime: endTime.value,
-    startTime: startTime.value,
+    endTime: radioValue.value ? proxy.$common.getDays(-radioValue.value)[0] + " 00:00:00" : "",
+    startTime: radioValue.value ? proxy.$common.getDays(-radioValue.value)[1] + " 00:00:00" : "",
   }).then((requset) => {
     if (requset.status === "SUCCESS") {
       dataList.value = requset.data.records;
@@ -166,11 +158,6 @@ function copy(value) {
  */
 function radioChange(e) {
   radioValue.value = e;
-  if (e) {
-    let getDays = proxy.$common.getDays(e);
-    startTime.value = getDays.startTime;
-    endTime.value = getDays.endTime;
-  }
   selectListApi();
 }
 
@@ -187,8 +174,6 @@ function load() {
  */
 function refresh() {
   radioValue.value = "";
-  startTime.value = "";
-  endTime.value = "";
   pageSize.value = 20;
   total.value = 0;
   selectListApi();

+ 104 - 93
src/pages/index.vue

@@ -19,71 +19,86 @@
   </u-navbar>
 
   <!-- <pagesHarder></pagesHarder> -->
-  <scroll-view class="home-container" scroll-y :style="{ height: `calc(100vh - (50px + ${proxy.$settingStore.barHightTop} + ${proxy.$settingStore.tabBarHeight}))` }">
-    <!-- <u-loadmore :status="arrayList.loadStatus" loadingText="" loadmoreText="" :icon="true" /> -->
-    <view class="uni-content-body">
-      <!-- 下拉列表 开始 -->
-      <u-transition :show="dialogFlag" :duration="200" mode="fade">
-        <view class="transition" @click="rightButtonClick()">
-          <view class="transition-section" :style="{ top: proxy.$settingStore.barHightTop }">
-            <view class="transition-section-content" @click="scanCode()">
-              <text class="transition-section-content-icon iconfont ucicon-saoyisao"></text>
-              <view class="transition-section-content-text"> 扫一扫 </view>
-            </view>
-            <!-- <div class="transition-section-divider"></div>
+
+  <oa-scroll
+    class="scroll-height"
+    :style="{ height: `calc(100vh - (50px + ${proxy.$settingStore.barHightTop} + ${proxy.$settingStore.tabBarHeight}))` }"
+    :refresherLoad="false"
+    :refresherEnabled="true"
+    :refresherDefaultStyle="'none'"
+    :refresherThreshold="44"
+    :refresherBackground="'#f5f6f7'"
+    @refresh="refresh"
+  >
+    <template #default>
+      <!-- <u-loadmore :status="arrayList.loadStatus" loadingText="" loadmoreText="" :icon="true" /> -->
+      <view class="home-container uni-content-body">
+        <!-- 下拉列表 开始 -->
+        <u-transition :show="dialogFlag" :duration="200" mode="fade">
+          <view class="transition" @click="rightButtonClick()">
+            <view class="transition-section" :style="{ top: proxy.$settingStore.barHightTop }">
+              <view class="transition-section-content" @click="scanCode()">
+                <text class="transition-section-content-icon iconfont ucicon-saoyisao"></text>
+                <view class="transition-section-content-text"> 扫一扫 </view>
+              </view>
+              <!-- <div class="transition-section-divider"></div>
             <view class="transition-section-content">
               <text class="transition-section-content-icon iconfont ucicon-saoyisao"></text>
               <view class="transition-section-content-text">发起群聊 </view>
             </view> -->
+            </view>
           </view>
-        </view>
-      </u-transition>
-      <!-- 下拉列表 结束 -->
+        </u-transition>
+        <!-- 下拉列表 结束 -->
 
-      <!-- 轮播图 开始 -->
-      <u-swiper :list="swiperList" :interval="swiperTime" indicatorMode="line" radius="0" height="160" indicator circular keyName="url" @click="swiperClick" @change="swiperChange"> </u-swiper>
+        <!-- 轮播图 开始 -->
+        <u-swiper v-if="swiperBool" :list="swiperList" :interval="swiperTime" indicatorMode="line" radius="0" height="160" indicator circular keyName="url" @click="swiperClick" @change="swiperChange">
+        </u-swiper>
 
-      <view class="app-info-notice bg-white radius shadow-default margin-lr-sm margin-bottom-sm">
-        <view class="flex">
-          <view class="info-title text-df">综合智慧云</view>
-          <view class="info-time text-sm">07-25 19:23</view>
+        <image v-if="!swiperBool" style="width: 100%; height: 160px" src="@/static/images/index/banner1.png"></image>
+
+        <view class="app-info-notice bg-white radius shadow-default margin-lr-sm margin-bottom-sm">
+          <view class="flex">
+            <view class="info-title text-df">综合智慧云</view>
+            <view class="info-time text-sm">07-25 19:23</view>
+          </view>
+          <view class="info-content text-sm">综合智慧云app,助力企业数字化转型升级,超多业务功能,全新部署上线,操作简单流畅...</view>
         </view>
-        <view class="info-content text-sm">综合智慧云app,助力企业数字化转型升级,超多业务功能,全新部署上线,操作简单流畅...</view>
-      </view>
 
-      <!-- 轮播图 结束 -->
+        <!-- 轮播图 结束 -->
 
-      <!-- 宫格列表 -->
-      <view class="section2 section bg-white margin-bottom-sm" v-if="recentlyUsed.length > 0">
-        <view style="color: #000000; font-size: 14px; padding: 10px 10px 5px 10px">最近使用</view>
-        <view class="cu-list grid col-5 no-border">
-          <view class="cu-item justify-center align-center" @tap="navItemClick(item)" v-for="(item, index) in recentlyUsed.slice(0, 5)" :key="index">
-            <image :src="item.meta.icon" style="width: 40px; height: 40px"></image>
-            <!-- <view class="cu-tag badge" v-if="item.badge != 0">
+        <!-- 宫格列表 -->
+        <view class="section2 section bg-white margin-bottom-sm" v-if="recentlyUsed.length > 0">
+          <view style="color: #000000; font-size: 14px; padding: 10px 10px 5px 10px">最近使用</view>
+          <view class="cu-list grid col-5 no-border">
+            <view class="cu-item justify-center align-center" @tap="navItemClick(item)" v-for="(item, index) in recentlyUsed.slice(0, 5)" :key="index">
+              <image :src="item.meta.icon" style="width: 40px; height: 40px"></image>
+              <!-- <view class="cu-tag badge" v-if="item.badge != 0">
               <block v-if="item.badge != 0">{{ item.badge > 99 ? "99+" : item.badge }}</block>
             </view> -->
-            <text style="font-size: 12px">{{ item.meta.title }}</text>
+              <text style="font-size: 12px">{{ item.meta.title }}</text>
+            </view>
           </view>
         </view>
-      </view>
-      <!-- 宫格列表 end -->
-
-      <!-- 宫格列表 -->
-      <view class="section2 section bg-white">
-        <view style="color: #000000; font-size: 14px; padding: 10px 10px 5px 10px">常用功能</view>
-        <view class="cu-list grid col-5 no-border">
-          <view class="cu-item justify-center align-center" @tap="navItemClick(item)" v-for="(item, index) in cuIconList" :key="index">
-            <image :src="item.meta.icon" style="width: 40px; height: 40px"></image>
-            <!-- <view class="cu-tag badge" v-if="item.badge != 0">
+        <!-- 宫格列表 end -->
+
+        <!-- 宫格列表 -->
+        <view class="section2 section bg-white">
+          <view style="color: #000000; font-size: 14px; padding: 10px 10px 5px 10px">常用功能</view>
+          <view class="cu-list grid col-5 no-border">
+            <view class="cu-item justify-center align-center" @tap="navItemClick(item)" v-for="(item, index) in cuIconList" :key="index">
+              <image :src="item.meta.icon" style="width: 40px; height: 40px"></image>
+              <!-- <view class="cu-tag badge" v-if="item.badge != 0">
               <block v-if="item.badge != 0">{{ item.badge > 99 ? "99+" : item.badge }}</block>
             </view> -->
-            <text style="font-size: 12px">{{ item.meta.title }}</text>
+              <text style="font-size: 12px">{{ item.meta.title }}</text>
+            </view>
           </view>
         </view>
+        <!-- 宫格列表 end -->
       </view>
-      <!-- 宫格列表 end -->
-    </view>
-  </scroll-view>
+    </template>
+  </oa-scroll>
 
   <oa-tabbar :tabbarValue="0"></oa-tabbar>
 </template>
@@ -149,44 +164,6 @@ function swiperClick(list) {
   }
 }
 
-/**
- * @轮播图
- * @api接口请求
- */
-function getMobileBannerApi() {
-  getMobileBanner({
-    tenantId: useStore.$state.tenantId,
-  }).then((res) => {
-    if (res.data.length > 0) {
-      swiperList.value = [];
-      swiperBool.value = res.data[0].openNot == 1 ? true : false;
-      swiperTime.value = res.data[0].carouselTime * 1000;
-
-      if (swiperBool.value) {
-        for (let i = 1; i <= 5; i++) {
-          if (res.data[0]["bannerPath" + i]) {
-            swiperList.value.push({
-              url: res.data[0]["bannerPath" + i],
-              link: res.data[0]["linkUrl" + i],
-              linkType: res.data[0]["linkType" + i],
-              type: "image",
-            });
-          }
-        }
-      } else {
-        swiperList.value = [
-          {
-            url: "/static/images/index/banner1.png",
-            link: "",
-            linkType: 1,
-            type: "image",
-          },
-        ];
-      }
-    }
-  });
-}
-
 onLoad((option) => {
   uni.hideTabBar(); //隐藏自带tabbar
 
@@ -194,11 +171,18 @@ onLoad((option) => {
     recentlyUsed.value = uni.getStorageSync(useStore.$state.name + useStore.$state.tenantId);
   }
 
-  getAppRoutersData();
-
-  getMobileBannerApi();
+  getAppRoutersData(); //调用路由信息接口
+  getMobileBannerApi(); //调用banner图接口
 });
 
+/**
+ * @scrollView刷新数据
+ */
+function refresh() {
+  getAppRoutersData(); //调用路由信息接口
+  getMobileBannerApi(); //调用banner图接口
+}
+
 /**
  * @扫码功能
  */
@@ -250,7 +234,9 @@ function scanCode() {
   //#endif
 }
 
-//获取地理位置
+/**
+ * @获取地理位置
+ */
 function getLocation() {
   jwx.configWeiXin((jweixin) => {
     // 微信公众号获取位置
@@ -263,7 +249,9 @@ function getLocation() {
   });
 }
 
-//九宫格页面跳转
+/**
+ * @九宫格页面跳转
+ */
 function navItemClick(item) {
   if (item.path) {
     item.sort = 0;
@@ -313,10 +301,36 @@ function navItemClick(item) {
  * @右侧按钮点击事件
  */
 function rightButtonClick() {
-  console.log(1);
   dialogFlag.value = !dialogFlag.value;
 }
 
+/**
+ * @轮播图
+ * @api接口请求
+ */
+function getMobileBannerApi() {
+  getMobileBanner({
+    tenantId: useStore.$state.tenantId,
+  }).then((res) => {
+    if (res.data.length > 0) {
+      swiperList.value = [];
+      swiperBool.value = res.data[0].openNot == 1 ? true : false;
+      swiperTime.value = res.data[0].carouselTime * 1000;
+
+      for (let i = 1; i <= 5; i++) {
+        if (res.data[0]["bannerPath" + i]) {
+          swiperList.value.push({
+            url: res.data[0]["bannerPath" + i],
+            link: res.data[0]["linkUrl" + i],
+            linkType: res.data[0]["linkType" + i],
+            type: "image",
+          });
+        }
+      }
+    }
+  });
+}
+
 /**
  * @获取路由信息
  * @api接口请求
@@ -329,7 +343,6 @@ function getAppRoutersData() {
     // domain :'172.16.120.165:13203'
   }).then((res) => {
     res.data.forEach((el) => {
-      //  const modules = import.meta.glob("@/static/icons/*.svg");
       el.meta.icon = `/static/icons/index/${el.meta.icon}.svg`;
     });
 
@@ -352,8 +365,6 @@ onNavigationBarButtonTap((e) => {
 
 <style lang="scss" scoped>
 .home-container {
-  height: 100vh;
-
   .uni-content-body {
     // #ifdef H5
     padding-bottom: 50px;

+ 2 - 5
src/plugins/common.plugins.js

@@ -99,7 +99,7 @@ export default {
   },
 
   /**
-   * @指定获取当前时间前几天的日期
+   * @指定获取开始时间结束时间
    */
   getDays(value) {
     let oneDay = 24 * 60 * 60 * 1000;
@@ -107,10 +107,7 @@ export default {
     endTime = this.formatterDate(endTime, "yyyy-MM-dd");
     let startTime = new Date(Date.now() - value * oneDay);
     startTime = this.formatterDate(startTime, "yyyy-MM-dd");
-    const days = {
-      startTime,
-      endTime,
-    };
+    const days = [startTime, endTime,]
     return days;
   },