diff --git a/api/httpSetting.js b/api/httpSetting.js index 805e0d5..b267483 100644 --- a/api/httpSetting.js +++ b/api/httpSetting.js @@ -1,114 +1,133 @@ // api.js +// 导入qs库 +import qs from "qs"; + // 基础URL,可以根据环境来设置 // uEnvDev const accountInfo = wx.getAccountInfoSync(); // env类型 develop:开发版、trial:体验版、release:正式版 export const env = accountInfo.miniProgram.envVersion; if (!env) { - console.error("获取运行环境失败!"); + console.error("获取运行环境失败!"); } const baseApi = { - // 开发版 - develop: "http://110.40.156.216:30005/api", - // 体验版 - trial: "http://110.40.156.216:30005/api", - // 正式版 - release: "http://110.40.156.216:30005/api" + // 开发版 + develop: "http://110.40.156.216:30005/api", + // 体验版 + trial: "http://110.40.156.216:30005/api", + // 正式版 + release: "http://110.40.156.216:30005/api", }; -console.log(env, 'env') +console.log(env, "env"); // request请求baseURL -const BASE_URL = baseApi[env] || 'http://110.40.156.216:30005/api'; - +const BASE_URL = baseApi[env] || "http://110.40.156.216:30005/api"; function request(url, method, data = {}) { - const loginRes = uni.getStorageSync('loginRes') || {}; - const UTCOffset = new Date().getTimezoneOffset(); - return new Promise((resolve, reject) => { - uni.request({ - url: BASE_URL + url, // 完整的URL - method: method, - data: data, - header: { - 'AccessToken': loginRes.accessToken || '-1', // 请求头,可根据需要调整 - 'UserId': loginRes.appUserId || '-1', // 请求头,可根据需要调整 - 'LanguageType': 0, - }, - success: (res) => { - if (res.statusCode === 200) { - console.log(res) - if (res.data.code === 200 | res.data.code === 0) { - resolve(res.data) - } else { - reject(res.data) - } - } else { - reject(res); - } - - }, - fail: (err) => { - uni.showToast({ - title: '请求错误', // 提示的文本内容 - icon: 'none', // 提示的图标,可选值:'success' | 'loading' | 'none' - duration: 2000 // 提示框的显示时间,单位为毫秒,默认1500ms - }); - reject(err); // 请求失败 - } - }); - }); + const loginRes = uni.getStorageSync("loginRes") || {}; + const UTCOffset = new Date().getTimezoneOffset(); + return new Promise((resolve, reject) => { + uni.request({ + url: BASE_URL + url, // 完整的URL + method: method, + data: data, + header: { + AccessToken: loginRes.accessToken || "-1", // 请求头,可根据需要调整 + UserId: loginRes.appUserId || "-1", // 请求头,可根据需要调整 + LanguageType: 0, + }, + success: (res) => { + if (res.statusCode === 200) { + console.log(res); + if ((res.data.code === 200) | (res.data.code === 0)) { + resolve(res.data); + } else { + reject(res.data); + } + } else { + reject(res); + } + }, + fail: (err) => { + uni.showToast({ + title: "请求错误", // 提示的文本内容 + icon: "none", // 提示的图标,可选值:'success' | 'loading' | 'none' + duration: 2000, // 提示框的显示时间,单位为毫秒,默认1500ms + }); + reject(err); // 请求失败 + }, + }); + }); } +// 使用uni.addInterceptor拦截请求,处理GET请求中的数组参数 +uni.addInterceptor("request", { + invoke(args) { + // request 触发前拼接 url + const { data, method } = args; + if (method === "GET") { + // 如果是get请求,且params是数组类型如arr=[1,2],则转换成arr=1&arr=2 + const newData = qs.stringify(data, { + arrayFormat: "repeat", + }); + delete args.data; + args.url = `${args.url}?${newData}`; + } + }, + success(args) {}, + fail(err) {}, + complete(res) {}, +}); + // GET 请求 export function get(url, params = {}) { - return request(url, 'GET', params); + return request(url, "GET", params); } // POST 请求 export function post(url, data = {}) { - return request(url, 'POST', data); -} - -export function uploadFile(url, filePath = '', data = {}) { - const loginRes = uni.getStorageSync('loginRes') || {}; - return new Promise((resolve, reject) => { - uni.uploadFile({ - url: BASE_URL + url, // 完整的URL - filePath: filePath, - name: 'image', - header: { - 'AccessToken': loginRes.accessToken || '-1', // 请求头,可根据需要调整 - 'UserId': loginRes.appUserId || '-1', // 请求头,可根据需要调整 - LanguageType: 0, - // 其他需要的请求头信息(如Token) - }, - formData: data, - success: (res) => { - if (res.statusCode === 200) { - if (res.data.code === 500) { - uni.showToast({ - title: '系统错误', // 提示的文本内容 - icon: 'none', // 提示的图标,可选值:'success' | 'loading' | 'none' - duration: 2000 // 提示框的显示时间,单位为毫秒,默认1500ms - }); - } - if (res.data.code === 20001) { - reject(res.data); - } - resolve(res.data); // 返回数据 - } else { - reject(res.data); // 返回错误信息 - } - }, - fail: (err) => { - uni.showToast({ - title: '请求错误', // 提示的文本内容 - icon: 'none', // 提示的图标,可选值:'success' | 'loading' | 'none' - duration: 2000 // 提示框的显示时间,单位为毫秒,默认1500ms - }); - reject(err); // 请求失败 - } - }); - }) + return request(url, "POST", data); +} +export function uploadFile(url, filePath = "", data = {}) { + const loginRes = uni.getStorageSync("loginRes") || {}; + return new Promise((resolve, reject) => { + uni.uploadFile({ + url: BASE_URL + url, // 完整的URL + filePath: filePath, + name: "image", + header: { + AccessToken: loginRes.accessToken || "-1", // 请求头,可根据需要调整 + UserId: loginRes.appUserId || "-1", // 请求头,可根据需要调整 + LanguageType: 0, + // 其他需要的请求头信息(如Token) + }, + formData: data, + success: (res) => { + if (res.statusCode === 200) { + if (res.data.code === 500) { + uni.showToast({ + title: "系统错误", // 提示的文本内容 + icon: "none", // 提示的图标,可选值:'success' | 'loading' | 'none' + duration: 2000, // 提示框的显示时间,单位为毫秒,默认1500ms + }); + } + if (res.data.code === 20001) { + reject(res.data); + } + resolve(res.data); // 返回数据 + } else { + reject(res.data); // 返回错误信息 + } + }, + fail: (err) => { + uni.showToast({ + title: "请求错误", // 提示的文本内容 + icon: "none", // 提示的图标,可选值:'success' | 'loading' | 'none' + duration: 2000, // 提示框的显示时间,单位为毫秒,默认1500ms + }); + reject(err); // 请求失败 + }, + }); + }); } diff --git a/api/index.js b/api/index.js index 2c0ec7a..43eb559 100644 --- a/api/index.js +++ b/api/index.js @@ -15,3 +15,36 @@ export const appserEditUser = (params ={}) => post('/app/user/editUser', params) export const factoryMapGetListPage = (params ={}) => get('/app/factoryMap/getListPage', params); +export const factoryMapGetJobById = (factoryId, params ={}) => get(`/app/factoryMap/getJob/${factoryId}`, params); + +export const tagGetListPage = (params ={}) => get('/app/job/getTags', params); + +/** + * 获取收藏列表 + */ +export const collectGetCollectList = (params ={}) => get('/collect/getCollectList', params); + +/** + * 添加收藏 + */ +export const collectAdd = (params ={}) => post('/collect/add', params); + +/** + * 取消收藏 + */ +export const collectCancel = (params ={}) => post('/collect/cancel', params); + +/** + * 获取评论列表 + */ +export const commentGetFirstLevelComment= (params ={}) => get('/comment/getFirstLevelComment', params); + +/** + * 添加评论 + */ +export const commentAdd = (params ={}) => post('/comment/add', params); + +/** + * 删除评论 + */ +export const commentDelete = (params ={}) => post('/comment/delete', params); diff --git a/components/popup-drawer/popup-drawer.vue b/components/popup-drawer/popup-drawer.vue index 975acd5..affb8e6 100644 --- a/components/popup-drawer/popup-drawer.vue +++ b/components/popup-drawer/popup-drawer.vue @@ -1,278 +1,273 @@ - - - - - + + + + + \ No newline at end of file diff --git a/components/recruitment/recruitment.vue b/components/recruitment/recruitment.vue index 09a479c..402ced6 100644 --- a/components/recruitment/recruitment.vue +++ b/components/recruitment/recruitment.vue @@ -2,8 +2,15 @@ -
-

