+
import { get } from '@/api/store/base'
+import {
+ getSameCityTransport,
+ saveSameCityTransport,
+ delectArea,
+} from '@/api/sameCityTransport/sameCityTransport'
import { ChineseDistricts } from '@/components/VabArea/city-picker.data'
import {
distributionOpction,
@@ -1312,8 +1320,8 @@ export default {
],
inAdvanceTime: 0,
shopAddress: '',
- dispensingArea: 0,
- divideType: 0,
+ dispensingArea: 1,
+ divideType: 1,
distance: {
distanceNum: null,
weightNum: null,
@@ -1350,40 +1358,8 @@ export default {
customActive: 0,
showCustomEditing: false,
showCustomDragging: false,
- radiusList: [
- {
- id: 0,
- areaNum: 1,
- minPriceType: 0,
- minPrice: null,
- deliveryCostAmount: null,
- freightReliefType: 0,
- freightReliefAmout: null,
- derateAmout: null,
- circlePath: {
- center: {
- lng: 0,
- lat: 0,
- },
- // center:[],
- radius: 300,
- },
- },
- ],
- customList: [
- {
- areaNum: 0,
- oldCenter: {},
- polygonPath: [],
- areaNum: 1,
- minPriceType: 0,
- minPrice: null,
- deliveryCostAmount: null,
- freightReliefType: 0,
- freightReliefAmout: null,
- derateAmout: null,
- },
- ],
+ radiusList: [],
+ customList: [],
},
BMap: null,
center: { lng: 0, lat: 0 },
@@ -1420,6 +1396,7 @@ export default {
},
created() {
this.ChineseDistricts = ChineseDistricts
+ this.getSameCityTransport()
this.getCompanyInfo()
this.goodsTypeList = Object.keys(this.goodsTypeData).map((key) => ({
label: this.goodsTypeData[key],
@@ -1428,6 +1405,44 @@ export default {
},
beforeDestroy() {},
methods: {
+ async getSameCityTransport() {
+ let res = await getSameCityTransport()
+ if (res && res.status == 200) {
+ let transportBase = res.data.transportBase
+ let transportList = res.data.transportList
+ this.form.dispensingArea = transportBase.area_type
+
+ this.form.distance.distanceNum = transportBase.distance_base
+ this.form.distance.weightNum = transportBase.weight_base
+ this.form.distance.distributionFreightNum =
+ transportBase.delivery_base_fee
+
+ this.form.distanceAdd.distanceNum = transportBase.distance_increase_km
+ this.form.distanceAdd.FreightAddNum =
+ transportBase.distance_increase_fee
+
+ this.form.weightAdd.weightAddNum = transportBase.weight_increase_kg
+ this.form.weightAdd.FreightAddNum = transportBase.weight_increase_fee
+
+ let arr = transportList.map((item, index) => {
+ let obj = {
+ areaNum: index + 1,
+ transport_id: item.transport_id,
+ circlePath: {
+ radius: item.max_delivery_radius,
+ center: this.center,
+ },
+ minPriceType: item.min_delivery_amount_type - 1,
+ minPrice: item.min_delivery_amount,
+ freightReliefType: item.delivery_discount_type - 1,
+ freightReliefAmout: item.min_delivery_discount_amount,
+ derateAmout: item.delivery_discount,
+ }
+ return obj
+ })
+ this.mapForm.radiusList = arr
+ }
+ },
handleSkip() {
this.$router.push({ path: '/setupshop' })
},
@@ -1618,7 +1633,7 @@ export default {
})
},
addRadiusItem() {
- if (this.form.divideType == 0) {
+ if (this.form.divideType == 1) {
if (this.mapForm.radiusList.length >= 10) return
let areaNum = this.mapForm.radiusList.length + 1
@@ -1643,7 +1658,7 @@ export default {
} else {
if (this.mapForm.customList.length >= 10) return
- let areaNum = this.mapForm.radiusList.length + 1
+ let areaNum = this.mapForm.customList.length + 1
let { lng, lat } = this.center
// 正方形的边长(米)
@@ -1664,9 +1679,9 @@ export default {
]
let obj = {
+ transport_id: 0,
areaNum: areaNum,
polygonPath: polygonPath,
- areaNum: areaNum,
minPriceType: 0,
minPrice: null,
deliveryCostAmount: null,
@@ -1681,8 +1696,12 @@ export default {
// this.creatCircle(obj)
},
- delectRadiusItem(index) {
- if (this.form.divideType == 0) {
+ async delectRadiusItem(index, item) {
+ let res = await delectArea({ transport_id: item.transport_id })
+ if (res && res.status == 200) {
+ this.$baseMessage('删除成功', 'success')
+ }
+ if (this.form.divideType == 1) {
if (this.mapForm.radiusList.length == 0) return
this.mapForm.radiusList.splice(index, 1)
@@ -1732,30 +1751,72 @@ export default {
this.center.lng = Number(this.shopInfoData.store_longitude)
this.center.lat = Number(this.shopInfoData.store_latitude)
- this.mapForm.radiusList[0].circlePath.center.lng = Number(
- this.shopInfoData.store_longitude
- )
- this.mapForm.radiusList[0].circlePath.center.lat = Number(
- this.shopInfoData.store_latitude
- )
- this.mapForm.customList[0].oldCenter = this.center
- let { lng, lat } = this.center
- // 正方形的边长(米)
- var side_length = 300
- // 每度纬度的距离(米)
- var lat_distance_per_degree = 111000
+ if (this.mapForm.radiusList.length == 0) {
+ let obj = {
+ areaNum: 1,
+ minPriceType: 0,
+ minPrice: null,
+ deliveryCostAmount: null,
+ freightReliefType: 0,
+ freightReliefAmout: null,
+ derateAmout: null,
+ circlePath: {
+ center: {
+ lng: 0,
+ lat: 0,
+ },
+ // center:[],
+ radius: 300,
+ },
+ }
- var deltaLat = side_length / lat_distance_per_degree
+ this.mapForm.radiusList.push(obj)
- var deltaLng = deltaLat
+ this.mapForm.radiusList[0].circlePath.center.lng = Number(
+ this.shopInfoData.store_longitude
+ )
+ this.mapForm.radiusList[0].circlePath.center.lat = Number(
+ this.shopInfoData.store_latitude
+ )
+ }
- this.mapForm.customList[0].polygonPath = [
- { lng: lng + deltaLng, lat: lat + deltaLat },
- { lng: lng + deltaLng, lat: lat - deltaLat },
- { lng: lng - deltaLng, lat: lat - deltaLat },
- { lng: lng - deltaLng, lat: lat + deltaLat },
- ]
+ if (this.mapForm.customList.length == 0) {
+ let areaNum = this.mapForm.radiusList.length + 1
+
+ let obj = {
+ transport_id: 0,
+ areaNum: areaNum,
+ polygonPath: [],
+ minPriceType: 0,
+ minPrice: null,
+ deliveryCostAmount: null,
+ freightReliefType: 0,
+ freightReliefAmout: null,
+ derateAmout: null,
+ oldCenter: this.center,
+ }
+
+ this.mapForm.customList.push(obj)
+
+ let { lng, lat } = this.center
+ // 正方形的边长(米)
+ var side_length = 300
+
+ // 每度纬度的距离(米)
+ var lat_distance_per_degree = 111000
+
+ var deltaLat = side_length / lat_distance_per_degree
+
+ var deltaLng = deltaLat
+
+ this.mapForm.customList[0].polygonPath = [
+ { lng: lng + deltaLng, lat: lat + deltaLat },
+ { lng: lng + deltaLng, lat: lat - deltaLat },
+ { lng: lng - deltaLng, lat: lat - deltaLat },
+ { lng: lng - deltaLng, lat: lat + deltaLat },
+ ]
+ }
this.mapReady = true
}
},
@@ -1818,14 +1879,14 @@ export default {
this.mapForm.showCircleEditing = true
},
onClickMarker() {
- if (this.form.divideType == 0) {
+ if (this.form.divideType == 1) {
this.mapForm.showRadiusDragging = true
} else {
this.mapForm.showCustomDragging = true
}
},
handleDragging(e, index) {
- if (this.form.divideType == 0) {
+ if (this.form.divideType == 1) {
this.mapForm.radiusList[index].circlePath.center = e.point
let divs = document.querySelectorAll('.BMap_vectex_node')
@@ -1862,7 +1923,7 @@ export default {
}
},
handleMarkerMouseovert() {
- if (this.form.divideType == 0) {
+ if (this.form.divideType == 1) {
this.mapForm.showRadiusDragging = true
} else {
this.mapForm.showCustomDragging = true
@@ -1980,7 +2041,57 @@ export default {
// })
// },
- handerSubmit() {},
+ async handerSubmit() {
+ if (
+ !this.form.distance.distanceNum ||
+ !this.form.distance.weightNum ||
+ !this.form.distance.distributionFreightNum ||
+ !this.form.distanceAdd.distanceNum ||
+ !this.form.distanceAdd.FreightAddNum ||
+ !this.form.weightAdd.weightAddNum ||
+ !this.form.weightAdd.FreightAddNum
+ ) {
+ this.$baseMessage('请填写完整的信息', 'error')
+ return
+ }
+
+ let list =
+ this.mapForm.radiusList.map((item) => {
+ let obj = {
+ transport_id: item.transport_id || null,
+ area_type: this.form.divideType,
+ max_delivery_radius: item.circlePath.radius,
+ min_delivery_amount_type: item.minPriceType + 1,
+ min_delivery_amount: item.minPrice,
+ delivery_discount_type: item.freightReliefType + 1,
+ min_delivery_discount_amount: item.freightReliefAmout,
+ delivery_discount: item.derateAmout,
+ }
+
+ return obj
+ }) || []
+
+ let params = {
+ transportBase: {
+ transport_base_id: null,
+ area_type: this.form.dispensingArea,
+ basis: 1,
+ distance_base: this.form.distance.distanceNum || 0,
+ weight_base: this.form.distance.weightNum || 0,
+ delivery_base_fee: this.form.distance.distributionFreightNum || 0,
+ distance_increase_km: this.form.distanceAdd.distanceNum || 0,
+ distance_increase_fee: this.form.distanceAdd.FreightAddNum || 0,
+ weight_increase_kg: this.form.weightAdd.weightAddNum || 0,
+ weight_increase_fee: this.form.weightAdd.FreightAddNum || 0,
+ },
+ transportList: list,
+ }
+
+ let res = await saveSameCityTransport(params)
+ if (res && res.status == 200) {
+ this.$baseMessage('保存成功', 'success')
+ }
+ },
},
}