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

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,20 @@ export default {
areaRes = areaRes.data; areaRes = areaRes.data;
if (areaRes) { if (areaRes) {
let areaArr = [areaRes.provinceArea, areaRes.cityArea, areaRes.countryArea]; 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 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 = { let curLocation = {
area: areaArr, area: areaArr,
updateTimes: new Date().getTime() updateTimes: new Date().getTime()

View File

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

View File

@ -27,7 +27,7 @@
<view class="action"> <view class="action">
<picker :mode="'multiSelector'" @change="regionChange" @columnchange="regionColChange" <picker :mode="'multiSelector'" @change="regionChange" @columnchange="regionColChange"
:value="areaMultiIndex" :range-key="'areaName'" :range="areaList"> :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> <text class="cuIcon-location"></text>
</picker> </picker>
</view> </view>
@ -117,6 +117,19 @@
<load-status-bar ref="loadStatusBar2" @loadMore="loadOtherCityProductPage"></load-status-bar> <load-status-bar ref="loadStatusBar2" @loadMore="loadOtherCityProductPage"></load-status-bar>
</view> </view>
</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> </view>
</template> </template>
@ -146,13 +159,14 @@
InputBottom: 0, InputBottom: 0,
searchInfo: {}, searchInfo: {},
areaList: [], areaList: [],
areaMultiIndex: [0, 0, 0], areaMultiIndex: [0, 0],
productList: [], productList: [],
otherCityProductList: [], otherCityProductList: [],
pageNum: 0, pageNum: 0,
pageSize: 0, pageSize: 0,
otherCityProductPageNum: 0, otherCityProductPageNum: 0,
otherCityProductPageSize: 0 otherCityProductPageSize: 0,
isShowPrivSetting: false
} }
}, },
mounted() { mounted() {
@ -162,16 +176,15 @@
this.offBindEvent(); this.offBindEvent();
}, },
async onReady() { async onReady() {
await this.$request.authAndGetLocation(); // await this.$request.authAndGetLocation();
await this.loadData(); //
await this.getCurAreaArr();
}, },
methods: { methods: {
async loadData() { async loadData() {
this.initBasicData(); this.initBasicData();
// //
await this.loadRegionList(); await this.loadRegionList();
await this.getCurAreaArr();
await this.loadRegionList();
// //
let hotServCategoryRes = await this.$request.getHotCategory({ let hotServCategoryRes = await this.$request.getHotCategory({
type: 1 type: 1
@ -202,15 +215,85 @@
offBindEvent() { offBindEvent() {
uni.$off('clickCard'); uni.$off('clickCard');
}, },
async getCurAreaArr() { async authLocationCallback(res) {
let areaArr = await this.$request.getCurArea(); if (res.detail.authSetting['scope.userLocation']) {
if (areaArr) { this.isShowPrivSetting = false;
this.searchInfo.area = areaArr; await this.getCurAreaArr();
} }
// else { },
// // async wxGetLocation() {
// this.searchInfo.area = [this.areaList[0][0], this.areaList[1][0], this.areaList[2][0]]; 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() { async loadCategoryList() {
let res = await this.$request.getProductCategories(); let res = await this.$request.getProductCategories();
@ -245,11 +328,23 @@
parentCode: subRegionList[0].areaCode 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 = [];
this.areaList.push(regionList); // this.areaList.push(regionList);
this.areaList.push(subRegionList); 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) { regionChange(e) {
this.areaMultiIndex = e.detail.value; this.areaMultiIndex = e.detail.value;
@ -261,35 +356,35 @@
this.reloadProductPage(); this.reloadProductPage();
}, },
async regionColChange(e) { async regionColChange(e) {
let colObj = e.detail; // let colObj = e.detail;
if (colObj.column == 0) { // if (colObj.column == 0) {
// // //
let subAreaList = await this.$request.areaListByStep({ // let subAreaList = await this.$request.areaListByStep({
parentCode: this.areaList[0][colObj.value].areaCode // parentCode: this.areaList[0][colObj.value].areaCode
}); // });
subAreaList = subAreaList.data; // subAreaList = subAreaList.data;
let subSubAreaList = []; // let subSubAreaList = [];
if (subAreaList.length) { // if (subAreaList.length) {
subSubAreaList = await this.$request.areaListByStep({ // subSubAreaList = await this.$request.areaListByStep({
parentCode: subAreaList[0].areaCode // parentCode: subAreaList[0].areaCode
}); // });
subSubAreaList = subSubAreaList.data; // subSubAreaList = subSubAreaList.data;
} // }
this.areaList.pop(); // this.areaList.pop();
this.areaList.pop(); // this.areaList.pop();
this.areaList.push(subAreaList); // this.areaList.push(subAreaList);
this.areaList.push(subSubAreaList); // this.areaList.push(subSubAreaList);
this.areaMultiIndex = [colObj.value, 0, 0]; // this.areaMultiIndex = [colObj.value, 0, 0];
} else if (colObj.column == 1) { // } else if (colObj.column == 1) {
// // //
let subAreaList = await this.$request.areaListByStep({ // let subAreaList = await this.$request.areaListByStep({
parentCode: this.areaList[1][colObj.value].areaCode // parentCode: this.areaList[1][colObj.value].areaCode
}); // });
subAreaList = subAreaList.data; // subAreaList = subAreaList.data;
this.areaList.pop(); // this.areaList.pop();
this.areaList.push(subAreaList); // this.areaList.push(subAreaList);
this.areaMultiIndex = [this.areaMultiIndex[0], colObj.value, 0]; // this.areaMultiIndex = [this.areaMultiIndex[0], colObj.value, 0];
} // }
}, },
async tabSelect(e, item) { async tabSelect(e, item) {
this.tabCur = e == null ? 0 : e.currentTarget.dataset.index; this.tabCur = e == null ? 0 : e.currentTarget.dataset.index;
@ -340,7 +435,6 @@
}) })
}, },
clickHotCategory(item) { clickHotCategory(item) {
console.log(item)
let params = { let params = {
category: item category: item
}; };
@ -378,6 +472,11 @@
async loadProductPage(params = { async loadProductPage(params = {
areaId: this.searchInfo.area && this.searchInfo.area.length ? this.searchInfo.area[this.searchInfo.area.length - 1].areaId : null 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") { }, 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.pageNum = this[pageNumName];
params.pageSize = this[pageSizeName]; params.pageSize = this[pageSizeName];
params.status = 0; params.status = 0;

View File

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

View File

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

View File

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