|
|
|
@ -2,8 +2,15 @@ |
|
|
|
|
<view class="page"> |
|
|
|
|
<template v-for="c in courses"> |
|
|
|
|
<view v-if="c.list.length && c.list.filter(e => !e.edited).length" class="block"> |
|
|
|
|
<view class="type-wrap"> |
|
|
|
|
<view class="l-title">{{ c.name }}</view> |
|
|
|
|
<view 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> |
|
|
|
|
|
|
|
|
|
<view v-show="!c.shrink"> |
|
|
|
|
<template v-for="(item, i) in c.list"> |
|
|
|
|
<view v-if="!item.edited" :key="i"> |
|
|
|
@ -21,7 +28,7 @@ |
|
|
|
|
</view> |
|
|
|
|
<view :class="['line req', {err: err === 'periodOfUse' + item.dataOrCourseId + item.authority}]"> |
|
|
|
|
<view class="name">使用期限</view> |
|
|
|
|
<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> |
|
|
|
@ -29,7 +36,7 @@ |
|
|
|
|
</view> |
|
|
|
|
<view :class="['line req', {err: err === 'startTime' + item.dataOrCourseId + item.authority}]"> |
|
|
|
|
<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="dateChange(item)"> |
|
|
|
|
<view :class="['ph', {val: item.startTime}]"> |
|
|
|
|
{{ item.endTime ? item.startTime + ' - ' + item.endTime : item.startTime}} |
|
|
|
|
</view> |
|
|
|
@ -130,10 +137,13 @@ |
|
|
|
|
courses['list' + this.$util.getOrderType(e.classificationId)] = { |
|
|
|
|
shrink: false, |
|
|
|
|
name: e.classificationName, |
|
|
|
|
deadline: '', |
|
|
|
|
unit: 2, |
|
|
|
|
list: [] |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
const { provinceId, cityId } = this |
|
|
|
|
const isTrial = this.orderType == 2 |
|
|
|
|
list.map(async e => { |
|
|
|
|
// 查询产品管理设置的平台结算价 |
|
|
|
|
if (provinceId) { |
|
|
|
@ -146,20 +156,45 @@ |
|
|
|
|
customerId: this.customerId, |
|
|
|
|
productId: [e.mallId] |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const item = res.orderOthers |
|
|
|
|
if (item && item.length) { |
|
|
|
|
let date = new Date(item[0].endTime) |
|
|
|
|
date = new Date(date.setDate(date.getDate() + 1)) |
|
|
|
|
e.startTime = this.$util.formatDate(date, 'yyyy-MM-dd') |
|
|
|
|
} |
|
|
|
|
// 试用默认赋值1月后,需要计算结束日期 |
|
|
|
|
if (isTrial) { |
|
|
|
|
this.calcDate(e, !e.authority) |
|
|
|
|
} |
|
|
|
|
courses['list' + e.authority].list.push(e) |
|
|
|
|
}) |
|
|
|
|
this.courses = courses |
|
|
|
|
}).catch(e => {}) |
|
|
|
|
// try { |
|
|
|
|
// uni.removeStorageSync('courses') |
|
|
|
|
// } catch (e) {} |
|
|
|
|
}, |
|
|
|
|
// 批量设置产品时间 |
|
|
|
|
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({ |
|
|
|
@ -188,12 +223,15 @@ |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 使用期限转换以及计算剩余天数 |
|
|
|
|
calcDate(row, fromData) { |
|
|
|
|
console.log('row=>',row) |
|
|
|
|
console.log('fromData=>',fromData) |
|
|
|
|
// 使用期限输入回调 |
|
|
|
|
dateChange(row, fromData) { |
|
|
|
|
clearTimeout(this.timer) |
|
|
|
|
this.timer = setTimeout(() => { |
|
|
|
|
this.calcDate(row, fromData) |
|
|
|
|
}, 500) |
|
|
|
|
}, |
|
|
|
|
// 使用期限转换以及计算剩余天数 |
|
|
|
|
calcDate(row, fromData) { |
|
|
|
|
const { periodOfUse, options } = row |
|
|
|
|
let optionsData = 0 |
|
|
|
|
if (periodOfUse) { |
|
|
|
@ -207,7 +245,6 @@ |
|
|
|
|
} |
|
|
|
|
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 |
|
|
|
@ -249,12 +286,10 @@ |
|
|
|
|
} |
|
|
|
|
// 折扣率 |
|
|
|
|
this.calcDiscount(row) |
|
|
|
|
}, 500) |
|
|
|
|
}, |
|
|
|
|
// 计算结算价及平台服务费 |
|
|
|
|
dealSettlePrice(row) { |
|
|
|
|
// 如果是试用或者没选择,结算价和平台服务费都是0 |
|
|
|
|
console.log('dealSettlePrice=>', row, this.orderType) |
|
|
|
|
if (this.orderType != 1) { |
|
|
|
|
row.settlementPrice = 0 |
|
|
|
|
row.serviceFee = 0 |
|
|
|
@ -272,7 +307,6 @@ |
|
|
|
|
1 : |
|
|
|
|
row.accountNum)).toFixed((2)) |
|
|
|
|
row.settlementPrice = this.$util.handleNaN(sPrice) |
|
|
|
|
console.log('dealSettlePrice2=>', row, this.$util.handleNaN(sPrice)) |
|
|
|
|
// 平台服务费 |
|
|
|
|
if (row.settlementPrice) { |
|
|
|
|
row.serviceFee = (row.finalPrice * (this.rate / 100)).toFixed(2) |
|
|
|
@ -396,11 +430,27 @@ |
|
|
|
|
.l-title { |
|
|
|
|
margin: 0 24rpx; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.arrow { |
|
|
|
|
position: absolute; |
|
|
|
|
top: 30rpx; |
|
|
|
|
right: 30rpx; |
|
|
|
|
|
|
|
|
|
.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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.pro-name { |
|
|
|
|
display: flex; |
|
|
|
|