luban-mall/pagesA/cart/settlement.vue

130 lines
3.8 KiB
Vue
Raw Normal View History

2022-07-08 08:15:29 +00:00
<template>
<view class="pad-b150">
<status-nav :ifReturn="true" navBarTitle="订单提交" :marginBottom="0"></status-nav>
<view class="settlement-content">
<view class="settlement-title">联系方式</view>
<view class="settlement-tips">请输入您的联系方式我们将尽快与您联系并确认订单信息</view>
<view class="settlement-list">
<view class="settlement-item">
<view class="name">联系人</view>
<view class="txt flex">
<text>称呼</text>
<input type="text" v-model="name" @tap="chooseEv(0)" :class="current==0 ? 'focusc' : ''" placeholder="请输入您的称呼" placeholder-style="color:#999999">
</view>
</view>
<view class="settlement-item">
<view class="name">联系方式</view>
<view class="txt flex">
<text>电话</text>
<input type="text" v-model="phone" @tap="chooseEv(1)" :class="current==1 ? 'focusc' : ''" placeholder="请输入手机号码" placeholder-style="color:#999999">
</view>
</view>
<view class="settlement-item">
<view class="name">联系地址</view>
<view class="txt flex">
<text>地址</text>
<input type="text" v-model="address" @tap="chooseEv(2)" :class="current==2 ? 'focusc' : ''" placeholder="请输入地址" placeholder-style="color:#999999">
</view>
</view>
<view class="settlement-item">
<view class="name">送货时间</view>
<view class="txt flex">
<text>日期</text>
<picker mode="date" @change="chooseTime(3,$event)">
<input type="text" v-model="toTime" disabled @tap="chooseEv(0)" :class="current==0 ? 'focusc' : ''" placeholder="请选择送货日期" placeholder-style="color:#999999">
</picker>
</view>
</view>
</view>
</view>
<view class="settlement-btn flex">
<view class="btn" @tap="submit"></view>
</view>
</view>
</template>
<script>
import statusNav from '@/components/status-navs/status-nav';
export default {
components:{
statusNav
},
data() {
return {
current:6,
toTime:'',// 时间
address:'',// 地址
name:'',// 称呼
phone:'',// 电话
flag:true
}
},
onLoad() {
console.log(uni.getStorageSync('buyList'),'缓存数组')
},
onShow() {
this.getUserInfo()
},
methods: {
// 获取默认信息
getUserInfo(){
this.$requst.get('/api/user/info').then(res=>{
console.log(res,'用户信息')
if(res.code==0) {
this.address = res.data.order_address; //地址
this.name = res.data.order_contact; //联系人
this.phone = res.data.order_phone; //电话
}
})
},
// 提交
submit(){
if(this.checkEmpty() && this.flag){
this.flag = false;
let params = {
sku_list: uni.getStorageSync('buyList'),
order_phone: this.phone,
order_contact: this.name,
order_address: this.address,
order_date: this.toTime,
}
this.$requst.post('/api/order/create',params).then(res=>{
if(res.code==0) {
uni.navigateTo({
url:`/pagesA/cart/finish?id=${res.data.id}&coding=${res.data.coding}`
})
}else{
console.log(res.msg,'提示信息')
this.$toolAll.tools.showToast(res.msg);
this.flag = true;
}
})
}
},
checkEmpty(){
let result = false;
if(!this.name) {
this.$toolAll.tools.showToast('请填写联系人');
} else if(this.$toolAll.tools.isPhone(this.phone)) {
this.$toolAll.tools.showToast('请正确填写联系电话');
} else if(!this.address) {
this.$toolAll.tools.showToast('请填写收货地址');
} else {
result = true;
}
return result;
},
chooseEv(index) {
this.current = index;
},
chooseTime(index,e) {
this.toTime = e.detail.value;
}
}
}
</script>
<style>
</style>