较为完整的微信点餐小程序个人中心页面代码
时间: 2023-12-30 12:04:24 浏览: 320
以下是一个简单的微信点餐小程序个人中心页面的代码:
```html
<!--wxml文件-->
<view class="container">
<view class="user-info">
<image class="avatar" src="{{userInfo.avatarUrl}}"></image>
<text class="nickname">{{userInfo.nickName}}</text>
</view>
<view class="order-list">
<view class="order-item" wx:for="{{orderList}}" wx:key="index">
<view class="order-item-header">
<text class="order-id">订单号:{{item.orderId}}</text>
<text class="order-status">{{item.status}}</text>
</view>
<view class="order-item-body">
<view class="order-item-food" wx:for="{{item.foodList}}" wx:key="index">
<image class="food-image" src="{{item.image}}"></image>
<text class="food-name">{{item.name}}</text>
<text class="food-price">{{item.price}}</text>
</view>
</view>
<view class="order-item-footer">
<view class="order-time">{{item.time}}</view>
<view class="order-total-price">总价:{{item.totalPrice}}</view>
</view>
</view>
</view>
</view>
```
```css
/*wxss文件*/
.container {
padding: 20rpx;
}
.user-info {
display: flex;
align-items: center;
margin-bottom: 20rpx;
}
.avatar {
width: 80rpx;
height: 80rpx;
border-radius: 50%;
margin-right: 20rpx;
}
.nickname {
font-size: 32rpx;
color: #333;
}
.order-list {
display: flex;
flex-direction: column;
}
.order-item {
margin-bottom: 20rpx;
border: 1rpx solid #eee;
border-radius: 10rpx;
padding: 20rpx;
}
.order-item-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10rpx;
}
.order-id {
font-size: 28rpx;
color: #666;
}
.order-status {
font-size: 24rpx;
color: #f00;
}
.order-item-body {
display: flex;
flex-direction: column;
}
.order-item-food {
display: flex;
align-items: center;
margin-bottom: 10rpx;
}
.food-image {
width: 80rpx;
height: 80rpx;
margin-right: 10rpx;
}
.food-name {
font-size: 28rpx;
color: #333;
}
.food-price {
font-size: 24rpx;
color: #f00;
margin-left: auto;
}
.order-item-footer {
display: flex;
justify-content: space-between;
align-items: center;
}
.order-time {
font-size: 24rpx;
color: #999;
}
.order-total-price {
font-size: 28rpx;
color: #f00;
}
```
```javascript
//js文件
Page({
data: {
userInfo: {},
orderList: [
{
orderId: "001",
status: "已完成",
time: "2022-05-01 12:00:00",
totalPrice: 99.99,
foodList: [
{
name: "麻辣烫",
image: "/images/food1.jpg",
price: 29.99
},
{
name: "炸鸡",
image: "/images/food2.jpg",
price: 39.99
},
{
name: "可乐",
image: "/images/food3.jpg",
price: 9.99
}
]
},
{
orderId: "002",
status: "待付款",
time: "2022-05-02 12:00:00",
totalPrice: 88.88,
foodList: [
{
name: "热干面",
image: "/images/food4.jpg",
price: 18.88
},
{
name: "汉堡",
image: "/images/food5.jpg",
price: 29.99
},
{
name: "雪碧",
image: "/images/food6.jpg",
price: 9.99
}
]
}
]
},
onLoad: function () {
// 获取用户信息
wx.getUserInfo({
success: res => {
this.setData({
userInfo: res.userInfo
})
}
})
}
})
```
以上代码仅作为示例,实际应用中可能需要根据具体需求进行修改和完善。
阅读全文