Initial commit: gmTouringMiniApp project
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
// pages/poi/poi.js
|
||||
const userStore = require('../../userStore.js');
|
||||
|
||||
// 模拟的景点数据,实际项目中可以来自云端接口
|
||||
const POI_LIST = [
|
||||
{ id: 'poi_001', name: '西湖', icon: '🌊', desc: '杭州最著名的湖泊' },
|
||||
{ id: 'poi_002', name: '灵隐寺', icon: '🛕', desc: '千年古刹,禅意悠远' },
|
||||
{ id: 'poi_003', name: '雷峰塔', icon: '🗼', desc: '白娘子传说所在地' },
|
||||
{ id: 'poi_004', name: '西溪湿地', icon: '🌾', desc: '城市中的绿色湿地' },
|
||||
{ id: 'poi_005', name: '千岛湖', icon: '🏝️', desc: '碧水青山,湖光山色' }
|
||||
];
|
||||
|
||||
Page({
|
||||
data: {
|
||||
points: 0,
|
||||
badgeCount: 0,
|
||||
pois: []
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.refresh();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.refresh();
|
||||
},
|
||||
|
||||
// 每次刷新:把打卡状态合并到景点列表中,同时更新顶部积分/徽章数
|
||||
refresh() {
|
||||
const data = userStore.getUserData();
|
||||
const checkedSet = new Set(data.checkIns.map(c => c.poiId));
|
||||
|
||||
const pois = POI_LIST.map(p => ({
|
||||
...p,
|
||||
checked: checkedSet.has(p.id)
|
||||
}));
|
||||
|
||||
this.setData({
|
||||
points: data.points,
|
||||
badgeCount: data.badges.length,
|
||||
pois
|
||||
});
|
||||
},
|
||||
|
||||
// 点击打卡按钮
|
||||
onCheckIn(e) {
|
||||
const { id, name } = e.currentTarget.dataset;
|
||||
const res = userStore.checkIn(id, name);
|
||||
|
||||
wx.showToast({
|
||||
title: res.message,
|
||||
icon: res.success ? 'success' : 'none',
|
||||
duration: 1500
|
||||
});
|
||||
|
||||
if (res.success) {
|
||||
this.refresh();
|
||||
}
|
||||
},
|
||||
|
||||
// 跳转到徽章页面
|
||||
goBadges() {
|
||||
wx.navigateTo({ url: '/pages/badges/badges' });
|
||||
},
|
||||
|
||||
// 调试用:清空本地数据
|
||||
onResetData() {
|
||||
wx.showModal({
|
||||
title: '确认清空',
|
||||
content: '将清除所有积分、徽章和打卡记录',
|
||||
success: (r) => {
|
||||
if (r.confirm) {
|
||||
wx.clearStorageSync();
|
||||
this.refresh();
|
||||
wx.showToast({ title: '已清空', icon: 'success' });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"navigationBarTitleText": "景点打卡",
|
||||
"navigationBarBackgroundColor": "#fff8ec",
|
||||
"navigationBarTextStyle": "black",
|
||||
"backgroundColor": "#fff8ec"
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<!--pages/poi/poi.wxml-->
|
||||
<view class="page">
|
||||
|
||||
<!-- 顶部用户信息卡片 -->
|
||||
<view class="header-card" bindtap="goBadges">
|
||||
<view class="header-left">
|
||||
<view class="header-label">我的积分</view>
|
||||
<view class="header-points">
|
||||
<text class="points-num">{{points}}</text>
|
||||
<text class="points-unit"> 分</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="header-right">
|
||||
<view class="badge-count">
|
||||
<text class="badge-count-num">{{badgeCount}}</text>
|
||||
<text class="badge-count-label">枚徽章</text>
|
||||
</view>
|
||||
<view class="arrow">查看 ›</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 景点列表 -->
|
||||
<view class="section-title">热门景点</view>
|
||||
|
||||
<view class="poi-list">
|
||||
<view class="poi-item" wx:for="{{pois}}" wx:key="id">
|
||||
<view class="poi-icon">{{item.icon}}</view>
|
||||
<view class="poi-info">
|
||||
<view class="poi-name">{{item.name}}</view>
|
||||
<view class="poi-desc">{{item.desc}}</view>
|
||||
</view>
|
||||
<button
|
||||
class="poi-btn {{item.checked ? 'poi-btn-done' : ''}}"
|
||||
disabled="{{item.checked}}"
|
||||
data-id="{{item.id}}"
|
||||
data-name="{{item.name}}"
|
||||
bindtap="onCheckIn"
|
||||
>
|
||||
{{item.checked ? '已打卡' : '打卡 +10'}}
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 调试按钮:清空数据 -->
|
||||
<view class="reset-wrap">
|
||||
<button class="reset-btn" bindtap="onResetData">清空本地数据(调试)</button>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
@@ -0,0 +1,156 @@
|
||||
/* pages/poi/poi.wxss */
|
||||
|
||||
.page {
|
||||
min-height: 100vh;
|
||||
padding: 24rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* 顶部积分卡片 */
|
||||
.header-card {
|
||||
background: linear-gradient(135deg, #ffb347 0%, #ff7e5f 100%);
|
||||
border-radius: 24rpx;
|
||||
padding: 36rpx 32rpx;
|
||||
color: #fff;
|
||||
box-shadow: 0 8rpx 24rpx rgba(255, 126, 95, 0.25);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.header-label {
|
||||
font-size: 26rpx;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.header-points {
|
||||
margin-top: 8rpx;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.points-num {
|
||||
font-size: 64rpx;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.points-unit {
|
||||
font-size: 28rpx;
|
||||
margin-left: 6rpx;
|
||||
}
|
||||
|
||||
.header-right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.badge-count-num {
|
||||
font-size: 40rpx;
|
||||
font-weight: 700;
|
||||
margin-right: 6rpx;
|
||||
}
|
||||
|
||||
.badge-count-label {
|
||||
font-size: 24rpx;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
margin-top: 12rpx;
|
||||
font-size: 22rpx;
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
/* 分区标题 */
|
||||
.section-title {
|
||||
margin: 40rpx 8rpx 20rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
/* 景点列表 */
|
||||
.poi-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.poi-item {
|
||||
background: #ffffff;
|
||||
border-radius: 20rpx;
|
||||
padding: 24rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.poi-icon {
|
||||
width: 96rpx;
|
||||
height: 96rpx;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, #fff2d6, #ffe0b3);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 52rpx;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.poi-info {
|
||||
flex: 1;
|
||||
margin: 0 24rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.poi-name {
|
||||
font-size: 30rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.poi-desc {
|
||||
margin-top: 6rpx;
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
/* 打卡按钮 */
|
||||
.poi-btn {
|
||||
min-width: 160rpx;
|
||||
height: 64rpx;
|
||||
line-height: 64rpx;
|
||||
padding: 0 24rpx;
|
||||
font-size: 26rpx;
|
||||
color: #fff;
|
||||
background: linear-gradient(135deg, #ffb347, #ff7e5f);
|
||||
border-radius: 32rpx;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.poi-btn-done {
|
||||
background: #e5e5e5 !important;
|
||||
color: #999 !important;
|
||||
}
|
||||
|
||||
.poi-btn[disabled] {
|
||||
background: #e5e5e5 !important;
|
||||
color: #999 !important;
|
||||
}
|
||||
|
||||
/* 调试按钮 */
|
||||
.reset-wrap {
|
||||
margin: 60rpx 0 40rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.reset-btn {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
background: transparent;
|
||||
padding: 12rpx 32rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user