Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
X
XiTianSenMall
Project
Project
Details
Activity
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
leiqingsong
XiTianSenMall
Commits
c1ae3320
Commit
c1ae3320
authored
Mar 13, 2021
by
xulili
Browse files
Options
Browse Files
Download
Plain Diff
merge
parents
b0255731
fda7ecc8
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
84 additions
and
30 deletions
+84
-30
App.vue
H5/src/App.vue
+7
-2
bridgeToAppFun.js
H5/src/utils/bridgeToAppFun.js
+52
-18
localGetter.js
H5/src/utils/localGetter.js
+8
-0
request.js
H5/src/utils/request.js
+1
-4
grade.vue
H5/src/views/grade.vue
+1
-1
invite.vue
H5/src/views/invite.vue
+1
-1
leagueNums.vue
H5/src/views/leagueNums.vue
+1
-2
publish.vue
H5/src/views/moments/publish.vue
+1
-1
settings.vue
H5/src/views/settings.vue
+12
-1
No files found.
H5/src/App.vue
View file @
c1ae3320
...
...
@@ -22,8 +22,13 @@ export default {
this
.
currentTitle
=
val
.
meta
.
title
;
}
},
mounted
()
{
getAuthToken
()
created
()
{
console
.
log
(
'和App开始交互'
);
getAuthToken
().
then
(
res
=>
{
console
.
log
(
'获取token成功'
,
res
);
}).
catch
(
err
=>
{
console
.
log
(
'获取token失败'
,
err
);
})
}
};
</
script
>
...
...
H5/src/utils/bridgeToAppFun.js
View file @
c1ae3320
// H5 去调用App的方法
import
jsBridge
from
"./bridge"
;
import
{
getUserInfo
}
from
"@/api/user"
;
function
saveUser
(
data
)
{
localStorage
.
setItem
(
"token"
,
data
);
if
(
data
)
{
getUserInfo
().
then
(
res
=>
{
console
.
log
(
'存用户信息'
);
console
.
log
(
res
);
console
.
log
(
'----'
);
if
(
res
.
code
==
0
)
{
localStorage
.
setItem
(
"user"
,
JSON
.
stringify
(
res
.
data
));
}
})
}
else
{
console
.
log
(
"调用失败"
);
}
}
// 获取Token
export
function
getAuthToken
()
{
getUserInfo
().
then
()
// return new Promise((resolve, reject) => {
// console.log("调用1");
jsBridge
.
callhandler
(
"getAuthToken"
,
null
,
data
=>
{
console
.
log
(
"调用2"
);
localStorage
.
setItem
(
"token"
,
data
);
console
.
log
(
"--------------"
);
if
(
data
)
{
getUserInfo
().
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
localStorage
.
setItem
(
"user"
,
JSON
.
stringify
(
res
.
data
));
}
})
// resolve(data);
const
userAgent
=
navigator
.
userAgent
;
console
.
log
(
"ua"
,
userAgent
);
if
(
userAgent
.
indexOf
(
'Android'
)
>
-
1
||
userAgent
.
indexOf
(
'Adr'
)
>
-
1
)
{
// android
console
.
log
(
"android, 和安卓交互"
);
const
token
=
window
.
android
.
getAuthToken
();
console
.
log
(
'an-token'
,
token
);
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
token
)
{
saveUser
(
token
);
resolve
(
token
)
}
else
{
// reject("调用失败,未返回data");
console
.
log
(
"调用失败"
);
reject
(
'失败'
)
}
});
// });
})
}
else
if
(
userAgent
.
match
(
/
\(
i
[^
;
]
+;
(
U;
)?
CPU.+Mac OS X/
))
{
// ios
console
.
log
(
"ios"
);
return
new
Promise
((
resolve
,
reject
)
=>
{
console
.
log
(
"调用1"
);
jsBridge
.
callhandler
(
"getAuthToken"
,
null
,
data
=>
{
console
.
log
(
"调用2"
);
localStorage
.
setItem
(
"token"
,
data
);
console
.
log
(
"--------------"
);
if
(
data
)
{
resolve
(
data
)
getUserInfo
().
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
localStorage
.
setItem
(
"user"
,
JSON
.
stringify
(
res
.
data
));
}
})
}
else
{
console
.
log
(
"调用失败"
);
reject
(
"getAuthToken"
,
data
);
}
});
})
}
}
// 退出
export
function
logoutToApp
()
{
console
.
log
(
"退出登录"
);
jsBridge
.
callhandler
(
"logout"
);
}
H5/src/utils/localGetter.js
View file @
c1ae3320
export
function
getUserId
()
{
<<<<<<<
HEAD
let
userInfo
=
localStorage
.
getItem
(
'user'
)
if
(
userInfo
){
return
JSON
.
parse
(
userInfo
).
userId
||
''
;
...
...
@@ -6,4 +7,11 @@ export function getUserId() {
return
''
}
=======
if
(
localStorage
.
getItem
(
"user"
))
{
return
JSON
.
parse
(
localStorage
.
getItem
(
'user'
)).
userId
;
}
else
{
return
""
;
}
>>>>>>>
fda7ecc8c9d2dc436d2ae853fbd549faf9b8cb85
}
\ No newline at end of file
H5/src/utils/request.js
View file @
c1ae3320
...
...
@@ -11,8 +11,7 @@ const service = axios.create({
service
.
interceptors
.
request
.
use
(
config
=>
{
// const token = localStorage.getItem("token");
const
token
=
"b5f71c00b8fa4fe6b2eac577d9f15e19"
;
const
token
=
localStorage
.
getItem
(
"token"
);
// config.headers["Authorization"] = "Bearer " + token;
config
.
headers
[
"token"
]
=
token
;
if
(
!
config
.
loading
)
{
...
...
@@ -25,8 +24,6 @@ service.interceptors.request.use(
},
error
=>
{
if
(
loading
)
Toast
.
clear
();
console
.
log
(
"rqquest====错误"
,
error
);
console
.
log
(
error
);
this
.
$toast
.
fail
(
error
.
response
.
data
.
error
);
}
);
...
...
H5/src/views/grade.vue
View file @
c1ae3320
...
...
@@ -107,7 +107,7 @@ export default {
this
.
$router
.
push
({
name
:
urlName
});
},
getstatus
()
{
const
userId
=
13933770749
;
const
userId
=
this
.
$userId
;
const
_this
=
this
;
getForestStatus
(
userId
).
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
...
...
H5/src/views/invite.vue
View file @
c1ae3320
...
...
@@ -5,7 +5,7 @@
</
template
>
<
script
>
import
{
inviteCode
}
from
"@/api/invite"
;
var
userId
=
"13933770749"
;
var
userId
=
this
.
$userId
;
export
default
{
data
()
{
return
{
...
...
H5/src/views/leagueNums.vue
View file @
c1ae3320
...
...
@@ -21,7 +21,6 @@
</
template
>
<
script
>
var
userId
=
13100911369
;
import
{
getMyTeam
}
from
"@/api/grade"
;
export
default
{
name
:
"leagueNums"
,
...
...
@@ -76,7 +75,7 @@ export default {
},
methods
:
{
getMyTeam
()
{
getMyTeam
(
userId
).
then
(
res
=>
{
getMyTeam
(
this
.
$
userId
).
then
(
res
=>
{
if
(
res
.
data
)
{
this
.
list
.
forEach
(
v
=>
{
v
.
num
=
res
.
data
[
v
[
"field"
]];
...
...
H5/src/views/moments/publish.vue
View file @
c1ae3320
...
...
@@ -51,7 +51,7 @@ export default {
fd
.
append
(
"files"
,
file
.
file
);
});
fd
.
append
(
"zxField"
,
this
.
message
);
fd
.
append
(
"userId"
,
"13100911369"
);
fd
.
append
(
"userId"
,
this
.
$userId
);
uploadImage
(
fd
).
then
();
},
openPopup
()
{
...
...
H5/src/views/settings.vue
View file @
c1ae3320
<
template
>
<div
class=
"settings"
>
<van-cell-group
class=
"group-1"
>
<van-cell
title=
"用户名"
value=
"135****1234
"
/>
<van-cell
title=
"用户名"
:value=
"$userId
"
/>
<van-cell
is-link
center
title=
"头像"
@
click=
"onModefy"
>
<img
class=
"avatar-img"
...
...
@@ -46,6 +46,7 @@
</
template
>
<
script
>
import
{
getUserInfo
}
from
"@/api/user"
;
import
{
logoutToApp
}
from
"@/utils/bridgeToAppFun"
;
import
{
logout
}
from
"@/api/user"
;
import
{
fillInviteCode
}
from
"@/api/user"
;
...
...
@@ -61,7 +62,17 @@ export default {
inviteeCodeDialog
:
false
};
},
created
()
{
this
.
getUser
()
},
methods
:
{
getUser
()
{
getUserInfo
().
then
(
res
=>
{
if
(
res
.
code
===
0
)
{
localStorage
.
setItem
(
"user"
,
JSON
.
stringify
(
res
.
data
));
}
})
},
logout
()
{
const
params
=
{
token
:
"qwedskdljlkjlklkjlkjlkjl"
...
...
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