diff --git a/components/region-address.vue b/components/region-address.vue new file mode 100644 index 0000000..923aeeb --- /dev/null +++ b/components/region-address.vue @@ -0,0 +1,144 @@ + + + + + diff --git a/config/order.js b/config/order.js index 7c18bb4..aa2d8a1 100644 --- a/config/order.js +++ b/config/order.js @@ -54,3 +54,7 @@ export const upgradeOrder = data => // 确认收货 export const confirmReceipt = orderCode => http.put(`/sale/api/my-order/confirm/${orderCode}`) + +// 获取注册升级区域列表 +export const getRegionAreaList = params => + http.get('/retail-member/api/retail-member/query-region', { params }) diff --git a/config/request.js b/config/request.js index 7c691d2..a7de8a3 100644 --- a/config/request.js +++ b/config/request.js @@ -20,7 +20,7 @@ module.exports = vm => { //#ifdef DEV_SERVER console.log('DEV_SERVER') - config.baseURL = 'http://192.168.0.104:8080' + config.baseURL = 'http://192.168.0.86:8080' //#endif //#ifdef QA_SERVER diff --git a/pages/commonMixins/regionSelect.js b/pages/commonMixins/regionSelect.js new file mode 100644 index 0000000..f9f75eb --- /dev/null +++ b/pages/commonMixins/regionSelect.js @@ -0,0 +1,64 @@ +import { getRegionAreaList } from '@/config/order.js' + +export default { + data() { + return { + regionList: [], + provinceList: [], + cityList: [], + countyList: [], + regionCity: '', + regionProvince: '', + regionCounty: '', + gradeValue: null, + defaultRegionSelectCode: [], + } + }, + computed: {}, + methods: { + getRegionAreaList(gradeValue) { + if (!gradeValue) return + this.gradeValue = gradeValue + const params = { + type: 'county', + } + getRegionAreaList(params).then(res => { + this.provinceList = res.data.filter(item => item.parent === 0) + this.cityList = res.data.filter(item => + this.provinceList.find(province => province.pkId === item.parent) + ) + this.countyList = res.data.filter(item => + this.cityList.find(city => city.pkId === item.parent) + ) + this.getProvinceFilterList() + this.getCityFilterList() + this.getCountyFilterList() + }) + }, + getProvinceFilterList() { + if (!this.cityList.length) { + this.provinceList = [] + } + this.provinceList = this.provinceList.filter( + item => !!this.cityList.find(city => city.parent === item.pkId) + ) + }, + getCityFilterList() { + if (this.gradeValue === 80) return + if (!this.countyList.length) { + this.cityList = [] + } + this.cityList = this.cityList.filter( + item => !!this.countyList.find(county => county.parent === item.pkId) + ) + }, + getCountyFilterList() { + if (!this.gradeValue || this.gradeValue === 80) { + this.countyList = [] + } + }, + }, + onShow() { + // this.getRegionAreaList() + }, +} diff --git a/pages/regiest/index.vue b/pages/regiest/index.vue index 2ad3a92..d9aa7c2 100644 --- a/pages/regiest/index.vue +++ b/pages/regiest/index.vue @@ -10,6 +10,27 @@ disabled /> + + + + {{ regionAddress.map(item => item.name).join('-') }} + + 请选择区域 + + + + + @@ -415,14 +443,19 @@ import { REPURCHASE_AREA, REISSUE_AREA, } from '@/util/specialAreaMap' +import regionSelect from '@/pages/commonMixins/regionSelect' +import RegionAddress from '@/components/region-address.vue' export default { + mixins: [regionSelect], components: { 'v-address': address, mustAgreeMent, agreement, + RegionAddress, }, data() { return { + regionAddress: [], isDeliveryWay: true, pt: false, isDp: false, @@ -433,6 +466,7 @@ export default { defaultCode: [], moren: '', addressList: [], + userInfo: uni.getStorageSync('User'), deliList: [], transList: [], queryCardList: [], @@ -444,7 +478,6 @@ export default { isTrans: false, countryIndex: 0, isCountry: false, - userInfo: '', countryList: [], isClick: 0, specialArea: '', @@ -574,6 +607,7 @@ export default { }, delId: '', selTable: [], + gradeValue: '', } }, computed: { @@ -618,8 +652,6 @@ export default { this.getPageList() // 幂等性 this.getGenerate() - // 登录信息 - this.userInfo = uni.getStorageSync('User') this.setPageTitle(this.specialArea) }, onShow() { @@ -627,6 +659,14 @@ export default { this.getAddressList() }, methods: { + regionSelectHandle() { + console.log(this.provinceList, '....pkId') + this.$refs.regionAddress.setShow(this.provinceList[0].pkId) + }, + setRegionAddress(area) { + console.log(area, '....area') + this.regionAddress = area + }, setPageTitle(areaId) { const areaList = [ REGIEST_AREA, @@ -788,6 +828,10 @@ export default { if (res.code == 200) { if (res.data.isEnough) { this.form.pkGradeVal = res.data.pkGradeVal + if ([60, 70, 80].includes(res.data.gradeValue)) { + this.gradeValue = res.data.gradeValue + this.getRegionAreaList(res.data.gradeValue) + } } else { this.form.pkGradeVal = '' uni.showToast({ @@ -1144,6 +1188,19 @@ export default { }) }, goBuy() { + const extParams = {} + if ([60, 70, 80].includes(this.gradeValue) && this.provinceList.length) { + if (!this.regionAddress.length) { + uni.showToast({ + title: '请选择会员区域', + icon: 'none', + }) + return + } + extParams.regionProvince = this.regionAddress[0]?.pkId || -1 + extParams.regionCity = this.regionAddress[1]?.pkId || -1 + extParams.regionCounty = this.regionAddress[2]?.pkId || -1 + } this.$refs.uForm.validate().then(res => { this.isLoading = true let deleteList = [] diff --git a/pages/upgrade/index.vue b/pages/upgrade/index.vue index 08d21b9..66f5923 100644 --- a/pages/upgrade/index.vue +++ b/pages/upgrade/index.vue @@ -674,6 +674,7 @@ export default { } api.memLevel(params).then(res => { if (res.code == 200) { + console.log(res.data, 'res.data.memLevel') if (res.data.isEnough) { this.form.pkGradeVal = res.data.pkGradeVal } else {