From 90d85ca1b7f48b930d5b46966963aa0c4cbf0dc4 Mon Sep 17 00:00:00 2001 From: donqi Date: Wed, 18 May 2022 01:08:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=88=E5=82=85=E5=85=A5=E9=A9=BB=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=EF=BC=8C=E5=AE=8C=E6=88=90=E4=B8=89=E5=88=86=E4=B9=8B?= =?UTF-8?q?=E4=B8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/js/request.js | 16 +- components/uni-combox/my-uni-combox.vue | 16 +- main.js | 6 +- pages.json | 23 +-- pages/index/index.vue | 2 +- pages/my/master-occupancy.vue | 189 ++++++++++++++++++++++++ pages/my/new-serv.vue | 36 ++++- style/blue/blue-topic.css | 6 +- 8 files changed, 266 insertions(+), 28 deletions(-) create mode 100644 pages/my/master-occupancy.vue diff --git a/common/js/request.js b/common/js/request.js index 2d8dd10..955de79 100644 --- a/common/js/request.js +++ b/common/js/request.js @@ -7,9 +7,11 @@ export default { uni.addInterceptor('request', { invoke(args) { // request 触发前拼接 url - // args.url = 'http://www.opsoul.com' + args.url; - args.url = 'https://www.opsoul.com' + args.url; - args.data.deptId = globalData.deptId + // args.url = 'https://www.opsoul.com' + args.url; + args.url = 'http://127.0.0.1:80' + args.url; + if (args.data) { + args.data.deptId = globalData.deptId; + } // console.log("停止触发"); // return false; }, @@ -138,5 +140,13 @@ export default { data: params }) return res[1].data; + }, + async areaListByStep(params = { parentCode: null }) { + let res = await uni.request({ + url: '/system/area/list', + method: 'POST', + data: params + }) + return res[1].data; } } diff --git a/components/uni-combox/my-uni-combox.vue b/components/uni-combox/my-uni-combox.vue index 98ec755..7c4afe8 100644 --- a/components/uni-combox/my-uni-combox.vue +++ b/components/uni-combox/my-uni-combox.vue @@ -4,8 +4,8 @@ {{label}} - @@ -18,7 +18,7 @@ - {{item.name}} + {{item[showField]}} @@ -63,19 +63,23 @@ return [] } }, + showField: { + type: String, + default: 'name' + }, emptyTips: { type: String, default: '无匹配项' }, // #ifndef VUE3 value: { - type: [String, Number], + type: [Object, String, Number], default: '' }, // #endif // #ifdef VUE3 modelValue: { - type: [String, Number], + type: [Object, String, Number], default: '' }, // #endif @@ -138,7 +142,7 @@ this.inputVal = this.filterCandidates[index] this.showSelector = false this.$emit('input', this.inputVal) - this.$emit('update:modelValue', this.inputVal.name) + this.$emit('update:modelValue', this.inputVal[this.showField]) }, onInput() { setTimeout(() => { diff --git a/main.js b/main.js index bbc7fd7..0207f64 100644 --- a/main.js +++ b/main.js @@ -8,7 +8,8 @@ import globalFun from './common/js/glogalFun.js'; import validate from './common/js/validate.js'; import dateUtil from './common/js/dateUtil.js'; import commonFun from './common/js/commonFun.js'; -import request from './common/js/request.js'; +import request from './common/js/request.js'; +import globalData from './common/js/globalData.js'; Vue.component('cu-custom', CuCustom) Vue.component('confirm-modal', ConfirmModal); @@ -21,7 +22,8 @@ const data = type => { request.addInterceptor(); Vue.prototype.$api = { data -} +} +Vue.prototype.$globalData = globalData; Vue.prototype.$globalFun = globalFun; Vue.prototype.$validate = validate; Vue.prototype.$dateUtil = dateUtil; diff --git a/pages.json b/pages.json index d8f57e2..fc04042 100644 --- a/pages.json +++ b/pages.json @@ -1,6 +1,7 @@ { "pages": [{ - "path": "pages/index/index" + // "path": "pages/index/index" + "path": "pages/my/master-occupancy" }], "subPackages": [{ "root": "pages/area-proxy/", @@ -25,14 +26,18 @@ }, { "path": "finish-order" }] - }, { - "root": "pages/my/", - "pages": [{ - "path": "new-serv" - }, { - "path": "goods-manage" - }] - }], + } + // { + // "root": "pages/my/", + // "pages": [{ + // "path": "new-serv" + // }, { + // "path": "goods-manage" + // }, { + // "path": "master-occupancy" + // }] + // } + ], "globalStyle": { "navigationStyle": "custom", "navigationBarTextStyle": "black" diff --git a/pages/index/index.vue b/pages/index/index.vue index 577b9df..2ac23ac 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -20,7 +20,7 @@ data() { return { moduleBarInfos: [], - curPageCode: 'myPage' + curPageCode: 'indexPage' } }, onLoad() { diff --git a/pages/my/master-occupancy.vue b/pages/my/master-occupancy.vue new file mode 100644 index 0000000..0db228a --- /dev/null +++ b/pages/my/master-occupancy.vue @@ -0,0 +1,189 @@ + + + + + diff --git a/pages/my/new-serv.vue b/pages/my/new-serv.vue index 3fac867..6e29718 100644 --- a/pages/my/new-serv.vue +++ b/pages/my/new-serv.vue @@ -83,8 +83,8 @@ 上架区域 - - + @@ -92,7 +92,7 @@ - {{item.name}} + {{item.areaName}} @@ -212,9 +212,10 @@ methods: { async loadData(goodId) { this.loadCategoryList(); + this.loadRegionList(); // TODO 如果存在goodId说明是修改,需要查询good信息进行回显 // this.categoryList = await this.$api.data('categoryList'); - this.regionList = await this.$api.data('regionList'); + // this.regionList = await this.$api.data('regionList'); }, async loadCategoryList(idArr) { let typeList = await this.$request.listByStep(); @@ -229,6 +230,17 @@ this.categoryList.push(subTypeList); this.categoryList.push(subSubTypeList); }, + async loadRegionList() { + let regionList = await this.$request.areaListByStep(); + regionList = regionList.data; + let subRegionList = []; + if (regionList && regionList.length > 0) { + subRegionList = await this.$request.areaListByStep({ parentCode: regionList[0].areaCode }); + subRegionList = subRegionList.data; + } + this.regionList.push(regionList); + this.regionList.push(subRegionList); + }, async categoryChange(e) { this.categoryMultiIndex = e.detail.value; let chosenCategory = []; @@ -269,7 +281,20 @@ } this.formData.region = chosenRegion; - this.formData.districtList = await this.$api.data('districtList'); + // 查询最后一级区域 + let areaList = await this.$request.areaListByStep({parentCode: chosenRegion[1].areaCode}); + this.formData.districtList = areaList.data; + }, + async regionColChange(e) { + let colObj = e.detail; + if (colObj.column == 0) { + // 通过二级查三级 + let subAreaList = await this.$request.areaListByStep({parentCode: this.regionList[0][colObj.value].areaCode}); + subAreaList = subAreaList.data; + this.regionList.pop(); + this.regionList.push(subAreaList); + this.regionMultiIndex = [colObj.value, 0]; + } }, checkSpecs(e) { let checkedIndexArr = e.detail.value; @@ -296,7 +321,6 @@ this.formData.districtList[i].checked = false; } } - console.log(this.formData) }, chooseImgList(e) { uni.chooseImage({ diff --git a/style/blue/blue-topic.css b/style/blue/blue-topic.css index 1a63859..cfaec91 100644 --- a/style/blue/blue-topic.css +++ b/style/blue/blue-topic.css @@ -1,3 +1,7 @@ +.bg-back { + background-color: #f5f5f5; +} + .line-default { color: #aaaaaa; } @@ -39,6 +43,6 @@ radio.main-color.checked .uni-radio-input { } .cu-list.menu>.cu-item.bg-main-color.light { - color: #0081ff; + color: #0081ff; background-color: #cce6ff; }