From c30851cdaca79665c6d1a07a9ef41c8a810b7f5d Mon Sep 17 00:00:00 2001
From: king <2229249788@qq.com>
Date: Tue, 1 Aug 2023 14:06:54 +0800
Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=9D=83=E9=99=90=E7=AE=A1?=
=?UTF-8?q?=E7=90=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.env | 2 +-
.env.playedu | 1 +
.idea/deployment.xml | 35 +++++++++++++
.idea/webServers.xml | 14 ++++++
package.json | 2 +
src/api/request.ts | 39 +++++----------
src/app.config.ts | 2 +-
src/app.tsx | 12 ++---
.../showModel/showModel.module.scss | 4 ++
src/pages/check/check.tsx | 8 +--
src/pages/index/components/videoList.tsx | 21 +++-----
src/pages/index/index.tsx | 22 +++-----
src/pages/login/login.tsx | 21 ++++----
src/store/profile.ts | 50 +++++++++++++++++--
14 files changed, 152 insertions(+), 81 deletions(-)
create mode 100644 .env.playedu
create mode 100644 .idea/deployment.xml
create mode 100644 .idea/webServers.xml
diff --git a/.env b/.env
index 9acc359..4a6ee80 100644
--- a/.env
+++ b/.env
@@ -1,2 +1,2 @@
TARO_APP_API=https://yjx.dev.yaojiankang.top
-#TARO_APP_API=https://playedu.yaojiankang.top
+TARO_APP_LGOIN=true
diff --git a/.env.playedu b/.env.playedu
new file mode 100644
index 0000000..b5cf466
--- /dev/null
+++ b/.env.playedu
@@ -0,0 +1 @@
+TARO_APP_API=https://playedu.yaojiankang.top
diff --git a/.idea/deployment.xml b/.idea/deployment.xml
new file mode 100644
index 0000000..0ae59ca
--- /dev/null
+++ b/.idea/deployment.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/webServers.xml b/.idea/webServers.xml
new file mode 100644
index 0000000..765706e
--- /dev/null
+++ b/.idea/webServers.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/package.json b/package.json
index f67cc0b..2c24713 100644
--- a/package.json
+++ b/package.json
@@ -14,6 +14,7 @@
"build:alipay": "taro build --type alipay",
"build:tt": "taro build --type tt",
"build:h5": "taro build --type h5",
+ "build:h5Playedu": "taro build --mode playedu --type h5 ",
"build:rn": "taro build --type rn",
"build:qq": "taro build --type qq",
"build:jd": "taro build --type jd",
@@ -23,6 +24,7 @@
"dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
+ "dev:h5Playedu": "npm run build:h5 --mode playedu -- --watch ",
"dev:rn": "npm run build:rn -- --watch",
"dev:qq": "npm run build:qq -- --watch",
"dev:jd": "npm run build:jd -- --watch",
diff --git a/src/api/request.ts b/src/api/request.ts
index 871524a..fcdf070 100644
--- a/src/api/request.ts
+++ b/src/api/request.ts
@@ -44,12 +44,6 @@ export const ERROR_STATUS: Record = {
'OVERSTEP': '请求越界~'
}
-// const whitelist = [
-// '/api/v1/auth/login/code',
-// '/api/v1/auth/login/checkout',
-// '/api/v1/auth/login/wechat'
-// ]
-
export function request(
url: string,
method: keyof Method,
@@ -64,21 +58,12 @@ export function request(
'Content-Type': 'application/json;charset=UTF-8',
}
}
+
const token = JSON.parse(Taro.getStorageSync('profile') || '{}')?.token
if (token) {
option.header ??= {}
option.header['Authorization'] = `Bearer ${token}`
}
- // else {
- /** 登录页面白名单 */
- // if (Taro.getCurrentInstance().router?.path === '/pages/login/login') {
- // if (!whitelist.includes(url)) {
- // return new Promise((_, reject) => reject())
- // }
- // } else {
- // return new Promise((_, reject) => reject())
- // }
- // }
if (method === 'GET' && data) {
let parameter = ''
Object.entries(data).forEach(([key, value], index) => {
@@ -88,7 +73,6 @@ export function request(
}
data && (option.data = data)
return new Promise((resolve, reject) => {
-
Taro.request({
...option,
success(res) {
@@ -97,16 +81,19 @@ export function request(
if (data?.code === 0 && res.statusCode === 200) {
resolve(data.data || [])
} else if (res.statusCode === 401) {
- // Taro.showModal({
- // title: "登录过期,需重新登陆",
- // showCancel: false,
- // success({confirm}) {
- // confirm && Taro.reLaunch({url: '/pages/login/login'})
- // }
- // })
+ Taro.showModal({
+ title: "登录过期,需重新登陆",
+ showCancel: false,
+ success({confirm}) {
+ confirm && Taro.reLaunch({url: '/pages/login/login'})
+ }
+ })
} else {
reject(null)
- Taro.showToast({title: data.msg || data.message || ERROR_STATUS[res.statusCode] || '请求错误~', icon: 'error'})
+ Taro.showToast({
+ title: data.msg || data.message || ERROR_STATUS[res.statusCode] || '请求错误~',
+ icon: 'error'
+ })
}
} catch (e) {
reject(null)
@@ -115,7 +102,7 @@ export function request(
fail(err) {
const errMsg = err?.errMsg
console.log(err)
- Taro.showToast({title: ERROR_STATUS[errMsg] || ERROR_STATUS['DEFAULT'], icon: 'error'})
+ Taro.showToast({title: ERROR_STATUS[errMsg] || ERROR_STATUS['DEFAULT'], icon: 'error'})
reject(null)
}
})
diff --git a/src/app.config.ts b/src/app.config.ts
index 0837c61..206d523 100644
--- a/src/app.config.ts
+++ b/src/app.config.ts
@@ -1,8 +1,8 @@
export default defineAppConfig({
pages: [
+ 'pages/index/index',
'pages/login/login',
'pages/check/check',
- 'pages/index/index',
'pages/my/my'
],
window: {
diff --git a/src/app.tsx b/src/app.tsx
index e80fe80..ff9176d 100644
--- a/src/app.tsx
+++ b/src/app.tsx
@@ -2,6 +2,8 @@ import Taro, {useDidShow, useDidHide} from '@tarojs/taro'
import './app.scss'
import {CustomWrapper} from "@tarojs/components";
import unique_ident from "@/hooks/unique_ident";
+import {Profile} from '@/store'
+
function updateApp() {
if (Taro.canIUse('getUpdateManager.onCheckForUpdate')) {
@@ -10,7 +12,6 @@ function updateApp() {
console.log('新版本', res.hasUpdate)
})
-
updateManager.onUpdateReady(() => {
Taro.showModal({
title: '更新提示',
@@ -35,15 +36,10 @@ function App(props) {
Taro.useLaunch(() => {
updateApp()
- // const token = JSON.parse(Taro.getStorageSync('profile') || '{}')?.token
- // if (!token) {
- // Taro.reLaunch({url: '/pages/login/login'})
- // }
unique_ident.put()
unique_ident.del()
})
-
Taro.getSystemInfo({
success(res) {
Taro.getApp().globalData = {
@@ -67,7 +63,9 @@ function App(props) {
return (
- {props.children}
+
+ {props.children}
+
)
}
diff --git a/src/components/showModel/showModel.module.scss b/src/components/showModel/showModel.module.scss
index 6ce34f9..b535516 100644
--- a/src/components/showModel/showModel.module.scss
+++ b/src/components/showModel/showModel.module.scss
@@ -4,4 +4,8 @@
padding: 20px 0;
width: 100%;
border-top: 1px solid #eee;
+
+ & > * {
+ background: red;
+ }
}
diff --git a/src/pages/check/check.tsx b/src/pages/check/check.tsx
index 82ecdf0..e431e75 100644
--- a/src/pages/check/check.tsx
+++ b/src/pages/check/check.tsx
@@ -2,7 +2,7 @@ import {FC, useRef, useState} from "react";
import {Button, Form, Image, Input, View} from "@tarojs/components";
import {Profile} from "@/store";
import {userApi} from "@/api";
-import Taro, {useRouter} from "@tarojs/taro";
+import Taro from "@tarojs/taro";
import {regexTel} from "@/utils/regu";
import styles from './check.module.scss'
@@ -19,7 +19,7 @@ const Bing: FC = () => {
const [loading, setLoading] = useState(false)
const {setUser, setToken, setCompany} = Profile.useContainer()
const [captchaKey, setCaptchaKey] = useState(uuid())
- const router = useRouter()
+ const openid = localStorage.getItem('openid')
async function Submit(data) {
setLoading(true)
@@ -33,7 +33,7 @@ const Bing: FC = () => {
const res = await userApi.checkout({
...value,
catch_key: captchaKey,
- openid: router.params.openid,
+ openid,
})
if (res) {
setCompany(res.company)
@@ -52,7 +52,7 @@ const Bing: FC = () => {