Commit eabe32b1 authored by 罗超's avatar 罗超

新增配送相关逻辑

parent 448bff0f
......@@ -104,6 +104,9 @@ export default {
font-family: "oswald";
src: url("https://viitto-1301420277.cos.ap-chengdu.myqcloud.com/smallapp/Oswald-Regular.ttf");
}
*{
font-family: "oswald" !important;
}
swiper{
height: unset;
}
......
<template>
<u-popup
mode="bottom"
border-radius="20"
:popup="false"
v-model="show"
:maskCloseAble="true"
length="auto"
:safeAreaInsetBottom="true"
@close="popupClose"
:z-index="9999"
close-icon="cross"
:closeable="true"
>
<view class="pesongBox">
<view class="title">配送</view>
<view class="details">
<template v-for="(x, i) in list">
<text
:key="i"
v-if="currentChosen == x.value"
class="item"
:style="{ color: mc, borderColor: mc, background: mc + '19' }"
@click="changeHandler(x.value)"
>{{ x.name }}</text
>
<text
:key="i"
v-else
class="item"
@click="changeHandler(x.value)"
:style="{ color: dc, borderColor: dc, background: dc + '19' }"
>{{ x.name }}</text
>
</template>
</view>
<view style="margin-bottom:2px;color:#777;font-size:13px">{{tips[`${currentChosen}`].title}}</view>
<view style="font-weight:600;font-size:13px">{{tips[`${currentChosen}`].content}}</view>
<view class="btton-box">
<u-button
size="80"
:ripple="true"
shape="circle"
:custom-style="{
backgroundColor: mc,
height: '80rpx',
color: '#FFF',
fontSize: '14px',
margin: '0 8vw',
width: '80vw',
}"
@click="chosenHandler"
>确定</u-button
>
</view>
</view>
</u-popup>
</template>
<script>
export default {
props: {
list: {
type: Array,
default: [
{
name: "快递配送",
value: "express",
},
{
name: "线下自提",
value: "offline",
},
{
name: "区域配送",
value: "city",
},
],
},
sendType: {
type: String,
default: "express",
},
index:{
type:Number,
default:0
}
},
data() {
return {
mc: "",
styleItem: {},
currentChosen: "",
show:true,
dc: "#666",
tips: {
express: {
title: "送货时间",
content: "同城次日到达,其他省3-5日送达",
},
offline: {
title: "自提地点",
content: "请咨询客服人员具体提货地点",
},
city: {
title: "送货时间",
content: "一般为当日送达,如遇特殊情况将延伸至次日送达",
},
},
};
},
mounted() {
this.mc = this.$uiConfig.mainColor;
this.currentChosen = this.sendType;
this.styleItem = {
color: this.mc,
borderColor: this.mc,
background: this.mc + "19",
};
//"offline","city"
},
methods: {
popupClose() {
this.$emit("close",{
index:this.index
})
},
chosenHandler(){
this.$emit("close",{
index:this.index,
val:this.currentChosen
})
},
changeHandler(val){
this.currentChosen=val
}
},
};
</script>
<style>
.pesongBox {
min-height: 60vh;
padding: 20px;
padding-bottom: 50px;
text-align: left !important;
}
.pesongBox .title {
font-size: 22px;
color: #000;
}
.pesongBox .details {
margin-top: 25px;
padding-bottom: 15px;
border-bottom: 1px solid #f5f5f5;
margin-bottom: 15px;
display: block;
}
.pesongBox .details .item {
border-radius: 30px;
padding: 5px 15px;
font-size: 14px;
font-weight: 600;
border: 1px solid transparent;
margin-right: 20px;
font-size: 12px;
}
.pesongBox .btton-box {
height: 50px;
display: flex;
padding: 5px 10px;
border-top: 1px solid #f5f5f5;
position: fixed;
bottom: 0;
left: 0;
right: 0;
align-items: center;
background: #fff;
}
</style>
<template>
<view class="addresschosen">
<view>
<view v-if="list.length>0">
<view class="item" v-if="defaultId!=0">
<view class="default">
<u-icon name="checked" size="44" :color="mc"></u-icon>
</view>
<view class="address" @click="chosenHandler">
<view class="address" @click="chosenHandler(currentAddress.id)">
<view class="base">
<text class="name">{{currentAddress.name}}</text>
<text class="phone">{{currentAddress.mobile}}</text>
......@@ -20,7 +20,7 @@
</view>
<view class="item" v-for="(x, i) in list" :key="i">
<view class="address">
<view class="base">
<view class="base" @click="chosenHandler(x.id)">
<text class="name">{{x.name}}</text>
<text class="phone">{{x.mobile}}</text>
</view>
......@@ -31,6 +31,7 @@
</view>
</view>
</view>
<u-empty text="你还没有新增收货地址哦" mode="address" v-else></u-empty>
<view class="btton-box">
<u-button
size="80"
......@@ -41,8 +42,10 @@
height: '80rpx',
color: '#FFF',
fontSize: '14px',
margin:'0 50px'
margin:'0 8vw',
width:'80vw'
}"
@click="newAddressHandler"
>新增收货地址</u-button>
</view>
</view>
......@@ -68,19 +71,26 @@ export default {
this.init();
},
methods: {
chosenHandler(id){
let pages = getCurrentPages()
let prevPage = pages[ pages.length - 2 ]
prevPage.$vm.formData.address_id = id
uni.navigateBack({
delta: 1
})
},
newAddressHandler(){
uni.navigateTo({
url: '/pages/address/addAddress'
});
},
init() {
this.loading = false;
let h=this.apiheader()
this.request(
{
url: "",
header: {
"X-Access-Token": "Tc8G75W5llGY_UPwlHBscYEPs1a32cDJ",
"X-App-Platform": "wxapp",
"X-App-Version": "4.2.47",
"X-Form-Id-List": JSON.stringify([]),
"X-Requested-With": "XMLHttpRequest",
"X-User-Id": 21269,
},
header: h,
data: {
r: "api/user/address",
},
......@@ -99,7 +109,7 @@ export default {
}
});
if (index != -1) {
this.list.splice(i, 1);
this.list.splice(index, 1);
}
}
);
......
<template>
<view class="ordersubmit" v-if="ds.mch_list">
<view class="ordersubmit" v-if="!loading">
<view class="add-box" @click="chosenAddress(ds.address.id)">
<view class="add-info">
<view class="address">{{
......@@ -44,13 +44,15 @@
</view>
<view class="peisong">
<view>配送</view>
<view>快递配送</view>
<view style="text-align:right;padding-right:5px">{{x.delivery.send_type_name}}</view>
<u-icon name="ellipsis" size="36" @click="showPeisongHandler(i)"></u-icon>
<peisong :list="x.delivery.send_type_list" :index="i" @close="changeSendTypeHandler" :send-type="x.delivery.send_type" v-if="x.delivery.showDelivery"></peisong>
</view>
<view class="liuyan">
<u-field
padding="0px"
label-width="80"
v-model="mobile"
v-model="x.form_data.remark"
label="留言"
placeholder="建议留言前先与客服沟通确认"
></u-field>
......@@ -139,7 +141,11 @@
</template>
<script>
import peisong from "@/components/peisong/index";
export default {
components: {
peisong,
},
data() {
return {
formData: {
......@@ -160,7 +166,9 @@ export default {
address: {},
mchs: [],
mc: "",
ds: {},
ds: {
total_price: "0.00",
},
expressPrice: 0.0,
goodPrice: 0.0,
couponPrice: 0.0,
......@@ -172,6 +180,7 @@ export default {
},
secondary: "",
userInt: false,
loading: true,
};
},
onLoad(option) {
......@@ -182,43 +191,62 @@ export default {
} else {
this.formData.list[0].goods_list = [
{
id: 40887,
attr: [
{
attr_id: 1,
attr_group_id: 1,
},
{
attr_id: 4,
attr_group_id: 2,
},
],
id: 74997,
attr: [{ attr_id: 1, attr_group_id: 1 }],
num: 1,
cat_id: 0,
goods_attr_id: 224815,
cart_id: 0,
cart_id: 77092,
goods_attr_id: 160655,
},
];
}
this.initPage();
this.init();
this.mc = this.$uiConfig.mainColor;
this.secondary = this.$uiConfig.secondary;
},
onShow() {
this.init();
},
methods: {
chosenAddress(id){
changeSendTypeHandler(e){
let i=e.index
console.log(i)
let obj=this.mchs[i]
obj.delivery.showDelivery=false
this.$set(this.mchs,i,obj)
this.$forceUpdate()
if(e && e.val){
if(this.mchs[i].delivery.send_type!=e.val){
this.formData.list[i].send_type=e.val
this.init()
}
}
},
showPeisongHandler(x){
let obj=this.mchs[x]
obj.delivery.showDelivery=true
this.$set(this.mchs,x,obj)
this.$forceUpdate()
},
chosenAddress(id) {
uni.navigateTo({
url: '/pages/address/address_chosen?form=ordersubmit&id='+id
url: "/pages/address/address_chosen?form=ordersubmit&id=" + id,
});
},
changeUseInt(e) {
this.userInt=e.value
if(this.userInt){
this.couponPrice+=parseFloat(this.integral.deduction_price)
this.ds.total_price=(parseFloat(this.ds.total_price)-parseFloat(this.integral.deduction_price)).toFixed(2)
}else{
this.couponPrice-=parseFloat(this.integral.deduction_price)
this.ds.total_price=(parseFloat(this.ds.total_price)+parseFloat(this.integral.deduction_price)).toFixed(2)
this.userInt = e.value;
if (this.userInt) {
this.couponPrice += parseFloat(this.integral.deduction_price);
this.ds.total_price = (
parseFloat(this.ds.total_price) -
parseFloat(this.integral.deduction_price)
).toFixed(2);
} else {
this.couponPrice -= parseFloat(this.integral.deduction_price);
this.ds.total_price = (
parseFloat(this.ds.total_price) +
parseFloat(this.integral.deduction_price)
).toFixed(2);
}
},
initPage() {
......@@ -237,6 +265,7 @@ export default {
});
},
init() {
this.loading = true;
let h = this.apiheader();
h["content-type"] = "application/x-www-form-urlencoded";
this.request(
......@@ -255,11 +284,19 @@ export default {
this.ds = res.data;
this.formatPrice();
this.formatAttr();
this.loading = false;
}
);
},
formatPrice() {
this.mchs.forEach((x) => {
x.delivery.showDelivery=false
x.delivery.send_type_list.forEach(y=>{
console.log(y.value==x.delivery.send_type)
if(y.value==x.delivery.send_type){
x.delivery.send_type_name=y.name
}
})
this.goodPrice += parseFloat(x.total_goods_price);
this.expressPrice += parseFloat(x.express_price);
this.couponPrice += parseFloat(x.coupon.coupon_discount || 0.0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment