首页服务条例信息的更改,从article中获取文章

This commit is contained in:
minimaxagent1 2025-08-04 14:20:50 +08:00
parent 42359bb06d
commit cc9768acc4
2 changed files with 290 additions and 11 deletions

53
api/article/article.js Normal file
View File

@ -0,0 +1,53 @@
import request from '@/utils/request'
/**
* 获取条款和隐私政策
* @param {Object} params - 查询参数
* @param {string} params.type - 类型 5:服务条款 6:隐私条款
* @param {string} params.appId - 应用ID
* @param {string} params.status - 状态
* @returns {Promise} 返回条款数据
*/
export function getArticleByType(params = {}) {
return request({
url: '/app/article/listByType',
method: 'GET',
params: {
appId: 1,
status: 1,
...params
}
})
}
/**
* 获取服务条款
* @returns {Promise} 返回服务条款数据
*/
export function getServiceTerms() {
return request({
url: '/app/article/listByType',
method: 'GET',
params: {
appId: 1,
status: 1,
type: '5'
}
})
}
/**
* 获取隐私政策
* @returns {Promise} 返回隐私政策数据
*/
export function getPrivacyPolicy() {
return request({
url: '/app/article/listByType',
method: 'GET',
params: {
appId: 1,
status: 1,
type: '6'
}
})
}

View File

