|
|
|
@ -60,7 +60,7 @@ |
|
|
|
|
<view class="l-title">{{ c.name }}</view> |
|
|
|
|
<uni-icons class="arrow" type="top" size="20" color="#007EFF" @click="toggle(c)"></uni-icons> |
|
|
|
|
<ul class="pro-list" v-show="!c.shrink"> |
|
|
|
|
<li v-for="(item, i) in c.list" @click.stop="editCourse(c, i)"> |
|
|
|
|
<li v-for="(item, i) in c.list"> |
|
|
|
|
<view class="name"> |
|
|
|
|
<view class="left"> |
|
|
|
|
<image class="icon" :src="$util.getIcon(item)" mode="widthFix"></image> |
|
|
|
@ -73,28 +73,59 @@ |
|
|
|
|
</view> |
|
|
|
|
<view class="info"> |
|
|
|
|
<view class="line"> |
|
|
|
|
<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> |
|
|
|
|
<view class="val">{{ item.startTime + (item.endTime ? ' - ' + item.endTime : '') }}</view> |
|
|
|
|
<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"> |
|
|
|
|
<view class="label">市场价(元)</view> |
|
|
|
|
<view class="val">{{ item.marketValue && item.marketValue + '元' }}</view> |
|
|
|
|
<view class="label">{{ item.authority ? '市场价' : '市场单价' }}</view> |
|
|
|
|
<view class="ph">{{ item.marketValue && item.marketValue + '元' }}</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="label">结算价</view> |
|
|
|
|
<view class="val">{{ item.settlementPrice && item.settlementPrice + '元' }}</view> |
|
|
|
|
<view v-if="isDetail" class="ph">{{ item.settlementPrice }}</view> |
|
|
|
|
<view class="inline" v-else> |
|
|
|
|
<input type="number" v-model="item.settlementPrice" placeholder="请输入" @change="handleErr(item, 'settlementPrice')" @input="updateServiceFee(item)"> |
|
|
|
|
元 |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="label">折扣率</view> |
|
|
|
|
<view class="val">{{ item.discountRate }}</view> |
|
|
|
|
<view class="ph">{{ item.discountRate }}</view> |
|
|
|
|
</view> |
|
|
|
|
<view class="line"> |
|
|
|
|
<view class="label">市场服务费</view> |
|
|
|
|
<view class="val">{{ item.serviceFee }}元</view> |
|
|
|
|
<view class="ph">{{ item.serviceFee }}元</view> |
|
|
|
|
</view> |
|
|
|
|
<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 class="line done"> |
|
|
|
|
<view class="val">成交价格</view> |
|
|
|
|
<view class="price">{{ item.finalPrice }}元</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
</li> |
|
|
|
@ -200,7 +231,19 @@ |
|
|
|
|
customerListAll: [], |
|
|
|
|
err: '', |
|
|
|
|
rate: '', |
|
|
|
|
shipInfo: '' |
|
|
|
|
shipInfo: '', |
|
|
|
|
orderRepeat:[], |
|
|
|
|
units: [{ |
|
|
|
|
text: '日', |
|
|
|
|
id: 0 |
|
|
|
|
}, { |
|
|
|
|
text: '月', |
|
|
|
|
id: 1 |
|
|
|
|
}, { |
|
|
|
|
text: '年', |
|
|
|
|
id: 2 |
|
|
|
|
}], |
|
|
|
|
unitText: ['日', '月', '年'], |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
watch: { |
|
|
|
@ -234,12 +277,6 @@ |
|
|
|
|
} |
|
|
|
|
this.courseList = store |
|
|
|
|
this.courses = list |
|
|
|
|
// this.$nextTick(() => { |
|
|
|
|
// uni.pageScrollTo({ |
|
|
|
|
// selector: '#products', |
|
|
|
|
// }) |
|
|
|
|
// }) |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
uni.removeStorageSync('courses') |
|
|
|
|
} catch (e) {} |
|
|
|
@ -459,7 +496,7 @@ |
|
|
|
|
} else { |
|
|
|
|
this.calcDiscount(e) |
|
|
|
|
this.dealSettlePrice(e) |
|
|
|
|
this.calcFinalPrice(e) |
|
|
|
|
// this.calcFinalPrice(e) |
|
|
|
|
const curPurchase = +e.settlementPrice + +e.serviceFee |
|
|
|
|
purchase += curPurchase |
|
|
|
|
profit += +e.finalPrice - curPurchase |
|
|
|
@ -469,15 +506,82 @@ |
|
|
|
|
form.profit = profit |
|
|
|
|
form.orderAmount = (+form.purchaseCost + +form.profit).toFixed(2) |
|
|
|
|
}, |
|
|
|
|
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%' |
|
|
|
|
// 计算订单总额 |
|
|
|
|
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({ |
|
|
|
|
customerId: this.customerId, |
|
|
|
|
id: cId, |
|
|
|
|
startTime: this.$util.formatDate(date, 'yyyy-MM-dd'), |
|
|
|
|
endTime: row.endTime |
|
|
|
|
}).then(res => { |
|
|
|
|
orderRepeat.includes(cId) && orderRepeat.splice(orderRepeat.findIndex(e => e === cId), 1) |
|
|
|
|
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) |
|
|
|
|
}, |
|
|
|
|
// 计算结算价及平台服务费 |
|
|
|
|
dealSettlePrice(row) { |
|
|
|
|
console.log('row==>',row) |
|
|
|
|
// 如果是试用或者没选择,结算价和平台服务费都是0 |
|
|
|
|
if (this.form.orderType != 1) { |
|
|
|
|
row.settlementPrice = 0 |
|
|
|
@ -485,9 +589,10 @@ |
|
|
|
|
} else { |
|
|
|
|
const unit = row.options // 使用期限单位 |
|
|
|
|
const useUnit = row.periodOfUse // 使用期限 |
|
|
|
|
let sPrice = '' |
|
|
|
|
// 结算单价。计算规则:结算单价(**元/年)*购买时长(单位年)*数量(课程为1,数据为账号数量) |
|
|
|
|
const priceUnit = row.settlementPriceUnit |
|
|
|
|
let sPrice = ((!unit ? |
|
|
|
|
sPrice = ((!unit ? |
|
|
|
|
priceUnit / 365 * useUnit : |
|
|
|
|
unit === 1 ? |
|
|
|
|
priceUnit / 12 * useUnit : |
|
|
|
@ -496,10 +601,40 @@ |
|
|
|
|
row.accountNum)).toFixed((2)) |
|
|
|
|
row.settlementPrice = this.$util.handleNaN(sPrice) |
|
|
|
|
// 平台服务费 |
|
|
|
|
if (row.settlementPrice) { |
|
|
|
|
row.serviceFee = (row.finalPrice * (this.rate / 100)).toFixed(2) |
|
|
|
|
this.calcAmount() |
|
|
|
|
console.log('row.settlementPrice =>' ,row.settlementPrice,row.settlementPriceUnit,sPrice,row) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
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) |
|
|
|
|
}, |
|
|
|
|
// 计算成交价。计算规则:成交单价*账号数*时间(成交单价为元/账号/年,所以时间要换算成年的单位去计算) |
|
|
|
|
calcFinalPrice(row) { |
|
|
|
@ -524,6 +659,10 @@ |
|
|
|
|
this.dealSettlePrice(row) |
|
|
|
|
}, 500) |
|
|
|
|
}, |
|
|
|
|
// 结算价修改后计算平台服务费 |
|
|
|
|
updateServiceFee(row) { |
|
|
|
|
options.serviceFee = (row.finalPrice * (this.rate / 100)).toFixed(2) |
|
|
|
|
}, |
|
|
|
|
// 显示发货信息 |
|
|
|
|
showShip(row) { |
|
|
|
|
let val = '' |
|
|
|
@ -661,21 +800,24 @@ |
|
|
|
|
color: #333; |
|
|
|
|
background: linear-gradient(90deg, #FFF5E5 0%, #FFFFFF 100%); |
|
|
|
|
} |
|
|
|
|
.left { |
|
|
|
|
display: inline-flex; |
|
|
|
|
align-items: center; |
|
|
|
|
max-width: 480rpx; |
|
|
|
|
margin-right: 10rpx; |
|
|
|
|
} |
|
|
|
|
.course-action { |
|
|
|
|
display: inline-flex; |
|
|
|
|
align-items: center; |
|
|
|
|
} |
|
|
|
|
.info-btn { |
|
|
|
|
.course-btn { |
|
|
|
|
padding: 0 16rpx; |
|
|
|
|
margin-left: 10rpx; |
|
|
|
|
margin-right: 10rpx; |
|
|
|
|
font-size: 28rpx; |
|
|
|
|
white-space: nowrap; |
|
|
|
|
&.mg { |
|
|
|
|
margin-left: 10rpx; |
|
|
|
|
} |
|
|
|
|
.left { |
|
|
|
|
display: inline-flex; |
|
|
|
|
align-items: center; |
|
|
|
|
max-width: 480rpx; |
|
|
|
|
margin-right: 10rpx; |
|
|
|
|
} |
|
|
|
|
.del { |
|
|
|
|
width: 40rpx; |
|
|
|
@ -697,6 +839,10 @@ |
|
|
|
|
font-size: 12px; |
|
|
|
|
} |
|
|
|
|
.label { |
|
|
|
|
font-size: 28rpx; |
|
|
|
|
color: #333; |
|
|
|
|
} |
|
|
|
|
.ph { |
|
|
|
|
font-size: 28rpx; |
|
|
|
|
color: #999; |
|
|
|
|
} |
|
|
|
@ -715,8 +861,15 @@ |
|
|
|
|
font-size: 32rpx; |
|
|
|
|
color: #007EFF; |
|
|
|
|
} |
|
|
|
|
.period { |
|
|
|
|
flex: none; |
|
|
|
|
width: 100rpx; |
|
|
|
|
font-size: 28rpx; |
|
|
|
|
text-align: center; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.bottom { |
|
|
|
|
z-index: 2; |
|
|
|
|
position: fixed; |
|
|
|
|
bottom: 0; |
|
|
|
|
padding-bottom: env(safe-area-inset-bottom); |
|
|
|
@ -812,6 +965,36 @@ |
|
|
|
|
background-color: #007EFF; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.ship-info { |
|
|
|
|
height: 400rpx; |
|
|
|
|
padding: 20rpx; |
|
|
|
|