address api
This commit is contained in:
@@ -11,8 +11,9 @@
|
||||
<view v-else>{{ time }}</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="order-btn">确认订单</view>
|
||||
<view class="order-btn" @click="addManicureOrder">确认订单</view>
|
||||
<u-picker mode="time" v-model="show" :params="params" @confirm="chooseDate"></u-picker>
|
||||
<u-toast ref="uToast" />
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
@@ -33,18 +34,42 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
validateValue() {
|
||||
if(this.$u.test.isEmpty(this.name)) {
|
||||
this.showToast('姓名不能为空', 'warning');
|
||||
return false;
|
||||
}
|
||||
if(this.$u.test.isEmpty(this.time)) {
|
||||
this.showToast('日期不能为空', 'warning');
|
||||
return false;
|
||||
}
|
||||
if(new Date() > new Date(this.time)) {
|
||||
this.showToast('日期错误', 'warning');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
addManicureOrder() {
|
||||
if(!this.validateValue()) return false;
|
||||
this.$u.api.addManicure({
|
||||
name: this.name,
|
||||
time: this.time
|
||||
time: new Date(this.time)
|
||||
}).then((res)=>{
|
||||
if (res.errCode == 0) {}
|
||||
let type = res.errCode == 0 ? 'success' : 'error';
|
||||
this.showToast(res.message, type);
|
||||
})
|
||||
},
|
||||
chooseDate(e) {
|
||||
let time = e.year + '年' + e.month + '月' + e.day + '日' + e.hour + '时' + e.minute + '分'
|
||||
// let time = e.year + '年' + e.month + '月' + e.day + '日' + e.hour + '时' + e.minute + '分'
|
||||
let time = e.year + '-' + e.month + '-' + e.day + ' ' + e.hour + ':' + e.minute
|
||||
this.time = time
|
||||
}
|
||||
},
|
||||
showToast(message, type) {
|
||||
this.$refs.uToast.show({
|
||||
title: message,
|
||||
type: type,
|
||||
})
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user