@ -6,20 +6,59 @@
<view class="imgbox">
<image src="https://api.ccttiot.com/smartmeter/img/static/uGPwljIaEppyKAT1iQaW" mode=""></image>
</view>
<button class="button" @click="getPhoneNumber" >
<button class="button" :disabled="!hasAgreed" :class="{ 'button-disabled': !hasAgreed }" @click="getPhoneNumber" >
授权登录
</button>
<view class="tip">
<image src="https://api.ccttiot.com/smartmeter/img/static/u4LEl3cUFgF9uN30ESnF" mode=""></image>
我已同意并阅读服务条款法律条款及隐私政策
<view class="checkbox-container" @click="toggleAgreement">
<view class="checkbox" :class="{ 'checked': hasAgreed }">
<text v-if="hasAgreed" class="checkmark"></text>
</view>
</view>
<text>我已同意并阅读</text>
<text class="link-text" @click="showServiceTerms">服务条款</text>
<text class="link-text" @click="showPrivacyPolicy">法律条款及隐私政策</text>
</view>
<!-- 服务条款弹窗 -->
<u-popup v-model="showServiceTermsPopup" mode="center" width="600rpx" height="800rpx" border-radius="20rpx">
<view class="popup-content">
<view class="popup-header">
<text class="popup-title">服务条款</text>
<text class="popup-close" @click="closeServiceTermsPopup">×</text>
</view>
<scroll-view class="popup-body" scroll-y>
<rich-text :nodes="serviceTermsContent"></rich-text>
</scroll-view>
<view class="popup-footer">
<button class="popup-btn" @click="agreeServiceTerms">同意</button>
</view>
</view>
</u-popup>
<!-- 隐私政策弹窗 -->
<u-popup v-model="showPrivacyPolicyPopup" mode="center" width="600rpx" height="800rpx" border-radius="20rpx">
<view class="popup-content">
<view class="popup-header">
<text class="popup-title">法律条款及隐私政策</text>
<text class="popup-close" @click="closePrivacyPolicyPopup">×</text>
</view>
<scroll-view class="popup-body" scroll-y>
<rich-text :nodes="privacyPolicyContent"></rich-text>
</scroll-view>
<view class="popup-footer">
<button class="popup-btn" @click="agreePrivacyPolicy">同意</button>
</view>
</view>
</u-popup>
</view>
</template>
<script>
import { navigateToPage } from "../../utils/router.js";
import { wxLogin } from "../../api/auth/auth.js";
import { forceHideLoading, AutoLoadingManager } from "../../utils/request.js";
import { navigateToPage } from "@/utils/router.js";
import { wxLogin } from "@/api/auth/auth.js";
import { forceHideLoading, AutoLoadingManager } from "@/utils/request.js";
import { getServiceTerms, getPrivacyPolicy } from "@/api/article/article.js";
export default {
data() {
@ -30,7 +69,14 @@ import { forceHideLoading, AutoLoadingManager } from "../../utils/request.js";
titleTxt:"登录",
chooseType:true,
usertype:'',
login:false
login:false,
hasAgreed: false, //
hasReadServiceTerms: false, //
hasReadPrivacyPolicy: false, //
showServiceTermsPopup: false, //
showPrivacyPolicyPopup: false, //
serviceTermsContent: '', //
privacyPolicyContent: '', //
}
},
onLoad() {
@ -54,7 +100,96 @@ import { forceHideLoading, AutoLoadingManager } from "../../utils/request.js";
this.usertype='00'
}
},
//
toggleAgreement() {
if (this.hasReadServiceTerms && this.hasReadPrivacyPolicy) {
this.hasAgreed = !this.hasAgreed;
} else {
uni.showToast({
title: '请先阅读服务条款和隐私政策',
icon: 'none'
});
}
},
//
async showServiceTerms() {
try {
const res = await getServiceTerms();
if (res.code === 200 && res.data) {
this.serviceTermsContent = res.data.content || '暂无服务条款内容';
this.showServiceTermsPopup = true;
} else {
uni.showToast({
title: '获取服务条款失败',
icon: 'none'
});
}
} catch (error) {
console.error('获取服务条款失败:', error);
uni.showToast({
title: '获取服务条款失败',
icon: 'none'
});
}
},
//
async showPrivacyPolicy() {
try {
const res = await getPrivacyPolicy();
if (res.code === 200 && res.data) {
this.privacyPolicyContent = res.data.content || '暂无隐私政策内容';
this.showPrivacyPolicyPopup = true;
} else {
uni.showToast({
title: '获取隐私政策失败',
icon: 'none'
});
}
} catch (error) {
console.error('获取隐私政策失败:', error);
uni.showToast({
title: '获取隐私政策失败',
icon: 'none'
});
}
},
//
closeServiceTermsPopup() {
this.showServiceTermsPopup = false;
},
//
closePrivacyPolicyPopup() {
this.showPrivacyPolicyPopup = false;
},
//
agreeServiceTerms() {
this.hasReadServiceTerms = true;
this.closeServiceTermsPopup();
this.checkAgreementStatus();
},
//
agreePrivacyPolicy() {
this.hasReadPrivacyPolicy = true;
this.closePrivacyPolicyPopup();
this.checkAgreementStatus();
},
//
checkAgreementStatus() {
if (this.hasReadServiceTerms && this.hasReadPrivacyPolicy) {
//
this.hasAgreed = true;
}
},
getPhoneNumber() {
//
if (!this.hasAgreed) {
uni.showToast({
title: '请先同意服务条款和隐私政策',
icon: 'none'
});
return;
}
let that = this;
uni.login({
success(res) {
@ -164,6 +299,10 @@ import { forceHideLoading, AutoLoadingManager } from "../../utils/request.js";
font-size: 40rpx;
color: #FFFFFF;
}
.button-disabled {
background: #CCCCCC !important;
color: #999999 !important;
}
.tip{
margin-top:128rpx ;
display: flex;
@ -173,11 +312,98 @@ import { forceHideLoading, AutoLoadingManager } from "../../utils/request.js";
font-weight: 400;
font-size: 20rpx;
color: #979797;
image{
width: 26rpx;
height: 26rpx;
.link-text {
color: #4C97E7;
text-decoration: underline;
}
}
/* 自定义勾选按钮样式 */
.checkbox-container {
display: flex;
align-items: center;
margin-right: 10rpx;
cursor: pointer;
}
.checkbox {
width: 26rpx;
height: 26rpx;
border: 2rpx solid #CCCCCC;
border-radius: 4rpx;
display: flex;
align-items: center;
justify-content: center;
background-color: #FFFFFF;
transition: all 0.3s ease;
}
.checkbox.checked {
background-color: #4C97E7;
border-color: #4C97E7;
}
.checkmark {
color: #FFFFFF;
font-size: 16rpx;
font-weight: bold;
line-height: 1;
}
/* 弹窗样式 */
.popup-content {
background: #fff;
border-radius: 20rpx;
overflow: hidden;
display: flex;
flex-direction: column;
height: 100%;
}
.popup-header {
padding: 30rpx;
border-bottom: 1rpx solid #eee;
display: flex;
justify-content: space-between;
align-items: center;
background: #f8f8f8;
}
.popup-title {
font-size: 32rpx;
font-weight: bold;
color: #333;
}
.popup-close {
font-size: 40rpx;
color: #999;
cursor: pointer;
padding: 10rpx;
}
.popup-body {
flex: 1;
padding: 30rpx;
line-height: 1.6;
font-size: 28rpx;
color: #333;
}
.popup-footer {
padding: 30rpx;
border-top: 1rpx solid #eee;
background: #f8f8f8;
}
.popup-btn {
width: 100%;
height: 80rpx;
background: #4C97E7;
color: #fff;
border: none;
border-radius: 40rpx;
font-size: 30rpx;
font-weight: 500;
}
</style>