address api

This commit is contained in:
2020-06-23 17:21:01 +08:00
parent fe995ced2d
commit 8c993da2cd
12 changed files with 390 additions and 55 deletions

View File

@@ -10,10 +10,10 @@
<view v-for="(item, index) in orderList" :key="index" class="order-item">
<view class="order-title">
<view class="order-text">订单</view>
<view class="order-status">已预约</view>
<view class="order-status">{{ item.status }}</view>
</view>
<view class="order-name">美甲人姓名xxx</view>
<view class="order-date">时间2020-04-12</view>
<view class="order-name">美甲人姓名{{ item.manicure_name }}</view>
<view class="order-date">时间{{ item.manicure_time | dateFormat }}</view>
</view>
<u-loadmore :status="loadStatus" bgColor="#ECECEC" margin-bottom="20"></u-loadmore>
</view>
@@ -39,20 +39,33 @@ export default {
current: 0,
swiperCurrent: 0,
page: 1,
orderList: 5,
orderList: [],
loadStatus: 'loadmore',
}
},
onShow() {
this.current = 0;
this.swiperCurrent = 0;
this.getManicureList();
},
filters: {
dateFormat(value) {
let date = new Date(value * 1000);
let year, month, day;
year = date.getFullYear();
month = date.getMonth() + 1;
day = date.getDate();
return year + "-" + month + "-" + day;
}
},
methods: {
getManicureList() {
this.$u.api.getManicureList({
page: this.page
}).then((res)=>{
if (res.errCode == 0) {}
if (res.errCode == 0) {
this.orderList = res.data.list;
}
})
},
reachBottom() {

View File

@@ -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>