| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271 |
- <template>
- <view class="timing-setting-page">
- <custom-card>
- <block slot="backText">定时设置</block>
- <block slot="right">
- <view class="right-icons">
- <u-icon name="more-dot-fill" color="#333333" size="36rpx" style="margin-right: 16rpx;" />
- <u-icon name="camera" color="#333333" size="36rpx" />
- </view>
- </block>
- </custom-card>
- <view class="timing-content">
- <!-- 定时卡片列表 -->
- <view
- class="timer-card"
- v-for="(timer, index) in timerList"
- :key="index"
- >
- <!-- 定时标题和开关 -->
- <view class="timer-header">
- <text class="timer-title">定时{{ index + 1 }}</text>
- <switch
- :checked="timer.enabled"
- @change="onSwitchChange($event, index)"
- color="#00c853"
- class="timer-switch"
- />
- </view>
- <!-- 单选按钮组 -->
- <view class="radio-group">
- <view
- class="radio-item"
- :class="{ active: timer.frequency === 'once' }"
- @click="selectFrequency(index, 'once')"
- >
- <view class="radio-icon">
- <view v-if="timer.frequency === 'once'" class="radio-dot"></view>
- </view>
- <text class="radio-text">仅一次</text>
- </view>
- <view
- class="radio-item"
- :class="{ active: timer.frequency === 'daily' }"
- @click="selectFrequency(index, 'daily')"
- >
- <view class="radio-icon">
- <view v-if="timer.frequency === 'daily'" class="radio-dot"></view>
- </view>
- <text class="radio-text">每天一次</text>
- </view>
- </view>
- <!-- 时间选择器 -->
- <picker
- mode="time"
- :value="timer.time"
- @change="onTimeChange($event, index)"
- >
- <view class="time-picker">
- <text class="time-text" :class="{ placeholder: !timer.time }">
- {{ timer.time || '请选择时间' }}
- </text>
- <u-icon name="clock" color="#999999" size="32rpx" />
- </view>
- </picker>
- </view>
- <!-- 确定按钮 -->
- <view class="confirm-btn" @click="handleConfirm">
- <text class="confirm-text">确定</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- timerList: [
- { enabled: false, frequency: 'once', time: '' },
- { enabled: false, frequency: 'once', time: '' },
- { enabled: false, frequency: 'once', time: '' },
- { enabled: false, frequency: 'once', time: '' },
- { enabled: false, frequency: 'once', time: '' },
- ],
- };
- },
- methods: {
- // 开关状态改变
- onSwitchChange(e, index) {
- this.timerList[index].enabled = e.detail.value;
- },
- // 选择频率
- selectFrequency(index, frequency) {
- this.timerList[index].frequency = frequency;
- },
- // 时间改变
- onTimeChange(e, index) {
- this.timerList[index].time = e.detail.value;
- },
- // 确认按钮
- handleConfirm() {
- const enabledTimers = this.timerList.filter((timer, index) => {
- if (timer.enabled) {
- if (!timer.time) {
- uni.showToast({
- title: `定时${index + 1}请选择时间`,
- icon: 'none'
- });
- return false;
- }
- return true;
- }
- return false;
- });
- console.log('保存的定时设置:', enabledTimers);
- uni.showToast({
- title: '保存成功',
- icon: 'success'
- });
- // TODO: 调用接口保存定时设置
- },
- },
- };
- </script>
- <style scoped lang="scss">
- uni-page-body {
- position: relative;
- height: 100%;
- }
- .timing-setting-page {
- min-height: 100%;
- background: linear-gradient(180deg, #e6f7f0 0%, #ffffff 100%);
- overflow-x: hidden;
- overflow-y: auto;
- .right-icons {
- display: flex;
- align-items: center;
- }
- .timing-content {
- padding: 24rpx 32rpx;
- }
- // 定时卡片
- .timer-card {
- background: #ffffff;
- border-radius: 12rpx;
- padding: 24rpx;
- margin-bottom: 20rpx;
- // 卡片头部
- .timer-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 24rpx;
- .timer-title {
- font-size: 32rpx;
- font-weight: 600;
- color: #333333;
- font-family: 'Source Han Sans CN';
- }
- .timer-switch {
- transform: scale(0.9);
- }
- }
- // 单选按钮组
- .radio-group {
- display: flex;
- margin-bottom: 24rpx;
- .radio-item {
- display: flex;
- align-items: center;
- margin-right: 48rpx;
- cursor: pointer;
- .radio-icon {
- width: 36rpx;
- height: 36rpx;
- border: 4rpx solid #cccccc;
- border-radius: 50%;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-right: 12rpx;
- box-sizing: border-box;
- .radio-dot {
- width: 18rpx;
- height: 18rpx;
- background: #00c853;
- border-radius: 50%;
- }
- }
- &.active {
- .radio-icon {
- border-color: #00c853;
- }
- .radio-text {
- color: #333333;
- }
- }
- .radio-text {
- font-size: 28rpx;
- color: #999999;
- font-family: 'Source Han Sans CN';
- }
- }
- }
- // 时间选择器
- .time-picker {
- display: flex;
- justify-content: space-between;
- align-items: center;
- padding: 20rpx 24rpx;
- background: #f5f5f5;
- border-radius: 8rpx;
- .time-text {
- font-size: 28rpx;
- color: #333333;
- font-family: 'Source Han Sans CN';
- &.placeholder {
- color: #999999;
- }
- }
- }
- }
- // 确定按钮
- .confirm-btn {
- width: 100%;
- height: 88rpx;
- background: #00c853;
- border-radius: 12rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-top: 20rpx;
- .confirm-text {
- font-size: 32rpx;
- font-weight: 500;
- color: #ffffff;
- font-family: 'Source Han Sans CN';
- }
- }
- }
- </style>
|