Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
施宇
/
icsalesProgram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f47dcf20
authored
Aug 07, 2019
by
施宇
Browse files
Options
_('Browse Files')
Download
Plain Diff
Merge branch 'master' of
http://119.23.72.7/shiyu/icsalesProgram
parents
97c0a8cf
6227bef0
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
41 deletions
app.js
pages/person/auth/index.js
utils/util.js
app.js
View file @
f47dcf20
const
WebIM
=
require
(
"utils/WebIM"
)[
"default"
];
let
chat
=
require
(
'utils/chat.js'
);
import
{
getData
,
judgeToken
}
from
'./utils/util.js'
;
import
{
apis
}
from
'./utils/api.js'
;
const
chat
=
require
(
'utils/chat.js'
);
import
{
getData
,
judgeToken
}
from
'./utils/util.js'
;
import
{
apis
}
from
'./utils/api.js'
;
App
({
globalData
:
{
unReadMessageNum
:
0
,
auth
:
wx
.
getStorageSync
(
'auth'
),
token
:
wx
.
getStorageSync
(
'access_token'
),
isIPX
:
false
,
//是否为iphone X
customerNum
:
"001"
,
...
...
@@ -12,8 +20,10 @@ App({
},
getImUser
:
chat
.
getImUser
,
addChatMember
:
function
(
id
)
{
let
token
=
wx
.
getStorageSync
(
'access_token'
)
||
''
;
this
.
addChatMemberStorage
(
id
);
getData
(
apis
.
addrecord
,
'GET'
,
{
"token"
:
token
,
"user_id"
:
id
...
...
@@ -26,48 +36,45 @@ App({
},
false
);
},
addChatMemberStorage
:
function
(
id
)
{
let
member
=
wx
.
getStorageSync
(
"member"
)
||
[];
let
index
=
member
.
indexOf
(
id
);
if
(
index
==
-
1
)
{
member
.
push
(
id
)
}
wx
.
setStorage
({
key
:
"member"
,
data
:
member
});
},
onLaunch
()
{
let
me
=
this
;
//验证用户是否登录状态
wx
.
getStorage
({
key
:
'access_token'
,
success
(
res
)
{
if
(
res
.
data
)
{
//验证是否授权
if
(
this
.
globalData
.
auth
)
{
//是否登录
if
(
this
.
globalData
.
token
)
{
wx
.
switchTab
({
url
:
'/pages/tab/home/home'
});
}
else
{
wx
.
redirectTo
({
url
:
'/pages/person/login/index'
});
}
}
else
{
wx
.
redirectTo
({
url
:
'/pages/person/auth/index'
});
}
})
// 查看是否授权
wx
.
getSetting
({
success
(
res
)
{
if
(
res
.
authSetting
[
'scope.userInfo'
])
{
// 已经授权
wx
.
switchTab
({
url
:
'/pages/tab/home/home'
})
}
}
});
if
(
judgeToken
()){
if
(
judgeToken
())
{
this
.
getImUser
();
}
chat
.
webimListen
();
this
.
checkIsIPhoneX
();
},
...
...
@@ -81,7 +88,6 @@ App({
}
}
})
}
,
}
});
\ No newline at end of file
pages/person/auth/index.js
View file @
f47dcf20
const
http
=
require
(
'../../../utils/util.js'
);
import
{
apis
}
from
'../../../utils/api.js'
;
import
{
apis
}
from
'../../../utils/api.js'
;
Page
({
...
...
@@ -14,7 +16,7 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad
:
function
(
options
)
{
onLoad
:
function
(
options
)
{
},
...
...
@@ -22,49 +24,49 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady
:
function
()
{
onReady
:
function
()
{
},
/**
* 生命周期函数--监听页面显示
*/
onShow
:
function
()
{
onShow
:
function
()
{
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide
:
function
()
{
onHide
:
function
()
{
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload
:
function
()
{
onUnload
:
function
()
{
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh
:
function
()
{
onPullDownRefresh
:
function
()
{
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom
:
function
()
{
onReachBottom
:
function
()
{
},
/**
* 用户点击右上角分享
*/
onShareAppMessage
:
function
()
{
onShareAppMessage
:
function
()
{
},
/**
...
...
@@ -73,7 +75,7 @@ Page({
bindGetUserInfo
(
e
)
{
let
self
=
this
;
if
(
e
.
detail
.
errMsg
==
'getUserInfo:ok'
){
if
(
e
.
detail
.
errMsg
==
'getUserInfo:ok'
)
{
wx
.
login
({
success
(
res
)
{
if
(
res
.
code
)
{
...
...
@@ -84,7 +86,7 @@ Page({
});
//获取openId
http
.
getData
(
apis
.
getOpenId
,
'GET'
,{
http
.
getData
(
apis
.
getOpenId
,
'GET'
,
{
code
:
res
.
code
,
'userinfo[avatarUrl]'
:
self
.
data
.
userinfo
.
avatarUrl
,
'userinfo[nickName]'
:
self
.
data
.
userinfo
.
nickName
...
...
@@ -102,6 +104,13 @@ Page({
data
:
res
.
data
.
session_key
});
//存储用户已经授权
wx
.
setStorage
({
key
:
"auth"
,
data
:
true
});
//授权成功跳转一键获取手机号
wx
.
navigateTo
({
url
:
'/pages/person/getphone/index'
...
...
@@ -117,7 +126,7 @@ Page({
}
})
}
else
{
}
else
{
//用户拒绝获取资料
wx
.
navigateTo
({
...
...
@@ -129,7 +138,7 @@ Page({
/**
* 暂不注册
*/
toUrl
:
function
()
{
toUrl
:
function
()
{
wx
.
switchTab
({
url
:
'/pages/tab/home/home'
})
...
...
utils/util.js
View file @
f47dcf20
...
...
@@ -46,7 +46,7 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => {
//处理token失效的情况
if
(
res
.
data
.
hasOwnProperty
(
'data'
))
{
if
(
res
.
data
.
err_code
==
=
501
||
res
.
data
.
errcode
=
==
501
)
{
if
(
res
.
data
.
err_code
==
501
||
res
.
data
.
errcode
==
501
)
{
wx
.
redirectTo
({
url
:
'/pages/person/login/index'
});
...
...
@@ -54,7 +54,7 @@ const getData = (url, type, param, callBack, loading, isheader, istoken) => {
typeof
callBack
==
"function"
&&
callBack
(
res
.
data
,
""
);
}
}
else
{
if
(
res
.
data
.
err_code
==
=
501
||
res
.
data
.
errcode
=
==
501
)
{
if
(
res
.
data
.
err_code
==
501
||
res
.
data
.
errcode
==
501
)
{
wx
.
redirectTo
({
url
:
'/pages/person/login/index'
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment