This commit is contained in:
GaoHao
2024-12-30 19:30:25 +08:00
9 changed files with 211 additions and 113 deletions

View File

@@ -1,8 +1,13 @@
import configdata from './config' import configdata from './config'
import cache from './cache' import cache from './cache'
import { import {
cacheClearAll cacheClearAll,cacheClear
} from '@/store/cashe.js' } from '@/store/cashe.js'
function successCallBack(url){
if(url.includes('app/courseCollect/insertCourseCollect')){
cacheClear('chasingDrama')
}
}
module.exports = { module.exports = {
config: function(name) { config: function(name) {
var info = null; var info = null;
@@ -151,7 +156,11 @@ module.exports = {
success: function(result) { success: function(result) {
if (result.data.code == 401) { if (result.data.code == 401) {
that.logout(); that.logout();
}else{
successCallBack(url)
// cacheClear('chasingDrama')
} }
succ.call(self, result.data) succ.call(self, result.data)
}, },
fail: function(e) { fail: function(e) {

View File

@@ -25,6 +25,10 @@
<view>注销账号</view> <view>注销账号</view>
<view><u-icon name="arrow-right"></u-icon></view> <view><u-icon name="arrow-right"></u-icon></view>
</view> </view>
<!-- <view class="flex justify-between padding bg-white solid-bottom" @click="clearCache">
<view>清除缓存</view>
<view>{{cacheSize}}</view>
</view> -->
<view class="flex justify-between padding bg-white solid-bottom" @click="loginOut"> <view class="flex justify-between padding bg-white solid-bottom" @click="loginOut">
<view>退出登录</view> <view>退出登录</view>
<view><u-icon name="arrow-right"></u-icon></view> <view><u-icon name="arrow-right"></u-icon></view>
@@ -39,6 +43,7 @@
data() { data() {
return { return {
version: null, version: null,
cacheSize:'0M'
} }
}, },
onLoad() { onLoad() {
@@ -54,8 +59,30 @@
// console.log(widgetInfo) // console.log(widgetInfo)
// this.version = widgetInfo.version // this.version = widgetInfo.version
// }) // })
const info= uni.getStorageInfoSync()
console.log(info);
const size=(info.currentSize/1024).toFixed(2)
this.cacheSize=size<1?(info.currentSize+'kb'):(size) +'M'
},
onShow() {
}, },
methods: { methods: {
clearCache(){
uni.showModal({
title:'提示',
content:`是否清除全部缓存
`,
success(res) {
if(res.confirm){
cacheClearAll()
const info= uni.getStorageInfoSync()
info.keys.map(v=>{
console.log(v);
})
}
}
})
},
goNav(e) { goNav(e) {
uni.navigateTo({ uni.navigateTo({
url: e url: e

View File

@@ -107,8 +107,7 @@
"navigationBarTitleText": "我的", "navigationBarTitleText": "我的",
"navigationStyle": "custom" "navigationStyle": "custom"
// #ifdef H5 // #ifdef H5
, ,"enablePullDownRefresh": true
"enablePullDownRefresh": true
// #endif // #endif
} }
}, },

View File

@@ -113,7 +113,8 @@
</template> </template>
<script> <script>
import { $cache_chasingDrama} from '@/store/cashe.js' import { isEmpty } from '../../utils/util';
import { $cache_chasingDrama} from '@/store/cashe.js'
export default { export default {
data() { data() {
return { return {
@@ -155,6 +156,12 @@
let data = { let data = {
userId: uni.getStorageSync('userId') userId: uni.getStorageSync('userId')
} }
if(!isEmpty($cache_chasingDrama.day)&&!isEmpty($cache_chasingDrama.isQd)&&!isEmpty($cache_chasingDrama.isErQd)){
this.day=$cache_chasingDrama.day
this.isQd=$cache_chasingDrama.isQd
this.isErQd=$cache_chasingDrama.isErQd
return
}
this.$Request.getT('/app/integral/selectIntegralDay', data).then(res => { this.$Request.getT('/app/integral/selectIntegralDay', data).then(res => {
if (res.code == 0) { if (res.code == 0) {
if (res.data.nowIntegral) { //判断今天是否签到 if (res.data.nowIntegral) { //判断今天是否签到
@@ -202,6 +209,10 @@
limit: 6, limit: 6,
classify: 1, //1收藏 2点赞 3历史记录 classify: 1, //1收藏 2点赞 3历史记录
} }
if($cache_chasingDrama.zhuiju){
this.zhuiju = $cache_chasingDrama.zhuiju
return
}
this.$Request.getT('/app/courseCollect/selectByUserId', data).then(res => { this.$Request.getT('/app/courseCollect/selectByUserId', data).then(res => {
if (res.code == 0) { if (res.code == 0) {
this.zhuiju = res.data.records this.zhuiju = res.data.records
@@ -216,6 +227,10 @@
limit: 6, limit: 6,
classify: 3, //1收藏 2点赞 3历史记录 classify: 3, //1收藏 2点赞 3历史记录
} }
if($cache_chasingDrama.list){
this.list=$cache_chasingDrama.list
return
}
this.$Request.getT('/app/courseCollect/selectByUserId', data).then(res => { this.$Request.getT('/app/courseCollect/selectByUserId', data).then(res => {
if (res.code == 0) { if (res.code == 0) {
this.list = res.data.records this.list = res.data.records

View File

@@ -210,7 +210,13 @@
import activityComp from '../../components/activityComp/activityComp.vue' import activityComp from '../../components/activityComp/activityComp.vue'
import dragButton from "@/components/drag-button/drag-button.vue"; import dragButton from "@/components/drag-button/drag-button.vue";
import httpsRequest from '../../common/httpRequest.js' import httpsRequest from '../../common/httpRequest.js'
import {$cache_index} from '@/store/cashe.js' import {
$cache_index
} from '@/store/cashe.js'
import {
$cache_config
} from '@/store/cashe.js'
console.log($cache_index)
export default { export default {
components: { components: {
videoList, videoList,
@@ -338,13 +344,8 @@
uni.setStorageSync('qdCodeion', options.qdCode) uni.setStorageSync('qdCodeion', options.qdCode)
} }
if (uni.getStorageSync('token')) { if (uni.getStorageSync('token')) {
this.$u.get('/app/common/type/813').then(res => { this.zhuliInit()
if (res.code == 0 && res.data.value) {
if (res.data.value == '是') {
this.getActivity()
}
}
})
} }
let u = navigator ? navigator.userAgent : ''; let u = navigator ? navigator.userAgent : '';
@@ -363,13 +364,13 @@
//本周热门 //本周热门
this.getrecomVideo('2') this.getrecomVideo('2')
//本周排行榜 //本周排行榜
setTimeout(()=>{ setTimeout(() => {
this.getrecomVideo('1') this.getrecomVideo('1')
},100) }, 100)
//最新 //最新
setTimeout(()=>{ setTimeout(() => {
this.getrecomVideo('') this.getrecomVideo('')
},200) }, 200)
this.getBannerList() this.getBannerList()
this.getMsg() this.getMsg()
this.getGardList() this.getGardList()
@@ -377,63 +378,29 @@
this.getCourseList() this.getCourseList()
this.homeTypeSel = uni.getStorageSync('homeTypeSel') ? uni.getStorageSync('homeTypeSel') : '否' this.homeTypeSel = uni.getStorageSync('homeTypeSel') ? uni.getStorageSync('homeTypeSel') : '否'
//#ifdef H5 //#ifdef H5
let that = this let that=this;
this.$u.get('/app/common/type/108').then(res => { //// 是否开启公众号自动登陆 108 if($cache_config.isGongZhongHaoAutoLogin!==null&&$cache_config.isGongZhongHaoAutoLogin!==undefined){
if (res.code == 0 && res.data) { if($cache_config.isGongZhongHaoAutoLogin=='是'){
if (res.data.value == '是') { that.wxWebInit()
let ua = navigator.userAgent.toLowerCase(); }
if (ua.indexOf('micromessenger') !== -1) {
let openid = uni.getStorageSync('openId'); }else{
let userId = uni.getStorageSync('userId'); this.$u.get('/app/common/type/108').then(res => { //// 是否开启公众号自动登陆 108
if (userId) { if (res.code == 0 && res.data) {
if (!openid) { $cache_config.set('isGongZhongHaoAutoLogin',res.data)
if (window.location.href.indexOf('?code=') !== -1 || window.location.href if (res.data.value == '是') {
.indexOf( that.wxWebInit()
'&code=') !==
-1) {
let code;
if (window.location.href.indexOf('?code=') !== -1) {
code = window.location.href.split('?code=')[1].split('&')[0];
} else {
code = window.location.href.split('&code=')[1].split('&')[0];
}
if (userId) {
that.$u.get('/app/user/openId/' + code + '/' + userId).then(
res => {
uni.setStorageSync('openId', res.data)
});
}
} else {
window.location.href =
'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
that.$queue.getWxAppid() +
'&redirect_uri=' +
window.location.href.split('#')[0] +
'&response_type=code&scope=snsapi_userinfo#wechat_redirect';
}
}
}
} }
} }
} });
}); }
//#endif //#endif
if (uni.getStorageSync('token')) { if (uni.getStorageSync('token')) {
this.getMyLoveVideo() this.getMyLoveVideo()
this.$u.get('/app/common/type/813').then(res => {
if (res.code == 0 && res.data.value) {
if (res.data.value == '是') {
this.getActivitys()
}
}
})
//新用户红包 837 //新用户红包 837
this.$u.get('/app/common/type/837').then(res => { this.newUserRedInit()
if (res.code == 0 && res.data.value) {
this.xxJDNum = res.data.value;
this.checkNewUser()
}
})
} else { //没有登录隐藏悬浮与弹窗 } else { //没有登录隐藏悬浮与弹窗
this.showzl = false this.showzl = false
this.shodrag = false this.shodrag = false
@@ -449,7 +416,7 @@
} }
}); });
// #endif // #endif
}, },
onReachBottom() { onReachBottom() {
if (this.page < this.pages) { if (this.page < this.pages) {
@@ -466,6 +433,78 @@
this.getCourseList() this.getCourseList()
}, },
methods: { methods: {
//新用户红包 837
newUserRedInit(){
if($cache_config.isNewUserRedPack!==null&&$cache_config.isNewUserRedPack!==undefined){
if($cache_config.isNewUserRedPack){
this.xxJDNum = $cache_config.isNewUserRedPack;
this.checkNewUser()
}
return
}
this.$u.get('/app/common/type/837').then(res => {
$cache_config.set('isNewUserRedPack',res.data.value)
if (res.code == 0 && res.data.value) {
this.xxJDNum = res.data.value;
this.checkNewUser()
}
})
},
zhuliInit(){
if($cache_config.isOpenZhuLi!==null&&$cache_config.isOpenZhuLi!==undefined){
if($cache_config.isOpenZhuLi=='是'){
this.getActivity()
}
}else{
this.$u.get('/app/common/type/813').then(res => {
if (res.code == 0 && res.data.value) {
$cache_config.set('isOpenZhuLi',res.data.value)
if (res.data.value == '是') {
this.getActivity()
}
}
})
}
},
//处于微信公众号时的处理
wxWebInit() {
let that = this;
let ua = navigator.userAgent.toLowerCase();
if (ua.indexOf('micromessenger') !== -1) {
let openid = uni.getStorageSync('openId');
let userId = uni.getStorageSync('userId');
if (userId) {
if (!openid) {
if (window.location.href.indexOf('?code=') !== -1 || window.location.href
.indexOf(
'&code=') !==
-1) {
let code;
if (window.location.href.indexOf('?code=') !== -1) {
code = window.location.href.split('?code=')[1].split('&')[0];
} else {
code = window.location.href.split('&code=')[1].split('&')[0];
}
if (userId) {
that.$u.get('/app/user/openId/' + code + '/' + userId).then(
res => {
uni.setStorageSync('openId', res.data)
});
}
} else {
window.location.href =
'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' +
that.$queue.getWxAppid() +
'&redirect_uri=' +
window.location.href.split('#')[0] +
'&response_type=code&scope=snsapi_userinfo#wechat_redirect';
}
}
}
}
},
// 获取活动等级 // 获取活动等级
getActivitys() { getActivitys() {
this.$Request.getT('/app/invite/selectInviteAwardByUserId').then(res => { this.$Request.getT('/app/invite/selectInviteAwardByUserId').then(res => {
@@ -501,9 +540,15 @@
limit: 1, limit: 1,
classify: 1 classify: 1
} }
if($cache_index.videoInfo){
this.videoInfo = $cache_index.videoInfo||[]
this.shodrag = this.videoInfo.length>0
return
}
this.$Request.getT('/app/courseCollect/selectByUserId', data).then(res => { this.$Request.getT('/app/courseCollect/selectByUserId', data).then(res => {
if (res.code == 0) { if (res.code == 0) {
this.videoInfo = res.data.records this.videoInfo = res.data.records
$cache_index.set('videoInfo',this.videoInfo)
if (this.videoInfo.length > 0) { if (this.videoInfo.length > 0) {
this.shodrag = true this.shodrag = true
} }
@@ -619,38 +664,38 @@
// #ifdef MP-TOUTIAO // #ifdef MP-TOUTIAO
data.dyShow = 1 data.dyShow = 1
// #endif // #endif
if(sort==2&&$cache_index.rmVideList){ if (sort == 2 && $cache_index.rmVideList) {
this.rmVideList = $cache_index.rmVideList this.rmVideList = $cache_index.rmVideList
return return
} }
if(sort==1&&$cache_index.phbVideoList){ if (sort == 1 && $cache_index.phbVideoList) {
this.phbVideoList = $cache_index.phbVideoList this.phbVideoList = $cache_index.phbVideoList
return return
} }
if(!sort&&$cache_index.newVideList){ if (!sort && $cache_index.newVideList) {
this.newVideList = $cache_index.newVideList this.newVideList = $cache_index.newVideList
return return
} }
console.log('请求服务器 获取推荐视频') console.log('请求服务器 获取推荐视频')
this.$Request.getT('/app/course/selectCourse', data).then(res => { this.$Request.getT('/app/course/selectCourse', data).then(res => {
if (res.code == 0) { if (res.code == 0) {
if (Number(sort) == 2) { //本周热门 if (Number(sort) == 2) { //本周热门
this.rmVideList = res.data.list this.rmVideList = res.data.list
$cache_index.set('rmVideList',this.rmVideList) $cache_index.set('rmVideList', this.rmVideList)
} else if (Number(sort) == 1) { //本周排行榜 } else if (Number(sort) == 1) { //本周排行榜
this.phbVideoList = res.data.list this.phbVideoList = res.data.list
$cache_index.set('phbVideoList',this.phbVideoList) $cache_index.set('phbVideoList', this.phbVideoList)
} else { //最新热播 } else { //最新热播
this.newVideList = res.data.list this.newVideList = res.data.list
$cache_index.set('newVideList',this.newVideList) $cache_index.set('newVideList', this.newVideList)
} }
} }
}) })
}, },
getTypeList() { getTypeList() {
if($cache_index.typeList){ if ($cache_index.typeList) {
this.typeList=$cache_index.typeList this.typeList = $cache_index.typeList
return return
} }
console.log('请求服务器 getTypeList') console.log('请求服务器 getTypeList')
this.$Request.getT('/app/courseClassification/queryClassification').then(res => { this.$Request.getT('/app/courseClassification/queryClassification').then(res => {
@@ -664,9 +709,9 @@
// res.data.forEach(d => { // res.data.forEach(d => {
// this.typeList.push(d); // this.typeList.push(d);
// }); // });
this.typeList=[fenlei,...res.data] this.typeList = [fenlei, ...res.data]
$cache_index.set('typeList',this.typeList) $cache_index.set('typeList', this.typeList)
// console.log(JSON.stringify(this.typeList)) // console.log(JSON.stringify(this.typeList))
} }
}); });
@@ -733,19 +778,19 @@
}, },
//获取背景图 //获取背景图
getBgImg() { getBgImg() {
const bgImg=$cache_index.bgImg const bgImg = $cache_index.bgImg
const tuiguang=$cache_index.tuiguang const tuiguang = $cache_index.tuiguang
if(bgImg&&tuiguang){ if (bgImg && tuiguang) {
this.bgImg = bgImg this.bgImg = bgImg
this.tuiguang = tuiguang this.tuiguang = tuiguang
return return
} }
this.$u.get('app/banner/selectBannerList?classify=5').then(res => { this.$u.get('app/banner/selectBannerList?classify=5').then(res => {
if (res.code == 0) { if (res.code == 0) {
this.bgImg = res.data[0].imageUrl this.bgImg = res.data[0].imageUrl
this.tuiguang = res.data[0].describes this.tuiguang = res.data[0].describes
$cache_index.set('bgImg',res.data[0].imageUrl) $cache_index.set('bgImg', res.data[0].imageUrl)
$cache_index.set('tuiguang',res.data[0].describes) $cache_index.set('tuiguang', res.data[0].describes)
} else { } else {
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,
@@ -774,13 +819,13 @@
// #ifdef MP-TOUTIAO // #ifdef MP-TOUTIAO
data.dyShow = 1 data.dyShow = 1
// #endif // #endif
if($cache_index.courseList&&this.page==1){ if ($cache_index.courseList && this.page == 1) {
this.courseList=$cache_index.courseList this.courseList = $cache_index.courseList
uni.stopPullDownRefresh() uni.stopPullDownRefresh()
return return
} }
this.$Request.getT('/app/course/selectCourse', data).then(res => { this.$Request.getT('/app/course/selectCourse', data).then(res => {
if (res.code == 0) { if (res.code == 0) {
this.pages = res.data.totalPage this.pages = res.data.totalPage
@@ -791,7 +836,7 @@
} }
if (this.page == 1) { if (this.page == 1) {
this.courseList = res.data.list this.courseList = res.data.list
$cache_index.set('courseList',res.data.list) $cache_index.set('courseList', res.data.list)
} else { } else {
this.courseList = [...this.courseList, ...res.data.list] this.courseList = [...this.courseList, ...res.data.list]
} }
@@ -844,9 +889,9 @@
}, },
// 获取金刚区列表 // 获取金刚区列表
getGardList() { getGardList() {
if($cache_index.gridList){ if ($cache_index.gridList) {
this.gridList=$cache_index.gridList this.gridList = $cache_index.gridList
return return
} }
this.$u.api.bannerList({ this.$u.api.bannerList({
classify: '2', classify: '2',
@@ -859,7 +904,7 @@
} }
}) })
this.gridList = this.processArray(arr) this.gridList = this.processArray(arr)
$cache_index.set('gridList',this.gridList) $cache_index.set('gridList', this.gridList)
} else { } else {
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,
@@ -954,9 +999,9 @@
}, },
// 获取轮播图列表 // 获取轮播图列表
getBannerList() { getBannerList() {
if($cache_index.swiperList){ if ($cache_index.swiperList) {
this.swiperList=$cache_index.swiperList this.swiperList = $cache_index.swiperList
return return
} }
this.$u.api.bannerList({ this.$u.api.bannerList({
classify: '1' classify: '1'
@@ -967,7 +1012,7 @@
this.swiperList.push(d) this.swiperList.push(d)
} }
}) })
$cache_index.set('swiperList',this.swiperList) $cache_index.set('swiperList', this.swiperList)
} else { } else {
uni.showToast({ uni.showToast({
title: res.msg, title: res.msg,

View File

@@ -161,7 +161,7 @@
title: '上传中...' title: '上传中...'
}); });
uni.uploadFile({ uni.uploadFile({
url: configdata.APIHOST + '/alioss/upload', url: configdata.APIHOST + 'alioss/upload',
// url: 'https://jiaoyu.xianmxkj.com/sqx_fast/alioss/upload', //仅为示例,非真实的接口地址 // url: 'https://jiaoyu.xianmxkj.com/sqx_fast/alioss/upload', //仅为示例,非真实的接口地址
filePath: e.detail.avatarUrl, filePath: e.detail.avatarUrl,
// filePath: res.tempFilePaths[0], // filePath: res.tempFilePaths[0],
@@ -214,7 +214,7 @@
let token = uni.getStorageSync('token'); let token = uni.getStorageSync('token');
let userId = uni.getStorageSync('userId'); let userId = uni.getStorageSync('userId');
uni.uploadFile({ uni.uploadFile({
url: configdata.APIHOST + '/alioss/upload', url: configdata.APIHOST + 'alioss/upload',
// url: 'https://jiaoyu.xianmxkj.com/sqx_fast/alioss/upload', //仅为示例,非真实的接口地址 // url: 'https://jiaoyu.xianmxkj.com/sqx_fast/alioss/upload', //仅为示例,非真实的接口地址
filePath: res.tempFilePaths[0], filePath: res.tempFilePaths[0],
name: 'file', name: 'file',

View File

@@ -99,6 +99,9 @@
<script> <script>
import {$cache_renwu} from '@/store/cashe.js' import {$cache_renwu} from '@/store/cashe.js'
import {isEmpty} from '@/utils/util.js'
export default { export default {
data() { data() {
@@ -202,7 +205,7 @@
* 获取签到数据 * 获取签到数据
*/ */
getsignIn() { getsignIn() {
if($cache_renwu.signInList&&$cache_renwu.signDays&&$cache_renwu.enable){ if($cache_renwu.signInList&&!isEmpty($cache_renwu.signDays)&&!isEmpty($cache_renwu.enable) ){
this.signInList =$cache_renwu.signInList this.signInList =$cache_renwu.signInList
this.signDays =$cache_renwu.signDays this.signDays =$cache_renwu.signDays
this.enable =$cache_renwu.enable this.enable =$cache_renwu.enable
@@ -366,6 +369,7 @@
onPullDownRefresh: function() { onPullDownRefresh: function() {
console.log(2) console.log(2)
$cache_renwu.clear() $cache_renwu.clear()
this.getsignIn()
this.getTaskdata(); this.getTaskdata();
}, },

View File

@@ -113,13 +113,9 @@ const $cache={
config:$cache_config config:$cache_config
} }
export function cacheClearAll() { export function cacheClearAll() {
console.log($cache_index); for(let i in $cache){
$cache_index.clear() $cache[i].clear()
$cache_video.clear() }
$cache_renwu.clear()
$cache_chasingDrama.clear()
$cache_user.clear()
$cache_config.clear()
} }
export function cacheClear(arr){ export function cacheClear(arr){
if(typeof arr==='string'&&$cache[arr]){ if(typeof arr==='string'&&$cache[arr]){

3
utils/util.js Normal file
View File

@@ -0,0 +1,3 @@
export function isEmpty(val){
return val===null||val===undefined||val===''
}