From 8de4d1fa7a98cc0a7e7459d13165d0cfbd21ab92 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Thu, 2 Jun 2022 18:28:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=E3=80=81=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E3=80=81=E5=AE=A2=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apis/modules/user.js | 4 ++ apis/request.js | 5 +- libs/util.js | 10 ++- pages.json | 9 +++ pages/addCourse/addCourse.vue | 64 +++++++++++------- pages/clients/clients.vue | 2 +- pages/editCourse/editCourse.vue | 46 ++++++++----- pages/index/index.vue | 6 ++ pages/login/login.vue | 35 +++++++--- pages/main/main.vue | 97 ++++++++++++++++++++++++++++ pages/orderDetail/orderDetail.vue | 104 ++++++++++++++++-------------- pages/orders/orders.vue | 2 +- pages/plans/plans.vue | 13 ++-- 13 files changed, 287 insertions(+), 110 deletions(-) create mode 100644 pages/main/main.vue diff --git a/apis/modules/user.js b/apis/modules/user.js index d572a8d..b212ed2 100644 --- a/apis/modules/user.js +++ b/apis/modules/user.js @@ -3,4 +3,8 @@ const { get, post } = request export const login = (data) => { return get('users/users/user/weChatAppletCallback', data) +} + +export const userBinding = (data) => { + return post('users/users/user/userBinding', data) } \ No newline at end of file diff --git a/apis/request.js b/apis/request.js index 81c964d..779a4c6 100644 --- a/apis/request.js +++ b/apis/request.js @@ -12,13 +12,14 @@ const request = options => { }) } const header = Object.assign({}, config.headers, { - token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyIiwiaWF0IjoxNjU0MTM1MDg4LCJleHAiOjE2NTQxNzgyODgsImFjY291bnRJZCI6IjEifQ.wSb1OgO7vfJoRRNe9tHirTAiTd7vHQLsKFU58cQTe84' + // token: uni.getStorageSync('token') + token: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1c2VyIiwiaWF0IjoxNjU0MTYzMjI2LCJleHAiOjE2NTQyMDY0MjYsImFjY291bnRJZCI6IjQ1MiJ9.oqupeDUjOWMKjdj7p7TclcfnPbsZfqwra5QKxo2YqvU' }) return new Promise((resolve, reject)=>{ const { url } = options uni.request({ header, - url: (url.includes('weChatAppletCallback') ? 'http://192.168.31.137:9000/' : config.baseURL) + url, + url: ((url.includes('weChatAppletCallback') || url.includes('userBinding')) ? 'http://192.168.31.137:9000/' : config.baseURL) + url, method: options.method || 'GET', // 请求类型,默认为GET data: options.data || {}, // 请求参数,默认空对象 success: ({ data }) => { diff --git a/libs/util.js b/libs/util.js index 8133052..02e05f6 100644 --- a/libs/util.js +++ b/libs/util.js @@ -43,5 +43,13 @@ export default { } } return fmt - } + }, + // 获取商务经理id + getBmId(val) { + return uni.getStorageSync('partnerId') + }, + // 获取商务经理名称 + getBmName(val) { + return uni.getStorageSync('partnerClassificationName') + }, } \ No newline at end of file diff --git a/pages.json b/pages.json index feb93be..4fca702 100644 --- a/pages.json +++ b/pages.json @@ -158,6 +158,15 @@ "enablePullDownRefresh": false } } + ,{ + "path" : "pages/main/main", + "style" : + { + "navigationBarTitleText": "", + "enablePullDownRefresh": false + } + + } ], "condition": { //模式配置,仅开发期间生效 "current": 0, //当前激活的模式(list 的索引项) diff --git a/pages/addCourse/addCourse.vue b/pages/addCourse/addCourse.vue index 291519e..7d1bd75 100644 --- a/pages/addCourse/addCourse.vue +++ b/pages/addCourse/addCourse.vue @@ -90,7 +90,6 @@ }, // 上拉加载 onReachBottom() { - console.log(4444) if (this.reachBottom >= 0) { this.reachBottom = 1 this.status = 'loading' @@ -174,6 +173,7 @@ authority: e.productType === 2 ? 0 : 1, // 区分权限 0为数据平台权限,1为课程权限 productType: e.productType, // 课程分类 (0->理论 1-实训 2 数据产品) options: 1, + miniProgramPictureAddress: e.miniProgramPictureAddress, // 图标 settlementPrice: '', // 结算价 settlementMethod: e.settlementMethod, // 结算方式,0为单价,1为分成 settlementPriceUnit: e.settlementPrice, // 结算单价 @@ -181,6 +181,26 @@ serviceFee: 0 // 平台服务费(前端计算后展示,不入库) } }, + // 判断是否为客户已有的课程 + handleRenew(authority, customerId, productId, result, resolve, reject) { + renew({ + authority, + customerId, + productId + }).then(({ orderOthers }) => { + result.map(e => { + const item = orderOthers.find(n => n.dataOrCourseId == e.dataOrCourseId && n.authority == authority && e.authority == authority) + if (item) { + let date = new Date(item.endTime) + date = new Date(date.setDate(date.getDate() + 1)) + e.startTime = this.$util.formatDate(date, 'yyyy-MM-dd') + } + }) + resolve() + }).catch(e => { + reject() + }) + }, // 确定 submit() { const list = this.list.filter(e => e.check.length) // 筛选出选中了的产品 @@ -190,30 +210,26 @@ const dataIds = [] const { customerId } = this list.map(e => { - // e.authority ? courseIds.push(e.cid) : dataIds.push(e.cid) - courseIds.push(e.cid) - result.find(n => n.dataOrCourseId == e.cid) || result.push(this.createParam(e)) + // 新勾选的产品,则获取到id,下面要调用, + if (!result.find(n => n.dataOrCourseId == e.id)) { + e.productType === 2 ? dataIds.push(e.id) : courseIds.push(e.id) + result.push(this.createParam(e)) + } + }) + + const promises = [] + dataIds.length && promises.push(new Promise((resolve, reject) => { + this.handleRenew(0, customerId, dataIds, result, resolve, reject) + })) + courseIds.length && promises.push(new Promise((resolve, reject) => { + this.handleRenew(1, customerId, courseIds, result, resolve, reject) + })) + Promise.all(promises).then(_ => { + uni.setStorageSync('courses', result) // 把选中的产品添加至缓存 + uni.redirectTo({ + url: `../editCourse/editCourse?customerId=${customerId}` + }) }) - // 判断是否为客户已有的课程 - renew({ - authority: 1, - customerId, - productId: courseIds - }).then(({ orderOthers }) => { - result.map(e => { - // const item = orderOthers.map(n => dataOrCourseId == e.dataOrCourseId && n.authority && e.authority) - const item = orderOthers.find(n => n.dataOrCourseId == e.dataOrCourseId) - if (item) { - let date = new Date(item.endTime) - date = new Date(date.setDate(date.getDate() + 1)) - e.startTime = this.$util.formatDate(date, 'yyyy-MM-dd') - } - }) - uni.setStorageSync('courses', result) // 把选中的产品添加至缓存 - uni.redirectTo({ - url: `../editCourse/editCourse?customerId=${this.customerId}` - }) - }).catch(e => {}) } else { this.$util.errMsg('请选择产品!') } diff --git a/pages/clients/clients.vue b/pages/clients/clients.vue index 406879a..5361e34 100644 --- a/pages/clients/clients.vue +++ b/pages/clients/clients.vue @@ -118,7 +118,7 @@ getList() { const method = this.curTab ? all : list method({ - businessManagerId: 112, + businessManagerId: this.$util.getBmId(), customerType: this.customerType, keywords: this.keyword, pageNum: this.page, diff --git a/pages/editCourse/editCourse.vue b/pages/editCourse/editCourse.vue index a0c2097..038baf4 100644 --- a/pages/editCourse/editCourse.vue +++ b/pages/editCourse/editCourse.vue @@ -6,7 +6,7 @@ - + {{ item.productName }} @@ -85,7 +85,7 @@ text: '年', value: 2 }], - courses: uni.getStorageSync('courses'), // 上一页缓存的产品 + courses: [], // 上一页缓存的产品 orderRepeat: [], repeatMsg: '' } @@ -94,6 +94,13 @@ const pages = getCurrentPages() const { options } = pages[pages.length - 1] this.customerId = options.customerId + const store = uni.getStorageSync('courses') + if (store) { + this.courses = store + try { + uni.removeStorageSync('courses') + } catch (e) {} + } }, methods: { // 删除课程 @@ -195,32 +202,37 @@ calcDiscount(row) { const price = row.authority ? row.finalPrice : row.finalValue const { marketValue } = row - // 课程:成交价/市场价;数据:成交单价/市场单价 - if (price) row.discountRate = marketValue != 0 ? (price / row.marketValue * 100).toFixed(2) + '%' : '0%' + // (原价-现价)÷原价 x100% + if (price) row.discountRate = marketValue != 0 ? ((marketValue - price) / marketValue * 100).toFixed(2) + '%' : '0%' }, // 成交价修改后,计算成交单价,数据才需要 计算规则:成交价/账号数/时间(成交单价为元/账号/年,所以时间要换算成年的单位去计算) calcFinalValue(row) { const { authority, periodOfUse, options, accountNum, finalPrice } = row - if (authority && periodOfUse && accountNum && finalPrice) { - row.finalValue = (finalPrice / accountNum / periodOfUse * (!options ? - 365 : - options === 1 ? - 12 : - 1)).toFixed(2) + if (!authority && periodOfUse && accountNum && finalPrice) { + row.finalValue = (finalPrice / accountNum / periodOfUse).toFixed(2) } // 折扣率 this.calcDiscount(row) }, // 计算成交价。计算规则:成交单价*账号数*时间(成交单价为元/账号/年,所以时间要换算成年的单位去计算) calcFinalPrice(row) { - const { finalValue, accountNum, periodOfUse, options } = row - if (finalValue && accountNum) { - row.finalPrice = ((!options ? - finalValue / 365 * periodOfUse : - options === 1 ? - finalValue / 12 * periodOfUse : - finalValue * periodOfUse) * accountNum).toFixed(2) + const { finalValue, accountNum, periodOfUse, finalPrice } = row + if (periodOfUse) { + if (accountNum) { + // 有成交单价,则成交价=成交单价*账号数*时间 + if (finalValue) { + row.finalPrice = Math.round(finalValue * periodOfUse * accountNum) + } else if (!finalValue && finalPrice) { + // 有成交价,没有成交单价,则成交单价=成交价/账号数/时间 + row.finalValue = (finalPrice / periodOfUse / accountNum).toFixed(2) + this.calculateDiscount(e, row) + } + } else if (finalValue && finalValue && !row.authority) { + // 有成交价、成交单价,没有数量,则数量=成交价/时间/成交单价 + row.accountNum = Math.floor(finalPrice / periodOfUse / finalValue) + } } + this.dealSettlePrice(row) }, // 确定 submit() { diff --git a/pages/index/index.vue b/pages/index/index.vue index 9363901..cb08d2e 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -49,6 +49,12 @@ value: e.partnerId }) }) + console.log(22, result) + if (result.length === 1) { + const val = result[0].value + this.partnerId = val + uni.setStorageSync('partnerId', val) + } this.list = result }).catch(e => {}) }, diff --git a/pages/login/login.vue b/pages/login/login.vue index 88ceba7..49ac5f7 100644 --- a/pages/login/login.vue +++ b/pages/login/login.vue @@ -29,7 +29,7 @@ + + diff --git a/pages/orderDetail/orderDetail.vue b/pages/orderDetail/orderDetail.vue index 10b6295..14d116c 100644 --- a/pages/orderDetail/orderDetail.vue +++ b/pages/orderDetail/orderDetail.vue @@ -5,7 +5,7 @@ 商务经理 - + {{ $util.getBmName() }} 客户名称 @@ -52,47 +52,49 @@ - - {{ c.name }} - -
    -
  • - - - - {{ item.productName }} + @@ -114,7 +116,7 @@ 总采购成本: {{ purchase }}元 总产品利润: - {{ profit }}元 + {{ profit }} 提交 @@ -151,16 +153,18 @@ form: { // orderNumber: '', // 编号 provinceId: '', // 省份id + provinceName: '', orderContact: '', // 联系人 email: '', customerId: '', // 客户id customerName: '', orderType: '', cityId: '', + cityName: '', phone: '', orderAmount: 0, customerName: '', - businessManager: '' + businessManagerId: this.$util.getBmId() }, courseList: {}, courses: [], // 缓存的产品列表 @@ -216,8 +220,7 @@ // 获取详情 getInfo() { getDetail({ - // orderId: this.orderId - orderId: 121 + orderId: this.orderId }).then(({ orderDetails }) => { const order = orderDetails this.contract = order.contractInformation @@ -246,6 +249,7 @@ console.log(111, list) // 3个分类的课程分别push到不同数组(0->理论 1-实训 2 数据产品) list.map(e => { + e.serviceFee = (e.settlementPrice * 0.1).toFixed(2) const type = e.productType !type ? courses.theory.list.push(e) : @@ -253,10 +257,6 @@ courses.practice.list.push(e) : courses.data.list.push(e) }) - // 没有数据的课程,直接删除 - courses.practice.list.length || delete courses.practice - courses.theory.list.length || delete courses.theory - courses.data.list.length || delete courses.data console.log(222, courses) this.courseList = courses }, @@ -296,6 +296,10 @@ const e = result.customer form.customerId = e.customerId form.customerName = e.customerName + form.provinceId = e.provinceId + form.cityId = e.cityId + form.provinceName = e.provinceName + form.cityName = e.cityName form.phone = e.phone form.email = e.email form.name = e.name @@ -311,13 +315,13 @@ this.$util.errMsg('请先选择客户!') }, // 删除课程 - delCourse(i) { + delCourse(c, i) { const that = this uni.showModal({ title: '提示', content: '确定要删除吗?', success(res) { - res.confirm && that.courses.splice(i, 1) + res.confirm && c.list.splice(i, 1) } }) }, diff --git a/pages/orders/orders.vue b/pages/orders/orders.vue index e1b4f16..c76cd84 100644 --- a/pages/orders/orders.vue +++ b/pages/orders/orders.vue @@ -138,7 +138,7 @@ methods: { getList() { list({ - businessManagerId: 111, + businessManagerId: this.$util.getBmId(), keywords: this.keyword, pageNum: this.page, pageSize: this.pageSize, diff --git a/pages/plans/plans.vue b/pages/plans/plans.vue index 7e4e53b..c52133b 100644 --- a/pages/plans/plans.vue +++ b/pages/plans/plans.vue @@ -9,7 +9,7 @@
  • {{ tab.name }}
-
    +
    • {{ item.name }} @@ -31,6 +31,7 @@
    + @@ -38,11 +39,11 @@ export default { data() { return { - curTab: 0, + curTab: '', tabs: [ { name: '不限', - id: 0 + id: '' }, { name: '标准方案', @@ -117,8 +118,10 @@ }, // tab切换 tabChange(tab) { - this.curTab = tab.id - this.list = this.all.filter(e => e.type === tab.id) + const { id } = tab + const { all } = this + this.curTab = id + this.list = id ? all.filter(e => e.type === id) : all }, // 跳转详情 toDetail(id) {