合并 智慧就业第一版
This commit is contained in:
31
utilB/amap-wx.130.js
Normal file
31
utilB/amap-wx.130.js
Normal file
@@ -0,0 +1,31 @@
|
||||
function AMapWX(a){this.key=a.key;this.requestConfig={key:a.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"};this.MeRequestConfig={key:a.key,serviceName:"https://restapi.amap.com/rest/me"}}
|
||||
AMapWX.prototype.getWxLocation=function(a,b){wx.getLocation({type:"gcj02",success:function(c){c=c.longitude+","+c.latitude;wx.setStorage({key:"userLocation",data:c});b(c)},fail:function(c){wx.getStorage({key:"userLocation",success:function(d){d.data&&b(d.data)}});a.fail({errCode:"0",errMsg:c.errMsg||""})}})};
|
||||
AMapWX.prototype.getMEKeywordsSearch=function(a){if(!a.options)return a.fail({errCode:"0",errMsg:"\u7f3a\u5c11\u5fc5\u8981\u53c2\u6570"});var b=a.options,c=this.MeRequestConfig,d={key:c.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"};b.layerId&&(d.layerId=b.layerId);b.keywords&&(d.keywords=b.keywords);b.city&&(d.city=b.city);b.filter&&(d.filter=b.filter);b.sortrule&&(d.sortrule=b.sortrule);b.pageNum&&(d.pageNum=b.pageNum);b.pageSize&&(d.pageSize=b.pageSize);b.sig&&(d.sig=
|
||||
b.sig);wx.request({url:c.serviceName+"/cpoint/datasearch/local",data:d,method:"GET",header:{"content-type":"application/json"},success:function(e){(e=e.data)&&e.status&&"1"===e.status&&0===e.code?a.success(e.data):a.fail({errCode:"0",errMsg:e})},fail:function(e){a.fail({errCode:"0",errMsg:e.errMsg||""})}})};
|
||||
AMapWX.prototype.getMEIdSearch=function(a){if(!a.options)return a.fail({errCode:"0",errMsg:"\u7f3a\u5c11\u5fc5\u8981\u53c2\u6570"});var b=a.options,c=this.MeRequestConfig,d={key:c.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"};b.layerId&&(d.layerId=b.layerId);b.id&&(d.id=b.id);b.sig&&(d.sig=b.sig);wx.request({url:c.serviceName+"/cpoint/datasearch/id",data:d,method:"GET",header:{"content-type":"application/json"},success:function(e){(e=e.data)&&e.status&&"1"===e.status&&
|
||||
0===e.code?a.success(e.data):a.fail({errCode:"0",errMsg:e})},fail:function(e){a.fail({errCode:"0",errMsg:e.errMsg||""})}})};
|
||||
AMapWX.prototype.getMEPolygonSearch=function(a){if(!a.options)return a.fail({errCode:"0",errMsg:"\u7f3a\u5c11\u5fc5\u8981\u53c2\u6570"});var b=a.options,c=this.MeRequestConfig,d={key:c.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"};b.layerId&&(d.layerId=b.layerId);b.keywords&&(d.keywords=b.keywords);b.polygon&&(d.polygon=b.polygon);b.filter&&(d.filter=b.filter);b.sortrule&&(d.sortrule=b.sortrule);b.pageNum&&(d.pageNum=b.pageNum);b.pageSize&&(d.pageSize=b.pageSize);
|
||||
b.sig&&(d.sig=b.sig);wx.request({url:c.serviceName+"/cpoint/datasearch/polygon",data:d,method:"GET",header:{"content-type":"application/json"},success:function(e){(e=e.data)&&e.status&&"1"===e.status&&0===e.code?a.success(e.data):a.fail({errCode:"0",errMsg:e})},fail:function(e){a.fail({errCode:"0",errMsg:e.errMsg||""})}})};
|
||||
AMapWX.prototype.getMEaroundSearch=function(a){if(!a.options)return a.fail({errCode:"0",errMsg:"\u7f3a\u5c11\u5fc5\u8981\u53c2\u6570"});var b=a.options,c=this.MeRequestConfig,d={key:c.key,s:"rsx",platform:"WXJS",appname:a.key,sdkversion:"1.2.0",logversion:"2.0"};b.layerId&&(d.layerId=b.layerId);b.keywords&&(d.keywords=b.keywords);b.center&&(d.center=b.center);b.radius&&(d.radius=b.radius);b.filter&&(d.filter=b.filter);b.sortrule&&(d.sortrule=b.sortrule);b.pageNum&&(d.pageNum=b.pageNum);b.pageSize&&
|
||||
(d.pageSize=b.pageSize);b.sig&&(d.sig=b.sig);wx.request({url:c.serviceName+"/cpoint/datasearch/around",data:d,method:"GET",header:{"content-type":"application/json"},success:function(e){(e=e.data)&&e.status&&"1"===e.status&&0===e.code?a.success(e.data):a.fail({errCode:"0",errMsg:e})},fail:function(e){a.fail({errCode:"0",errMsg:e.errMsg||""})}})};
|
||||
AMapWX.prototype.getGeo=function(a){var b=this.requestConfig,c=a.options;b={key:this.key,extensions:"all",s:b.s,platform:b.platform,appname:this.key,sdkversion:b.sdkversion,logversion:b.logversion};c.address&&(b.address=c.address);c.city&&(b.city=c.city);c.batch&&(b.batch=c.batch);c.sig&&(b.sig=c.sig);wx.request({url:"https://restapi.amap.com/v3/geocode/geo",data:b,method:"GET",header:{"content-type":"application/json"},success:function(d){(d=d.data)&&d.status&&"1"===d.status?a.success(d):a.fail({errCode:"0",
|
||||
errMsg:d})},fail:function(d){a.fail({errCode:"0",errMsg:d.errMsg||""})}})};
|
||||
AMapWX.prototype.getRegeo=function(a){function b(d){var e=c.requestConfig;wx.request({url:"https://restapi.amap.com/v3/geocode/regeo",data:{key:c.key,location:d,extensions:"all",s:e.s,platform:e.platform,appname:c.key,sdkversion:e.sdkversion,logversion:e.logversion},method:"GET",header:{"content-type":"application/json"},success:function(g){if(g.data.status&&"1"==g.data.status){g=g.data.regeocode;var h=g.addressComponent,f=[],k=g.roads[0].name+"\u9644\u8fd1",m=d.split(",")[0],n=d.split(",")[1];if(g.pois&&
|
||||
g.pois[0]){k=g.pois[0].name+"\u9644\u8fd1";var l=g.pois[0].location;l&&(m=parseFloat(l.split(",")[0]),n=parseFloat(l.split(",")[1]))}h.provice&&f.push(h.provice);h.city&&f.push(h.city);h.district&&f.push(h.district);h.streetNumber&&h.streetNumber.street&&h.streetNumber.number?(f.push(h.streetNumber.street),f.push(h.streetNumber.number)):f.push(g.roads[0].name);f=f.join("");a.success([{iconPath:a.iconPath,width:a.iconWidth,height:a.iconHeight,name:f,desc:k,longitude:m,latitude:n,id:0,regeocodeData:g}])}else a.fail({errCode:g.data.infocode,
|
||||
errMsg:g.data.info})},fail:function(g){a.fail({errCode:"0",errMsg:g.errMsg||""})}})}var c=this;a.location?b(a.location):c.getWxLocation(a,function(d){b(d)})};
|
||||
AMapWX.prototype.getWeather=function(a){function b(g){var h="base";a.type&&"forecast"==a.type&&(h="all");wx.request({url:"https://restapi.amap.com/v3/weather/weatherInfo",data:{key:d.key,city:g,extensions:h,s:e.s,platform:e.platform,appname:d.key,sdkversion:e.sdkversion,logversion:e.logversion},method:"GET",header:{"content-type":"application/json"},success:function(f){if(f.data.status&&"1"==f.data.status)if(f.data.lives){if((f=f.data.lives)&&0<f.length){f=f[0];var k={city:{text:"\u57ce\u5e02",data:f.city},
|
||||
weather:{text:"\u5929\u6c14",data:f.weather},temperature:{text:"\u6e29\u5ea6",data:f.temperature},winddirection:{text:"\u98ce\u5411",data:f.winddirection+"\u98ce"},windpower:{text:"\u98ce\u529b",data:f.windpower+"\u7ea7"},humidity:{text:"\u6e7f\u5ea6",data:f.humidity+"%"}};k.liveData=f;a.success(k)}}else f.data.forecasts&&f.data.forecasts[0]&&a.success({forecast:f.data.forecasts[0]});else a.fail({errCode:f.data.infocode,errMsg:f.data.info})},fail:function(f){a.fail({errCode:"0",errMsg:f.errMsg||""})}})}
|
||||
function c(g){wx.request({url:"https://restapi.amap.com/v3/geocode/regeo",data:{key:d.key,location:g,extensions:"all",s:e.s,platform:e.platform,appname:d.key,sdkversion:e.sdkversion,logversion:e.logversion},method:"GET",header:{"content-type":"application/json"},success:function(h){if(h.data.status&&"1"==h.data.status){h=h.data.regeocode;if(h.addressComponent)var f=h.addressComponent.adcode;else h.aois&&0<h.aois.length&&(f=h.aois[0].adcode);b(f)}else a.fail({errCode:h.data.infocode,errMsg:h.data.info})},
|
||||
fail:function(h){a.fail({errCode:"0",errMsg:h.errMsg||""})}})}var d=this,e=d.requestConfig;a.city?b(a.city):d.getWxLocation(a,function(g){c(g)})};
|
||||
AMapWX.prototype.getPoiAround=function(a){function b(e){e={key:c.key,location:e,s:d.s,platform:d.platform,appname:c.key,sdkversion:d.sdkversion,logversion:d.logversion};a.querytypes&&(e.types=a.querytypes);a.querykeywords&&(e.keywords=a.querykeywords);wx.request({url:"https://restapi.amap.com/v3/place/around",data:e,method:"GET",header:{"content-type":"application/json"},success:function(g){if(g.data.status&&"1"==g.data.status){if((g=g.data)&&g.pois){for(var h=[],f=0;f<g.pois.length;f++){var k=0==
|
||||
f?a.iconPathSelected:a.iconPath;h.push({latitude:parseFloat(g.pois[f].location.split(",")[1]),longitude:parseFloat(g.pois[f].location.split(",")[0]),iconPath:k,width:22,height:32,id:f,name:g.pois[f].name,address:g.pois[f].address})}a.success({markers:h,poisData:g.pois})}}else a.fail({errCode:g.data.infocode,errMsg:g.data.info})},fail:function(g){a.fail({errCode:"0",errMsg:g.errMsg||""})}})}var c=this,d=c.requestConfig;a.location?b(a.location):c.getWxLocation(a,function(e){b(e)})};
|
||||
AMapWX.prototype.getStaticmap=function(a){function b(e){c.push("location="+e);a.zoom&&c.push("zoom="+a.zoom);a.size&&c.push("size="+a.size);a.scale&&c.push("scale="+a.scale);a.markers&&c.push("markers="+a.markers);a.labels&&c.push("labels="+a.labels);a.paths&&c.push("paths="+a.paths);a.traffic&&c.push("traffic="+a.traffic);e="https://restapi.amap.com/v3/staticmap?"+c.join("&");a.success({url:e})}var c=[];c.push("key="+this.key);var d=this.requestConfig;c.push("s="+d.s);c.push("platform="+d.platform);
|
||||
c.push("appname="+d.appname);c.push("sdkversion="+d.sdkversion);c.push("logversion="+d.logversion);a.location?b(a.location):this.getWxLocation(a,function(e){b(e)})};
|
||||
AMapWX.prototype.getInputtips=function(a){var b=Object.assign({},this.requestConfig);a.location&&(b.location=a.location);a.keywords&&(b.keywords=a.keywords);a.type&&(b.type=a.type);a.city&&(b.city=a.city);a.citylimit&&(b.citylimit=a.citylimit);wx.request({url:"https://restapi.amap.com/v3/assistant/inputtips",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){c&&c.data&&c.data.tips&&a.success({tips:c.data.tips})},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg||
|
||||
""})}})};
|
||||
AMapWX.prototype.getDrivingRoute=function(a){var b=Object.assign({},this.requestConfig);a.origin&&(b.origin=a.origin);a.destination&&(b.destination=a.destination);a.strategy&&(b.strategy=a.strategy);a.waypoints&&(b.waypoints=a.waypoints);a.avoidpolygons&&(b.avoidpolygons=a.avoidpolygons);a.avoidroad&&(b.avoidroad=a.avoidroad);wx.request({url:"https://restapi.amap.com/v3/direction/driving",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){c&&c.data&&c.data.route&&a.success({paths:c.data.route.paths,
|
||||
taxi_cost:c.data.route.taxi_cost||""})},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg||""})}})};
|
||||
AMapWX.prototype.getWalkingRoute=function(a){var b=Object.assign({},this.requestConfig);a.origin&&(b.origin=a.origin);a.destination&&(b.destination=a.destination);wx.request({url:"https://restapi.amap.com/v3/direction/walking",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){c&&c.data&&c.data.route&&a.success({paths:c.data.route.paths})},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg||""})}})};
|
||||
AMapWX.prototype.getTransitRoute=function(a){var b=Object.assign({},this.requestConfig);a.origin&&(b.origin=a.origin);a.destination&&(b.destination=a.destination);a.strategy&&(b.strategy=a.strategy);a.city&&(b.city=a.city);a.cityd&&(b.cityd=a.cityd);wx.request({url:"https://restapi.amap.com/v3/direction/transit/integrated",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){c&&c.data&&c.data.route&&(c=c.data.route,a.success({distance:c.distance||"",taxi_cost:c.taxi_cost||
|
||||
"",transits:c.transits}))},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg||""})}})};
|
||||
AMapWX.prototype.getRidingRoute=function(a){var b=Object.assign({},this.requestConfig);a.origin&&(b.origin=a.origin);a.destination&&(b.destination=a.destination);wx.request({url:"https://restapi.amap.com/v3/direction/riding",data:b,method:"GET",header:{"content-type":"application/json"},success:function(c){c&&c.data&&c.data.route&&a.success({paths:c.data.route.paths})},fail:function(c){a.fail({errCode:"0",errMsg:c.errMsg||""})}})};module.exports.AMapWX=AMapWX;
|
||||
50
utilB/config.js
Normal file
50
utilB/config.js
Normal file
@@ -0,0 +1,50 @@
|
||||
let baseUrl = ""
|
||||
let baseUrl1 = ""
|
||||
let baseUrl2 = ""
|
||||
let baseUrl3 = ""
|
||||
let baseUrl4 = ""
|
||||
let baseUrl5 = ""
|
||||
let baseUrl6 = ""
|
||||
let baseUrl7 = ""
|
||||
let baseUrl8 = ""
|
||||
let filestore_site = "";
|
||||
// #ifdef MP-WEIXIN
|
||||
if (wx.getAccountInfoSync().miniProgram.envVersion === 'develop') {
|
||||
baseUrl = 'http://dev.51xuanxiao.com:8005/api' // 开发环境
|
||||
baseUrl1 = 'http://dev.51xuanxiao.com:8008/api' // 专业环境
|
||||
baseUrl2 = 'http://192.168.1.168:9002/api' // 院校环境
|
||||
baseUrl3 = 'http://dev.51xuanxiao.com:8007/api' // 职业环境
|
||||
baseUrl4 = 'http://dev.51xuanxiao.com:8009/api' // 用户环境
|
||||
baseUrl5 = 'http://dev.51xuanxiao.com:8006/api' // 测评环境
|
||||
|
||||
baseUrl6 = 'http://dev.51xuanxiao.com:8005' // 开发环境
|
||||
baseUrl7 = 'https://bapi.cnjzy.net/api' // 精志愿
|
||||
baseUrl8 = 'http://dev.51xuanxiao.com:8005/api' // 精志愿(新版本接口) 现在已迁移到 Career.YanXueApi
|
||||
filestore_site = 'http://192.168.1.168:31128' //文件地址
|
||||
} else {
|
||||
baseUrl = 'https://yanxueapi.51xuanxiao.com/api' // 生产环境
|
||||
baseUrl1 = "https://specialtyapi.51xuanxiao.com/api"// 专业环境
|
||||
baseUrl2 = "https://universityapi.51xuanxiao.com/api"// 院校环境
|
||||
baseUrl3 = "https://jobapi.51xuanxiao.com/api"// 职业环境
|
||||
baseUrl4 = "https://authapi.51xuanxiao.com/api"// 用户环境
|
||||
baseUrl5 = "https://testapi.51xuanxiao.com/api"// 测评环境
|
||||
|
||||
baseUrl6 = 'https://yanxueapi.51xuanxiao.com/' // 生产环境
|
||||
baseUrl7 = 'https://bapi.cnjzy.net/api' // 精志愿
|
||||
baseUrl8 = 'https://yanxueapi.51xuanxiao.com/api'// 精志愿(新版本接口)现在已迁移到 Career.YanXueApi
|
||||
filestore_site = 'https://filestore.plan.51xuanxiao.com' //文件地址
|
||||
}
|
||||
// #endif
|
||||
|
||||
export {
|
||||
baseUrl,
|
||||
baseUrl1,
|
||||
baseUrl2,
|
||||
baseUrl3,
|
||||
baseUrl4,
|
||||
baseUrl5,
|
||||
baseUrl6,
|
||||
baseUrl7,
|
||||
baseUrl8,
|
||||
filestore_site
|
||||
}
|
||||
19
utilB/imageUrl.js
Normal file
19
utilB/imageUrl.js
Normal file
@@ -0,0 +1,19 @@
|
||||
// 公共图片基地址
|
||||
const BASE_IMAGE_URL = 'https://51xuanxiao.oss-cn-hangzhou.aliyuncs.com/Resource/xcx_sygh';
|
||||
|
||||
/**
|
||||
* 图片地址拼接方法
|
||||
* @param {string} path - 图片路径(相对于基地址的路径)
|
||||
* @param {string} [process] - OSS图片处理参数,例如:'image/resize,m_fixed,w_348/quality,q_80'
|
||||
* @returns {string} 完整的图片URL
|
||||
*/
|
||||
export function ossImageUrl(path, process) {
|
||||
|
||||
// 如果有处理参数,拼接处理参数
|
||||
if (process) {
|
||||
return `${BASE_IMAGE_URL}/${path}?x-oss-process=${process}`;
|
||||
}
|
||||
|
||||
// 没有处理参数时,直接返回原始路径
|
||||
return `${BASE_IMAGE_URL}/${path}`;
|
||||
}
|
||||
117
utilB/request.js
Normal file
117
utilB/request.js
Normal file
@@ -0,0 +1,117 @@
|
||||
import {
|
||||
baseUrl,
|
||||
baseUrl1,
|
||||
baseUrl2,
|
||||
baseUrl3,
|
||||
baseUrl4,
|
||||
baseUrl5,
|
||||
baseUrl6,
|
||||
baseUrl7,
|
||||
baseUrl8
|
||||
} from './config.js'
|
||||
|
||||
const request = {}
|
||||
const headers = {}
|
||||
|
||||
request.globalRequest = (url, method, data, power, type) => {
|
||||
// 权限判断 因为有的接口请求头可能需要添加的参数不一样,所以这里做了区分
|
||||
// 1 == 不通过access_token校验的接口
|
||||
// 2 == 文件下载接口列表
|
||||
const userInfo = uni.getStorageSync('userInfo')
|
||||
// console.log('缓存userinfo:',userInfo);
|
||||
switch (power) {
|
||||
case 1:
|
||||
case 3:
|
||||
headers['Token'] = userInfo.token
|
||||
// if(power == 3){
|
||||
// const deviceInfo = wx.getDeviceInfo()
|
||||
// let data = {
|
||||
// model: deviceInfo.model,
|
||||
// system: deviceInfo.system,
|
||||
// platform: deviceInfo.platform
|
||||
// }
|
||||
// headers['DeviceInfo'] = JSON.stringify(data)
|
||||
// }
|
||||
break;
|
||||
case 2:
|
||||
headers['Authorization'] = userInfo.userToken
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
let host = "";
|
||||
let key = "";
|
||||
if (type == 1) {
|
||||
host = baseUrl1;
|
||||
} else if (type == 2) {
|
||||
host = baseUrl2;
|
||||
} else if (type == 3) {
|
||||
host = baseUrl3;
|
||||
} else if (type == 4) {
|
||||
host = baseUrl4;
|
||||
} else if (type == 5) {
|
||||
host = baseUrl5;
|
||||
} else if (type == 7) {
|
||||
host = baseUrl7;
|
||||
key = `?PartnerKey=51xuanxiao&PartnerSecret=mC6XRjDWUzGAdxcCqRBWGb88uR`;
|
||||
} else if (type == 8) {
|
||||
host = baseUrl8;
|
||||
//key = `?AppKey=51xuanxiao&AppSecret=mC6XRjDWUzGAdxcCqRBWGb88uR`;
|
||||
} else {
|
||||
host = baseUrl;
|
||||
}
|
||||
return uni.request({
|
||||
timeout: 60000,
|
||||
url: host + url + key,
|
||||
method,
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
header: headers
|
||||
}).then(res => {
|
||||
//console.log("ressss===="+JSON.stringify(res.data));
|
||||
console.log("type===="+type);
|
||||
if (type == 7) {
|
||||
if (res[1].data.code == 0) {
|
||||
return res[1].data
|
||||
} else {
|
||||
throw res[1].data
|
||||
}
|
||||
} else if (type == 8) {
|
||||
if (res[1].data.Code == 0) {
|
||||
return res[1].data
|
||||
} else {
|
||||
throw res[1].data
|
||||
}
|
||||
} else {
|
||||
if (res.data.Result) {
|
||||
return res.data
|
||||
} else {
|
||||
throw res.data
|
||||
}
|
||||
}
|
||||
}).catch(parmas => {
|
||||
switch (parmas.status) {
|
||||
case 401:
|
||||
uni.showToast({
|
||||
title: parmas.msg,
|
||||
icon: 'none',
|
||||
duration: 3500
|
||||
})
|
||||
uni.removeStorageSync("userInfo");
|
||||
setTimeout(() => {
|
||||
uni.reLaunch({
|
||||
url: "/pages/index/index"
|
||||
})
|
||||
}, 2800)
|
||||
break
|
||||
default:
|
||||
uni.showToast({
|
||||
title: parmas.message,
|
||||
icon: 'none'
|
||||
})
|
||||
return Promise.reject()
|
||||
break
|
||||
}
|
||||
})
|
||||
}
|
||||
export default request
|
||||
Reference in New Issue
Block a user