|
|
@@ -19,8 +19,8 @@
|
|
|
<view class="card-progress-box">
|
|
|
<view class="xx-progress-box">
|
|
|
<view>学习进度</view>
|
|
|
- <progress :percent="curProcess" class="xx-progress" stroke-width="20"
|
|
|
- backgroundColor="#3c7dfd" activeColor="#ffd11c" />
|
|
|
+ <progress :percent="curProcess" class="xx-progress" stroke-width="20" backgroundColor="#3c7dfd"
|
|
|
+ activeColor="#ffd11c" />
|
|
|
</view>
|
|
|
<view class="jxxx-btn" @click="handlePlay(banbenInfo,'jixu')"></view>
|
|
|
</view>
|
|
|
@@ -80,7 +80,7 @@
|
|
|
data() {
|
|
|
return {
|
|
|
canExitApp: false,
|
|
|
-
|
|
|
+
|
|
|
danyuanList: [],
|
|
|
currentUnitName: "",
|
|
|
isShow: true,
|
|
|
@@ -101,60 +101,58 @@
|
|
|
danyuanInfoVue
|
|
|
},
|
|
|
onShow() {
|
|
|
-
|
|
|
- console.log('this.needRefresh',this.needRefresh)
|
|
|
- console.log('this.hasCache',this.hasCache)
|
|
|
- console.log('学习页面显示,使用缓存数据')
|
|
|
+ // console.log('学习页面显示,使用缓存数据')
|
|
|
this.currentTabIndex = 1
|
|
|
- // 如果从其他页面返回需要刷新数据
|
|
|
- if (this.needRefresh) {
|
|
|
- this.needRefresh = false;
|
|
|
- this.updateFromCache();
|
|
|
- }
|
|
|
-
|
|
|
- // 如果是第一次进入,已经有缓存数据了,直接使用缓存
|
|
|
- if (this.hasCache) {
|
|
|
- this.updateFromCache();
|
|
|
- }
|
|
|
- },
|
|
|
- onHide() {
|
|
|
- console.log('学习页面隐藏,保存滚动位置')
|
|
|
- this.needRefresh = true; // 标记离开页面,返回时需要刷新
|
|
|
-
|
|
|
- },
|
|
|
- onLoad(options) {
|
|
|
- uni.hideTabBar()
|
|
|
const cacheData = cacheManager.get('xuexi-shuxue');
|
|
|
// cacheData && this.shouldUseCache(options, cacheData)
|
|
|
if (cacheData) {
|
|
|
// 使用缓存数据
|
|
|
console.log('使用缓存数据');
|
|
|
- this.hasCache = true;
|
|
|
- this.initFromCache(cacheData);
|
|
|
+ this.updateFromCache();
|
|
|
} else {
|
|
|
// 没有缓存或参数不同,重新请求
|
|
|
console.log('重新请求数据');
|
|
|
this.hasCache = false;
|
|
|
- const cacheDataAuth = cacheManager.get('auth');
|
|
|
+ const cacheDataAuth = cacheManager.get('auth');
|
|
|
this.initFromOptions(cacheDataAuth);
|
|
|
}
|
|
|
+
|
|
|
+ // // 如果从其他页面返回需要刷新数据
|
|
|
+ // if (this.needRefresh) {
|
|
|
+ // this.needRefresh = false;
|
|
|
+ // this.updateFromCache();
|
|
|
+ // }
|
|
|
+
|
|
|
+ // // 如果是第一次进入,已经有缓存数据了,直接使用缓存
|
|
|
+ // if (this.hasCache) {
|
|
|
+ // this.updateFromCache();
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ onHide() {
|
|
|
+ console.log('学习页面隐藏,保存滚动位置')
|
|
|
+ this.needRefresh = true; // 标记离开页面,返回时需要刷新
|
|
|
+
|
|
|
+ },
|
|
|
+ onLoad(options) {
|
|
|
+ // debugger
|
|
|
+ uni.hideTabBar()
|
|
|
},
|
|
|
methods: {
|
|
|
// 从缓存初始化方法
|
|
|
- initFromCache(cacheData) {
|
|
|
- console.log('cacheData',cacheData);
|
|
|
- this.banbenInfo = cacheData;
|
|
|
- this.curProcess = cacheData.curProcess;
|
|
|
- this.danyuanList = cacheData.danyuanList || [];
|
|
|
- this.banbenId = cacheData.banbenId || '';
|
|
|
- this.chanpinId = cacheData.chanpinId || '';
|
|
|
- this.danyuanId = cacheData.danyuanId || '';
|
|
|
- this.dengjiId = cacheData.dengjiId || '';
|
|
|
- },
|
|
|
+ // initFromCache(cacheData) {
|
|
|
+ // console.log('cacheData',cacheData);
|
|
|
+ // this.banbenInfo = cacheData;
|
|
|
+ // this.curProcess = cacheData.curProcess;
|
|
|
+ // this.danyuanList = cacheData.danyuanList || [];
|
|
|
+ // this.banbenId = cacheData.banbenId || '';
|
|
|
+ // this.chanpinId = cacheData.chanpinId || '';
|
|
|
+ // this.danyuanId = cacheData.danyuanId || '';
|
|
|
+ // this.dengjiId = cacheData.dengjiId || '';
|
|
|
+ // },
|
|
|
|
|
|
// 从参数初始化方法
|
|
|
initFromOptions(options) {
|
|
|
- console.log('options',options);
|
|
|
+ console.log('options', options);
|
|
|
this.chanpinId = options.chanpinId;
|
|
|
this.danyuanId = options.danyuanId;
|
|
|
this.banbenId = options.banbenId;
|
|
|
@@ -164,7 +162,7 @@
|
|
|
// 从缓存更新数据方法
|
|
|
updateFromCache() {
|
|
|
const cacheData = cacheManager.get('xuexi-shuxue');
|
|
|
- console.log('cacheData 从缓存更新数据方法',cacheData);
|
|
|
+ console.log('cacheData 从缓存更新数据方法', cacheData);
|
|
|
if (cacheData) {
|
|
|
this.banbenInfo = {
|
|
|
...cacheData
|
|
|
@@ -173,7 +171,7 @@
|
|
|
this.danyuanList = [...(cacheData.danyuanList || [])];
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
+
|
|
|
shouldUseCache(options, cacheData) {
|
|
|
if (options.banbenId && cacheData.banbenId === options.banbenId) {
|
|
|
return true;
|
|
|
@@ -182,6 +180,9 @@
|
|
|
},
|
|
|
// 改成了
|
|
|
loadDataFromApi() {
|
|
|
+ this.banbenInfo = {}
|
|
|
+ this.curProcess = ''
|
|
|
+ this.danyuanList = []
|
|
|
const req = {
|
|
|
banbenId: this.banbenId
|
|
|
}
|