JXDS18FUJT 1 жил өмнө
parent
commit
801ba1b4f5

+ 13 - 0
package-lock.json

@@ -1913,6 +1913,19 @@
         "loose-envify": "^1.0.0"
       }
     },
+    "weixin-js-sdk": {
+      "version": "1.6.0",
+      "resolved": "https://registry.npmmirror.com/weixin-js-sdk/-/weixin-js-sdk-1.6.0.tgz",
+      "integrity": "sha512-3IYQH7aalJGFJrwdT3epvTdR1MboMiH7vIZ5BRL2eYOJ12BNah7csoMkmSZzkq1+l92sSq29XdTCVjCJoK2sBQ=="
+    },
+    "weixin-js-sdk-ts": {
+      "version": "1.6.0",
+      "resolved": "https://registry.npmmirror.com/weixin-js-sdk-ts/-/weixin-js-sdk-ts-1.6.0.tgz",
+      "integrity": "sha512-TYUtTou3DA0FwCwjv5w2MrEB0ffGdV4A1KRXVNbyYkiRKQI7uo5y/gQ8HuqfngRg/iFNpVtaQf7lQl9NBNvrLw==",
+      "requires": {
+        "weixin-js-sdk": "^1.6.0"
+      }
+    },
     "weui": {
       "version": "1.1.0",
       "resolved": "https://registry.npmmirror.com/weui/-/weui-1.1.0.tgz",

+ 1 - 0
package.json

@@ -18,6 +18,7 @@
     "react": "^17.0.0",
     "react-dom": "^17.0.0",
     "react-router-dom": "^5.2.0",
+    "weixin-js-sdk-ts": "^1.6.0",
     "weui": "^1.1.0"
   },
   "devDependencies": {

+ 1 - 1
src/App.tsx

@@ -17,7 +17,7 @@ export function App() {
     <Router>
     <Switch>
       <Route exact path="/">
-        <VideoKindList />
+        <Home />
       </Route>
       <Route path="/home">
         <Home />

+ 11 - 2
src/api/index.ts

@@ -4,7 +4,7 @@ const api = {
     //公众号登陆
     loginGzhcode: (params: {
         authorizationCode: string
-    }) => {
+    }):AxiosPromise<loginGzhcode> => {
         return request({
             url: "login/gzhcode",
             headers: {
@@ -20,7 +20,7 @@ const api = {
         state: 0 | 1,
         videoSubject: number
 
-    }): AxiosPromise<StudentVideoTeachingListRes> => {
+    }): AxiosPromise<studentVideoTeachingListRes> => {
         return request({
             url: "student/video/teaching/list",
             method: 'get',
@@ -67,6 +67,15 @@ const api = {
             method:'get'
         })
 
+    },
+    //微信公众号的下单接口
+    studentWxGzhPrepareOrder(data:{}){
+        return request({
+            url:"/student/wx/gzhPrepareOrder",
+            method:'post',
+            data
+
+        })
     }
 
     

+ 13 - 1
src/api/type.d.ts

@@ -2,7 +2,19 @@ interface Res {
     code: number;
     msg: string;
 }
-interface StudentVideoTeachingListRes extends Res {
+interface loginGzhcode extends Res {
+    data:{
+        token:string
+        thirdResult:{
+            nickname:string
+            openid:string
+            sex:'0'|'1'
+            headimgurl:string
+            unionid:string
+        }
+    }
+}
+interface studentVideoTeachingListRes extends Res {
     total: number
     rows: {
         createTime: string

BIN
src/assets/images/ke_mu1.png


BIN
src/assets/images/ke_mu2.png


BIN
src/assets/images/ke_mu3.png


BIN
src/assets/images/ke_mu4.png


BIN
src/assets/images/road.png


BIN
src/assets/images/更多@2x.png


+ 2 - 2
src/utils/request.ts

@@ -1,7 +1,7 @@
 import axios from "axios";
 import { Toast } from 'antd-mobile'
 const request = axios.create({
-	baseURL: import.meta.env.MODE === "production" ? "https://nbjk.zzxcx.net/nbjk-admin" : "https://nbjk1.zzxcx.net/nbjk-admin",
+	baseURL: import.meta.env.MODE === "production" ? "https://nbjk.zzxcx.net/nbjk-admin" : "https://nbjk.zzxcx.net/nbjk-admin",
 });
 
 request.interceptors.request.use((config) => {
@@ -21,7 +21,7 @@ request.interceptors.request.use((config) => {
 });
 
 request.interceptors.response.use((res) => {
-	let redirect_uri = window.location.href
+	let redirect_uri =window.location.href
 	if (res && res.data) {
 		switch (res.data.code) {
 			case 401:

+ 165 - 34
src/views/home/index.less

@@ -1,42 +1,173 @@
 .Home {
-    text-align: center;
-  }
-  
-  .Home-logo {
-    height: 40vmin;
-    pointer-events: none;
+  width: 750px;
+
+  .user {
+    width: 690px;
+    margin: 0 auto;
+    line-height: 48px;
+    display: flex;
+
+    .head {
+      width: 48px;
+      height: 48px;
+      border-radius: 50%;
+    }
+
+    .nickname {
+      margin-left: 10px;
+      font-size: 34px;
+    }
   }
-  
-  @media (prefers-reduced-motion: no-preference) {
-    .Home-logo {
-      animation: Home-logo-spin infinite 20s linear;
+
+  .road {
+    width: 690px;
+    height: 478px;
+    margin: 0 auto;
+    padding-top: 36px;
+    border-radius: 20px 20px 20px 20px;
+    background: linear-gradient(188deg, #EDF4FF 0%, rgba(237, 244, 255, 0.43) 100%);
+
+    .first {
+      padding: 0 30px;
+      display: flex;
+      justify-content: space-between;
+      line-height: 50px;
+
+      .left {
+        font-size: 36px;
+
+        font-weight: bold;
+      }
+
+      .right {
+        color: rgba(73, 142, 245, 1);
+        font-size: 26px;
+        vertical-align: middle;
+        display: inline-block;
+
+        img {
+          width: 12px;
+          margin-left: 8px;
+        }
+      }
+    }
+
+    .sencond {
+      width: 328px;
+      padding: 0 30px;
+      margin-top: 16px;
+      text-align: center;
+      margin-bottom: 24px;
+
+      .button {
+        width: 268px;
+        line-height: 64px;
+        background-color: rgba(73, 142, 245, 1);
+        color: white;
+        font-size: 26px;
+        text-align: center;
+        border-radius: 20px 20px 20px 20px;
+      }
+    }
+
+    .third {
+      padding: 0 30px;
+      display: flex;
+      justify-content: space-between;
+
+      .left {
+        width: 408px;
+        height: 230px;
+      }
+
+      .right {
+        padding-top: 18px;
+        text-align: center;
+        font-size: 30px;
+        color: rgba(73, 142, 245, 1);
+
+        .look {
+          margin-top: 10px;
+          width: 200px;
+          line-height: 92px;
+          background: #498EF5;
+          border-radius: 50px 50px 50px 50px;
+          color: #fff;
+          opacity: 1;
+        }
+
+      }
     }
   }
-  
-  .Home-header {
-    background-color: #282c34;
-    min-height: 100vh;
+
+  .list {
+    width: 690px;
     display: flex;
-    flex-direction: column;
-    align-items: center;
-    justify-content: center;
-    font-size: calc(10px + 2vmin);
-    color: white;
+    flex-wrap: wrap;
+    margin: 0 auto;
+    position: relative;
+    justify-content: space-between;
+    padding-top: 40px;
   }
-  
-  .Home-link {
-    color: #61dafb;
+
+  .list-item {
+    width: 334px;
+    height: 302px;
+    margin-bottom: 40px;
+    position: relative;
+
+
   }
-  
-  @keyframes Home-logo-spin {
-    from {
-      transform: rotate(0deg);
-    }
-    to {
-      transform: rotate(360deg);
-    }
+
+  .list-item-img {
+    width: 100%;
+    height: 100%;
+
+
+
+  }
+
+  .list-item-text {
+    color: white;
+    position: absolute;
+    font-size: 42px;
+
+    text-align: left;
+
+
   }
-  
-  button {
-    font-size: calc(10px + 2vmin);
-  }
+
+}
+
+.left20 {
+  left: 20px;
+
+}
+
+.left34 {
+  left: 34px
+}
+
+.left40 {
+  left: 40px
+}
+
+.left60 {
+  left: 60px;
+}
+
+.top128 {
+  top: 128px;
+}
+
+.top88 {
+  top: 88px;
+}
+
+.top54 {
+  top: 54px;
+}
+
+.top30 {
+  top: 30px;
+}

+ 128 - 40
src/views/home/index.tsx

@@ -1,48 +1,136 @@
-import React, { useState } from 'react'
-import logo from '~/logo.svg'
-// 警告:antd.js?v=3a2dd9f5:57983 You are using a whole package of antd, please use https://www.npmjs.com/package/babel-plugin-import to reduce Home bundle size.
-// Vite 会对 npm 依赖进行预构建并重写为合法的 url。在本项目中,Vite 将 Antd 预构建到 /node_moduls/.vite 文件夹,并且将 url 重写为 /node_modules/.vite/antd.js?v=d2a18218,因此会出现这个警告。
-import { DatePicker } from 'antd';
 import './index.less'
+import React, { useEffect, useState } from "react";
 
+import { Link, useHistory } from 'react-router-dom';
+import kemu1 from './../../assets/images/ke_mu1.png'
+import kemu2 from './../../assets/images/ke_mu2.png'
+import kemu3 from './../../assets/images/ke_mu3.png'
+import kemu4 from './../../assets/images/ke_mu4.png'
+import blueArrow from './../../assets/images/更多@2x.png'
+import api from '~/api'
+import road from './../../assets/images/road.png'
+import WX from "weixin-js-sdk-ts";
 export const Home: React.FC = (props: any) => {
-  const [count, setCount] = useState(0)
+  const [list, setList] = useState([{
+    image: kemu1,
+    title: "科目一"
+  }, {
+    image: kemu2,
+    title: "科目二"
+  }, {
+    image: kemu3,
+    title: "科目三"
+  }, {
+    image: kemu4,
+    title: "科目四"
+  }])
+  const [userInfo, setUserInfo] = useState({ "openid": "", "nickname": "未知用户", "sex": "0", "province": "", "city": "", "country": "", "headimgurl": "https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKZYiaibphiayqRhARSnicqI2bHNYWfnuGTDLagIUfNSncS5H8m097t5qSHwkGeRLn8D0uV14ACfibVCZg/132", "privilege": [], "unionid": "" })
+  const wxPay = () => {
+    api.studentWxGzhPrepareOrder({
+      "foreType": 2,
+      "goodsId": 5,
+      "goodsType": 1,
+      "phoneType": 2
+    }).then(res=>{
+       WX.chooseWXPay(res.data.data)
+    })
+    // wx.chooseWXPay()
+  }
+  useEffect(() => {
+    document.title = ''
+    let query = new URLSearchParams(window.location.search)
+
+    if (query.get("state") == 'LOGIN') {
+      api.loginGzhcode({
+        authorizationCode: query.get("code") || ""
+      }).then(res => {
+        window.localStorage.setItem("token", res.data.data.token)
+        window.localStorage.setItem("userInfo", JSON.stringify(res.data.data.thirdResult))
+        window.location.replace('/')
+        console.log(res.data.data.token)
+      })
+    }
+    else {
+      api.studentUserInfo().then(res => {
+
+
+
+      })
+    }
+    setUserInfo(JSON.parse(window.localStorage.getItem('userInfo') || '{"openid":"","nickname":"未知用户","sex":"0","province":"","city":"","country":"","headimgurl":"https://thirdwx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTKZYiaibphiayqRhARSnicqI2bHNYWfnuGTDLagIUfNSncS5H8m097t5qSHwkGeRLn8D0uV14ACfibVCZg/132","privilege":[],"unionid":""}'
+    ) as {
+      openid: string;
+      nickname: string;
+      sex: string;
+      province: string;
+      city: string;
+      country: string;
+      headimgurl: string;
+      privilege: never[];
+      unionid: string;
+    })
+
+
+
+
+
+
+
+
+  }, [])
   return (
     <div className="Home">
-      <header className="Home-header">
-        <img src={logo} className="Home-logo" alt="logo" />
-        <DatePicker />
-        <p>Hello Vite + React!</p>
-        <p>
-          <button onClick={() => setCount((count) => count + 1)}>
-            count is: {count}
-          </button>
-        </p>
-        <p>
-          Edit <code>Home.tsx</code> and save to test HMR updates.
-        </p>
-        <p>
-          <a
-            className="Home-link"
-            href="https://reactjs.org"
-            target="_blank"
-            rel="noopener noreferrer"
-          >
-            Learn React
-          </a>
-          {' | '}
-          <a
-            className="Home-link"
-            href="https://vitejs.dev/guide/features.html"
-            target="_blank"
-            rel="noopener noreferrer"
-          >
-            Vite Docs
-          </a>
-        </p>
-      </header>
+      <div className='user'>
+        <img className='head' src={userInfo.headimgurl}></img>
+        <div className='nickname'>{userInfo.nickname}</div>
+      </div>
+      <div className='road'>
+        <div className='first'>
+          <span className='left'>科三真实考场</span>
+          <span className='right'>我的考场
+            <img src={blueArrow}></img>
+          </span>
+        </div>
+        <div className='sencond'>
+          <div className='button'>社会化驾驶人考场</div>
+          <img style={{
+            marginTop: '0.66vw',
+            width: '4.8vw'
+          }} src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACQAAAAOCAYAAABHN77IAAAAAXNSR0IArs4c6QAAATNJREFUSEvF1LtOAkEUBuD/zIISkWjwBfQV9B1kqQ0VFlrSUOClIyGh81bYUGqhlbFm13fQV9AXkGi4BJWdY2bjGlcXBmVHptvJzJlvi/8n+7izBVCDCClMcTGjD3CJlCF30F2lBF0TeHkaJgY98IA33P30nQ/yUSfPWYHEBYD8P6OaEoNNt7LQUu9+gnxEjYWd6VWJUAVgGYZ5zKg77bk6aiSDt8Kgj137qJ+D8C4JWDKBYuAR0io6uyn3+/xIkDq0fvi0YonkFQhrsaIYt558K9zsLd5HzR0KUofzpzyL124DgrZjQUk+w0y61CzTy7B5I0HBpUmrIYi0szN/rvuxsUCTVMPXSOswP1OmufGHaghFOnbQL6ohMtJmQJpqGBVpo6DIatBE2jgoVA3qQxPpcUDvkluDONeclCUAAAAASUVORK5CYII='></img>
+
+        </div>
+        <div className='third'>
+          <img className='left' src={road}></img>
+          <div className='right'>
+            <span>
+              <div>熟记考场</div>
+              <div>考试不用慌</div>
+            </span>
+            <div onClick={wxPay} className='look'>去看考场</div>
+          </div>
+        </div>
+      </div>
+      <div className="list">
+        {
+          list.map((item, index) => {
+            return (
+              <Link key={index} to={
+                './videoList/' + (index + 1)
+              }>
+                <div className="list-item" key={index}>
+                  <img className="list-item-img" src={item.image} alt="图片" />
+                  <span className="list-item-text top30 left60 ">{item.title}</span>
+                  <span className="list-item-text top88 left20">《视频讲解》</span>
+                </div>
+              </Link>
+
+
+            )
+          })
+
+        }
+      </div>
     </div>
   )
-}
 
-// export default Home
+}

+ 0 - 0
src/views/home/me/index.less


+ 0 - 10
src/views/home/me/index.tsx

@@ -1,10 +0,0 @@
-import './index.less'
-import React from "react";
-export const Me: React.FC = (props: any) => {
-    return (
-        <div>
-            <span>不服啊</span>
-        </div>
-    )
-
-}

+ 1 - 1
vite.config.ts

@@ -58,7 +58,7 @@ export default defineConfig({
     }]
   },
   server: {
-    host: "nbjk1-h5.zzxcx.net",
+    host: "nbjk-h5.zzxcx.net",
 		port: 443,
 		https: {
 			key: fs.readFileSync("./cert/nbjk-h5.zzxcx.net.key"),