diff --git a/components/tab-bar/myCenter.vue b/components/tab-bar/myCenter.vue index 3fc5b3c..fd64c1d 100644 --- a/components/tab-bar/myCenter.vue +++ b/components/tab-bar/myCenter.vue @@ -6,10 +6,12 @@ 兼职主页-{{workerCounts}} 钱包余额 ¥{{balance}} 我的订单 + 切换校区放到设置中 - + @@ -26,6 +28,17 @@ + + + + + 请选择所属区域 + + + {{item.title}} + + + @@ -33,46 +46,49 @@ export default { data() { return { - schoolShop:[], - workerCounts:0, - shopCounts:0, - balance:0, - worker:uni.getStorageSync('worker') + areaList:[], + schoolShop: [], + workerCounts: 0, + shopCounts: 0, + balance: 0, + worker: uni.getStorageSync('worker') } }, - props:{ - + props: { + }, watch: { - + }, methods: { - init(){ - + init() { + this.schoolShop = uni.getStorageSync('schoolShop') this.worker = uni.getStorageSync('worker') let shopId = uni.getStorageSync('shopId') let worker = uni.getStorageSync('worker') this.workerCounts = 0 this.shopCounts = 0 - if(worker){ + if (worker) { this.workerCounts = uni.getStorageSync('workerCounts') } - if(shopId){ + if (shopId) { this.shopCounts = uni.getStorageSync('shopCounts') } this.balance = 0 - this.tui.request("/worker/getAllDepo/", "GET", {userId:uni.getStorageSync('id')}, false, true).then((res) => { + this.tui.request("/worker/getAllDepo/", "GET", { + userId: uni.getStorageSync('id') + }, false, true).then((res) => { if (res.code == 200) { - if(res.result.user){ + if (res.result.user) { this.balance += Number(res.result.user.depoBal) } - if(res.result.worker){ + if (res.result.worker) { this.balance += Number(res.result.worker.depoBal) this.balance += Number(res.result.worker.depoBalRel) } - if(res.result.shop){ - for(let i = 0; i < res.result.shop.length;i++){ + if (res.result.shop) { + for (let i = 0; i < res.result.shop.length; i++) { this.balance += Number(res.result.shop[i].balance) } } @@ -84,42 +100,59 @@ uni.hideLoading() }).catch((res) => {}) }, - clickShop(item){ - uni.setStorageSync('shopId',item.id) - uni.setStorageSync('shopName',item.shopName) - uni.setStorageSync('shopIcon',item.shopIcon) - uni.setStorageSync('shopScore',item.shopScore) - uni.setStorageSync('shopTakeaway',item.shopTakeaway) - uni.setStorageSync('attrId',item.attrId) + clickShop(item) { + uni.setStorageSync('shopId', item.id) + uni.setStorageSync('shopName', item.shopName) + uni.setStorageSync('shopIcon', item.shopIcon) + uni.setStorageSync('shopScore', item.shopScore) + uni.setStorageSync('shopTakeaway', item.shopTakeaway) + + uni.setStorageSync('attrId', item.attrId) + this.$refs.shopPopup.close() uni.navigateTo({ url: '/package2/shop/merchantCenter' }) }, - navigatorTo(e,index){ + checkArea() { + this.tui.request("/app/shopArea/getByParentId/0", "get", {}, false, false).then((res) => { + if (res.code == 200) { + this.areaList = res.result + this.$refs.areaPopup.open() + } else { + this.tui.toast(res.message) + } + }) + }, + onClickArea(item) { + uni.setStorageSync('area', JSON.stringify(item)) + this.tui.toast('切换成功') + this.$refs.areaPopup.close() + }, + navigatorTo(e, index) { let url = "" - if(e=='addgoods'){ + if (e == 'addgoods') { url = '/package2/myCenter/addGoods' - }else if(e=='merchantCenter'){ - if(this.schoolShop){ - if(this.schoolShop.length>1){ + } else if (e == 'merchantCenter') { + if (this.schoolShop) { + if (this.schoolShop.length > 1) { this.$refs.shopPopup.open() return - }else if(this.schoolShop != ''){ - uni.setStorageSync('shopId',this.schoolShop[0].id) - uni.setStorageSync('attrId',this.schoolShop[0].attrId) - uni.setStorageSync('shopName',this.schoolShop[0].shopName) - uni.setStorageSync('shopIcon',this.schoolShop[0].shopIcon) - uni.setStorageSync('shopScore',this.schoolShop[0].shopScore) - uni.setStorageSync('shopTakeaway',this.schoolShop[0].shopTakeaway) + } else if (this.schoolShop != '') { + uni.setStorageSync('shopId', this.schoolShop[0].id) + uni.setStorageSync('attrId', this.schoolShop[0].attrId) + uni.setStorageSync('shopName', this.schoolShop[0].shopName) + uni.setStorageSync('shopIcon', this.schoolShop[0].shopIcon) + uni.setStorageSync('shopScore', this.schoolShop[0].shopScore) + uni.setStorageSync('shopTakeaway', this.schoolShop[0].shopTakeaway) url = '/package2/shop/merchantCenter' } - }else{ + } else { uni.showModal({ title: '提示', content: '您还没有注册成为商家,要去注册吗?', - cancelText:'暂时不了', - confirmText:'去注册', - success: function (res) { + cancelText: '暂时不了', + confirmText: '去注册', + success: function(res) { if (res.confirm) { url = '/package2/shop/merchantRegister' uni.navigateTo({ @@ -128,34 +161,41 @@ } } }); - + } - - }else if(e=='dingdan'){ + + } else if (e == 'dingdan') { url = '/package1/order/orderList' - }else if(e=='addType'){ + } else if (e == 'addType') { url = '/package2/myCenter/addType' - }else if(e=='qianbao'){ + } else if (e == 'qianbao') { url = '/package2/myCenter/wallet' - }else if(e=='goodsList'){ - url = '/package2/myCenter/goodsList' - }else if(e=='merchant'){ + } else if (e == 'goodsList') { + url = '/package2/myCenter/goodsList' + } else if (e == 'merchant') { url = '/package2/shop/merchantRegister' - }else if(e=='jianzhichaping'){ + } else if (e == 'qiehuan') { + this.checkArea() + } else if (e == 'jianzhichaping') { let item = { - shopScore:uni.getStorageSync('worker').score, - id:uni.getStorageSync('worker').workerId + shopScore: uni.getStorageSync('worker').score, + id: uni.getStorageSync('worker').workerId } - url = '/package2/group/shopEvaluate?item=' + JSON.stringify(item) + '&isMerchant=2&isCha=' + (index =='cha'?1:0) - }else if(e == 'partTimeReg'){ + url = '/package2/group/shopEvaluate?item=' + JSON.stringify(item) + '&isMerchant=2&isCha=' + (index == + 'cha' ? 1 : 0) + } else if (e == 'partTimeReg') { let worker = uni.getStorageSync('worker') let that = this //当前人不是配送员身份 - if(worker == undefined || worker == '' || worker == null){ - that.tui.request("/worker/admin/add", "POST", {userId:uni.getStorageSync('id'),isChangeArea:1,region:JSON.parse(uni.getStorageSync('area')).id}, false, true).then((res) => { + if (worker == undefined || worker == '' || worker == null) { + that.tui.request("/worker/admin/add", "POST", { + userId: uni.getStorageSync('id'), + isChangeArea: 1, + region: JSON.parse(uni.getStorageSync('area')).id + }, false, true).then((res) => { if (res.code == 200) { - if(res.result != null){ - uni.setStorageSync('worker',res.result) + if (res.result != null) { + uni.setStorageSync('worker', res.result) } url = '/package2/myCenter/partTimeJobRegister' this.$refs.jianzhiPopup.close() @@ -168,18 +208,18 @@ } uni.hideLoading() }).catch((res) => {}) - }else{ + } else { url = '/package2/myCenter/partTimeJobRegister' this.$refs.jianzhiPopup.close() } - }else if(e=='jianzhizhuce'){ - if(uni.getStorageSync('worker')){ + } else if (e == 'jianzhizhuce') { + if (uni.getStorageSync('worker')) { url = '/package2/myCenter/partTimeJobRegister' - }else{ + } else { this.$refs.jianzhiPopup.open() return } - }else if(e=='jianzhizhuye'){ + } else if (e == 'jianzhizhuye') { url = '/package2/partTimeJob/partTimeJobCenter' } uni.navigateTo({ @@ -191,22 +231,25 @@ \ No newline at end of file