feat: 添加隐私协议链接和用户协议勾选验证

fix: 修复文章详情页路由错误问题
refactor: 优化手机号显示逻辑和存储方式
style: 调整页面布局样式和导航栏固定定位
perf: 优化排行榜数据显示和格式化逻辑
This commit is contained in:
34701892@qq.com 2025-08-18 09:49:28 +08:00
parent a70819522e
commit f0da0b3760
11 changed files with 157 additions and 33 deletions

View File

@ -11,11 +11,13 @@ onLaunch(() => {
onShow(() => { }); onShow(() => { });
onHide(() => { onHide(() => {
console.log("App Hide"); console.log("App Hide");
uni.setStorageSync('homeTabIndex', null)
}); });
</script> </script>
<style lang="scss"> <style lang="scss">
/* 注意要写在第一行同时给style标签加入lang="scss"属性 */ /* 注意要写在第一行同时给style标签加入lang="scss"属性 */
@import "@/uni_modules/uview-plus/index.scss"; @import "@/uni_modules/uview-plus/index.scss";
#app, #app,
uni-app, uni-app,
uni-page, uni-page,

View File

@ -28,13 +28,30 @@
<view :class="['news-meta', isLogin ? '' : 'mohu']"> <view :class="['news-meta', isLogin ? '' : 'mohu']">
<view> <view style="display: flex;justify-content: space-between;width: 100%;">
<view style="display: flex;">
<text class="source">{{ item.source }}</text> <text class="source">{{ item.source }}</text>
<text class="time">{{ <text class="time">{{
dayjs(item.publish_time).format("YYYY-MM-DD HH:MM:ss") dayjs(item.publish_time).format("YYYY-MM-DD HH:MM:ss")
}}</text> }}</text>
</view> </view>
<view class="r_option">
<image class="option_icon"
src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/eye_icon%402x.png"></image>
<text class="option_text">{{ item.viewCount }}</text>
<image class="option_icon"
src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/like_icon%402x.png"></image>
<text class="option_text">{{ item.likeCount }}</text>
<image class="option_icon"
src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/share_icon%402x.png"></image>
<text class="option_text">{{ item.shareCount }}</text>
</view>
</view>
</view> </view>
<view class="lock_view" v-if="!isLogin"> <view class="lock_view" v-if="!isLogin">
<image class="lock_icon" <image class="lock_icon"
@ -84,7 +101,34 @@ watch(
return; return;
} }
rankListLocal.value.push(item); // item.likeCount = item.likeCount || 3840;
// item.shareCount = item.shareCount || 20;
// item.viewCount = item.viewCount || 290000;
let likeCount = 0;
let shareCount = 0;
let viewCount = 0;
let favCount = 0;
if (item.likeCount) {
likeCount = item.likeCount > 10000 ? Number(item.likeCount / 10000).toFixed(1) + '万' : item.likeCount;
}
if (item.shareCount) {
shareCount = item.shareCount > 10000 ? Number(item.shareCount / 10000).toFixed(1) + '万' : item.shareCount;
}
if (item.viewCount) {
viewCount = item.viewCount > 10000 ? Number(item.viewCount / 10000).toFixed(1) + '万' : item.viewCount;
}
if (item.favCount) {
favCount = item.favCount > 10000 ? Number(item.favCount / 10000).toFixed(1) + '万' : item.viewCount;
}
rankListLocal.value.push({
...item,
favCount: favCount,
likeCount: likeCount,
shareCount: shareCount,
viewCount: viewCount,
});
}); });
loading.value = false; loading.value = false;
} }
@ -322,4 +366,26 @@ const handlePopupErrorCallback = () => {
font-style: normal; font-style: normal;
} }
} }
.r_option {
display: flex;
align-items: center;
justify-content: center;
gap: 10rpx;
.option_icon {
width: 24rpx;
height: 24rpx;
}
.option_text {
font-family: PingFangSC, PingFang SC;
font-weight: 400;
font-size: 24rpx;
color: #192236;
line-height: 33rpx;
text-align: justify;
font-style: normal;
}
}
</style> </style>

View File

@ -64,6 +64,8 @@
</view> </view>
</template> </template>
</u-cell> </u-cell>
</u-cell-group> </u-cell-group>
</view> </view>

View File

