main
JING 8 months ago
parent aa2b1e3727
commit 5b5b440614
  1. 90
      config/access/index.js
  2. 67
      config/api.js
  3. 31
      config/map/amap-wx.130.js
  4. 1122
      config/map/qqmap-wx-jssdk.js
  5. 2
      main.js
  6. 20
      pages/index/index.vue
  7. 64
      pages/user/account/index.vue

@ -1,90 +0,0 @@
var access = {
getAccess:function(k,userinfo){
if (userinfo && userinfo.access) {
return userinfo.access.indexOf(k) != -1;
}
return false;
},
hasAccess:function(arr,userinfo) {
if (userinfo && userinfo.access) {
return userinfo.access.some(_ => arr.indexOf(_) > -1);
}
return false;
},
/** 是否一级商户 */
isSuperType:function(userinfo){
if (this.getAccess(1002,userinfo)) {
return userinfo.userType == 2
}
if (this.getAccess(1003,userinfo) || this.getAccess(1004,userinfo)) {
return userinfo.userType == 1
}
return false;
},
/** 是否区级商户 */
isAreaType:function(userinfo){
if (this.getAccess(1002,userinfo)) {
return userinfo.userType == 1
}
if (this.getAccess(1003,userinfo) || this.getAccess(1004,userinfo)) {
return userinfo.userType == 2
}
return false;
},
/** 是否员工 */
isYuangongType:function(userinfo){
if (this.getAccess(1002,userinfo)) {
return userinfo.userType == 3
}
if (this.getAccess(1004,userinfo)) {
return userinfo.userType == 4
}
return false;
},
/** 是否三级 */
isThirdType:function(userinfo){
if (this.getAccess(1004,userinfo)) {
return userinfo.userType == 3
}
return false;
},
// 判断身份
checkidentity:function(userinfo) {
var res = {}
if (this.isSuperType(userinfo)) {
res = {
levelTxt: '一级',
levelVal: 1
}
} else if (this.isAreaType(userinfo)) {
res = {
levelTxt: '二级',
levelVal: 2
}
} else if (this.isThirdType(userinfo)) {
res = {
levelTxt: '店长',
levelVal: 3
}
/* } else if (this.isYuangongType(userinfo)) {
res = {
levelTxt: '员工',
levelVal: 3
} */
} else {
res = {
levelTxt: '用户',
levelVal: 4
}
}
return res
}
}
module.exports = access

