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
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
143 additions
and
49 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) => {
...
@@ -39,3 +39,13 @@ export const SET_FREQ = (params) => {
export
const
ADD_FENCE
=
(
params
)
=>
{
export
const
ADD_FENCE
=
(
params
)
=>
{
return
request
(
params
,
`
${
prefix
}
/fence/add`
,
"POST"
);
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
\ No newline at end of file
src/components/mapContent.vue
View file @
92ed03b
...
@@ -29,10 +29,10 @@ export default {
...
@@ -29,10 +29,10 @@ export default {
let
checkLoadedTimeoutId
=
""
;
let
checkLoadedTimeoutId
=
""
;
const
satelActive
=
ref
(
null
);
const
satelActive
=
ref
(
null
);
const
roadActive
=
ref
(
null
);
const
roadActive
=
ref
(
null
);
const
sharePage
=
ref
(
tru
e
);
const
sharePage
=
ref
(
fals
e
);
onMounted
(()
=>
{});
onMounted
(()
=>
{});
const
initMap
=
(
id
)
=>
{
const
initMap
=
(
id
)
=>
{
// sharePage.value = localStorage.getItem("sharePage"
);
sharePage
.
value
=
JSON
.
parse
(
localStorage
.
getItem
(
"sharePage"
)
);
let
check
=
()
=>
{
let
check
=
()
=>
{
checkLoadedTimeoutId
&&
window
.
clearTimeout
(
checkLoadedTimeoutId
);
checkLoadedTimeoutId
&&
window
.
clearTimeout
(
checkLoadedTimeoutId
);
let
AMap
=
window
.
AMap
;
let
AMap
=
window
.
AMap
;
...
...
src/components/top-tab.vue
View file @
92ed03b
...
@@ -44,6 +44,10 @@ export default {
...
@@ -44,6 +44,10 @@ export default {
}
}
});
});
}
}
console
.
log
(
localStorage
.
getItem
(
"sharePage"
));
if
(
localStorage
.
getItem
(
"sharePage"
))
{
routesArr
.
splice
(
routesArr
.
length
-
1
,
1
);
}
await
cb
();
await
cb
();
};
};
filterTabs
(()
=>
{
filterTabs
(()
=>
{
...
...
src/views/index.vue
View file @
92ed03b
...
@@ -73,6 +73,19 @@
...
@@ -73,6 +73,19 @@
</div>
</div>
</div>
</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>
</div>
</template>
</template>
...
@@ -87,7 +100,13 @@ import wx from "wx";
...
@@ -87,7 +100,13 @@ import wx from "wx";
import
{
useRoute
}
from
"vue-router"
;
import
{
useRoute
}
from
"vue-router"
;
import
{
Dialog
,
Toast
}
from
"vant"
;
import
{
Dialog
,
Toast
}
from
"vant"
;
import
"vant/es/toast/style"
;
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
({
export
default
defineComponent
({
name
:
"IndexPage"
,
name
:
"IndexPage"
,
components
:
{
components
:
{
...
@@ -101,8 +120,7 @@ export default defineComponent({
...
@@ -101,8 +120,7 @@ export default defineComponent({
const
finished
=
ref
(
false
);
const
finished
=
ref
(
false
);
const
list
=
ref
([]);
const
list
=
ref
([]);
const
carItem
=
ref
(
null
);
const
carItem
=
ref
(
null
);
const
loginUserId
=
ref
(
""
);
const
isShareDead
=
ref
(
false
);
const
isShareDead
=
ref
(
1
);
const
carInfoList
=
ref
([]);
const
carInfoList
=
ref
([]);
const
route
=
useRoute
();
const
route
=
useRoute
();
const
routeQuery
=
ref
(
null
);
const
routeQuery
=
ref
(
null
);
...
@@ -111,7 +129,10 @@ export default defineComponent({
...
@@ -111,7 +129,10 @@ export default defineComponent({
const
mapIsUploaded
=
ref
(
false
);
const
mapIsUploaded
=
ref
(
false
);
const
store
=
useStore
();
const
store
=
useStore
();
const
ISLOADING
=
computed
(()
=>
store
.
state
.
LOADING
);
const
ISLOADING
=
computed
(()
=>
store
.
state
.
LOADING
);
const
showOverlay
=
ref
(
false
);
let
isSharePage
=
false
;
let
map
=
undefined
;
let
map
=
undefined
;
let
_timeoutId
=
undefined
;
const
refreshCb
=
()
=>
{
const
refreshCb
=
()
=>
{
if
(
map
&&
carItem
.
value
)
{
if
(
map
&&
carItem
.
value
)
{
map
&&
map
.
clearMap
();
map
&&
map
.
clearMap
();
...
@@ -124,12 +145,6 @@ export default defineComponent({
...
@@ -124,12 +145,6 @@ export default defineComponent({
// 被分享者打开直接获取车辆定位数据
// 被分享者打开直接获取车辆定位数据
routeQuery
.
value
=
route
.
query
;
routeQuery
.
value
=
route
.
query
;
if
(
newVal
&&
routeQuery
.
value
.
sn
)
{
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
=
{
carItem
.
value
=
{
sns
:
routeQuery
.
value
.
sn
,
sns
:
routeQuery
.
value
.
sn
,
ownerName
:
ownerName
:
...
@@ -138,15 +153,53 @@ export default defineComponent({
...
@@ -138,15 +153,53 @@ export default defineComponent({
:
routeQuery
.
value
.
ownerName
,
:
routeQuery
.
value
.
ownerName
,
vin
:
routeQuery
.
value
.
vin
==
"null"
?
"--"
:
routeQuery
.
value
.
vin
,
vin
:
routeQuery
.
value
.
vin
==
"null"
?
"--"
:
routeQuery
.
value
.
vin
,
};
};
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
);
getCarInfo
(
carItem
.
value
);
// 校验分享时效性
checkIsShareDead
(
res
.
data
);
}
}
});
}
}
);
}
}
}
});
});
onMounted
(()
=>
{
onMounted
(()
=>
{
getCarList
(
);
localStorage
.
removeItem
(
"sharePage"
);
if
(
route
.
query
.
token
)
{
if
(
route
.
query
.
token
)
{
localStorage
.
setItem
(
"token"
,
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
({
AMapLoader
.
load
({
key
:
CONSTANT
.
MAP_KEY
,
key
:
CONSTANT
.
MAP_KEY
,
version
:
"1.4.8"
,
version
:
"1.4.8"
,
...
@@ -156,6 +209,27 @@ export default defineComponent({
...
@@ -156,6 +209,27 @@ export default defineComponent({
mapContentRefs
.
value
.
initMap
(
"container"
);
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
)
=>
{
const
isUploaded
=
(
data
)
=>
{
mapIsUploaded
.
value
=
data
;
mapIsUploaded
.
value
=
data
;
};
};
...
@@ -327,6 +401,9 @@ export default defineComponent({
...
@@ -327,6 +401,9 @@ export default defineComponent({
carFenceBtn
&&
carFenceBtn
.
classList
.
add
(
"disabled"
);
carFenceBtn
&&
carFenceBtn
.
classList
.
add
(
"disabled"
);
}
}
if
(
isSharePage
)
{
shareBtn
&&
shareBtn
.
classList
.
add
(
"disabled"
);
}
// 点击GPS
// 点击GPS
GPSBtn
&&
GPSBtn
&&
(
GPSBtn
.
onclick
=
()
=>
{
(
GPSBtn
.
onclick
=
()
=>
{
...
@@ -444,7 +521,7 @@ export default defineComponent({
...
@@ -444,7 +521,7 @@ export default defineComponent({
// 电子围栏
// 电子围栏
(
carFenceBtn
&&
carFenceBtn
).
onclick
=
()
=>
{
(
carFenceBtn
&&
carFenceBtn
).
onclick
=
()
=>
{
if
(
loginUserId
.
value
||
item
.
source
==
0
)
{
if
(
item
.
source
==
0
)
{
return
;
return
;
}
else
{
}
else
{
wx
.
miniProgram
.
navigateTo
({
wx
.
miniProgram
.
navigateTo
({
...
@@ -454,9 +531,10 @@ export default defineComponent({
...
@@ -454,9 +531,10 @@ export default defineComponent({
};
};
// 分享找车
// 分享找车
shareBtn
.
onclick
=
()
=>
{
shareBtn
.
onclick
=
()
=>
{
wx
.
miniProgram
.
navigateTo
({
if
(
isSharePage
)
{
url
:
`../../mapPackage/pages/findCar?sn=
${
item
.
sn
}
&tabItem=share&source=
${
item
.
source
}
&locationType=
${
item
.
locationType
}
`
,
return
;
});
}
showOverlay
.
value
=
true
;
};
};
//点击车辆打开信息窗体
//点击车辆打开信息窗体
marker
.
on
(
"click"
,
()
=>
{
marker
.
on
(
"click"
,
()
=>
{
...
@@ -471,7 +549,7 @@ export default defineComponent({
...
@@ -471,7 +549,7 @@ export default defineComponent({
return
marker
;
return
marker
;
};
};
const
check
=
(
cb
)
=>
{
const
check
=
(
cb
)
=>
{
if
(
loginUserId
.
value
&&
isShareDead
.
value
)
{
if
(
isShareDead
.
value
)
{
Toast
(
"该分享已失效"
);
Toast
(
"该分享已失效"
);
return
;
return
;
}
}
...
@@ -514,7 +592,6 @@ export default defineComponent({
...
@@ -514,7 +592,6 @@ export default defineComponent({
list
,
list
,
getCarList
,
getCarList
,
getCarInfo
,
getCarInfo
,
loginUserId
,
check
,
check
,
carInfoList
,
carInfoList
,
carItem
,
carItem
,
...
@@ -524,12 +601,14 @@ export default defineComponent({
...
@@ -524,12 +601,14 @@ export default defineComponent({
mapIsUploaded
,
mapIsUploaded
,
routeQuery
,
routeQuery
,
ISLOADING
,
ISLOADING
,
showOverlay
,
};
};
},
},
});
});
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
@import
"@/assets/css/share.scss"
;
.index-map
{
.index-map
{
position
:
relative
;
position
:
relative
;
}
}
...
...
src/views/info.vue
View file @
92ed03b
...
@@ -112,34 +112,5 @@ export default defineComponent({
...
@@ -112,34 +112,5 @@ export default defineComponent({
});
});
</
script
>
</
script
>
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.icon-share
{
@import
"@/assets/css/share.scss"
;
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
;
}
}
</
style
>
</
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