修改服务页的跳转问题

This commit is contained in:
zhouyanli
2026-04-20 08:46:02 +08:00
parent 445e44b3d9
commit fc7ef36a93
8 changed files with 134 additions and 327 deletions

View File

@@ -154,7 +154,8 @@
"pages": [{
"path": "activityList",
"style": {
"navigationBarTitleText": "活动列表"
"navigationBarTitleText": "活动列表",
"navigationStyle": "custom"
}
},
{
@@ -178,7 +179,8 @@
"pages": [{
"path": "noticeList",
"style": {
"navigationBarTitleText": "通知公告"
"navigationBarTitleText": "通知公告",
"navigationStyle": "custom"
}
},
{

View File

@@ -1,5 +1,10 @@
<template>
<view class="container">
<view class="status_bar"></view>
<!-- 顶部标题栏 -->
<view class="top-bar">
<uni-nav-bar left-icon="left" title="活动列表" backgroundColor ="none" :border="false" @clickLeft="narBack" />
</view>
<!-- 顶部图片 -->
<view class="topImg">
<image src="/static/首页/banner.png" style="width: 100%;height:100%;"></image>
@@ -323,6 +328,15 @@
}
})
// 返回
const narBack = () =>{
// uni.navigateBack({
// delta: 1
// })
uni.switchTab({
url:"/pages/index/index"
})
}
// 切换选项卡
const switchTab = (tab) => {
activeTab.value = tab
@@ -504,6 +518,15 @@
flex-direction: column;
padding: 20rpx;
}
.status_bar {
height: 32px;
width: 100%;
}
/* 顶部标题 */
.top-bar {
text-align: center;
margin-bottom: 20rpx;
}
.topImg {
width: 100%;
height: 280rpx;

View File

@@ -37,7 +37,7 @@
<up-swiper :list="bannerList" indicator indicatorMode="dot" ></up-swiper>
</view>
<view class="noticeClass">
<image src="/static/首页/公告.png" style="width: 38px;height: 38px;position: absolute;top: 21px;left: 27px;"></image>
<image src="/static/首页/公告.png" style="width: 38px;height: 38px;position: absolute;top: 21px;left: 23px;"></image>
<uni-notice-bar show-icon :text="noticeText" type="line"
:showIcon="true" show-get-more scrollable color="#000" background-color="#fff" moreColor="#000" @getmore="getNoticeMore"/>
<!-- <up-notice-bar class="notice-bar" :text="noticeText" mode="link" speed="100" bgColor="#FFF" color="#000" url="pages/notice-list/noticeList"></up-notice-bar> -->
@@ -332,7 +332,7 @@ const moreClick = () =>{
position: relative;
top: 167rpx;
left: 0;
padding: 40rpx;
padding: 40rpx 36rpx;
}
.noticeClass.uni-noticebar{
padding: 10px 15px 10px 45px;
@@ -348,7 +348,7 @@ const moreClick = () =>{
padding: 20rpx;
background-color: #fff;
border-radius: 8rpx;
margin: 20px;
margin: 20px 18px;
}
.openClass{
display: flex;
@@ -371,7 +371,7 @@ const moreClick = () =>{
.adCardClass{
// width: 100%;
height: 200rpx;
margin: 40rpx;
margin: 40rpx 30rpx;
background-color: #3E8EFF;
// margin-top: 30rpx;
border-radius: 28rpx;

View File

@@ -1,260 +0,0 @@
<template>
<view class="login-page">
<view class="status_bar"></view>
<!-- 标题 -->
<view class="login-title">账号密码登录</view>
<!-- 手机号输入框 -->
<view class="input-item">
<view class="input-icon">
<!-- <uni-icons type="phone" size="24" color="#999"></uni-icons> -->
<image src="/static/登录/手机号.png" mode="" style="height: 100%;width: 100%;"></image>
</view>
<uni-easyinput class="input-content" type="text" v-model="phoneNumber"
placeholder="请输入帐号" :inputBorder="false" :placeholderStyle="placeholderStyle">
</uni-easyinput>
</view>
<!-- 密码输入框 -->
<view class="input-item">
<view class="input-icon">
<!-- <uni-icons type="locked" size="24" color="#999"></uni-icons> -->
<image src="/static/登录/密码.png" mode="" style="height: 100%;width: 100%;"></image>
</view>
<uni-easyinput class="input-content" type="password" v-model="password"
placeholder="请输入密码" :inputBorder="false" :placeholderStyle="placeholderStyle">
</uni-easyinput>
</view>
<!-- 协议勾选 + 忘记密码 -->
<view class="agreement-wrap">
<view class="agreement-item" @click="toggleAgreement">
<uni-icons
type="checkbox-filled"
size="24"
color="#007aff"
v-if="agreeAgreement"
></uni-icons>
<uni-icons
type="checkbox"
size="24"
color="#999"
v-else
></uni-icons>
<text class="agreement-text">我已阅读并同意用户隐私政策</text>
</view>
<navigator class="forget-pwd" url="/pages/loginSub/forget-pwd">忘记密码</navigator>
</view>
<!-- 登录按钮 -->
<button
class="login-btn"
@click="handleLogin"
>
登录
</button>
<!-- 底部链接 -->
<view class="bottom-link">
<navigator class="link-item" url="/pages/login/login">验证码登录</navigator>
<navigator class="link-item" url="/pages/loginSub/register-new-user">注册新用户</navigator>
</view>
</view>
</template>
<script setup>
import { ref, computed } from 'vue';
import {onLoad} from "@dcloudio/uni-app"
import {getLoginPassword} from '/pages/api/api.js'
// 响应式数据
const phoneNumber = ref('');
const password = ref('');
const agreeAgreement = ref(true); // 默认勾选
const placeholderStyle = ref('font-size:24rpx')
// 计算属性:是否可登录(帐号+密码+协议都满足)
const canLogin = computed(() => {
const phoneReg = /^[a-zA-Z0-9_-]{4,16}$/; // 4-16位
const pwdReg = /^.{6,16}$/; // 密码6-16位
return phoneReg.test(phoneNumber.value) && pwdReg.test(password.value) && agreeAgreement.value;
});
// 切换协议勾选
const toggleAgreement = () => {
agreeAgreement.value = !agreeAgreement.value;
};
// 检查表单
const checkForm = () => {};
onLoad(() =>{
});
const handleLogin = async () => {
if (!canLogin.value) return;
// 防止多次点击触发登录
canLogin.value = false;
// // 2. 空值校验
// if (!phoneNumber.value) {
// uni.showToast({ title: '请输入手机号', icon: 'none' });
// canLogin.value = true; // 解锁
// return;
// }
// if (!password.value) {
// uni.showToast({ title: '请输入密码', icon: 'none' });
// canLogin.value = true; // 解锁
// return;
// }
const params = {
username: phoneNumber.value,
password: password.value
};
try {
// 3. 调用登录接口
const res = await getLoginPassword(params);
// 登录成功逻辑
// 如果后端返回token这里保存
// uni.setStorageSync('token', res.token || '');
uni.showToast({ title: '登录成功', icon: 'success' });
// 登录成功后再跳转
setTimeout(() => {
uni.switchTab({ url: '/pages/index/index' });
}, 1500);
} catch (err) {
// 登录失败逻辑(所有错误:账号不存在/密码错/网络异常都走这里)
uni.showToast({ title: `${err || '登录失败'}`, icon: 'none' });
} finally {
// 无论成功/失败,解锁按钮
canLogin.value = true;
}
};
// 登录逻辑
// const handleLogin = () => {
// if (!canLogin.value) return
// let params = {
// username:phoneNumber.value,
// password:password.value
// }
// getLoginPassword(params).then(res =>{
// // console.log('33333',res)
// if(res.code === 200){
// // console.log('33333',res)
// //uni.setStorageSync('token', res.token); // 假设后端返回token字段
// uni.showToast({ title: '登录成功', icon: 'success' });
// uni.switchTab({ url: '/pages/index/index' });
// // uni.reLaunch({ url: '/pages/index/index' });
// }else{
// uni.showToast({ title: `${res.msg},请先注册账号`, icon: 'error' });
// }
// })
// };
</script>
<style scoped>
.login-page {
padding: 80rpx 40rpx 40rpx;
/* background-color: #f8f9fa; */
min-height: 100vh;
background: repeating-linear-gradient(180deg, #E2F0FF, #F6FAFF );
}
.status_bar {
height: 160px;
width: 100%;
}
.login-title {
font-size: 48rpx;
font-weight: 600;
color: #333;
text-align: center;
margin-bottom: 80rpx;
}
.input-item {
display: flex;
align-items: center;
background-color: #fff;
border-radius: 40rpx;
padding: 0 30rpx;
height: 88rpx;
margin-bottom: 30rpx;
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}
.input-icon {
margin-right: 20rpx;
width: 50rpx;
height: 50rpx;
}
.input-content {
flex: 1;
font-size: 28rpx;
color: #333;
height: 100%;
}
.agreement-wrap {
display: flex;
justify-content: space-between;
align-items: center;
margin: 40rpx 0;
padding: 0 10rpx;
}
.agreement-item {
display: flex;
align-items: center;
}
.agreement-text {
font-size: 28rpx;
color: #666;
margin-left: 10rpx;
}
.forget-pwd {
font-size: 28rpx;
color: #007aff;
text-decoration: none;
}
.login-btn {
width: 100%;
height: 88rpx;
line-height: 88rpx;
background-color: #007aff;
color: #fff;
border-radius: 44rpx;
font-size: 32rpx;
margin-bottom: 60rpx;
}
.login-btn:disabled {
background-color: #99c8ff;
color: #fff;
}
.bottom-link {
display: flex;
justify-content: space-between;
padding: 0 20rpx;
}
.link-item {
font-size: 28rpx;
color: #007aff;
text-decoration: none;
}
</style>

View File

@@ -94,57 +94,67 @@ const checkForm = () => {};
onLoad(() =>{
});
const handleLogin = async () => {
if (!canLogin.value) return;
// 防止多次点击触发登录
canLogin.value = false;
// const handleLogin = async () => {
// if (!canLogin.value) return;
// // 防止多次点击触发登录
// // canLogin.value = false;
// // 2. 空值校验
// // // 2. 空值校验
// if (!phoneNumber.value) {
// uni.showToast({ title: '请输入手机号', icon: 'none' });
// canLogin.value = true; // 解锁
// // canLogin.value = true;
// return;
// }
// if (!password.value) {
// uni.showToast({ title: '请输入密码', icon: 'none' });
// canLogin.value = true; // 解锁
// // canLogin.value = true;
// return;
// }
const params = {
username: phoneNumber.value,
password: password.value
};
try {
// 3. 调用登录接口
const res = await getLoginPassword(params);
// 登录成功逻辑
// 如果后端返回token这里保存
// uni.setStorageSync('token', res.token || '');
uni.showToast({ title: '登录成功', icon: 'success' });
// 登录成功后再跳转
setTimeout(() => {
uni.switchTab({ url: '/pages/index/index' });
}, 1500);
} catch (err) {
// 登录失败逻辑(所有错误:账号不存在/密码错/网络异常都走这里)
uni.showToast({ title: `${err || '登录失败'}`, icon: 'none' });
} finally {
// 无论成功/失败,解锁按钮
canLogin.value = true;
}
};
// 登录逻辑
// const handleLogin = () => {
// if (!canLogin.value) return
// let params = {
// const params = {
// username: phoneNumber.value,
// password: password.value
// };
// try {
// // 3. 调用登录接口
// const res = await getLoginPassword(params);
// // 登录成功逻辑
// // 如果后端返回token这里保存
// // uni.setStorageSync('token', res.token || '');
// uni.showToast({ title: '登录成功', icon: 'success' });
// // 登录成功后再跳转
// setTimeout(() => {
// uni.switchTab({ url: '/pages/index/index' });
// }, 1500);
// } catch (err) {
// // 登录失败逻辑(所有错误:账号不存在/密码错/网络异常都走这里)
// uni.showToast({ title: `${err || '登录失败'}`, icon: 'none' });
// } finally {
// // 无论成功/失败,解锁按钮
// canLogin.value = true;
// }
// };
// 登录逻辑
const handleLogin = () => {
if (!canLogin.value) return
let params = {
username:phoneNumber.value,
password:password.value
}
if (!phoneNumber.value) {
uni.showToast({ title: '请输入手机号', icon: 'none' });
// canLogin.value = true;
return;
}
if (!password.value) {
uni.showToast({ title: '请输入密码', icon: 'none' });
// canLogin.value = true;
return;
}
// getLoginPassword(params).then(res =>{
// // console.log('33333',res)
// if(res.code === 200){
@@ -158,8 +168,11 @@ const handleLogin = async () => {
// }
// })
setTimeout(() => {
uni.switchTab({ url: '/pages/index/index' });
}, 1500);
// };
};
</script>
<style scoped>

View File

@@ -7,6 +7,11 @@
:refresher-triggered="refreshing"
:style="{ height: `calc(100vh - ${statusBarHeight + navBarHeight}px)` }"
>
<view class="status_bar"></view>
<!-- 顶部标题栏 -->
<view class="top-bar">
<uni-nav-bar left-icon="left" title="通知公告" backgroundColor ="none" :border="false" @clickLeft="narBack" />
</view>
<!-- 下拉刷新 -->
<view class="refresh-container" v-if="refreshing">
<uni-icons type="spinner-cycle" size="20" color="#999" class="loading"></uni-icons>
@@ -115,6 +120,15 @@
url:'/pages/notice-list/noticeListDetails'
})
}
// 返回
const narBack = () =>{
// uni.navigateBack({
// delta: 1
// })
uni.switchTab({
url:"/pages/index/index"
})
}
</script>
@@ -125,6 +139,15 @@
box-sizing: border-box;
background-color: #f9f9f9;
}
.status_bar {
height: 32px;
width: 100%;
}
/* 顶部标题 */
.top-bar {
text-align: center;
margin-bottom: 20rpx;
}
/* 下拉刷新 */
.refresh-container {

View File

@@ -152,7 +152,10 @@ function personalClick(){
}
// 返回上一页
const goBack = () => {
uni.navigateBack()
// uni.navigateBack()
uni.switchTab({
url:"/pages/index/index"
})
}
// 跳转报修详情
const goDetail = (item) => {

View File

@@ -123,7 +123,10 @@ const filterdList = computed(() => {
})
// 返回上一页
const goBack = () => {
uni.navigateBack()
// uni.navigateBack()
uni.switchTab({
url:"/pages/index/index"
})
}
// 查看详情