Browse Source

修改返回

wangxy 6 days ago
parent
commit
4a602af59a

+ 16 - 2
api/chanpinShuxue.js

@@ -1,7 +1,7 @@
 import request from '@/utils/request'
-export function getShuxueChanpinList(data = {}) {
+export function getChanpinTongyongIndex(data = {}) {
     return request({
-        'url': '/app/shuxue/chanpin/list',
+        'url': '/app/chanpin/tongyong/index',
         headers: {
             isToken: true
         },
@@ -10,6 +10,20 @@ export function getShuxueChanpinList(data = {}) {
         timeout: 20000
     })
 }
+
+export function getShuxueChanpinBanbenSave(data = {}) {
+    return request({
+        'url': '/app/shuxue/chanpin/banben/save',
+        headers: {
+            isToken: true
+        },
+        method: 'post',
+        data,
+        timeout: 20000
+    })
+}
+
+
 export function getShuxueChanpinBanbenList(data = {}) {
     return request({
         'url': '/app/shuxue/chanpin/banben/list',

+ 1 - 1
pages.json

@@ -56,7 +56,7 @@
 			}
 		},
 		{
-			"path": "pages/chanpinXuanze/banben",
+			"path": "pages/chanpinXuanze/cp1/banben",
 			"style": {
 				"navigationStyle": "custom"
 			}

+ 0 - 93
pages/chanpinXuanze/banben.vue

@@ -1,93 +0,0 @@
-<template>
-	<view class="ezy-xbb-page">
-		<view class="icon-title-navBar-box">
-			<view class="nav-bar-icon" @click="handleBack"></view>
-			<view class="nav-bar-title">选择版本</view>
-		</view>
-
-		<view class="xbb-list-box">
-			<template v-if="data.banbenList.length">
-				<ezyActiveVue class="ezy-list-item-active xbb-item-box" v-for="item in data.banbenList" :key="item.id"  @aclick="handleSelect(item)">
-					<!-- 封面 -->
-					<image class="item-img-box" :src="item.cover" mode=""></image>
-					<view class="item-content-box">
-						<!-- 名称+等级 -->
-						<view class="item-name">{{item.chanpinName}} {{item.dengjiName}}</view>
-						<!-- 版本名称 -->
-						<view class="item-bb">{{item.name}}</view>
-					</view>
-					<view class="item-play-btn"></view>
-				</ezyActiveVue>
-			</template>
-			<template v-else>
-				<view class="shiti-frame-box">
-					<view class="ezy-no-sj">
-						<icon></icon>
-						<text>暂无数据</text>
-					</view>
-				</view>
-			</template>
-		</view>
-		<!-- <CustomTabBar :currentTabNumber="0"></CustomTabBar> -->
-	</view>
-</template>
-
-<script setup>
-	import {reactive} from "vue";
-	import {onLoad} from "@dcloudio/uni-app"
-	import * as shuxueHttp from "@/api/chanpinShuxue.js"
-  // import CustomTabBar from "@/components/custom-tabbar/custom-tabbar.vue";
-	import cacheManager from "@/utils/cacheManager.js";
-	import ezyActiveVue from "@/components/ezyActive/ezyActive.vue";
-	const data = reactive({
-		dengjiId: null,
-		banbenList: []
-	})
-	function getBanbenList() {
-		shuxueHttp.getShuxueChanpinBanbenList({dengjiId: data.dengjiId}).then(res => {
-			data.banbenList = res.data;
-		})
-	}
-
-	function handleBack() {
-		uni.switchTab({
-		  url: `/pages/chanpinXuanze/index`
-		})
-	}
-
-  function handleSelect(item) {
-	  if (cacheManager.get('xuexi-shuxue')) {
-		  console.log('清除xuexi-shuxuexuexi-shuxue');
-	  	cacheManager.remove("xuexi-shuxue")
-	  }
- /*   uni.redirectTo({
-      url: `/pages/chanpinneirong/index?banbenId=${item.id}&danyuanId=1&customType=3&chanpinId=${item.chanpinId}&dengjiId=${item.dengjiId}`
-    }) */
-	const opt = {
-		banbenId: item.id,
-		danyuanId:1, // 测试需要固定为 1
-		chanpinId:item.chanpinId,
-		dengjiId: item.dengjiId
-	}
-	cacheManager.updateObject("auth",{
-		banbenId:item.id,
-		chanpinId:item.chanpinId,
-		dengjiId:item.dengjiId,
-	})
-	// 跳转
-	uni.switchTab({
-		url: "/pages/chanpinneirong/index"
-	})
-  }
-
-	onLoad((options) => {
-		data.dengjiId = options.dengjiId;
-		getBanbenList();
-	})
-
-
-</script>
-
-<style>
-
-</style>

+ 8 - 29
pages/chanpinXuanze/components/shuxueList.vue

@@ -1,45 +1,24 @@
 <template>
 	<view class="sx-card-list" v-if="list.length">
-		<view v-for="item in list" :key="item.chanpinId" class="sx-card-box">
-			<view class="card-head-box">
-				<!-- 封面 -->
-				<image :src="item.cover" class="head-img"></image>
-				<view class="head-right-box">
-					<!-- 名称 -->
-					<view class="head-title">{{item.name}}</view>
-					<!-- 简介 -->
-					<view class="head-content">{{item.intro}}</view>
-					<!-- 共计 -->
-					<view class="head-content">{{item.gongji}}</view>
-				</view>
-			</view>
-			<view class="card-body-box">
-				<view class="body-title">请选择学习等级</view>
-				<view class="dj-item-row">
-					<ezyActiveVue v-for="cItem in item.levelList" class="ezy-btn-active dj-item" @aclick="handleSelect(cItem)" :class="{active: item.active}">{{cItem.levelName}}</ezyActiveVue>
-				</view>
-			</view>
-		</view>
+    <template  v-for="{chanpin,value:item} in list">
+      <cp1 v-if="chanpin == 'tujiemuti'" :item="item" :key="item.chanpinId"></cp1>
+      <cp2 v-if="chanpin == 'tujiemuti333'" :item="item" :key="item.chanpinId"></cp2>
+    </template>
+
 	</view>
-	<view class="no-kc-list" v-else>
+	<view class="ezy-no-sj" v-else>
 		<icon></icon>
 		<text>暂无数据</text>
 	</view>
 </template>
 
 <script setup>
-import ezyActiveVue from "@/components/ezyActive/ezyActive.vue";
+
+import cp1 from '../cp1/card.vue';
 
 	const props = defineProps({
 		list: {
 			type: Array
 		}
 	})
-	
-	// 选择产品等级
-	function handleSelect(item) {	
-		uni.navigateTo({
-			url: `/pages/chanpinXuanze/banben?dengjiId=${item.dengjiId}`
-		})
-	}
 </script>

+ 22 - 0
pages/chanpinXuanze/components/yingyuList.vue

@@ -0,0 +1,22 @@
+<template>
+	<view class="sx-card-list" v-if="list.length">
+    <template  v-for="{chanpin,value:item} in list" :item="item">
+      <cp1 v-if="chanpin == 'xxx'" :item="item" :key="item.chanpinId" class="sx-card-box"></cp1>
+    </template>
+
+	</view>
+	<view class="ezy-no-sj" v-else>
+		<icon></icon>
+		<text>暂无数据</text>
+	</view>
+</template>
+
+<script setup>
+  import cardVue from '../cp1/card.vue';
+
+	const props = defineProps({
+		list: {
+			type: Array
+		}
+	})
+</script>

+ 21 - 0
pages/chanpinXuanze/components/yuwenList.vue

@@ -0,0 +1,21 @@
+<template>
+  <view class="sx-card-list" v-if="list.length">
+    <template  v-for="{chanpin,value:item} in list" :item="item">
+      <cp1 v-if="chanpin == 'xxx'" :item="item" :key="item.chanpinId" class="sx-card-box"></cp1>
+    </template>
+  </view>
+  <view class="ezy-no-sj" v-else>
+    <icon></icon>
+    <text>暂无数据</text>
+  </view>
+</template>
+
+<script setup>
+import cardVue from '../cp1/card.vue';
+
+const props = defineProps({
+  list: {
+    type: Array
+  }
+})
+</script>

+ 83 - 0
pages/chanpinXuanze/cp1/banben.vue

@@ -0,0 +1,83 @@
+<template>
+  <view class="ezy-xbb-page">
+    <view class="icon-title-navBar-box">
+      <view class="nav-bar-icon" @click="handleBack"></view>
+      <view class="nav-bar-title">选择版本</view>
+    </view>
+
+    <view class="xbb-list-box">
+      <template v-if="data.banbenList.length">
+        <ezyActiveVue class="ezy-list-item-active xbb-item-box" v-for="item in data.banbenList" :key="item.id"
+                      @aclick="handleSelect(item)">
+          <!-- 封面 -->
+          <image class="item-img-box" :src="item.cover" mode=""></image>
+          <view class="item-content-box">
+            <!-- 名称+等级 -->
+            <view class="item-name">{{ item.chanpinName }} {{ item.dengjiName }}</view>
+            <!-- 版本名称 -->
+            <view class="item-bb">{{ item.name }}</view>
+          </view>
+          <view class="item-play-btn"></view>
+        </ezyActiveVue>
+      </template>
+      <template v-else>
+        <view class="shiti-frame-box">
+          <view class="ezy-no-sj">
+            <icon></icon>
+            <text>暂无数据</text>
+          </view>
+        </view>
+      </template>
+    </view>
+  </view>
+</template>
+
+<script setup>
+import {reactive} from "vue";
+import {onLoad} from "@dcloudio/uni-app"
+import * as shuxueHttp from "@/api/chanpinShuxue.js"
+import cacheManager from "@/utils/cacheManager.js";
+import ezyActiveVue from "@/components/ezyActive/ezyActive.vue";
+
+const data = reactive({
+  dengjiId: null,
+  banbenList: []
+})
+
+function getBanbenList() {
+  shuxueHttp.getShuxueChanpinBanbenList({dengjiId: data.dengjiId}).then(res => {
+    data.banbenList = res.data;
+  })
+}
+
+function handleBack() {
+  uni.switchTab({
+    url: `/pages/chanpinXuanze/index`
+  })
+}
+
+function handleSelect(item) {
+  const opt = {
+    banbenId: item.id,
+  }
+  shuxueHttp.getShuxueChanpinBanbenSave(opt).then(res => {
+    if (!res.data) { return;}
+    cacheManager.get('neirong') && cacheManager.remove('neirong');
+    // 跳转
+    uni.switchTab({
+      url: "/pages/chanpinneirong/index"
+    })
+  })
+}
+
+onLoad((options) => {
+  data.dengjiId = options.dengjiId;
+  getBanbenList();
+})
+
+
+</script>
+
+<style>
+
+</style>

+ 43 - 0
pages/chanpinXuanze/cp1/card.vue

@@ -0,0 +1,43 @@
+<template>
+  <view class="sx-card-box">
+    <view class="card-head-box">
+      <!-- 封面 -->
+      <image :src="item.cover" class="head-img"></image>
+      <view class="head-right-box">
+        <!-- 名称 -->
+        <view class="head-title">{{item.name}}</view>
+        <!-- 简介 -->
+        <view class="head-content">{{item.intro}}</view>
+        <!-- 共计 -->
+        <view class="head-content">{{item.gongji}}</view>
+      </view>
+    </view>
+    <view class="card-body-box">
+      <view class="body-title">请选择学习等级</view>
+      <view class="dj-item-row">
+        <ezyActiveVue v-for="cItem in item.levelList" class="ezy-btn-active dj-item" @aclick="handleSelect(cItem)" :class="{active: item.active}">{{cItem.levelName}}</ezyActiveVue>
+      </view>
+    </view>
+  </view>
+</template>
+
+<script setup>
+import ezyActiveVue from "@/components/ezyActive/ezyActive.vue";
+const porps = defineProps({
+  item: {
+    type: Object
+  }
+})
+
+	// 选择产品等级
+function handleSelect(item) {
+  uni.navigateTo({
+    url: `/pages/chanpinXuanze/cp1/banben?dengjiId=${item.dengjiId}`
+  })
+}
+
+</script>
+
+<style scoped>
+
+</style>

+ 13 - 0
pages/chanpinXuanze/cp2/card.vue

@@ -0,0 +1,13 @@
+<template>
+
+</template>
+
+<script>
+export default {
+  name: "card.vue"
+}
+</script>
+
+<style scoped>
+
+</style>

+ 106 - 78
pages/chanpinXuanze/index.vue

@@ -1,86 +1,114 @@
 <template>
-	<view class="ezy-xuanke-page">
-		<!-- 返回区域 -->
-		<view class="icon-title-navBar-box">
-			<text class="nav-bar-title">选课</text>
-		</view>
-		<view class="ezy-page-body">
-			<!-- 头部区域 -->
-			
-			<view class="xuanke-tab-box">
-				<!-- 动画按钮 -->
-				<ezyActiveVue class="ezy-btn-active tab-item" v-for="item in data.list" :key="item.value" 
-					:class="{active: item.value == data.chanpinActiveSelect}" @aclick="handleSelectChanpin(item)">
-					{{item.name}}</ezyActiveVue>
-			</view>
-			<!-- 英语列表 -->
-			<template v-if="data.chanpinActiveSelect == 1">
-				<view class="ezy-no-sj" v-if="data.list.length">
-					<icon></icon>
-					<text>暂无数据</text>
-				</view>
-			</template>
-			<!-- 数学列表 -->
-			<shuxueListVue v-if="data.chanpinActiveSelect == 2" :list="data.shuxueList"></shuxueListVue>
-			<!-- 语文列表 -->
-			<template v-if="data.chanpinActiveSelect == 3">
-				<view class="ezy-no-sj" v-if="data.list.length">
-					<icon></icon>
-					<text>暂无数据</text>
-				</view>
-			</template>
-		</view>
-	</view>
-	<custom-tab-bar :show="true" :current-index="currentTabIndex" />
+  <view class="ezy-xuanke-page">
+    <!-- 返回区域 -->
+    <view class="icon-title-navBar-box">
+      <text class="nav-bar-title">选课</text>
+    </view>
+    <view class="ezy-page-body">
+      <!-- 头部区域 -->
+
+      <view class="xuanke-tab-box">
+        <!-- 动画按钮 -->
+        <ezyActiveVue class="ezy-btn-active tab-item" v-for="item in data.list"
+                      :key="item.value"
+                      :class="{active: item.value == data.chanpinActiveSelect}"
+                      @aclick="handleSelectChanpin(item)">
+          {{ item.name }}
+        </ezyActiveVue>
+      </view>
+      <!-- 数学列表 -->
+      <shuxueListVue v-if="data.chanpinActiveSelect == 1" :list="data.shuxueList"></shuxueListVue>
+      <!-- 英语列表 -->
+      <yingyuListVue v-if="data.chanpinActiveSelect == 2" :list="data.yingyuList"></yingyuListVue>
+      <!-- 语文列表 -->
+      <yuwenListVue v-if="data.chanpinActiveSelect == 3" :list="data.yuwenList"></yuwenListVue>
+    </view>
+  </view>
+  <custom-tab-bar :show="true" :current-index="currentTabIndex"/>
 </template>
 
 <script setup>
-	import {
-		reactive, ref
-	} from "vue";
-	import shuxueListVue from "./components/shuxueList.vue";
-	import {
-		onLoad,
-		onShow
-	} from "@dcloudio/uni-app"
-	import * as shuxueHttp from "@/api/chanpinShuxue.js"
-	import CustomTabBar from "@/components/custom-tabbar/index.vue";
-	import ezyActiveVue from "@/components/ezyActive/ezyActive.vue";
-	
-	let currentTabIndex = ref(0)
-	const data = reactive({
-		list: [{
-				name: '英语',
-				value: 1
-			},
-			{
-				name: '数学',
-				value: 2
-			},
-			{
-				name: '语文',
-				value: 3
-			},
-		],
-		chanpinActiveSelect: 2,
+import {
+  reactive, ref
+} from "vue";
+import shuxueListVue from "./components/shuxueList.vue";
+import yingyuListVue from "./components/yingyuList.vue";
+import yuwenListVue from "./components/yuwenList.vue";
+import {
+  onLoad,
+  onShow
+} from "@dcloudio/uni-app"
+import * as shuxueHttp from "@/api/chanpinShuxue.js"
+import CustomTabBar from "@/components/custom-tabbar/index.vue";
+import ezyActiveVue from "@/components/ezyActive/ezyActive.vue";
+import {getChanpinTongyongIndex} from "../../api/chanpinShuxue";
+import {getFullTimer} from "../../utils/common";
+
+let currentTabIndex = ref(0)
+const data = reactive({
+  list: [
+    {
+      name: '数学',
+      value: 1
+    },
+    {
+      name: '英语',
+      value: 2
+    },
+    {
+      name: '语文',
+      value: 3
+    },
+  ],
+  chanpinActiveSelect: 1,
+
+  shuxueList: [],
+})
+
+
+function getFormatData(data) {
+  const shuxue = data.shuxue || {};
+  const yingyu = data.yingyu || {};
+  const yuwen = data.yuwen || {};
+
+  return {
+    shuxue: Object.entries(shuxue).map(([chanpin, value]) => {
+      return { chanpin, value };
+    }),
+    yingyu:Object.entries(yingyu).map(([chanpin, value]) => {
+      return { chanpin, value };
+    }),
+    yuwen:Object.entries(yuwen).map(([chanpin, value]) => {
+      return { chanpin, value };
+    }),
+  }
+}
+
+function getShuxueList() {
+  shuxueHttp.getChanpinTongyongIndex().then(res => {
+    const result = getFormatData(res.data);
+    data.shuxueList = result.shuxue;
+    data.yingyuList = result.yingyu;
+    data.yuwenList = result.yuwen;
+  })
+}
+
+function handleSelectChanpin(item) {
+  data.chanpinActiveSelect = item.value
+}
 
-		shuxueList: [],
-	})
+onShow(() => {
+  currentTabIndex.value = 0;
+  data.chanpinActiveSelect = 1;
 
-	function getShuxueList() {
-		shuxueHttp.getShuxueChanpinList().then(res => {
-			data.shuxueList = res.data;
-		})
-	}
+  if (getFullTimer() !== `2026-01-28`) {
+    //每日刷新
+    getShuxueList();
+  }
+})
 
-	function handleSelectChanpin(item) {
-		data.chanpinActiveSelect = item.value
-	}
-	onShow(() => {
-			currentTabIndex.value = 0;
-	})
-	onLoad(() => {
-		uni.hideTabBar()
-		getShuxueList()
-	})
+onLoad(() => {
+  uni.hideTabBar()
+  getShuxueList()
+})
 </script>

+ 1 - 0
pages/chanpinXuanze/readme.md

@@ -0,0 +1 @@
+tujiemuti: 'cp1', // 小学数学图解母体

+ 22 - 0
utils/common.js

@@ -145,4 +145,26 @@ export function convertTimeToSeconds(timeStr) {
     // 计算总秒数:小时 × 3600 + 分钟 × 60
     const totalSeconds = hours * 60 + minutes;
     return totalSeconds.toString();
+}
+
+export function getUserIsYouke() {
+	const auth = cacheManager.get('auth');
+	if (!auth) {
+		throw new Error('数据异常,未发现用户信息');
+	}
+
+	if (!auth.userName) {
+		throw new Error('数据异常,无法判定用户身份')
+	}
+
+	return auth.userName.startsWith('youke');
+}
+
+export function getFullTimer() {
+	const now = new Date();
+	const year = now.getFullYear();
+	const month = now.getMonth() + 1;
+	const day = now.getDate();
+    // 格式:2026-01-29
+	return `${year}-${month.toString().padStart(2, '0')}-${day.toString().padStart(2, '0')}`;
 }