首页+我的

This commit is contained in:
2024-04-19 10:35:20 +08:00
parent 1bcb13ce7a
commit 8407d51fb6
538 changed files with 934456 additions and 1635 deletions

331
App.vue
View File

@@ -1,77 +1,231 @@
<script>
import {
mapMutations
} from 'vuex'
import {
version
} from './package.json'
import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
// import {
// mapMutations
// } from 'vuex'
// import {
// version
// } from './package.json'
// import checkUpdate from '@/uni_modules/uni-upgrade-center-app/utils/check-update';
import { music, bgm } from "@/utils/music.js";
import store from "@/store/index.js";
import socket from "@/config/socket";
// #ifdef H5
import { h5Login } from "@/config/html5Utils";
// #endif
// // #ifdef APP-PLUS
// import APPUpdate from '@/uni_modules/zhouWei-APPUpdate/js_sdk/appUpdate';
// // #endif
// #ifdef APP-PLUS
import updata from "@/uni_modules/uni-upgrade-center-app/utils/check-update";
// #endif
import Vue from "vue";
export default {
onLaunch: function () {
// #ifdef H5
console.log(
`%c hello uniapp %c v${version} `,
'background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff',
'background:#007aff ;padding: 1px; border-radius: 0 3px 3px 0; color: #fff; font-weight: bold;'
)
// #endif
// 线上示例使用
// console.log('%c uni-app官方团队诚邀优秀前端工程师加盟一起打造更卓越的uni-app & uniCloud欢迎投递简历到 hr2013@dcloud.io', 'color: red');
console.log('App Launch');
// #ifdef APP-PLUS
// App平台检测升级服务端代码是通过uniCloud的云函数实现的详情可参考https://ext.dcloud.net.cn/plugin?id=4542
if (plus.runtime.appid !== 'HBuilder') { // 真机运行不需要检查更新真机运行时appid固定为'HBuilder'这是调试基座的appid
checkUpdate()
}
data() {
return {
platform: null, // 系统
};
},
onLaunch: function (e) {
// 检测自动更新
// #ifdef APP-PLUS
updata();
// #endif
// 一键登录预登陆,可以显著提高登录速度
uni.preLogin({
provider: 'univerify',
success: (res) => {
// 成功
this.setUniverifyErrorMsg();
console.log("preLogin success: ", res);
},
fail: (res) => {
this.setUniverifyLogin(false);
this.setUniverifyErrorMsg(res.errMsg);
// 失败
console.log("preLogin fail res: ", res);
}
})
// #endif
},
onShow: function () {
console.log('App Show')
},
onHide: function () {
console.log('App Hide')
},
globalData: {
test: ''
},
methods: {
...mapMutations(['setUniverifyErrorMsg', 'setUniverifyLogin'])
}
}
uni.getSystemInfo({
success(res) {
Vue.prototype.winWidth = res.screenWidth;
Vue.prototype.winHeight = res.screenHeight;
Vue.prototype.statusBarHeight = res.statusBarHeight;
},
});
// 取出初始播放信息
uni.getStorage({
key: "playingInfo",
success: function (res) {
console.log(res, "playingInfo本地初始化");
store.commit("setUserInfo", {
playingInfo: res.data,
});
store.commit("setUserInfo", {
playTitle: res.data.chapter,
fengImg: res.data.bookImage,
});
console.log(store.state.userInfo, "初始化");
},
fail: function (e) {
console.log(e, "playingInfo本地初始化失败");
store.commit("setUserInfo", {
playingInfo: {
images: "../../static/icon/fengziIcon.jpg",
chapterName: "暂无播放信息",
},
});
store.commit("setUserInfo", {
playTitle: "暂无播放信息",
fengImg: "../../static/icon/fengziIcon.jpg",
});
},
});
// 取出播放列表
uni.getStorage({
key: "playData",
success: function (res) {
// 本地有播放数据就用本地的
console.log(res.data, "取出的本地数据");
if (res.data.myList.length <= 0) {
store.commit("setUserInfo", {
playVisible: false,
});
} else {
music.setList(res.data.myList, "", store.state.userInfo.playIndex);
// music.setCoverImg(res.data.fengImg)
store.commit("setUserInfo", res.data);
}
store.commit("setUserInfo", {
playFlag: false,
}); // 设置播放按钮状态为暂停
store.commit("setUserInfo", {
currentTime: 0,
});
},
fail: function (e) {
// 如果没有,就查询一下线上的播放记录
console.log("本地无数据");
music.setList([]);
//store.commit('setUserInfo',{'playingInfo': {'bookid':0,'chapterId':0}});
store.commit("setUserInfo", {
playVisible: false,
});
store.commit("setUserInfo", {
myList: [],
fengImg: "../../static/icon/fengziIcon.jpg",
});
store.commit("setUserInfo", {
playFlag: false,
});
store.commit("setUserInfo", {
currentTime: 0,
});
},
});
// end
// 取出播放弹窗显示或者隐藏
uni.getStorage({
key: "playVisible",
success: function (res) {
store.commit("setUserInfo", {
playVisible: res.data,
}); // 设置是否显示按钮
},
fail: function (e) {
// 如果本地没有playVisible数据默认为false
store.commit("setUserInfo", {
playVisible: false,
});
},
});
//取出缓存数据
store.commit("setCacheData");
// #ifdef MP-WEIXIN
if (store.state.userInfo.token) {
socket.init();
}
// #endif
// #ifdef H5
console.log(store.state);
if (store.state.userInfo.token) {
socket.init();
} else {
h5Login("force", () => {
socket.init();
});
}
// #endif
// #ifdef APP-PLUS
if (store.state.userInfo.token) {
socket.init();
}
// APPUpdate();
// #endif
},
onShow: function (e) {
// #ifdef MP-WEIXIN
//获取二维码携带的参数
let scene = decodeURIComponent(e.query.scene);
scene = scene.split("&");
let data = {
//场景值
scene: e.scene,
};
scene.forEach((item) => {
let arr = item.split("=");
if (arr.length == 2) {
data[arr[0]] = arr[1];
}
});
store.commit("setChatScenesInfo", Object.assign(e.query, data));
//小程序更新
if (uni.getUpdateManager) {
const updateManager = uni.getUpdateManager();
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
// console.log(res.hasUpdate);
});
updateManager.onUpdateReady(function (res) {
uni.showModal({
title: "更新提示",
content: "新版本已经准备好,是否重启应用?",
success(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate();
}
},
});
});
updateManager.onUpdateFailed(function (res) {
// 新的版本下载失败
uni.showModal({
title: "已经有新版本了哟~",
content: "新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~",
showCancel: false,
});
});
}
// #endif
},
onHide: function () {},
destroyed() {
store.commit("setUserInfo", {
playFlag: true,
});
console.log("页面销毁");
},
globalData: {
test: "",
},
methods: {
// ...mapMutations(['setUniverifyErrorMsg', 'setUniverifyLogin'])
},
};
</script>
<style lang="scss">
@import "@/uni_modules/uview-ui/index.scss";
@import '@/uni_modules/uni-scss/index.scss';
@import "@/uni_modules/uni-scss/index.scss";
/* #ifndef APP-PLUS-NVUE */
/* uni.css - 通用组件、模板样式库可以当作一套ui库应用 */
@import './common/uni.css';
@import '@/static/customicons.css';
@import '@/style/common.scss';
@import "./common/uni.css";
@import "@/static/customicons.css";
@import "@/style/common.scss";
/* H5 兼容 pc 所需 */
/* #ifdef H5 */
@media screen and (min-width: 768px) {
body {
overflow-y: scroll;
}
body {
overflow-y: scroll;
}
}
/* 顶栏通栏样式 */
@@ -80,60 +234,61 @@ export default {
right: 0;
} */
uni-page-body {
background-color: #F5F5F5 !important;
min-height: 100% !important;
height: auto !important;
/deep/uni-page-body {
// background-color: #F5F5F5 !important;
background-color: #d8f8e4 !important;
min-height: 100% !important;
height: 100% !important;
}
.uni-top-window uni-tabbar .uni-tabbar {
background-color: #fff !important;
background-color: #fff !important;
}
.uni-app--showleftwindow .hideOnPc {
display: none !important;
display: none !important;
}
/* #endif */
/* 以下样式用于 hello uni-app 演示所需 */
page {
background-color: #efeff4;
height: 100%;
font-size: 28rpx;
/* line-height: 1.8; */
background-color: #efeff4;
height: 100%;
font-size: 28rpx;
/* line-height: 1.8; */
}
.fix-pc-padding {
padding: 0 50px;
padding: 0 50px;
}
.uni-header-logo {
padding: 30rpx;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 10rpx;
padding: 30rpx;
flex-direction: column;
justify-content: center;
align-items: center;
margin-top: 10rpx;
}
.uni-header-image {
width: 100px;
height: 100px;
width: 100px;
height: 100px;
}
.uni-hello-text {
color: #7A7E83;
color: #7a7e83;
}
.uni-hello-addfile {
text-align: center;
line-height: 300rpx;
background: #FFF;
padding: 50rpx;
margin-top: 10px;
font-size: 38rpx;
color: #808080;
text-align: center;
line-height: 300rpx;
background: #fff;
padding: 50rpx;
margin-top: 10px;
font-size: 38rpx;
color: #808080;
}
/* #endif*/
</style>
</style>