lmc 2 年之前
父节点
当前提交
4c3c0709fa
共有 21 个文件被更改,包括 522 次插入0 次删除
  1. 23 0
      .gitignore
  2. 5 0
      Dockerfile
  3. 17 0
      babel.config.js
  4. 14 0
      build.sh
  5. 4 0
      entrypoint.sh
  6. 52 0
      package.json
  7. 二进制
      public/favicon.ico
  8. 21 0
      public/index.html
  9. 21 0
      src/App.vue
  10. 二进制
      src/assets/back.png
  11. 二进制
      src/assets/jujia.png
  12. 二进制
      src/assets/logo.png
  13. 二进制
      src/assets/success.png
  14. 14 0
      src/main.js
  15. 31 0
      src/router/index.js
  16. 13 0
      src/store/index.js
  17. 6 0
      src/utils/api.js
  18. 80 0
      src/utils/downLoad.js
  19. 95 0
      src/utils/request.js
  20. 114 0
      src/views/login.vue
  21. 12 0
      vue.config.js

+ 23 - 0
.gitignore

@@ -0,0 +1,23 @@
+.DS_Store
+node_modules
+/dist
+
+
+# local env files
+.env.local
+.env.*.local
+
+# Log files
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?

+ 5 - 0
Dockerfile

@@ -0,0 +1,5 @@
+from node:16.0.0
+WORKDIR /user/app
+COPY entrypoint.sh /
+RUN chmod +x /entrypoint.sh
+ENTRYPOINT ["/entrypoint.sh"]

+ 17 - 0
babel.config.js

@@ -0,0 +1,17 @@
+
+module.exports = {
+  "presets": [
+    '@vue/cli-plugin-babel/preset'
+  ],
+  "plugins": [
+    [
+      "import",
+      {
+        "libraryName": "vant",
+        "libraryDirectory": "es",
+        "style": true
+      }
+    ]
+  ]
+}
+

+ 14 - 0
build.sh

@@ -0,0 +1,14 @@
+ 
+ 
+ 
+ 
+# npm install -g npm@8.12.1
+#npm install -g cnpm -registry=https://registry.npm.taobao.org
+## cnpm install @vue/cli-service -g
+# rm -rf node_modules
+# rm -rf package-lock.json
+ 
+#  npm install -g cnpm -registry=https://registry.npm.taobao.org
+#  cnpm install @vue/cli-service -g
+#  cnpm i  
+ cnpm run build

+ 4 - 0
entrypoint.sh

@@ -0,0 +1,4 @@
+#!/bin/bash
+
+bash  build.sh 
+

+ 52 - 0
package.json

@@ -0,0 +1,52 @@
+{
+  "name": "witcarbon-app",
+  "version": "0.1.0",
+  "private": true,
+  "scripts": {
+    "serve": "vue-cli-service serve",
+    "build": "vue-cli-service build",
+    "lint": "vue-cli-service lint"
+  },
+  "dependencies": {
+    "axios": "^1.2.1",
+    "axios-retry": "^3.3.1",
+    "core-js": "^3.8.3",
+    "vant": "^4.0.2",
+    "vconsole": "^3.15.0",
+    "vue": "^3.2.13",
+    "vue-router": "^4.1.6",
+    "vuex": "^4.1.0"
+  },
+  "devDependencies": {
+    "@babel/core": "^7.12.16",
+    "@babel/eslint-parser": "^7.12.16",
+    "@vue/cli-plugin-babel": "~5.0.0",
+    "@vue/cli-plugin-eslint": "~5.0.0",
+    "@vue/cli-service": "~5.0.0",
+    "babel-loader": "^9.1.0",
+    "babel-plugin-import": "^1.13.5",
+    "eslint": "^7.32.0",
+    "eslint-plugin-vue": "^8.0.3",
+    "i": "^0.3.7"
+  },
+  "eslintConfig": {
+    "root": true,
+    "env": {
+      "node": true
+    },
+    "extends": [
+      "plugin:vue/vue3-essential",
+      "eslint:recommended"
+    ],
+    "parserOptions": {
+      "parser": "@babel/eslint-parser"
+    },
+    "rules": {}
+  },
+  "browserslist": [
+    "> 1%",
+    "last 2 versions",
+    "not dead",
+    "not ie 11"
+  ]
+}

