db 2 anni fa
commit
749c5e2797

+ 7 - 0
.env.development

@@ -0,0 +1,7 @@
+VITE_APP_BASE_URL="/cygx"
+
+VITE_APP_OUTDIR="dist"
+
+VITE_APP_WX_APPID ="wxb7cb8a15abad5b8e"
+
+VITE_APP_CYGX_BASEAPIURL="http://rddpweb.brilliantstart.cn/api"

+ 7 - 0
.env.product

@@ -0,0 +1,7 @@
+VITE_APP_BASE_URL="/cygx"
+
+VITE_APP_OUTDIR="cygxzs"
+
+VITE_APP_WX_APPID ="wxb7cb8a15abad5b8e"
+
+VITE_APP_CYGX_BASEAPIURL="https://cygx.hzinsights.com/api"

+ 7 - 0
.env.test

@@ -0,0 +1,7 @@
+VITE_APP_BASE_URL="/cygx"
+
+VITE_APP_OUTDIR="cygx_xzs"
+
+VITE_APP_WX_APPID ="wxb7cb8a15abad5b8e"
+
+VITE_APP_CYGX_BASEAPIURL="http://rddpweb.brilliantstart.cn/api"

+ 6 - 0
.gitignore

@@ -0,0 +1,6 @@
+node_modules
+.DS_Store
+dist
+dist-ssr
+*.local
+package-lock.json

+ 1 - 0
README.md

@@ -0,0 +1 @@
+# Vue 3 + Vite + vant 模板

+ 14 - 0
index.html

@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <meta charset="UTF-8" />
+    <link rel="icon" href="/favicon.ico" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, viewport-fit=cover"/>
+    <title>Vite App</title>
+    <script type="text/javascript" src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
+  </head>
+  <body>
+    <div id="app"></div>
+    <script type="module" src="/src/main.js"></script>
+  </body>
+</html>

+ 27 - 0
package.json

@@ -0,0 +1,27 @@
+{
+  "name": "hangmin",
+  "version": "0.0.0",
+  "scripts": {
+    "dev": "vite",
+    "build": "vite build --mode product",
+    "build.test": "vite build --mode test",
+    "serve": "vite preview --port 3001"
+  },
+  "dependencies": {
+    "axios": "^0.24.0",
+    "element-plus": "^2.2.9",
+    "normalize.css": "^8.0.1",
+    "vant": "^3.5.2",
+    "vue": "^3.2.16",
+    "vue-router": "^4.0.12"
+  },
+  "devDependencies": {
+    "@vitejs/plugin-vue": "^1.9.3",
+    "postcss-px-to-viewport": "^1.1.1",
+    "sass": "^1.44.0",
+    "unplugin-auto-import": "^0.9.3",
+    "unplugin-vue-components": "^0.21.1",
+    "vite": "^2.6.4",
+    "vite-plugin-style-import": "^1.4.0"
+  }
+}

+ 22 - 0
postcss.config.js

@@ -0,0 +1,22 @@
+module.exports = {
+    plugins: {
+      "postcss-px-to-viewport": {
+        unitToConvert: "px", // 需要转换的单位,默认为"px"
+        viewportWidth: 750, //  设计稿的视口宽度
+        unitPrecision: 5, // 单位转换后保留的精度
+        propList: ["*"], // 能转化为vw的属性列表
+        viewportUnit: "vw", //  希望使用的视口单位
+        // fontViewportUnit: "vw", // 字体使用的视口单位
+        selectorBlackList: [], // 需要忽略的CSS选择器
+        minPixelValue: 1, // 最小的转换数值,如果为1的话,只有大于1的值会被转换
+        mediaQuery: false, // 媒体查询里的单位是否需要转换单位
+        replace: true, // 是否直接更换属性值,而不添加备用属性
+        exclude: /node_modules/, // 忽略某些文件夹下的文件或特定文件
+        include: undefined, // 如果设置了include,那将只有匹配到的文件才会被转换,例如只转换 'src/mobile' 下的文件 (include: /\/src\/mobile\//)
+        landscape: false, // 是否添加根据 landscapeWidth 生成的媒体查询条件 @media (orientation: landscape)
+        landscapeUnit: "vw", // 横屏时使用的单位
+        landscapeWidth: 568, // 横屏时使用的视口宽度
+      },
+    },
+  };
+  

BIN
public/favicon.ico


+ 26 - 0
src/App.vue

@@ -0,0 +1,26 @@
+<template>
+  <router-view></router-view>
+</template>
+
+<script>
+// import { onMounted } from "vue";
+// import { wxLogin } from "@/util/wxLogin";
+
+// onMounted(() => {
+//   wxLogin();
+// });
+</script>
+
+<style>
+body {
+  font-family: PingFang SC-Regular, PingFang SC;
+}
+div {
+  box-sizing: border-box;
+}
+p {
+  padding: 0;
+  margin: 0;
+  font-weight: 400;
+}
+</style>

