|
|
|
@ -60,8 +60,15 @@ |
|
|
|
|
<view id="products"> |
|
|
|
|
<template v-for="c in courseList"> |
|
|
|
|
<view v-if="c.list.length" class="block pro-wrap"> |
|
|
|
|
<view class="l-title">{{ c.name }}</view> |
|
|
|
|
<uni-icons class="arrow" type="top" size="20" color="#007EFF" @click="toggle(c)"></uni-icons> |
|
|
|
|
<view class="type-wrap"> |
|
|
|
|
<view class="l-title">{{ c.name }}</view> |
|
|
|
|
<view v-if="!isDetail" class="batch"> |
|
|
|
|
<input class="deadline" type="number" v-model="c.deadline" placeholder="批量输入" @change="batchDeadlineChange(c)"> |
|
|
|
|
<view class="unit" @click="batchUnitChange(c)">{{ units.find(e => e.id === c.unit).text }}</view> |
|
|
|
|
</view> |
|
|
|
|
<uni-icons class="arrow" type="top" size="20" color="#007EFF" @click="toggle(c)"></uni-icons> |
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
<ul class="pro-list" v-show="!c.shrink"> |
|
|
|
|
<li v-for="(item, i) in c.list"> |
|
|
|
|
<view class="name"> |
|
|
|
@ -77,7 +84,7 @@ |
|
|
|
|
<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)"> |
|
|
|
|
<uni-datetime-picker v-else type="date" v-model="item.startTime" :border="false" @change="dateChange(item)"> |
|
|
|
|
<view :class="['ph', {val: item.startTime}]"> |
|
|
|
|
{{ item.endTime ? item.startTime + ' - ' + item.endTime : item.startTime}} |
|
|
|
|
</view> |
|
|
|
@ -87,7 +94,7 @@ |
|
|
|
|
<view class="label">使用期限</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')"> |
|
|
|
|
<input class="period" type="number" v-model="item.periodOfUse" placeholder="请输入" @input="dateChange(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> |
|
|
|
@ -193,7 +200,7 @@ |
|
|
|
|
<script> |
|
|
|
|
import { productCategoryList, delCart } from '@/apis/modules/product.js' |
|
|
|
|
import { queryCustomer, queryCustomerDetails } from '@/apis/modules/client.js' |
|
|
|
|
import { add, update, getDetail, renew, queryCitySettlementPrice, getOrderOtherTime } from '@/apis/modules/order.js' |
|
|
|
|
import { add, getDetail, renew, queryCitySettlementPrice, getOrderOtherTime } from '@/apis/modules/order.js' |
|
|
|
|
import { getPartnerTeamRates } from '@/apis/modules/parner.js' |
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
@ -370,9 +377,12 @@ |
|
|
|
|
courses['list' + this.$util.getOrderType(e.classificationId)] = { |
|
|
|
|
shrink: false, |
|
|
|
|
name: e.classificationName, |
|
|
|
|
deadline: '', |
|
|
|
|
unit: 2, |
|
|
|
|
list: [] |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
const isTrial = this.form.orderType == 2 |
|
|
|
|
// 3个分类的课程分别push到不同数组(0->理论 1-实训 2 数据产品) |
|
|
|
|
list.map(e => { |
|
|
|
|
// 发货信息处理 |
|
|
|
@ -384,6 +394,13 @@ |
|
|
|
|
e.copyInfo = e.shipContent || val.join(';') |
|
|
|
|
|
|
|
|
|
e.serviceFee = (e.finalPrice * (this.rate / 100)).toFixed(2) // 服务费 != 0 && 才需要算 |
|
|
|
|
|
|
|
|
|
// 试用则默认赋值1月 |
|
|
|
|
if (isTrial) { |
|
|
|
|
e.periodOfUse = 1 |
|
|
|
|
e.options = 1 |
|
|
|
|
this.calcDate(e, !e.authority) |
|
|
|
|
} |
|
|
|
|
courses['list' + e.authority].list.push(e) |
|
|
|
|
}) |
|
|
|
|
this.courseList = courses |
|
|
|
@ -610,68 +627,72 @@ |
|
|
|
|
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) { |
|
|
|
|
// 使用期限输入回调 |
|
|
|
|
dateChange(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({ |
|
|
|
|
authority: row.authority, |
|
|
|
|
customerId: this.form.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) |
|
|
|
|
this.calcDate(row, fromData) |
|
|
|
|
}, 500) |
|
|
|
|
}, |
|
|
|
|
// 使用期限转换以及计算剩余天数 |
|
|
|
|
calcDate(row, fromData) { |
|
|
|
|
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({ |
|
|
|
|
authority: row.authority, |
|
|
|
|
customerId: this.form.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) |
|
|
|
|
}, |
|
|
|
|
dealSettlePrice(row) { |
|
|
|
|
// 如果是试用或者没选择,结算价和平台服务费都是0 |
|
|
|
|
if (this.form.orderType != 1) { |
|
|
|
@ -694,7 +715,6 @@ |
|
|
|
|
// 平台服务费 |
|
|
|
|
row.serviceFee = (row.finalPrice * (this.rate / 100)).toFixed(2) |
|
|
|
|
this.calcAmount() |
|
|
|
|
console.log('row.settlementPrice =>' ,row.settlementPrice,row.settlementPriceUnit,sPrice,row) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
calcDiscount(row) { |
|
|
|
@ -703,6 +723,29 @@ |
|
|
|
|
// (原价-现价)÷原价 x100% |
|
|
|
|
if (price) row.discountRate = marketValue != 0 ? ((marketValue - price) / marketValue * 100).toFixed(2) + '%' : '0%' |
|
|
|
|
}, |
|
|
|
|
// 批量设置产品时间 |
|
|
|
|
batchDeadlineChange (c) { |
|
|
|
|
c.list.map(e => { |
|
|
|
|
e.periodOfUse = c.deadline |
|
|
|
|
this.calcDate(e, !e.authority) |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 批量设置产品期限单位 |
|
|
|
|
batchUnitChange(c) { |
|
|
|
|
const that = this |
|
|
|
|
uni.showActionSheet({ |
|
|
|
|
title: '标题', |
|
|
|
|
itemList: that.unitText, |
|
|
|
|
success: ({ tapIndex }) => { |
|
|
|
|
c.unit = tapIndex |
|
|
|
|
c.list.map(e => { |
|
|
|
|
e.options = tapIndex |
|
|
|
|
that.calcDate(e, !e.authority) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 单个产品选择年月日 |
|
|
|
|
selectUnit(item) { |
|
|
|
|
const that = this |
|
|
|
|
uni.showActionSheet({ |
|
|
|
@ -854,6 +897,27 @@ |
|
|
|
|
<style scoped lang="scss"> |
|
|
|
|
.page { |
|
|
|
|
padding-bottom: 420rpx; |
|
|
|
|
|
|
|
|
|
.type-wrap { |
|
|
|
|
display: flex; |
|
|
|
|
justify-content: space-between; |
|
|
|
|
align-items: center; |
|
|
|
|
} |
|
|
|
|
.batch { |
|
|
|
|
display: inline-flex; |
|
|
|
|
align-items: center; |
|
|
|
|
.deadline, .unit { |
|
|
|
|
font-size: 28rpx; |
|
|
|
|
color: #333; |
|
|
|
|
} |
|
|
|
|
.deadline { |
|
|
|
|
width: 130rpx; |
|
|
|
|
} |
|
|
|
|
.unit { |
|
|
|
|
min-width: 80rpx; |
|
|
|
|
text-align: center; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.show { |
|
|
|
|
padding-bottom: 280rpx; |
|
|
|
@ -876,11 +940,6 @@ |
|
|
|
|
margin: 0 24rpx; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.arrow { |
|
|
|
|
position: absolute; |
|
|
|
|
top: 20rpx; |
|
|
|
|
right: 30rpx; |
|
|
|
|
} |
|
|
|
|
.pro-list { |
|
|
|
|
.name { |
|
|
|
|
display: flex; |
|
|
|
|