li-guang
2020-12-31 805546268abc5687dbefdd40cd927da62b096fad
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
219
220
221
222
223
224
225
226
227
228
229
<template>
    <!-- 确认服务单 -->
    <view>
        <view class="header flex align-center">
            <image class="header-img" :src="memberInfo.photo?memberInfo.photo:'../../static/images/default-avatar.png'"></image>
            <view class="ml-10">
                <view class="font-16">
                    <text>{{memberInfo.vipName}}</text>
                    <text class="ml-20">{{memberInfo.phone}}</text>
                </view>
                <text class="font-14 gray mt-5">{{memberInfo.vipLevel || '-'}}</text>
            </view>
        </view>
        <view class="font-16 content">
            <view class="content-row flex align-center justify-between">
                <text>预约时间</text>
                <text class="gray" @click="showTime()">{{yyTime || '请选择预约时间'}}</text>
            </view>
            <date-time-picker ref='date-time' type='datetime' @change='dateTimeChange'></date-time-picker>
            <view class="content-row flex align-center justify-between">
                <text>预约技师</text>
                <view class="blue">
                    <picker mode="selector" range-key="name" :range="employeeList" @change="employeeChange">
                        <view>
                            <text v-if="curEmployee.name">{{curEmployee.name}}</text>
                            <text v-else class="gray">请选择美疗师</text>
                            <text class="iconfont iconjiantouarrow486 ml-5"></text>
                        </view>
                    </picker>
                </view>
            </view>
        </view>
        <view class="content">
            <view class="content-row flex align-center" v-for="item in list">
                <image class="product-img" :src="item.img?item.img:'../../static/images/no-img.png'" mode="aspectFill"></image>
                <view class="flex justify-between align-center flex-1 ml-10">
                    <view class="flex flex-v">
                        <text class="font-14">{{item.name}}</text>
                        <text class="font-12 gray mt-5">时长: {{item.timeLength}}分钟</text>
                        <text class="font-12 gray">有效期至: {{item.invalidTime || '-'}}</text>
                    </view>
                    <view>
                        <text class="font-16">×{{item.num}}</text>
                    </view>
                </view>
            </view>
            <view class="content-row right">
                <text class="font-16 blue">共{{totalCount}}项服务</text>
            </view>
        </view>
        <view class="content input-row flex">
            <text class="mr-10">备注</text>
            <input type="text" v-model="remark" maxlength="100" placeholder="客户需求" placeholder-class='placeholder'/>
        </view>
        <view class="footer">
            <button :disabled="isDisabled" class="blue-btn" @click="createOrder">提交服务单</button>
        </view>
    </view>
</template>
 
<script>
    import DateTimePicker from '../../components/bory-dateTimePicker/bory-dateTimePicker.vue'
    export default{
        components:{
            DateTimePicker
        },
        data(){
            return{
                id: '',
                list: [],
                yyTime: '',
                employeeList:[],
                curEmployee: {},
                memberInfo: {},
                remark: '',
                isDisabled: false
            }
        },
        computed:{
            totalCount(){
                let count = 0;
                this.list.forEach((item) => {
                    count += item.num;
                })
                return count;
            },
            totalTime(){
                let timeLength = 0;
                this.list.forEach((item) => {
                    timeLength += item.timeLength * item.num;
                })
                return timeLength;
            }
        },
        onLoad(options) {
            this.id = options.id;
            this.list = JSON.parse(decodeURIComponent(options.list));
            this.loadMemberInfo();
        },
        methods:{
            loadMemberInfo(){
                this.$httpUtils.request('/api/vip/findVipInfoById/'+this.id).then((res) => {
                    if(res.status == 200){
                        this.memberInfo = res.mapInfo.vipInfo;
                    }
                })
            },
            loadEmployeeList(){
                this.$httpUtils.request('/api/user/findBeauticianList', {
                    startTime: this.yyTime
                }, 'POST').then((res) => {
                    if(res.status == 200){
                        this.employeeList = res.rows;
                        if(!this.employeeList.length){
                            this.$toast.info('暂无可预约的美疗师')
                        }
                    }
                })
            },
            showTime () {
                this.$refs['date-time'].show();
            },
            dateTimeChange(val) {
                this.yyTime = val;
                this.loadEmployeeList()
            },
            employeeChange(e){
                this.curEmployee = this.employeeList[e.detail.value];
            },
            valid(){
                if(!this.yyTime){
                    this.$toast.info('请预约时间');
                    return false
                }
                if(!this.curEmployee.id){
                    this.$toast.info('请预约美疗师');
                    return false
                }
            },
            createOrder(){
                if(this.valid() === false){
                    return;
                }
                this.isDisabled = true;
                let projItems = this.list.map((item) => {
                    return {
                        "count": item.num,
                        "puseId": item.id
                    }
                })
                this.$httpUtils.request('/api/serviceOrder/createServiceOrder', {
                    beautyId: this.curEmployee.id,
                    projItems: projItems,
                    remark: this.remark,
                    totalTime: this.totalTime,
                    yyTime: this.yyTime,
                    vipId: this.id
                }, 'POST').then((res) => {
                    if(res.status == 200){
                        uni.navigateTo({
                            url: './submitSucceed?type=2'
                        })
                    }
                    this.$toast.info(res.info);
                    this.isDisabled = false;
                }).catch(() => {
                    this.isDisabled = false;
                })
            }
        }
    }
</script>
 
<style>
    page{
        background: #F6F6F8;
        padding-top: 10px;
        padding-bottom: 70px;
    }
    .header{
        background: #FFFFFF;
        border: 1px solid #EDEAF4;
        border-radius: 4px;
        box-shadow:0 6px 6px rgba(237,234,244,0.5);
        padding: 10px;
    }
    .header-img{
        width: 48px;
        height: 48px;
        border-radius: 50%;
    }
    .content{
        margin: 10px;
        padding: 0 10px;
        background: #FFFFFF;
        border: 1px solid #EDEAF4;
        border-radius: 4px;
        box-shadow:0 6px 6px rgba(237,234,244,0.5);    
    }
    .content-row{
        border-bottom: 1px solid #EDEAF4;
        padding: 10px 5px;
        font-size: 14px;
    }
    .content-row:nth-last-child(1){
        border: 0;
    }
    .product-img{
        width: 53px;
        height: 53px;
        border-radius: 4px;
    }
    .input-row{
        padding: 10px;
        font-size: 14px;
    }
    .input-row input{
        font-size: 14px;
        flex: 1;
    }
    .footer{
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 0;
        padding-bottom: 20px;
        background: #F6F6F8;
    }
</style>