Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
micro-customization-system
/
e-shield-h5
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 92ed03bc
authored
Jul 21, 2022
by
zhangxw
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
分享逻辑调整
1 parent
2a3d8618
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
144 additions
and
50 deletions
src/api/index.js
src/assets/css/share.scss
src/components/mapContent.vue
src/components/top-tab.vue
src/views/index.vue
src/views/info.vue
src/api/index.js
View file @
92ed03b
...
...
@@ -39,3 +39,13 @@ export const SET_FREQ = (params) => {
export
const
ADD_FENCE
=
(
params
)
=>
{
return
request
(
params
,
`
${
prefix
}
/fence/add`
,
"POST"
);
};
// 获取分享id
export
const
GET_SHARE_ID
=
(
params
)
=>
{
return
request
(
params
,
`
${
prefix
}
/share/vehicle`
);
};
// 校验分享时效性 是否可用
export
const
CHECK_SHARE
=
(
params
)
=>
{
return
request
(
params
,
`
${
prefix
}
/vehicle/sharedDetails`
);
};
src/assets/css/share.scss
0 → 100644
View file @
92ed03b
.icon-share
{
position
:
absolute
;
top
:
20px
;
right
:
70px
;
}
.tip
{
margin-top
:
105px
;
text-align
:
center
;
color
:
#fff
;
font-size
:
16px
;
.fle
{
display
:
inline-block
;
width
:
18px
;
height
:
22px
;
vertical-align
:
middle
;
}
.sharebtn
{
display
:
inline-block
;
width
:
4px
;
height
:
4px
;
margin
:
1px
;
background
:
#fff
;
border-radius
:
50%
;
}
.sharebtn.middle
{
width
:
6px
;
height
:
6px
;
margin
:
0
;
}
}
\ No newline at end of file
src/components/mapContent.vue
View file @
92ed03b
...
...
@@ -29,10 +29,10 @@ export default {
let
checkLoadedTimeoutId
=
""
;
const
satelActive
=
ref
(
null
);
const
roadActive
=
ref
(
null
);
const
sharePage
=
ref
(
tru
e
);
const
sharePage
=
ref
(
fals
e
);
onMounted
(()
=>
{});
const
initMap
=
(
id
)
=>
{
// sharePage.value = localStorage.getItem("sharePage"
);
sharePage
.
value
=
JSON
.
parse
(
localStorage
.
getItem
(
"sharePage"
)
);
let
check
=
()
=>
{
checkLoadedTimeoutId
&&
window
.
clearTimeout
(
checkLoadedTimeoutId
);
let
AMap
=
window
.
AMap
;
...
...
src/components/top-tab.vue
View file @
92ed03b
...
...
@@ -44,6 +44,10 @@ export default {
}
});
}
console
.
log
(
localStorage
.
getItem
(
"sharePage"
));
if
(
localStorage
.
getItem
(
"sharePage"
))
{
routesArr
.
splice
(
routesArr
.
length
-
1
,
1
);
}
await
cb
();
};
filterTabs
(()
=>
{
...
...
src/views/index.vue
View file @
92ed03b
...
...
@@ -73,6 +73,19 @@
</div>
</div>
</div>
<van-overlay
:show=
"showOverlay"
@
click=
"showOverlay = false"
:z-index=
"100000"
>
<span
class=
"icon icon-share"
></span>
<p
class=
"tip"
>
点击右上角“
<span
class=
"fle"
><span
class=
"sharebtn"
></span><span
class=
"sharebtn middle"
></span
><span
class=
"sharebtn"
></span></span
>
”转发/分享
</p>
</van-overlay>
</div>
</template>
...
...
@@ -87,7 +100,13 @@ import wx from "wx";
import
{
useRoute
}
from
"vue-router"
;
import
{
Dialog
,
Toast
}
from
"vant"
;
import
"vant/es/toast/style"
;
import
{
GET_ALL_CAR_LIST
,
GET_CAR_LOCATION_INFO
}
from
"@/api/index"
;
import
moment
from
"@/utils/moment"
;
import
{
GET_ALL_CAR_LIST
,
GET_CAR_LOCATION_INFO
,
GET_SHARE_ID
,
CHECK_SHARE
,
}
from
"@/api/index"
;
export
default
defineComponent
({
name
:
"IndexPage"
,
components
:
{
...
...
@@ -101,8 +120,7 @@ export default defineComponent({
const
finished
=
ref
(
false
);
const
list
=
ref
([]);
const
carItem
=
ref
(
null
);
const
loginUserId
=
ref
(
""
);
const
isShareDead
=
ref
(
1
);
const
isShareDead
=
ref
(
false
);
const
carInfoList
=
ref
([]);
const
route
=
useRoute
();
const
routeQuery
=
ref
(
null
);
...
...
@@ -111,7 +129,10 @@ export default defineComponent({
const
mapIsUploaded
=
ref
(
false
);
const
store
=
useStore
();
const
ISLOADING
=
computed
(()
=>
store
.
state
.
LOADING
);
const
showOverlay
=
ref
(
false
);
let
isSharePage
=
false
;
let
map
=
undefined
;
let
_timeoutId
=
undefined
;
const
refreshCb
=
()
=>
{
if
(
map
&&
carItem
.
value
)
{
map
&&
map
.
clearMap
();
...
...
@@ -124,12 +145,6 @@ export default defineComponent({
// 被分享者打开直接获取车辆定位数据
routeQuery
.
value
=
route
.
query
;
if
(
newVal
&&
routeQuery
.
value
.
sn
)
{
if
(
route
.
query
.
token
)
{
localStorage
.
setItem
(
"token"
,
route
.
query
.
token
);
}
if
(
route
.
query
.
sharePage
)
{
localStorage
.
setItem
(
"sharePage"
,
true
);
}
carItem
.
value
=
{
sns
:
routeQuery
.
value
.
sn
,
ownerName
:
...
...
@@ -138,15 +153,53 @@ export default defineComponent({
:
routeQuery
.
value
.
ownerName
,
vin
:
routeQuery
.
value
.
vin
==
"null"
?
"--"
:
routeQuery
.
value
.
vin
,
};
getCarInfo
(
carItem
.
value
);
if
(
route
.
query
.
token
)
{
localStorage
.
setItem
(
"token"
,
route
.
query
.
token
);
}
if
(
JSON
.
parse
(
route
.
query
.
sharePage
))
{
localStorage
.
setItem
(
"sharePage"
,
JSON
.
parse
(
route
.
query
.
sharePage
));
// 获取分享id
GET_SHARE_ID
({
vehicleId
:
Number
(
routeQuery
.
value
.
id
)
}).
then
(
(
res
)
=>
{
if
(
res
.
code
==
200
)
{
// 校验分享链接是否有效
CHECK_SHARE
({
shareId
:
res
.
data
}).
then
((
v
)
=>
{
if
(
v
.
code
==
200
)
{
if
(
v
.
data
&&
v
.
data
.
setting
&&
v
.
data
.
setting
.
enableStatus
!==
1
)
{
Dialog
({
message
:
"该分享无效,请启用后使用"
});
}
else
if
(
v
.
data
&&
v
.
data
.
setting
&&
moment
().
isAfter
(
moment
(
v
.
data
.
setting
.
expirationDate
))
)
{
isShareDead
.
value
=
true
;
Dialog
({
message
:
"该分享已失效"
});
}
else
{
getCarInfo
(
carItem
.
value
);
// 校验分享时效性
checkIsShareDead
(
res
.
data
);
}
}
});
}
}
);
}
}
});
onMounted
(()
=>
{
getCarList
(
);
localStorage
.
removeItem
(
"sharePage"
);
if
(
route
.
query
.
token
)
{
localStorage
.
setItem
(
"token"
,
route
.
query
.
token
);
}
localStorage
.
removeItem
(
"sharePage"
);
if
(
route
.
query
.
sharePage
)
{
localStorage
.
setItem
(
"sharePage"
,
JSON
.
parse
(
route
.
query
.
sharePage
));
isSharePage
=
JSON
.
parse
(
route
.
query
.
sharePage
);
}
AMapLoader
.
load
({
key
:
CONSTANT
.
MAP_KEY
,
version
:
"1.4.8"
,
...
...
@@ -156,6 +209,27 @@ export default defineComponent({
mapContentRefs
.
value
.
initMap
(
"container"
);
});
});
const
checkIsShareDead
=
(
id
)
=>
{
if
(
_timeoutId
)
{
clearTimeout
(
_timeoutId
);
}
_timeoutId
=
setTimeout
(()
=>
{
CHECK_SHARE
({
shareId
:
id
}).
then
((
v
)
=>
{
if
(
v
.
code
==
200
)
{
if
(
(
v
.
data
&&
v
.
data
.
setting
&&
v
.
data
.
setting
.
enableStatus
!==
1
)
||
(
v
.
data
&&
v
.
data
.
setting
&&
moment
().
isAfter
(
moment
(
v
.
data
.
setting
.
expirationDate
)))
)
{
isShareDead
.
value
=
true
;
}
else
{
checkIsShareDead
();
}
}
});
},
1000
*
60
*
5
);
};
const
isUploaded
=
(
data
)
=>
{
mapIsUploaded
.
value
=
data
;
};
...
...
@@ -327,6 +401,9 @@ export default defineComponent({
carFenceBtn
&&
carFenceBtn
.
classList
.
add
(
"disabled"
);
}
if
(
isSharePage
)
{
shareBtn
&&
shareBtn
.
classList
.
add
(
"disabled"
);
}
// 点击GPS
GPSBtn
&&
(
GPSBtn
.
onclick
=
()
=>
{
...
...
@@ -444,7 +521,7 @@ export default defineComponent({
// 电子围栏
(
carFenceBtn
&&
carFenceBtn
).
onclick
=
()
=>
{
if
(
loginUserId
.
value
||
item
.
source
==
0
)
{
if
(
item
.
source
==
0
)
{
return
;
}
else
{
wx
.
miniProgram
.
navigateTo
({
...
...
@@ -454,9 +531,10 @@ export default defineComponent({
};
// 分享找车
shareBtn
.
onclick
=
()
=>
{
wx
.
miniProgram
.
navigateTo
({
url
:
`../../mapPackage/pages/findCar?sn=
${
item
.
sn
}
&tabItem=share&source=
${
item
.
source
}
&locationType=
${
item
.
locationType
}
`
,
});
if
(
isSharePage
)
{
return
;
}
showOverlay
.
value
=
true
;
};
//点击车辆打开信息窗体
marker
.
on
(
"click"
,
()
=>
{
...
...
@@ -471,7 +549,7 @@ export default defineComponent({
return
marker
;
};
const
check
=
(
cb
)
=>
{
if
(
loginUserId
.
value
&&
isShareDead
.
value
)
{
if
(
isShareDead
.
value
)
{
Toast
(
"该分享已失效"
);
return
;
}
...
...
@@ -514,7 +592,6 @@ export default defineComponent({
list
,
getCarList
,
getCarInfo
,
loginUserId
,
check
,
carInfoList
,
carItem
,
...
...
@@ -524,12 +601,14 @@ export default defineComponent({
mapIsUploaded
,
routeQuery
,
ISLOADING
,
showOverlay
,
};
},
});
</
script
>
<
style
lang=
"scss"
scoped
>
@import
"@/assets/css/share.scss"
;
.index-map
{
position
:
relative
;
}
...
...
src/views/info.vue
View file @
92ed03b
...
...
@@ -112,34 +112,5 @@ export default defineComponent({
});
</
script
>
<
style
lang=
"scss"
scoped
>
.icon-share
{
position
:
absolute
;
top
:
20px
;
right
:
65px
;
}
.tip
{
margin-top
:
105px
;
text-align
:
center
;
color
:
#fff
;
font-size
:
16px
;
.fle
{
display
:
inline-block
;
width
:
18px
;
height
:
22px
;
vertical-align
:
middle
;
}
.sharebtn
{
display
:
inline-block
;
width
:
4px
;
height
:
4px
;
margin
:
1px
;
background
:
#fff
;
border-radius
:
50%
;
}
.sharebtn.middle
{
width
:
6px
;
height
:
6px
;
margin
:
0
;
}
}
@import
"@/assets/css/share.scss"
;
</
style
>
Write
Preview
Markdown
is supported
Attach a file
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 post a comment