You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1020 lines
30 KiB

3 years ago
<template>
<view :class="['page', { show: isDetail }]">
3 years ago
<view class="block">
<view class="l-title">基本信息</view>
<view class="form-list">
<view class="line">
<view class="name">商务经理</view>
2 years ago
<view class="val">{{ form.businessManagerName }}</view>
3 years ago
</view>
2 years ago
<view :class="['line req', {err: err === 'customerName'}]">
3 years ago
<view class="name">客户名称</view>
<view v-if="isDetail" class="val">{{ form.customerName }}</view>
<view v-else class="customer-wrap">
<view :class="['ph', {val: form.customerName}]" @click="customerVisible = true">{{ form.customerName || '请选择客户' }}</view>
1 year ago
<!-- <view class="create" @click="toClient">找不到客户马上创建</view> -->
</view>
3 years ago
</view>
2 years ago
<view class="line" v-if="form.customerName">
3 years ago
<view class="name">省份</view>
<view class="val">{{ form.provinceName }}</view>
</view>
2 years ago
<view class="line" v-if="form.customerName">
3 years ago
<view class="name">城市</view>
<view class="val">{{ form.cityName }}</view>
</view>
2 years ago
<view class="line" v-if="form.customerName">
3 years ago
<view class="name">联系人</view>
2 years ago
<view class="val">{{ form.orderContact }}</view>
3 years ago
</view>
2 years ago
<view class="line" v-if="form.customerName">
3 years ago
<view class="name">电话</view>
<view class="val">{{ form.phone }}</view>
</view>
2 years ago
<view class="line" v-if="form.customerName">
3 years ago
<view class="name">邮箱</view>
<view class="val">{{ form.email }}</view>
</view>
12 months ago
<!-- <view :class="['line req', {err: err === 'orderType'}]">
3 years ago
<view class="name">订单类型</view>
2 years ago
<view v-if="isDetail" class="val">{{ orderTypes.find(e => e.value === form.orderType).text }}</view>
2 years ago
<uni-data-picker v-else class="picker-input" placeholder="请选择订单类型" popup-title="请选择订单类型" preload :clear-icon="false" :localdata="orderTypes" v-model="form.orderType" @change="calcTotal(1)"></uni-data-picker>
12 months ago
</view> -->
1 year ago
<template v-if="edited">
<view class="line">
<view class="name">订单编号</view>
<view class="val">{{ form.orderNumber }}</view>
</view>
<view class="line">
<view class="name">订单时间</view>
<view class="val">{{ form.createTime }}</view>
</view>
<view class="line">
<view class="name">订单金额</view>
<view class="val">{{ form.orderAmount }}</view>
</view>
</template>
3 years ago
</view>
3 years ago
</view>
3 years ago
<template v-for="c in courseList">
2 years ago
<view v-if="c.list.length" class="block pro-wrap" id="products">
<view class="l-title">{{ c.name }}</view>
3 years ago
<uni-icons class="arrow" type="top" size="20" color="#007EFF" @click="toggle(c)"></uni-icons>
<ul class="pro-list" v-show="!c.shrink">
1 year ago
<li v-for="(item, i) in c.list">
<view class="name">
<view class="left">
2 years ago
<image class="icon" :src="$util.getIcon(item)" mode="widthFix"></image>
{{ item.productName }}
</view>
<view class="course-action">
<image v-if="!isDetail" class="del" src="@/static/image/trash.png" mode="widthFix" @click.stop="delCourse(c, i)"></image>
</view>
3 years ago
</view>
<view class="info">
<view class="line">
1 year ago
<view class="label">起始日期</view>
<view v-if="isDetail || isEdit" class="ph">{{ item.endTime ? item.startTime + ' - ' + item.endTime : item.startTime}}</view>
<uni-datetime-picker v-else type="date" v-model="item.startTime" :border="false" @change="calcDate(item)">
<view :class="['ph', {val: item.startTime}]">
{{ item.endTime ? item.startTime + ' - ' + item.endTime : item.startTime}}
</view>
</uni-datetime-picker>
</view>
<view class="line" :class="[ {err: err === 'periodOfUse' + item.dataOrCourseId + item.authority}]">
<view class="label">使用期限</view>
1 year ago
<view v-if="isDetail" class="ph">{{item.periodOfUse}}{{ units.find(e => e.id === item.options).text }}</view>
<template v-else>
<input class="period" type="number" v-model="item.periodOfUse" placeholder="请输入" @input="calcDate(item, !item.authority)" @change="handleErr(item, 'periodOfUse')">
<view class="val unit" @click="selectUnit(item)">
<text>{{ units.find(e => e.id === item.options).text }}</text>
<image class="icon" src="@/static/image/arrow-down.png" mode="widthFix"></image>
</view>
</template>
</view>
<view :class="['line req', {err: err === 'accountNum' + item.dataOrCourseId + item.authority}]">
<view class="label">数量</view>
<view v-if="item.authority || (!item.authority && isDetail)" class="ph">1</view>
<view v-else class="inline">
<input type="number" v-model="item.accountNum" placeholder="请输入账号数量" @input="calcFinalPrice(item)" @change="handleErr(item, 'accountNum')">
</view>
</view>
<view class="line">
1 year ago
<view class="label">{{ item.authority ? '市场价' : '市场单价' }}</view>
<view class="ph">{{ item.marketValue && item.marketValue + '元' }}</view>
</view>
<view class="line">
<view class="label">结算价</view>
1 year ago
<view class="ph">{{ item.settlementPrice && item.settlementPrice + '元' }}</view>
</view>
<view class="line">
<view class="label">折扣率</view>
1 year ago
<view class="ph">{{ item.discountRate }}</view>
</view>
<view class="line">
2 years ago
<view class="label">市场服务费</view>
1 year ago
<view class="ph">{{ item.serviceFee }}</view>
</view>
1 year ago
<view :class="['line req', {err: err === 'finalPrice' + item.dataOrCourseId + item.authority}]">
<view class="label">成交价</view>
<view v-if="isDetail" class="ph">{{ item.finalPrice }}</view>
<view class="inline" v-else>
<input type="number" v-model="item.finalPrice" placeholder="请输入" @input="calcFinalValue(item)" @change="handleErr(item, 'finalPrice')">
</view>
</view>
1 year ago
<view v-if="(item.authority == 0 || item.authority == 3 || item.authority == 4) && item.shipInfo" class="line">
<view class="label">发货信息</view>
<view class="ph ship-info" v-html="item.shipInfo" @click="copy(item)"></view>
</view>
3 years ago
</view>
</li>
</ul>
</view>
</template>
3 years ago
3 years ago
<view class="bottom">
1 year ago
<template v-if="!edited && !orderId">
<view class="next-wrap">
<view class="lg-btn next" @click="toAdd(0)">下一步</view>
2 years ago
</view>
1 year ago
</template>
<template v-else>
<view v-if="!orderId" class="add-wrap">
<view class="lg-btn" @click="toAdd(1)">
<uni-icons class="icon" type="plus" color="#007FFF"></uni-icons>
添加产品
3 years ago
</view>
1 year ago
</view>
<view :class="['product', isDetail ? 'show' : 'edit']">
<view class="text">
<view class="total">
<view v-if="isDetail">共选<text class="num">{{ courses.length }}</text>个产品</view>
<view class="column">总成交价合计<text class="num">{{ form.orderAmount }}</text></view>
2 years ago
</view>
1 year ago
<view class="info">
<view class="line">
总采购成本:<text class="num">{{ form.purchaseCost }}</text>
</view>
<view class="line">
总产品利润:<text class="num"> {{ form.profit }}</text>
</view>
2 years ago
</view>
3 years ago
</view>
1 year ago
<view v-if="!isDetail" class="btn" @click="submit">提交({{ courses.length }})</view>
3 years ago
</view>
1 year ago
</template>
3 years ago
</view>
<view class="popup-mask" v-show="customerVisible" @click="closeCustomer"></view>
<view class="popup" v-show="customerVisible">
<view class="top">请选择客户</view>
<uni-icons class="close" type="closeempty" size="20" @click="closeCustomer"></uni-icons>
<uni-search-bar class="search" radius="5" placeholder="请输入客户名称" v-model="keyword" clearButton="auto" cancelButton="none" />
1 year ago
<view class="create" @click="toClient">找不到客户马上创建</view>
3 years ago
<view class="list">
3 years ago
<view class="item" v-for="item in customerList" @click="customerChange(item)">{{ item.customerName }}</view>
3 years ago
</view>
</view>
</view>
</template>
<script>
import { productCategoryList, delCart } from '@/apis/modules/product.js'
3 years ago
import { queryCustomer, queryCustomerDetails } from '@/apis/modules/client.js'
1 year ago
import { add, update, getDetail, queryCitySettlementPrice, getOrderOtherTime } from '@/apis/modules/order.js'
2 years ago
import { getPartnerTeamRates } from '@/apis/modules/parner.js'
3 years ago
export default {
data() {
return {
3 years ago
isDetail: false,
orderId: '',
1 year ago
edited: false,
shopCart: false,
3 years ago
orderTypes: [{
text: '正式',
3 years ago
value: 1
3 years ago
}, {
text: '试用',
3 years ago
value: 2
3 years ago
}],
form: {
2 years ago
businessManagerName: uni.getStorageSync('team').userName,
3 years ago
// orderNumber: '', // 编号
provinceId: '', // 省份id
provinceName: '',
3 years ago
orderContact: '', // 联系人
email: '',
customerId: '', // 客户id
customerName: '',
12 months ago
orderType: 2,
3 years ago
cityId: '',
cityName: '',
3 years ago
phone: '',
orderAmount: 0,
customerName: '',
3 years ago
profit: 0, // 利润
2 years ago
purchaseCost: 0, // 采购成本
2 years ago
teamId: uni.getStorageSync('team').id,
businessManagerId: this.$util.getBmId()
3 years ago
},
courseList: {},
3 years ago
courses: [], // 缓存的产品列表
3 years ago
contract: { // 合同信息
contractName: '', // 合同名称
contractFile: '', // 合同文件
contractMoney: '', // 合同金额
contractNumber: '',// 合同编号
startTime: '', // 期限-头
endTime: '' // 期限-尾
},
3 years ago
customerVisible: false,
keyword: '',
searchTimer: null,
customerList: [],
customerListAll: [],
2 years ago
err: '',
rate: '',
1 year ago
orderRepeat:[],
units: [{
text: '日',
id: 0
}, {
text: '月',
id: 1
}, {
text: '年',
id: 2
}],
unitText: ['日', '月', '年'],
3 years ago
}
},
2 years ago
watch: {
keyword () {
clearTimeout(this.searchTimer)
this.searchTimer = setTimeout(() => {
this.filterCustomer()
}, 500)
}
},
3 years ago
onShow() {
const pages = getCurrentPages()
3 years ago
const { options } = pages[pages.length - 1]
this.orderId = options.orderId
this.isDetail = !!options.show
1 year ago
this.edited = options.edited // 已经编辑过产品的标识
this.shopCart = options.shopCart // 从购物车进来的标识
3 years ago
const store = uni.getStorageSync('courses')
1 year ago
const form = uni.getStorageSync('orderForm')
if (form) {
this.form = form
uni.removeStorageSync('orderForm')
}
2 years ago
this.getRate()
3 years ago
if (this.orderId) {
this.getInfo()
1 year ago
} else if (options.edited && store) { // 不是从购物车进来,并且有产品缓存(即是从当前页面点下一步编辑完产品回来的情况),则处理缓存里的产品
3 years ago
// 新增取缓存,取了删除
3 years ago
const list = []
for (const i in store) {
1 year ago
// 发货信息处理
store[i].list.map(e => {
let val = []
e.mallNonAssociatedLinks && e.mallNonAssociatedLinks.forEach(e => {
val.push(e.urlName + ':' + e.url)
})
e.shipInfo = e.shipContent || val.join('<br>')
e.copyInfo = e.shipContent || val.join(';')
})
3 years ago
list.push(...store[i].list)
}
this.courseList = store
this.courses = list
3 years ago
try {
uni.removeStorageSync('courses')
} catch (e) {}
this.calcTotal()
3 years ago
}
1 year ago
// 如果是客户订单记录页面点的新增,会有客户id,要默认选中该客户
const { customerId } = options
customerId && this.customerChange({
customerId
})
3 years ago
// 非详情才需要查询客户
if (!this.isDetail) {
this.getCustomer()
}
// 设置标题
uni.setNavigationBarTitle({
3 years ago
title: this.orderId ?
(this.isDetail ?
3 years ago
'订单详情' :
'编辑订单') :
'新增订单'
})
3 years ago
},
methods: {
3 years ago
// 获取详情
getInfo() {
2 years ago
uni.showLoading({
title: '加载中'
})
3 years ago
getDetail({
orderId: this.orderId
3 years ago
}).then(({ orderDetails }) => {
const order = orderDetails
this.contract = order.contractInformation
this.form = order.order
this.courses = order.orderOther
this.handleProduct(order.orderOther)
2 years ago
uni.hideLoading()
}).catch(e => {
uni.hideLoading()
})
3 years ago
},
// 转换产品列表
handleProduct(list) {
let courses = {}
// 产品分类
productCategoryList().then(res => {
res.classificationList.forEach(e => {
courses['list' + this.$util.getOrderType(e.classificationId)] = {
shrink: false,
name: e.classificationName,
list: []
}
})
// 3个分类的课程分别push到不同数组(0->理论 1-实训 2 数据产品)
list.map(e => {
1 year ago
// 发货信息处理
let val = []
e.mallNonAssociatedLinks && e.mallNonAssociatedLinks.forEach(e => {
val.push(e.urlName + ':' + e.url)
})
e.shipInfo = e.shipContent || val.join('<br>')
e.copyInfo = e.shipContent || val.join(';')
e.serviceFee = (e.finalPrice * (this.rate / 100)).toFixed(2) // 服务费 != 0 && 才需要算
courses['list' + e.authority].list.push(e)
})
this.courseList = courses
}).catch(e => {})
},
3 years ago
// 获取客户列表
getCustomer() {
queryCustomer({
countries: '中国',
provinceId: '',
cityId: '',
searchContent: this.keyword,
page: 1,
size: 10000
}).then(({ message }) => {
this.customerListAll = message.list
this.customerList = message.list
}).catch(res => {})
3 years ago
},
3 years ago
// 客户模糊匹配
filterCustomer() {
const { keyword } = this
this.customerList = keyword ?
this.customerListAll.filter(e => e.customerName.includes(keyword)) :
this.customerListAll
},
// 关闭客户弹框
closeCustomer() {
this.customerVisible = false
this.keyword = ''
},
// 客户名称选择回调
async customerChange(item) {
3 years ago
const { form } = this
// 获取客户详情
const { result } = await queryCustomerDetails({
3 years ago
customerId: item.customerId
})
this.handleErr('customerName')
const e = result.customer
const { provinceId, cityId } = e
form.customerId = e.customerId
form.customerName = e.customerName
form.provinceId = provinceId
form.cityId = cityId
form.provinceName = e.provinceName
form.cityName = e.cityName
form.phone = e.phone
form.email = e.email
form.orderContact = e.name
// 获取平台结算价重新计算课程的相关参数
const list = this.courseList
const courses = []
const promises = []
for (const i in list) {
list[i].list.forEach(n => {
promises.push(new Promise(async (resolve, reject) => {
const res = await queryCitySettlementPrice(n.mallId, provinceId, cityId)
if (res.mallPrice) n.settlementPriceUnit = res.mallPrice.discountRate || 0
courses.push(n)
resolve()
}))
})
}
Promise.all(promises).then(_ => {
this.courses = courses
this.calcTotal()
this.closeCustomer()
})
3 years ago
},
2 years ago
// 查询合伙人团队费率
getRate() {
getPartnerTeamRates({
teamId: uni.getStorageSync('team').teamId
}).then(({ teamRates }) => {
2 years ago
this.rate = teamRates.annualMarketingFee || 0
2 years ago
}).catch(res => {})
},
3 years ago
// 跳转
1 year ago
toAdd(add) {
add && uni.setStorageSync('courses', this.courses)
1 year ago
uni.setStorageSync('orderForm', this.form)
3 years ago
const { customerId, orderType } = this.form
1 year ago
// 从购物车进来的,直接跳转到编辑产品;否则跳转到选择产品
const url = this.shopCart ?
`../editCourse/editCourse` :
`../addCourse/addCourse`
3 years ago
customerId ?
1 year ago
this.$util.to(url + `?orderType=${orderType}&customerId=${customerId}&provinceId=${this.form.provinceId}&cityId=${this.form.cityId}`) :
3 years ago
this.$util.errMsg('请先选择客户!')
3 years ago
},
1 year ago
// 前往创建客户
toClient() {
1 year ago
this.shopCart || uni.setStorageSync('courses', this.courses)
1 year ago
this.$util.to(`/order/clientDetail/clientDetail?order=1${this.shopCart ? '&shopCart=1' : ''}`)
1 year ago
},
3 years ago
// 删除课程
delCourse(c, i) {
2 years ago
const that = this
3 years ago
uni.showModal({
title: '提示',
content: '确定要删除吗?',
success(res) {
2 years ago
if (res.confirm) {
c.list.splice(i, 1)
const courses = []
const list = that.courseList
for (const j in list) {
list[j].list.map(n => {
courses.push(n)
})
}
that.courses = courses
that.calcTotal()
}
3 years ago
}
})
},
3 years ago
// 收缩产品
toggle(c) {
c.shrink = !c.shrink
},
3 years ago
// 计算订单总额
2 years ago
calcTotal(out) {
2 years ago
this.handleErr('orderType')
3 years ago
const { form } = this
2 years ago
const isTrial = form.orderType === 2 // 是否试用
2 years ago
let total = 0
2 years ago
const list = this.courses
let purchase = 0 // 总采购成本
let profit = 0 // 总利润
/**
* 1总采购成本+总产品利润=总成交价格
2单个产品采购成本 =结算价+平台服务费
3平台服务费=结算价*10%
4单个产品的利润=成交价-采购成本
总成本和总利润为单个产品的采购成本价和利润的和
*/
list.map(e => {
2 years ago
// out=1 && 试用,则把结算价等重置为0
if (out && isTrial) {
2 years ago
e.settlementPrice = 0
e.serviceFee = 0
e.finalPrice = 0
e.finalValue = 0
e.discountRate = '0%'
} else {
2 years ago
this.calcDiscount(e)
this.dealSettlePrice(e)
1 year ago
// this.calcFinalPrice(e)
2 years ago
const curPurchase = +e.settlementPrice + +e.serviceFee
purchase += curPurchase
profit += +e.finalPrice - curPurchase
}
2 years ago
})
2 years ago
form.purchaseCost = purchase
form.profit = profit
form.orderAmount = (+form.purchaseCost + +form.profit).toFixed(2)
3 years ago
},
1 year ago
// 计算订单总额
calcAmount() {
const { form } = this
const list = this.courses
let purchase = 0 // 总采购成本
let profit = 0 // 总利润
list.map(e => {
const curPurchase = +e.settlementPrice + +e.serviceFee
purchase += curPurchase
profit += +e.finalPrice - curPurchase
})
form.purchaseCost = Math.round(purchase)
form.profit = Math.round(profit)
form.orderAmount = (+form.purchaseCost + +form.profit).toFixed(2)
console.log(111, this.courseList, this.courses)
},
calcDate(row, fromData) {
clearTimeout(this.timer)
this.timer = setTimeout(() => {
const { periodOfUse, options } = row
let optionsData = 0
if (periodOfUse) {
if (options == 1){
optionsData = periodOfUse === '12' ? 31536000000 : periodOfUse*30*24*60*60*1000
} else if (options == 2){
optionsData = periodOfUse*365*24*60*60*1000
} else {
optionsData = periodOfUse*24*60*60*1000
}
}
let time = new Date(row.startTime).getTime()
let endTime = time + optionsData
row.endTime = time + optionsData
let dt = new Date(endTime)
row.endTime = (dt.getFullYear()) + "-" + (dt.getMonth() + 1) + "-" + (dt.getDate())
let endYear = endTime - time
let endYears = endYear/1000/60/60/24
row.remainingPeriod = endYears
const unit = row.options // 使用期限单位
const useUnit = row.periodOfUse // 使用期限
// 计算市场价
const price = row.marketPrice || 0 // 市场单价
// 结算单价是元/年,所以如果选择的不是年,要进行换算(日:/365,月:/12)
row.marketValue = (!unit ?
price / 365 * useUnit :
unit === 1 ?
price / 12 * useUnit :
price * useUnit).toFixed(2)
this.dealSettlePrice(row)
// 只有改变了起止日期才需要调接口查询订单,该接口作用是把开始时间传过去,会返回一个提示或者时间,如果是时间,则把时间+1天,如果是提示,则无法保存
if (!fromData) {
const cId = row.dataOrCourseId
const date = new Date(row.startTime)
const orderRepeat = this.orderRepeat
getOrderOtherTime({
1 year ago
authority: row.authority,
customerId: this.form.customerId,
1 year ago
id: cId,
startTime: this.$util.formatDate(date, 'yyyy-MM-dd'),
endTime: row.endTime
}).then(res => {
1 year ago
orderRepeat.includes(cId) && orderRepeat.splice(orderRepeat.findIndex(e => e == cId), 1)
1 year ago
if (res.endTime) {
let time = new Date(res.endTime)
time = new Date(time.setDate(time.getDate() + 1))
row.startTime = this.$util.formatDate(time, 'yyyy-MM-dd')
}
}).catch(res => {
this.repeatMsg = res.message
orderRepeat.includes(cId) || orderRepeat.push(cId)
})
}
// 折扣率
this.calcDiscount(row)
}, 500)
2 years ago
},
dealSettlePrice(row) {
1 year ago
// 如果是试用或者没选择,结算价和平台服务费都是0
if (this.form.orderType != 1) {
2 years ago
row.settlementPrice = 0
row.serviceFee = 0
} else {
const unit = row.options // 使用期限单位
const useUnit = row.periodOfUse // 使用期限
1 year ago
let sPrice = ''
// 结算单价。计算规则:结算单价(**元/年)*购买时长(单位年)*数量(课程为1,数据为账号数量)
const priceUnit = row.settlementPriceUnit
1 year ago
sPrice = ((!unit ?
priceUnit / 365 * useUnit :
unit === 1 ?
priceUnit / 12 * useUnit :
priceUnit * useUnit) * (row.authority ?
1 :
row.accountNum)).toFixed((2))
2 years ago
row.settlementPrice = this.$util.handleNaN(sPrice)
// 平台服务费
1 year ago
row.serviceFee = (row.finalPrice * (this.rate / 100)).toFixed(2)
this.calcAmount()
console.log('row.settlementPrice =>' ,row.settlementPrice,row.settlementPriceUnit,sPrice,row)
2 years ago
}
},
1 year ago
calcDiscount(row) {
const price = row.authority ? row.finalPrice : row.finalValue
const { marketValue } = row
// (原价-现价)÷原价 x100%
if (price) row.discountRate = marketValue != 0 ? ((marketValue - price) / marketValue * 100).toFixed(2) + '%' : '0%'
},
selectUnit(item) {
const that = this
uni.showActionSheet({
title: '标题',
itemList: that.unitText,
success: ({ tapIndex }) => {
item.options = tapIndex
that.calcDate(item)
}
})
},
// 成交价修改后,计算成交单价,数据才需要 计算规则:成交价/账号数/时间(成交单价为元/账号/年,所以时间要换算成年的单位去计算)
calcFinalValue(row) {
clearTimeout(this.timer)
this.timer = setTimeout(() => {
const { authority, periodOfUse, options, accountNum, finalPrice } = row
if (!authority && periodOfUse && accountNum && finalPrice) {
row.finalValue = (finalPrice / accountNum / periodOfUse).toFixed(2)
}
// 折扣率
this.calcDiscount(row)
this.dealSettlePrice(row)
}, 500)
},
2 years ago
// 计算成交价。计算规则:成交单价*账号数*时间(成交单价为元/账号/年,所以时间要换算成年的单位去计算)
calcFinalPrice(row) {
clearTimeout(this.timer)
this.timer = setTimeout(() => {
const { finalValue, accountNum, periodOfUse, finalPrice } = row
if (periodOfUse) {
if (accountNum) {
// 有成交单价,则成交价=成交单价*账号数*时间
if (finalValue) {
row.finalPrice = Math.round(finalValue * periodOfUse * accountNum)
} else if (!finalValue && finalPrice) {
// 有成交价,没有成交单价,则成交单价=成交价/账号数/时间
row.finalValue = (finalPrice / periodOfUse / accountNum).toFixed(2)
this.calcDiscount(row)
}
} else if (finalValue && finalPrice && !row.authority) {
// 有成交价、成交单价,没有数量,则数量=成交价/时间/成交单价
row.accountNum = Math.floor(finalPrice / periodOfUse / finalValue)
}
}
this.dealSettlePrice(row)
}, 500)
},
1 year ago
// 结算价修改后计算平台服务费
updateServiceFee(row) {
options.serviceFee = (row.finalPrice * (this.rate / 100)).toFixed(2)
},
// 复制发货信息
1 year ago
copy(row) {
const that = this
uni.setClipboardData({
1 year ago
data: row.copyInfo,
success() {
1 year ago
that.$util.sucMsg('复制成功')
}
})
},
2 years ago
// 处理错误提示
handleErr(val) {
if (val === this.err) this.err = ''
},
// 消息推送授权
publicNotice() {
uni.requestSubscribeMessage({
tmplIds: ['8pDVfWYqh9c-nn3CeA1NXJtBxdd1FYiCtrl5BeLvbgU'],
success: (res) => {
uni.switchTab({
url: '/pages/orders/orders'
})
},
fail: function(err) {
uni.showToast({
title: err,
duration: 2000,
icon: 'error'
});
}
})
},
// 从购物车选择产品下单的,则提交订单后删除购物车相对应产品
async delShopCart(courses) {
const list = courses.filter(e => e.shopCartId)
list.length && await delCart(list.map(e => e.shopCartId))
},
3 years ago
// 提交
submit() {
3 years ago
const { form, courses } = this
2 years ago
if (!form.customerId) {
this.err = 'customerName'
return this.$util.errMsg('请选择客户!')
}
if (!form.orderType) {
this.err = 'orderType'
return this.$util.errMsg('请选择订单类型!')
}
if (!courses.length) return this.$util.errMsg('请选择课程后再确认订单!')
1 year ago
if (this.orderRepeat.length) return this.$util.errMsg(this.repeatMsg) // 有重复订单不能提交
3 years ago
courses.map(e => {
e.startTime = this.$util.formatDate(new Date(e.startTime), 'yyyy-MM-dd')
3 years ago
})
2 years ago
uni.showLoading({
title: '提交中'
})
3 years ago
const data = {
contractInformation: this.contract, // 合同信息
order: form, // 订单基本数据
3 years ago
orderOther: courses // 产品列表
}
if (this.orderId) {
update(data).then(res => {
2 years ago
uni.hideLoading()
3 years ago
this.$util.sucMsg('编辑成功')
setTimeout(() => {
uni.switchTab({
url: '/pages/orders/orders'
})
3 years ago
}, 1500)
2 years ago
}).catch(res => {
uni.hideLoading()
})
3 years ago
} else {
add(data).then(res => {
this.delShopCart(courses)
2 years ago
uni.hideLoading()
3 years ago
this.$util.sucMsg('添加成功')
this.publicNotice()
2 years ago
}).catch(res => {
uni.hideLoading()
})
3 years ago
}
}
3 years ago
}
}
</script>
<style scoped lang="scss">
3 years ago
.page {
2 years ago
padding-bottom: 420rpx;
3 years ago
}
.show {
2 years ago
padding-bottom: 280rpx;
}
.form-list {
.customer-wrap {
text-align: right;
}
1 year ago
}
.create {
padding: 0 20rpx;
font-size: 20rpx;
text-align: right;
color: #f00;
}
3 years ago
.pro-wrap {
position: relative;
padding: 0;
.l-title {
margin: 0 24rpx;
}
}
.arrow {
position: absolute;
top: 20rpx;
right: 30rpx;
3 years ago
}
.pro-list {
.name {
3 years ago
display: flex;
justify-content: space-between;
align-items: center;
padding: 14rpx 24rpx;
font-size: 30rpx;
color: #333;
background: linear-gradient(90deg, #FFF5E5 0%, #FFFFFF 100%);
}
1 year ago
.left {
display: inline-flex;
align-items: center;
max-width: 480rpx;
margin-right: 10rpx;
}
.course-action {
display: inline-flex;
align-items: center;
}
1 year ago
.course-btn {
padding: 0 16rpx;
font-size: 28rpx;
1 year ago
white-space: nowrap;
3 years ago
}
2 years ago
.del {
width: 40rpx;
1 year ago
margin-right: 20rpx;
2 years ago
}
3 years ago
.icon {
width: 60rpx;
height: 60rpx;
margin-right: 12rpx;
border-radius: 10rpx;
}
.info {
padding: 12rpx 24rpx;
3 years ago
}
.line {
display: flex;
3 years ago
justify-content: space-between;
1 year ago
padding: 28rpx 0;
3 years ago
font-size: 12px;
1 year ago
border-bottom: 1px solid #E6E8ED;
&:last-child {
border-bottom: 0;
}
3 years ago
}
3 years ago
.label {
1 year ago
margin-right: 20rpx;
1 year ago
font-size: 28rpx;
1 year ago
white-space: nowrap;
1 year ago
color: #333;
}
.ph {
3 years ago
font-size: 28rpx;
color: #999;
1 year ago
&.ship-info {
text-align: right;
}
3 years ago
}
.val {
font-size: 28rpx;
color: #333;
}
3 years ago
.done {
3 years ago
margin-top: 12rpx;
padding-top: 24rpx;
3 years ago
font-size: 13px;
color: #333;
3 years ago
border-top: 1px solid #E6E8ED;
3 years ago
}
3 years ago
.price {
font-size: 32rpx;
color: #007EFF;
}
1 year ago
.period {
flex: none;
width: 100rpx;
font-size: 28rpx;
text-align: center;
}
3 years ago
}
3 years ago
.bottom {
1 year ago
z-index: 2;
3 years ago
position: fixed;
2 years ago
bottom: 0;
padding-bottom: env(safe-area-inset-bottom);
3 years ago
width: 100%;
2 years ago
background-color: #fff;
2 years ago
box-shadow: 0 -2px 2px #f5f5f5;
2 years ago
box-sizing: border-box;
1 year ago
.add-wrap {
padding: 16rpx 24rpx 40rpx;
background-color: #f5f5f5;
}
.next-wrap {
padding: 24rpx 24rpx 0;
3 years ago
}
1 year ago
/deep/.lg-btn {
display: flex;
justify-content: center;
align-items: center;
font-size: 28rpx;
line-height: 88rpx;
color: #007EFF;
background-color: #fff;
border: 1px solid #007EFF;
border-radius: 16rpx;
.icon {
margin-right: 10rpx;
}
.uni-icons {
font-size: 38rpx !important;
}
&.next {
color: #fff;
background-color: #007EFF;
}
3 years ago
}
}
.product {
3 years ago
display: flex;
2 years ago
justify-content: space-between;
3 years ago
align-items: center;
3 years ago
padding: 24rpx;
3 years ago
background-color: #fff;
.total {
2 years ago
white-space: nowrap;
}
2 years ago
.line {
&:first-child {
margin-bottom: 8px;
}
}
2 years ago
&.show {
padding: 24rpx 50rpx;
.total {
2 years ago
display: flex;
2 years ago
margin-bottom: 30rpx;
font-size: 30rpx;
font-weight: 600;
color: #333;
2 years ago
.column {
margin-left: 10rpx;
}
2 years ago
.num {
2 years ago
margin: 0 5rpx;
font-size: 34rpx;
font-weight: 600;
2 years ago
color: #007EFF;
}
}
}
&.edit {
.total {
margin-bottom: 10rpx;
2 years ago
text-align: right;
2 years ago
font-size: 30rpx;
2 years ago
color: #666;
2 years ago
.num {
font-weight: 600;
2 years ago
font-size: 34rpx;
2 years ago
}
2 years ago
}
3 years ago
.num {
3 years ago
margin: 0 5rpx;
2 years ago
font-size: 30rpx;
3 years ago
color: #007EFF;
}
3 years ago
}
3 years ago
.info {
font-size: 24rpx;
color: #333;
2 years ago
white-space: nowrap;
3 years ago
}
.btn {
2 years ago
width: 180rpx;
2 years ago
margin-left: 30rpx;
3 years ago
line-height: 80rpx;
3 years ago
font-size: 32rpx;
3 years ago
text-align: center;
color: #fff;
border-radius: 10rpx;
background-color: #007EFF;
}
3 years ago
}
1 year ago
.unit {
display: inline-flex;
align-items: center;
.icon {
width: 28rpx;
margin-left: 20rpx;
}
input {
font-size: 28rpx;
}
text{
font-size: 28rpx;
}
}
.line {
.inline {
display: flex;
align-items: center;
font-size: 28rpx;
input {
text-align: right;
margin-right: 10rpx;
margin-left: 20rpx;
color: #333;
}
}
.edit {
margin-left: 10rpx;
}
}
3 years ago
</style>