首页定位拒绝情况处理;产品列表,师傅圈默认展示当前市的,然后用户只能选择当前市的以及当前市下的区进行筛选

This commit is contained in:
donqi 2022-12-31 20:39:15 +08:00
parent 29eb03800e
commit dbf467b928
6 changed files with 367 additions and 205 deletions

View File

@ -78,6 +78,7 @@ export default {
areaRes = areaRes.data;
if (areaRes) {
let areaArr = [areaRes.provinceArea, areaRes.cityArea, areaRes.countryArea];
// let areaArr = [areaRes.cityArea, areaRes.countryArea];
let curLocation = {
area: areaArr,
updateTimes: new Date().getTime()
@ -85,6 +86,19 @@ export default {
uni.setStorageSync('curLocation', curLocation);
}
},
async storageLocation(res) {
let areaRes = await this.baiduGetLoacation(res.latitude, res.longitude);
areaRes = areaRes.data;
if (areaRes) {
let areaArr = [areaRes.provinceArea, areaRes.cityArea, areaRes.countryArea];
// let areaArr = [areaRes.cityArea, areaRes.countryArea];
let curLocation = {
area: areaArr,
updateTimes: new Date().getTime()
}
uni.setStorageSync('curLocation', curLocation);
}
},
async getCurArea() {
try{
let curLocation = uni.getStorageSync('curLocation');

View File

@ -60,6 +60,7 @@
"scope.userLocation" : {
"desc" : "因涉及上门家政服务,需获取地理位置"
}
}
},
"requiredPrivateInfos": ["getLocation"]
}
}

View File

