Files
jjx-web/pages/index/self-support/productQuote.vue
T
b2894lxlx 17b2d8f117 1、新增旧货市场
2、新增用户等级
2023-12-10 14:53:07 +08:00

363 lines
18 KiB
Vue

<template>
<view>
<top-bar></top-bar>
<common-header></common-header>
<category-bar></category-bar>
<view class="w-1200 m-a">
<u-swiper :list="list" :height="380" borderRadius="0"></u-swiper>
<view class="bg-white p-40">
<view v-for="(item, index) in configList" :key="index"
class="my-20 flex flex-col justify-start items-start">
<view class="flex flex-col justify-start items-start">
<view class="flex justify-start items-center text-35 mb-20">
<text>服务内容:{{ item.name }}</text>
<view class="flex flex-col justify-start items-start">
<view v-for="(content, contentIndex) in item.contents" :key="contentIndex"
class="mb-40 flex justify-start items-center">
<view class="ml-35">
<text>业务编号:</text>
<text>{{ content.code }}</text>
</view>
<view class="flex justify-start items-center">
<text class="ml-35">服务服务项目:</text>
<el-checkbox v-model="configList[index].contents[contentIndex].checked"
@change="selectContent(content)"
:disabled="!content.amountList || content.amountList.length === 0">
{{ content.title }}
</el-checkbox>
</view>
<view class="flex justify-start items-center ml-35">
<el-select v-model="configList[index].contents[contentIndex].amountIndex"
clearable
:disabled="!content.amountList || content.amountList.length === 0">
<el-option v-for="(amount, amountIndex) in content.amountList"
:key="amountIndex"
:label="amount.title" :value="amountIndex"/>
</el-select>
<text class="ml-35" v-if="content.amountIndex !== null">
{{ content.amountList[content.amountIndex].amount }}元/次
</text>
</view>
</view>
</view>
</view>
<view>备注: {{ item.remark }}</view>
</view>
</view>
<el-form ref="form" :model="form" label-width="200px">
<view v-for="(item, productIndex) in productList" :key="productIndex">
<el-form-item label="检测产品:" required>
<el-input v-model="productList[productIndex].name"/>
</el-form-item>
<el-form-item label="检测内容">
{{ contentNameList.join() }}
</el-form-item>
<el-form-item label="取样所在地">
<el-row :gutter="10">
<el-col :span="4">
<el-select v-model="addressIndex[productIndex][0]" placeholder="请选择省">
<el-option v-for="(item, index) in provinceData" :key="index"
:label="item.name"
:value="index">
</el-option>
</el-select>
</el-col>
<el-col :span="4">
<el-select v-model="addressIndex[productIndex][1]" placeholder="请选择市"
:disabled="addressIndex[productIndex].length === 0">
<template v-if="addressIndex[productIndex][0] !== null">
<el-option v-for="(item, index) in cityData[addressIndex[productIndex][0]]"
:key="index"
:label="item.name"
:value="index">
</el-option>
</template>
</el-select>
</el-col>
<el-col :span="4">
<el-select v-model="addressIndex[productIndex][2]" placeholder="请选择区"
:disabled="addressIndex[productIndex].length === 1">
<template
v-if="addressIndex[productIndex][0] !== null && addressIndex[productIndex][1] !== null">
<el-option
v-for="(item, index) in areaData[addressIndex[productIndex][0]][addressIndex[productIndex][1]]"
:key="index"
:label="item.name"
:value="index">
</el-option>
</template>
</el-select>
</el-col>
<el-col :span="11">
<el-input v-model="productList[productIndex].address" placeholder="请输入详细地址"/>
</el-col>
</el-row>
</el-form-item>
<el-form-item label="接收文件电子邮箱:">
<el-input v-model="productList[productIndex].email"/>
</el-form-item>
<el-form-item label="接收文件微信:">
<el-input v-model="productList[productIndex].wechat"/>
</el-form-item>
<el-form-item label="接收文件寄件地址">
<el-row :gutter="10">
<el-col :span="4">
<el-select v-model="receiveAddressIndex[productIndex][0]" placeholder="请选择省">
<el-option v-for="(item, index) in provinceData" :key="index"
:label="item.name"
:value="index">
</el-option>
</el-select>
</el-col>
<el-col :span="4">
<el-select v-model="receiveAddressIndex[productIndex][1]" placeholder="请选择市"
:disabled="receiveAddressIndex[productIndex].length === 0">
<template v-if="receiveAddressIndex[productIndex][0] !== null">
<el-option
v-for="(item, index) in cityData[receiveAddressIndex[productIndex][0]]"
:key="index"
:label="item.name"
:value="index">
</el-option>
</template>
</el-select>
</el-col>
<el-col :span="4">
<el-select v-model="receiveAddressIndex[productIndex][2]" placeholder="请选择区"
:disabled="receiveAddressIndex[productIndex].length === 1">
<template
v-if="receiveAddressIndex[productIndex][0] !== null && receiveAddressIndex[productIndex][1] !== null">
<el-option
v-for="(item, index) in areaData[receiveAddressIndex[productIndex][0]][receiveAddressIndex[productIndex][1]]"
:key="index"
:label="item.name"
:value="index">
</el-option>
</template>
</el-select>
</el-col>
<el-col :span="11">
<el-input v-model="productList[productIndex].receiveAddress" placeholder="请输入详细地址"/>
</el-col>
</el-row>
</el-form-item>
<el-form-item label="申请人:">
<el-input v-model="productList[productIndex].requestName"/>
</el-form-item>
<el-form-item label="联系人:">
<el-input v-model="productList[productIndex].contactName"/>
</el-form-item>
<el-form-item label="联系方式:">
<el-input v-model="productList[productIndex].contact"/>
</el-form-item>
<el-form-item label="本次服务费用小计:">
<view class="flex justify-between items-start mb-20 w-100p">
<view class="flex justify-start items-center">
<el-input v-model="amount" disabled/>
<view class="ml-20">
<el-button type="primary" @click.native="addProduct">增加考察对象
</el-button>
</view>
<view class="ml-20">
<el-button type="primary" plain @click.native="removeProduct(productIndex)"
class="ml-20"
:disabled="productList.length === 1">删除该对象
</el-button>
</view>
</view>
</view>
</el-form-item>
</view>
</el-form>
<view class="mt-40 flex justify-center items-center">
<view class="flex justify-center items-center">
<text>总价:</text>
<text class="text-main font-bold text-35">{{ totalAmount }}元</text>
</view>
<view class="ml-35">客服联系方式: 0771-3923001</view>
</view>
<view class="mt-40 flex justify-center items-center">
<el-button type="primary" @click.native="newOrder"
:disabled="productList.length === 0 || !productList[0].name">
立即支付
</el-button>
</view>
</view>
</view>
<gap/>
<common-footer></common-footer>
</view>
</template>
<script>
import provinces from "@/uni_modules/vk-uview-ui/libs/address/provinces.json";
import citys from "@/uni_modules/vk-uview-ui/libs/address/citys.json";
import areas from "@/uni_modules/vk-uview-ui/libs/address/areas.json";
export default {
name: "productQuote",
data() {
return {
provinceData: provinces,
cityData: citys,
areaData: areas,
list: [
{
image: '/static/images/selfSupport/swiper.jpg',
title: '昨夜星辰昨夜风,画楼西畔桂堂东'
},
],
form: {},
configList: [],
checkList: [],
contentList: [],
contentNameList: [],
addressIndex: [[null, null, null]],
addressDetail: '',
receiveAddressIndex: [[null, null, null]],
receiveAddressDetail: '',
productList: [
{
name: '',
code: '',
addressRegion: {
province: null,
city: null,
area: null,
},
address: '',
email: '',
wechat: '',
receiveAddressRegion: {
province: null,
city: null,
area: null,
},
receiveAddress: '',
requestName: '',
contactName: '',
contact: '',
}
],
}
},
methods: {
async getConfigList() {
const {rows} = await vk.callFunction({
url: 'client/coop/config/pub/getList',
data: {type: 1}
})
if (rows) {
this.configList = rows.map(item => {
item.contents.map(content => {
content.checked = false
content.amountIndex = null
return content
})
return item
})
}
},
addProduct() {
this.productList.push({
name: '',
code: '',
addressRegion: {
province: null,
city: null,
area: null,
},
address: '',
email: '',
wechat: '',
receiveAddressRegion: {
province: null,
city: null,
area: null,
},
receiveAddress: '',
requestName: '',
contactName: '',
contact: '',
})
this.addressIndex.push([null, null, null])
this.receiveAddressIndex.push([null, null, null])
},
removeProduct(index) {
this.productList.splice(index, 1)
this.addressIndex.splice(index, 1)
this.receiveAddressIndex.splice(index, 1)
},
selectContent(content) {
const index = this.contentNameList.indexOf(content.title)
if (index === -1) this.contentNameList.push(content.title)
else this.contentNameList.splice(index, 1)
},
async newOrder() {
const amountList = []
this.configList.forEach(item => {
item.contents.forEach(content => {
if (content.checked && content.amountList.length > 0) {
content.amountList.forEach((amount, amountIndex) => {
if (amountIndex === content.amountIndex) {
amountList.push(amount._index)
}
})
}
})
})
if (amountList.length === 0) return this.$message({
message: '请至少选择一项服务',
type: 'error'
})
this.productList.forEach((item, index) => {
this.productList[index].addressRegion = {
province: this.provinceData[this.addressIndex[index][0]],
city: this.cityData[this.addressIndex[index][0]][this.addressIndex[index][1]],
area: this.areaData[this.addressIndex[index][0]][this.addressIndex[index][1]][this.addressIndex[index][2]],
}
this.productList[index].receiveAddressRegion = {
province: this.provinceData[this.receiveAddressIndex[index][0]],
city: this.cityData[this.receiveAddressIndex[index][0]][this.receiveAddressIndex[index][1]],
area: this.areaData[this.receiveAddressIndex[index][0]][this.receiveAddressIndex[index][1]][this.receiveAddressIndex[index][2]],
}
})
const {data} = await vk.callFunction({
url: 'client/selfSupport/kh/addOrder',
data: {
type: 1,
amountList,
contentList: this.productList
}
})
vk.navigateTo({
url: `/pages/index/shop/pay?id=${data}`
})
},
},
onLoad() {
this.getConfigList()
},
computed: {
amount() {
let tmpAmount = 0
this.configList.forEach(item => {
item.contents.forEach(content => {
if (content.checked && content.amountList.length > 0) {
content.amountList.forEach((amount, amountIndex) => {
if (amountIndex === content.amountIndex) {
tmpAmount += parseFloat(amount.amount)
}
})
}
})
})
return tmpAmount
},
totalAmount() {
return this.amount * this.productList.length
}
}
}
</script>