Ver Fonte

修改生日

shish há 11 meses atrás
pai
commit
7d628d8452

+ 14 - 0
hdPad/src/api/member/index.js

@@ -36,3 +36,17 @@ export const debt = data => {
 export const getVisit = data => {
 	return https.get("/custom/get-visit", data);
 };
+
+/** *
+ * 获取客户详情 b
+ */
+export const getCustomDetail = data => {
+	return https.get("/custom/detail", data);
+};
+
+/** *
+ * 更新客户生日信息 b
+ */
+export const updateCustomBirthday = data => {
+	return https.post("/custom/update-birthday", data);
+};

+ 326 - 0
hdPad/src/pages/home/components/birthdayEdit.vue

@@ -0,0 +1,326 @@
+<template>
+    <div class="birthday-container full-width">
+        <!-- 类型选择 -->
+        <div class="birthday-section">
+            <div class="section-title">类型</div>
+            <div class="type-buttons">
+                <button 
+                    class="admin-button-com middle" 
+                    :class="[birthdayType == 0 ? 'blue' : 'default']" 
+                    @click="birthdayType = 0"
+                >公历</button>
+                <button 
+                    class="admin-button-com middle" 
+                    :class="[birthdayType == 1 ? 'blue' : 'default']" 
+                    @click="birthdayType = 1"
+                >农历</button>
+            </div>
+        </div>
+        
+        <!-- 月份选择 -->
+        <div class="birthday-section">
+            <div class="section-title">月份</div>
+            <div class="month-buttons">
+                <button 
+                    v-for="(month, index) in [1,2,3,4,5,6,7,8,9,10,11,12]" 
+                    :key="'month-'+month" 
+                    class="month-button" 
+                    :class="{ active: birthdayMonth == month }"
+                    @click="birthdayMonth = month"
+                >{{ month }}</button>
+            </div>
+        </div>
+        
+        <!-- 日期选择 (数字按钮形式) -->
+        <div class="birthday-section">
+            <div class="section-title">日期</div>
+            <div class="date-buttons-container">
+                <!-- 使用固定高度的容器和绝对定位的滚动视图 -->
+                <view class="date-buttons-wrapper">
+                    <scroll-view 
+                        scroll-y="true" 
+                        class="date-buttons-scroll" 
+                        enhanced="true"
+                        show-scrollbar="true"
+                        always-bounce-vertical="true"
+                    >
+                        <div class="date-buttons">
+                            <button 
+                                v-for="(date, index) in dateArray" 
+                                :key="'date-'+date" 
+                                class="date-button" 
+                                :class="{ active: birthdayDate == date }"
+                                @click="birthdayDate = date"
+                            >{{ date }}</button>
+                        </div>
+                    </scroll-view>
+                </view>
+            </div>
+        </div>
+        
+        <!-- 操作按钮 -->
+        <div class="birthday-actions">
+            <button class="admin-button-com blue" @click="saveBirthday">保存</button>
+            <button class="admin-button-com default" @click="cancelBirthday">取消</button>
+        </div>
+    </div>
+</template>
+
+<script>
+export default {
+    name: "birthdayEdit",
+    props: {
+        customId: {
+            type: Number,
+            default: 0,
+            required: true
+        }
+    },
+    data() {
+        return {
+            birthdayType: 0, // 0公历 1农历
+            birthdayMonth: new Date().getMonth() + 1, // 默认当前月份
+            birthdayDate: new Date().getDate(), // 默认当前日期
+            dateArray: [], // 日期数组
+            originalBirthday: {}, // 原始生日信息,用于取消操作
+        }
+    },
+    watch: {
+        birthdayMonth() {
+            this.updateDateArray()
+        },
+        customId: {
+            immediate: true,
+            handler(val) {
+                if (val) {
+                    this.getCustomBirthday()
+                }
+            }
+        }
+    },
+    methods: {
+        // 获取客户生日信息
+        getCustomBirthday() {
+            if (!this.customId) {
+                uni.showToast({
+                    title: '请先选择客户',
+                    icon: 'none'
+                })
+                return
+            }
+            
+            // 这里应该调用API获取客户生日信息
+            this.$api.member.getCustomDetail({id: this.customId}).then(res => {
+                if (res.code === 0) {
+                    const data = res.data
+                    // 保存原始生日信息,用于取消操作
+                    this.originalBirthday = {
+                        type: data.birthdayType || 0,
+                        month: data.birthdayMonth || 1,
+                        date: data.birthdayDate || 1
+                    }
+                    
+                    this.birthdayType = data.birthdayType || 0
+                    this.birthdayMonth = data.birthdayMonth || 1
+                    this.birthdayDate = data.birthdayDate || 1
+                    this.updateDateArray()
+                }
+            }).catch(err => {
+                uni.showToast({
+                    title: '获取客户信息失败',
+                    icon: 'none'
+                })
+            })
+        },
+        // 更新日期数组
+        updateDateArray() {
+            const daysInMonth = this.getDaysInMonth(this.birthdayMonth)
+            this.dateArray = Array.from({length: daysInMonth}, (_, i) => i + 1)
+        },
+        // 获取月份天数
+        getDaysInMonth(month) {
+            // 简单处理,不考虑闰年
+            const daysMap = {
+                1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6: 30,
+                7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31
+            }
+            return daysMap[month] || 30
+        },
+        // 保存生日信息
+        saveBirthday() {
+            if (!this.customId) return
+            
+            const params = {
+                id: this.customId,
+                birthdayType: this.birthdayType,
+                birthdayMonth: this.birthdayMonth,
+                birthdayDate: this.birthdayDate
+            }
+            
+            // 调用API保存生日信息
+            this.$api.member.updateCustomBirthday(params).then(res => {
+                if (res.code === 0) {
+                    uni.showToast({
+                        title: '生日修改成功',
+                        icon: 'success'
+                    })
+                    this.$emit('save-success')
+                } else {
+                    uni.showToast({
+                        title: res.msg || '保存失败',
+                        icon: 'none'
+                    })
+                }
+            }).catch(err => {
+                uni.showToast({
+                    title: '保存失败',
+                    icon: 'none'
+                })
+            })
+        },
+        // 取消修改
+        cancelBirthday() {
+            // 恢复原始值
+            this.birthdayType = this.originalBirthday.type
+            this.birthdayMonth = this.originalBirthday.month
+            this.birthdayDate = this.originalBirthday.date
+            this.$emit('cancel')
+        }
+    }
+};
+</script>
+
+<style lang="scss" scoped>
+// 生日修改样式
+.full-width {
+    padding: 0 !important;
+    margin: 0 !important;
+    width: 100% !important;
+}
+
+.birthday-container {
+    background-color: #fff;
+    width: 100%;
+    height: 100%;
+    padding: 15px;
+}
+
+.birthday-section {
+    margin-bottom: 25px;
+}
+
+.section-title {
+    font-size: 20px;
+    font-weight: bold;
+    margin-bottom: 15px;
+    color: #333;
+}
+
+.type-buttons {
+    display: flex;
+    gap: 15px;
+    
+    button {
+        min-width: 100px;
+        height: 50px;
+        font-size: 18px;
+        
+        &.blue {
+            background-color: #0076FF;
+            color: white;
+        }
+        
+        &.default {
+            background-color: #F5F5F5;
+            color: #333;
+        }
+    }
+}
+
+.month-buttons {
+    display: flex;
+    flex-wrap: wrap;
+    gap: 15px;
+}
+
+.month-button {
+    width: 70px;
+    height: 70px;
+    border-radius: 50%;
+    border: 1px solid #ddd;
+    background-color: #fff;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    font-size: 22px;
+    
+    &.active {
+        background-color: #0076FF;
+        color: white;
+        border-color: #0076FF;
+    }
+}
+
+.date-buttons-container {
+    position: relative;
+}
+
+.date-buttons-wrapper {
+    height: 240px;
+    position: relative;
+    overflow: hidden;
+}
+
+.date-buttons-scroll {
+    height: 100%;
+    width: 100%;
+}
+
+.date-buttons {
+    display: flex;
+    flex-wrap: wrap;
+    gap: 15px;
+    padding: 5px;
+}
+
+.date-button {
+    width: 70px;
+    height: 70px;
+    border-radius: 50%;
+    border: 1px solid #ddd;
+    background-color: #fff;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    font-size: 22px;
+    
+    &.active {
+        background-color: #0076FF;
+        color: white;
+        border-color: #0076FF;
+    }
+}
+
+.birthday-actions {
+    display: flex;
+    justify-content: center;
+    gap: 20px;
+    margin-top: 30px;
+    
+    button {
+        min-width: 120px;
+        height: 50px;
+        font-size: 18px;
+        
+        &.blue {
+            background-color: #0076FF;
+            color: white;
+        }
+        
+        &.default {
+            background-color: #F5F5F5;
+            color: #333;
+        }
+    }
+}
+</style>

+ 22 - 3
hdPad/src/pages/home/custom.vue

@@ -17,7 +17,11 @@
             </view>
 
             <view class="custom-asset" v-if="showIndex == 2">
-
+                <birthdayEdit 
+                    :customId="selectCustomId" 
+                    @save-success="handleBirthdaySaveSuccess" 
+                    @cancel="handleBirthdayCancel">
+                </birthdayEdit>
             </view>
 
         </view>
@@ -31,9 +35,10 @@ import casherNav from './components/nav.vue'
 import customList from './components/customList.vue'
 import customInfo from './components/customInfo.vue'
 import balanceChange from './components/balanceChange.vue'
+import birthdayEdit from './components/birthdayEdit.vue'
 export default {
     name: "custom",
-    components: {casherNav,customList,customInfo,balanceChange},
+    components: {casherNav,customList,customInfo,balanceChange,birthdayEdit},
     mixins: [productMins],
     data() {
         return {
@@ -46,9 +51,21 @@ export default {
     computed: {
         ...mapGetters(["getLoginInfo"])
     },
+    watch: {
+    },
     methods: {
         changeBirthday(){
-
+            this.showIndex = 2
+        },
+        // 处理生日保存成功
+        handleBirthdaySaveSuccess() {
+            this.showIndex = 0
+            // 刷新客户信息
+            this.$refs.customInforRef.getCustomDetail(this.selectCustomId)
+        },
+        // 处理生日取消修改
+        handleBirthdayCancel() {
+            this.showIndex = 0
         },
         goBalance(){
             this.showIndex = 1
@@ -127,6 +144,8 @@ export default {
     }
     & .custom-asset{
         flex: 32;
+        padding: 20px;
     }
 }
+
 </style>