二进制
public/favicon.ico


+ 21 - 0
public/index.html

@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<html lang="">
+
+<head>
+  <meta charset="utf-8">
+  <meta http-equiv="X-UA-Compatible" content="IE=edge">
+  <meta name="viewport"
+    content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover" />
+  <link rel="icon" href="<%= BASE_URL %>favicon.ico">
+  <title>双碳感知资产运营管理平台</title>
+</head>
+
+<body style="overflow-x: hidden;">
+  <noscript>
+    <strong>We're sorry but 双碳感知资产运营管理平台 doesn't work properly without JavaScript enabled.
+      Please enable it to continue.</strong>
+  </noscript>
+  <div id="app"></div>
+</body>
+
+</html>

+ 21 - 0
src/App.vue

@@ -0,0 +1,21 @@
+<template>
+  <router-view> </router-view>
+  <!-- 开启顶部安全区适配 -->
+  <van-nav-bar safe-area-inset-top />
+  <!-- 开启底部安全区适配 -->
+  <van-number-keyboard safe-area-inset-bottom />
+</template>
+<script>
+export default {};
+</script>
+<style>
+#app {
+  font-family: ”Microsoft YaHei”, Arial, Helvetica, sans-serif, ”宋体”;
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+  text-align: center;
+  color: #333333;
+  background: #f8f8f8;
+  height: 100vh;
+}
+</style>

二进制
src/assets/back.png


二进制
src/assets/jujia.png


二进制
src/assets/logo.png


二进制
src/assets/success.png


+ 14 - 0
src/main.js

@@ -0,0 +1,14 @@
+
+import { createApp } from 'vue'
+import App from './App.vue'
+import router from './router'
+import store from './store/index'
+import VConsole from 'vconsole';
+import { Toast } from 'vant';
+import { Notify  } from 'vant';
+
+if (process.env.NODE_ENV !== "production") {
+    new VConsole({ theme: 'dark' });
+}
+
+createApp(App).use(store).use(router).use(Toast).use(Notify).mount('#app')

+ 31 - 0
src/router/index.js

@@ -0,0 +1,31 @@
+
+import { createRouter, createWebHashHistory } from 'vue-router'
+
+const routes = [
+  {
+    path: '/',
+    redirect:'login'
+  },
+  {
+    path: 'login',
+    name: '登录',
+    component: () => import(/* webpackChunkName: "about" */ '../views/login.vue')
+  },
+  // {
+  //   path: '/alllist',
+  //   name: '全部人员列表',
+  //   component: () => import(/* webpackChunkName: "about" */ '../views/alllist.vue')
+  // },
+]
+
+const router = createRouter({
+  history: createWebHashHistory(), 
+  routes
+})
+// 全局前置守卫,设置页面标题
+router.beforeEach((to, from, next) => {
+  document.title = to.matched[0] == null ? '双碳感知资产运营管理平台' : to.matched[0].name;
+  next(); //必须写
+});
+
+export default router

+ 13 - 0
src/store/index.js

@@ -0,0 +1,13 @@
+
+import { createStore } from 'vuex'
+
+export default createStore({
+  state: {
+  },
+  mutations: {
+  },
+  actions: {
+  },
+  modules: {
+  }
+})

+ 6 - 0
src/utils/api.js

@@ -0,0 +1,6 @@
+
+import { service } from './request'
+export default {
+    // loginByPwd: (params) => service.post("/app/login", params),
+    // getUserInfo: (params) => service.get("/app/login", params)
+}

+ 80 - 0
src/utils/downLoad.js