+ 12 - 0
src/api/api.js

@@ -0,0 +1,12 @@
+import { get, post } from "./http";
+
+export const apiWxLogin = (params) => {
+  return get("/wechat/loginByxzs", params);
+};
+
+export const getWxSign = (params) => {
+  return get("/wechat/getWxSign", params);
+};
+export const getUser = (params) => {
+  return get("/wechat/user/detail", params);
+};

+ 40 - 0
src/api/http.js

@@ -0,0 +1,40 @@
+"use strict";
+import axios from "axios";
+
+let config = {
+  baseURL: import.meta.env.VITE_APP_CYGX_BASEAPIURL,
+  // baseURL: 'http://192.168.20.34:8103/api',
+  timeout: 60 * 1000, // Timeout
+};
+const _axios = axios.create(config);
+
+_axios.interceptors.request.use(
+  function (config) {
+    let auth = localStorage.getItem("Authorization") || "";
+    if (auth) {
+      config.headers.Authorization = auth;
+    }
+    config.headers.Authorization= 'b0e0cb73b728d57c3895ec3817af1429'
+    return config;
+  },
+  function (error) {
+    return Promise.reject(error);
+  }
+);
+
+_axios.interceptors.response.use(
+  function (response) {
+    return response.data;
+  },
+  function (error) {
+    return Promise.reject(error);
+  }
+);
+
+export const get = (url, params) => {
+  return _axios.get(url, { params });
+};
+
+export const post = (url, params) => {
+  return _axios.post(url, params);
+};

BIN
src/assets/img/bg_icon.png


BIN
src/assets/img/card_bg.png


BIN
src/assets/img/init_imgurl.png


BIN
src/assets/logo.png


+ 7 - 0
src/main.js

@@ -0,0 +1,7 @@
+import { createApp } from 'vue'
+import App from './App.vue'
+import router from './router'
+
+import 'normalize.css'
+
+createApp(App).use(router).mount('#app')

+ 17 - 0
src/router/index.js

@@ -0,0 +1,17 @@
+import { createRouter, createWebHistory } from "vue-router";
+
+const routes = [
+  {
+    path: "/",
+    redirect: "/index",
+  },
+  { path: "/index", component: () => import("@/views/index.vue") },
+  { path: "/revamp", component: () => import("@/views/changeTag.vue") },
+];
+
+const router = createRouter({
+  history: createWebHistory(import.meta.env.VITE_APP_BASE_URL),
+  routes,
+});
+
+export default router;

+ 12 - 0
src/util/commom.js

@@ -0,0 +1,12 @@
+/**
+ * 公共方法
+ */
+
+import md5 from "js-md5";
+
+/**
+ * 密码加密
+ */
+export const md5Signature = (val) => {
+  return md5(val);
+};

+ 43 - 0
src/util/wxLogin.js

