diff --git a/App.vue b/App.vue index 705e388..e6e2877 100644 --- a/App.vue +++ b/App.vue @@ -40,16 +40,28 @@ success: function (rs) { console.log(rs); //发起网络请求 - var post = {loginCode: rs.code}; - // _this.$api.post('ycl/user/wx-login', post,function(res){ - // console.log(res); - // _this.$user.session('openid',res.wxOpenid); - // _this.$user.session('user_id',res.id); - // if(!_this.$com.isNull(res.token)) - // { - // _this.$user.session('token',res.token); - // } - // }); + var post = { + js_code: rs.code, + }; + //三方登录类型;applet:小程序,app_wechat:app端微信,official_account:公众号 + // #ifdef MP + post.login_type = 'applet'; + // #endif + // #ifdef APP + post.login_type = 'app_wechat'; + // #endif + // #ifdef H5 + post.login_type = 'official_account'; + // #endif + _this.$api.post('/api/login', post,function(res){ + console.log(res); + _this.$user.session('userInfo',res); + _this.$user.session('user_id',res.id); + if(!_this.$com.isNull(res.token)) + { + _this.$user.session('token',res.token); + } + }); }, fail:function(rs){ console.log('登录失败'+rs.errMsg); diff --git a/config/env.js b/config/env.js index 8690491..ff69551 100644 --- a/config/env.js +++ b/config/env.js @@ -3,14 +3,14 @@ var NowENV = 'development'; var ENV_API_URL = { production:'https://netcharge.spacechong.com/', //正式环境 - development:'https://devnetcharge.spacechong.com/', //开发测试环境 + development:'http://photo.internal.com/', //开发测试环境 local:'http://192.168.10.123:8901/',//本地调试环境 } //CdnUrl 环境配置[都默认为线上都行] var ENV_BASE_URL = { production:'https://netcharge.spacechong.com', //正式环境 - development:'https://netcharge.spacechong.com', //开发测试环境 + development:'https://photo.internal.com', //开发测试环境 local:'https://netcharge.spacechong.com',//本地调试环境 } diff --git a/config/request.js b/config/request.js index 45eb2f6..f917528 100644 --- a/config/request.js +++ b/config/request.js @@ -64,10 +64,10 @@ module.exports = (vm) => { // 响应拦截 uni.$u.http.interceptors.response.use((response) => { /* 对响应成功做点什么 可使用async await 做异步操作*/ const data = response.data - + //console.log('请求返回',data); // 自定义参数 const custom = response.config?.custom - if (data.result !== 1) { + if (data.code !== 200) { // 如果没有显式定义custom的toast参数为false的话,默认对报错进行toast弹出提示 if (custom.toast !== false) { uni.$u.toast(data.msg) @@ -85,7 +85,7 @@ module.exports = (vm) => { }, (response) => { //console.log(response); // 对响应错误做点什么 (statusCode !== 200) - if(response.statusCode == 401) + if(response.statusCode == 920) { // 假设201为token失效,这里跳转登录 uni.$u.toast('用户信息验证失败,请重新登录'); diff --git a/pages/index/index.vue b/pages/index/index.vue index 4fa4244..bf0d044 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -226,17 +226,17 @@ getHomeInfo(){ var _this =this; //post 请求例子 - _this.$api.post('ycl/home', {},function(res){ + /* _this.$api.post('ycl/home', {},function(res){ console.log(res); var d = res; var banner = d.adList banner.forEach((item, index) => { item.title = item.adName; }) - //_this.banner = banner; - //_this.notice = d.notice; - //_this.$user.session('servicePhone',d.servicePhone); - }); + _this.banner = banner; + _this.notice = d.notice; + _this.$user.session('servicePhone',d.servicePhone); + }); */ }, //滚动监控 scroll1(e) { diff --git a/pages/user/account/index.vue b/pages/user/account/index.vue index a8968b1..f078ff6 100644 --- a/pages/user/account/index.vue +++ b/pages/user/account/index.vue @@ -24,7 +24,7 @@ height="26" :sizeType="['compressed']" :deletable="true" - :maxCount="1" + :maxCount="5" :previewFullImage="false" > diff --git a/pages/user/index.vue b/pages/user/index.vue index f25a279..b33cd58 100644 --- a/pages/user/index.vue +++ b/pages/user/index.vue @@ -13,10 +13,10 @@ - + - {{userInfo.wxName}} + {{userInfo.nick_name}} @@ -166,8 +166,8 @@ export default { return { isLogin:false, //登录 userInfo:{ - wxAvatar:'/static/img/user/avatar.png', - wxName:'点击登录', + avatar:'/static/img/user/avatar.png', + nick_name:'点击登录', }, tabList: [ { @@ -189,11 +189,11 @@ export default { }, onShow() { var _this =this; - var openid = _this.$user.session('openid'); - if(!_this.$com.isNull(openid)) + var token = _this.$user.session('token'); + if(!_this.$com.isNull(token)) { _this.isLogin = true; - //_this.getUserInfo(); + _this.getUserInfo(); } @@ -219,25 +219,17 @@ export default { getUserInfo() { var _this =this; - var post ={}; - _this.$api.post('ycl/user/wx-info',post,function(rs){ - console.log(rs); - _this.userInfo = rs; - _this.$user.session('lifeData',rs); - var identityinfo = _this.$access.checkidentity(rs); - console.log(identityinfo); - _this.identityinfo = identityinfo; - _this.$user.session('identityinfo',identityinfo); - if(identityinfo.levelVal != 4) - { - var setmenu = _this.setmenu; - var updatedSetmenu = setmenu.filter(item => item.label !== '代理入驻'); - _this.setmenu = updatedSetmenu; - } - - },function(err){ - console.log(err); - }); + 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.userInfo = userInfo; + }, goTo(url) {