diff --git a/api/chat.js b/api/chat.js new file mode 100644 index 0000000..9386155 --- /dev/null +++ b/api/chat.js @@ -0,0 +1,17 @@ +let bindInfo = { + chat_create:"/yishoudan/common/user/job/match/getTalk",// 创建会话 + chat_send:"/yishoudan/common/user/job/match/doTalk",// 处理会话 + chat_ai_job:"/yishoudan/store/job/getShareJobs",// gpt返回的职位列表 + chat_daotian_job:"/yishoudan/store/job/platform/list",// 稻田职位列表 + job_detail_daotian:"/yishoudan/store/job/platform/detail",// 稻田职位详情 + chat_config:'/yishoudan/common/user/job/match/getBotInfo',// 获取机器人配置 + ai_config:'/robot/config/getRobotList',// 获取机器人列表 + + + chat_getConversationld:'/chat/message/getConversationId',// 获取会话id + chat_getHistory:'/chat/message/getPageList',// 获取历史记录 + chat_addHistory:'/chat/message/addChatMessage',// 新增聊天记录 + chat_delMsg:'/chat/message/deleteMessage',// 删除聊天记录 +} + +export default bindInfo; \ No newline at end of file diff --git a/api/index.js b/api/index.js index 6835510..4b182af 100644 --- a/api/index.js +++ b/api/index.js @@ -6,6 +6,7 @@ import orderInfo from './order.js'; import personInfo from './person.js'; import wyyxInfo from './wyyx.js'; import commonInfo from './common.js'; +import chatInfo from './chat.js'; let testInfo = {// 测试接口 testUrl:"/overall/store/job/list",// 来源:稻田 小程序首页列表 @@ -19,4 +20,4 @@ let baseInfo = {// 公共接口 getConfig:"/yishoudan/weixin/config/getConfig", } -export default Object.assign(testInfo,baseInfo,loginInfo,userInfo,bindInfo,jobInfo,orderInfo,personInfo,commonInfo,wyyxInfo); \ No newline at end of file +export default Object.assign(testInfo,baseInfo,loginInfo,userInfo,bindInfo,jobInfo,orderInfo,personInfo,commonInfo,wyyxInfo,chatInfo); \ No newline at end of file diff --git a/root/chat/index.vue b/root/chat/index.vue index b28e309..1ac73c8 100644 --- a/root/chat/index.vue +++ b/root/chat/index.vue @@ -114,7 +114,7 @@ @@ -2307,7 +2307,7 @@ line-height: 1.5; // letter-spacing: 1.5px; word-break: break-all; - min-height: 45px; + min-height: 25px; } } @@ -2319,7 +2319,7 @@ line-height: 1.5; // letter-spacing: 1.5px; word-break: break-all; - min-height: 45px; + min-height: 25px; } } } diff --git a/root/utils/cozi.js b/root/utils/cozi.js index 1c31f0b..0bcc4da 100644 --- a/root/utils/cozi.js +++ b/root/utils/cozi.js @@ -1,5 +1,5 @@ let ajaxUrl = "https://api.coze.cn/"; - + let requestTask; let data = { ajaxUrl: ajaxUrl, diff --git a/utils/ajax.js b/utils/ajax.js index aadb6c7..ddb1fe7 100644 --- a/utils/ajax.js +++ b/utils/ajax.js @@ -1,216 +1,236 @@ // let ajaxUrl = "http://192.168.3.83:8001"; let ajaxUrl = "https://daotian.matripe.com.cn"; +let requestTask; let data = { - ajaxUrl: ajaxUrl, - Get ($url = '', $parmas = {}, callback = () => { }, failback = () => { }) { - let that = this, - params = {}; - let promise = new Promise((resolve, reject) => { - params = $parmas; - resolve(); - }); - promise.then(() => { - that.postData($url, params, callback, failback, 'GET'); - }).catch(); - }, - Post ($url = '', $parmas = {}, callback = () => { }, failback = () => { }) { - let that = this, - params = {}; - let promise = new Promise((resolve, reject) => { - params = $parmas; - resolve(); - }); - promise.then(() => { - that.postData($url, params, callback, failback, 'POST'); - }).catch(); - }, - Put ($url = '', $parmas = {}, callback = () => { }, failback = () => { }) { - let that = this, - params = {}; - let promise = new Promise((resolve, reject) => { - params = $parmas; - resolve(); - }); - promise.then(() => { - that.postData($url, params, callback, failback, 'PUT'); - }).catch(); - }, + ajaxUrl: ajaxUrl, + startAbort($bool = 0) { + if ($bool == 1) { + requestTask.abort(); + } + }, + Get($url = '', $parmas = {}, callback = () => {}, failback = () => {}) { + let that = this, + params = {}; + let promise = new Promise((resolve, reject) => { + params = $parmas; + resolve(); + }); + promise.then(() => { + that.postData($url, params, callback, failback, 'GET'); + }).catch(); + }, + Post($url = '', $parmas = {}, callback = () => {}, failback = () => {}) { + let that = this, + params = {}; + let promise = new Promise((resolve, reject) => { + params = $parmas; + resolve(); + }); + promise.then(() => { + that.postData($url, params, callback, failback, 'POST'); + }).catch(); + }, + Put($url = '', $parmas = {}, callback = () => {}, failback = () => {}) { + let that = this, + params = {}; + let promise = new Promise((resolve, reject) => { + params = $parmas; + resolve(); + }); + promise.then(() => { + that.postData($url, params, callback, failback, 'PUT'); + }).catch(); + }, - setPublicParams () { - let that = this, - params = {}; - let uuid_new = ""; - // #ifdef APP-PLUS - if (uni.getSystemInfoSync().osName == "android") { - uuid_new = "from_android_applyAssistantUniapp" - } else { - uuid_new = "from_ios_applyAssistantUniapp" - } - // #endif - params = { - 'requestComeFrom':'assistant_miniapp', - // #ifdef APP-PLUS - 'g-open-env': 'APP-PLUS', - appId: uuid_new, - // 请求来源标识 1.小程序 2.app 3.网页 - appClassify: 2, - appName: encodeURIComponent('报名助手') - // #endif - // #ifdef H5 - 'g-open-env': 'H5', - appId: '', - appClassify: 3, - appName: encodeURIComponent('报名助手') - // #endif - // #ifdef MP-WEIXIN - 'g-open-env': 'MP-MINI', - appId: uni.getAccountInfoSync().miniProgram.appId, - appClassify: 1, - appName: encodeURIComponent('报名助手') - // #endif - // #ifdef MP-TOUTIAO - 'g-open-env': 'MP-TOUTIAO', - appId: tt.getEnvInfoSync().microapp.appId, - subAppId: uni.getStorageSync('subAppId'), - appClassify: 1, - appName: encodeURIComponent('报名助手') - // #endif - // #ifdef MP-KUAISHOU - 'g-open-env': 'MP-KUAISHOU', - appId: "", - appClassify: 1, - appName: encodeURIComponent('报名助手') - // #endif - } - return params - }, - // 发送请求 - postData ($url = '', $parmas = {}, callback = () => { }, failback = () => { }, $method) { - let that = this, - $header = {}; - if (uni.getStorageSync("apply-token")) { - $header.Authorization = 'Bearer ' + uni.getStorageSync("apply-token"); - } - if (uni.getStorageSync("apply-agencyId")) { - // console.log('uni.getStorageSync("apply-agencyId")', uni.getStorageSync("apply-agencyId")); - $header.Agencyid = uni.getStorageSync("apply-agencyId"); - } - if ($parmas == '') { - $parmas = {}; - } - if ($parmas.formdata || $method == "POST" || $method == "PUT") { - $header['content-type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; - } - for (const k in $parmas) { - if ($parmas[k] == undefined || $parmas[k] == 'undefined') { - $parmas[k] = '' - } - } - console.log("公共参数,+++++", Object.assign($parmas, that.setPublicParams())); - uni.request({ - url: ajaxUrl + $url, - data: Object.assign($parmas, that.setPublicParams()), - header: Object.assign($header, that.setPublicParams()), - method: $method, - success: (res) => { - // console.log('测试报错123123123123123123',res); - // console.log('测试报错123123123123123123$url',$url); - let resData = res.data; - - if (resData.status == 200) {// 正常 - callback(resData.data, resData.msg); - } else if (resData.status == 9999) {// 登录过期或者身份变动等需要登录的场景 - uni.showToast({ - title: resData.msg, - icon: "none" - }); - failback(resData); - setTimeout(() => { - uni.reLaunch({ - url: '/root/person/loginIndex?path=/' + that.getPathCopy().path + '&level=' + that.getPathCopy().level - }); - }, 1500); - } else if (resData.status == 500 || resData.status == 502) {// 某种原因导致接口提示该状态码 - // if (resData.msg == '系统异常,请稍后') { - // uni.reLaunch({ - // url: '/root/other/error' - // }); - // } else { - uni.showToast({ - title: resData.msg, - // title:'系统异常,请稍后', - icon: "none" - }); - failback(resData.msg); - // } - } else if (resData.status == 2002) { - uni.showToast({ - title:'已切换团队,需要重新登录', - icon: "none" - }); - setTimeout(() => { - uni.reLaunch({ - url: '/root/person/loginIndex?path=/pages/home/index&level=' + that.getPathCopy().level - }); - }, 1500); - } else {// 其他异常 - if($url == '/yishoudan/user/apply/order/V2/details'){ - - }else{ - uni.showToast({ - title: resData.msg, - icon: "none" - }); - } - - - failback(resData.msg); - } - }, - fail (error) { - uni.showToast({ - // title: error.errMsg, - title:'系统异常,请稍后', - icon: "none" - }) - failback(error); - } - }); - }, + setPublicParams() { + let that = this, + params = {}; + let uuid_new = ""; + // #ifdef APP-PLUS + if (uni.getSystemInfoSync().osName == "android") { + uuid_new = "from_android_applyAssistantUniapp" + } else { + uuid_new = "from_ios_applyAssistantUniapp" + } + // #endif + params = { + 'requestComeFrom': 'assistant_miniapp', + // #ifdef APP-PLUS + 'g-open-env': 'APP-PLUS', + appId: uuid_new, + // 请求来源标识 1.小程序 2.app 3.网页 + appClassify: 2, + appName: encodeURIComponent('报名助手') + // #endif + // #ifdef H5 + 'g-open-env': 'H5', + appId: '', + appClassify: 3, + appName: encodeURIComponent('报名助手') + // #endif + // #ifdef MP-WEIXIN + 'g-open-env': 'MP-MINI', + appId: uni.getAccountInfoSync().miniProgram.appId, + appClassify: 1, + appName: encodeURIComponent('报名助手') + // #endif + // #ifdef MP-TOUTIAO + 'g-open-env': 'MP-TOUTIAO', + appId: tt.getEnvInfoSync().microapp.appId, + subAppId: uni.getStorageSync('subAppId'), + appClassify: 1, + appName: encodeURIComponent('报名助手') + // #endif + // #ifdef MP-KUAISHOU + 'g-open-env': 'MP-KUAISHOU', + appId: "", + appClassify: 1, + appName: encodeURIComponent('报名助手') + // #endif + } + return params + }, + // 发送请求 + postData($url = '', $parmas = {}, callback = () => {}, failback = () => {}, $method) { + let that = this, + $header = {}; + if (uni.getStorageSync("apply-token")) { + $header.Authorization = 'Bearer ' + uni.getStorageSync("apply-token"); + } + if (uni.getStorageSync("apply-agencyId")) { + // console.log('uni.getStorageSync("apply-agencyId")', uni.getStorageSync("apply-agencyId")); + $header.Agencyid = uni.getStorageSync("apply-agencyId"); + } + if ($parmas == '') { + $parmas = {}; + } + if ($parmas.formdata || $method == "POST" || $method == "PUT") { + $header['content-type'] = 'application/x-www-form-urlencoded; charset=UTF-8'; + } + for (const k in $parmas) { + if ($parmas[k] == undefined || $parmas[k] == 'undefined') { + $parmas[k] = '' + } + } + console.log("公共参数,+++++", Object.assign($parmas, that.setPublicParams())); + uni.getNetworkType({ + success: function(res) { + // console.log(res); + if (res.networkType != 'none') { + requestTask = uni.request({ + url: ajaxUrl + $url, + data: Object.assign($parmas, that.setPublicParams()), + header: Object.assign($header, that.setPublicParams()), + method: $method, + success: (res) => { + // console.log('测试报错123123123123123123',res); + // console.log('测试报错123123123123123123$url',$url); + let resData = res.data; - // 头像上传 - uploadFile ($file, callback = () => { }) { - let that = this; - uni.uploadFile({ - url: ajaxUrl + '/user/changeUserImgsrc', - filePath: $file, - name: 'uploadFile', - header: Object.assign({ - Authorization: 'Bearer ' + uni.getStorageSync("apply-token") - }, that.setPublicParams()), - formData: that.setPublicParams(), - success: (uploadFileRes) => { - callback(JSON.parse(uploadFileRes.data).data.url); - } - }); - }, - /* 获取当前path - */ - getPathCopy () { - const pages = getCurrentPages(); - if (pages.length > 0) { - let _path = pages[pages.length - 1].route; - return { - path: _path, - level: _path.slice(0, 4) - } - } else { - return { - path: '', - level: '' - }; - } - }, + if (resData.status == 200) { // 正常 + callback(resData.data, resData.msg); + } else if (resData.status == 9999) { // 登录过期或者身份变动等需要登录的场景 + uni.showToast({ + title: resData.msg, + icon: "none" + }); + failback(resData); + setTimeout(() => { + uni.reLaunch({ + url: '/root/person/loginIndex?path=/' + that.getPathCopy().path + '&level=' + + that.getPathCopy().level + }); + }, 1500); + } else if (resData.status == 500 || resData.status == 502) { // 某种原因导致接口提示该状态码 + // if (resData.msg == '系统异常,请稍后') { + // uni.reLaunch({ + // url: '/root/other/error' + // }); + // } else { + uni.showToast({ + title: resData.msg, + // title:'系统异常,请稍后', + icon: "none" + }); + failback(resData.msg); + // } + } else if (resData.status == 2002) { + uni.showToast({ + title: '已切换团队,需要重新登录', + icon: "none" + }); + setTimeout(() => { + uni.reLaunch({ + url: '/root/person/loginIndex?path=/pages/home/index&level=' + that + .getPathCopy().level + }); + }, 1500); + } else { // 其他异常 + if ($url == '/yishoudan/user/apply/order/V2/details') { + + } else { + uni.showToast({ + title: resData.msg, + icon: "none" + }); + } + + + failback(resData.msg); + } + }, + fail(error) { + uni.showToast({ + // title: error.errMsg, + title: '系统异常,请稍后', + icon: "none" + }) + failback(error); + } + }); + } else { + uni.showToast({ + title: '网络异常,请检查网络', + icon: "none" + }) + } + }, + }); + }, + + // 头像上传 + uploadFile($file, callback = () => {}) { + let that = this; + uni.uploadFile({ + url: ajaxUrl + '/user/changeUserImgsrc', + filePath: $file, + name: 'uploadFile', + header: Object.assign({ + Authorization: 'Bearer ' + uni.getStorageSync("apply-token") + }, that.setPublicParams()), + formData: that.setPublicParams(), + success: (uploadFileRes) => { + callback(JSON.parse(uploadFileRes.data).data.url); + } + }); + }, + /* 获取当前path + */ + getPathCopy() { + const pages = getCurrentPages(); + if (pages.length > 0) { + let _path = pages[pages.length - 1].route; + return { + path: _path, + level: _path.slice(0, 4) + } + } else { + return { + path: '', + level: '' + }; + } + }, }; export default data; \ No newline at end of file