diff --git a/apis/request.js b/apis/request.js index a4f1063..b42f7bb 100644 --- a/apis/request.js +++ b/apis/request.js @@ -19,7 +19,7 @@ const request = options => { const { url } = options uni.request({ header, - url: (otherUrl.find(e => url.includes(e)) ? 'http://192.168.31.137:9000/' : config.baseURL) + url, + url: (otherUrl.find(e => url.includes(e)) ? 'http://192.168.31.151:9000/' : config.baseURL) + url, method: options.method || 'GET', // 请求类型,默认为GET data: options.data || {}, // 请求参数,默认空对象 success: ({ data }) => { diff --git a/config/product.js b/config/product.js index ea2a564..206e21d 100644 --- a/config/product.js +++ b/config/product.js @@ -5,5 +5,6 @@ */ export default { - normalIcon: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/20220609/png/1534733700683030528.png' // 通用图标 + normalIcon: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/20220609/png/1534733700683030528.png', // 通用图标 + dataIcon: 'https://huoran.oss-cn-shenzhen.aliyuncs.com/20220627/png/1541256164447641600.png' // 数据图标 } diff --git a/config/request.js b/config/request.js index c3aa89f..24cd55b 100644 --- a/config/request.js +++ b/config/request.js @@ -5,7 +5,7 @@ */ export default { - baseURL: 'http://192.168.31.137:9000/', + baseURL: 'http://192.168.31.151:9000/', headers: { 'Content-Type': 'application/json;charset=UTF-8' }, diff --git a/libs/util.js b/libs/util.js index 2fdba01..9ba6d34 100644 --- a/libs/util.js +++ b/libs/util.js @@ -1,6 +1,8 @@ +import Product from '@/config/product' + const files = [ - 'https://huoran.oss-cn-shenzhen.aliyuncs.com/20220530/docx/1531155187057057792.docx', - 'https://huoran.oss-cn-shenzhen.aliyuncs.com/20220530/docx/1531156166884220928.docx', + 'https://huoran.oss-cn-shenzhen.aliyuncs.com/20220530/docx/1531155187057057792.docx', // 用户服务协议 + 'https://huoran.oss-cn-shenzhen.aliyuncs.com/20220530/docx/1531156166884220928.docx', // 用户隐私协议 'https://huoran.oss-cn-shenzhen.aliyuncs.com/20220601/docx/1531930503312596992.docx', // 人工智能 'https://huoran.oss-cn-shenzhen.aliyuncs.com/20220601/docx/1531930756791164928.docx', // 大数据 'https://huoran.oss-cn-shenzhen.aliyuncs.com/20220601/docx/1531929864150999040.docx', // 金融科技 @@ -65,6 +67,10 @@ export default { getBmName(val) { return uni.getStorageSync('team').partnerClassificationName }, + // 返回图标。如果有图标,则直接返回,否则判断是否是数据产品,即productType=2,如果是,则取数据图标,否则则显示通用图标,这两个图标都在config/product.js里有配置 + getIcon(e) { + return e.miniProgramPictureAddress || (e.productType === 2 ? Product.dataIcon : Product.normalIcon) + }, // 预览文档 openFile(id) { uni.showLoading({ diff --git a/order/addCourse/addCourse.vue b/order/addCourse/addCourse.vue index 6e94c0f..e534a2f 100644 --- a/order/addCourse/addCourse.vue +++ b/order/addCourse/addCourse.vue @@ -11,7 +11,7 @@ @@ -186,6 +186,7 @@ marketValue: '', // 市场价 marketPrice: e.marketPrice, // 市场单价 finalPrice: trial ? 0 : '', // 成交价 + finalValue: trial ? 0 : '', // 成交单价(数据产品特有) discountRate: trial ? '0%' : '', // 折扣率 accountNum: e.productType === 2 ? '' : 1, // 账号数 totalAmount: '', // 总价 diff --git a/order/editCourse/editCourse.vue b/order/editCourse/editCourse.vue index 47eb894..cb13d64 100644 --- a/order/editCourse/editCourse.vue +++ b/order/editCourse/editCourse.vue @@ -8,7 +8,7 @@ - + {{ item.productName }} @@ -18,18 +18,15 @@ 产品类型 {{ productTypes.find(e => e.id === item.productType).name }} - + 使用期限 - - - {{ units.find(e => e.value === item.options).text }} + + + {{ units.find(e => e.id === item.options).text }} - - - - + 起止日期 @@ -37,10 +34,10 @@ - + 数量 1 - + {{ item.authority ? '市场价' : '市场单价' }} @@ -58,10 +55,10 @@ 平台服务费 {{ item.serviceFee }}元 - + 成交价 - + @@ -85,14 +82,15 @@ timer: null, units: [{ text: '日', - value: 0 + id: 0 }, { text: '月', - value: 1 + id: 1 }, { text: '年', - value: 2 + id: 2 }], + unitText: ['日', '月', '年'], productTypes: [ { name: '实训课程', @@ -109,7 +107,8 @@ ], courses: {} , // 上一页缓存的产品 orderRepeat: [], - repeatMsg: '' + repeatMsg: '', + err: '' } }, onShow() { @@ -154,6 +153,16 @@ uni.removeStorageSync('courses') } catch (e) {} }, + selectUnit(item) { + const that = this + uni.showActionSheet({ + title: '标题', + itemList: that.unitText, + success: ({ tapIndex }) => { + item.options = tapIndex + } + }) + }, showUnit(i) { this.$refs.unit[i].show() }, @@ -233,43 +242,35 @@ }, // 计算结算价及平台服务费 dealSettlePrice(row) { - console.log(33, row) - clearTimeout(this.timer) - this.timer = setTimeout(() => { - const unit = row.options // 使用期限单位 - const useUnit = row.periodOfUse // 使用期限 - let sPrice = '' - if (row.settlementMethod == 0) { - // 结算单价。计算规则:结算单价(**元/年)*购买时长(单位年)*数量(课程为1,数据为账号数量) - const priceUnit = row.settlementPriceUnit - sPrice = ((!unit ? - priceUnit / 365 * useUnit : - unit === 1 ? - priceUnit / 12 * useUnit : - priceUnit * useUnit) * (row.authority ? - 1 : - row.accountNum)).toFixed((2)) - } else { - // 比例分成。计算规则:成交价*商务分成比例 - sPrice = (row.finalPrice * row.businessProportion / 100).toFixed((2)) - } - row.settlementPrice = this.$util.handleNaN(sPrice) - // 平台服务费(结算价*10%) - if (row.settlementPrice) { - row.serviceFee = (row.settlementPrice * 0.1).toFixed(2) - } - }, 500) + const unit = row.options // 使用期限单位 + const useUnit = row.periodOfUse // 使用期限 + let sPrice = '' + if (row.settlementMethod == 0) { + // 结算单价。计算规则:结算单价(**元/年)*购买时长(单位年)*数量(课程为1,数据为账号数量) + const priceUnit = row.settlementPriceUnit + sPrice = ((!unit ? + priceUnit / 365 * useUnit : + unit === 1 ? + priceUnit / 12 * useUnit : + priceUnit * useUnit) * (row.authority ? + 1 : + row.accountNum)).toFixed((2)) + } else { + // 比例分成。计算规则:成交价*商务分成比例 + sPrice = (row.finalPrice * row.businessProportion / 100).toFixed((2)) + } + row.settlementPrice = this.$util.handleNaN(sPrice) + // 平台服务费(结算价*10%) + if (row.settlementPrice) { + row.serviceFee = (row.settlementPrice * 0.1).toFixed(2) + } }, // 计算折扣率 calcDiscount(row) { - clearTimeout(this.timer) - this.timer = setTimeout(() => { - const price = row.authority ? row.finalPrice : row.finalValue - const { marketValue } = row - console.log(66, row) - // (原价-现价)÷原价 x100% - if (price) row.discountRate = marketValue != 0 ? ((marketValue - price) / marketValue * 100).toFixed(2) + '%' : '0%' - }, 500) + const price = row.authority ? row.finalPrice : row.finalValue + const { marketValue } = row + // (原价-现价)÷原价 x100% + if (price) row.discountRate = marketValue != 0 ? ((marketValue - price) / marketValue * 100).toFixed(2) + '%' : '0%' }, // 成交价修改后,计算成交单价,数据才需要 计算规则:成交价/账号数/时间(成交单价为元/账号/年,所以时间要换算成年的单位去计算) calcFinalValue(row) { @@ -297,9 +298,9 @@ } else if (!finalValue && finalPrice) { // 有成交价,没有成交单价,则成交单价=成交价/账号数/时间 row.finalValue = (finalPrice / periodOfUse / accountNum).toFixed(2) - this.calculateDiscount(e, row) + this.calcDiscount(row) } - } else if (finalValue && finalValue && !row.authority) { + } else if (finalValue && finalPrice && !row.authority) { // 有成交价、成交单价,没有数量,则数量=成交价/时间/成交单价 row.accountNum = Math.floor(finalPrice / periodOfUse / finalValue) } @@ -307,6 +308,10 @@ this.dealSettlePrice(row) }, 500) }, + // 处理错误提示 + handleErr(e, val) { + if (val + e.dataOrCourseId + e.authority === this.err) this.err = '' + }, // 确定 submit() { const courses = this.courses @@ -316,26 +321,33 @@ for (const i in courses) { list.push(...courses[i].list) } + console.log(11, list) // 必填校验 for (const i in list) { const e = list[i] + const suf = e.dataOrCourseId + '' + e.authority if (e.periodOfUse === '') { + this.err = 'periodOfUse' + suf msg = '请输入使用期限!' break } if (!e.startTime) { + this.err = 'startTime' + suf msg = '请选择起止日期!' break } if (e.accountNum === '') { + this.err = 'accountNum' + suf msg = '请输入数量!' break } if (e.finalPrice === '') { + this.err = 'finalPrice' + suf msg = '请输入成交价!' break } } + console.log(33, this.err) if (msg) return this.$util.errMsg(msg) if (this.orderRepeat.length) return this.$util.errMsg(this.repeatMsg) // 有重复订单不能提交 uni.setStorageSync('courses', this.courses) diff --git a/order/orderDetail/orderDetail.vue b/order/orderDetail/orderDetail.vue index 0194905..a53cda5 100644 --- a/order/orderDetail/orderDetail.vue +++ b/order/orderDetail/orderDetail.vue @@ -5,9 +5,9 @@ 商务经理 - {{ userName }} + {{ form.businessManagerName }} - + 客户名称 {{ form.customerName }} {{ form.customerName || '请选择客户' }} @@ -32,9 +32,9 @@ 邮箱 {{ form.email }} - + 订单类型 - {{ form.industryClassName }} + {{ orderTypes.find(e => e.value === form.orderType).text }} @@ -60,7 +60,7 @@
  • - + {{ item.productName }} @@ -142,7 +142,6 @@ data() { return { isDetail: false, - userName: uni.getStorageSync('team').userName, orderId: '', orderTypes: [{ text: '正式', @@ -152,6 +151,7 @@ value: 2 }], form: { + businessManagerName: uni.getStorageSync('team').userName, // orderNumber: '', // 编号 provinceId: '', // 省份id provinceName: '', @@ -186,6 +186,7 @@ searchTimer: null, customerList: [], customerListAll: [], + err: '' } }, onShow() { @@ -312,6 +313,7 @@ queryCustomerDetails({ customerId: item.customerId }).then(({ result }) => { + this.handleErr('customerName') const e = result.customer form.customerId = e.customerId form.customerName = e.customerName @@ -368,6 +370,7 @@ }, // 计算订单总额 calcTotal() { + this.handleErr('orderType') const { form } = this const isTrial = form.orderType === 2 // 是否试用 let total = 0 @@ -394,15 +397,28 @@ form.profit = isTrial ? 0 : Math.round(profit) form.orderAmount = isTrial ? 0 : +form.purchaseCost + +form.profit }, + // 处理错误提示 + handleErr(val) { + if (val === this.err) this.err = '' + }, // 提交 submit() { const { form, courses } = this - if (!form.customerId) return this.$util.errMsg('请选择客户!') - if (!form.orderType) return this.$util.errMsg('请选择订单类型!') + if (!form.customerId) { + this.err = 'customerName' + return this.$util.errMsg('请选择客户!') + } + if (!form.orderType) { + this.err = 'orderType' + return this.$util.errMsg('请选择订单类型!') + } if (!courses.length) return this.$util.errMsg('请选择课程权限或数据权限后再确认订单!') courses.map(e => { e.startTime = this.$util.formatDate(new Date(e.startTime), 'yyyy-MM-dd') }) + uni.showLoading({ + title: '提交中' + }) const data = { contractInformation: this.contract, // 合同信息 order: form, // 订单基本数据 @@ -410,18 +426,24 @@ } if (this.orderId) { update(data).then(res => { + uni.hideLoading() this.$util.sucMsg('编辑成功') setTimeout(() => { uni.navigateBack() }, 1500) - }).catch(res => {}) + }).catch(res => { + uni.hideLoading() + }) } else { add(data).then(res => { + uni.hideLoading() this.$util.sucMsg('添加成功') setTimeout(() => { uni.navigateBack() }, 1500) - }).catch(res => {}) + }).catch(res => { + uni.hideLoading() + }) } } } @@ -430,10 +452,10 @@