|
|
|
@ -4,8 +4,14 @@ |
|
|
|
|
<uni-search-bar class="search" radius="5" placeholder="请输入产品名称" clearButton="auto" cancelButton="none" v-model="keyword" /> |
|
|
|
|
</uni-card> |
|
|
|
|
|
|
|
|
|
<ul class="tab"> |
|
|
|
|
<li v-for="(tab, i) in tabs" :class="{active: curTab === tab.id}" @click="tabChange(tab)">{{ tab.name }}</li> |
|
|
|
|
<ul class="tab-wrap"> |
|
|
|
|
<view class="tab"> |
|
|
|
|
<li :class="{active: curTab === ''}" @click="tabChange('')">全部</li> |
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
|
<scroll-view scroll-x :scroll-left="scrollLeft" class="tab tab-scroll"> |
|
|
|
|
<li v-for="(tab, i) in tabs" :key="i" :class="{active: curTab === tab.id}" @click="tabChange(tab.id)">{{ tab.name }}</li> |
|
|
|
|
</scroll-view> |
|
|
|
|
</ul> |
|
|
|
|
|
|
|
|
|
<ul class="list"> |
|
|
|
@ -26,32 +32,19 @@ |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import { AppletsDataProductList } from '@/apis/modules/product.js' |
|
|
|
|
import { renew } from '@/apis/modules/order.js' |
|
|
|
|
import { productCategoryList, listOfGoods } from '@/apis/modules/product.js' |
|
|
|
|
import { renew, queryCitySettlementPrice } from '@/apis/modules/order.js' |
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
|
return { |
|
|
|
|
// authority: 权限。0数据平台,1为课程,2职站增值模块,3实训课程(非集成),4实验工具 |
|
|
|
|
orderType: 1, |
|
|
|
|
customerId: '', |
|
|
|
|
provinceId: '', |
|
|
|
|
cityId: '', |
|
|
|
|
teamId: '', |
|
|
|
|
curTab: '', |
|
|
|
|
tabs: [ |
|
|
|
|
{ |
|
|
|
|
name: '全部', |
|
|
|
|
id: '' |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: '实训课程', |
|
|
|
|
id: 1 |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: '理论课程', |
|
|
|
|
id: 0 |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
name: '数据产品', |
|
|
|
|
id: 2 |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
tabs: [], |
|
|
|
|
reachBottom: 0, // 是否是上拉加载。0->否,1->是,-1->加载完所有数据 |
|
|
|
|
status: 'more', // 上拉加载状态 more|loading|noMore |
|
|
|
|
searchTimer: null, |
|
|
|
@ -105,22 +98,38 @@ |
|
|
|
|
const { options } = pages[pages.length - 1] |
|
|
|
|
this.orderType = options.orderType |
|
|
|
|
this.customerId = options.customerId |
|
|
|
|
this.provinceId = options.provinceId |
|
|
|
|
this.cityId = options.cityId |
|
|
|
|
this.teamId = options.teamId |
|
|
|
|
this.getTypes() |
|
|
|
|
this.getList() |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
// 产品类型 |
|
|
|
|
getTypes() { |
|
|
|
|
productCategoryList().then(res => { |
|
|
|
|
res.classificationList.forEach(e => { |
|
|
|
|
e.id = e.classificationId |
|
|
|
|
e.name = e.classificationName |
|
|
|
|
}) |
|
|
|
|
this.tabs.push(...res.classificationList) |
|
|
|
|
}).catch(e => {}) |
|
|
|
|
}, |
|
|
|
|
// 获取课程列表 |
|
|
|
|
getList() { |
|
|
|
|
uni.showLoading({ |
|
|
|
|
title: '加载中' |
|
|
|
|
}) |
|
|
|
|
AppletsDataProductList({ |
|
|
|
|
sort: 'desc', |
|
|
|
|
keywords: this.keyword, |
|
|
|
|
productType: this.curTab, |
|
|
|
|
listOfGoods({ |
|
|
|
|
pageNum: this.page, |
|
|
|
|
pageSize: this.pageSize |
|
|
|
|
}).then(({ data }) => { |
|
|
|
|
const { records } = data |
|
|
|
|
pageSize: this.pageSize, |
|
|
|
|
sort: 0, |
|
|
|
|
isShelves: 0, |
|
|
|
|
hotTag: 1, |
|
|
|
|
productName: this.keyword, |
|
|
|
|
productType: this.curTab, |
|
|
|
|
}).then(({ page }) => { |
|
|
|
|
const { records } = page |
|
|
|
|
const list = this.courses |
|
|
|
|
const all = this.checkAll.length // 是否勾选了全选 |
|
|
|
|
const pageChange = this.reachBottom > 0 // 是否是翻页 |
|
|
|
@ -131,9 +140,9 @@ |
|
|
|
|
text: '', |
|
|
|
|
value: 1 |
|
|
|
|
} |
|
|
|
|
e.check = (all && pageChange) || checked.find(n => n.id === e.id && n.productType === e.productType) ? 1 : 0 |
|
|
|
|
e.check = (all && pageChange) || checked.find(n => n.mallId === e.mallId) ? 1 : 0 |
|
|
|
|
// 筛选已经勾选的产品 |
|
|
|
|
if (list.find(n => n.dataOrCourseId == e.id && n.productType == e.productType)) { |
|
|
|
|
if (list.find(n => n.mallId == e.mallId)) { |
|
|
|
|
// 已经选择了的则禁止选择,并且直接选中 |
|
|
|
|
checkData.disable = true |
|
|
|
|
e.check = 1 |
|
|
|
@ -144,7 +153,7 @@ |
|
|
|
|
// 未加载完所有数据,并且不是筛选,则拼接list,否则直接赋值 |
|
|
|
|
this.list = pageChange ? [...this.list, ...records] : records |
|
|
|
|
this.page++ // 每次获取了数据后page+1 |
|
|
|
|
const noMore = this.list.length === data.total // 是否加载完所有数据 |
|
|
|
|
const noMore = this.list.length === page.total // 是否加载完所有数据 |
|
|
|
|
this.status = noMore ? 'noMore' : 'more' // 加载完了则设置为noMore |
|
|
|
|
this.reachBottom = noMore ? -1 : 0 // 加载完了则设置为-1 |
|
|
|
|
uni.hideLoading() |
|
|
|
@ -166,8 +175,8 @@ |
|
|
|
|
checkChange(e, i) { |
|
|
|
|
const { checked } = this |
|
|
|
|
const item = this.list[i] |
|
|
|
|
const { id, productType } = item |
|
|
|
|
const include = checked.findIndex(e => e.id === id && e.productType === productType) |
|
|
|
|
const { mallId } = item |
|
|
|
|
const include = checked.findIndex(e => e.mallId === mallId) |
|
|
|
|
// 选中的情况下,该产品如果没有push到已选数组里,则push |
|
|
|
|
if (e.detail.value.length) { |
|
|
|
|
include === -1 && checked.push(item) |
|
|
|
@ -185,8 +194,8 @@ |
|
|
|
|
const { checked, list } = this |
|
|
|
|
list.map(e => { |
|
|
|
|
e.check = isCheck ? 1 : 0 |
|
|
|
|
const { id, productType } = e |
|
|
|
|
const include = checked.findIndex(n => n.id === id && n.productType === productType) |
|
|
|
|
const { mallId } = e |
|
|
|
|
const include = checked.findIndex(n => n.mallId === mallId) |
|
|
|
|
// 选中的情况下,该产品如果没有push到已选数组里,则push |
|
|
|
|
if (isCheck) { |
|
|
|
|
include === -1 && checked.push(e) |
|
|
|
@ -196,51 +205,50 @@ |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
// 生成产品参数 |
|
|
|
|
createParam(e) { |
|
|
|
|
createParam(e, authority) { |
|
|
|
|
const { orderType } = this |
|
|
|
|
const trial = orderType == 2 // 是否是试用 |
|
|
|
|
return { |
|
|
|
|
dataOrCourseId: e.id, // id |
|
|
|
|
dataOrCourseId: e.associatedProduct, // id |
|
|
|
|
mallId: e.mallId, |
|
|
|
|
productName: e.productName, // 名称 |
|
|
|
|
periodOfUse: '', // 使用期限 |
|
|
|
|
startTime: this.$util.formatDate(new Date(), 'yyyy-MM-dd'), // 开始 |
|
|
|
|
endTime: '', // 终止 |
|
|
|
|
remainingPeriod: '', // 剩余期限 |
|
|
|
|
marketValue: '', // 市场价 |
|
|
|
|
marketPrice: e.marketPrice, // 市场单价 |
|
|
|
|
marketPrice: e.marketUnitPrice, // 市场单价 |
|
|
|
|
finalPrice: trial ? 0 : '', // 成交价 |
|
|
|
|
finalValue: trial ? 0 : '', // 成交单价(数据产品特有) |
|
|
|
|
discountRate: trial ? '0%' : '', // 折扣率 |
|
|
|
|
accountNum: e.productType === 2 ? '' : 1, // 账号数 |
|
|
|
|
accountNum: authority ? 1 : '', // 账号数 |
|
|
|
|
totalAmount: '', // 总价 |
|
|
|
|
isEnable: 1, // 启用否:1启用,0禁用 |
|
|
|
|
isEnable: 0, // 启用否:1启用,0禁用 |
|
|
|
|
ship: 0, // 发货否(0未发货,1已发货,默认不发货) |
|
|
|
|
authority: e.productType === 2 ? 0 : 1, // 区分权限 0为数据平台权限,1为课程权限 |
|
|
|
|
productType: e.productType, // 课程分类 (0->理论 1-实训 2 数据产品) |
|
|
|
|
authority, // 区分权限 0为数据平台权限,1为课程权限 |
|
|
|
|
options: 2, |
|
|
|
|
miniProgramPictureAddress: e.miniProgramPictureAddress, // 图标 |
|
|
|
|
miniProgramPictureAddress: e.appletIcon || '', // 图标 |
|
|
|
|
settlementPrice: trial ? 0 : '', // 结算价 |
|
|
|
|
settlementMethod: e.settlementMethod, // 结算方式,0为单价,1为分成 |
|
|
|
|
settlementPriceUnit: e.settlementPrice, // 结算单价 |
|
|
|
|
businessProportion: e.businessProportion, // 商务占比 |
|
|
|
|
settlementPriceUnit: e.settlementPrice || 0, // 结算单价 |
|
|
|
|
serviceFee: 0 // 平台服务费(前端计算后展示,不入库) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 判断是否为客户已有的课程 |
|
|
|
|
handleRenew(authority, customerId, productId, result, resolve, reject) { |
|
|
|
|
handleRenew(authority, customerId, productId, mallId, result, resolve, reject) { |
|
|
|
|
renew({ |
|
|
|
|
authority, |
|
|
|
|
customerId, |
|
|
|
|
productId |
|
|
|
|
productId, |
|
|
|
|
mallId |
|
|
|
|
}).then(({ orderOthers }) => { |
|
|
|
|
result.map(e => { |
|
|
|
|
const item = orderOthers.find(n => n.dataOrCourseId == e.dataOrCourseId && n.authority == authority == e.authority) |
|
|
|
|
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') |
|
|
|
|
e.renew = 1 |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
resolve() |
|
|
|
@ -253,28 +261,80 @@ |
|
|
|
|
const list = this.checked // 已选产品 |
|
|
|
|
if (list.length) { |
|
|
|
|
const result = this.courses |
|
|
|
|
const courseIds = [] |
|
|
|
|
const dataIds = [] |
|
|
|
|
console.log(123, result) |
|
|
|
|
const list1 = [] // 实训、理论 |
|
|
|
|
const list0 = [] // 数据前瞻 |
|
|
|
|
const list2 = [] // 职站增值 |
|
|
|
|
const list3 = [] // 实训课程(非集成) |
|
|
|
|
const list4 = [] // 实验工具 |
|
|
|
|
|
|
|
|
|
const mallId1 = [] // 实训、理论 |
|
|
|
|
const mallId0 = [] // 数据前瞻 |
|
|
|
|
const mallId2 = [] // 职站增值 |
|
|
|
|
const mallId3 = [] // 实训课程(非集成) |
|
|
|
|
const mallId4 = [] // 实验工具 |
|
|
|
|
const { customerId } = this |
|
|
|
|
list.map(e => { |
|
|
|
|
// 新勾选的产品,则获取到id,下面要调用, |
|
|
|
|
if (!result.find(n => (n.dataOrCourseId == e.id || n.dataOrCourseId == e.dataOrCourseId) && ((n.authority && e.productType != 2) || (!n.authority && e.productType == 2)))) { |
|
|
|
|
e.productType === 2 ? dataIds.push(e.id) : courseIds.push(e.id) |
|
|
|
|
result.push(this.createParam(e)) |
|
|
|
|
|
|
|
|
|
const listPromise = [] |
|
|
|
|
list.forEach(async e => { |
|
|
|
|
listPromise.push(new Promise(async (resolve, reject) => { |
|
|
|
|
// 新勾选的产品,则获取到id,下面要调用 |
|
|
|
|
if (!result.find(n => (n.dataOrCourseId == e.associatedProduct || n.dataOrCourseId == e.dataOrCourseId) && n.authority == e.authority)) { |
|
|
|
|
// 查询产品管理设置的平台结算价 |
|
|
|
|
if (this.provinceId) { |
|
|
|
|
const res = await queryCitySettlementPrice(e.mallId, this.provinceId, this.cityId) |
|
|
|
|
if (res.mallPrice) e.settlementPrice = res.mallPrice.discountRate |
|
|
|
|
} |
|
|
|
|
console.log(44, e) |
|
|
|
|
const classId = e.classificationId |
|
|
|
|
const pid = +e.associatedProduct |
|
|
|
|
const mallId = e.mallId |
|
|
|
|
if (classId == 1 || classId == 2) { |
|
|
|
|
list1.push(pid) |
|
|
|
|
mallId1.push(mallId) |
|
|
|
|
} else if (classId == 3) { |
|
|
|
|
list2.push(pid) |
|
|
|
|
mallId2.push(mallId) |
|
|
|
|
} else if (classId == 4) { |
|
|
|
|
list3.push(pid) |
|
|
|
|
mallId3.push(mallId) |
|
|
|
|
} else if (classId == 5) { |
|
|
|
|
list0.push(pid) |
|
|
|
|
mallId0.push(mallId) |
|
|
|
|
} else if (classId == 6) { |
|
|
|
|
list4.push(pid) |
|
|
|
|
mallId4.push(mallId) |
|
|
|
|
} |
|
|
|
|
result.push(this.createParam(e, this.$util.getOrderType(classId))) |
|
|
|
|
resolve() |
|
|
|
|
} else { |
|
|
|
|
resolve() |
|
|
|
|
} |
|
|
|
|
})) |
|
|
|
|
}) |
|
|
|
|
Promise.all(listPromise).then(_ => { |
|
|
|
|
const promises = [] |
|
|
|
|
// 课程和数据的分别调接口 |
|
|
|
|
dataIds.length && promises.push(new Promise((resolve, reject) => { |
|
|
|
|
this.handleRenew(0, customerId, dataIds, result, resolve, reject) |
|
|
|
|
// 有5种产品,要传不同的authority调renew接口 |
|
|
|
|
list0.length && promises.push(new Promise((resolve, reject) => { |
|
|
|
|
this.handleRenew(0, customerId, list0, mallId0, result, resolve, reject) |
|
|
|
|
})) |
|
|
|
|
list1.length && promises.push(new Promise((resolve, reject) => { |
|
|
|
|
this.handleRenew(1, customerId, list1, mallId1, result, resolve, reject) |
|
|
|
|
})) |
|
|
|
|
list2.length && promises.push(new Promise((resolve, reject) => { |
|
|
|
|
this.handleRenew(2, customerId, list2, mallId2, result, resolve, reject) |
|
|
|
|
})) |
|
|
|
|
courseIds.length && promises.push(new Promise((resolve, reject) => { |
|
|
|
|
this.handleRenew(1, customerId, courseIds, result, resolve, reject) |
|
|
|
|
list3.length && promises.push(new Promise((resolve, reject) => { |
|
|
|
|
this.handleRenew(3, customerId, list3, mallId3, result, resolve, reject) |
|
|
|
|
})) |
|
|
|
|
list4.length && promises.push(new Promise((resolve, reject) => { |
|
|
|
|
this.handleRenew(4, customerId, list4, mallId4, result, resolve, reject) |
|
|
|
|
})) |
|
|
|
|
Promise.all(promises).then(_ => { |
|
|
|
|
uni.setStorageSync('courses', result) // 把选中的产品添加至缓存 |
|
|
|
|
uni.redirectTo({ |
|
|
|
|
url: `../editCourse/editCourse?customerId=${customerId}&orderType=${this.orderType}&action=add` |
|
|
|
|
url: `../editCourse/editCourse?customerId=${customerId}&orderType=${this.orderType}&teamId=${this.teamId}` |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
@ -289,6 +349,16 @@ |
|
|
|
|
.page { |
|
|
|
|
padding-bottom: 130rpx; |
|
|
|
|
} |
|
|
|
|
.tab-wrap { |
|
|
|
|
display: flex; |
|
|
|
|
.tab-scroll { |
|
|
|
|
width: calc(100% - 100rpx); |
|
|
|
|
white-space: nowrap; |
|
|
|
|
li { |
|
|
|
|
display: inline-block; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
.list { |
|
|
|
|
li { |
|
|
|
|
display: flex; |
|
|
|
|