Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
self-support
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李俊赕
self-support
Commits
3bbc3075
Commit
3bbc3075
authored
May 28, 2021
by
高铭波
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into dev
parents
4c9eee3e
4cf29477
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
165 additions
and
134 deletions
+165
-134
App.vue
src/App.vue
+26
-60
customer.vue
src/components/mine/customer.vue
+21
-19
mine.vue
src/pages/index/mine.vue
+7
-5
index.vue
src/pages/login/index.vue
+21
-15
index.vue
src/pages/mine/wallet/index.vue
+2
-1
settlement.vue
src/pages/mine/wallet/settlement.vue
+3
-2
statement.vue
src/pages/mine/wallet/statement.vue
+3
-2
index.js
src/store/index.js
+4
-1
login.js
src/utils/login.js
+20
-2
util.js
src/utils/util.js
+58
-27
No files found.
src/App.vue
View file @
3bbc3075
...
@@ -38,9 +38,7 @@ export default {
...
@@ -38,9 +38,7 @@ export default {
"接单操作须知有助你快速了解充电桩安装业务,提高接单效率,请认真查看及学习。"
,
"接单操作须知有助你快速了解充电桩安装业务,提高接单效率,请认真查看及学习。"
,
},
},
},
},
// 退出登录
// 授权用户信息
authUserInfo
:
""
,
logout
:
false
,
logout
:
false
,
navHeight
:
0
,
//导航栏高度
navHeight
:
0
,
//导航栏高度
rpxScreenHeight
:
0
,
// 照相视框高度
rpxScreenHeight
:
0
,
// 照相视框高度
...
@@ -153,14 +151,10 @@ export default {
...
@@ -153,14 +151,10 @@ export default {
wxAppNo
:
that
.
globalData
.
wxAppNo
,
// 自营平台小程序
wxAppNo
:
that
.
globalData
.
wxAppNo
,
// 自营平台小程序
};
};
let
result
=
await
that
.
$u
.
api
.
loginWechatAuth
(
params
);
let
result
=
await
that
.
$u
.
api
.
loginWechatAuth
(
params
);
console
.
log
(
"result"
,
result
)
if
(
result
&&
result
.
code
==
200
&&
result
.
data
&&
result
.
data
.
token
)
{
if
(
login
.
setUserData
(
result
.
data
,
this
);
result
&&
this
.
profileSet
(
this
)
result
.
code
==
200
&&
this
.
profileAppend
(
this
)
result
.
data
&&
result
.
data
.
token
)
{
that
.
setUserData
(
result
.
data
);
}
else
{
}
else
{
uni
.
navigateTo
({
uni
.
navigateTo
({
url
:
"pages/login/index"
,
url
:
"pages/login/index"
,
...
@@ -174,25 +168,6 @@ export default {
...
@@ -174,25 +168,6 @@ export default {
}
}
});
});
},
},
setUserData
(
userInfo
,
that
)
{
let
self
=
that
?
that
:
this
if
(
userInfo
&&
userInfo
.
token
)
{
// 如果已经登录则直接获取相关信息
self
.
$u
.
vuex
(
"vuex_token"
,
userInfo
.
token
);
self
.
$u
.
vuex
(
"vuex_user"
,
userInfo
);
self
.
$u
.
vuex
(
"vuex_wx_uid"
,
userInfo
.
wxopenid
);
this
.
track
(
'auth_login'
,
{
auth_token
:
userInfo
.
token
,
auth_user
:
userInfo
,
auth_wx_uid
:
userInfo
.
wxopenid
});
}
else
{
self
.
$u
.
vuex
(
"vuex_token"
,
""
);
self
.
$u
.
vuex
(
"vuex_user"
,
null
);
self
.
$u
.
vuex
(
"vuex_wx_uid"
,
""
);
}
self
.
$u
.
vuex
(
"vuex_settled"
,
null
);
},
/* 版本更新 */
/* 版本更新 */
async
updateApp
()
{
async
updateApp
()
{
...
@@ -229,41 +204,32 @@ export default {
...
@@ -229,41 +204,32 @@ export default {
AnalysysAgent
.
track
(
"self_support_"
+
event
,
properties
);
AnalysysAgent
.
track
(
"self_support_"
+
event
,
properties
);
}
}
},
},
identify
(
userInfo
,
openid
,
unionid
=
null
)
{
profileSet
(
vm
)
{
// 设备身份表示
// 设备身份标识
if
(
AnalysysAgent
)
{
let
setProfile
=
{
openid
:
openid
,
unionid
:
unionid
,
};
setProfile
=
Object
.
assign
(
setProfile
,
userInfo
);
AnalysysAgent
.
profileSet
(
setProfile
);
}
},
setUserId
(
userId
)
{
// 用户id设置
if
(
AnalysysAgent
)
{
if
(
AnalysysAgent
)
{
AnalysysAgent
.
alias
(
userId
+
""
);
let
user
=
vm
.
$u
.
deepClone
(
vm
.
vuex_user
);
let
profile
=
vm
.
$u
.
deepClone
(
vm
.
vuex_auth_user
);
profile
.
openid
=
user
.
wxopenid
||
profile
.
openid
profile
.
unionid
=
user
.
unionid
||
profile
.
unionid
||
null
AnalysysAgent
.
profileSet
(
profile
);
}
}
},
},
setUser
(
user
)
{
profileAppend
(
vm
)
{
// 用户附加属性
if
(
AnalysysAgent
)
{
if
(
AnalysysAgent
)
{
let
userInfo
=
{
let
user
=
vm
.
$u
.
deepClone
(
vm
.
vuex_user
);
mobile
:
user
.
mobile
,
// 用户id设置
userfrom_id
:
user
.
uid
,
AnalysysAgent
.
alias
(
user
.
id
+
""
);
userfrom
:
"自营平台"
,
// 用户附加属性
avatar
:
user
.
avatar
,
let
profile
=
{
nickname
:
user
.
nickname
,
userfrom
:
"自营平台"
,
username
:
user
.
username
,
id
:
user
.
id
,
wxhuid
:
user
.
wxhuid
,
mobile
:
user
.
mobile
,
id
:
user
.
id
,
loginName
:
user
.
loginName
,
money
:
user
.
money
,
source
:
user
.
score
,
score
:
user
.
score
,
};
};
Object
.
keys
(
userInfo
).
map
((
key
)
=>
{
Object
.
keys
(
profile
).
map
((
key
)
=>
{
if
(
key
&&
userInfo
[
key
])
{
if
(
key
&&
profile
[
key
])
{
AnalysysAgent
.
profileAppend
(
key
,
userInfo
[
key
]);
AnalysysAgent
.
profileAppend
(
key
,
profile
[
key
]);
}
}
});
});
}
}
...
...
src/components/mine/customer.vue
View file @
3bbc3075
...
@@ -32,6 +32,7 @@
...
@@ -32,6 +32,7 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
util
from
'@/utils/util.js'
export
default
{
export
default
{
props
:
{
props
:
{
type
:
{
// exclusive:专属; mine:我的页面客服; pop:弹窗;
type
:
{
// exclusive:专属; mine:我的页面客服; pop:弹窗;
...
@@ -44,13 +45,14 @@
...
@@ -44,13 +45,14 @@
},
},
computed
:
{
computed
:
{
cusQrcode
()
{
cusQrcode
()
{
return
process
.
uniEnv
.
qn_base_url
+
(
this
.
isMine
?
'erweima-rk.png'
:
'dingdanzhushou-n.png'
)
let
src
=
this
.
isMine
?
'erweima-rk.png'
:
'dingdanzhushou-n.png'
;
},
return
util
.
imageCache
(
this
,
src
)
kefuzxiaoxiImage
()
{
},
return
process
.
uniEnv
.
qn_base_url
+
'kefuzxiaoxi.png'
kefuzxiaoxiImage
()
{
return
util
.
imageCache
(
this
,
'kefuzxiaoxi.png'
)
},
},
minekefutuImage
()
{
minekefutuImage
()
{
return
process
.
uniEnv
.
qn_base_url
+
this
.
imageName
return
util
.
imageCache
(
this
,
this
.
imageName
)
},
},
imageName
()
{
imageName
()
{
return
this
.
isMine
?
'kefufuwu-n.png'
:
'kefutuzs.png'
return
this
.
isMine
?
'kefufuwu-n.png'
:
'kefutuzs.png'
...
@@ -252,19 +254,19 @@
...
@@ -252,19 +254,19 @@
}
}
.settle-button
{
.settle-button
{
margin-bottom
:
14rpx
;
margin-bottom
:
14rpx
;
width
:
400rpx
;
width
:
400rpx
;
height
:
104rpx
;
height
:
104rpx
;
font-size
:
32rpx
;
font-size
:
32rpx
;
background-color
:
#2272FF
;
background-color
:
#2272FF
;
border-radius
:
52rpx
;
border-radius
:
52rpx
;
line-height
:
104rpx
;
line-height
:
104rpx
;
font-weight
:
bold
;
font-weight
:
bold
;
&
.is-mine
{
&
.is-mine
{
width
:
300rpx
;
width
:
300rpx
;
height
:
80rpx
;
height
:
80rpx
;
border-radius
:
40rpx
;
border-radius
:
40rpx
;
line-height
:
80rpx
;
line-height
:
80rpx
;
}
}
}
}
...
@@ -283,4 +285,4 @@
...
@@ -283,4 +285,4 @@
}
}
}
}
}
}
</
style
>
</
style
>
src/pages/index/mine.vue
View file @
3bbc3075
...
@@ -37,6 +37,8 @@
...
@@ -37,6 +37,8 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
util
from
'@/utils/util.js'
import
login
from
"@/utils/login.js"
;
const
app
=
getApp
();
const
app
=
getApp
();
export
default
{
export
default
{
data
()
{
data
()
{
...
@@ -121,10 +123,10 @@
...
@@ -121,10 +123,10 @@
return
this
.
avatar
||
this
.
placeholderImage
return
this
.
avatar
||
this
.
placeholderImage
},
},
wodebeijingImage
()
{
wodebeijingImage
()
{
return
this
.
qnPath
+
'wodebeijing.png'
return
util
.
imageCache
(
this
,
'wodebeijing.png'
)
},
},
placeholderImage
()
{
placeholderImage
()
{
return
this
.
qnPath
+
'touxiang.png'
return
util
.
imageCache
(
this
,
'touxiang.png'
)
},
},
headImageStyle
()
{
headImageStyle
()
{
return
this
.
avatar
?
'width:136rpx; height:136rpx;border-radius:68rpx'
:
'width:144rpx; height:144rpx;border-radius:72rpx'
return
this
.
avatar
?
'width:136rpx; height:136rpx;border-radius:68rpx'
:
'width:144rpx; height:144rpx;border-radius:72rpx'
...
@@ -174,12 +176,12 @@
...
@@ -174,12 +176,12 @@
this
.
$u
.
route
({
url
:
"pages/login/index"
})
this
.
$u
.
route
({
url
:
"pages/login/index"
})
},
},
logout
()
{
logout
()
{
app
.
setUserData
({},
this
)
login
.
setUserData
({},
this
);
app
.
globalData
.
logout
=
true
app
.
globalData
.
logout
=
true
},
},
async
allowLogin
()
{
async
allowLogin
()
{
let
res
=
await
this
.
$u
.
api
.
allowLogin
()
let
res
=
await
this
.
$u
.
api
.
allowLogin
()
if
(
res
&&
res
.
code
==
200
)
{
if
(
res
&&
res
.
code
==
200
)
{
this
.
showSuperButton
=
res
.
data
===
true
this
.
showSuperButton
=
res
.
data
===
true
}
}
...
...
src/pages/login/index.vue
View file @
3bbc3075
...
@@ -45,15 +45,15 @@ export default {
...
@@ -45,15 +45,15 @@ export default {
bindTitle
:
'立即绑定'
,
bindTitle
:
'立即绑定'
,
bindPhone
:
'绑定手机'
,
bindPhone
:
'绑定手机'
,
bindTips
:
'首次登录的用户需绑定手机才可接单'
,
bindTips
:
'首次登录的用户需绑定手机才可接单'
,
code
:
''
code
:
''
,
}
}
},
},
computed
:
{
computed
:
{
logo
()
{
logo
()
{
return
this
.
qnPath
+
'logo.png'
return
util
.
imageCache
(
this
,
'logo.png'
)
},
},
logo2
()
{
logo2
()
{
return
this
.
qnPath
+
'logo-2.png'
return
util
.
imageCache
(
this
,
'logo-2.png'
)
},
},
},
},
onLoad
(
e
)
{
onLoad
(
e
)
{
...
@@ -61,7 +61,7 @@ export default {
...
@@ -61,7 +61,7 @@ export default {
},
},
onShow
()
{
onShow
()
{
// 微信授权过用户信息,则无需重复授权
// 微信授权过用户信息,则无需重复授权
if
(
app
.
globalData
.
authUserInfo
)
{
if
(
this
.
vuex_auth_user
&&
Object
.
keys
(
this
.
vuex_auth_user
).
length
)
{
this
.
needAuth
=
false
this
.
needAuth
=
false
}
}
this
.
getCode
()
this
.
getCode
()
...
@@ -81,9 +81,7 @@ export default {
...
@@ -81,9 +81,7 @@ export default {
desc
:
'用于授权登录'
,
desc
:
'用于授权登录'
,
success
:
function
(
res
)
{
success
:
function
(
res
)
{
const
userInfo
=
res
.
userInfo
;
const
userInfo
=
res
.
userInfo
;
app
.
globalData
.
authUserInfo
=
userInfo
that
.
$u
.
vuex
(
'vuex_auth_user'
,
userInfo
)
app
.
globalData
.
authUserInfo
.
nickName
=
app
.
globalData
.
authUserInfo
.
nickName
||
''
app
.
globalData
.
authUserInfo
.
avatarUrl
=
app
.
globalData
.
authUserInfo
.
avatarUrl
||
''
uni
.
showLoading
({
uni
.
showLoading
({
title
:
'授权中..'
,
title
:
'授权中..'
,
mask
:
true
mask
:
true
...
@@ -115,8 +113,8 @@ export default {
...
@@ -115,8 +113,8 @@ export default {
authLogin
()
{
authLogin
()
{
var
that
=
this
var
that
=
this
let
params
=
{
let
params
=
{
nickname
:
app
.
globalData
.
authUserInfo
.
nickName
,
nickname
:
this
.
vuex_auth_user
.
nickName
||
''
,
avatar
:
app
.
globalData
.
authUserInfo
.
avatarUrl
,
avatar
:
this
.
vuex_auth_user
.
avatarUrl
||
''
,
}
}
login
.
appLogin
().
then
(
res
=>
{
login
.
appLogin
().
then
(
res
=>
{
params
.
code
=
res
.
code
params
.
code
=
res
.
code
...
@@ -124,7 +122,10 @@ export default {
...
@@ -124,7 +122,10 @@ export default {
}).
then
(
res
=>
{
}).
then
(
res
=>
{
uni
.
hideLoading
();
uni
.
hideLoading
();
if
(
res
&&
res
.
code
==
200
&&
res
.
data
&&
res
.
data
.
token
)
{
if
(
res
&&
res
.
code
==
200
&&
res
.
data
&&
res
.
data
.
token
)
{
app
.
setUserData
(
res
.
data
,
that
)
login
.
setUserData
(
res
.
data
,
that
)
app
.
track
(
'auth_login'
,
{
mobile
:
res
.
data
.
mobile
});
app
.
profileSet
(
that
)
app
.
profileAppend
(
that
)
that
.
goBackPage
()
that
.
goBackPage
()
}
else
{
}
else
{
that
.
setLoginStatus
()
that
.
setLoginStatus
()
...
@@ -146,8 +147,8 @@ export default {
...
@@ -146,8 +147,8 @@ export default {
});
});
}
else
if
(
e
.
detail
.
encryptedData
&&
e
.
detail
.
iv
)
{
}
else
if
(
e
.
detail
.
encryptedData
&&
e
.
detail
.
iv
)
{
let
params
=
{
let
params
=
{
nickname
:
app
.
globalData
.
authUserInfo
.
nickName
,
nickname
:
this
.
vuex_auth_user
.
nickName
||
''
,
avatar
:
app
.
globalData
.
authUserInfo
.
avatarUrl
,
avatar
:
this
.
vuex_auth_user
.
avatarUrl
||
''
,
encryptedData
:
e
.
detail
.
encryptedData
,
encryptedData
:
e
.
detail
.
encryptedData
,
iv
:
e
.
detail
.
iv
,
iv
:
e
.
detail
.
iv
,
}
}
...
@@ -160,6 +161,9 @@ export default {
...
@@ -160,6 +161,9 @@ export default {
uni
.
hideLoading
()
uni
.
hideLoading
()
if
(
res
)
{
if
(
res
)
{
app
.
setUserData
(
res
.
data
,
that
)
app
.
setUserData
(
res
.
data
,
that
)
app
.
track
(
'signup_login'
,
{
mobile
:
res
.
data
.
mobile
});
app
.
profileSet
(
that
)
app
.
profileAppend
(
that
)
app
.
getBaseInfo
(
that
)
app
.
getBaseInfo
(
that
)
that
.
goBackPage
()
that
.
goBackPage
()
}
else
{
}
else
{
...
@@ -200,12 +204,14 @@ export default {
...
@@ -200,12 +204,14 @@ export default {
toLogin
(
params
)
{
toLogin
(
params
)
{
login
.
appLogin
().
then
(
res
=>
{
login
.
appLogin
().
then
(
res
=>
{
params
.
code
=
res
.
code
params
.
code
=
res
.
code
console
.
log
(
"params3"
,
params
)
return
login
.
signup
(
params
);
return
login
.
signup
(
params
);
}).
then
(
res
=>
{
}).
then
(
res
=>
{
uni
.
hideLoading
()
uni
.
hideLoading
()
if
(
res
)
{
if
(
res
)
{
app
.
setUserData
(
res
.
data
,
this
)
login
.
setUserData
(
res
.
data
,
this
)
app
.
track
(
'signup_login'
,
{
mobile
:
res
.
data
.
mobile
});
app
.
profileSet
(
this
)
app
.
profileAppend
(
this
)
app
.
getBaseInfo
(
this
)
app
.
getBaseInfo
(
this
)
this
.
goBackPage
()
this
.
goBackPage
()
}
else
{
}
else
{
...
@@ -253,7 +259,7 @@ export default {
...
@@ -253,7 +259,7 @@ export default {
title
:
'登录页'
title
:
'登录页'
});
});
}
else
{
}
else
{
if
(
!
app
.
globalData
.
authUserInfo
)
{
if
(
!
this
.
vuex_auth_user
||
!
Object
.
keys
(
this
.
vuex_auth_user
).
length
)
{
this
.
needAuth
=
true
this
.
needAuth
=
true
uni
.
setNavigationBarTitle
({
uni
.
setNavigationBarTitle
({
title
:
'授权页'
title
:
'授权页'
...
...
src/pages/mine/wallet/index.vue
View file @
3bbc3075
...
@@ -56,6 +56,7 @@
...
@@ -56,6 +56,7 @@
<
script
>
<
script
>
let
now
=
new
Date
(
new
Date
().
toLocaleDateString
()).
getTime
();
let
now
=
new
Date
(
new
Date
().
toLocaleDateString
()).
getTime
();
import
util
from
'@/utils/util.js'
import
Statement
from
"@/components/mine/statement.vue"
import
Statement
from
"@/components/mine/statement.vue"
export
default
{
export
default
{
components
:
{
components
:
{
...
@@ -109,7 +110,7 @@
...
@@ -109,7 +110,7 @@
return
process
.
uniEnv
.
qn_base_url
return
process
.
uniEnv
.
qn_base_url
},
},
qianbaobeijing
()
{
qianbaobeijing
()
{
return
this
.
imageUrl
+
'qianbaobeijing.png'
return
util
.
imageCache
(
this
,
'qianbaobeijing.png'
)
},
},
buttonStyle
()
{
buttonStyle
()
{
return
{
return
{
...
...
src/pages/mine/wallet/settlement.vue
View file @
3bbc3075
...
@@ -44,6 +44,7 @@
...
@@ -44,6 +44,7 @@
<
script
>
<
script
>
let
now
=
new
Date
(
new
Date
().
toLocaleDateString
()).
getTime
();
let
now
=
new
Date
(
new
Date
().
toLocaleDateString
()).
getTime
();
import
util
from
'@/utils/util.js'
import
Settlement
from
"@/components/mine/settlement.vue"
import
Settlement
from
"@/components/mine/settlement.vue"
const
baseinfo
=
{
totalAmount
:
0
,
payableRecordExtendDtos
:
[]}
const
baseinfo
=
{
totalAmount
:
0
,
payableRecordExtendDtos
:
[]}
export
default
{
export
default
{
...
@@ -64,7 +65,7 @@
...
@@ -64,7 +65,7 @@
},
},
computed
:
{
computed
:
{
liushuibeijingImage
()
{
liushuibeijingImage
()
{
return
this
.
imageUrl
+
'liushuibeijing.png'
return
util
.
imageCache
(
this
,
'liushuibeijing.png'
)
},
},
imageUrl
()
{
imageUrl
()
{
return
process
.
uniEnv
.
qn_base_url
return
process
.
uniEnv
.
qn_base_url
...
@@ -73,7 +74,7 @@
...
@@ -73,7 +74,7 @@
return
this
.
loading
||
this
.
info
.
payableRecordExtendDtos
&&
this
.
info
.
payableRecordExtendDtos
.
length
return
this
.
loading
||
this
.
info
.
payableRecordExtendDtos
&&
this
.
info
.
payableRecordExtendDtos
.
length
},
},
banner
()
{
banner
()
{
return
this
.
imageUrl
+
'receipt.png'
return
util
.
imageCache
(
this
,
'receipt.png'
)
},
},
},
},
onLoad
()
{
onLoad
()
{
...
...
src/pages/mine/wallet/statement.vue
View file @
3bbc3075
...
@@ -45,6 +45,7 @@
...
@@ -45,6 +45,7 @@
<
script
>
<
script
>
let
now
=
new
Date
(
new
Date
().
toLocaleDateString
()).
getTime
();
let
now
=
new
Date
(
new
Date
().
toLocaleDateString
()).
getTime
();
const
baseinfo
=
{
expectedAmount
:
0
,
settledAmount
:
0
,
statementList
:
[]}
const
baseinfo
=
{
expectedAmount
:
0
,
settledAmount
:
0
,
statementList
:
[]}
import
util
from
'@/utils/util.js'
import
Statement
from
"@/components/mine/statement.vue"
import
Statement
from
"@/components/mine/statement.vue"
export
default
{
export
default
{
components
:
{
components
:
{
...
@@ -84,13 +85,13 @@
...
@@ -84,13 +85,13 @@
},
},
liushuibeijingImage
()
{
liushuibeijingImage
()
{
return
this
.
imageUrl
+
'liushuibeijing.png'
return
util
.
imageCache
(
this
,
'liushuibeijing.png'
)
},
},
imageUrl
()
{
imageUrl
()
{
return
process
.
uniEnv
.
qn_base_url
return
process
.
uniEnv
.
qn_base_url
},
},
banner
()
{
banner
()
{
return
this
.
imageUrl
+
'receipt.png'
return
util
.
imageCache
(
this
,
'receipt.png'
)
},
},
hasInfo
()
{
hasInfo
()
{
return
this
.
loading
||
this
.
data
.
statementList
&&
this
.
data
.
statementList
.
length
return
this
.
loading
||
this
.
data
.
statementList
&&
this
.
data
.
statementList
.
length
...
...
src/store/index.js
View file @
3bbc3075
...
@@ -12,7 +12,7 @@ try {
...
@@ -12,7 +12,7 @@ try {
}
}
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名
let
saveStateKeys
=
[
'vuex_user'
,
'vuex_wx_uid'
,
'vuex_token'
,
'uploadTask'
];
let
saveStateKeys
=
[
'vuex_user'
,
'vuex_wx_uid'
,
'vuex_token'
,
'
vuex_cache'
,
'
uploadTask'
];
// 保存变量到本地存储中
// 保存变量到本地存储中
const
saveLifeData
=
function
(
key
,
value
)
{
const
saveLifeData
=
function
(
key
,
value
)
{
...
@@ -32,11 +32,14 @@ const store = new Vuex.Store({
...
@@ -32,11 +32,14 @@ const store = new Vuex.Store({
// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
vuex_user
:
lifeData
.
vuex_user
?
lifeData
.
vuex_user
:
{},
vuex_user
:
lifeData
.
vuex_user
?
lifeData
.
vuex_user
:
{},
vuex_token
:
lifeData
.
vuex_token
?
lifeData
.
vuex_token
:
''
,
vuex_token
:
lifeData
.
vuex_token
?
lifeData
.
vuex_token
:
''
,
vuex_cache
:
lifeData
.
vuex_cache
?
lifeData
.
vuex_cache
:
{},
vuex_version
:
'1.0.1'
,
vuex_version
:
'1.0.1'
,
vuex_config
:
{},
vuex_config
:
{},
// 入驻信息
// 入驻信息
vuex_settled
:
null
,
vuex_settled
:
null
,
vuex_wx_uid
:
lifeData
.
vuex_wx_uid
||
0
,
vuex_wx_uid
:
lifeData
.
vuex_wx_uid
||
0
,
// 授权用户信息
vuex_auth_user
:
{},
// 上传队列
// 上传队列
uploadTask
:
lifeData
.
uploadTask
?
lifeData
.
uploadTask
:
[]
uploadTask
:
lifeData
.
uploadTask
?
lifeData
.
uploadTask
:
[]
},
},
...
...
src/utils/login.js
View file @
3bbc3075
...
@@ -116,11 +116,29 @@ function login(provider) {
...
@@ -116,11 +116,29 @@ function login(provider) {
});
});
}
}
/**
* 初始化用户信息
* @param {Object} userInfo 用户信息
* @param {Object} vm Vue对象实例
*/
function
setUserData
(
userInfo
,
vm
)
{
if
(
userInfo
&&
userInfo
.
token
)
{
// 如果已经登录则直接获取相关信息
vm
.
$u
.
vuex
(
"vuex_token"
,
userInfo
.
token
);
vm
.
$u
.
vuex
(
"vuex_user"
,
userInfo
);
vm
.
$u
.
vuex
(
"vuex_wx_uid"
,
userInfo
.
wxopenid
);
}
else
{
vm
.
$u
.
vuex
(
"vuex_token"
,
""
);
vm
.
$u
.
vuex
(
"vuex_user"
,
null
);
vm
.
$u
.
vuex
(
"vuex_wx_uid"
,
""
);
}
vm
.
$u
.
vuex
(
"vuex_settled"
,
null
);
}
module
.
exports
=
{
module
.
exports
=
{
appLogin
:
appLogin
,
appLogin
:
appLogin
,
authorization
:
authorization
,
authorization
:
authorization
,
signup
:
signup
,
signup
:
signup
,
oauth
:
oauth
oauth
:
oauth
,
setUserData
,
}
}
\ No newline at end of file
src/utils/util.js
View file @
3bbc3075
var
t
=
function
(
t
)
{
import
md5Libs
from
"uview-ui/libs/function/md5"
;
return
(
t
=
t
.
toString
())[
1
]
?
t
:
"0"
+
t
;
var
t
=
function
(
t
)
{
return
(
t
=
t
.
toString
())[
1
]
?
t
:
"0"
+
t
;
};
};
// const getToken = function(){
// const getToken = function(){
...
@@ -18,44 +19,74 @@ var t = function(t) {
...
@@ -18,44 +19,74 @@ var t = function(t) {
// }
// }
// }
// }
const
getOpenid
=
function
()
{
const
getOpenid
=
function
()
{
const
app
=
getApp
()
const
app
=
getApp
()
let
openid
=
app
&&
app
.
globalData
&&
app
.
globalData
.
openid
||
''
let
openid
=
app
&&
app
.
globalData
&&
app
.
globalData
.
openid
||
''
if
(
!
openid
)
{
if
(
!
openid
)
{
openid
=
uni
.
getStorageSync
(
'openid'
)
openid
=
uni
.
getStorageSync
(
'openid'
)
}
}
return
openid
return
openid
}
}
const
setOpenid
=
function
(
openid
)
{
const
setOpenid
=
function
(
openid
)
{
const
app
=
getApp
()
const
app
=
getApp
()
uni
.
setStorageSync
(
'openid'
,
openid
)
uni
.
setStorageSync
(
'openid'
,
openid
)
if
(
app
&&
app
.
globalData
)
{
if
(
app
&&
app
.
globalData
)
{
app
.
globalData
.
openid
=
openid
app
.
globalData
.
openid
=
openid
}
}
}
}
/**
* ====图片本地缓存====
* @param {Object} vm 当前vue实例
* @param {Object} src 图片地址
* @param {Object} host 图片前缀,默认使用qn_base_url
*/
const
imageCache
=
function
(
vm
,
src
,
host
)
{
host
=
host
||
process
.
uniEnv
.
qn_base_url
let
image_url
=
host
+
src
let
image_name
=
md5Libs
.
md5
(
image_url
)
var
arr
=
Object
.
keys
(
vm
.
vuex_cache
);
if
(
vm
.
vuex_cache
&&
arr
.
length
&&
arr
.
includes
(
image_name
))
{
// call_back(vm.vuex_cache[image_name])
return
vm
.
vuex_cache
[
image_name
]
}
else
{
// 本地没有缓存 需要下载
uni
.
downloadFile
({
url
:
image_url
,
success
:
(
res
)
=>
{
if
(
res
.
statusCode
===
200
)
{
// call_back(res.tempFilePath)
vm
.
$u
.
vuex
(
`vuex_cache.
${
image_name
}
`
,
res
.
tempFilePath
)
}
}
});
return
image_url
}
}
module
.
exports
=
{
module
.
exports
=
{
formatTime
:
function
(
n
)
{
formatTime
:
function
(
n
)
{
var
e
=
n
.
getFullYear
(),
r
=
n
.
getMonth
()
+
1
,
o
=
n
.
getDate
(),
i
=
n
.
getHours
(),
u
=
n
.
getMinutes
(),
a
=
n
.
getSeconds
();
var
e
=
n
.
getFullYear
(),
r
=
n
.
getMonth
()
+
1
,
o
=
n
.
getDate
(),
i
=
n
.
getHours
(),
u
=
n
.
getMinutes
(),
a
=
n
.
getSeconds
();
return
[
e
,
r
,
o
].
map
(
t
).
join
(
"-"
)
+
" "
+
[
i
,
u
,
a
].
map
(
t
).
join
(
":"
);
return
[
e
,
r
,
o
].
map
(
t
).
join
(
"-"
)
+
" "
+
[
i
,
u
,
a
].
map
(
t
).
join
(
":"
);
},
},
throttle
:
function
(
t
,
n
)
{
throttle
:
function
(
t
,
n
)
{
null
!=
n
&&
null
!=
n
||
(
n
=
1500
);
null
!=
n
&&
null
!=
n
||
(
n
=
1500
);
var
e
=
null
;
var
e
=
null
;
return
function
()
{
return
function
()
{
var
r
=
+
new
Date
();
var
r
=
+
new
Date
();
console
.
log
(
r
+
","
+
e
+
","
+
new
Date
()),
(
r
-
e
>
n
||
!
e
)
&&
(
t
(),
e
=
r
);
console
.
log
(
r
+
","
+
e
+
","
+
new
Date
()),
(
r
-
e
>
n
||
!
e
)
&&
(
t
(),
e
=
r
);
};
};
},
},
formatLonLat
:
function
(
t
,
n
)
{
formatLonLat
:
function
(
t
,
n
)
{
if
(
void
0
===
t
||
""
==
t
)
return
""
;
if
(
void
0
===
t
||
""
==
t
)
return
""
;
if
(
t
+=
""
,
0
==
n
)
return
parseFloat
(
t
).
toFixed
(
6
);
if
(
t
+=
""
,
0
==
n
)
return
parseFloat
(
t
).
toFixed
(
6
);
var
e
=
t
.
indexOf
(
"."
),
r
=
e
<
0
?
t
:
t
.
substring
(
0
,
e
),
o
=
0
,
i
=
0
;
var
e
=
t
.
indexOf
(
"."
),
r
=
e
<
0
?
t
:
t
.
substring
(
0
,
e
),
o
=
0
,
i
=
0
;
return
e
>
0
&&
(
o
=
60
*
(
o
=
"0"
+
t
.
substring
(
e
))
+
""
,
2
==
n
?
(
e
=
o
.
indexOf
(
"."
))
>
0
&&
(
i
=
"0"
+
o
.
substring
(
e
),
return
e
>
0
&&
(
o
=
60
*
(
o
=
"0"
+
t
.
substring
(
e
))
+
""
,
2
==
n
?
(
e
=
o
.
indexOf
(
"."
))
>
0
&&
(
i
=
"0"
+
o
.
substring
(
e
),
o
=
o
.
substring
(
0
,
e
),
e
=
(
i
=
60
*
i
+
""
).
indexOf
(
"."
),
i
=
i
.
substring
(
0
,
e
+
4
),
o
=
o
.
substring
(
0
,
e
),
e
=
(
i
=
60
*
i
+
""
).
indexOf
(
"."
),
i
=
i
.
substring
(
0
,
e
+
4
),
i
=
parseFloat
(
i
).
toFixed
(
0
))
:
1
==
n
&&
(
o
=
parseFloat
(
o
).
toFixed
(
6
))),
2
==
n
?
r
+
"°"
+
o
+
"′"
+
i
+
"″"
:
1
==
n
?
r
+
"°"
+
o
+
"′"
:
void
0
;
i
=
parseFloat
(
i
).
toFixed
(
0
))
:
1
==
n
&&
(
o
=
parseFloat
(
o
).
toFixed
(
6
))),
2
==
n
?
r
+
"°"
+
o
+
"′"
+
i
+
"″"
:
1
==
n
?
r
+
"°"
+
o
+
"′"
:
void
0
;
},
},
// getToken,
// getToken,
// setToken,
// setToken,
getOpenid
,
getOpenid
,
setOpenid
,
setOpenid
,
imageCache
,
};
};
\ No newline at end of file
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