feat: 新增sw(税务)与hj(生态环境)专区模块;自制hj/sw-tabbar底栏;hj-web内嵌阅读(双指缩放);hnlylaw三活动authorization隔离(Sft/Sw/Hj);缓存键Hj后缀;问卷1006/1007;home专区入口接线;sw/hj规则与隐私文案、学习清单及链接校修复
This commit is contained in:
@@ -0,0 +1,305 @@
|
||||
<template>
|
||||
<view>
|
||||
<image src="https://aliyunoss.hn12301.net/learnlaw/xfhh_bj.jpg" style="width: 750rpx;" mode="widthFix"></image>
|
||||
<!-- <image src="https://aliyunoss.hn12301.net/learnlaw/xfhm_ckjpxq.png"
|
||||
style="width: 250rpx;position: absolute;top: 1210rpx;left: 250rpx;" mode="widthFix"
|
||||
@click="showPrize = true"></image> -->
|
||||
<image src="https://aliyunoss.hn12301.net/learnlaw/xfhh_dtcj.png"
|
||||
style="width: 340rpx;position: absolute;top: 1250rpx;left: 25rpx;" mode="widthFix" @click="goRegister">
|
||||
</image>
|
||||
<image src="https://aliyunoss.hn12301.net/learnlaw/xfhh_fzxx.png"
|
||||
style="width: 340rpx;position: absolute;top: 1250rpx;right: 25rpx;" mode="widthFix" @click="goStudy">
|
||||
</image>
|
||||
<view class="side-tab" style="top: 480rpx;" hover-class="side-tab-hover" @click="goRules">活动规则</view>
|
||||
<view class="back-home" @click="goHome">
|
||||
<text class="back-home-icon">‹</text>
|
||||
</view>
|
||||
<view class="blocked-mask" v-if="blocked">
|
||||
<text class="blocked-tip">{{ blockTip }}</text>
|
||||
<text class="blocked-sub">本活动仅支持手机微信访问</text>
|
||||
</view>
|
||||
<hj-tabbar current="index"></hj-tabbar>
|
||||
<view class="prize-mask" v-if="showPrize" @click="showPrize = false"></view>
|
||||
<view class="prize-popup" v-if="showPrize">
|
||||
<scroll-view scroll-y class="prize-scroll">
|
||||
<image src="https://aliyunoss.hn12301.net/learnlaw/xfhm_main_jp.jpg" mode="widthFix" style="width: 100%;"></image>
|
||||
</scroll-view>
|
||||
<view class="prize-close" @click="showPrize = false">
|
||||
<text class="prize-close-text">✕</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import hjTabbar from '@/components/hj-tabbar/hj-tabbar.vue'
|
||||
|
||||
const APP_ID = 'wx71c218bd9ff0e2da'
|
||||
const SCOPE = 'snsapi_base'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
hjTabbar
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
blocked: false,
|
||||
blockTip: '',
|
||||
showPrize: false
|
||||
}
|
||||
},
|
||||
onLoad() {
|
||||
this.initLogin()
|
||||
},
|
||||
onShow() {
|
||||
if (this.blocked) return
|
||||
const openId = uni.getStorageSync('openIdHj')
|
||||
const isRegistered = uni.getStorageSync('isRegisteredHj')
|
||||
const userId = uni.getStorageSync('userIdHj')
|
||||
if (openId && (!isRegistered || !userId)) {
|
||||
this.loginWithOpenId(openId)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
goHome() {
|
||||
uni.reLaunch({
|
||||
url: '/pages/home/home'
|
||||
})
|
||||
},
|
||||
goStudy() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/hj-study/hj-study'
|
||||
})
|
||||
},
|
||||
initLogin() {
|
||||
if (!this.isWechatBrowser()) {
|
||||
this.block('请在微信中打开')
|
||||
return
|
||||
}
|
||||
if (this.isPcWechat()) {
|
||||
this.block('请使用手机微信打开')
|
||||
return
|
||||
}
|
||||
let openId = uni.getStorageSync('openIdHj')
|
||||
if (openId) {
|
||||
this.loginWithOpenId(openId)
|
||||
return
|
||||
}
|
||||
const code = this.getCodeFromUrl()
|
||||
if (code) {
|
||||
this.exchangeOpenId(code)
|
||||
} else {
|
||||
this.wechatAuth()
|
||||
}
|
||||
},
|
||||
block(tip) {
|
||||
this.blocked = true
|
||||
this.blockTip = tip
|
||||
},
|
||||
isWechatBrowser() {
|
||||
return /MicroMessenger/i.test(navigator.userAgent)
|
||||
},
|
||||
isPcWechat() {
|
||||
return /MicroMessenger/i.test(navigator.userAgent) && /WindowsWechat|MacWechat/i.test(navigator.userAgent)
|
||||
},
|
||||
getCodeFromUrl() {
|
||||
const match = window.location.href.match(/[?&]code=([^&#]+)/)
|
||||
return match ? match[1] : null
|
||||
},
|
||||
cleanUrlCode() {
|
||||
const cleanUrl = window.location.href.replace(/[?&]code=[^&#]*(&|#|$)/, (m, p1) => p1 === '&' ? '?' : (
|
||||
p1 === '#' ? '#' : ''))
|
||||
window.history.replaceState({}, '', cleanUrl)
|
||||
},
|
||||
wechatAuth() {
|
||||
const base = window.location.href.split('#')[0].split('?')[0]
|
||||
const redirectUri = encodeURIComponent(base + '#/pages/hj-index/hj-index')
|
||||
const url =
|
||||
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${APP_ID}&redirect_uri=${redirectUri}&response_type=code&scope=${SCOPE}&state=STATE#wechat_redirect`
|
||||
window.location.href = url
|
||||
},
|
||||
loginWithOpenId(openId) {
|
||||
this.$u.api.wxOpenidLogin({
|
||||
wenjuan_id: 1007,
|
||||
open_id: openId
|
||||
}).then(loginRes => {
|
||||
if (!loginRes.Data) {
|
||||
uni.setStorageSync('isRegisteredHj', false)
|
||||
return
|
||||
}
|
||||
if (loginRes.code === 0 && loginRes.Data?.user_name && loginRes.Data?.user_phone) {
|
||||
uni.setStorageSync('isRegisteredHj', true)
|
||||
uni.setStorageSync('userIdHj', loginRes.Data.user_id)
|
||||
uni.setStorageSync('userNameHj', loginRes.Data.user_name)
|
||||
uni.setStorageSync('userPhoneHj', loginRes.Data.user_phone)
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error('登录请求失败', err)
|
||||
})
|
||||
},
|
||||
goRegister() {
|
||||
const isRegistered = uni.getStorageSync('isRegisteredHj')
|
||||
if (isRegistered) {
|
||||
uni.navigateTo({
|
||||
url: '/pages/hj-answer/hj-answer'
|
||||
})
|
||||
return
|
||||
}
|
||||
uni.navigateTo({
|
||||
url: '/pages/hj-register/hj-register'
|
||||
})
|
||||
},
|
||||
goRules() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/hj-rules/hj-rules'
|
||||
})
|
||||
},
|
||||
exchangeOpenId(code) {
|
||||
this.$u.api.getWxOpenId(code).then(res => {
|
||||
if (res.code !== 0 || !res.Data || !res.Data.openid) return
|
||||
const openId = res.Data.openid
|
||||
uni.setStorageSync('openIdHj', openId)
|
||||
this.cleanUrlCode()
|
||||
return this.$u.api.wxOpenidLogin({
|
||||
wenjuan_id: 1007,
|
||||
open_id: openId
|
||||
})
|
||||
}).then(loginRes => {
|
||||
if (loginRes && loginRes.code === 0 && loginRes.Data && loginRes.Data.user_name && loginRes
|
||||
.Data.user_phone) {
|
||||
uni.setStorageSync('isRegisteredHj', true)
|
||||
uni.setStorageSync('userIdHj', loginRes.Data.user_id || loginRes.Data.uesr_id)
|
||||
uni.setStorageSync('userNameHj', loginRes.Data.user_name)
|
||||
uni.setStorageSync('userPhoneHj', loginRes.Data.user_phone)
|
||||
} else if (loginRes && !loginRes.Data) {
|
||||
uni.setStorageSync('isRegisteredHj', false)
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error('请求失败', err)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
page {
|
||||
background-color: #7CC6EB;
|
||||
}
|
||||
|
||||
.blocked-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
z-index: 999;
|
||||
background-color: #7CC6EB;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.blocked-tip {
|
||||
font-size: 36rpx;
|
||||
font-weight: 600;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.blocked-sub {
|
||||
font-size: 26rpx;
|
||||
color: rgba(255, 255, 255, 0.85);
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.side-tab {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
width: 160rpx;
|
||||
height: 60rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border-radius: 30rpx 0 0 30rpx;
|
||||
background: linear-gradient(135deg, #FD5401, #FF8A3D);
|
||||
color: #fff;
|
||||
font-size: 24rpx;
|
||||
font-weight: 600;
|
||||
letter-spacing: 2rpx;
|
||||
border-left: 6rpx solid rgba(255, 255, 255, 0.65);
|
||||
box-shadow: 0 6rpx 16rpx rgba(253, 84, 1, 0.35);
|
||||
}
|
||||
|
||||
.side-tab-hover {
|
||||
opacity: 0.85;
|
||||
}
|
||||
|
||||
.back-home {
|
||||
position: fixed;
|
||||
left: 20rpx;
|
||||
top: 80rpx;
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
border-radius: 50%;
|
||||
background: rgba(0, 0, 0, 0.25);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 998;
|
||||
}
|
||||
|
||||
.back-home-icon {
|
||||
font-size: 44rpx;
|
||||
color: #fff;
|
||||
line-height: 1;
|
||||
margin-top: -6rpx;
|
||||
}
|
||||
|
||||
.prize-mask {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.6);
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.prize-popup {
|
||||
position: fixed;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width: 620rpx;
|
||||
z-index: 1001;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.prize-scroll {
|
||||
width: 620rpx;
|
||||
max-height: 75vh;
|
||||
background: #fff;
|
||||
border-radius: 24rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.prize-close {
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
border-radius: 50%;
|
||||
border: 2rpx solid rgba(255, 255, 255, 0.9);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
|
||||
.prize-close-text {
|
||||
font-size: 32rpx;
|
||||
color: #fff;
|
||||
line-height: 1;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user