Compare commits

..

14 Commits

Author SHA1 Message Date
ebba3ca7d3 添加 README.md 2024-01-24 09:59:48 +08:00
757412fac6 更新 app.json 2024-01-09 16:11:02 +08:00
1c043f2041 更新 policy.wxss 2024-01-09 16:04:43 +08:00
35d6a58a44 更新 policy.wxml 2024-01-09 16:04:40 +08:00
9d6a63ddd3 更新 policy.js 2024-01-09 16:04:38 +08:00
d11830d360 更新 home.js 2024-01-09 16:04:36 +08:00
138d104692 更新 config.js 2024-01-09 15:22:47 +08:00
2e6702a3bf 更新 home.wxml 2024-01-09 15:22:44 +08:00
3463cd1bd8 更新 login.js 2024-01-08 14:13:37 +08:00
61e2f4d9ad 更新 login.wxss 2024-01-06 15:28:02 +08:00
0e2fe478b1 更新 login.wxml 2024-01-06 15:27:59 +08:00
d546c90dbc 更新 login.js 2024-01-06 15:27:56 +08:00
9aef1d6e52 更新 login.js 2024-01-06 11:33:40 +08:00
5ed9d81c55 更新 app.json 2024-01-06 11:33:38 +08:00
11 changed files with 82 additions and 73 deletions

1
README.md Normal file
View File

@@ -0,0 +1 @@
微信小程序

View File

@@ -14,29 +14,7 @@
"navigationBarTitleText": "万名群众进城镇", "navigationBarTitleText": "万名群众进城镇",
"navigationBarBackgroundColor": "#2b4b6b" "navigationBarBackgroundColor": "#2b4b6b"
}, },
"tabBar": {
"list": [{
"pagePath": "pages/home/home",
"text": "首页",
"iconPath": "/assets/images/icon/home-off.png",
"selectedIconPath": "/assets/images/icon/home-on.png"
},
{
"pagePath": "pages/personal/personal",
"text": "个人",
"iconPath": "/assets/images/icon/personal-off.png",
"selectedIconPath": "/assets/images/icon/personal-on.png"
}]
},
"style": "v2", "style": "v2",
"rendererOptions": {
"skyline": {
"defaultDisplayBlock": true,
"disableABTest": true,
"sdkVersionBegin": "3.0.0",
"sdkVersionEnd": "15.255.255"
}
},
"componentFramework": "glass-easel", "componentFramework": "glass-easel",
"sitemapLocation": "sitemap.json", "sitemapLocation": "sitemap.json",
"lazyCodeLoading": "requiredComponents" "lazyCodeLoading": "requiredComponents"

View File

@@ -22,8 +22,15 @@ Page({
wx.request({ wx.request({
url: requestUrl + '/api/get-menu', // 更改为你的实际API地址 url: requestUrl + '/api/get-menu', // 更改为你的实际API地址
success: (res) => { success: (res) => {
let code = res.data.code
console.log(res.data) console.log(res.data)
this.setData({ menuItems: res.data.data }); if (code == 0) {
console.log("请求菜单信息成功")
this.setData({ menuItems: res.data.data });
} else{
console.log("请求菜单信息失败")
}
} }
}); });
}, },

View File

@@ -12,7 +12,7 @@
<view class="grid-container"> <view class="grid-container">
<view class="card"> <view class="card">
<navigator wx:for="{{menuItems}}" wx:key="id" url="{{item.url}}" class="grid-item"> <navigator wx:for="{{menuItems}}" wx:key="id" url="{{item.url}}" class="grid-item">
<image src="data:image/png;base64,{{item.base64EncodedImage}}"></image> <image src="{{item.image_url}}"></image>
<text>{{item.menu_name}}</text> <text>{{item.menu_name}}</text>
</navigator> </navigator>
</view> </view>

View File