@@ -0,0 +1,80 @@
+import axios from "axios";
+import { Notify } from "vant";
+
+// 获取环境变量
+const getBaseURI = () => {
+  let env = process.env.VUE_APP_NODE_ENV || process.env.NODE_ENV;
+
+  //    开发环境
+  if (env === "dev" || env == "development") {
+    //    return 'http://112.30.213.162:8082/stayhome-app'
+    //return 'http://192.168.1.101:9013/stayhome-app';
+    // return 'https://s-stg.ringzle.com/stayhome-app'
+    //    return 'http://192.168.1.102:9013/stayhome-app';
+    return "https://s.ringzle.com/stayhome-app";
+  }
+
+  // 集成测试环境
+  if (env === "prod:sit") {
+    return "https://s.ringzle.com/stayhome-app";
+  }
+
+  if (env === "prod:uat") {
+    return "https://s.ringzle.com/stayhome-app";
+  }
+  // 生产环境
+  if (env === "prod" || env === "production") {
+    return "/stayhome-app";
+  }
+};
+
+// 默认超时时间
+axios.defaults.timeout = 10000;
+axios.defaults.timeoutErrorMessage = "请求超时,请检查网络后重试";
+// 请求接口根目录
+axios.defaults.baseURL = getBaseURI();
+
+// http request 拦截器
+axios.interceptors.request.use(
+  (config) => {
+    // 配置头部
+    let token = window.localStorage.getItem("token");
+    if (token != "") {
+      config.headers["token"] = token;
+    }
+
+    return config;
+  },
+  (err) => {
+    Notify({ type: "danger", message: JSON.stringify(err) });
+    return Promise.reject(err);
+  }
+);
+
+// http response 拦截器
+axios.interceptors.response.use(
+  (response) => {
+    return response;
+  },
+  (err) => {
+    Notify({ type: "danger", message: JSON.stringify(err) });
+    return Promise.reject(err);
+  }
+);
+
+export function fetch(options) {
+  return new Promise((resolve, reject) => {
+    axios
+      .get(options.url, {
+        params: options.data,
+        timeout: options.timeout,
+        responseType: options.responseType || "json",
+      })
+      .then((response) => {
+        resolve(options.responseType ? response : response.data.data);
+      })
+      .catch((err) => {
+        reject(err);
+      });
+  });
+}

+ 95 - 0
src/utils/request.js

@@ -0,0 +1,95 @@
+
+import axios from "axios";
+import { Notify } from "vant";
+import axiosRetry from "axios-retry";
+
+// 获取环境变量
+export const getBaseURI = () => {
+  let env = process.env.VUE_APP_NODE_ENV || process.env.NODE_ENV;
+
+  //    开发环境
+  if (env === "dev" || env == "development") {
+    //    return 'http://112.30.213.162:8082/stayhome-app'
+    //return 'http://192.168.1.101:9013/stayhome-app';
+    // return 'https://s-stg.ringzle.com/stayhome-app'
+    //    return 'http://192.168.1.102:9013/stayhome-app';
+    return "https://s.ringzle.com/stayhome-app";
+  }
+
+  // 集成测试环境
+  if (env === "prod:sit") {
+    return "https://s.ringzle.com/stayhome-app";
+  }
+
+  if (env === "prod:uat") {
+    return "https://s.ringzle.com/stayhome-app";
+  }
+  // 生产环境
+  if (env === "prod" || env === "production") {
+    return "/stayhome-app";
+  }
+};
+
+export const BaseUrl = getBaseURI();
+
+export const service = axios.create({
+  timeout: 10000,
+  timeoutErrorMessage: "请求超时,请检查网络后重试",
+  baseURL: getBaseURI(),
+});
+
+/**
+ * req 拦截器
+ */
+service.interceptors.request.use(
+  (config) => {
+    // 配置头部
+    let token = window.localStorage.getItem("token");
+    if (token != "") {
+      config.headers["token"] = token;
+    }
+    return config;
+  },
+  (error) => {
+    Notify({ type: "danger", message: JSON.stringify(error) });
+    return Promise.resolve(error);
+  }
+);
+
+/**
+ * res 拦截器
+ */
+service.interceptors.response.use((response) => {
+  const res = response.data;
+  // 判断token 失效
+  if (res.code == 10021) {
+    Notify({ type: "danger", message: res.msg });
+  }
+  if (res.code == 500) {
+    Notify({ type: "danger", message: res.msg });
+  }
+  if (res.error) {
+    if (process.env.NODE_ENV !== "production") {
+      console.error(res);
+    }
+    Notify({ type: "danger", message: JSON.stringify(res) });
+    return Promise.resolve(res);
+  }
+  return Promise.resolve(res);
+});
+
+axiosRetry(service, {
+  retries: 3, // 设置自动发送请求次数
+  retryDelay: () => 300, // 重新请求的间隔
+  shouldResetTimeout: true, //  重置超时时间
+  retryCondition: (error) => {
+    // true为打开自动发送请求,false为关闭自动发送请求
+    if (error.message.includes("timeout")) return true;
+    // 如果你要在请求出错的时候重新发送请求(返回400以上的状态码时) 你应该像下面这样写
+    if (
+      error.message.includes("timeout") ||
+      error.message.includes("status code")
+    )
+      return true;
+  },
+});