@ -19,6 +19,56 @@ var api = {
if(catchFun) catchFun(rs);
});
},
/**
* oss上传图片
*
* @param string fileBaseUrl url地址
* @param string scene //对应文件配置file->file_type列表类型
* "back_icon": "后端图标",
"back_small": "后端小图",
"back_centre": "后端中图",
"back_max": "后端大图",
"user_small": "用户端小图",
"user_centre": "用户端中图",
"user_max": "用户端大图",
"user_portrait": "用户面部模型"
* @param {object} data 数据对象 {filePath:'',fileType:'image'}
* @param function thenFun then回调
* @param function catchFun catch回调
*/
ossUpload:function(fileBaseUrl,scene,data,thenFun,catchFun){
//从http://tmp/IX45zGr8kI1Tb1fd2c2b3045e9bfce734869d2024805.png 中
//提取 IX45zGr8kI1Tb1fd2c2b3045e9bfce734869d2024805.png 文件名
var fileNameArr = fileBaseUrl.split('//tmp/');
console.log(fileNameArr);
//获取文件名
var fileName = fileNameArr[1];
//获取文件格式
var suffixArr = fileName.split('.');
var suffix = suffixArr[1];
//先获取oss签名
api.post('api/aliSignature',{
scene:scene,
appoint:1,
filename:fileName,
},function(res){
console.log('签名成功',res);
var ossConfig = res;
data.ossConfig = ossConfig;
api.upload(ossConfig.host,data,function(rs){
console.log('上传成功',rs);
if(thenFun) thenFun(rs);
},function(er){
console.log('上传失败',er);
if(catchFun) catchFun(er);
});
},function(err){
console.log('签名失败',err);
if(catchFun) catchFun(err);
});
},
/**
* get 请求数据
@ -30,7 +80,7 @@ var api = {
*/
get:function(urlName, data, thenFun,catchFun) {
//数据组合
var newData = Object.assign(api.setSign(data), ENV.appData());
var newData = data;
uni.$u.http.get(urlName,{params:newData}).then(res => {
if(thenFun) thenFun(res);
}).catch((rs) =>{
@ -82,6 +132,19 @@ var api = {
*/
upload:function(urlName, data, thenFun,catchFun){
var newData = data;
var formData = {};
if(data.hasOwnProperty('ossConfig'))
{
var newFormData ={
key: data.ossConfig.key,
OSSAccessKeyId: data.ossConfig.accessId,
policy: data.ossConfig.policy, // 输入你获取的的policy
success_action_status: '200', // 让服务端返回200,不然,默认会返回204
signature: data.ossConfig.signature, // 输入你获取的的signature
};
formData = newFormData;
}
uni.$u.http.upload(urlName, {
params: {}, /* 会加在url上 */
// #ifdef MP-ALIPAY
@ -97,7 +160,7 @@ var api = {
header: {
"Content-Type": "multipart/form-data"
}, /* 会与全局header合并,如有同名属性,局部覆盖全局 */
formData: {}, // HTTP 请求中其他额外的 form data
formData: formData, // HTTP 请求中其他额外的 form data
// 返回当前请求的task, options。请勿在此处修改options。非必填
getTask: (task, options) => {
task.onProgressUpdate((res) => {

@ -1,31 +0,0 @@
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;

File diff suppressed because it is too large Load Diff

@ -19,8 +19,6 @@ Vue.prototype.$user = user;
import com from '@/config/com.js';
Vue.prototype.$com = com;
import access from '@/config/access/index.js';
Vue.prototype.$access = access;
// #ifdef H5
import wechat from '@/config/wechat.js'

@ -198,8 +198,13 @@
},
onLoad() {
this.getHomeInfo();
var _this = this;
//
_this.getHomeInfo();
//1
setTimeout(function(res){
_this.getUploadConfig();
},1000);
},
onShareAppMessage() {
@ -238,6 +243,17 @@
_this.$user.session('servicePhone',d.servicePhone);
}); */
},
//
getUploadConfig(){
var _this = this;
var post = {};
_this.$api.get('/api/fileDeploy', post,function(res){
console.log(res);
_this.$user.session('app_config',res);
});
},
//
scroll1(e) {
console.log(e);

@ -15,8 +15,7 @@
<view class="up">
<view class="img">
<u-upload
:fileList="wxAvatar"
:fileList="uploadImg"
@afterRead="afterRead"
@delete="deletePic"
name="avatar"
@ -24,7 +23,7 @@
height="26"
:sizeType="['compressed']"
:deletable="true"
:maxCount="5"
:maxCount="1"
:previewFullImage="false"
>
@ -50,7 +49,7 @@
border="none"
color="#999999"
maxlength="10"
v-model="info.wxName"
v-model="info.nick_name"
></u--input>
</view>
<view class='i_box_5'>
@ -119,12 +118,11 @@
return {
//form
info: {
wxName:'',
wxAvatar:'',
phoneNumber:'点击获取手机号',
nick_name:'',
avatar:'',
},
wxAvatar: [],
uploadImg: [],
}
},
@ -139,17 +137,25 @@
getUserInfo()
{
var _this =this;
var post ={};
_this.$api.post('ycl/user/wx-info',post,function(rs){
console.log(rs);
_this.info = rs;
_this.wxAvatar =[{url:rs.wxAvatar}];
});
var _this =this;
var userInfo = _this.$user.session('userInfo');
if(_this.$com.isNull(userInfo.nick_name) )
{
userInfo.nick_name = '微信用户';
}
if(_this.$com.isNull(userInfo.avatar))
{
userInfo.avatar = '/static/img/user/avatar.png';
}
_this.info = userInfo;
_this.uploadImg =[{url:userInfo.avatar}];
},
//
deletePic(event) {
var _this = this;
_this.wxAvatar = [];
_this.uploadImg = [];
},
//
afterRead(event) {
@ -159,18 +165,16 @@
var edetail = event.file.thumb;
if (edetail.indexOf('http://tmp') != -1 || edetail.indexOf('wxfile://tmp') != -1)
{
var FSM = uni.getFileSystemManager();
FSM.readFile({
filePath: edetail,
encoding: "base64",
success: function(data) {
_this.info.imgBase64 = "data:image/png;base64," + data.data
_this.wxAvatar = [{url:edetail}];
},
fail: function(err){
console.log('http://tmp',err)
}
})
//
var upData = {filePath:edetail,fileType:'image'};
_this.$api.ossUpload(edetail,'user_small',upData,function(res){
console.log('ossUpload success',res);
},function(err){
console.log('ossUpload fail',err);
});
}
@ -213,12 +217,12 @@
var _this =this;
var info = _this.info;
if(_this.$com.isNull(info.wxName))
if(_this.$com.isNull(info.nick_name))
{
_this.$com.showError('请输入昵称');
return;
}
if(_this.$com.isNull(info.wxAvatar) && _this.$com.isNull(info.imgBase64))
if(_this.$com.isNull(info.avatar) && _this.$com.isNull(info.imgBase64))
{
_this.$com.showError('请上传头像');
return;
@ -282,7 +286,7 @@ border-radius: 15rpx; margin: 0rpx auto; color:#3D3D3D;}
.i_box_3x{height: 100rpx;min-width: 65.7%; width: auto;font-size: 26rpx;}
::v-deep .u-input{ border:none !important; color:#3D3D3D !important; margin-top: 20rpx;}
.up{ width: 100%; height: auto; display: flex; margin-top: 20rpx;}
.up .img{width:80%; }
.up .img{width:80%; overflow: hidden; }
.up .img .u-upload{ margin-left: 80rpx;}
.up .icon{ width:20%;}
::v-deep .i_box_3x .u-button--info{ background-color: transparent !important; border: none !important; color: #FFFFFF !important; text-align: right !important;}

Loading…
Cancel
Save