Files
lunar-mini/mini/pages/wish-tree/wish-tree.wxml
T
gouki 63bcd9f412
Publish Mini Program Dev Version / publish (push) Successful in 4m10s
refactor(wish-tree): 用 WebGL 重写许愿树
- 移除 Canvas 2D 绘制,改用 WebGL
- 手写着色器实现光照和发光效果
- 树干使用圆柱体变形,带扭曲效果
- 树冠使用多层变形球体,带噪声
- 相机自动旋转,可触摸控制
- 保留陀螺仪和麦克风交互
- 简化场景,只保留一棵祈福树
- 深色主题 UI,金色点缀
2026-08-08 14:08:33 +00:00

107 lines
3.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<view class="container">
<!-- WebGL Canvas -->
<canvas
type="webgl"
id="webgl-canvas"
class="webgl-canvas"
bindtouchstart="onCanvasTouch"
bindtouchmove="onCanvasMove"
bindtouchend="onCanvasEnd"
></canvas>
<!-- 顶部导航 -->
<view class="top-bar">
<view class="tree-info">
<text class="tree-name">{{treeName}}</text>
<text class="tree-desc">{{treeDesc}}</text>
</view>
<!-- 传感器控制 -->
<view class="sensor-controls">
<view class="sensor-btn {{micEnabled ? 'active' : ''}}" bindtap="enableMicrophone">
<text class="sensor-icon">🎤</text>
</view>
</view>
</view>
<!-- 许愿按钮 -->
<view class="action-bar">
<button class="btn-wish" bindtap="openCreateModal">
<text class="icon">🙏</text>
<text>我要许愿</text>
</button>
</view>
<!-- 许愿弹窗 -->
<view class="modal" wx:if="{{showCreateModal}}">
<view class="modal-mask" bindtap="closeCreateModal"></view>
<view class="modal-content">
<view class="modal-header">
<text class="modal-title">许下心愿</text>
<text class="modal-close" bindtap="closeCreateModal">×</text>
</view>
<view class="modal-body">
<!-- 许愿类型选择 -->
<view class="type-selector">
<view
class="type-item {{wishType === 'free' ? 'active' : ''}}"
bindtap="selectType"
data-type="free"
>
<text class="type-name">免费许愿</text>
<text class="type-desc">20字以内</text>
</view>
<view
class="type-item {{wishType === 'paid' ? 'active' : ''}}"
bindtap="selectType"
data-type="paid"
>
<text class="type-name">付费许愿</text>
<text class="type-desc">更多特权</text>
</view>
</view>
<!-- 许愿内容输入 -->
<textarea
class="wish-input"
placeholder="请输入你的愿望..."
maxlength="{{wishType === 'free' ? maxFreeLength : maxPaidLength}}"
bindinput="onInputContent"
value="{{wishContent}}"
></textarea>
<view class="input-count">
{{wishContent.length}}/{{wishType === 'free' ? maxFreeLength : maxPaidLength}}
</view>
<!-- 付费商品选择 -->
<view class="product-section" wx:if="{{wishType === 'paid'}}">
<view class="section-title">选择许愿商品</view>
<view class="product-list">
<view
wx:for="{{products}}"
wx:key="id"
class="product-item {{selectedProduct && selectedProduct.id === item.id ? 'active' : ''}}"
bindtap="selectProduct"
data-id="{{item.id}}"
>
<view class="product-info">
<text class="product-name">{{item.name}}</text>
<text class="product-desc">展示{{item.duration}}天</text>
</view>
<view class="product-price">¥{{item.price / 100}}</view>
</view>
</view>
</view>
</view>
<view class="modal-footer">
<button class="btn-outline" bindtap="closeCreateModal">取消</button>
<button class="btn-primary" bindtap="submitWish">
{{wishType === 'paid' ? '支付并许愿' : '提交许愿'}}
</button>
</view>
</view>
</view>
</view>