diff --git a/package1/myCenter/partTimeJobRegister.vue b/package1/myCenter/partTimeJobRegister.vue index 883ab66..9dc9e85 100644 --- a/package1/myCenter/partTimeJobRegister.vue +++ b/package1/myCenter/partTimeJobRegister.vue @@ -14,10 +14,11 @@ * 姓名 - + * 学生证上传 身份信息仅用于认证身份,平台会严格保密 @@ -30,77 +31,72 @@ style="width: 80px;height: 80px;background-size: 100%;" /> + + + * 超出3楼以上额外收费 + + + + + * 兼职类型 - - 代买饭 + + 外卖 - 快递 - + * 规则配置 - + - 代买饭规则 + 外卖规则 - - 选择地址 + + 配置规则 - - - - 取 - - - 第三食堂 - - - - - 送 - - - 1号宿舍楼 - - - - - - - - - - 取 + + + + + 取 + + + {{item.getAreaName}} + - - 第三食堂 + + + 送 + + + {{item.putAreaName}} + - - - - 送 - - - 1号宿舍楼 + + + - - + + 备注: + @@ -110,52 +106,38 @@ 快递规则 - - 选择地址 + + 配置规则 - - - - 取 + + + + + 取 + + + {{item.getAreaName}} + - - 第三食堂 - - - - - 送 + + + 送 + + + {{item.putAreaName}} + - - 1号宿舍楼 + + + - - - - - - - - 取 - - - 第三食堂 - - - - - 送 - - - 1号宿舍楼 - - - - + + 备注: + @@ -169,7 +151,7 @@ style="width: 90px;height: 90px;margin-top: 10px;" /> 关注公众号 - + 提交注册 @@ -186,29 +168,30 @@ - + - {{item.name}} + {{item.title}} + 暂无可选取货区域 - + - {{item.name}} + {{item.title}} - + 暂无可送货区域 确定 - + @@ -222,49 +205,78 @@ return { menuButtonInfo: {}, formData: { + name: '', + highFloorFee: 0, paotui: false, - daimai: false, + waima: false, studentCard: '', }, bigImg: '', - qucan:[{ - name:'第一食堂', - checked:false, - },{ - name:'第二食堂', - checked:false, - },{ - name:'第三食堂', - checked:false, - },{ - name:'第四食堂', - checked:false, - }], - songcan:[{ - name:'男生宿舍1号楼', - checked:false, - },{ - name:'男生宿舍2号楼', - checked:false, - },{ - name:'男生宿舍3号楼', - checked:false, - },{ - name:'男生宿舍4号楼', - checked:false, - }] + qucan:[], + songcan:[], + shopArea: [], + waimaRuleList: [], + paotuiRuleList: [], + currentConfigType: '' } }, components: { }, onLoad() { - + this.getShopArea() + this.getWorkerMessage() }, onShow() { this.menuButtonInfo = uni.getMenuButtonBoundingClientRect() }, methods: { + getWorkerMessage(){ + let that = this + that.tui.request("/app/workerRelaPrice/getByWorkerId?workerId=W" + uni.getStorageSync('id'), "GET", {}, false, true).then((res) => { + if (res.code == 200) { + if(res.result != null){ + let data = res.result; + if (data.workerName) that.formData.name = data.workerName; + if (data.cardPicture) that.formData.studentCard = data.cardPicture; + if (data.highFloorFee !== undefined && data.highFloorFee !== null) that.formData.highFloorFee = data.highFloorFee; + + let list = data.workerRelaPriceList || []; + let waimaList = list.filter(item => item.orderType == 0); + let paotuiList = list.filter(item => item.orderType == 1); + + if(waimaList.length > 0) { + that.formData.waima = true; + that.waimaRuleList = waimaList; + } + if(paotuiList.length > 0) { + that.formData.paotui = true; + that.paotuiRuleList = paotuiList; + } + that.$forceUpdate(); + } + } else { + that.tui.toast(res.message) + return + } + }).catch((res) => {}) + }, + getShopArea(){ + let that = this + that.tui.request("/app/shopArea/getByParentId/"+JSON.parse(uni.getStorageSync('area')).id, "GET", {}, false, true).then((res) => { + if (res.code == 200) { + if(res.result != null){ + for(let m = 0;m {}) + }, back() { uni.navigateBack() }, @@ -273,9 +285,9 @@ this.bigImg = this.formData.studentCard; this.$refs.imgPopup.open() }, - daimaiOrpaotui(type) { - if (type == 'daimai') { - this.formData.daimai = !this.formData.daimai + waimaOrpaotui(type) { + if (type == 'waima') { + this.formData.waima = !this.formData.waima } else { this.formData.paotui = !this.formData.paotui } @@ -290,16 +302,118 @@ this.$forceUpdate() }, closeGuize(){ + let selectedQucan = this.qucan.filter(item => item.checked); + let selectedSongcan = this.songcan.filter(item => item.checked); + if(selectedQucan.length == 0 || selectedSongcan.length == 0) { + uni.showToast({title: '请至少选择一个取货地址和一个送货地址', icon: 'none'}); + return; + } + + let currentRuleList = this.currentConfigType == 'waima' ? this.waimaRuleList : this.paotuiRuleList; + let newRules = []; + let userId = uni.getStorageSync('id') || ''; + selectedQucan.forEach(q => { + selectedSongcan.forEach(s => { + let existing = currentRuleList.find(r => r.getAreaId == q.id && r.putAreaId == s.id); + if (existing) { + newRules.push(existing); + } else { + newRules.push({ + workerId: "W"+userId, + getAreaId: q.id, + getAreaName: q.title, + putAreaId: s.id, + putAreaName: s.title, + orderBkge: '', + orderType: this.currentConfigType == 'waima' ? 0 : 1, + remark: '' + }); + } + }); + }); + + if (this.currentConfigType == 'waima') { + this.waimaRuleList = newRules; + } else { + this.paotuiRuleList = newRules; + } + this.$refs.guizePopup.close() }, checkAddress(type) { - if (type == 'daimai') { - this.$refs.guizePopup.open() + let that = this + this.currentConfigType = type; + this.qucan = []; + this.songcan = []; + let currentRuleList = type == 'waima' ? this.waimaRuleList : this.paotuiRuleList; + let isCanteenVal = type == 'waima' ? 1 : 2; + + this.shopArea.forEach(item => { + let isGetChecked = currentRuleList.some(r => r.getAreaId == item.id); + let isPutChecked = currentRuleList.some(r => r.putAreaId == item.id); + + if (item.isCanteen == isCanteenVal) { + that.qucan.push({...item, checked: isGetChecked}); + } else { + that.songcan.push({...item, checked: isPutChecked}); + } + }); + this.$refs.guizePopup.open() + }, + removeRule(type, index) { + if(type == 'waima') { + this.waimaRuleList.splice(index, 1); } else { - this.$refs.guizePopup.open() + this.paotuiRuleList.splice(index, 1); + } + }, + submit() { + if (!this.formData.name) return uni.showToast({title: '请填写姓名', icon: 'none'}); + if (!this.formData.studentCard) return uni.showToast({title: '请上传学生证', icon: 'none'}); + if (!this.formData.waima && !this.formData.paotui) return uni.showToast({title: '请至少选择一种兼职类型', icon: 'none'}); + + if (this.formData.waima && this.waimaRuleList.length == 0) { + return uni.showToast({title: '请配置外卖规则', icon: 'none'}); + } + if (this.formData.paotui && this.paotuiRuleList.length == 0) { + return uni.showToast({title: '请配置快递规则', icon: 'none'}); } + let workerRelaPriceList = []; + if (this.formData.waima) { + let invalid = this.waimaRuleList.find(item => !item.orderBkge); + if (invalid) return uni.showToast({title: '请填写外卖配送费', icon: 'none'}); + workerRelaPriceList = workerRelaPriceList.concat(this.waimaRuleList); + } + if (this.formData.paotui) { + let invalid = this.paotuiRuleList.find(item => !item.orderBkge); + if (invalid) return uni.showToast({title: '请填写快递配送费', icon: 'none'}); + workerRelaPriceList = workerRelaPriceList.concat(this.paotuiRuleList); + } + + let submitData = { + userId: uni.getStorageSync('id'), + workerName: this.formData.name, + cardPicture: this.formData.studentCard, + highFloorFee: this.formData.highFloorFee, + workerRelaPriceList: workerRelaPriceList + }; + + uni.showLoading({title: '提交中...', mask: true}); + this.tui.request('/app/workerRelaPrice/batchAdd', 'post', submitData).then(res => { + uni.hideLoading(); + if (res.code == 200) { + uni.showToast({title: '提交成功'}); + setTimeout(() => { + uni.navigateBack(); + }, 1500); + } else { + uni.showToast({title: res.message, icon: 'none'}); + } + }).catch(err => { + uni.hideLoading(); + }); }, pictureAdd() { let that = this