首页定位拒绝情况处理;产品列表,师傅圈默认展示当前市的,然后用户只能选择当前市的以及当前市下的区进行筛选
This commit is contained in:
parent
29eb03800e
commit
dbf467b928
|
|
@ -78,6 +78,20 @@ 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()
|
||||
}
|
||||
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()
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@
|
|||
"scope.userLocation" : {
|
||||
"desc" : "因涉及上门家政服务,需获取地理位置"
|
||||
}
|
||||
}
|
||||
},
|
||||
"requiredPrivateInfos": ["getLocation"]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
@ -117,6 +117,19 @@
|
|||
<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,16 +176,15 @@
|
|||
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({
|
||||
type: 1
|
||||
|
|
@ -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();
|
||||
|
|
@ -245,11 +328,23 @@
|
|||
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;
|
||||
|
|
@ -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;
|
||||
|
|
@ -340,7 +435,6 @@
|
|||
})
|
||||
},
|
||||
clickHotCategory(item) {
|
||||
console.log(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;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -171,16 +171,16 @@
|
|||
this.pageNum = this.$globalData.initPageNum;
|
||||
this.pageSize = this.$globalData.initPageSize;
|
||||
this.loadCategoryList();
|
||||
this.loadRegionList();
|
||||
// 获取当前定位
|
||||
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 = {}) {
|
||||
|
|
@ -196,6 +196,10 @@
|
|||
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;
|
||||
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.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;
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
Loading…
Reference in New Issue