22285461@qq.com 5 maanden geleden
bovenliggende
commit
9361e6c44f
10 gewijzigde bestanden met toevoegingen van 197 en 86 verwijderingen
  1. 1 1
      dist/assets/index-C7jCC9F0.js
  2. 2 2
      dist/index.html
  3. 1 1
      index.html
  4. 2 0
      src/DataCenter.ts
  5. 31 0
      src/LocalModels.ts
  6. 61 0
      src/Network.ts
  7. 12 0
      src/Tools.ts
  8. 73 2
      src/components/ApplyUserInfo.vue
  9. 8 80
      src/components/Test.vue
  10. 6 0
      src/router.ts

File diff suppressed because it is too large
+ 1 - 1
dist/assets/index-C7jCC9F0.js


+ 2 - 2
dist/index.html

@@ -3,9 +3,9 @@
 <head>
     <meta charset="UTF-8"/>
     <link rel="icon" type="image/svg+xml" href="/vite.svg"/>
-    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
     <title>桢禧文化</title>
-  <script type="module" crossorigin src="/assets/index-CcMA6quk.js"></script>
+  <script type="module" crossorigin src="/assets/index-C7jCC9F0.js"></script>
   <link rel="stylesheet" crossorigin href="/assets/index-FrvreMPU.css">
 </head>
 <body>

+ 1 - 1
index.html

@@ -3,7 +3,7 @@
 <head>
     <meta charset="UTF-8"/>
     <link rel="icon" type="image/svg+xml" href="/vite.svg"/>
-    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
+    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
     <title>桢禧文化</title>
 </head>
 <body>

+ 2 - 0
src/DataCenter.ts