+ 114 - 0
src/views/login.vue

@@ -0,0 +1,114 @@
+
+<template>
+  <van-form>
+    <div style="background-color: #fff">
+      <van-image
+        width="48"
+        height="48"
+        style="margin-top: 20%"
+        :src="require('@/assets/jujia.png')"
+      />
+      <div
+        style="
+          font-size: 18px;
+          text-align: center;
+          color: #5776e6;
+          margin-top: 20px;
+          font-weight: 600;
+        "
+      >
+        双碳感知资产运营管理平台
+      </div>
+      <van-field
+        v-model="tel"
+        type="tel"
+        name="手机号"
+        label="手机号"
+        style="margin: 50px 0 50px 20px"
+        placeholder="请输入手机号"
+        :rules="[{ required: true, message: '请输入手机号' }]"
+      />
+      <van-field
+        v-model="password"
+        type="password"
+        name="密码"
+        label="密码"
+        style="margin: 50px 0 50px 20px"
+        placeholder="请输入密码"
+        :rules="[{ required: true, message: '请输入密码' }]"
+      />
+
+      <div style="margin: 16px">
+        <van-button
+          round
+          block
+          type="primary"
+          :disabled="disBtn"
+          @click="submitForm"
+        >
+          进入体验
+        </van-button>
+      </div>
+    </div>
+  </van-form>
+</template>
+
+<script>
+import { ref } from "@vue/reactivity";
+import Api from "./utils/api";
+export default {
+  setup() {
+    const tel = ref("");
+    const password = ref("");
+    return { tel, password };
+  },
+  mounted() {
+    window.localStorage.setItem("token", "");
+    window.localStorage.setItem("role", "");
+  },
+  methods: {
+    submitForm() {
+      this.$toast({
+        message: "登录中...",
+        forbidClick: true,
+      });
+      Api.loginByPwd({
+        username: this.tel,
+        password: this.password,
+        captcha: "1",
+        uuid:'1'
+      }).then((res) => {
+        if (res.code == 0) {
+          this.$toast.clear();
+          window.localStorage.setItem("token", res.data.token);
+          this.getUserInfo();
+        } else {
+          this.$notify({ type: "danger", message: res.msg });
+        }
+      });
+    },
+    //获取用户信息role分类
+    getUserInfo() {
+      Api.getUserInfo().then((res) => {
+        if (res.code == 0) {
+          console.log(res.data);
+        } else {
+          this.$notify({ type: "danger", message: res.msg });
+        }
+      });
+    },
+  },
+};
+</script>
+
+<style>
+#app {
+  font-family: ”Microsoft YaHei”, Arial, Helvetica, sans-serif, ”宋体”;
+  -webkit-font-smoothing: antialiased;
+  -moz-osx-font-smoothing: grayscale;
+  text-align: center;
+  color: #333333;
+  background: #f8f8f8;
+  height: 100vh;
+}
+</style>

+ 12 - 0
vue.config.js

@@ -0,0 +1,12 @@
+module.exports = {
+  //配置路径别名
+  devServer: {
+    port: 3000,
+    open: true,
+    hot: true,//自动保存
+  },
+  lintOnSave: false,
+  productionSourceMap: false,
+  publicPath: "./",
+  transpileDependencies: [],
+}