Initial commit

This commit is contained in:
admin
2025-12-09 02:45:30 +08:00
commit 0bbb3d0a47
303 changed files with 22764 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
const app = getApp()
Page({
data: {
user: {},
formData: {
name: '',
phone: '',
age: '',
education: '',
address: ''
}
},
onLoad() {
this.fetchUser();
},
fetchUser() {
const { request } = require('../../utils/request')
request({ url: '/user' })
.then((data) => {
this.setData({ user: data })
})
.catch(() => {
this.setData({
user: {
id: '8839201',
name: '学员用户',
avatar:
'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=200&auto=format&fit=crop&q=60',
stats: {
learning: 12,
coupons: 3,
hours: 28
}
}
})
})
},
handleInput(e) {
const field = e.currentTarget.dataset.field;
const value = e.detail.value;
this.setData({
[`formData.${field}`]: value
});
},
handleSubmit() {
console.log(this.data.formData);
wx.showToast({
title: '保存成功',
icon: 'success'
})
const { request } = require('../../utils/request')
request({ url: '/user', method: 'POST', data: this.data.formData })
.then((data) => {
console.log(data)
})
}
})

View File

@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "个人中心"
}

View File

@@ -0,0 +1,71 @@
<view class="container">
<view class="profile-header">
<view class="user-info">
<image class="avatar" src="{{user.avatar}}" mode="aspectFill"></image>
<view class="user-details">
<view class="username">{{user.name}}</view>
<view class="userid">ID: {{user.id}}</view>
</view>
</view>
<view class="stats-card">
<view class="stat-item">
<view class="stat-val">{{user.stats.learning}}</view>
<view class="stat-label">在学课程</view>
</view>
<view class="stat-item">
<view class="stat-val">{{user.stats.coupons}}</view>
<view class="stat-label">优惠券</view>
</view>
<view class="stat-item">
<view class="stat-val">{{user.stats.hours}}h</view>
<view class="stat-label">学习时长</view>
</view>
</view>
</view>
<view class="form-section">
<view class="form-title-bar">
<view class="blue-line"></view>
<text class="form-title">录入学员信息</text>
</view>
<view class="form-group">
<text class="label">学员姓名</text>
<view class="input-wrap">
<input type="text" placeholder="请输入真实姓名" bindinput="handleInput" data-field="name" value="{{formData.name}}"/>
</view>
</view>
<view class="form-group">
<text class="label">联系电话</text>
<view class="input-wrap">
<input type="number" placeholder="请输入手机号码" bindinput="handleInput" data-field="phone" value="{{formData.phone}}"/>
</view>
</view>
<view class="form-row">
<view class="form-group half">
<text class="label">年龄</text>
<view class="input-wrap">
<input type="number" placeholder="0" bindinput="handleInput" data-field="age" value="{{formData.age}}"/>
</view>
</view>
<view class="form-group half">
<text class="label">学历</text>
<view class="input-wrap">
<input type="text" placeholder="学历" bindinput="handleInput" data-field="education" value="{{formData.education}}"/>
</view>
</view>
</view>
<view class="form-group">
<text class="label">居住地址</text>
<view class="input-wrap">
<input type="text" placeholder="请输入详细地址" bindinput="handleInput" data-field="address" value="{{formData.address}}"/>
</view>
</view>
<button class="submit-btn" bindtap="handleSubmit">保存信息</button>
</view>
</view>

View File

@@ -0,0 +1,112 @@
.container {
min-height: 100vh;
background-color: #f9fafb;
}
.profile-header {
background-color: white;
padding: 40rpx 40rpx 100rpx 40rpx;
position: relative;
margin-bottom: 60rpx;
}
.user-info {
display: flex;
align-items: center;
gap: 30rpx;
}
.avatar {
width: 128rpx;
height: 128rpx;
border-radius: 50%;
border: 4rpx solid white;
box-shadow: 0 4rpx 10rpx rgba(0,0,0,0.1);
background-color: #eee;
}
.user-details {
display: flex;
flex-direction: column;
}
.username {
font-size: 40rpx;
font-weight: bold;
color: #1f2937;
}
.userid {
font-size: 28rpx;
color: #6b7280;
}
.stats-card {
position: absolute;
bottom: -40rpx;
left: 40rpx;
right: 40rpx;
background-color: white;
border-radius: 20rpx;
box-shadow: 0 10rpx 30rpx rgba(0,0,0,0.05);
padding: 30rpx;
display: flex;
justify-content: space-around;
text-align: center;
}
.stat-val {
font-size: 36rpx;
font-weight: bold;
color: #1f2937;
}
.stat-label {
font-size: 24rpx;
color: #9ca3af;
}
.form-section {
padding: 40rpx;
background-color: white;
margin: 0 30rpx 40rpx 30rpx;
border-radius: 30rpx;
box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.05);
}
.form-title-bar {
display: flex;
align-items: center;
margin-bottom: 40rpx;
gap: 16rpx;
}
.blue-line {
width: 8rpx;
height: 32rpx;
background-color: #2563eb;
border-radius: 4rpx;
}
.form-title {
font-size: 32rpx;
font-weight: bold;
color: #1f2937;
}
.form-group {
margin-bottom: 30rpx;
}
.label {
font-size: 24rpx;
color: #6b7280;
margin-bottom: 10rpx;
display: block;
}
.input-wrap {
background-color: #f9fafb;
padding: 24rpx;
border-radius: 20rpx;
border: 2rpx solid #f3f4f6;
}
.form-row {
display: flex;
gap: 30rpx;
}
.half {
flex: 1;
}
.submit-btn {
background-color: #2563eb;
color: white;
border-radius: 20rpx;
margin-top: 40rpx;
font-weight: bold;
font-size: 32rpx;
}