添加订单续费功能

master
yujialong 5 months ago
parent c5d0dbc3b0
commit 960bd8ec5c
  1. 16
      apis/request.js
  2. 180
      order/orderDetail/orderDetail.vue

@ -1,17 +1,7 @@
import config from '@/config/request' import config from '@/config/request'
let HTTP_COUNT = 0 // loading次数
let logouted = 0 let logouted = 0
const request = options => { const request = options => {
HTTP_COUNT++
if (config.showLoading) {
// 请求数据时的loading
// uni.showToast({
// title: '加载中',
// duration: 200,
// icon: 'loading'
// })
}
const header = Object.assign({}, config.headers, { const header = Object.assign({}, config.headers, {
token: uni.getStorageSync('token') token: uni.getStorageSync('token')
}) })
@ -65,12 +55,6 @@ const request = options => {
}) })
reject(err) reject(err)
}, },
complete: () => {
if (config.showLoading) {
// HTTP_COUNT--
// HTTP_COUNT || uni.hideLoading()
}
}
}) })
}) })
} }

@ -170,6 +170,13 @@
</template> </template>
</view> </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-mask" v-show="customerVisible" @click="closeCustomer"></view>
<view class="popup" v-show="customerVisible"> <view class="popup" v-show="customerVisible">
<view class="top">请选择客户</view> <view class="top">请选择客户</view>
@ -186,12 +193,13 @@
<script> <script>
import { productCategoryList, delCart } from '@/apis/modules/product.js' import { productCategoryList, delCart } from '@/apis/modules/product.js'
import { queryCustomer, queryCustomerDetails } from '@/apis/modules/client.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' import { getPartnerTeamRates } from '@/apis/modules/parner.js'
export default { export default {
data() { data() {
return { return {
isDetail: false, isDetail: false,
isRenew: 0, //
orderId: '', orderId: '',
edited: false, edited: false,
shopCart: false, shopCart: false,
@ -239,6 +247,7 @@
customerList: [], customerList: [],
customerListAll: [], customerListAll: [],
err: '', err: '',
promises: [],
rate: '', rate: '',
orderRepeat:[], orderRepeat:[],
units: [{ units: [{
@ -267,6 +276,8 @@
const { options } = pages[pages.length - 1] const { options } = pages[pages.length - 1]
this.orderId = options.orderId this.orderId = options.orderId
this.isDetail = !!options.show this.isDetail = !!options.show
const { action } = options
this.isRenew = action === 'renew'
this.edited = options.edited // this.edited = options.edited //
this.shopCart = options.shopCart // this.shopCart = options.shopCart //
const store = uni.getStorageSync('courses') const store = uni.getStorageSync('courses')
@ -332,11 +343,20 @@
orderId: this.orderId orderId: this.orderId
}).then(({ orderDetails }) => { }).then(({ orderDetails }) => {
const order = orderDetails const order = orderDetails
this.contract = order.contractInformation if (!this.isRenew) this.contract = order.contractInformation //
this.form = order.order this.form = order.order
order.orderOther.forEach(e => {
e.settlementPriceUnit = e.settlementPrice
})
this.courses = order.orderOther this.courses = order.orderOther
this.handleProduct(order.orderOther) for (let i = 0; i < 5; i++) {
uni.hideLoading() this.handleRenew(i)
}
Promise.all(this.promises).then(_ => {
this.handleProduct(this.courses)
this.calcTotal()
uni.hideLoading()
})
}).catch(e => { }).catch(e => {
uni.hideLoading() uni.hideLoading()
}) })
@ -369,6 +389,54 @@
this.courseList = courses this.courseList = courses
}).catch(e => {}) }).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: 23
item.status = now < startTime ?
1 :
now > startTime && now < endTime ?
2 :
3
if (item.status === 3) item.isEnable = 0 //
})
resolve()
}).catch(e => {
reject()
})
}))
},
// //
getCustomer() { getCustomer() {
queryCustomer({ queryCustomer({
@ -682,10 +750,6 @@
this.dealSettlePrice(row) this.dealSettlePrice(row)
}, 500) }, 500)
}, },
//
updateServiceFee(row) {
options.serviceFee = (row.finalPrice * (this.rate / 100)).toFixed(2)
},
// //
copy(row) { copy(row) {
const that = this const that = this
@ -700,6 +764,11 @@
handleErr(val) { handleErr(val) {
if (val === this.err) this.err = '' if (val === this.err) this.err = ''
}, },
toAction(url) {
uni.redirectTo({
url
})
},
// //
publicNotice() { publicNotice() {
uni.requestSubscribeMessage({ uni.requestSubscribeMessage({
@ -725,7 +794,8 @@
}, },
// //
submit() { submit() {
const { form, courses } = this const { form } = this
const courses = []
if (!form.customerId) { if (!form.customerId) {
this.err = 'customerName' this.err = 'customerName'
return this.$util.errMsg('请选择客户!') return this.$util.errMsg('请选择客户!')
@ -734,11 +804,20 @@
this.err = 'orderType' this.err = 'orderType'
return this.$util.errMsg('请选择订单类型!') return this.$util.errMsg('请选择订单类型!')
} }
if (!courses.length) return this.$util.errMsg('请选择课程后再确认订单!') for (const i in this.courseList) {
if (this.orderRepeat.length) return this.$util.errMsg(this.repeatMsg) // courses.push(...this.courseList[i].list)
courses.map(e => { }
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') 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({ uni.showLoading({
title: '提交中' title: '提交中'
}) })
@ -747,39 +826,26 @@
order: form, // order: form, //
orderOther: courses // orderOther: courses //
} }
if (this.orderId) { //
update(data).then(res => { add(data).then(res => {
uni.hideLoading() this.delShopCart(courses)
this.$util.sucMsg('编辑成功') uni.hideLoading()
setTimeout(() => { this.$util.sucMsg('添加成功')
uni.switchTab({
url: '/pages/orders/orders' // #ifdef MP-WEIXIN
}) this.publicNotice()
}, 1500) // #endif
}).catch(res => {
uni.hideLoading() // #ifdef MP-TOUTIAO
}) setTimeout(() => {
} else { uni.switchTab({
add(data).then(res => { url: '/pages/orders/orders'
this.delShopCart(courses) })
uni.hideLoading() }, 1500)
this.$util.sucMsg('添加成功') // #endif
}).catch(res => {
// #ifdef MP-WEIXIN uni.hideLoading()
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; 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> </style>

Loading…
Cancel
Save