{{dataSource.factoryName || '默认工厂'}}

+
+ +

{{dataSource.factoryName || '默认工厂'}}

+ + + + + +
@@ -22,8 +29,8 @@ {{dataSource.workTime || '8:00-20:00'}} {{dataSource.gender}} - {{dataSource.jobName || '主营汽车线束'}} - {{`距你${Math.round(dataSource.distanceMeters)}米`}} + {{dataSource.jobName || '主营汽车线束'}} + {{`距你${Math.round(dataSource.distanceMeters)}米`}} {{item.tagName}} @@ -45,7 +52,9 @@ - \ No newline at end of file diff --git a/pages/positionDetail/positionDetail.vue b/pages/positionDetail/positionDetail.vue index 0faa0e0..0285267 100644 --- a/pages/positionDetail/positionDetail.vue +++ b/pages/positionDetail/positionDetail.vue @@ -1,419 +1,690 @@ - - - - - + + + + + \ No newline at end of file diff --git a/pages/searchPositions/searchPositions.vue b/pages/searchPositions/searchPositions.vue index 99f77c3..6f6135f 100644 --- a/pages/searchPositions/searchPositions.vue +++ b/pages/searchPositions/searchPositions.vue @@ -8,17 +8,13 @@ - 长白班 - 高工资 - 包吃住 - 日结 - 大龄工 + {{ item.tagName || '标签' }} -