@@ -1,5 +1,5 @@
import { requestUrl } from '../../utils/config.js'; import { requestUrl } from '../../utils/config.js';
function showTost(title){ function showToast(title){
wx.showToast({ wx.showToast({
title: title, title: title,
icon: "none", icon: "none",
@@ -14,7 +14,8 @@ Page({
*/ */
data: { data: {
phoneNumber: '', // 手机号 phoneNumber: '', // 手机号
password: '' // 密码 password: '', // 密码
checked: false,
}, },
handlePhoneInput(event) { handlePhoneInput(event) {
this.setData({ phoneNumber: event.detail.value }); this.setData({ phoneNumber: event.detail.value });
@@ -22,8 +23,23 @@ Page({
handlePasswordInput(event) { handlePasswordInput(event) {
this.setData({ password: event.detail.value }); this.setData({ password: event.detail.value });
}, },
togglePasswordVisibility() {
this.setData({ passwordVisible: !this.data.passwordVisible });
},
checkAccepted(e) {
if(e.detail.value.length>0){
this.setData({
checked:true
})
}else{
this.setData({
checked:false
})
}
},
handleLogin() { handleLogin() {
wx.request({ if (this.data.checked) {
wx.request({
url: requestUrl + '/user/login', // 你的接口地址 url: requestUrl + '/user/login', // 你的接口地址
method: 'POST', method: 'POST',
data: { data: {
@@ -36,15 +52,15 @@ Page({
success(res) { success(res) {
if (res.data.code == 0 && res.data.msg == "ok"){ if (res.data.code == 0 && res.data.msg == "ok"){
console.log("登录成功",res.data.code) console.log("登录成功",res.data.code)
showTost("登录成功") showToast("登录成功")
// wx.redirectTo({ // wx.redirectTo({
// url: 'pages/home/home', // url: 'pages/home/home',
// }) // })
wx.switchTab({ wx.redirectTo({
url: 'pages/home/home' url: '/pages/home/home'
}) })
} else { } else {
showTost(res.data.msg) showToasst(res.data.msg)
console.log("登录失败",res.data) console.log("登录失败",res.data)
} }
}, },
@@ -52,6 +68,13 @@ Page({
console.log('登录失败', error); console.log('登录失败', error);
} }
}); });
} else {
// 如果协议未被接受,显示提示或者阻止登录
wx.showToast({
title: '请先同意用户使用协议',
icon: 'none',
});
}
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载

View File

@@ -7,14 +7,16 @@
<!-- 手机号输入区 --> <!-- 手机号输入区 -->
<view class="phone"> <view class="phone">
<image src="/assets/images/icon/Phone.svg" class="phone-icon"></image> <image src="/assets/images/icon/Phone.svg" class="phone-icon"></image>
<input bindinput ="handlePhoneInput" placeholder="请输入手机号" /> <input bindinput="handlePhoneInput" placeholder="请输入手机号" />
</view> </view>
<!-- 密码输入区 --> <!-- 密码输入区 -->
<view class="password"> <view class="password">
<image src="/assets/images/icon/password.svg" class="password-icon"></image> <image src="/assets/images/icon/password.svg" class="password-icon"></image>
<input type="password" bindinput="handlePasswordInput" placeholder="请输入密码" /> <!-- 根据passwordVisible动态设置input类型 -->
<image src="/assets/images/icon/eye.svg" class="eye-icon"></image> <input type="{{passwordVisible ? 'text' : 'password'}}" bindinput="handlePasswordInput" placeholder="请输入密码" />
<!-- 绑定点击事件到togglePasswordVisibility函数 -->
<image src="/assets/images/icon/eye.svg" class="eye-icon" bindtap="togglePasswordVisibility"></image>
</view> </view>
<!-- 忘记密码链接 --> <!-- 忘记密码链接 -->
@@ -24,14 +26,16 @@
<!-- 登录按钮 --> <!-- 登录按钮 -->
<view class="login-btn"> <view class="login-btn">
<button class="btn-dl" bind:tap="handleLogin" type="primary">登录</button> <!-- 绑定点击事件到handleLogin函数 -->
<button class="btn-dl" bindtap="handleLogin" type="primary">登录</button>
</view> </view>
<!-- 协议区 --> <!-- 协议区 -->
<view class="agreement-area"> <checkbox-group bindchange="checkAccepted" class="agreement-area">
<checkbox class="agreement"></checkbox> <checkbox class="agreement-box" checked="{{checked}}"></checkbox>
<view class="agreement-text">同意小程序《使用协议》</view> <view class="agreement-text">小程序《用户使用协议》</view>
</view> </checkbox-group>
</view> </view>
<!-- 登录提示框 --> <!-- 登录提示框 -->

View File

@@ -123,7 +123,7 @@
position: absolute; position: absolute;
} }
/* 复选框 */ /* 复选框 */
.login .login-card .agreement-area .agreement{ .login .login-card .agreement-area .agreement-box{
margin-left: 85rpx; margin-left: 85rpx;
/* 修改复选框的大小 */ /* 修改复选框的大小 */
transform:scale(.6); transform:scale(.6);

View File

@@ -1,38 +1,32 @@
// pages/policy/policy.js // pages/policy/policy.js
import { requestUrl } from '../../utils/config.js';
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
policies: [ policy_list:[],
{ title: "政策标题1", date: "2024-01-01" },
{ title: "政策标题2", date: "2023-01-02" },
{ title: "政策标题3", date: "2022-01-02" },
{ title: "政策标题4", date: "2023-01-02" },
{ title: "政策标题5", date: "2022-01-02" },
{ title: "政策标题6", date: "2023-01-02" },
{ title: "政策标题7", date: "2021-01-02" },
{ title: "政策标题8", date: "2021-01-02" },
{ title: "政策标题9", date: "2024-02-02" },
{ title: "政策标题10", date: "2024-03-02" },
{ title: "政策标题11", date: "2024-04-02" },
{ title: "政策标题12", date: "2024-01-02" },
{ title: "政策标题13", date: "2024-01-02" },
{ title: "政策标题14", date: "2024-01-02" },
{ title: "政策标题15", date: "2024-01-02" },
{ title: "政策标题16", date: "2024-01-02" },
{ title: "政策标题17", date: "2024-01-02" },
// 更多政策数据...
]
// 更多数据...
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
wx.request({
url:requestUrl + '/api/policy-list',
method: 'GET',
success: (res) => {
let code = res.data.code
if (code == 0) {
console.log("请求政策列表成功")
this.setData({policy_list:res.data.data});
} else {
console.log('请求政策列表失败')
}
}
})
}, },
/** /**

View File

@@ -1,19 +1,18 @@
<view class="policy-page"> <view class="policy-page">
<!-- 搜索框 --> <!-- 搜索框 -->
<view class="search-bar"> <view class="search-bar">
<input type="text" placeholder="请输入关键字搜索" confirm-type="search" /> <input class="input-class" type="text" placeholder="请输入关键字搜索" confirm-type="search" />
</view> </view>
<!-- 政策列表 --> <!-- 政策列表 -->
<view class="policy-list"> <view class="policy-list">
<!-- 循环遍历政策数据 --> <!-- 循环遍历政策数据 -->
<block wx:for="{{policies}}" wx:key="unique"> <block wx:for="{{policy_list}}" wx:key="unique">
<!-- 每项政策使用圆角矩形卡片展示 --> <!-- 每项政策使用圆角矩形卡片展示 -->
<view class="policy-card"> <view class="policy-card">
<view class="policy-item"> <view class="policy-item">
<view class="title">{{item.title}} <text class="title">{{item.title}}</text>
</view> <text class="date">发布时间:{{item.date}}</text>
<view class="date">发布时间:{{item.date}}</view>
</view> </view>
</view> </view>
</block> </block>

View File

@@ -3,22 +3,25 @@
flex-direction: column; flex-direction: column;
} }
.search-bar input { .search-bar, .input-class {
width: 90%; width: 90%;
padding: 10px; padding: 10px;
border: 1px solid #ccc; /* 轻微边框 */ border: 1px solid #ccc; /* 轻微边框 */
border-radius: 5px; /* 圆角 */ border-radius: 5px; /* 圆角 */
margin:0 auto; /* 上下保持0左右自动实现水平居中 */ margin:0 auto; /* 上下保持0左右自动实现水平居中 */
} }
.policy-item .title, .policy-item .date {
display: block;
}
.policy-list .policy-item { .policy-list .policy-item {
padding: 10px; padding: 10rpx;
} }
.policy-item .title { .policy-item .title {
font-size: 18px; font-size: 36rpx;
color: #333; color: #333;
} }
@@ -31,6 +34,6 @@
background-color: white; /* 卡片背景色 */ background-color: white; /* 卡片背景色 */
border-radius: 10px; /* 圆角 */ border-radius: 10px; /* 圆角 */
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); /* 阴影效果 */ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); /* 阴影效果 */
margin: 10px; /* 外边距,根据需要调整 */ margin: 20rpx; /* 外边距,根据需要调整 */
padding: 15px; /* 内边距,根据需要调整 */ padding: 20rpx; /* 内边距,根据需要调整 */
} }

View File

@@ -1,6 +1,6 @@
// 在config.js // 在config.js
//本地测试 //本地测试
// const requestUrl = "http://127.0.0.1:8000"; const requestUrl = "http://127.0.0.1:8000";
// 服务器测试 // 服务器测试
const requestUrl = "https://wx-ed1284f.kimgo.cn"; // const requestUrl = "https://wx-ed1284f.kimgo.cn";
export { requestUrl }; export { requestUrl };