登录接口调试

main
JING 9 months ago
parent e0aa3ec933
commit 58533716ed
  1. 32
      App.vue
  2. 4
      config/env.js
  3. 6
      config/request.js
  4. 10
      pages/index/index.vue
  5. 2
      pages/user/account/index.vue
  6. 44
      pages/user/index.vue

@ -40,16 +40,28 @@
success: function (rs) { success: function (rs) {
console.log(rs); console.log(rs);
// //
var post = {loginCode: rs.code}; var post = {
// _this.$api.post('ycl/user/wx-login', post,function(res){ js_code: rs.code,
// console.log(res); };
// _this.$user.session('openid',res.wxOpenid); //applet,app_wechatapp,official_account
// _this.$user.session('user_id',res.id); // #ifdef MP
// if(!_this.$com.isNull(res.token)) post.login_type = 'applet';
// { // #endif
// _this.$user.session('token',res.token); // #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){ fail:function(rs){
console.log('登录失败'+rs.errMsg); console.log('登录失败'+rs.errMsg);

@ -3,14 +3,14 @@
var NowENV = 'development'; var NowENV = 'development';
var ENV_API_URL = { var ENV_API_URL = {
production:'https://netcharge.spacechong.com/', //正式环境 production:'https://netcharge.spacechong.com/', //正式环境
development:'https://devnetcharge.spacechong.com/', //开发测试环境 development:'http://photo.internal.com/', //开发测试环境
local:'http://192.168.10.123:8901/',//本地调试环境 local:'http://192.168.10.123:8901/',//本地调试环境
} }
//CdnUrl 环境配置[都默认为线上都行] //CdnUrl 环境配置[都默认为线上都行]
var ENV_BASE_URL = { var ENV_BASE_URL = {
production:'https://netcharge.spacechong.com', //正式环境 production:'https://netcharge.spacechong.com', //正式环境
development:'https://netcharge.spacechong.com', //开发测试环境 development:'https://photo.internal.com', //开发测试环境
local:'https://netcharge.spacechong.com',//本地调试环境 local:'https://netcharge.spacechong.com',//本地调试环境
} }

@ -64,10 +64,10 @@ module.exports = (vm) => {
// 响应拦截 // 响应拦截
uni.$u.http.interceptors.response.use((response) => { /* 对响应成功做点什么 可使用async await 做异步操作*/ uni.$u.http.interceptors.response.use((response) => { /* 对响应成功做点什么 可使用async await 做异步操作*/
const data = response.data const data = response.data
//console.log('请求返回',data);
// 自定义参数 // 自定义参数
const custom = response.config?.custom const custom = response.config?.custom
if (data.result !== 1) { if (data.code !== 200) {
// 如果没有显式定义custom的toast参数为false的话,默认对报错进行toast弹出提示 // 如果没有显式定义custom的toast参数为false的话,默认对报错进行toast弹出提示
if (custom.toast !== false) { if (custom.toast !== false) {
uni.$u.toast(data.msg) uni.$u.toast(data.msg)
@ -85,7 +85,7 @@ module.exports = (vm) => {
}, (response) => { }, (response) => {
//console.log(response); //console.log(response);
// 对响应错误做点什么 (statusCode !== 200) // 对响应错误做点什么 (statusCode !== 200)
if(response.statusCode == 401) if(response.statusCode == 920)
{ {
// 假设201为token失效,这里跳转登录 // 假设201为token失效,这里跳转登录
uni.$u.toast('用户信息验证失败,请重新登录'); uni.$u.toast('用户信息验证失败,请重新登录');

@ -226,17 +226,17 @@
getHomeInfo(){ getHomeInfo(){
var _this =this; var _this =this;
//post //post
_this.$api.post('ycl/home', {},function(res){ /* _this.$api.post('ycl/home', {},function(res){
console.log(res); console.log(res);
var d = res; var d = res;
var banner = d.adList var banner = d.adList
banner.forEach((item, index) => { banner.forEach((item, index) => {
item.title = item.adName; item.title = item.adName;
}) })
//_this.banner = banner; _this.banner = banner;
//_this.notice = d.notice; _this.notice = d.notice;
//_this.$user.session('servicePhone',d.servicePhone); _this.$user.session('servicePhone',d.servicePhone);
}); }); */
}, },
// //
scroll1(e) { scroll1(e) {

@ -24,7 +24,7 @@
height="26" height="26"
:sizeType="['compressed']" :sizeType="['compressed']"
:deletable="true" :deletable="true"
:maxCount="1" :maxCount="5"
:previewFullImage="false" :previewFullImage="false"
> >

@ -13,10 +13,10 @@
<image class='background' src="/static/img/user/topbg.png" mode="aspectFill"></image> <image class='background' src="/static/img/user/topbg.png" mode="aspectFill"></image>
<view class="userInfo"> <view class="userInfo">
<view class="uleft"> <view class="uleft">
<u-image :src="userInfo.wxAvatar" width="48px" height="48px" radius="50%" @error="imgErr"></u-image> <u-image :src="userInfo.avatar" width="48px" height="48px" radius="50%" @error="imgErr"></u-image>
</view> </view>
<view class="ucenter"> <view class="ucenter">
<view class="name"><text class="username">{{userInfo.wxName}}</text><!-- <text class="level">等级</text> --></view> <view class="name"><text class="username">{{userInfo.nick_name}}</text><!-- <text class="level">等级</text> --></view>
</view> </view>
<view class="uright"> <view class="uright">
<view class="change" @click="goTo('/pages/user/account/index')"> <view class="change" @click="goTo('/pages/user/account/index')">
@ -166,8 +166,8 @@ export default {
return { return {
isLogin:false, // isLogin:false, //
userInfo:{ userInfo:{
wxAvatar:'/static/img/user/avatar.png', avatar:'/static/img/user/avatar.png',
wxName:'点击登录', nick_name:'点击登录',
}, },
tabList: [ tabList: [
{ {
@ -189,11 +189,11 @@ export default {
}, },
onShow() { onShow() {
var _this =this; var _this =this;
var openid = _this.$user.session('openid'); var token = _this.$user.session('token');
if(!_this.$com.isNull(openid)) if(!_this.$com.isNull(token))
{ {
_this.isLogin = true; _this.isLogin = true;
//_this.getUserInfo(); _this.getUserInfo();
} }
@ -219,25 +219,17 @@ export default {
getUserInfo() getUserInfo()
{ {
var _this =this; var _this =this;
var post ={}; var userInfo = _this.$user.session('userInfo');
_this.$api.post('ycl/user/wx-info',post,function(rs){ if(_this.$com.isNull(userInfo.nick_name) )
console.log(rs); {
_this.userInfo = rs; userInfo.nick_name = '微信用户';
_this.$user.session('lifeData',rs); }
var identityinfo = _this.$access.checkidentity(rs); if(_this.$com.isNull(userInfo.avatar))
console.log(identityinfo); {
_this.identityinfo = identityinfo; userInfo.avatar = '/static/img/user/avatar.png';
_this.$user.session('identityinfo',identityinfo); }
if(identityinfo.levelVal != 4) _this.userInfo = userInfo;
{
var setmenu = _this.setmenu;
var updatedSetmenu = setmenu.filter(item => item.label !== '代理入驻');
_this.setmenu = updatedSetmenu;
}
},function(err){
console.log(err);
});
}, },
goTo(url) goTo(url)
{ {

Loading…
Cancel
Save