|
@@ -126,17 +126,342 @@
|
|
|
</template>
|
|
|
<script>
|
|
|
import { permission } from '@/utils/directivePage'
|
|
|
+
|
|
|
export default {
|
|
|
props: ["subjectId"],
|
|
|
data() {
|
|
|
+ const query = this.$route.query
|
|
|
return {
|
|
|
- remark: "",
|
|
|
+ musicGroupId: query.id,
|
|
|
+ result: {}, // 返回结果
|
|
|
+ instrument: {}, // 乐器类型
|
|
|
+ baseInfo: {}, // 其它类
|
|
|
+ money: 580,
|
|
|
+ balance: 0, // 余额
|
|
|
+ needPrice: 0, // 还需支付
|
|
|
+ payType: false, // 是否余额支付
|
|
|
+ orderInfo: {
|
|
|
+ marketPrice: 0,
|
|
|
+ amount: 0, // 现价总金额
|
|
|
+ groupPurchasePrice: 0, // 现价
|
|
|
+ goodsGroupIds: null,
|
|
|
+ goodsIds: null,
|
|
|
+ contractGoodsIds: null, // 选中所有商品ID
|
|
|
+ couponPrice: 0, //
|
|
|
+ musicClassFee: 0
|
|
|
+ }, // 金额列表,金额计算
|
|
|
+ courseInfo: null, // 课程信息
|
|
|
+ courseScheduleStatus: false, // 课程状态
|
|
|
+ musicGroupSubject: null, // 基本信息
|
|
|
+ instrumentResult: [], //乐器
|
|
|
+ accessOries: [], // 辅件(打包)
|
|
|
+ agreeStatus: true,
|
|
|
+ authStatus: false,
|
|
|
+ buyList: [], // 信息列表
|
|
|
+ ids: [],
|
|
|
+ chargeTypeId: null,
|
|
|
+ paymentStatus: null,
|
|
|
+ paymentPattern: null,
|
|
|
};
|
|
|
},
|
|
|
methods: {
|
|
|
-
|
|
|
+ async __init() {
|
|
|
+ // 获取数据
|
|
|
+ await getSubjectGoodsAndInfo(params).then(res => {
|
|
|
+ let result = res.data
|
|
|
+ if (result.code == 200) {
|
|
|
+ let tempResult = result.data
|
|
|
+ this.paymentPattern = tempResult.musicGroupPaymentCalender ? tempResult.musicGroupPaymentCalender.paymentPattern : 2
|
|
|
+ let tempInfo = tempResult.musicGroupPaymentCalender? tempResult.musicGroupPaymentCalender.musicGroupPaymentCalenderCourseSettingsList : null
|
|
|
+ // 判断是否有课程
|
|
|
+ if (tempInfo && tempInfo.length > 0) {
|
|
|
+ // 默认课程都选中
|
|
|
+ this.courseInfo = tempInfo
|
|
|
+ } else {
|
|
|
+ // 判断是否有课程,如果没有课程则默认显示0
|
|
|
+ this.courseInfo = [{
|
|
|
+ id: -1,
|
|
|
+ courseCurrentPrice: 0,
|
|
|
+ courseOriginalPrice: 0,
|
|
|
+ isStudentOptional: false,
|
|
|
+ courseType: 'MUSIC'
|
|
|
+ }]
|
|
|
+ }
|
|
|
+ this.courseInfo.forEach(item => {
|
|
|
+ item.isStatus = true
|
|
|
+ })
|
|
|
+
|
|
|
+ this.musicGroupSubject = tempResult.musicGroupSubjectPlan
|
|
|
+ let instrumentInfo = {}
|
|
|
+ tempResult.musicGroupSubjectGoodsGroupList.forEach((item) => {
|
|
|
+ if (item.type == "INSTRUMENT") {
|
|
|
+ // 获取乐器所有提供方式
|
|
|
+ let KGPTJ = item.kitGroupPurchaseTypeJson ? JSON.parse(item.kitGroupPurchaseTypeJson) : {}
|
|
|
+ for (let single in KGPTJ) {
|
|
|
+ let tempItem = Object.assign({}, item) // 深拷贝
|
|
|
+ tempItem.marketPrice = tempItem.goodsList[0].marketPrice
|
|
|
+ tempItem.kitType = single // 优惠模式
|
|
|
+ tempItem.coupon = KGPTJ[single] // 优惠金额
|
|
|
+ if (instrumentInfo.id) {
|
|
|
+ tempItem.checked = false
|
|
|
+ if (single == 'GROUP') { // 团购
|
|
|
+ if ((instrumentInfo.kitType == 'GROUP' && instrumentInfo.price < tempItem.price) || instrumentInfo.kitType ==
|
|
|
+ 'LEASE' || instrumentInfo.kitType == 'FREE') {
|
|
|
+ this.instrumentResult.forEach(instrRes => {
|
|
|
+ instrRes.checked = false
|
|
|
+ })
|
|
|
+ tempItem.checked = true
|
|
|
+ instrumentInfo = {
|
|
|
+ id: tempItem.id,
|
|
|
+ price: tempItem.price,
|
|
|
+ kitType: single
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (single == 'LEASE') { // 租赁
|
|
|
+ if (instrumentInfo.kitType == 'LEASE' && instrumentInfo.price < tempItem.price) {
|
|
|
+ this.instrumentResult.forEach(instrRes => {
|
|
|
+ instrRes.checked = false
|
|
|
+ })
|
|
|
+ tempItem.checked = true
|
|
|
+ instrumentInfo = {
|
|
|
+ id: tempItem.id,
|
|
|
+ price: tempItem.price,
|
|
|
+ kitType: single
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (single == 'FREE') { // 免费
|
|
|
+ if (instrumentInfo.kitType == 'FREE' && instrumentInfo.price < tempItem.price) {
|
|
|
+ this.instrumentResult.forEach(instrRes => {
|
|
|
+ instrRes.checked = false
|
|
|
+ })
|
|
|
+ tempItem.checked = true
|
|
|
+ instrumentInfo = {
|
|
|
+ id: tempItem.id,
|
|
|
+ price: tempItem.price,
|
|
|
+ kitType: single
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tempItem.checked = true
|
|
|
+ instrumentInfo = {
|
|
|
+ id: tempItem.id,
|
|
|
+ price: tempItem.price,
|
|
|
+ kitType: single
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.instrumentResult.push(tempItem)
|
|
|
+ }
|
|
|
+ } else if (item.type == "ACCESSORIES") {
|
|
|
+ item.checked = true
|
|
|
+ this.accessOries.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 添加自备选项
|
|
|
+ if (this.instrumentResult.length > 0) {
|
|
|
+ this.instrumentResult.push({
|
|
|
+ id: -1,
|
|
|
+ kitType: 'owned',
|
|
|
+ name: '自备',
|
|
|
+ price: 0,
|
|
|
+ marketPrice: 0,
|
|
|
+ checked: false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 初始化计算金额
|
|
|
+ this.calcPrice()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onCourseChange(item) {
|
|
|
+ // 判断用户是否可以选择
|
|
|
+ if (item.isStudentOptional) {
|
|
|
+ item.isStatus = !item.isStatus
|
|
|
+ this.calcPrice()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onClickCheckbox() { //是否使用余额支付
|
|
|
+ if (!this.payType) {
|
|
|
+ if (this.orderInfo.amount >= this.balance) {
|
|
|
+ this.needPrice = Number((this.orderInfo.amount - this.balance).toFixed(2))
|
|
|
+ } else {
|
|
|
+ this.needPrice = 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.needPrice = this.orderInfo.amount
|
|
|
+ }
|
|
|
+ this.payType = !this.payType
|
|
|
+ },
|
|
|
+ onAuxiliarie(item) {
|
|
|
+ // 辅件切换状态
|
|
|
+ item.checked = !item.checked
|
|
|
+ // 重新计算金额
|
|
|
+ this.calcPrice()
|
|
|
+ },
|
|
|
+ instrumentF(item) {
|
|
|
+ // 乐器切换状态
|
|
|
+ this.instrumentResult.forEach(item => {
|
|
|
+ item.checked = false
|
|
|
+ })
|
|
|
+ item.checked = true
|
|
|
+ // 重新计算金额
|
|
|
+ this.calcPrice()
|
|
|
+ },
|
|
|
+ calcPrice() {
|
|
|
+ let buyList = [],
|
|
|
+ ids = []
|
|
|
+ let amount = 0,
|
|
|
+ marketPrice = 0,
|
|
|
+ goodsGroupIds = {},
|
|
|
+ courseKeys = [],
|
|
|
+ couponPrice = 0, // 优惠金额
|
|
|
+ goodsIds = [],
|
|
|
+ tempCourseFee = 0,
|
|
|
+ musicClassFee = 0,
|
|
|
+ contractGoodsIds = '' // 合同所需要的商品Id (只需要乐器编号)
|
|
|
+ // 课程
|
|
|
+ let mgs = this.musicGroupSubject
|
|
|
+ let csi = this.courseInfo
|
|
|
+ // 加上判断是否有课程信息
|
|
|
+ if (mgs) {
|
|
|
+ csi.forEach(item => {
|
|
|
+ if (item.isStatus) {
|
|
|
+ musicClassFee += parseFloat(item.courseCurrentPrice)
|
|
|
+ marketPrice += parseFloat(item.courseOriginalPrice)
|
|
|
+ if (item.id > 0) {
|
|
|
+ courseKeys.push(item.id)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ // 乐器
|
|
|
+ let ir = this.instrumentResult
|
|
|
+ if (ir.length > 0) {
|
|
|
+ ir.forEach(item => {
|
|
|
+ if (item.checked) {
|
|
|
+ if (item.name != '自备') {
|
|
|
+ contractGoodsIds += item.goodsIdList
|
|
|
+ }
|
|
|
+ if (item.kitType == 'FREE') {
|
|
|
+ amount += 0
|
|
|
+ couponPrice = 0 // 优惠金额
|
|
|
+ } else if (item.kitType == 'LEASE') {
|
|
|
+ couponPrice = item.coupon // 优惠金额
|
|
|
+ if (item.name != '自备') {
|
|
|
+ amount += item.depositFee
|
|
|
+ } else {
|
|
|
+ amount += 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ amount += parseFloat(item.price)
|
|
|
+ couponPrice = item.coupon ? item.coupon : 0
|
|
|
+ }
|
|
|
+ if (item.kitType == 'LEASE') {
|
|
|
+ if (item.name != '自备') {
|
|
|
+ marketPrice += item.depositFee
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ marketPrice += parseFloat(item.marketPrice)
|
|
|
+ }
|
|
|
+ // item.id ? goodsGroupIds[item.id] : null
|
|
|
+ if (item.id) {
|
|
|
+ goodsGroupIds[item.id] = item.kitType
|
|
|
+ }
|
|
|
+ if (item.kitType == 'LEASE') {
|
|
|
+ buyList.push({
|
|
|
+ name: item.name,
|
|
|
+ type: '租赁',
|
|
|
+ price: item.depositFee
|
|
|
+ })
|
|
|
+ } else if (item.kitType == 'GROUP' && parseFloat(item.price - couponPrice) > 0) {
|
|
|
+ buyList.push({
|
|
|
+ name: item.name,
|
|
|
+ type: '团购',
|
|
|
+ price: parseFloat(item.price - couponPrice)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ amount += parseFloat(tempCourseFee + musicClassFee)
|
|
|
+ if (!this.courseScheduleStatus) {
|
|
|
+ marketPrice += parseFloat(musicClassFee)
|
|
|
+ }
|
|
|
+ if (parseFloat(tempCourseFee + musicClassFee) > 0) {
|
|
|
+ buyList.unshift({
|
|
|
+ name: '乐团课',
|
|
|
+ type: paymentPatternType[this.paymentPattern],
|
|
|
+ price: Number((tempCourseFee + musicClassFee).toFixed(2))
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 辅件
|
|
|
+ if (this.accessOries.length > 0) {
|
|
|
+ let tempAccessPrice = 0
|
|
|
+ this.accessOries.forEach(item => {
|
|
|
+ if (item.checked) {
|
|
|
+ tempAccessPrice += parseFloat(item.price)
|
|
|
+ amount += parseFloat(item.price)
|
|
|
+ if (item.goodsList && item.goodsList.length > 0) {
|
|
|
+ item.goodsList.forEach(childGoods => {
|
|
|
+ marketPrice += parseFloat(childGoods.marketPrice)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ goodsGroupIds[item.id] = 'ACCESSORIES'
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (tempAccessPrice > 0) {
|
|
|
+ buyList.push({
|
|
|
+ name: '辅件',
|
|
|
+ type: '团购',
|
|
|
+ price: tempAccessPrice
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // console.log(amount)
|
|
|
+ let tempGroupPurchasePrice = amount
|
|
|
+ // 判断减去优惠金额,是否大于0(这里有可能出现负数)
|
|
|
+ if (amount - couponPrice >= 0) {
|
|
|
+ amount = Number((amount - couponPrice).toFixed(2))
|
|
|
+ this.errorPrice = false
|
|
|
+ } else {
|
|
|
+ amount = 0
|
|
|
+ this.errorPrice = true // 订单金额是否异常
|
|
|
+ }
|
|
|
+
|
|
|
+ if (amount - tempCourseFee - musicClassFee > 0) {
|
|
|
+ ids.push(1, 2)
|
|
|
+ }
|
|
|
+ if (parseFloat(tempCourseFee + musicClassFee) > 0) {
|
|
|
+ ids.push(3, 4, 5)
|
|
|
+ }
|
|
|
+ this.ids = ids
|
|
|
+ // 计算是否使用过余额
|
|
|
+ if (this.payType) {
|
|
|
+ let tempPrice = Number((amount - this.balance).toFixed(2))
|
|
|
+ if (tempPrice > 0) {
|
|
|
+ this.needPrice = tempPrice
|
|
|
+ } else {
|
|
|
+ this.needPrice = 0
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ this.needPrice = Number(amount.toFixed(2))
|
|
|
+ }
|
|
|
+ this.buyList = buyList
|
|
|
+ this.orderInfo = {
|
|
|
+ amount: Number(amount.toFixed(2)),
|
|
|
+ marketPrice: Number(marketPrice.toFixed(2)),
|
|
|
+ groupPurchasePrice: tempGroupPurchasePrice,
|
|
|
+ couponPrice: couponPrice,
|
|
|
+ goodsGroupIds: goodsGroupIds,
|
|
|
+ goodsIds: goodsIds.join(','),
|
|
|
+ contractGoodsIds: contractGoodsIds,
|
|
|
+ courseKeys: courseKeys,
|
|
|
+ musicClassFee: musicClassFee
|
|
|
+ }
|
|
|
+ },
|
|
|
permission(str){
|
|
|
- return permission(str)
|
|
|
+ return permission(str)
|
|
|
}
|
|
|
},
|
|
|
};
|