@@ -2,6 +2,8 @@ import {LocalModels} from "./LocalModels.ts";
 
 export namespace DataCenter {
 
+    export let wxOpenId = null
+
     export let shengShi: Map<string, string[]> = new Map()
 
     export let shiQu: Map<string, string[]> = new Map()

+ 31 - 0
src/LocalModels.ts

@@ -1,4 +1,12 @@
 export namespace LocalModels {
+    function beanToObject(bean: object) {
+        let result = {}
+        Object.keys(bean).forEach(function (key) {
+            result[key] = bean[key]
+        })
+        return result
+    }
+
     export class Area {
         sheng: string
         shi: string
@@ -11,4 +19,27 @@ export namespace LocalModels {
         shiPinYin: string
         quPinYin: string
     }
+
+    export class BaseRequest {
+
+        toData() {
+            return beanToObject(this)
+        }
+    }
+
+    export class UserRequest extends BaseRequest {
+        user_name: string = ""
+        is_man: boolean = false
+        date_mode: number = 0
+        born_year: number = 0
+        born_month: number = 0
+        born_day: number = 0
+        know_time: number = 0
+        born_hour: number = 0
+        born_minute: number = 0
+        born_sheng: string = ""
+        born_shi: string = ""
+        born_qu: string = ""
+        open_id: string = ""
+    }
 }

+ 61 - 0
src/Network.ts

@@ -0,0 +1,61 @@
+import {LocalModels} from "./LocalModels.ts";
+import {Tools} from "./Tools.ts";
+
+export namespace Network {
+
+    let sendingTime: Map<string, number> = new Map()
+
+    let debugMode = true
+
+    export function applyUserInfo(request: LocalModels.UserRequest, cb: () => void) {
+        post(getServerUrl() + "applyUserInfo", request.toData(), function (rsp: string) {
+            console.log(rsp)
+            cb && cb()
+        })
+    }
+
+    function getServerUrl() {
+        if (!debugMode) {
+            return "https://yixuefrp.cxhy.cn/wx/"
+        } else {
+            return "http://127.0.0.1:13008/wx/"
+        }
+    }
+
+    export function post(url: string, data: object, cb: (response: string) => void) {
+        let tm = Date.now()
+        let allow: boolean = false
+        if (!sendingTime.has(url)) {
+            sendingTime.set(url, tm)
+            allow = true
+        } else {
+            let last = sendingTime.get(url)
+
+            if (tm - last > 1000) {
+                sendingTime.set(url, tm)
+                allow = true
+            }
+        }
+        if (!allow) {
+            cb && cb(null)
+            Tools.showMessage("操作太快了,请慢一点")
+            return
+        }
+
+        let requst = new XMLHttpRequest()
+        requst.open("POST", url, true)
+        requst.setRequestHeader('Content-Type', 'application/json');
+        //requst.setRequestHeader('Access-Control-Allow-Origin', '*');
+        let dt = JSON.stringify(data)
+        requst.onreadystatechange = function () {
+            if (requst.readyState == XMLHttpRequest.DONE) {
+                if (requst.status == 200) {
+                    cb && cb(requst.responseText)
+                } else {
+                    console.error(requst.statusText)
+                }
+            }
+        }
+        requst.send(dt)
+    }
+}

+ 12 - 0
src/Tools.ts

@@ -0,0 +1,12 @@
+import {ElMessage} from "element-plus";
+import {h} from "vue";
+
+export namespace Tools {
+    export function showMessage(msg: string) {
+        ElMessage({
+            message: h('p', null, [
+                h('i', {style: 'color: black'}, msg),
+            ]),
+        })
+    }
+}

+ 73 - 2
src/components/ApplyUserInfo.vue

@@ -1,6 +1,9 @@
 <script setup lang="ts">
-import {computed, ref} from "vue";
+import {computed, onMounted, ref} from "vue";
 import {DataCenter} from "../DataCenter.ts";
+import {Tools} from "../Tools.ts";
+import {LocalModels} from "../LocalModels.ts";
+import {Network} from "../Network.ts";
 
 let dateModeTexts = ["新历", "农历"]
 let knowTimeTexts = ["知道时辰", "不知道时辰"]
@@ -17,6 +20,9 @@ let chengshi = ref("-")
 let diqu = ref("-")
 let chengshiOptions = ref([])
 let diquOptions = ref([])
+let userName = ref("")
+let isMan = ref(true)
+let userNameCompt = ref()
 
 function range(min: number, max: number) {
   let result = []
@@ -57,12 +63,77 @@ let getShengFens = computed(function () {
 })
 
 function applyInfo() {
-  console.log(document.URL)
+  let query = window.location.search
+  let params = new URLSearchParams(query)
+  let openId = params.get("user")?.trim()
+  if (openId.length == 0) {
+    Tools.showMessage("获取用户信息失败,请退出页面重试")
+    return
+  }
+  let uName = userName.value.trim()
+  if (uName.length == 0) {
+    Tools.showMessage("请填写用户姓名")
+    userNameCompt.value?.focus()
+    return
+  }
+
+  let request = new LocalModels.UserRequest()
+  request.open_id = openId
+  request.user_name = uName
+  request.is_man = isMan.value
+  request.born_year = curYear.value
+  request.born_month = curMonth.value
+  request.born_day = curDay.value
+  request.know_time = knowTimeValue.value
+  request.born_hour = curHour.value
+  request.born_minute = curMin.value
+  request.born_sheng = shengfen.value
+  request.born_shi = chengshi.value
+  request.born_qu = diqu.value
+  Network.applyUserInfo(request, function () {
+    console.log("over")
+  })
+  //todo
 }
 
+function checkWxOpenId() {
+  if (DataCenter.wxOpenId == null) {
+    let url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wxf01ec97b45a4bc49&redirect_uri=https://yixuefrp.cxhy.cn/test&response_type=code&scope=snsapi_base&state=999#wechat_redirect"
+    window.location.href = url
+  }
+}
+
+onMounted(function () {
+  checkWxOpenId()
+})
+
 </script>
 
 <template>
+  <!--姓名、性别-->
+  <el-row style="width: 100%">
+    <el-row align="middle" style="margin-top: 10px;">
+      <el-col :span="4">姓名</el-col>
+      <el-col :span="18">
+        <el-input ref="userNameCompt" v-model="userName"></el-input>
+      </el-col>
+    </el-row>
+    <el-row align="middle" style="margin-top: 10px;">
+      <el-col :span="4"></el-col>
+      <el-col :span="18" align="left">
+        <el-switch
+            v-model="isMan"
+            class="ml-2"
+            inline-prompt
+            size="large"
+            style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949; margin-right: 20px"
+            active-text="男"
+            inactive-text="女"
+        />
+      </el-col>
+    </el-row>
+  </el-row>
+
   <el-row align="middle" style="margin-top: 10px">
     <el-col :span="4"></el-col>
     <el-col :span="18">

+ 8 - 80
src/components/Test.vue

@@ -1,88 +1,16 @@
 <script setup lang="ts">
 
+import {onMounted, ref} from "vue";
+
+let curUrl = ref("")
+
+onMounted(function () {
+  curUrl.value = document.URL
+})
 </script>
 
 <template>
-  <!DOCTYPE html>
-  <html lang="en">
-  <head>
-    <meta charset="UTF-8">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <title>Date Selector Page</title>
-    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@1/css/pico.min.css">
-  </head>
-  <body>
-  <nav class="container-fluid">
-    <ul>
-      <li><strong>Date Selector</strong></li>
-    </ul>
-    <ul>
-      <li><a href="#">Home</a></li>
-      <li><a href="#">About</a></li>
-      <li><a href="#" role="button">Contact</a></li>
-    </ul>
-  </nav>
-  <main class="container">
-    <div class="grid">
-      <section>
-        <hgroup>
-          <h2>Select Your Date</h2>
-          <h3>Choose Year, Month, and Day</h3>
-        </hgroup>
-        <p>Use the dropdown menus below to select the year, month, and day:</p>
-        <form>
-          <label for="year">Year</label>
-          <select id="year" name="year">
-            <option value="2022">2022</option>
-            <option value="2023">2023</option>
-            <option value="2024">2024</option>
-          </select>
-          <label for="month">Month</label>
-          <select id="month" name="month">
-            <option value="01">January</option>
-            <option value="02">February</option>
-            <option value="03">March</option>
-            <!-- Add other months here -->
-          </select>
-          <label for="day">Day</label>
-          <select id="day" name="day">
-            <option value="01">1</option>
-            <option value="02">2</option>
-            <option value="03">3</option>
-            <!-- Add other days here -->
-          </select>
-          <button type="submit">Submit</button>
-        </form>
-        <figure>
-          <img src="https://source.unsplash.com/random/800x600" alt="Random Unsplash Image">
-          <figcaption>
-            <a href="https://unsplash.com" target="_blank">Image from Unsplash</a>
-          </figcaption>
-        </figure>
-      </section>
-    </div>
-  </main>
-  <section aria-label="Subscribe example">
-    <div class="container">
-      <article>
-        <hgroup>
-          <h2>Subscribe</h2>
-          <h3>Get the latest updates</h3>
-        </hgroup>
-        <form class="grid">
-          <input type="text" id="firstname" name="firstname" placeholder="First Name" aria-label="First Name" required>
-          <input type="email" id="email" name="email" placeholder="Email" aria-label="Email" required>
-          <button type="submit" onclick="event.preventDefault()">Subscribe</button>
-        </form>
-      </article>
-    </div>
-  </section>
-  <footer class="container">
-    <small><a href="#">Privacy Policy</a> • <a href="#">Terms of Service</a></small>
-  </footer>
-  </body>
-  </html>
-
+  {{ curUrl }}
 </template>
 
 <style scoped>

+ 6 - 0
src/router.ts

@@ -1,5 +1,6 @@
 import {createRouter, createWebHistory} from "vue-router";
 import ApplyUserInfo from "./components/ApplyUserInfo.vue";
+import Test from "./components/Test.vue";
 
 const routes = [
     {
@@ -7,6 +8,11 @@ const routes = [
         name: "ApplyUserInfo",
         component: ApplyUserInfo,
     },
+    {
+        path: "/test",
+        name: "test",
+        component: Test,
+    },
 ]
 
 const router = createRouter({

Some files were not shown because too many files changed in this diff