瀏覽代碼

首页热门曲目-未判断学生是否是会员

liushengqiang 2 年之前
父節點
當前提交
3f7746b46c

+ 7 - 0
src/page-instrument/component/mode-type-mode/index.tsx

@@ -5,6 +5,8 @@ import { headTopData } from "../../header-top";
 import state, { IPlatform } from "/src/state";
 import TeacherBootom from "../../custom-plugins/guide-page/teacher-bootom";
 import StudentBottom from "../../custom-plugins/guide-page/student-bottom";
+import TheVip from "../../custom-plugins/the-vip";
+import { storeData } from "/src/store";
 export default defineComponent({
 	name: "modelWraper",
 
@@ -19,6 +21,10 @@ export default defineComponent({
 					showPC.value = true;
 				}, 500);
 			} else {
+				// 不是vip, 不引导
+				if (!storeData.user.vipMember) {
+					return
+				}
 				// 学生端
 				setTimeout(() => {
 					showStudent.value = true;
@@ -55,6 +61,7 @@ export default defineComponent({
 					</div>
 					{showPC.value && headTopData.modeType === "init" ? <TeacherBootom></TeacherBootom> : null}
 					{showStudent.value && headTopData.modeType === "init" ? <StudentBottom></StudentBottom> : null}
+					{state.platform !== IPlatform.PC && headTopData.modeType === "init" && <TheVip />}
 				</div>
 			</>
 		);

+ 66 - 32
src/page-instrument/custom-plugins/the-vip/index.tsx

@@ -1,35 +1,69 @@
-import { defineComponent } from 'vue';
-import icon_bg from './icon_bg.png';
-import icon_title from './icon_title.png';
-import icon_btn from './icon_btn.png';
-import icon_close from './icon_close.png';
-import styles from './index.module.less';
+import { defineComponent, onMounted, reactive } from "vue";
+import icon_bg from "./icon_bg.png";
+import icon_title from "./icon_title.png";
+import icon_btn from "./icon_btn.png";
+import icon_close from "./icon_close.png";
+import styles from "./index.module.less";
+import { Popup } from "vant";
+import { setUserInfo, storeData } from "/src/store";
+import { api_back } from "/src/helpers/communication";
+import { listenerMessage, postMessage } from "/src/utils/native-message";
+import { studentQueryUserInfo } from "../../api";
 
 export default defineComponent({
-  name: 'TheVip',
-  emits: ['close'],
-  setup(props, { emit }) {
-    return () => (
-      <div class={styles.container}>
-        <img
-          class={styles.close}
-          src={icon_close}
-          onClick={() => emit('close')}
-        />
-        <img class={styles.title} src={icon_title} />
-        <div class={styles.content}>
-          您还未领取<span style={{ color: '#FF5A56' }}>“小酷AI”</span>
-          哦,如需继续使用,请领取~
-        </div>
-        <div class={styles.btns}>
-          <img
-            class={styles.btn}
-            src={icon_btn}
-            onClick={() => emit('close', true)}
-          />
-          <div onClick={() => emit('close')}>暂不领取</div>
-        </div>
-      </div>
-    );
-  }
+	name: "TheVip",
+	emits: ["close"],
+	setup(props, { emit }) {
+		const data = reactive({
+			show: !storeData.user.vipMember,
+		});
+		const close = () => {
+			api_back();
+		};
+    const getUserInfo = async () => {
+      const res = await studentQueryUserInfo();
+				const student = res?.data || {};
+				setUserInfo(student);
+    }
+		onMounted(() => {
+      listenerMessage('webViewOnResume', () => {
+        if (storeData.user.vipMember) return;
+        console.log('页面显示')
+        getUserInfo()
+      });
+		});
+		return () => (
+			<Popup
+				teleport="body"
+				closeOnClickOverlay={false}
+				class={["popup-custom"]}
+				show={!storeData.user.vipMember}
+			>
+				<div class={styles.container}>
+					<img class={styles.close} src={icon_close} onClick={close} />
+					<img class={styles.title} src={icon_title} />
+					<div class={styles.content}>
+						您还未领取<span style={{ color: "#FF5A56" }}>“小酷AI”</span>
+						哦,如需继续使用,请领取~
+					</div>
+					<div class={styles.btns}>
+						<img
+							class={styles.btn}
+							src={icon_btn}
+							onClick={() => {
+								postMessage({
+									api: "openWebView",
+									content: {
+										url: `${location.origin}/classroom-app/#/member-center`,
+										orientation: 1,
+									},
+								});
+							}}
+						/>
+						<div onClick={close}>暂不领取</div>
+					</div>
+				</div>
+			</Popup>
+		);
+	},
 });

+ 2 - 0
src/store.ts

@@ -16,6 +16,8 @@ type IUser = {
 	memberRankSettingId?: number;
 	id?: string | number;
 	clientType?: "BACKEND" | "SCHOOL" | "TEACHER" | "STUDENT";
+	/** 是否是VIP */
+	vipMember?: boolean;
 };
 type IStatus = "init" | "login" | "logout" | "error";
 type IPlatformType = "STUDENT" | "TEACHER" | "WEB" | "";