#
zhou zhou
3 天以前 eb9838ebbf1017bbe2fbe981dfc4be2bf26528e7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
<template>
    <view class="page-container">
        <u-navbar
            :title="$t('settings.title')"
            :fixed="true"
            :placeholder="true"
            :autoBack="true"
            bgColor="#ffffff"
            titleStyle="font-weight: 600; color: #303133; font-size: 32rpx;"
        ></u-navbar>
 
        <view class="content">
            <u-cell-group :border="false">
                <u-cell
                    v-for="(item, index) in settingsList"
                    :key="index"
                    :title="item.title"
                    :border="true"
                    size="large"
                    titleStyle="font-size: 30rpx; color: #333333;"
                >
                    <view
                        slot="icon"
                        :class="['cell-icon-wrap', item.iconBgColor]"
                    >
                        <u-icon
                            :name="item.iconName"
                            color="#ffffff"
                            size="20"
                        ></u-icon>
                    </view>
                    
                    <!-- 开关类型设置项 -->
                    <view slot="value" v-if="item.type === 'switch'">
                        <u-switch
                            v-model="appSettings[item.key]"
                            @change="saveSettings"
                            size="24"
                            activeColor="#2979ff"
                        ></u-switch>
                    </view>
                    
                    <!-- 输入框类型设置项 -->
                    <view slot="value" v-else-if="item.type === 'input'" style="width: 200rpx;" @tap.stop>
                        <u--input
                            v-model="appSettings[item.key]"
                            @blur="saveSettings"
                            border="none"
                            inputAlign="right"
                            :placeholder="$t('settings.inputPlaceholder')"
                        ></u--input>
                    </view>
                    
                    <!-- 数字输入框类型设置项 -->
                    <view slot="value" v-else-if="item.type === 'number'" style="width: 200rpx;" @tap.stop>
                        <u--input
                            type="number"
                            v-model="appSettings[item.key]"
                            @blur="saveSettings"
                            border="none"
                            inputAlign="right"
                            :placeholder="$t('settings.inputPlaceholder')"
                        ></u--input>
                    </view>
                    
                    <!-- 图标/箭头类型(例如跳转其它设置页) -->
                    <!-- 可以根据需要扩展 v-else-if="item.type === 'link'" -->
                </u-cell>
 
                <!-- 如果需要配置更多设置项,可以参考下方的样式结构 -->
                <!--
                <u-cell
                    title="其他设置"
                    :border="true"
                    :isLink="true"
                    size="large"
                    titleStyle="font-size: 30rpx; color: #333333;"
                >
                    <view slot="icon" class="cell-icon-wrap bg-yellow">
                        <u-icon name="setting" color="#ffffff" size="20"></u-icon>
                    </view>
                </u-cell>
                -->
            </u-cell-group>
        </view>
    </view>
</template>
 
<script>
export default {
    data() {
        return {
            appSettings: {
                orderReviewRequired: false,
                orderPakinRequiresMainList: false,
                orderDetlMultiSelect: false,
                orderCombNeedSplit: true,
                orderCombSeparator: ';',
                orderCombArrayIndex: 0,
                orderCombStartPos: 3
            }
        }
    },
    computed: {
        settingsList() {
            return [
                {
                    key: 'orderReviewRequired',
                    title: this.$t('settings.orderReviewRequired'),
                    iconName: 'checkbox-mark',
                    iconBgColor: 'bg-blue',
                    type: 'switch'
                },
                {
                    key: 'orderPakinRequiresMainList',
                    title: this.$t('settings.orderPakinRequiresMainList'),
                    iconName: 'list',
                    iconBgColor: 'bg-green',
                    type: 'switch'
                },
                {
                    key: 'orderDetlMultiSelect',
                    title: this.$t('settings.orderDetlMultiSelect'),
                    iconName: 'list-dot',
                    iconBgColor: 'bg-yellow',
                    type: 'switch'
                },
                {
                    key: 'orderCombNeedSplit',
                    title: this.$t('settings.orderCombNeedSplit'),
                    iconName: 'cut',
                    iconBgColor: 'bg-blue',
                    type: 'switch'
                },
                {
                    key: 'orderCombSeparator',
                    title: this.$t('settings.orderCombSeparator'),
                    iconName: 'minus',
                    iconBgColor: 'bg-yellow',
                    type: 'input'
                },
                {
                    key: 'orderCombArrayIndex',
                    title: this.$t('settings.orderCombArrayIndex'),
                    iconName: 'grid-fill',
                    iconBgColor: 'bg-blue',
                    type: 'number'
                },
                {
                    key: 'orderCombStartPos',
                    title: this.$t('settings.orderCombStartPos'),
                    iconName: 'play-right-fill',
                    iconBgColor: 'bg-green',
                    type: 'number'
                }
            ]
        }
    },
    onShow() {
        const settings = uni.getStorageSync('appSettings')
        if (settings) {
            this.appSettings = { ...this.appSettings, ...settings }
        } else {
            // 兼容或迁移旧的设置读取逻辑
            const oldSetting = uni.getStorageSync('orderReviewRequired')
            if (oldSetting !== '') {
                this.appSettings.orderReviewRequired = oldSetting
                this.saveSettings()
            }
        }
    },
    methods: {
        saveSettings() {
            uni.setStorageSync('appSettings', this.appSettings)
        }
    }
}
</script>
 
<style>
page {
    background: #f0f2f5;
}
 
.page-container {
    min-height: 100vh;
    background-color: #f0f2f5;
}
 
.content {
    margin-top: 20rpx;
    background-color: #ffffff;
}
 
/* 左侧图标外层方块背景 */
.cell-icon-wrap {
    width: 52rpx;
    height: 52rpx;
    border-radius: 12rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 20rpx;
}
 
/* 定义几种颜色匹配截图里不同状态的图标底色 */
.bg-blue {
    background-color: #7ec3fa;
}
 
.bg-yellow {
    background-color: #f8c158;
}
 
.bg-green {
    background-color: #63d98f;
}
</style>