Commit 54dd796e authored by Damon's avatar Damon

refactor: 物料选择接口对接

parent 91483a06
...@@ -11,6 +11,6 @@ const UNI_APP = { ...@@ -11,6 +11,6 @@ const UNI_APP = {
qn_base_url: 'https://qn-static.banshouhui.com/self-support/', qn_base_url: 'https://qn-static.banshouhui.com/self-support/',
qn_asset_url: 'http://deudn.c.pp.cc/', qn_asset_url: 'http://deudn.c.pp.cc/',
argoDebugMode: 1, argoDebugMode: 1,
version: 'v1.3.9' version: 'v1.5.0'
} }
module.exports = UNI_APP; module.exports = UNI_APP;
;(function() { ;(function() {
let NODE_ENV = 'test' // dev:开发环境 | test:测试环境 | prod:生产环境 let NODE_ENV = 'test' // dev:开发环境 | test:测试环境 | prod:生产环境
let ENV_VAR = null let ENV_VAR = null
let VERSION_NUMBER = '1.4.0' //版本号 let VERSION_NUMBER = '1.5.0' //版本号
//小程序是否审核通过,参数配置在ucenter库version表,对应版本号的is_audit设置为1,将显示学习视频 //小程序是否审核通过,参数配置在ucenter库version表,对应版本号的is_audit设置为1,将显示学习视频
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
if (NODE_ENV === 'dev') { if (NODE_ENV === 'dev') {
......
...@@ -10,7 +10,7 @@ const UNI_APP = { ...@@ -10,7 +10,7 @@ const UNI_APP = {
qn_base_url: 'https://qn-static.banshouhui.com/self-support/', qn_base_url: 'https://qn-static.banshouhui.com/self-support/',
qn_asset_url: 'https://qn-static.banshouhui.com', qn_asset_url: 'https://qn-static.banshouhui.com',
argoDebugMode: 0, argoDebugMode: 0,
version: 'v1.3.9' version: 'v1.5.0'
} }
module.exports = UNI_APP; module.exports = UNI_APP;
...@@ -11,6 +11,6 @@ const UNI_APP = { ...@@ -11,6 +11,6 @@ const UNI_APP = {
qn_base_url: 'https://qn-static.banshouhui.com/self-support/', qn_base_url: 'https://qn-static.banshouhui.com/self-support/',
qn_asset_url: 'https://qn-static.banshouhui.com', qn_asset_url: 'https://qn-static.banshouhui.com',
argoDebugMode: 1, argoDebugMode: 1,
version: 'v1.3.9' version: 'v1.5.0'
} }
module.exports = UNI_APP; module.exports = UNI_APP;
...@@ -19,10 +19,18 @@ let partsApiFun = function (vm) { ...@@ -19,10 +19,18 @@ let partsApiFun = function (vm) {
* 配件过滤-品类列表 * 配件过滤-品类列表
*/ */
let getCategoryList = async () => await vm.$u.get(base + vm.vuex_token + '/allow/category/list'); let getCategoryList = async () => await vm.$u.get(base + vm.vuex_token + '/allow/category/list');
/**
* 配件过滤-一级分类
*/
let getClassify = async (params = {}) => await vm.$u.get(parts + vm.vuex_token + '/type/classify/' + params.id);
/** /**
* 配件过滤-品牌列表 * 配件过滤-品牌列表
*/ */
let getBrandList = async (params = {}) => await vm.$u.get(base + vm.vuex_token + '/allow/brand/list', params); let getBrandList = async (params = {}) => await vm.$u.get(parts + vm.vuex_token + '/type/towLevel/' + params.categoryId + '/' + params.classifyId);
/**
* 配件过滤-三级分类列表
*/
let getThreeLevel = async (params = {}) => await vm.$u.get(parts + vm.vuex_token + '/type/threeLevel/' + params.categoryId + '/' + params.classifyId + '?partnerCompanyId = ' + params.partnerCompanyId + '&speciesId=' + params.speciesId);
/** /**
* 查询配件列表 * 查询配件列表
*/ */
...@@ -50,7 +58,9 @@ let partsApiFun = function (vm) { ...@@ -50,7 +58,9 @@ let partsApiFun = function (vm) {
getSiteAddress, getSiteAddress,
updateAddress, updateAddress,
getCategoryList, getCategoryList,
getClassify,
getBrandList, getBrandList,
getThreeLevel,
getPartsList, getPartsList,
applyParts, applyParts,
getMyReserve, getMyReserve,
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
<view class="categary" v-if="type === '2'"> <view class="categary" v-if="type === '2'">
<view class="u-flex u-col-center"> <view class="u-flex u-col-center">
<view <view
:class="['txt', {'active': categoryId === item.categoryId }]" :class="['txt', {'active': classifyId === item.id }]"
v-for="item in categary" v-for="item in classify"
:key="item.categoryId" :key="item.id"
@click="changeCategary(item)" @click="changeClassify(item)"
>{{item.label}}</view> >{{item.label}}</view>
</view> </view>
</view> </view>
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
:scroll-into-view="scrollId" :scroll-into-view="scrollId"
> >
<view <view
:id="`brand${item.brandId}`" :id="`brand${item.id}`"
:class="['label-title', { selected: item.brandId == brandId }]" :class="['label-title', { selected: item.id == brandId }]"
v-for="(item, index) in brand" v-for="(item, index) in brand"
:key="index" :key="index"
@click="selectBrand(item, index)" @click="selectBrand(item, index)"
...@@ -41,27 +41,25 @@ ...@@ -41,27 +41,25 @@
</scroll-view> </scroll-view>
</view> </view>
<view class="more u-flex" @click="handleClick"> <view class="more u-flex" @click="handleClick">
<!-- <picker mode="selector" :value="brandIndex" range-key="label" :range="brand" @click="show = true" @change="changeBrand"> -->
<view class="more-text">更多</view> <view class="more-text">更多</view>
<!-- </picker> -->
<u-icon class="input-icon" color="#2272FF" name="arrow-right"></u-icon> <u-icon class="input-icon" color="#2272FF" name="arrow-right"></u-icon>
</view> </view>
</view> </view>
<view class="model u-flex" v-show="showMore !== true"> <view class="model u-flex" v-if="showMore !== true && model.length > 0">
<view class="label-content u-flex"> <view class="label-content u-flex">
<scroll-view <scroll-view
style="width:100%;white-space: nowrap;" style="width:100%;white-space: nowrap;"
scroll-x="true" scroll-x="true"
class="u-flex" class="u-flex"
:scroll-into-view="scrollId" :scroll-into-view="scrollModelId"
> >
<view <view
:id="`brand${item.brandId}`" :id="`model${item.id}`"
:class="['label-title', { selected: item.brandId == brandId }]" :class="['label-title', { selected: item.id == modelId }]"
v-for="(item, index) in brand" v-for="(item, index) in model"
:key="index" :key="index"
@click="selectBrand(item, index)" @click="selectModel(item, index)"
>{{ item.label }}</view> >{{ item.label }}</view>
</scroll-view> </scroll-view>
</view> </view>
...@@ -70,20 +68,20 @@ ...@@ -70,20 +68,20 @@
</view> </view>
</view> </view>
<view class="allModel u-flex" v-show="showMore === true"> <view class="allModel u-flex" v-if="showMore === true && model.length > 0">
<view class="label-content u-flex"> <view class="label-content u-flex">
<scroll-view <scroll-view
style="width:100%;height: 320rpx;" style="width:100%;height: 320rpx;"
scroll-y="true" scroll-y="true"
class="u-flex" class="u-flex"
:scroll-into-view="scrollId" :scroll-into-view="scrollModelId"
> >
<view <view
:id="`brand${item.brandId}`" :id="`model${item.id}`"
:class="['label-title', { selected: item.brandId == brandId }]" :class="['label-title', { selected: item.id == modelId }]"
v-for="(item, index) in brand" v-for="(item, index) in model"
:key="index" :key="index"
@click="selectBrand(item, index)" @click="selectModel(item, index)"
>{{ item.label }}</view> >{{ item.label }}</view>
</scroll-view> </scroll-view>
</view> </view>
...@@ -93,7 +91,7 @@ ...@@ -93,7 +91,7 @@
</view> </view>
<view class="lists"> <view class="lists">
<view class="mask" v-show="showMore === true" @click="showMore = false"></view> <view class="mask" v-if="showMore === true" @click="showMore = false"></view>
<scroll-view <scroll-view
style="height:100%;" style="height:100%;"
:scroll-top="scrollTop" :scroll-top="scrollTop"
...@@ -143,13 +141,16 @@ export default { ...@@ -143,13 +141,16 @@ export default {
show: false, show: false,
showMore: false, showMore: false,
categary: [], categary: [],
classify: [],
brand: [], brand: [],
model: [], model: [],
categaryIndex: 0, categaryIndex: 0,
categoryId: '', categoryId: '',
brandIndex: 0, classifyId: '',
brandId: 0, brandId: 0,
scrollId: '', scrollId: '',
scrollModelId: '',
modelId: 0,
loadStatus: 'loadmore', loadStatus: 'loadmore',
lists: [], lists: [],
submitList: [], submitList: [],
...@@ -218,15 +219,25 @@ export default { ...@@ -218,15 +219,25 @@ export default {
if (res.code === 200) { if (res.code === 200) {
const data = res.data const data = res.data
if (data.length > 0) { if (data.length > 0) {
this.categary = data.map((v) => { this.categoryId = data[0].categoryId
v.label = v.categoryName this.getClassify()
} else {
this.getPartsList()
}
}
})
},
// 获取一级分类
getClassify() {
this.$u.api.getClassify({ id: this.categoryId }).then((res) => {
if (res.code === 200) {
const data = res.data
if (data.length > 0) {
this.classify = data.map((v) => {
v.label = v.name
return v return v
}) })
this.categary.push({ this.classifyId = this.classify[0].id
categoryId: 2,
label: '非桩类',
})
this.categoryId = this.categary[0].categoryId
this.getBrandList() this.getBrandList()
} else { } else {
this.getPartsList() this.getPartsList()
...@@ -234,26 +245,69 @@ export default { ...@@ -234,26 +245,69 @@ export default {
} }
}) })
}, },
// 获取品牌 // 获取二级分类
getBrandList(id) { getBrandList(id) {
this.$u.api.getBrandList({ categoryId: this.categoryId }).then((res) => { this.$u.api.getBrandList({ categoryId: this.categoryId, classifyId: this.classifyId }).then((res) => {
if (res.code === 200) { if (res.code === 200) {
const data = res.data const data = res.data
let lists
if (this.classifyId === 1) {
lists = data.partnerCompany
} else {
lists = data.classify
}
let item, index let item, index
this.brand = data.map((v, i) => { this.brand = lists.map((v, i) => {
if (id && parseInt(id) === v.brandId) { if (id && parseInt(id) === v.id) {
item = v item = v
index = i index = i
} }
v.label = v.brandName v.label = v.name
return v return v
}) })
if (item && index) { if (item && index) {
this.selectBrand(item, index) this.selectBrand(item, index)
this.scrollId = `brand${item.brandId}` this.scrollId = `brand${item.id}`
} else {
this.brandId = this.brand?.[0]?.id
this.lists = []
this.getThreeLevel()
}
}
})
},
// 获取三级分类
getThreeLevel() {
const params = {
categoryId: this.categoryId,
classifyId: this.classifyId,
partnerCompanyId: '',
speciesId: ''
}
if (this.classifyId === 1) {
params.partnerCompanyId = this.brandId
} else {
params.speciesId = this.brandId
}
this.$u.api.getThreeLevel(params).then(res => {
if (res.code === 200) {
const data = res.data
let item, index
this.model = data.map((v, i) => {
// if (id && parseInt(id) === v.id) {
// item = v
// index = i
// }
v.label = v.name
return v
})
if (item && index) {
this.selectModel(item, index)
this.scrollModelId = `model${item.id}`
} else { } else {
this.brandId = this.brand?.[0]?.brandId this.modelId = this.model?.[0]?.id
this.lists = [] this.lists = []
this.getPartsList() this.getPartsList()
} }
...@@ -268,9 +322,19 @@ export default { ...@@ -268,9 +322,19 @@ export default {
pageNumber: this.pageNumber, pageNumber: this.pageNumber,
pageSize: this.pageSize, pageSize: this.pageSize,
categoryId: this.categoryId || '', categoryId: this.categoryId || '',
brandId: this.brandId || '',
keyword: this.keyword, keyword: this.keyword,
classifyId: this.classifyId,
brandId: this.modelId,
speciesId: '',
partnerCompanyId: '',
}
if (this.classifyId === 1) {
params.partnerCompanyId = this.brandId
} else {
params.speciesId = this.brandId
} }
this.$u.api.getPartsList(params).then((res) => { this.$u.api.getPartsList(params).then((res) => {
if (res.code === 200) { if (res.code === 200) {
const data = res.data const data = res.data
...@@ -301,27 +365,26 @@ export default { ...@@ -301,27 +365,26 @@ export default {
this.getPartsList() this.getPartsList()
}, },
// 选择品类 // 选择品类
changeCategary(data) { changeClassify(data) {
this.categoryId = data.categoryId this.classifyId = data.id
this.brandIndex = ''
this.show = false this.show = false
this.brand = []
this.pageNumber = 1 this.pageNumber = 1
this.getBrandList() this.getBrandList()
}, },
// 下拉选择品牌
changeBrand(data) {
this.brandIndex = data.detail.value
this.brandId = this.brand[this.brandIndex].brandId
this.scrollId = `brand${this.brandId}`
this.lists = []
this.pageNumber = 1
this.getPartsList()
},
// 点击选择品牌 // 点击选择品牌
selectBrand(item, index) { selectBrand(item, index) {
this.scrollId = '' this.scrollId = ''
this.brandIndex = index this.brandId = item.id
this.brandId = item.brandId this.model = []
this.lists = []
this.pageNumber = 1
this.getThreeLevel()
},
// 点击选择三级分类
selectModel(item, index) {
this.scrollModelId = ''
this.modelId = item.id
this.lists = [] this.lists = []
this.pageNumber = 1 this.pageNumber = 1
this.getPartsList() this.getPartsList()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment