From f54fe343f5b6c4d94978fedcbfdc56023090c657 Mon Sep 17 00:00:00 2001 From: huliyong <2783385703@qq.com> Date: Tue, 1 Jul 2025 17:26:11 +0800 Subject: [PATCH] 1 --- components/AddressPicker.vue | 280 ++++++++++++++++++++++++++++++++++ components/screen/screenWork.vue | 28 +++- pages/index/index.vue | 12 +- pages_order/mine/InvitationCredit.vue | 2 +- pages_order/work/addResume.vue | 76 +++++++-- pages_order/work/jobPosting.vue | 40 +++-- store/store.js | 34 ++++- utils/oss-upload/oss/index.js | 10 -- utils/oss-upload/oss/web.js | 63 -------- 9 files changed, 443 insertions(+), 102 deletions(-) create mode 100644 components/AddressPicker.vue delete mode 100644 utils/oss-upload/oss/web.js diff --git a/components/AddressPicker.vue b/components/AddressPicker.vue new file mode 100644 index 0000000..3cfea16 --- /dev/null +++ b/components/AddressPicker.vue @@ -0,0 +1,280 @@ + + + + + \ No newline at end of file diff --git a/components/screen/screenWork.vue b/components/screen/screenWork.vue index 2a65b3e..2d8d8fd 100644 --- a/components/screen/screenWork.vue +++ b/components/screen/screenWork.vue @@ -9,7 +9,7 @@ :custom-style="{padding: '0 30rpx'}" @click="selectMenu"> - @@ -41,6 +41,9 @@ @clickItem="clickItem" @popupChange="change"> + + + @@ -76,7 +79,11 @@ import { mapState, } from 'vuex' + import AddressPicker from '@/components/AddressPicker.vue' export default { + components: { + AddressPicker + }, props : { sign : { default : 'dropDown_1' @@ -244,6 +251,13 @@ this.activeName = name; + // 地址选择使用AddressPicker组件 + if(name === 'areaId'){ + this.$refs.addressPicker.open() + return + } + + // 智能推荐弹窗 if(type == 1){ this.$refs.popup.open() return @@ -313,6 +327,18 @@ this.$refs.popup.close() }, + // 地址选择确认回调 + onAddressConfirm(addressResult) { + // 更新areaId的状态 + this.areaId.label = addressResult.fullAddress + this.areaId.value = addressResult.selectedAddress.selectedAddress + + // 调用clickItem来更新result数组并触发父组件事件 + this.clickItem({ + label: addressResult.fullAddress, + value: addressResult.selectedAddress.selectedAddress + }) + }, } } diff --git a/pages/index/index.vue b/pages/index/index.vue index c597e63..e3376f4 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -39,8 +39,12 @@ v-if="jobTypeList.length > 4" @click="$utils.navigateTo(`/pages_order/work/workTypeList`)" > - + 其他招工 + + @@ -125,12 +129,18 @@ productList: [], keyword : '', screenWorkList : [], + config_other_job : '', } }, onPullDownRefresh(){ this.$refs.workList.getData(this.screenWorkList) this.$store.commit('getBanner') }, + onLoad(){ + uni.on('initConfig', (e) => { + this.config_other_job = e.config_other_job + }) + }, // 页面显示的时候触发 onShow() { this.$refs.workList.getData(this.screenWorkList) diff --git a/pages_order/mine/InvitationCredit.vue b/pages_order/mine/InvitationCredit.vue index 6853202..6c3b8eb 100644 --- a/pages_order/mine/InvitationCredit.vue +++ b/pages_order/mine/InvitationCredit.vue @@ -81,7 +81,7 @@ --> + style="padding: 20rpx;background-color: #fff;"> diff --git a/pages_order/work/addResume.vue b/pages_order/work/addResume.vue index 6c64c98..1977527 100644 --- a/pages_order/work/addResume.vue +++ b/pages_order/work/addResume.vue @@ -14,13 +14,20 @@ {{ item.title }} - + {{ t.name || t.adress }} + + + + {{ selectedAddress || '请选择工作地区' }} + + + @@ -118,13 +125,19 @@ + + + @@ -328,12 +358,28 @@ import index from '../../uni_modules/uv-ui-tools' font-size: 26rpx; } - .act { - color: #fff; - background: $uni-color; - } + .act { + color: #fff; + background: $uni-color; } } + + .address-selector { + display: flex; + justify-content: space-between; + align-items: center; + background: rgba($uni-color, 0.1); + padding: 20rpx; + margin: 10rpx; + border-radius: 10rpx; + font-size: 26rpx; + + .selected-address { + flex: 1; + color: #333; + } + } + } } .form-sheet-cell{ diff --git a/pages_order/work/jobPosting.vue b/pages_order/work/jobPosting.vue index 9a3348b..8b25237 100644 --- a/pages_order/work/jobPosting.vue +++ b/pages_order/work/jobPosting.vue @@ -17,7 +17,7 @@ title="所在城市" rightIconStyle="fontSize: 30rpx;" :value="form.areaId_dictText || '请选择所在城市'" - @click="openPicker('areaId',$refs.addressListPicker)" + @click="openAddressPicker" isLink > @@ -189,10 +189,7 @@ keyName="name" @confirm="pickerConfirm"> - + + + + 发布 @@ -212,7 +212,11 @@ diff --git a/store/store.js b/store/store.js index 90406b4..6fab708 100644 --- a/store/store.js +++ b/store/store.js @@ -16,6 +16,7 @@ const store = new Vuex.Store({ jobTypeList : [],//工种 natureList : [],//工作性质 addressList : [],//开放地址 + addressTreeMap : {},//多级地址映射,key为父级id,value为子级数组 UserExtensionInfo : {},//用户扩展信息,包含认证信息、统计信息 }, getters: { @@ -31,6 +32,8 @@ const store = new Vuex.Store({ n.paramValueImage // state.configList[n.keyName + '_keyValue'] = n.keyValue }) + + uni.emit('initConfig', state.configList) } }) @@ -109,6 +112,7 @@ const store = new Vuex.Store({ api('commonQueryAddressList', { pageNo : 1, pageSize : 99999, + pid : 0, }, res => { if(res.code != 200){ return @@ -229,8 +233,36 @@ const store = new Vuex.Store({ } }) }, + // 设置子级地址列表到状态中 + setChildAddressList(state, { pid, list }){ + state.addressTreeMap[pid] = list + }, + }, + actions: { + // 获取子级地址列表 + async getChildAddressList({ state, commit }, pid){ + // 如果已经缓存了,直接返回 + if(state.addressTreeMap[pid]){ + return Promise.resolve(state.addressTreeMap[pid]) + } + + return new Promise((resolve, reject) => { + api('commonQueryAddressList', { + pageNo : 1, + pageSize : 99999, + pid : pid, + }, res => { + if(res.code == 200){ + // 存储到映射中 + commit('setChildAddressList', { pid, list: res.result.records }) + resolve(res.result.records) + } else { + reject(res) + } + }) + }) + }, }, - actions: {}, }) export default store \ No newline at end of file diff --git a/utils/oss-upload/oss/index.js b/utils/oss-upload/oss/index.js index 40706d2..af41fc8 100644 --- a/utils/oss-upload/oss/index.js +++ b/utils/oss-upload/oss/index.js @@ -2,10 +2,6 @@ * 阿里云OSS工具类 */ import OSSConfig from "@/utils/oss-upload/oss/OSSConfig.js" -//支持web端 -import { - uploadFileToOSS -} from '@/utils/oss-upload/oss/web.js' import ossConfig from '@/config.js' /** @@ -98,9 +94,6 @@ export function ossUploadImage({ count: 1, sizeType, success(res) { - // #ifdef H5 - return uploadFileToOSS(res.tempFiles[0]).then(success).catch(fail) - // #endif ossUpload(res.tempFilePaths[0], key, folder).then(success).catch(fail) }, fail @@ -128,9 +121,6 @@ export function ossUploadVideo({ maxDuration, camera, success(res) { - // #ifdef H5 - return uploadFileToOSS(res.tempFile).then(success).catch(fail) - // #endif ossUpload(res.tempFilePath, key, folder).then(success).catch(fail) }, fail diff --git a/utils/oss-upload/oss/web.js b/utils/oss-upload/oss/web.js deleted file mode 100644 index dfaab6e..0000000 --- a/utils/oss-upload/oss/web.js +++ /dev/null @@ -1,63 +0,0 @@ -// 此方法适用于web -import OSS from "ali-oss" -import config from '@/config.js' - -/** - * 生成一个随机的Key - */ -function storeKey() { - let s = []; - let hexDigits = "0123456789abcdef"; - for (let i = 0; i < 36; i++) { - s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); - } - s[14] = "4"; - s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); - s[8] = s[13] = s[18] = s[23] = "-"; - return s.join(""); -} - -/** - * 根据当天日期在OSS端生成文件夹 - */ -function storeFolder() { - const date = new Date(); - const formatNumber = n => { - n = n.toString() - return n[1] ? n : '0' + n - } - return [date.getFullYear(), date.getMonth() + 1, date.getDate()].map(formatNumber).join('-') -} - - -export function uploadFileToOSS(file) { - - uni.showLoading({ - title: '上传中...' - }); - - return new Promise((resolve,reject) => { - // 创建OSS实例 - const client = new OSS(config.aliOss.config); - - // 设置文件名和文件目录 - const suffix = '.' + file.name.split('.').pop(); - let key = storeFolder() - if(key[key.length - 1] != '/') key += '/' - const fileName = key + storeKey() + suffix; // 注意:文件名需要是唯一的 - - // 使用put接口上传文件 - client.multipartUpload(fileName, file, { - headers: { - 'Content-Disposition': 'inline', - 'Content-Type': file.type - } - }).then(res => { - uni.hideLoading(); - resolve(config.aliOss.url + res.name); - }).catch(err => { - uni.hideLoading(); - reject(err) - }) - }) -} \ No newline at end of file