Browse Source

服务器配置列表/登录页优化

fanghuisheng 1 year ago
parent
commit
970ea9f99c

+ 2 - 2
src/manifest.json

@@ -1,7 +1,7 @@
 {
-    "name" : "智慧消防",
+    "name" : "综合智慧云",
     "appid" : "__UNI__36DE3A0",
-    "description" : "智慧消防",
+    "description" : "综合智慧云",
     "versionName" : "2.0",
     "versionCode" : 2,
     "transformPx" : false,

+ 7 - 0
src/pages.json

@@ -35,6 +35,13 @@
         "navigationBarTextStyle": "black" // 仅支持 black/white
       }
     },
+    {
+      "path": "pages/serveConfigSelect",
+      "style": {
+        "navigationBarTitleText": "服务器配置",
+        "navigationStyle": "custom"
+      }
+    },
     {
       "path": "pages/serveConfig",
       "style": {

+ 12 - 12
src/pages/login.vue

@@ -10,13 +10,13 @@
     <view class="middle">
       <view class="top">
         <image class="logo" mode="heightFix" :src="useStore.$state.loginLogo" v-if="useStore.$state.loginLogo" />
-        <image class="logo" mode="heightFix" src="@/static/logo200.png" v-else />
-        <text class="title" v-if="useStore.$state.loginTitle">{{ useStore.$state.loginTitle }}</text>
-        <text class="title" v-else>移动端登录</text>
+        <!-- <image class="logo" mode="heightFix" src="@/static/logo200.png" v-else /> -->
+        <text class="title" :style="{ color: useStore.$state.loginBg ? '#FFFFFF' : '#000000' }" v-if="useStore.$state.loginTitle">{{ useStore.$state.loginTitle }}</text>
+        <!-- <text class="title" v-else>移动端登录</text> -->
       </view>
 
       <view class="content">
-        <text class="title">请登录</text>
+        <text class="title" :style="{ color: useStore.$state.loginBg ? '#FFFFFF' : '#000000' }">请登录</text>
 
         <!-- #ifdef APP-PLUS -->
         <view id="okay" v-if="!linkUrl">首次账号登录请先配置服务器</view>
@@ -54,10 +54,10 @@
         <text @click="switchMode">{{ switchText }}</text>
       </view>
 
-      <!-- #ifdef APP-PLUS -->
+      <!-- #ifdef APP-PLUS-->
       <view class="xieyi text-center">
-        <u-checkbox-group>
-          <u-checkbox v-model="userChecked" shape="circle" inactiveColor="#0081ff" size="13"></u-checkbox>
+        <u-checkbox-group v-model="userChecked">
+          <u-checkbox :name="true" shape="circle" inactiveColor="#0081ff" size="13"></u-checkbox>
         </u-checkbox-group>
         <text>我已阅读并同意</text>
         <text @click="handleUserAgrement" class="text-blue">用户协议</text>
@@ -82,7 +82,7 @@ import publicStore from "@/store/modules/public.js";
 
 import useStores from "@/store/modules/user.js";
 const useStore = useStores();
-const newPublicStore = publicStore();
+const publicStores = publicStore();
 
 const { proxy } = getCurrentInstance();
 
@@ -98,7 +98,7 @@ const data = reactive({
   /** 服务器配置数据 */
   linkUrl: uni.getStorageSync("serveUrl"),
   /** 用户隐私协议数据 */
-  userChecked: false,
+  userChecked: [true],
 
   // VerificationCodeOne
 });
@@ -106,7 +106,7 @@ const data = reactive({
 const { phone, verify, codeTime, switchText, username, password, inputIconBool, linkUrl, userChecked } = toRefs(data);
 
 function goSeverConfig() {
-  proxy.$tab.navigateTo("/pages/serveConfig");
+  proxy.$tab.navigateTo("/pages/serveConfigSelect");
 }
 
 /**登录方式切换 */
@@ -137,7 +137,7 @@ function getVerifyCode() {
   }
 
   //#ifdef APP-PLUS
-  if (userChecked.value) {
+  if (userChecked.value[0]) {
     proxy.$modal.msg("请在阅读并同意 用户协议和隐私协议后登录");
     return;
   }
@@ -220,7 +220,7 @@ function submitRes() {
   //#endif
 
   //#ifdef APP-PLUS
-  if (userChecked.value) {
+  if (userChecked.value[0]) {
     proxy.$modal.msg("请在阅读并同意 用户协议和隐私协议后登录");
     return;
   }

+ 4 - 3
src/pages/mine/about/index.vue

@@ -1,8 +1,9 @@
 <template>
   <view class="about-container">
     <view class="header-section text-center">
-      <image style="width: 150rpx; height: 150rpx" src="@/static/logo200.png" mode="widthFix"> </image>
-      <uni-title type="h2" title="永天saas移动端"></uni-title>
+      <image style="width: 150rpx; height: 150rpx" mode="heightFix" :src="useStore.$state.loginLogo" v-if="useStore.$state.loginLogo" />
+      <image style="width: 150rpx; height: 150rpx" mode="heightFix" src="@/static/logo200.png" v-else />
+      <uni-title type="h2" :title="useStore.$state.loginTitle"></uni-title>
     </view>
 
     <view class="content-section">
@@ -16,7 +17,7 @@
         <view class="list-cell list-cell-arrow">
           <view class="menu-item-box">
             <view>官方邮箱</view>
-            <!-- <view class="text-right">ruoyi@xx.com</view> -->
+            <view class="text-right"></view>
           </view>
         </view>
         <view class="list-cell list-cell-arrow">

+ 11 - 12
src/pages/serveConfig.vue

@@ -15,7 +15,9 @@
 
       <!-- <u-input v-model="port" type="number" placeholder="端口号(必填)" border="none" maxlength="5" clearable> </u-input> -->
 
-      <u-input v-model="port" type="number" placeholder="端口号(非必填)" border="none" maxlength="5" clearable> </u-input>
+      <u-input style="margin-bottom: 15px" v-model="port" type="number" placeholder="端口号(非必填)" border="none" maxlength="5" clearable> </u-input>
+
+      <u-input v-model="content" placeholder="备注(非必填)" border="none" maxlength="20" clearable> </u-input>
 
       <u-button type="primary" style="width: 100%; height: 45px; font-size: 17px; margin-top: 20px" @click="handleSubmit()" shape="circle"> 保 存</u-button>
     </view>
@@ -28,17 +30,18 @@ import { onLoad, onShow, onHide, onLaunch } from "@dcloudio/uni-app";
 import { ref, onMounted, inject, shallowRef, reactive, toRefs, getCurrentInstance } from "vue";
 import { getToken, setToken, removeToken } from "@/utils/auth";
 import publicStore from "@/store/modules/public.js";
-const newPublicStore = publicStore();
+const publicStores = publicStore();
 
 const { proxy } = getCurrentInstance();
 
 const dataList = reactive({
   linkUrl: "", //链接地址
   port: "",
+  content: "",
 });
 
 const uForm = ref(null);
-const { linkUrl, port } = toRefs(dataList);
+const { linkUrl, port, content } = toRefs(dataList);
 
 /**
  * @扫一扫
@@ -53,7 +56,6 @@ function scanClick() {
       });
 
       linkUrl.value = e.result.split(":")[0];
-
       port.value = e.result.split(":")[1];
     },
     fail: (err) => {
@@ -74,7 +76,7 @@ function scanClick() {
 }
 
 /**
- * @提交
+ * @保存
  * @按钮点击事件
  */
 function handleSubmit() {
@@ -95,8 +97,10 @@ function handleSubmit() {
 
   if (!port.value) {
     uni.setStorageSync("serveUrl", linkUrl.value);
+    publicStores.getServeList(linkUrl.value, content.value);
   } else {
     uni.setStorageSync("serveUrl", linkUrl.value + ":" + port.value);
+    publicStores.getServeList(linkUrl.value + ":" + port.value, content.value);
   }
 
   config.baseUrl = "http://" + uni.getStorageSync("serveUrl") + "/prod-api";
@@ -107,15 +111,10 @@ function handleSubmit() {
  * @跳转登录
  */
 function navigateTo() {
-  proxy.$tab.redirectTo("/pages/login");
+  proxy.$tab.redirectTo("/pages/serveConfigSelect");
 }
 
-onLoad((options) => {
-  if (uni.getStorageSync("serveUrl")) {
-    linkUrl.value = uni.getStorageSync("serveUrl").split(":")[0];
-    port.value = uni.getStorageSync("serveUrl").split(":")[1];
-  }
-});
+onLoad((options) => {});
 </script>
 
 <style>

+ 226 - 0
src/pages/serveConfigSelect.vue

@@ -0,0 +1,226 @@
+<template>
+  <view id="serveConfig">
+    <view class="top">
+      <u-icon name="arrow-left" size="17px" color="#000" :bold="true" @click="navigateTo"></u-icon>
+    </view>
+
+    <view class="content">
+      <text class="title">选择服务器地址</text>
+      <u-icon class="icons" name="scan" color="#2a98ff" size="22" @tap="serveClick(1)"></u-icon>
+      <text class="setting" @click="serveClick(2)"> 添加 </text>
+    </view>
+
+    <view class="bottom">
+      <div class="serveList">
+        <u-radio-group v-model="radiovalue" placement="column" @change="handleRadio">
+          <div style="display: flex; background-color: #f5f6fa !important; margin-bottom: 15px; padding: 10px; border-radius: 8px" v-for="(item, index) in radiolist" :key="index">
+            <u-radio :customStyle="{ margin: 'auto 0' }" :value="item.id" :name="item.id"></u-radio>
+
+            <div style="margin: auto 0 auto 0; width: 100%" @click="handleRadio(item.id)">
+              <div style="margin-bottom: 5px; font-weight: 600">{{ item.linkUrl }}</div>
+              <div style="color: #a0a4af; font-size: 12px">备注:{{ item.content }}</div>
+            </div>
+
+            <div v-if="item.id != radiovalue" style="margin: auto 0 auto 0; height: 100%" @click="deleteRadio(index)">
+              <u-icon name="close" color="#a0a4af" size="14"></u-icon>
+            </div>
+          </div>
+        </u-radio-group>
+      </div>
+
+      <u-button v-if="radiolist.length > 0" type="primary" style="width: 100%; height: 45px; font-size: 17px; margin-top: 20px" @click="handleSubmit()" shape="circle"> 保 存</u-button>
+    </view>
+  </view>
+
+  <!--
+    .u-radio__icon-wrap{
+      background-color: transparent;
+    }
+    .u-icon{width: 8px;
+    height: 8px;
+    background-color: rgb(41, 121, 255);
+    border-radius: 100%;}
+    .u-icon__icon{display:none}  -->
+</template>
+
+<script setup>
+import config from "@/config";
+import { onLoad, onShow, onHide, onLaunch } from "@dcloudio/uni-app";
+import { ref, onMounted, inject, shallowRef, reactive, toRefs, getCurrentInstance } from "vue";
+import { getToken, setToken, removeToken } from "@/utils/auth";
+import publicStore from "@/store/modules/public.js";
+const publicStores = publicStore();
+
+const { proxy } = getCurrentInstance();
+
+const dataList = reactive({
+  radiolist: [],
+  radiovalue: "",
+});
+
+const uForm = ref(null);
+const { radiolist, radiovalue } = toRefs(dataList);
+
+/**
+ * @切换单选
+ * @按钮点击事件
+ */
+function handleRadio(id) {
+  radiovalue.value = id;
+  let serveList = uni.getStorageSync("serveList");
+  serveList[0].radiovalue = radiovalue.value;
+  uni.setStorageSync("serveList", serveList);
+}
+
+/**
+ * @删除
+ * @按钮点击事件
+ */
+function deleteRadio(index) {
+  let serveList = uni.getStorageSync("serveList");
+  serveList[0].radiolist.splice(index, 1);
+  uni.setStorageSync("serveList", serveList);
+  proxy.$tab.redirectTo("/pages/serveConfigSelect"); //重载当前页
+}
+
+/**
+ * @扫一扫
+ * @按钮点击事件
+ */
+function serveClick(type) {
+  if (type == 1) {
+    uni.scanCode({
+      success: async (e) => {
+        uni.showToast({
+          title: "扫码成功",
+          icon: "none",
+        });
+
+        publicStores.getServeList(e.result, "");
+
+        init();
+      },
+      fail: (err) => {
+        uni.showToast({
+          title: "扫码失败",
+          icon: "none",
+        });
+        console.log("扫码失败", err);
+      },
+      complete: () => {
+        // uni.showToast({
+        //   title: "扫码结束",
+        //   icon: "none",
+        // });
+        console.log("扫码结束");
+      },
+    });
+  } else if (type == 2) {
+    proxy.$tab.redirectTo("/pages/serveConfig");
+  }
+}
+
+/**
+ * @保存
+ * @按钮点击事件
+ */
+function handleSubmit() {
+  let serveList = uni.getStorageSync("serveList");
+  if (serveList.length > 0) {
+    serveList[0].radiolist.forEach((el) => {
+      if (el.id == serveList[0].radiovalue) {
+        uni.setStorageSync("serveUrl", el.linkUrl);
+        config.baseUrl = "http://" + uni.getStorageSync("serveUrl") + "/prod-api";
+        navigateTo();
+      }
+    });
+  }
+}
+
+/**
+ * @跳转登录
+ */
+function navigateTo() {
+  proxy.$tab.redirectTo("/pages/login");
+}
+
+/**
+ * @初始化
+ */
+function init() {
+  let serveList = uni.getStorageSync("serveList");
+  if (serveList.length > 0) {
+    radiovalue.value = serveList[0].radiovalue;
+    radiolist.value = serveList[0].radiolist;
+  }
+
+  // uni.setStorageSync("serveList", []);
+}
+
+onLoad((options) => {
+  init();
+});
+</script>
+
+<style>
+page {
+  background-color: #ffffff;
+}
+</style>
+
+<style lang="scss" scoped>
+#serveConfig {
+  position: relative;
+  z-index: 1;
+  width: 100%;
+  padding: 0 40px;
+  margin: auto;
+  padding-top: 20%;
+
+  .top {
+  }
+
+  .content {
+    display: flex;
+    margin: 30px 0;
+
+    .title {
+      margin: auto auto auto 0;
+      color: #000;
+      font-size: 18px;
+    }
+
+    .icons {
+      margin: auto 5px auto 0;
+    }
+
+    .setting {
+      color: #2a98ff;
+      margin: auto 0;
+    }
+  }
+
+  .bottom {
+    .serveList {
+      max-height: calc(59px * 6);
+      overflow: auto;
+    }
+    // .u-radio {
+    //   :deep(.u-radio__icon-wrap) {
+    //     background-color: transparent !important;
+    //   }
+
+    //   :deep(.u-icon) {
+    //     width: 8px;
+    //     height: 8px;
+    //     background-color: rgb(41, 121, 255);
+    //     border-radius: 100%;
+    //   }
+
+    //   :deep(.u-icon__icon) {
+    //     display: none;
+    //   }
+    // }
+  }
+}
+</style>

+ 1 - 1
src/permission.js

@@ -4,7 +4,7 @@ import { getToken } from "@/utils/auth";
 const loginPage = "/pages/login";
 
 // 页面白名单
-const whiteList = ["/pages/login", "/pages/serveConfig", "/pages/common/textview/index1", "/pages/common/webview/index", "/pages/business/mhxf/unitInfoCollection/index"];
+const whiteList = ["/pages/login", "/pages/serveConfig", "/pages/serveConfigSelect", "/pages/common/textview/index1", "/pages/common/webview/index", "/pages/business/mhxf/unitInfoCollection/index"];
 
 // 检查地址白名单
 function checkWhite(url) {

+ 40 - 10
src/store/modules/public.js

@@ -25,17 +25,17 @@ const publicStore = defineStore("public", {
     ],
     timeList: [
       new Date().getFullYear() +
-        "-" +
-        (new Date().getMonth() + 1 < 10 ? "0" + (new Date().getMonth() + 1) : "" + (new Date().getMonth() + 1)) +
-        "-" +
-        (new Date().getDate() < 10 ? "0" + new Date().getDate() : new Date().getDate()) +
-        " 00:00:00",
+      "-" +
+      (new Date().getMonth() + 1 < 10 ? "0" + (new Date().getMonth() + 1) : "" + (new Date().getMonth() + 1)) +
+      "-" +
+      (new Date().getDate() < 10 ? "0" + new Date().getDate() : new Date().getDate()) +
+      " 00:00:00",
       new Date().getFullYear() +
-        "-" +
-        (new Date().getMonth() + 1 < 10 ? "0" + (new Date().getMonth() + 1) : "" + (new Date().getMonth() + 1)) +
-        "-" +
-        (new Date().getDate() < 10 ? "0" + new Date().getDate() : new Date().getDate()) +
-        " 23:59:59",
+      "-" +
+      (new Date().getMonth() + 1 < 10 ? "0" + (new Date().getMonth() + 1) : "" + (new Date().getMonth() + 1)) +
+      "-" +
+      (new Date().getDate() < 10 ? "0" + new Date().getDate() : new Date().getDate()) +
+      " 23:59:59",
     ],
 
     mhjz: [
@@ -256,6 +256,36 @@ const publicStore = defineStore("public", {
 
       return arr;
     },
+
+
+    /**
+     * @公共添加服务器列表
+     */
+    getServeList(linkUrl, content) {
+      let serveList = uni.getStorageSync("serveList");
+      if (serveList.length <= 0) {
+        uni.setStorageSync("serveList", [
+          {
+            radiolist: [
+              {
+                id: 1,
+                linkUrl: linkUrl,
+                content: content,
+              },
+            ],
+            radiovalue: 1,
+          },
+        ]);
+      } else {
+        serveList[0].radiolist.push({
+          id: serveList[0].radiolist[serveList[0].radiolist.length - 1].id + 1,
+          linkUrl: linkUrl,
+          content: content,
+        });
+
+        uni.setStorageSync("serveList", serveList);
+      }
+    }
   },
 });