@ -27,7 +27,7 @@
<view class="action">
<picker :mode="'multiSelector'" @change="regionChange" @columnchange="regionColChange"
:value="areaMultiIndex" :range-key="'areaName'" :range="areaList">
<text>{{searchInfo.area && searchInfo.area.length ? searchInfo.area[2].areaName : areaList[2][0].areaName}}</text>
<text>{{searchInfo.area && searchInfo.area.length ? searchInfo.area[1].areaName : areaList[1][0].areaName}}</text>
<text class="cuIcon-location"></text>
</picker>
</view>
@ -116,6 +116,19 @@
</view>
<load-status-bar ref="loadStatusBar2" @loadMore="loadOtherCityProductPage"></load-status-bar>
</view>
</view>
<!-- 前往授权设置 -->
<view class="cu-modal" :class="isShowPrivSetting?'show':''">
<view class="cu-dialog">
<view class="padding-xl text-left">
<view>需先授权定位功能才可正常使用功能</view>
</view>
<view class="cu-bar bg-white">
<navigator class="modal-bottom-oper margin-0 flex-sub text-black" open-type="exit" target="miniProgram">拒绝授权
</navigator>
<button class="cu-btn modal-bottom-oper margin-0 flex-sub text-main-color bg-white solid-left" open-type="openSetting" @opensetting="authLocationCallback">前往授权</button>
</view>
</view>
</view>
</view>
</template>
@ -146,13 +159,14 @@
InputBottom: 0,
searchInfo: {},
areaList: [],
areaMultiIndex: [0, 0, 0],
areaMultiIndex: [0, 0],
productList: [],
otherCityProductList: [],
pageNum: 0,
pageSize: 0,
otherCityProductPageNum: 0,
otherCityProductPageSize: 0
otherCityProductPageSize: 0,
isShowPrivSetting: false
}
},
mounted() {
@ -162,15 +176,14 @@
this.offBindEvent();
},
async onReady() {
await this.$request.authAndGetLocation();
await this.loadData();
// await this.$request.authAndGetLocation();
//
await this.getCurAreaArr();
},
methods: {
async loadData() {
this.initBasicData();
//
await this.loadRegionList();
await this.getCurAreaArr();
//
await this.loadRegionList();
//
let hotServCategoryRes = await this.$request.getHotCategory({
@ -202,15 +215,85 @@
offBindEvent() {
uni.$off('clickCard');
},
async getCurAreaArr() {
let areaArr = await this.$request.getCurArea();
if (areaArr) {
this.searchInfo.area = areaArr;
async authLocationCallback(res) {
if (res.detail.authSetting['scope.userLocation']) {
this.isShowPrivSetting = false;
await this.getCurAreaArr();
}
// else {
// //
// this.searchInfo.area = [this.areaList[0][0], this.areaList[1][0], this.areaList[2][0]];
// }
},
async wxGetLocation() {
let _this = this;
// wx.getSetting authScope
let res1 = await wx.getSetting();
if (res1) {
if (!res1.authSetting['scope.userLocation']) {
let res2 = await wx.getLocation({
type: 'gcj02',
fail: async (result) => {
console.log(result)
if (result.errno === 103 || result.errMsg === 'getLocation:fail auth deny') {
this.isShowPrivSetting = true;
} else {
//
uni.showToast({
title: '请确认是否开启定位',
icon: 'none',
duration: 1500
})
}
},
success: async (result) => {
await _this.$request.storageLocation(result);
let areaArr = await _this.getCurAreaArr();
if (areaArr) {
_this.searchInfo.area = areaArr;
await _this.loadData();
}
}
})
} else {
wx.getLocation({
type: 'gcj02',
fail: async (result) => {
console.log(result)
if (result.errCode === 2 || result.errCode === 404) {
uni.showToast({
title: '定位获取失败,请确认是否开启定位',
icon: 'none',
duration: 2500
})
} else {
uni.showToast({
title: '定位获取失败,请稍后重试',
icon: 'none',
duration: 2500
})
}
},
success: async (result) => {
await _this.$request.storageLocation(result);
let areaArr = await _this.getCurAreaArr();
if (areaArr) {
_this.searchInfo.area = areaArr;
await _this.loadData();
}
}
})
}
}
},
async getCurAreaArr() {
let curLocation = uni.getStorageSync('curLocation');
if (curLocation && curLocation.updateTimes) {
let curTimes = new Date().getTime();
let deltaSeconds = curTimes - curLocation.updateTimes;
if (deltaSeconds <= 15 * 60 * 1000) {
this.searchInfo.area = curLocation.area;
this.loadData();
return;
}
}
await this.wxGetLocation();
},
async loadCategoryList() {
let res = await this.$request.getProductCategories();
@ -244,12 +327,24 @@
subSubRegionList = await this.$request.areaListByStep({
parentCode: subRegionList[0].areaCode
});
subSubRegionList = subSubRegionList.data;
subSubRegionList = subSubRegionList.data;
let allAreaIdsOfSubSubRegionList = [];
subSubRegionList.forEach(region => {
allAreaIdsOfSubSubRegionList.push(region.areaId)
})
let subSubRegionListWithAll = [{
areaIds: allAreaIdsOfSubSubRegionList,
areaId: subRegionList[0].areaId,
isAll: true,
areaName: subRegionList[0].areaName
}].concat(subSubRegionList);
subSubRegionList = subSubRegionListWithAll;
}
this.areaList = [];
this.areaList.push(regionList);
// this.areaList.push(regionList);
this.areaList.push(subRegionList);
this.areaList.push(subSubRegionList);
this.areaList.push(subSubRegionList);
this.searchInfo.area = [this.areaList[0][0], this.areaList[1][0]];
},
regionChange(e) {
this.areaMultiIndex = e.detail.value;
@ -261,35 +356,35 @@
this.reloadProductPage();
},
async regionColChange(e) {
let colObj = e.detail;
if (colObj.column == 0) {
//
let subAreaList = await this.$request.areaListByStep({
parentCode: this.areaList[0][colObj.value].areaCode
});
subAreaList = subAreaList.data;
let subSubAreaList = [];
if (subAreaList.length) {
subSubAreaList = await this.$request.areaListByStep({
parentCode: subAreaList[0].areaCode
});
subSubAreaList = subSubAreaList.data;
}
this.areaList.pop();
this.areaList.pop();
this.areaList.push(subAreaList);
this.areaList.push(subSubAreaList);
this.areaMultiIndex = [colObj.value, 0, 0];
} else if (colObj.column == 1) {
//
let subAreaList = await this.$request.areaListByStep({
parentCode: this.areaList[1][colObj.value].areaCode
});
subAreaList = subAreaList.data;
this.areaList.pop();
this.areaList.push(subAreaList);
this.areaMultiIndex = [this.areaMultiIndex[0], colObj.value, 0];
}
// let colObj = e.detail;
// if (colObj.column == 0) {
// //
// let subAreaList = await this.$request.areaListByStep({
// parentCode: this.areaList[0][colObj.value].areaCode
// });
// subAreaList = subAreaList.data;
// let subSubAreaList = [];
// if (subAreaList.length) {
// subSubAreaList = await this.$request.areaListByStep({
// parentCode: subAreaList[0].areaCode
// });
// subSubAreaList = subSubAreaList.data;
// }
// this.areaList.pop();
// this.areaList.pop();
// this.areaList.push(subAreaList);
// this.areaList.push(subSubAreaList);
// this.areaMultiIndex = [colObj.value, 0, 0];
// } else if (colObj.column == 1) {
// //
// let subAreaList = await this.$request.areaListByStep({
// parentCode: this.areaList[1][colObj.value].areaCode
// });
// subAreaList = subAreaList.data;
// this.areaList.pop();
// this.areaList.push(subAreaList);
// this.areaMultiIndex = [this.areaMultiIndex[0], colObj.value, 0];
// }
},
async tabSelect(e, item) {
this.tabCur = e == null ? 0 : e.currentTarget.dataset.index;
@ -339,8 +434,7 @@
url: '/pages/product/filtered-products?params=' + encodeURIComponent(JSON.stringify(params))
})
},
clickHotCategory(item) {
console.log(item)
clickHotCategory(item) {
let params = {
category: item
};
@ -378,6 +472,11 @@
async loadProductPage(params = {
areaId: this.searchInfo.area && this.searchInfo.area.length ? this.searchInfo.area[this.searchInfo.area.length - 1].areaId : null
}, loadStatusBarRefName = "loadStatusBar1", resContainer = "productList", pageNumName = "pageNum", pageSizeName = "pageSize") {
if (!params.exceptParentAreaId && this.searchInfo.area
&& this.searchInfo.area.length && this.searchInfo.area[this.searchInfo.area.length - 1].isAll) {
params.areaIds = this.searchInfo.area[this.searchInfo.area.length - 1].areaIds;
params.areaId = null;
}
params.pageNum = this[pageNumName];
params.pageSize = this[pageSizeName];
params.status = 0;

View File

@ -11,7 +11,7 @@
<picker :mode="'multiSelector'" @change="regionChange" @columnchange="regionColChange"
:value="areaMultiIndex" :range-key="'areaName'" :range="areaList">
<text class="cuIcon-location"></text>
<text>{{searchInfo.area && searchInfo.area.length ? searchInfo.area[2].areaName : areaList[2][0].areaName}}</text>
<text>{{searchInfo.area && searchInfo.area.length ? searchInfo.area[1].areaName : areaList[1][0].areaName}}</text>
</picker>
</view>
<view class="search-form round">
@ -208,7 +208,7 @@
stickyTop: this.CustomBar,
searchInfo: {},
areaList: [],
areaMultiIndex: [0, 0, 0],
areaMultiIndex: [0, 0],
categoryList: [],
categoryMultiIndex: [0, 0, 0]
}
@ -220,7 +220,6 @@
async loadData() {
this.pageNum = this.$globalData.initPageNum;
this.pageSize = this.$globalData.initPageSize;
await this.loadRegionList();
//
await this.getCurAreaArr();
await this.loadRegionList();
@ -230,9 +229,7 @@
async getCurAreaArr() {
let areaArr = await this.$request.getCurArea();
if (areaArr) {
this.searchInfo.area = areaArr;
} else {
this.searchInfo.area = [this.areaList[0][0], this.areaList[1][0], this.areaList[2][0]]
this.searchInfo.area = [areaArr[1], areaArr[2]];
}
},
async reloadData(params = {}) {
@ -244,6 +241,10 @@
this.loadOtherCityWorkerPage();
},
async loadWorkerPage(params = {}) {
if (this.searchInfo.area && this.searchInfo.area.length && this.searchInfo.area[this.searchInfo.area.length - 1].isAll) {
params.areaIds = this.searchInfo.area[this.searchInfo.area.length - 1].areaIds;
params.areaId = null;
}
params.pageNum = this.pageNum;
params.pageSize = this.pageSize;
this.$refs.loadStatusBar1.showLoading();
@ -315,38 +316,50 @@
this.categoryList.push(subSubTypeList);
},
async loadRegionList() {
let area = this.searchInfo.area && this.searchInfo.area.length ? this.searchInfo.area : null
let regionList = await this.$request.areaListByStep({
areaId: area == null ? null : area[0].areaId
});
regionList = regionList.data;
let subRegionList = [];
// let area = this.searchInfo.area && this.searchInfo.area.length ? this.searchInfo.area : null
// let regionList = await this.$request.areaListByStep({
// areaId: area == null ? null : area[0].areaId
// });
// regionList = regionList.data;
let subRegionList = [this.searchInfo.area[0]];
let subSubRegionList = [];
if (regionList && regionList.length > 0) {
let params = {};
if (area != null) {
params = {
areaId: area[1].areaId,
parentCode: area[0].areaId
}
} else {
params = {
parentCode: regionList[0].areaCode
}
}
subRegionList = await this.$request.areaListByStep(params);
subRegionList = subRegionList.data;
}
// if (regionList && regionList.length > 0) {
// let params = {};
// if (area != null) {
// params = {
// areaId: area[1].areaId,
// parentCode: area[0].areaId
// }
// } else {
// params = {
// parentCode: regionList[0].areaCode
// }
// }
// subRegionList = await this.$request.areaListByStep(params);
// subRegionList = subRegionList.data;
// }
if (subRegionList && subRegionList.length > 0) {
subSubRegionList = await this.$request.areaListByStep({
parentCode: subRegionList[0].areaCode
});
subSubRegionList = subSubRegionList.data;
let allAreaIdsOfSubSubRegionList = [];
subSubRegionList.forEach(region => {
allAreaIdsOfSubSubRegionList.push(region.areaId)
})
let subSubRegionListWithAll = [{
areaIds: allAreaIdsOfSubSubRegionList,
areaId: subRegionList[0].areaId,
isAll: true,
areaName: subRegionList[0].areaName
}].concat(subSubRegionList);
subSubRegionList = subSubRegionListWithAll;
}
this.areaList = [];
this.areaList.push(regionList);
// this.areaList.push(regionList);
this.areaList.push(subRegionList);
this.areaList.push(subSubRegionList);
this.searchInfo.area = [this.areaList[0][0], this.areaList[1][0]];
},
regionChange(e) {
this.areaMultiIndex = e.detail.value;
@ -358,35 +371,35 @@
this.searchGoods();
},
async regionColChange(e) {
let colObj = e.detail;
if (colObj.column == 0) {
//
let subAreaList = await this.$request.areaListByStep({
parentCode: this.areaList[0][colObj.value].areaCode
});
subAreaList = subAreaList.data;
let subSubAreaList = [];
if (subAreaList.length) {
subSubAreaList = await this.$request.areaListByStep({
parentCode: subAreaList[0].areaCode
});
subSubAreaList = subSubAreaList.data;
}
this.areaList.pop();
this.areaList.pop();
this.areaList.push(subAreaList);
this.areaList.push(subSubAreaList);
this.areaMultiIndex = [colObj.value, 0, 0];
} else if (colObj.column == 1) {
//
let subAreaList = await this.$request.areaListByStep({
parentCode: this.areaList[1][colObj.value].areaCode
});
subAreaList = subAreaList.data;
this.areaList.pop();
this.areaList.push(subAreaList);
this.areaMultiIndex = [this.areaMultiIndex[0], colObj.value, 0];
}
// let colObj = e.detail;
// if (colObj.column == 0) {
// //
// let subAreaList = await this.$request.areaListByStep({
// parentCode: this.areaList[0][colObj.value].areaCode
// });
// subAreaList = subAreaList.data;
// let subSubAreaList = [];
// if (subAreaList.length) {
// subSubAreaList = await this.$request.areaListByStep({
// parentCode: subAreaList[0].areaCode
// });
// subSubAreaList = subSubAreaList.data;
// }
// this.areaList.pop();
// this.areaList.pop();
// this.areaList.push(subAreaList);
// this.areaList.push(subSubAreaList);
// this.areaMultiIndex = [colObj.value, 0, 0];
// } else if (colObj.column == 1) {
// //
// let subAreaList = await this.$request.areaListByStep({
// parentCode: this.areaList[1][colObj.value].areaCode
// });
// subAreaList = subAreaList.data;
// this.areaList.pop();
// this.areaList.push(subAreaList);
// this.areaMultiIndex = [this.areaMultiIndex[0], colObj.value, 0];
// }
},
async categoryChange(e) {
this.categoryMultiIndex = e.detail.value;
@ -450,9 +463,11 @@
searchGoods() {
let params = {
goodsCategoryId: this.searchInfo.category && this.searchInfo.category.length > 1 ? this.searchInfo.category[2].goodsCategoryId : null,
areaId: this.searchInfo.area[2].areaId,
workerName: this.searchInfo.inputWorkerName
};
if (this.searchInfo.area && this.searchInfo.area.length) {
params.areaId = this.searchInfo.area[this.searchInfo.area.length - 1].areaId;
}
this.reloadData(params);
},
showShopDetail(shopInfo) {

View File

@ -23,7 +23,7 @@
:value="areaMultiIndex" :range-key="'areaName'" :range="areaList">
<view class="flex justify-start">
<view class="text-cut search-nav-item-text">
{{chosenArea && chosenArea.length ? chosenArea[2].areaName : item.title}}
{{chosenArea && chosenArea.length ? chosenArea[chosenArea.length - 1].areaName : item.title}}
</view>
<text class="text-lg"><text class="cuIcon-triangledownfill"></text></text>
</view>
@ -140,7 +140,7 @@
}],
inputGoodsName: null,
areaList: [],
areaMultiIndex: [0, 0, 0],
areaMultiIndex: [0, 0],
chosenArea: [],
categoryList: [],
categoryMultiIndex: [0, 0, 0],
@ -159,7 +159,7 @@
}
if (params.area) {
this.chosenArea = params.area;
this.taskConditions[0].value = this.chosenArea[2].areaId;
this.taskConditions[0].value = this.chosenArea[this.chosenArea.length - 1].areaId;
}
if (params.inputGoodsName) {
this.inputGoodsName = params.inputGoodsName;
@ -170,17 +170,17 @@
async loadData() {
this.pageNum = this.$globalData.initPageNum;
this.pageSize = this.$globalData.initPageSize;
this.loadCategoryList();
this.loadRegionList();
this.loadCategoryList();
//
await this.getCurAreaArr();
await this.getCurAreaArr();
await this.loadRegionList();
this.loadProductData();
},
async getCurAreaArr() {
let areaArr = await this.$request.getCurArea();
if (areaArr) {
this.chosenArea = areaArr;
this.taskConditions[0].value = this.chosenArea[2].areaId;
this.chosenArea = [areaArr[1], areaArr[2]];
this.taskConditions[0].value = this.chosenArea[this.chosenArea.length - 1].areaId;
}
},
async loadProductData(params = {}) {
@ -195,7 +195,11 @@
params.params = params.params ? params.params : {};
params.params[condition.code] = condition.value === 1 ? 'desc' : 'asc';
}
})
})
if (this.chosenArea[this.chosenArea.length - 1].isAll) {
params.areaId = null;
params.areaIds = this.chosenArea[this.chosenArea.length - 1].areaIds;
}
this.loadMoreStatus = 'loading bg-main-color light';
this.hasMoreData = false;
try {
@ -256,25 +260,38 @@
this.categoryList.push(subSubTypeList);
},
async loadRegionList() {
let regionList = await this.$request.areaListByStep();
regionList = regionList.data;
let subRegionList = [];
// let regionList = await this.$request.areaListByStep();
// regionList = regionList.data;
let subRegionList = [this.chosenArea[0]];
let subSubRegionList = [];
if (regionList && regionList.length > 0) {
subRegionList = await this.$request.areaListByStep({
parentCode: regionList[0].areaCode
});
subRegionList = subRegionList.data;
}
// if (regionList && regionList.length > 0) {
// subRegionList = await this.$request.areaListByStep({
// parentCode: regionList[0].areaCode
// });
// subRegionList = subRegionList.data;
// }
if (subRegionList && subRegionList.length > 0) {
subSubRegionList = await this.$request.areaListByStep({
parentCode: subRegionList[0].areaCode
});
subSubRegionList = subSubRegionList.data;
subSubRegionList = await this.$request.areaListByStep({
parentCode: subRegionList[0].areaCode
});
subSubRegionList = subSubRegionList.data;
let allAreaIdsOfSubSubRegionList = [];
subSubRegionList.forEach(region => {
allAreaIdsOfSubSubRegionList.push(region.areaId)
})
let subSubRegionListWithAll = [{
areaIds: allAreaIdsOfSubSubRegionList,
areaId: subRegionList[0].areaId,
isAll: true,
areaName: subRegionList[0].areaName
}].concat(subSubRegionList);
subSubRegionList = subSubRegionListWithAll;
}
this.areaList.push(regionList);
// this.areaList.push(regionList);
this.areaList.push(subRegionList);
this.areaList.push(subSubRegionList);
this.areaList.push(subSubRegionList);
this.chosenArea = [this.areaList[0][0], this.areaList[1][0]];
this.taskConditions[0].value = this.chosenArea[this.chosenArea.length - 1].areaId;
},
searchGoods() {
this.reloadProductPage();
@ -323,29 +340,29 @@
this.searchGoods();
},
async regionColChange(e) {
let colObj = e.detail;
if (colObj.column == 0) {
//
let subAreaList = await this.$request.areaListByStep({parentCode: this.areaList[0][colObj.value].areaCode});
subAreaList = subAreaList.data;
let subSubAreaList = [];
if (subAreaList.length) {
subSubAreaList = await this.$request.areaListByStep({parentCode: subAreaList[0].areaCode});
subSubAreaList = subSubAreaList.data;
}
this.areaList.pop();
this.areaList.pop();
this.areaList.push(subAreaList);
this.areaList.push(subSubAreaList);
this.areaMultiIndex = [colObj.value, 0, 0];
} else if (colObj.column == 1) {
//
let subAreaList = await this.$request.areaListByStep({parentCode: this.areaList[1][colObj.value].areaCode});
subAreaList = subAreaList.data;
this.areaList.pop();
this.areaList.push(subAreaList);
this.areaMultiIndex = [this.areaMultiIndex[0], colObj.value, 0];
}
// let colObj = e.detail;
// if (colObj.column == 0) {
// //
// let subAreaList = await this.$request.areaListByStep({parentCode: this.areaList[0][colObj.value].areaCode});
// subAreaList = subAreaList.data;
// let subSubAreaList = [];
// if (subAreaList.length) {
// subSubAreaList = await this.$request.areaListByStep({parentCode: subAreaList[0].areaCode});
// subSubAreaList = subSubAreaList.data;
// }
// this.areaList.pop();
// this.areaList.pop();
// this.areaList.push(subAreaList);
// this.areaList.push(subSubAreaList);
// this.areaMultiIndex = [colObj.value, 0, 0];
// } else if (colObj.column == 1) {
// //
// let subAreaList = await this.$request.areaListByStep({parentCode: this.areaList[1][colObj.value].areaCode});
// subAreaList = subAreaList.data;
// this.areaList.pop();
// this.areaList.push(subAreaList);
// this.areaMultiIndex = [this.areaMultiIndex[0], colObj.value, 0];
// }
},
async categoryChange(e) {
this.categoryMultiIndex = e.detail.value;

View File

@ -11,7 +11,7 @@
<view class="cu-avatar round"
:style="'background-image:url(' + shopInfo.workerLogoUrl + '); width: 130rpx; height: 130rpx;'">
</view>
<view class="margin-left-sm flex-column-between">
<view class="margin-left-sm flex-column-between text-beside-avatar">
<view class="text-black text-xl">{{shopInfo.name}}</view>
<view>
<view>
@ -77,7 +77,7 @@
<picker :mode="'multiSelector'" @change="regionChange" @columnchange="regionColChange"
:value="areaMultiIndex" :range-key="'areaName'" :range="areaList">
<text class="cuIcon-location"></text>
<text>{{searchInfo.area && searchInfo.area.length ? searchInfo.area[2].areaName : areaList[2][0].areaName}}</text>
<text>{{searchInfo.area && searchInfo.area.length ? searchInfo.area[1].areaName : areaList[1][0].areaName}}</text>
</picker>
</view>
<view class="search-form round">
@ -127,7 +127,7 @@
}],
searchInfo: {},
areaList: [],
areaMultiIndex: [0, 0, 0],
areaMultiIndex: [0, 0],
categoryList: [],
stickyTop: this.CustomBar
}
@ -144,17 +144,15 @@
})
this.shopInfo = res.data;
this.loadCategoryList();
await this.loadRegionList();
//
await this.getCurAreaArr();
await this.loadRegionList();
this.searchGoods();
},
async getCurAreaArr() {
let areaArr = await this.$request.getCurArea();
if (areaArr) {
this.searchInfo.area = areaArr;
} else {
this.searchInfo.area = [this.areaList[0][0], this.areaList[1][0], this.areaList[2][0]];
this.searchInfo.area = [areaArr[1], areaArr[2]];
}
},
async loadProductData(params = {}) {
@ -162,6 +160,10 @@
status: 0,
...params
}
if (this.searchInfo.area[this.searchInfo.area.length - 1].isAll) {
params.areaId = null;
params.areaIds = this.searchInfo.area[this.searchInfo.area.length - 1].areaIds;
}
let res = await this.$request.qryProductPage(params);
this.productList = res[1].data.rows;
},
@ -183,25 +185,37 @@
this.categoryList.push(subSubTypeList);
},
async loadRegionList() {
let regionList = await this.$request.areaListByStep();
regionList = regionList.data;
let subRegionList = [];
// let regionList = await this.$request.areaListByStep();
// regionList = regionList.data;
let subRegionList = [this.searchInfo.area[0]];
let subSubRegionList = [];
if (regionList && regionList.length > 0) {
subRegionList = await this.$request.areaListByStep({
parentCode: regionList[0].areaCode
});
subRegionList = subRegionList.data;
}
// if (regionList && regionList.length > 0) {
// subRegionList = await this.$request.areaListByStep({
// parentCode: regionList[0].areaCode
// });
// subRegionList = subRegionList.data;
// }
if (subRegionList && subRegionList.length > 0) {
subSubRegionList = await this.$request.areaListByStep({
parentCode: subRegionList[0].areaCode
});
subSubRegionList = subSubRegionList.data;
let allAreaIdsOfSubSubRegionList = [];
subSubRegionList.forEach(region => {
allAreaIdsOfSubSubRegionList.push(region.areaId)
})
let subSubRegionListWithAll = [{
areaIds: allAreaIdsOfSubSubRegionList,
areaId: subRegionList[0].areaId,
isAll: true,
areaName: subRegionList[0].areaName
}].concat(subSubRegionList);
subSubRegionList = subSubRegionListWithAll;
}
this.areaList.push(regionList);
// this.areaList.push(regionList);
this.areaList.push(subRegionList);
this.areaList.push(subSubRegionList);
this.searchInfo.area = [this.areaList[0][0], this.areaList[1][0]];
},
regionChange(e) {
this.areaMultiIndex = e.detail.value;
@ -213,39 +227,39 @@
this.searchGoods();
},
async regionColChange(e) {
let colObj = e.detail;
if (colObj.column == 0) {
//
let subAreaList = await this.$request.areaListByStep({
parentCode: this.areaList[0][colObj.value].areaCode
});
subAreaList = subAreaList.data;
let subSubAreaList = [];
if (subAreaList.length) {
subSubAreaList = await this.$request.areaListByStep({
parentCode: subAreaList[0].areaCode
});
subSubAreaList = subSubAreaList.data;
}
this.areaList.pop();
this.areaList.pop();
this.areaList.push(subAreaList);
this.areaList.push(subSubAreaList);
this.areaMultiIndex = [colObj.value, 0, 0];
} else if (colObj.column == 1) {
//
let subAreaList = await this.$request.areaListByStep({
parentCode: this.areaList[1][colObj.value].areaCode
});
subAreaList = subAreaList.data;
this.areaList.pop();
this.areaList.push(subAreaList);
this.areaMultiIndex = [this.areaMultiIndex[0], colObj.value, 0];
}
// let colObj = e.detail;
// if (colObj.column == 0) {
// //
// let subAreaList = await this.$request.areaListByStep({
// parentCode: this.areaList[0][colObj.value].areaCode
// });
// subAreaList = subAreaList.data;
// let subSubAreaList = [];
// if (subAreaList.length) {
// subSubAreaList = await this.$request.areaListByStep({
// parentCode: subAreaList[0].areaCode
// });
// subSubAreaList = subSubAreaList.data;
// }
// this.areaList.pop();
// this.areaList.pop();
// this.areaList.push(subAreaList);
// this.areaList.push(subSubAreaList);
// this.areaMultiIndex = [colObj.value, 0, 0];
// } else if (colObj.column == 1) {
// //
// let subAreaList = await this.$request.areaListByStep({
// parentCode: this.areaList[1][colObj.value].areaCode
// });
// subAreaList = subAreaList.data;
// this.areaList.pop();
// this.areaList.push(subAreaList);
// this.areaMultiIndex = [this.areaMultiIndex[0], colObj.value, 0];
// }
},
searchGoods() {
let params = {
areaId: this.searchInfo.area[2].areaId,
areaId: this.searchInfo.area[this.searchInfo.area.length - 1].areaId,
goodsName: this.searchInfo.goodsName,
workerId: this.shopInfo.workerId
};
@ -267,6 +281,8 @@
}
</script>
<style>
<style scoped>
.text-beside-avatar {
width: 75%;
}
</style>