lion 2 years ago
parent af3979d5b2
commit 96211fb16e

@ -9,7 +9,6 @@
// this.$u.api.login({
// code: res.code
// }).then(res => {
// this.$u.vuex('vuex_token', res.token)
// this.$u.api.user().then(res=>{
// this.$u.vuex('vuex_user', res)
// })

@ -39,12 +39,59 @@ const install = (Vue, vm) => {
if (res.statusCode === 200) {
if (res.data.hasOwnProperty("errcode")) {
if (res.data?.errcode === 40001) {
setTimeout(() => {
let origin = window.location.origin;
let pathname = window.location.pathname;
window.location.href = origin + pathname;
}, 1500)
uni.showModal({
title:'用户信息已失效',
confirmText:'重新获取',
success:function(res){
if(res.confirm){
console.log("res",res)
uni.removeStorageSync('xtykt_lifeData')
uni.login({
provider: 'weixin',
success: (res1) => {
uni.request({
url:baseUrl+'/api/mobile/user/wechat-login',
data:{
code:res1.code,
activity_tag : 'xtykt',
activity_list_id : 12
},
method: 'GET',
success: res2 => {uni.setStorageSync('xtykt_lifeData',{'vuex_token':res2.data.token})
const currentPage = getCurrentPages()[getCurrentPages().length - 1];
const currentPagePath ="/" + currentPage.route;
const currentPageOptions = currentPage.options;
const queryString = Object.keys(currentPageOptions)
.map(key => `${key}=${currentPageOptions[key]}`)
.join('&');
// 使用uni.reLaunch方法刷新当前页面
uni.reLaunch({
url: `${currentPagePath}?${queryString}`
});
console.log("reLaunch",`${currentPagePath}?${queryString}`)
},
fail: (res3) => {
console.log("err",res3)
}
});
},
fail: (res4) => {
console.log("err",res4)
}
});
// login end
}
}
}) // showConfirm end
return
// setTimeout(() => {
// let origin = window.location.origin;
// let pathname = window.location.pathname;
// window.location.href = origin + pathname;
// }, 1500)
} else {
uni.showToast({
icon: "none",

@ -0,0 +1,202 @@
<template>
<view v-if="showPrivacy" :class="privacyClass">
<view :class="contentClass">
<view class="title">隐私保护指引</view>
<view class="des">
感谢选择我们的小程序我们非常重视您的个人信息安全和隐私保护根据最新法律要求使用我们的产品前请仔细阅读<text class="link"
@tap="openPrivacyContract">{{privacyContractName}}
</text>以便我们向您提供更优质的服务<br />我们将尽全力保护您的个人信息及合法权益感谢您的信任
<br />
</view>
<view class="btns">
<button class="item reject" @tap="exitMiniProgram"></button>
<button id="agree-btn" class="item agree" open-type="agreePrivacyAuthorization"
@agreeprivacyauthorization="handleAgreePrivacyAuthorization">同意</button>
</view>
</view>
</view>
</template>
<script>
export default {
name: 'PrivacyPopup',
data() {
return {
privacyContractName: '',
showPrivacy: false,
isRead: false,
resolvePrivacyAuthorization: null,
};
},
props: {
position: {
type: String,
default: 'center'
}
},
computed: {
privacyClass() {
return this.position === 'bottom' ? 'privacy privacy-bottom' : 'privacy';
},
contentClass() {
return this.position === 'bottom' ? 'content content-bottom' : 'content';
}
},
mounted() {
console.log("123",wx.getPrivacySetting)
if (wx.onNeedPrivacyAuthorization) {
wx.onNeedPrivacyAuthorization((resolve) => {
this.resolvePrivacyAuthorization = resolve;
});
}
if (wx.getPrivacySetting) {
wx.getPrivacySetting({
success: (res) => {
console.log(res, 'getPrivacySetting');
if (res.needAuthorization) {
this.privacyContractName = res.privacyContractName;
this.showPrivacy = true;
}
},
});
}
},
methods: {
openPrivacyContract() {
wx.openPrivacyContract({
success: () => {
this.isRead = true;
},
fail: () => {
uni.showToast({
title: '遇到错误',
icon: 'error',
});
},
});
},
exitMiniProgram() {
this.$emit('reject-privacy'); //
wx.exitMiniProgram();
},
handleAgreePrivacyAuthorization() {
// if (this.isRead) {
this.showPrivacy = false;
this.$emit('agree-privacy'); //
if (typeof this.resolvePrivacyAuthorization === 'function') {
this.resolvePrivacyAuthorization({
buttonId: 'agree-btn',
event: 'agree',
});
}
// } else {
// uni.showToast({
// title: '',
// icon: 'error',
// });
// }
},
},
};
</script>
<style scoped>
.privacy {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, .5);
z-index: 9999999;
display: flex;
align-items: center;
justify-content: center;
}
.privacy-bottom {
align-items: flex-end;
}
.content {
width: 632rpx;
padding: 48rpx;
box-sizing: border-box;
background: #fff;
border-radius: 16rpx;
}
.content-bottom {
position: absolute;
bottom: 0;
width: 96%;
padding: 36rpx;
padding-bottom: constant(safe-area-inset-bottom);
padding-bottom: env(safe-area-inset-bottom);
border-radius: 16rpx 16rpx 0 0;
}
.content .title {
text-align: center;
color: #333;
font-weight: bold;
font-size: 32rpx;
}
.content .des {
font-size: 26rpx;
color: #666;
margin-top: 40rpx;
text-align: justify;
line-height: 1.6;
}
.content .des .link {
color: #044ed7;
text-decoration: underline;
}
.btns {
margin-top: 48rpx;
margin-bottom: 12rpx;
display: flex;
}
.btns .item {
width: 200rpx;
height: 72rpx;
overflow: visible;
display: flex;
align-items: center;
justify-content: center;
/* border-radius: 16rpx; */
box-sizing: border-box;
border: none !important;
}
.btns .reject {
background: #f4f4f5;
color: #666;
font-size: 14px;
font-weight: 300;
margin-right: 16rpx;
}
.btns .agree {
width: 320rpx;
background: #07c160;
color: #fff;
font-size: 16px;
}
.privacy-bottom .btns .agree {
width: 440rpx;
}
</style>

@ -4,23 +4,26 @@
<!-- 状态栏占位 -->
<view class="statusBar" :style="{paddingTop: navBarTop+'px'}"></view>
<!-- 真正的导航栏内容 -->
<view class="navBar" :style="{'height':navBarHeight+'px','line-height':navBarHeight+'px'}">
<view class="navBar" :style="{'height':navBarHeight+'px','line-height':navBarHeight+'px'}">
<view>斜塘街道基层党员冬训</view>
</view>
</view>
<view class="content">
<!-- #ifdef MP-WEIXIN -->
<!-- <privacy-popup ref="privacyComponent" @agree-privacy="onAgreePrivacy"
@reject-privacy="onRejectPrivacy"></privacy-popup> -->
<!-- #endif -->
<view class="topbg">
<image class="topbg" :src="require('@/static/index-top.png')"></image>
</view>
<view :style="{'margin-top':bannerTop+'rpx'}">
<image class="banner" src="https://vr.langye.net/images/index-banner.png"></image>
</view>
<view class="content-content">
<view class="icons">
<block v-for="(item,index) in iconList">
<image v-if="index<3" :src="item.src" @click="toMenu(item.id)"></image>
<view class="icons">
<block v-for="(item,index) in iconList">
<image v-if="index<3" :src="item.src" @click="toMenu(item.id)"></image>
</block>
</view>
<view class="icons icons-out">
@ -33,29 +36,32 @@
<image class="menus-list-img" :src="item.poster?item.poster:replaceImg"></image>
<view class="menus-list-title">{{item.title}}</view>
</view>
</view>
</view>
<view v-if="hasNomore" class="hasNomore"></view>
</view>
<tabbar :current-page="0"></tabbar>
</view>
</template>
<script>
import tabbar from "../../components/tabbar/tabbar.vue"
import{isNull} from '@/common/util.js'
export default {
components:{
tabbar
<script>
import tabbar from "../../components/tabbar/tabbar.vue"
import {
isNull
} from '@/common/util.js'
import PrivacyPopup from '@/components/privacy-popup/privacy-popup.vue';
export default {
components: {
tabbar,
PrivacyPopup
},
data() {
return {
navBarBoxHeight: 0,
navBarTop: 0,
bannerTop: 0,
navBarHeight:0,
isScroll: false,
bannerTop: 0,
navBarHeight: 0,
isScroll: false,
iconList: [{
id: 6,
src: require("@/static/index-icon1.png"),
@ -81,39 +87,56 @@
url: "https://vr.langye.net/h5xtdt/",
src: require("@/static/index-icon5.png"),
title: '百步芳草 与理同行'
}],
replaceImg:require("@/static/index-img.png"),
menuList:[],
currentPage:1,
hasNomore:false
}],
replaceImg: require("@/static/index-img.png"),
menuList: [],
currentPage: 1,
hasNomore: false,
}
},
onLoad() {
const MenuButton = uni.getMenuButtonBoundingClientRect()
this.navBarTop = MenuButton.top //
this.navBarHeight = MenuButton.height
this.navBarBoxHeight = this.navBarTop + this.navBarHeight + 10
this.bannerTop = this.navBarBoxHeight*2 - 360
// this.getMenu()
this.getToken()
onLoad() {
const MenuButton = uni.getMenuButtonBoundingClientRect()
this.navBarTop = MenuButton.top //
this.navBarHeight = MenuButton.height
this.navBarBoxHeight = this.navBarTop + this.navBarHeight + 10
this.bannerTop = this.navBarBoxHeight * 2 - 360
// this.getMenu()
if (isNull(this.vuex_token)) {
this.getToken()
} else {
this.getMenuList(11, (this.currentPage))
}
},
onPageScroll(e) {
var that = this;
if (e.scrollTop > (this.navBarTop/2)) {
if (e.scrollTop > (this.navBarTop / 2)) {
that.isScroll = true;
} else {
that.isScroll = false;
}
},
onReachBottom() {
if (true)
this.getMenuList(11,(this.currentPage + 1))
},
onReachBottom() {
if (true)
this.getMenuList(11, (this.currentPage + 1))
},
methods: {
onAgreePrivacy() {
//
//
console.log('User agreed to the privacy policy');
this.getToken()
},
onRejectPrivacy() {
//
//
console.log('User rejected the privacy policy');
},
toMenu(id) {
if (id) {
uni.navigateTo({
@ -129,73 +152,77 @@
}
},
toDetail(id) {
if(id){
uni.navigateTo({
url:'/pages/detail/detail?id='+id + '&menuTitle=学习新思想'
})
if (id) {
uni.navigateTo({
url: '/pages/detail/detail?id=' + id + '&menuTitle=学习新思想'
})
}
},
async getToken(){
await uni.login({
provider: 'weixin',
success: (res) => {
console.log(res.code);
this.$u.api.login({
code: res.code
}).then(res => {
},
async getToken() {
await uni.login({
provider: 'weixin',
success: (res) => {
this.$u.api.login({
code: res.code
}).then(res => {
this.$u.vuex('vuex_token', res.token)
this.$u.api.user().then(res=>{
this.$u.vuex('vuex_user', res)
this.getMenuList(11,this.currentPage)
})
})
}
});
},
async getMenu(){
const res = await this.$u.api.baseFormIndex({
page: 1,
page_size: 9999,
table_name: 'study_columns',
})
const parArr = res.data.filter(item=>item.pid===0)
parArr.map(item=>{
this.menuList.map(m=>{
if(item.title===m.title){
m.id = parArr.id
}
})
})
},
async getMenuList(id,currentPage){
uni.showLoading({
title:'加载中'
})
let that = this
const res = await this.$u.api.getAudios({
study_column_id: id,
page:currentPage
})
if(res.data.length===0 && currentPage>0){
uni.stopPullDownRefresh(); // < ,
//
that.hasNomore = true
uni.showToast({
title: '没有更多了',
icon: 'none'
});
return;
}
if (currentPage == 1) {
that.menuList = res.data;
} else {
that.menuList.push(...res.data);
}
that.currentPage = currentPage;
uni.hideLoading()
},
this.$u.api.user().then(res => {
this.$u.vuex('vuex_user', res)
this.getMenuList(11, this.currentPage)
})
}).catch(err=>{
console.log('login-error:',JSON.stringify(err))
})
},
fail: (res) => {
console.log("errtoken", JSON.stringify(res))
}
});
},
async getMenu() {
const res = await this.$u.api.baseFormIndex({
page: 1,
page_size: 9999,
table_name: 'study_columns',
})
const parArr = res.data.filter(item => item.pid === 0)
parArr.map(item => {
this.menuList.map(m => {
if (item.title === m.title) {
m.id = parArr.id
}
})
})
},
async getMenuList(id, currentPage) {
uni.showLoading({
title: '加载中'
})
let that = this
const res = await this.$u.api.getAudios({
study_column_id: id,
page: currentPage
})
if (res.data.length === 0 && currentPage > 0) {
uni.stopPullDownRefresh(); // < ,
//
that.hasNomore = true
uni.showToast({
title: '没有更多了',
icon: 'none'
});
return;
}
if (currentPage == 1) {
that.menuList = res.data;
} else {
that.menuList.push(...res.data);
}
that.currentPage = currentPage;
uni.hideLoading()
},
}
}
@ -303,11 +330,12 @@
text-overflow: ellipsis;
}
}
.hasNomore{
text-align: center;
color:#a4a4a4;
height:80rpx;
line-height: 80rpx;
.hasNomore {
text-align: center;
color: #a4a4a4;
height: 80rpx;
line-height: 80rpx;
}
}

@ -162,7 +162,7 @@
this.navBarHeight = MenuButton.height
this.navBarBoxHeight = this.navBarTop + this.navBarHeight + 10
this.action = baseUrl + "/api/mobile/upload-file"
this.getToken()
// this.getToken()
this.otherData.token = this.vuex_token
this.getInitUser()
this.getParty()

Loading…
Cancel
Save