@@ -0,0 +1,43 @@
+/**
+ * 微信授权登录(静默)
+ */
+
+import { apiWxLogin } from "@/api/api";
+import { Toast } from "vant";
+import "vant/es/toast/style";
+
+export const wxLogin = async () => {
+  // 判断是否在微信浏览器
+  const userAgent = navigator.userAgent.toLowerCase();
+  if (userAgent.match(/MicroMessenger/i) != "micromessenger") {
+    Toast("请在微信内打开");
+    return false;
+  }
+
+  //判断是否存在token
+  let Authorization = localStorage.getItem("Authorization");
+  if (Authorization) return;
+
+  //判断当前路由是否是有code
+  const url = location.search; //获取url携带的参数
+  let urlParams = new Object();
+  if (url.indexOf("?") != -1) {
+    let str = url.substr(1);
+    let strs = str.split("&");
+    for (let i = 0; i < strs.length; i++) {
+      urlParams[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
+    }
+  }
+
+  if (urlParams.code) {
+    let res = await apiWxLogin({ Code: urlParams.code });
+    if (res.data.Ret === 200) {
+      localStorage.setItem("Authorization", res.data.Data.Token);
+      window.location.href = `${window.location.origin}${process.env.VITE_APP_BASE_URL}/cygx/index`;
+    }
+  } else {
+    const redirectUri = encodeURIComponent(`${window.location.origin}${process.env.VITE_APP_BASE_URL}/cygx/index`);
+    const appid = process.env.VITE_APP_WX_APPID;
+    window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_base&state=123#wechat_redirect`;
+  }
+};

+ 12 - 0
src/views/changeTag.vue

@@ -0,0 +1,12 @@
+<script setup>
+import { reactive, toRefs, onMounted, ref, unref } from "vue";
+onMounted(() => {
+  document.title = "推送规则";
+});
+</script>
+
+<template>
+  <div class="container">123</div>
+</template>
+
+<style lang="" scoped></style>

+ 232 - 0
src/views/index.vue

@@ -0,0 +1,232 @@
+<script setup>
+import { reactive, toRefs, onMounted, ref, unref } from "vue";
+import { Button, Toast } from "vant";
+import "vant/es/toast/style";
+import { getWxSign, getUser } from "@/api/api.js";
+import { useRouter, useRoute } from "vue-router";
+const router = useRouter();
+
+/**
+ * 获取用户详情
+ */
+const userInfo = ref({});
+const permissionList = ref([]);
+const getUse = async () => {
+  // if (localStorage.getItem("Authorization")) {
+  let res = await getUser({
+    Token: "b0e0cb73b728d57c3895ec3817af1429",
+  });
+  console.log(res);
+  if (res.Ret === 200) {
+    userInfo.value = res.Data;
+    permissionList.value = userInfo.value.Permission.split(",") || [];
+  }
+  // }
+};
+
+/**
+ * 微信js_sdk
+ */
+const wxconfig = async () => {
+  const res = await getWxSign({ Url: window.location.href });
+  if (res.Ret === 200) {
+    wx.config({
+      debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+      appId: res.Data.AppId, // 必填,公众号的唯一标识
+      timestamp: res.Data.Timestamp, // 必填,生成签名的时间戳
+      nonceStr: res.Data.NonceStr, // 必填,生成签名的随机串
+      signature: res.Data.Signature, // 必填,签名
+      jsApiList: ["hideAllNonBaseMenuItem", "onMenuShareTimeline"],
+      openTagList: ["wx-open-launch-weapp"], // 可选,需要使用的开放标签列表,例如['wx-open-launch-app']
+    });
+    wx.ready(function () {
+      wx.hideAllNonBaseMenuItem();
+    });
+  }
+};
+/**
+ * 点击跳转推送规则
+ */
+const goChangeTag = () => {
+  router.push("/revamp");
+};
+/**
+ * 点击跳转小程序
+ */
+const handleLaunchFn = () => {
+  console.log("sss");
+  // alert('11')
+};
+
+const handleErrorFn = () => {
+  // alert('ff')
+  console.log("eee");
+};
+
+getUse();
+// wxconfig();
+onMounted(() => {
+  document.title = "登录";
+  var btn = document.getElementById("launch-btn");
+  btn.addEventListener("launch", function (e) {
+    console.log("success");
+  });
+  btn.addEventListener("error", function (e) {
+    console.log("fail", e.detail);
+  });
+  btn.addEventListener("ready", function (e) {
+    console.log("ready	");
+  });
+});
+</script>
+
+<template>
+  <div class="container-index">
+    <div class="content">
+      <p class="is-info" v-if="userInfo.HasPermission && userInfo.HasPermission != 3">您已登录成功!</p>
+      <p class="is-info" v-else>暂无您的客户信息</p>
+      <div class="synopsis">
+        <p v-if="userInfo.HasPermission && userInfo.HasPermission != 3">我们将为您推送近期所有的研究更新与活动提醒</p>
+      </div>
+      <div class="personal-details">
+        <div class="head-portrait">
+          <img :src="userInfo.Headimgurl" v-if="userInfo.Headimgurl" />
+          <img src="@/assets/img/init_imgurl.png" v-else />
+        </div>
+        <div class="details-item">
+          <template v-if="userInfo.HasPermission == 1 || userInfo.HasPermission == 2">
+            <p class="name">{{ userInfo.RealName }}</p>
+            <p class="phone">{{ userInfo.Mobile }}</p>
+            <p class="company">{{ userInfo.CompanyName }}</p>
+          </template>
+        </div>
+      </div>
+      <div class="authority">
+        <template v-if="userInfo.HasPermission == 1">
+          <div class="item" v-for="item in permissionList" :key="item">{{ item }}</div>
+        </template>
+        <template v-else-if="userInfo.HasPermission == 2">
+          <div class="item">暂无权限</div>
+        </template>
+      </div>
+      <div class="bottom-box">
+        <p class="inform" v-if="userInfo.HasPermission == 1">您亦可在【推送规则】中更改您关注的赛道,让小助手更好地理解您的需求,为您降噪哦~</p>
+        <p class="inform" v-else-if="userInfo.HasPermission == 2">当前无行业权限,可前往【查研观向】小程序申请开通试用权限</p>
+        <p class="inform" v-else-if="userInfo.HasPermission == 3">请先前往【查研观向】小程序绑定您的联系方式并申请开通试用权限</p>
+        <div class="bottom-btn" v-if="userInfo.HasPermission == 2" @click="goChangeTag">去更改</div>
+        <div class="bottom-btn" v-else>
+          去小程序
+          <wx-open-launch-weapp id="launch-btn" class="wx-app" username="gh_a9d3744e1072" path="pages/index/index.html">
+            <div v-is="'script'" type="text/wxtag-template">
+              <div class="btn">去小程序</div>
+            </div>
+          </wx-open-launch-weapp>
+        </div>
+      </div>
+    </div>
+  </div>
+</template>
+
+<style lang="scss" scoped>
+.container-index {
+  width: 100%;
+  height: 100vh;
+  background: url("@/assets/img/bg_icon.png") no-repeat;
+  background-size: 100% 100%;
+  padding: 25% 15px 0;
+  .content {
+    width: 100%;
+    height: 842px;
+    padding: 60px 35px 0;
+    background: url("@/assets/img/card_bg.png") no-repeat;
+    background-size: 100% 100%;
+    color: #fff;
+    .is-info {
+      font-size: 61px;
+      font-weight: 500;
+    }
+    .synopsis {
+      font-size: 28px;
+      padding: 10px 0;
+      height: 80px;
+    }
+    .personal-details {
+      display: flex;
+      .head-portrait {
+        width: 126px;
+        height: 126px;
+        border-radius: 50%;
+        overflow: hidden;
+        img {
+          width: 100%;
+          height: 100%;
+        }
+      }
+      .details-item {
+        margin-left: 30px;
+        font-size: 28px;
+        .name {
+          font-size: 34px;
+          font-weight: 500;
+        }
+        .phone {
+          padding: 10px 0 5px;
+        }
+      }
+    }
+    .authority {
+      height: 238px;
+      width: 105%;
+      overflow: hidden;
+      padding-top: 10px;
+      .item {
+        width: 148px;
+        height: 34px;
+        font-size: 24px;
+        border-radius: 4px;
+        display: inline-block;
+        margin: 20px 20px 0 0;
+        text-align: center;
+        line-height: 32px;
+        border: 1px solid #e5cfb1;
+        font-weight: 400;
+        color: #e5cfb1;
+      }
+    }
+    .bottom-box {
+      font-size: 28px;
+      color: #fff;
+      text-align: center;
+      .inform {
+        margin-bottom: 50px;
+      }
+      .bottom-btn {
+        width: 337px;
+        height: 62px;
+        background: linear-gradient(180deg, #e5cfb1 0%, #caaf8b 100%);
+        border-radius: 78px;
+        margin: 0 auto;
+        line-height: 62px;
+        font-size: 32px;
+        font-weight: 500;
+        color: #3e3d3c;
+        position: relative; // 相对定位
+        z-index: 0;
+      }
+      .wx-app {
+        position: absolute; // 绝对定位
+        top: 0;
+        left: 0;
+        width: 100%;
+        height: 100%;
+        z-index: 100;
+        opacity: 0;
+        .btn {
+          width: 100%;
+          height: 100%;
+        }
+      }
+    }
+  }
+}
+</style>

+ 41 - 0
vite.config.js

@@ -0,0 +1,41 @@
+import { defineConfig, loadEnv } from "vite";
+import vue from "@vitejs/plugin-vue";
+import path from "path";
+import Components from "unplugin-vue-components/vite";
+import AutoImport from "unplugin-auto-import/vite";
+import { VantResolver } from "unplugin-vue-components/resolvers";
+import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
+export default ({ mode }) =>
+  defineConfig({
+    base: loadEnv(mode, process.cwd()).VITE_APP_BASE_URL,
+    plugins: [
+      vue(),
+      AutoImport({
+        resolvers: [ElementPlusResolver()],
+      }),
+      Components({
+        resolvers: [VantResolver(), ElementPlusResolver()],
+      }),
+    ],
+    resolve: {
+      alias: {
+        "@": path.resolve(__dirname, "./src"),
+      },
+    },
+    server: {
+      port: 8888,
+      cors: true,
+      host: "0.0.0.0",
+      proxy: {
+        "/api": {
+          target: loadEnv(mode, process.cwd()).VITE_APP_CYGX_BASEAPIURL,
+          //target: 'https://cygxpctest.hzinsights.com',
+          changeOrigin: true,
+          rewrite: (path) => path.replace(/^\/api/, "/api"),
+        },
+      },
+    },
+    build: {
+      outDir: loadEnv(mode, process.cwd()).VITE_APP_OUTDIR,
+    },
+  });