|
|
@ -8,7 +8,7 @@ |
|
|
|
<view v-for="(item, i) in c.list"> |
|
|
|
<view v-for="(item, i) in c.list"> |
|
|
|
<view class="pro-name"> |
|
|
|
<view class="pro-name"> |
|
|
|
<view class="left"> |
|
|
|
<view class="left"> |
|
|
|
<image v-if="item.miniProgramPictureAddress" class="icon" :src="item.miniProgramPictureAddress" mode="widthFix"></image> |
|
|
|
<image class="icon" :src="$util.getIcon(item)" mode="widthFix"></image> |
|
|
|
{{ item.productName }} |
|
|
|
{{ item.productName }} |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<uni-icons class="del" type="trash" size="25" color="#ADADAD" @click="delCourse(c, i)"></uni-icons> |
|
|
|
<uni-icons class="del" type="trash" size="25" color="#ADADAD" @click="delCourse(c, i)"></uni-icons> |
|
|
@ -18,18 +18,15 @@ |
|
|
|
<view class="name">产品类型</view> |
|
|
|
<view class="name">产品类型</view> |
|
|
|
<view class="val">{{ productTypes.find(e => e.id === item.productType).name }}</view> |
|
|
|
<view class="val">{{ productTypes.find(e => e.id === item.productType).name }}</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="line req"> |
|
|
|
<view :class="['line req', {err: err === 'periodOfUse' + item.dataOrCourseId + item.authority}]"> |
|
|
|
<view class="name">使用期限</view> |
|
|
|
<view class="name">使用期限</view> |
|
|
|
<input class="period" type="number" v-model="item.periodOfUse" placeholder="请输入" @input="calcDate(item, !item.authority)"> |
|
|
|
<input class="period" type="number" v-model="item.periodOfUse" placeholder="请输入" @input="calcDate(item, !item.authority)" @change="handleErr(item, 'periodOfUse')"> |
|
|
|
<view class="val unit" @click="showUnit(i)"> |
|
|
|
<view class="val unit" @click="selectUnit(item)"> |
|
|
|
<text>{{ units.find(e => e.value === item.options).text }}</text> |
|
|
|
<text>{{ units.find(e => e.id === item.options).text }}</text> |
|
|
|
<image class="icon" src="@/static/image/arrow-down.png" mode="widthFix"></image> |
|
|
|
<image class="icon" src="@/static/image/arrow-down.png" mode="widthFix"></image> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<uni-data-picker class="unit-picker" ref="unit" popup-title="请选择" :clear-icon="false" :localdata="units" v-model="item.options" @change="calcDate(item)"> |
|
|
|
|
|
|
|
<text></text> |
|
|
|
|
|
|
|
</uni-data-picker> |
|
|
|
|
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="line req"> |
|
|
|
<view :class="['line req', {err: err === 'startTime' + item.dataOrCourseId + item.authority}]"> |
|
|
|
<view class="name">起止日期</view> |
|
|
|
<view class="name">起止日期</view> |
|
|
|
<uni-datetime-picker type="date" v-model="item.startTime" :border="false" @change="calcDate(item)"> |
|
|
|
<uni-datetime-picker type="date" v-model="item.startTime" :border="false" @change="calcDate(item)"> |
|
|
|
<view :class="['ph', {val: item.startTime}]"> |
|
|
|
<view :class="['ph', {val: item.startTime}]"> |
|
|
@ -37,10 +34,10 @@ |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</uni-datetime-picker> |
|
|
|
</uni-datetime-picker> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="line req"> |
|
|
|
<view :class="['line req', {err: err === 'accountNum' + item.dataOrCourseId + item.authority}]"> |
|
|
|
<view class="name">数量</view> |
|
|
|
<view class="name">数量</view> |
|
|
|
<view v-if="item.authority" class="val">1</view> |
|
|
|
<view v-if="item.authority" class="val">1</view> |
|
|
|
<input v-else type="number" v-model="item.accountNum" placeholder="请输入" @input="calcFinalPrice(item)"> |
|
|
|
<input v-else type="number" v-model="item.accountNum" placeholder="请输入账号数量" @input="calcFinalPrice(item)" @change="handleErr(item, 'accountNum')"> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="line"> |
|
|
|
<view class="line"> |
|
|
|
<view class="name">{{ item.authority ? '市场价' : '市场单价' }}</view> |
|
|
|
<view class="name">{{ item.authority ? '市场价' : '市场单价' }}</view> |
|
|
@ -58,10 +55,10 @@ |
|
|
|
<view class="name">平台服务费</view> |
|
|
|
<view class="name">平台服务费</view> |
|
|
|
<view class="val">{{ item.serviceFee }}元</view> |
|
|
|
<view class="val">{{ item.serviceFee }}元</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="line req"> |
|
|
|
<view :class="['line req', {err: err === 'finalPrice' + item.dataOrCourseId + item.authority}]"> |
|
|
|
<view class="name">成交价</view> |
|
|
|
<view class="name">成交价</view> |
|
|
|
<view class="inline"> |
|
|
|
<view class="inline"> |
|
|
|
<input type="number" v-model="item.finalPrice" placeholder="请输入" @input="calcFinalValue(item)"> |
|
|
|
<input type="number" v-model="item.finalPrice" placeholder="请输入" @input="calcFinalValue(item)" @change="handleErr(item, 'finalPrice')"> |
|
|
|
元 |
|
|
|
元 |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
@ -85,14 +82,15 @@ |
|
|
|
timer: null, |
|
|
|
timer: null, |
|
|
|
units: [{ |
|
|
|
units: [{ |
|
|
|
text: '日', |
|
|
|
text: '日', |
|
|
|
value: 0 |
|
|
|
id: 0 |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
text: '月', |
|
|
|
text: '月', |
|
|
|
value: 1 |
|
|
|
id: 1 |
|
|
|
}, { |
|
|
|
}, { |
|
|
|
text: '年', |
|
|
|
text: '年', |
|
|
|
value: 2 |
|
|
|
id: 2 |
|
|
|
}], |
|
|
|
}], |
|
|
|
|
|
|
|
unitText: ['日', '月', '年'], |
|
|
|
productTypes: [ |
|
|
|
productTypes: [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
name: '实训课程', |
|
|
|
name: '实训课程', |
|
|
@ -109,7 +107,8 @@ |
|
|
|
], |
|
|
|
], |
|
|
|
courses: {} , // 上一页缓存的产品 |
|
|
|
courses: {} , // 上一页缓存的产品 |
|
|
|
orderRepeat: [], |
|
|
|
orderRepeat: [], |
|
|
|
repeatMsg: '' |
|
|
|
repeatMsg: '', |
|
|
|
|
|
|
|
err: '' |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
onShow() { |
|
|
|
onShow() { |
|
|
@ -154,6 +153,16 @@ |
|
|
|
uni.removeStorageSync('courses') |
|
|
|
uni.removeStorageSync('courses') |
|
|
|
} catch (e) {} |
|
|
|
} catch (e) {} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
selectUnit(item) { |
|
|
|
|
|
|
|
const that = this |
|
|
|
|
|
|
|
uni.showActionSheet({ |
|
|
|
|
|
|
|
title: '标题', |
|
|
|
|
|
|
|
itemList: that.unitText, |
|
|
|
|
|
|
|
success: ({ tapIndex }) => { |
|
|
|
|
|
|
|
item.options = tapIndex |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, |
|
|
|
showUnit(i) { |
|
|
|
showUnit(i) { |
|
|
|
this.$refs.unit[i].show() |
|
|
|
this.$refs.unit[i].show() |
|
|
|
}, |
|
|
|
}, |
|
|
@ -233,43 +242,35 @@ |
|
|
|
}, |
|
|
|
}, |
|
|
|
// 计算结算价及平台服务费 |
|
|
|
// 计算结算价及平台服务费 |
|
|
|
dealSettlePrice(row) { |
|
|
|
dealSettlePrice(row) { |
|
|
|
console.log(33, row) |
|
|
|
const unit = row.options // 使用期限单位 |
|
|
|
clearTimeout(this.timer) |
|
|
|
const useUnit = row.periodOfUse // 使用期限 |
|
|
|
this.timer = setTimeout(() => { |
|
|
|
let sPrice = '' |
|
|
|
const unit = row.options // 使用期限单位 |
|
|
|
if (row.settlementMethod == 0) { |
|
|
|
const useUnit = row.periodOfUse // 使用期限 |
|
|
|
// 结算单价。计算规则:结算单价(**元/年)*购买时长(单位年)*数量(课程为1,数据为账号数量) |
|
|
|
let sPrice = '' |
|
|
|
const priceUnit = row.settlementPriceUnit |
|
|
|
if (row.settlementMethod == 0) { |
|
|
|
sPrice = ((!unit ? |
|
|
|
// 结算单价。计算规则:结算单价(**元/年)*购买时长(单位年)*数量(课程为1,数据为账号数量) |
|
|
|
priceUnit / 365 * useUnit : |
|
|
|
const priceUnit = row.settlementPriceUnit |
|
|
|
unit === 1 ? |
|
|
|
sPrice = ((!unit ? |
|
|
|
priceUnit / 12 * useUnit : |
|
|
|
priceUnit / 365 * useUnit : |
|
|
|
priceUnit * useUnit) * (row.authority ? |
|
|
|
unit === 1 ? |
|
|
|
1 : |
|
|
|
priceUnit / 12 * useUnit : |
|
|
|
row.accountNum)).toFixed((2)) |
|
|
|
priceUnit * useUnit) * (row.authority ? |
|
|
|
} else { |
|
|
|
1 : |
|
|
|
// 比例分成。计算规则:成交价*商务分成比例 |
|
|
|
row.accountNum)).toFixed((2)) |
|
|
|
sPrice = (row.finalPrice * row.businessProportion / 100).toFixed((2)) |
|
|
|
} else { |
|
|
|
} |
|
|
|
// 比例分成。计算规则:成交价*商务分成比例 |
|
|
|
row.settlementPrice = this.$util.handleNaN(sPrice) |
|
|
|
sPrice = (row.finalPrice * row.businessProportion / 100).toFixed((2)) |
|
|
|
// 平台服务费(结算价*10%) |
|
|
|
} |
|
|
|
if (row.settlementPrice) { |
|
|
|
row.settlementPrice = this.$util.handleNaN(sPrice) |
|
|
|
row.serviceFee = (row.settlementPrice * 0.1).toFixed(2) |
|
|
|
// 平台服务费(结算价*10%) |
|
|
|
} |
|
|
|
if (row.settlementPrice) { |
|
|
|
|
|
|
|
row.serviceFee = (row.settlementPrice * 0.1).toFixed(2) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, 500) |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
// 计算折扣率 |
|
|
|
// 计算折扣率 |
|
|
|
calcDiscount(row) { |
|
|
|
calcDiscount(row) { |
|
|
|
clearTimeout(this.timer) |
|
|
|
const price = row.authority ? row.finalPrice : row.finalValue |
|
|
|
this.timer = setTimeout(() => { |
|
|
|
const { marketValue } = row |
|
|
|
const price = row.authority ? row.finalPrice : row.finalValue |
|
|
|
// (原价-现价)÷原价 x100% |
|
|
|
const { marketValue } = row |
|
|
|
if (price) row.discountRate = marketValue != 0 ? ((marketValue - price) / marketValue * 100).toFixed(2) + '%' : '0%' |
|
|
|
console.log(66, row) |
|
|
|
|
|
|
|
// (原价-现价)÷原价 x100% |
|
|
|
|
|
|
|
if (price) row.discountRate = marketValue != 0 ? ((marketValue - price) / marketValue * 100).toFixed(2) + '%' : '0%' |
|
|
|
|
|
|
|
}, 500) |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
// 成交价修改后,计算成交单价,数据才需要 计算规则:成交价/账号数/时间(成交单价为元/账号/年,所以时间要换算成年的单位去计算) |
|
|
|
// 成交价修改后,计算成交单价,数据才需要 计算规则:成交价/账号数/时间(成交单价为元/账号/年,所以时间要换算成年的单位去计算) |
|
|
|
calcFinalValue(row) { |
|
|
|
calcFinalValue(row) { |
|
|
@ -297,9 +298,9 @@ |
|
|
|
} else if (!finalValue && finalPrice) { |
|
|
|
} else if (!finalValue && finalPrice) { |
|
|
|
// 有成交价,没有成交单价,则成交单价=成交价/账号数/时间 |
|
|
|
// 有成交价,没有成交单价,则成交单价=成交价/账号数/时间 |
|
|
|
row.finalValue = (finalPrice / periodOfUse / accountNum).toFixed(2) |
|
|
|
row.finalValue = (finalPrice / periodOfUse / accountNum).toFixed(2) |
|
|
|
this.calculateDiscount(e, row) |
|
|
|
this.calcDiscount(row) |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (finalValue && finalValue && !row.authority) { |
|
|
|
} else if (finalValue && finalPrice && !row.authority) { |
|
|
|
// 有成交价、成交单价,没有数量,则数量=成交价/时间/成交单价 |
|
|
|
// 有成交价、成交单价,没有数量,则数量=成交价/时间/成交单价 |
|
|
|
row.accountNum = Math.floor(finalPrice / periodOfUse / finalValue) |
|
|
|
row.accountNum = Math.floor(finalPrice / periodOfUse / finalValue) |
|
|
|
} |
|
|
|
} |
|
|
@ -307,6 +308,10 @@ |
|
|
|
this.dealSettlePrice(row) |
|
|
|
this.dealSettlePrice(row) |
|
|
|
}, 500) |
|
|
|
}, 500) |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
// 处理错误提示 |
|
|
|
|
|
|
|
handleErr(e, val) { |
|
|
|
|
|
|
|
if (val + e.dataOrCourseId + e.authority === this.err) this.err = '' |
|
|
|
|
|
|
|
}, |
|
|
|
// 确定 |
|
|
|
// 确定 |
|
|
|
submit() { |
|
|
|
submit() { |
|
|
|
const courses = this.courses |
|
|
|
const courses = this.courses |
|
|
@ -316,26 +321,33 @@ |
|
|
|
for (const i in courses) { |
|
|
|
for (const i in courses) { |
|
|
|
list.push(...courses[i].list) |
|
|
|
list.push(...courses[i].list) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
console.log(11, list) |
|
|
|
// 必填校验 |
|
|
|
// 必填校验 |
|
|
|
for (const i in list) { |
|
|
|
for (const i in list) { |
|
|
|
const e = list[i] |
|
|
|
const e = list[i] |
|
|
|
|
|
|
|
const suf = e.dataOrCourseId + '' + e.authority |
|
|
|
if (e.periodOfUse === '') { |
|
|
|
if (e.periodOfUse === '') { |
|
|
|
|
|
|
|
this.err = 'periodOfUse' + suf |
|
|
|
msg = '请输入使用期限!' |
|
|
|
msg = '请输入使用期限!' |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
if (!e.startTime) { |
|
|
|
if (!e.startTime) { |
|
|
|
|
|
|
|
this.err = 'startTime' + suf |
|
|
|
msg = '请选择起止日期!' |
|
|
|
msg = '请选择起止日期!' |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
if (e.accountNum === '') { |
|
|
|
if (e.accountNum === '') { |
|
|
|
|
|
|
|
this.err = 'accountNum' + suf |
|
|
|
msg = '请输入数量!' |
|
|
|
msg = '请输入数量!' |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
if (e.finalPrice === '') { |
|
|
|
if (e.finalPrice === '') { |
|
|
|
|
|
|
|
this.err = 'finalPrice' + suf |
|
|
|
msg = '请输入成交价!' |
|
|
|
msg = '请输入成交价!' |
|
|
|
break |
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
console.log(33, this.err) |
|
|
|
if (msg) return this.$util.errMsg(msg) |
|
|
|
if (msg) return this.$util.errMsg(msg) |
|
|
|
if (this.orderRepeat.length) return this.$util.errMsg(this.repeatMsg) // 有重复订单不能提交 |
|
|
|
if (this.orderRepeat.length) return this.$util.errMsg(this.repeatMsg) // 有重复订单不能提交 |
|
|
|
uni.setStorageSync('courses', this.courses) |
|
|
|
uni.setStorageSync('courses', this.courses) |
|
|
|