@ -63,6 +63,14 @@
</view> </view>
</template> </template>
</u-cell> </u-cell>
<u-cell title="隐私协议"
icon="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/newmini/%E9%9A%90%E7%A7%81%E5%8D%8F%E8%AE%AE%E5%92%8C%E7%94%A8%E6%88%B7%E5%8D%8F%E8%AE%AEicon.png"
isLink :iconStyle="{ width: '40rpx', height: '40rpx', marginRight: '20rpx' }" :titleStyle="{
fontSize: '32rpx',
color: '#333333',
}" @click="handleClick(3)">
</u-cell>
</u-cell-group> </u-cell-group>
</view> </view>
@ -111,10 +119,11 @@ onMounted(() => {
}); });
// * // *
const maskPhoneNumber = (phoneNumber: string) => { const maskPhoneNumber = () => {
if (!phoneNumber && uni.getStorageSync("userPhone")) { // if (!phoneNumber && uni.getStorageSync("userPhone")) {
phoneNumber = uni.getStorageSync("userPhone"); // phoneNumber = uni.getStorageSync("userPhone");
} // }
let phoneNumber = uni.getStorageSync("userPhone");
if (phoneNumber) { if (phoneNumber) {
return phoneNumber.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2"); return phoneNumber.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
} else { } else {
@ -161,7 +170,14 @@ const handleClick = (val: number) => {
uni.navigateTo({ uni.navigateTo({
url: "/pages/subscribed/index", url: "/pages/subscribed/index",
}); });
} else { } else if (val === 3) {
wx.openPrivacyContract({
success: () => { }, //
fail: () => { }, //
complete: () => { },
});
}
else {
uni.navigateTo({ uni.navigateTo({
url: `/pages/bookmark/index?tabs=${val}`, url: `/pages/bookmark/index?tabs=${val}`,
}); });

View File

@ -1,5 +1,5 @@
// const baseURL = "http://192.168.31.25:8060/api"; // const baseURL = "http://192.168.31.25:8060/api";
// export const baseUrl = "http://192.168.3.38:8040/apih5"; export const baseUrl = "http://192.168.3.38:8040/apih5";
export const baseUrl = "https://cankao.cs.com.cn/apih5"; // export const baseUrl = "https://cankao.cs.com.cn/apih5";
export const baseUrlDataV = "https://cankao.cs.com.cn/zzck_datav"; export const baseUrlDataV = "https://cankao.cs.com.cn/zzck_datav";

View File

@ -29,7 +29,7 @@ const props = defineProps({
const doDetail = (item: any) => { const doDetail = (item: any) => {
console.log("🚀 ~ doDetail ~ item:", item) console.log("🚀 ~ doDetail ~ item:", item)
uni.navigateTo({ uni.navigateTo({
url: `/pages/detail/index?id=${item.id}`, url: `/pages/detail/indexNewsInfo?id=${item.id}`,
}); });
}; };

View File

@ -8,7 +8,8 @@
}"></view> }"></view>
<!-- <Navbar title="中证参考"></Navbar> --> <!-- <Navbar title="中证参考"></Navbar> -->
<!-- 头部 --> <!-- 头部 -->
<view class="subHeader"> <view class="subHeader"
:style="{ position: 'sticky', top: getNavHeight() + 'px', background: '#fff', zIndex: '9999' }">
<view class="flashBack" @click="doBack"> <view class="flashBack" @click="doBack">
<u-icon size="20" name="arrow-left" color="#333333"></u-icon> <u-icon size="20" name="arrow-left" color="#333333"></u-icon>
</view> </view>

View File

@ -1,9 +1,13 @@
<template> <template>
<view class="container"> <view class="container">
<view :style="{ height: getNavHeight() + 'px' }"></view> <view :style="{ height: getNavHeight() + 'px', position: 'sticky', top: 0, background: '#fff', zIndex: '9999' }">
</view>
<!-- 导航栏 start --> <!-- 导航栏 start -->
<view class="custom-bav-bar"> <view class="custom-bav-bar"
:style="{ position: 'sticky', top: getNavHeight() + 'px', background: '#fff', zIndex: '9999' }">
<view class="left"> <view class="left">
<image src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/static/icon_left.png" class="back_icon" <image src="https://cankao.obs.cn-east-3.myhuaweicloud.com/mini/static/icon_left.png" class="back_icon"
@click="handleBack" /> @click="handleBack" />

View File

@ -7,18 +7,30 @@
<!-- <view class="bottom_btn" @click="goIndex"> 立即进入 </view> --> <!-- <view class="bottom_btn" @click="goIndex"> 立即进入 </view> -->
<button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" class="bottom_btn"> <!-- 用户协议 -->
<view class="tips">
<u-checkbox-group v-model="checked" placement="column" @change="checkboxChange">
<u-checkbox class="checkbox" shape="circle"></u-checkbox>
</u-checkbox-group>
<text class="r_userAgreement">已阅读并同意<text class="userAgreement"
@click="goUserAgreement">江南农商银行隐私政策中证参考智能资讯小程序服务使用许可及服务协议</text>首次登录的手机号将自动注册</text>
</view>
<button v-if="checked && checked?.length > 0" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber"
class="bottom_btn">
<view> <view>
<text>立即进入</text> <text>立即进入</text>
</view> </view>
</button> </button>
<!-- 用户协议 --> <button v-else class="bottom_btn" @click="needCheck">
<view class="tips"> <view>
<u-checkbox class="checkbox" shape="circle"></u-checkbox> <text>立即进入</text>
<text class="r_userAgreement">已阅读并同意<text class="userAgreement"
@click="goUserAgreement">江南农商银行隐私政策中证参考智能资讯小程序服务使用许可及服务协议</text>首次登录的手机号将自动注册</text>
</view> </view>
</button>
</view> </view>
</template> </template>
@ -37,6 +49,14 @@ import { doWxAuth } from "@/api/index";
import { onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app"; import { onPullDownRefresh, onReachBottom } from "@dcloudio/uni-app";
import { useShareStore } from "@/stores/shareStore"; import { useShareStore } from "@/stores/shareStore";
const stores = useShareStore(); const stores = useShareStore();
const checked = ref([])
watch(checked, (newVal) => {
console.log("🚀 ~ newVal:", newVal)
if (newVal) {
}
})
let timer = ref(); let timer = ref();
@ -62,6 +82,7 @@ function getPhoneNumber(phoneObj) {
uni.showLoading(); uni.showLoading();
getWxCode(phoneObj.detail); getWxCode(phoneObj.detail);
} }
const codeWx = ref(); const codeWx = ref();
function getWxCode(phoneObj) { function getWxCode(phoneObj) {
console.log("🚀 ~ getWxCode ~ phoneObj:", phoneObj); console.log("🚀 ~ getWxCode ~ phoneObj:", phoneObj);
@ -96,7 +117,7 @@ async function doWxAuthFn(phoneObj, jsCode) {
// uni.setStorageSync("userId", data.userId); // uni.setStorageSync("userId", data.userId);
uni.setStorageSync("unionId", data.unionId); uni.setStorageSync("unionId", data.unionId);
uni.setStorageSync("openId", data.openId); uni.setStorageSync("openId", data.openId);
uni.setStorageSync("phone", data.phone); uni.setStorageSync("userPhone", data.phone);
uni.redirectTo({ uni.redirectTo({
url: "/pages/minihome/index", url: "/pages/minihome/index",
}); });
@ -120,6 +141,15 @@ onLoad((option) => {
// }, 2000) // }, 2000)
}); });
//
function needCheck() {
uni.showToast({
title: "请先同意用户协议",
icon: 'none'
})
}
function goUserAgreement() { function goUserAgreement() {
wx.openPrivacyContract({ wx.openPrivacyContract({
success: () => { }, // success: () => { }, //
@ -135,6 +165,7 @@ onUnload(() => {
onShow(() => { onShow(() => {
stores.initWxConfig(); stores.initWxConfig();
uni.setStorageSync('homeTabIndex', null)
}); });
</script> </script>

View File

@ -6,13 +6,9 @@
<u-icon size="20" name="arrow-left" color="#333333"></u-icon> <u-icon size="20" name="arrow-left" color="#333333"></u-icon>
</view> </view>
<view class="title"> <view class="title">
<u-tabs <u-tabs :list="list" :activeStyle="{
:list="list"
:activeStyle="{
color: '#E7303F', color: '#E7303F',
}" }" lineColor="#E7303F"></u-tabs>
lineColor="#E7303F"
></u-tabs>
</view> </view>
</view> </view>
@ -48,6 +44,7 @@ const list = ref([
display: flex; display: flex;
align-items: center; align-items: center;
position: relative; position: relative;
.title { .title {
font-size: 16px; font-size: 16px;
color: #fff; color: #fff;

View File

@ -118,11 +118,16 @@ onShow(() => {
} else { } else {
tabChange(0) tabChange(0)
} }
uni.setStorageSync('homeTabIndex', null)
}) })
onMounted(async () => { onMounted(async () => {
getNewsList() getNewsList()
}); });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">