emis-sapp/pages/post/freightCalculate.vue
2024-08-27 20:19:15 +08:00

209 lines
6.9 KiB
Vue

<template>
<tpx-page>
<tpx-layout>
<template v-slot:body>
<view class="com-jianju pos-rlt pb-30" style="padding-top: 2rpx;">
<view class="blcok-white">
<!-- 地址选择 -->
<bpe-addressinfo-tmp v-model:value="submitParam" @onChange="handleAddressChange"></bpe-addressinfo-tmp>
</view>
<view class="com-section mt-30">路线信息</view>
<view class="blcok-white" style="padding-top: 0;padding-bottom: 0;">
<template v-if="submitParam.reciever.country && submitParam.sender.country">
<view class="yunf-input-item">
<tpx-select v-model:value="submitParam.transLine" v-model:text="submitParam.transLineTypeName" v-model:resObject="wayRes"
:getListFun="getTransLineList" :transKeyVal="{valKey: 'lineCode',titleKey: 'lineName'}"
:searchParam="waySearchParam" @onChange="handleWayChange" placeholder="请选择路线"
>
<tpx-text-item label="路线" :value="submitParam.transLineTypeName"></tpx-text-item>
</tpx-select>
</view>
</template>
<view class="yunf-input-item">
<tpx-select v-model:value="submitParam.customsEclaration" :list="dicData.emis_declare_mode"
mode="drop"
>
<tpx-text-item label="报关方式" :value="submitParam.customsEclaration" :list="dicData.emis_declare_mode"></tpx-text-item>
</tpx-select>
</view>
<view class="yunf-input-item">
<tpx-select v-model:value="submitParam.customsClear" :list="dicData.emis_customs_clear"
mode="drop"
>
<tpx-text-item label="清关方式" :value="submitParam.customsClear" :list="dicData.emis_customs_clear"></tpx-text-item>
</tpx-select>
</view>
<view class="yunf-input-item">
<u-row justify="between">
<text class="font-28 font-weight">包裹重量</text>
<view>
<tpx-input v-model:value="submitParam.billWeight" placeholder="" inputAlign="right" suffix="kg" _digit="4"></tpx-input>
</view>
</u-row>
</view>
<view class="yunf-input-item">
<u-row justify="between" align="top">
<text class="font-28 pt-20 font-weight">总体积</text>
<view>
<tpx-input v-model:value="submitParam.totalVolume" placeholder="" inputAlign="right" suffix="m³" _digit="4"></tpx-input>
</view>
</u-row>
</view>
</view>
<view class="com-section mt-30">产品类型</view>
<view class="blcok-white yunf-list" style="padding-bottom: 2rpx;">
<bpe-choosetypelist-tmp ref="caleRef" v-model:value="submitParam" :autoCalc="false"></bpe-choosetypelist-tmp>
</view>
<u-row justify="center">
<view class="mt-40">
<u-button @click="handleCalPost" size="large" shape="circle"
custom-style="width: 400rpx;height:80rpx;font-size: 30rpx;" type="primary">运费试算</u-button>
</view>
</u-row>
</view>
</template>
<template v-if="submitParam.freight" v-slot:footer>
<view class="pos-rlt blcok-white" style="border-radius: 0;margin-top: 0;">
<u-row justify="between">
<view style="flex:1;">
<bpe-checkagree-tmp v-model:value="submitParam" :showPrivacy="false"></bpe-checkagree-tmp>
</view>
<view>
<u-row>
<u-button @click="handleToXiaDan" size="large" shape="circle"
custom-style="width: 200rpx;height:80rpx;font-size: 30rpx;" type="primary">下单</u-button>
</u-row>
</view>
</u-row>
</view>
</template>
</tpx-layout>
</tpx-page>
</template>
<script>
import BpeAddressinfoTmp from "@/components/buns-post-edit-templates/bpe-addressinfo-tmp"
import BpeCheckagreeTmp from "@/components/buns-post-edit-templates/bpe-checkagree-tmp"
import BpeChoosetypelistTmp from "@/components/buns-post-edit-templates/bpe-choosetypelist-tmp"
import * as apiService from "@/common/api"
export default {
components: { BpeAddressinfoTmp, BpeCheckagreeTmp, BpeChoosetypelistTmp },
props: {
// hasLeftWin: {
// type: Boolean
// }
},
computed: {
dicData() {
return this.$store.getters.dicData
},
waySearchParam() {
return { country: this.submitParam.reciever.country, fromCountry: this.submitParam.sender.country }
},
},
data() {
return {
...this.getDefaultData(),
}
},
onShareAppMessage() {
return {
}
},
onLoad() {
this.initData();
},
onUnload() {
},
methods: {
getTransLineList: apiService.getTransLineList,
initData() {
},
getDefaultData(){
return {
submitParam: {
reciever: {},
sender: {}
},
wayRes: { list: [] },
}
},
handleDialogClick(curModal){
curModal.show = true
},
async handleCalPost() {
this.submitParam.freight = 0
await this.$refs.caleRef.calcTypeFee()
},
handleAddressChange() { // 地址切换
let { wayRes, submitParam } = this.getDefaultData()
if(this.submitParam.reciever.country && this.submitParam.sender.country) {
this.submitParam.transLine = submitParam.transLine
this.submitParam.transLineTypeName = submitParam.transLineTypeName
this.handleWayChange() // 调用线路切换,清空后续数据
}
},
handleWayChange(val) { // 线路切换
let { productRes, submitParam } = this.getDefaultData()
// 清空产品类型数据
this.submitParam.productType = submitParam.productType
this.submitParam.productTypeName = submitParam.productTypeName
const item = this.wayRes.list.filter(t=> t.val == val)[0]
this.updateDltDestSite({ lineCode: val })
this.updateDltSendSite({ lineCode: val })
},
async updateDltDestSite({ lineCode }) {
const { country, province, city, county, address } = this.submitParam.reciever
let res = await apiService.getCaculteDestSite({ lineCode, country, province, city, county, address })
// 更新路线推荐的默认目的地
let data = res.data || {}
this.submitParam.destinationCode = data.destCode
this.submitParam.destinationName = data.destName
this.submitParam.dispatchUnderlingSiteCode = data.siteCode;
this.submitParam.dispatchUnderlingSiteName = data.siteName;
},
async updateDltSendSite({ lineCode }) {
const { country, province, city, county, address } = this.submitParam.sender
let sendRes = await apiService.getCaculteSendSite({ lineCode, country, province, city, county, address })
let data = sendRes.data || {}
this.submitParam.sendSiteCode = data.siteCode
this.submitParam.sendSiteName = data.siteName
},
handleToXiaDan(){
let cpData = JSON.parse(JSON.stringify(this.submitParam))
this.goto(`post/post?defaultSubParams=${encodeURIComponent(JSON.stringify(cpData))}&type=create`)
}
}
}
</script>
<style lang="scss">
@import '@/common/uni-nvue.scss';
page {
background-color: #F6F6F6;
height: 100% !important;
}
</style>
<style scoped lang="scss">
.yunf-input-item{
padding: 26rpx 0;
border-bottom: 2rpx solid #F6F6F6;
}
</style>