|
|
|
@ -170,6 +170,13 @@ |
|
|
|
|
</template> |
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
<view v-if="isDetail && form.isDel !== 1 && form.orderStatus === 1" class="action"> |
|
|
|
|
<view class="item" @click="toAction(`../orderDetail/orderDetail?orderId=${orderId}&action=renew`)"> |
|
|
|
|
<uni-icons class="icon" custom-prefix="iconfont" type="icon-product" size="30" color="#959595"></uni-icons> |
|
|
|
|
<view class="text">续费</view> |
|
|
|
|
</view> |
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
<view class="popup-mask" v-show="customerVisible" @click="closeCustomer"></view> |
|
|
|
|
<view class="popup" v-show="customerVisible"> |
|
|
|
|
<view class="top">请选择客户</view> |
|
|
|
@ -186,12 +193,13 @@ |
|
|
|
|
<script> |
|
|
|
|
import { productCategoryList, delCart } from '@/apis/modules/product.js' |
|
|
|
|
import { queryCustomer, queryCustomerDetails } from '@/apis/modules/client.js' |
|
|
|
|
import { add, update, getDetail, queryCitySettlementPrice, getOrderOtherTime } from '@/apis/modules/order.js' |
|
|
|
|
import { add, update, getDetail, renew, queryCitySettlementPrice, getOrderOtherTime } from '@/apis/modules/order.js' |
|
|
|
|
import { getPartnerTeamRates } from '@/apis/modules/parner.js' |
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
isDetail: false, |
|
|
|
|
isRenew: 0, // 续费 |
|
|
|
|
orderId: '', |
|
|
|
|
edited: false, |
|
|
|
|
shopCart: false, |
|
|
|
@ -239,6 +247,7 @@ |
|
|
|
|
customerList: [], |
|
|
|
|
customerListAll: [], |
|
|
|
|
err: '', |
|
|
|
|
promises: [], |
|
|
|
|
rate: '', |
|
|
|
|
orderRepeat:[], |
|
|
|
|
units: [{ |
|
|
|
@ -267,6 +276,8 @@ |
|
|
|
|
const { options } = pages[pages.length - 1] |
|
|
|
|
this.orderId = options.orderId |
|
|
|
|
this.isDetail = !!options.show |
|
|
|
|
const { action } = options |
|
|
|
|
this.isRenew = action === 'renew' |
|
|
|
|
this.edited = options.edited // 已经编辑过产品的标识 |
|
|
|
|
this.shopCart = options.shopCart // 从购物车进来的标识 |
|
|
|
|
const store = uni.getStorageSync('courses') |
|
|
|
@ -332,11 +343,20 @@ |
|
|
|
|
orderId: this.orderId |
|
|
|
|
}).then(({ orderDetails }) => { |
|
|
|
|
const order = orderDetails |
|
|
|
|
this.contract = order.contractInformation |
|
|
|
|
if (!this.isRenew) this.contract = order.contractInformation // 非续费才回显合同 |
|
|
|
|
this.form = order.order |
|
|
|
|
order.orderOther.forEach(e => { |
|
|
|
|
e.settlementPriceUnit = e.settlementPrice |
|
|
|
|
}) |
|
|
|
|
this.courses = order.orderOther |
|
|
|
|
this.handleProduct(order.orderOther) |
|
|
|
|
uni.hideLoading() |
|
|
|
|
for (let i = 0; i < 5; i++) { |
|
|
|
|
this.handleRenew(i) |
|
|
|
|
} |
|
|
|
|
Promise.all(this.promises).then(_ => { |
|
|
|
|
this.handleProduct(this.courses) |
|
|
|
|
this.calcTotal() |
|
|
|
|
uni.hideLoading() |
|
|
|
|
}) |
|
|
|
|
}).catch(e => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
}) |
|
|
|
@ -369,6 +389,54 @@ |
|
|
|
|
this.courseList = courses |
|
|
|
|
}).catch(e => {}) |
|
|
|
|
}, |
|
|
|
|
// 处理开始结束时间和订单状态(参考pc,订单模块不是本人开发的,所以也不懂这里逻辑) |
|
|
|
|
handleRenew(authority) { |
|
|
|
|
const list = this.courses.filter(e => e.authority == authority) |
|
|
|
|
const productId = list.map(e => e.mallId) |
|
|
|
|
productId.length && this.promises.push(new Promise((resolve, reject) => { |
|
|
|
|
renew({ |
|
|
|
|
authority, |
|
|
|
|
customerId: this.form.customerId, |
|
|
|
|
productId, |
|
|
|
|
}).then(({ orderOthers }) => { |
|
|
|
|
const { courses } = this |
|
|
|
|
const now = new Date() |
|
|
|
|
orderOthers.map(e => { |
|
|
|
|
// e.settlementPriceUnit = e.settlementPrice |
|
|
|
|
const item = courses.find(n => n.dataOrCourseId == e.dataOrCourseId && n.authority == authority && e.authority == authority) |
|
|
|
|
if (item) { |
|
|
|
|
if (this.isRenew) { // 续费 |
|
|
|
|
let date = new Date(e.endTime) |
|
|
|
|
if (now < date) { // 没过期,则返回的结束日期+1天作为开始时间 |
|
|
|
|
date = new Date(date.setDate(date.getDate() + 1)) |
|
|
|
|
item.startTime = this.$util.formatDate(date, 'yyyy-MM-dd') |
|
|
|
|
} else { // 过期了则当前日期作为开始时间 |
|
|
|
|
item.startTime = this.$util.formatDate(now, 'yyyy-MM-dd') |
|
|
|
|
} |
|
|
|
|
item.endTime = '' |
|
|
|
|
item.periodOfUse = '' |
|
|
|
|
item.marketValue = e.marketValue |
|
|
|
|
} else if (!this.isDetail) { // 如果不是查看 |
|
|
|
|
item.startTime = e.startTime.split(' ')[0] |
|
|
|
|
item.endTime = e.endTime ? e.endTime.split(' ')[0] : '' |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
const startTime = new Date(item.startTime) |
|
|
|
|
const endTime = new Date(item.endTime) |
|
|
|
|
// 1: 未生效,2:生效中,3:已过期 |
|
|
|
|
item.status = now < startTime ? |
|
|
|
|
1 : |
|
|
|
|
now > startTime && now < endTime ? |
|
|
|
|
2 : |
|
|
|
|
3 |
|
|
|
|
if (item.status === 3) item.isEnable = 0 // 已过期的,变成禁用状态,且不能启用 |
|
|
|
|
}) |
|
|
|
|
resolve() |
|
|
|
|
}).catch(e => { |
|
|
|
|
reject() |
|
|
|
|
}) |
|
|
|
|
})) |
|
|
|
|
}, |
|
|
|
|
// 获取客户列表 |
|
|
|
|
getCustomer() { |
|
|
|
|
queryCustomer({ |
|
|
|
@ -682,10 +750,6 @@ |
|
|
|
|
this.dealSettlePrice(row) |
|
|
|
|
}, 500) |
|
|
|
|
}, |
|
|
|
|
// 结算价修改后计算平台服务费 |
|
|
|
|
updateServiceFee(row) { |
|
|
|
|
options.serviceFee = (row.finalPrice * (this.rate / 100)).toFixed(2) |
|
|
|
|
}, |
|
|
|
|
// 复制发货信息 |
|
|
|
|
copy(row) { |
|
|
|
|
const that = this |
|
|
|
@ -700,6 +764,11 @@ |
|
|
|
|
handleErr(val) { |
|
|
|
|
if (val === this.err) this.err = '' |
|
|
|
|
}, |
|
|
|
|
toAction(url) { |
|
|
|
|
uni.redirectTo({ |
|
|
|
|
url |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
// 消息推送授权 |
|
|
|
|
publicNotice() { |
|
|
|
|
uni.requestSubscribeMessage({ |
|
|
|
@ -725,7 +794,8 @@ |
|
|
|
|
}, |
|
|
|
|
// 提交 |
|
|
|
|
submit() { |
|
|
|
|
const { form, courses } = this |
|
|
|
|
const { form } = this |
|
|
|
|
const courses = [] |
|
|
|
|
if (!form.customerId) { |
|
|
|
|
this.err = 'customerName' |
|
|
|
|
return this.$util.errMsg('请选择客户!') |
|
|
|
@ -734,11 +804,20 @@ |
|
|
|
|
this.err = 'orderType' |
|
|
|
|
return this.$util.errMsg('请选择订单类型!') |
|
|
|
|
} |
|
|
|
|
if (!courses.length) return this.$util.errMsg('请选择课程后再确认订单!') |
|
|
|
|
if (this.orderRepeat.length) return this.$util.errMsg(this.repeatMsg) // 有重复订单不能提交 |
|
|
|
|
courses.map(e => { |
|
|
|
|
for (const i in this.courseList) { |
|
|
|
|
courses.push(...this.courseList[i].list) |
|
|
|
|
} |
|
|
|
|
if (!courses.length) return this.$util.errMsg('请选择课程权限或数据权限后再确认订单!') |
|
|
|
|
let invalid = 0 |
|
|
|
|
courses.forEach(e => { |
|
|
|
|
if (!e.periodOfUse) { |
|
|
|
|
invalid = 1 |
|
|
|
|
return this.$util.errMsg('请输入使用期限!') |
|
|
|
|
} |
|
|
|
|
e.startTime = this.$util.formatDate(new Date(e.startTime), 'yyyy-MM-dd') |
|
|
|
|
}) |
|
|
|
|
if (invalid) return false |
|
|
|
|
if (this.isRenew || courses.some(e => e.renew)) form.orderNature = 2 |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '提交中' |
|
|
|
|
}) |
|
|
|
@ -747,39 +826,26 @@ |
|
|
|
|
order: form, // 订单基本数据 |
|
|
|
|
orderOther: courses // 产品列表 |
|
|
|
|
} |
|
|
|
|
if (this.orderId) { |
|
|
|
|
update(data).then(res => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
this.$util.sucMsg('编辑成功') |
|
|
|
|
setTimeout(() => { |
|
|
|
|
uni.switchTab({ |
|
|
|
|
url: '/pages/orders/orders' |
|
|
|
|
}) |
|
|
|
|
}, 1500) |
|
|
|
|
}).catch(res => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
add(data).then(res => { |
|
|
|
|
this.delShopCart(courses) |
|
|
|
|
uni.hideLoading() |
|
|
|
|
this.$util.sucMsg('添加成功') |
|
|
|
|
|
|
|
|
|
// #ifdef MP-WEIXIN |
|
|
|
|
this.publicNotice() |
|
|
|
|
// #endif |
|
|
|
|
|
|
|
|
|
// #ifdef MP-TOUTIAO |
|
|
|
|
setTimeout(() => { |
|
|
|
|
uni.switchTab({ |
|
|
|
|
url: '/pages/orders/orders' |
|
|
|
|
}) |
|
|
|
|
}, 1500) |
|
|
|
|
// #endif |
|
|
|
|
}).catch(res => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
// 职站商城只能新增订单跟续费订单,这两个动作都是调新增接口,只有发货跟编辑才是调编辑接口 |
|
|
|
|
add(data).then(res => { |
|
|
|
|
this.delShopCart(courses) |
|
|
|
|
uni.hideLoading() |
|
|
|
|
this.$util.sucMsg('添加成功') |
|
|
|
|
|
|
|
|
|
// #ifdef MP-WEIXIN |
|
|
|
|
this.publicNotice() |
|
|
|
|
// #endif |
|
|
|
|
|
|
|
|
|
// #ifdef MP-TOUTIAO |
|
|
|
|
setTimeout(() => { |
|
|
|
|
uni.switchTab({ |
|
|
|
|
url: '/pages/orders/orders' |
|
|
|
|
}) |
|
|
|
|
}, 1500) |
|
|
|
|
// #endif |
|
|
|
|
}).catch(res => { |
|
|
|
|
uni.hideLoading() |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -1032,4 +1098,28 @@ |
|
|
|
|
margin-left: 10rpx; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.action { |
|
|
|
|
z-index: 2; |
|
|
|
|
position: fixed; |
|
|
|
|
bottom: 0; |
|
|
|
|
display: flex; |
|
|
|
|
justify-content: space-around; |
|
|
|
|
width: 100%; |
|
|
|
|
padding: 5px 10px; |
|
|
|
|
padding-bottom: env(safe-area-inset-bottom); |
|
|
|
|
background-color: #fff; |
|
|
|
|
border-top: 1px solid #f3f3f3; |
|
|
|
|
box-shadow: 0 -2px 2px #f5f5f5; |
|
|
|
|
box-sizing: border-box; |
|
|
|
|
&:empty { |
|
|
|
|
padding: 0 !important; |
|
|
|
|
} |
|
|
|
|
.item { |
|
|
|
|
text-align: center; |
|
|
|
|
} |
|
|
|
|
.text { |
|
|
|
|
font-size: 10px; |
|
|
|
|
color: #959595; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
</style> |
|
|
|
|