Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fns_front_2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenqikuai
fns_front_2
Commits
3dddb664
Commit
3dddb664
authored
Oct 18, 2021
by
chenqikuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
7996255f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
92 additions
and
31 deletions
+92
-31
OutletDBService.ts
src/db/OutletDBService.ts
+32
-0
index.ts
src/db/index.ts
+9
-0
index.ts
src/service/AddressService/index.ts
+29
-28
displayName.ts
src/utils/displayName.ts
+22
-3
No files found.
src/db/OutletDBService.ts
0 → 100644
View file @
3dddb664
import
{
iOutLet
,
MyAppDatabase
}
from
'.'
export
default
class
OutletDBService
{
static
instance
:
OutletDBService
outlet
:
Dexie
.
Table
<
iOutLet
,
number
>
static
getInstance
()
{
if
(
!
OutletDBService
.
instance
)
OutletDBService
.
instance
=
new
OutletDBService
()
return
OutletDBService
.
instance
}
constructor
()
{
const
db
=
new
MyAppDatabase
()
this
.
outlet
=
db
.
outlet
}
add
(
outlet
:
iOutLet
)
{
return
this
.
outlet
.
add
(
outlet
)
}
update
(
outlet
:
iOutLet
)
{
return
this
.
outlet
.
update
(
outlet
.
id
,
outlet
)
}
delete
(
id
:
number
)
{
return
this
.
outlet
.
delete
(
id
)
}
get
(
id
:
number
)
{
return
this
.
outlet
.
get
(
id
)
}
}
src/db/index.ts
View file @
3dddb664
...
@@ -16,11 +16,18 @@ export interface iChatListCard {
...
@@ -16,11 +16,18 @@ export interface iChatListCard {
isRobootCard
?:
boolean
isRobootCard
?:
boolean
}
}
export
interface
iOutLet
{
id
:
number
name
:
string
}
export
class
MyAppDatabase
extends
Dexie
{
export
class
MyAppDatabase
extends
Dexie
{
chatMessage
:
Dexie
.
Table
<
iChatMessage
,
number
>
chatMessage
:
Dexie
.
Table
<
iChatMessage
,
number
>
chatListCard
:
Dexie
.
Table
<
iChatListCard
,
number
>
chatListCard
:
Dexie
.
Table
<
iChatListCard
,
number
>
contactPerson
:
Dexie
.
Table
<
iContact2
,
number
>
contactPerson
:
Dexie
.
Table
<
iContact2
,
number
>
userInfo
:
Dexie
.
Table
<
iUserinfo
,
number
>
userInfo
:
Dexie
.
Table
<
iUserinfo
,
number
>
outlet
:
Dexie
.
Table
<
iOutLet
,
number
>
constructor
()
{
constructor
()
{
super
(
'MyAppDatabase'
)
super
(
'MyAppDatabase'
)
...
@@ -31,11 +38,13 @@ export class MyAppDatabase extends Dexie {
...
@@ -31,11 +38,13 @@ export class MyAppDatabase extends Dexie {
chatListCard
:
'++id, masterId, targetId, unreadMsgCount, content, inChat, isRobootCard'
,
chatListCard
:
'++id, masterId, targetId, unreadMsgCount, content, inChat, isRobootCard'
,
contactPerson
:
'++id, addr, bank, phone, user_name, out_let_name'
,
contactPerson
:
'++id, addr, bank, phone, user_name, out_let_name'
,
userInfo
:
'++id, created_at, phone, remark, user_name, uuid, addr'
,
userInfo
:
'++id, created_at, phone, remark, user_name, uuid, addr'
,
outlet
:
'id, name'
,
})
})
this
.
chatMessage
=
this
.
table
(
'chatMessage'
)
this
.
chatMessage
=
this
.
table
(
'chatMessage'
)
this
.
chatListCard
=
this
.
table
(
'chatListCard'
)
this
.
chatListCard
=
this
.
table
(
'chatListCard'
)
this
.
contactPerson
=
this
.
table
(
'contactPerson'
)
this
.
contactPerson
=
this
.
table
(
'contactPerson'
)
this
.
userInfo
=
this
.
table
(
'userInfo'
)
this
.
userInfo
=
this
.
table
(
'userInfo'
)
this
.
outlet
=
this
.
table
(
'outlet'
)
}
}
}
}
src/service/AddressService/index.ts
View file @
3dddb664
...
@@ -41,35 +41,36 @@ class AddressService {
...
@@ -41,35 +41,36 @@ class AddressService {
)
)
})
})
}
}
getGps
();
if
(
'geolocation'
in
window
.
navigator
)
{
//
if ('geolocation' in window.navigator) {
console
.
log
(
'geolocation'
);
//
console.log('geolocation');
window
.
navigator
.
geolocation
.
getCurrentPosition
(
//
window.navigator.geolocation.getCurrentPosition(
(
position
)
=>
{
//
(position) => {
console
.
log
(
position
,
'position'
)
//
console.log(position, 'position')
const
la
=
position
.
coords
.
latitude
.
toString
()
//
const la = position.coords.latitude.toString()
const
lo
=
position
.
coords
.
longitude
.
toString
()
//
const lo = position.coords.longitude.toString()
resolve
(
//
resolve(
baseAxios
<
iNearbyOutLet
[]
>
({
//
baseAxios<iNearbyOutLet[]>({
method
:
'post'
,
//
method: 'post',
url
:
'/address/nearby'
,
//
url: '/address/nearby',
data
:
{
//
data: {
...
data
,
//
...data,
longitude
:
lo
,
//
longitude: lo,
latitude
:
la
,
//
latitude: la,
},
//
},
}),
//
}),
)
//
)
},
//
},
(
error
)
=>
{
//
(error) => {
console
.
log
(
error
)
//
console.log(error)
getGps
()
//
getGps()
},
//
},
)
//
)
}
else
{
//
} else {
console
.
log
(
'geolocation not in window'
);
//
console.log('geolocation not in window');
getGps
()
//
getGps()
}
//
}
})
})
}
}
...
...
src/utils/displayName.ts
View file @
3dddb664
import
{
iChatListCard
}
from
'@/db'
import
{
iChatListCard
}
from
'@/db'
import
ContactPersonService
from
'@/db/ContactPersonService'
import
ContactPersonService
from
'@/db/ContactPersonService'
import
OutletDBService
from
'@/db/OutletDBService'
import
UserInfoDBService
from
'@/db/UserInfoService'
import
UserInfoDBService
from
'@/db/UserInfoService'
import
AddressService
from
'@/service/AddressService'
import
AddressService
from
'@/service/AddressService'
import
UserService
from
'@/service/UserService'
import
UserService
from
'@/service/UserService'
...
@@ -63,16 +64,34 @@ export const getDisplayNamesFromAddress = async (
...
@@ -63,16 +64,34 @@ export const getDisplayNamesFromAddress = async (
/* 获取网点名称 */
/* 获取网点名称 */
export
const
getDisplayNamesFromOutletId
=
async
(
outletids
:
number
[])
=>
{
export
const
getDisplayNamesFromOutletId
=
async
(
outletids
:
number
[])
=>
{
const
promiseList
=
outletids
.
map
((
id
)
=>
{
const
promiseList
=
outletids
.
map
(
async
(
id
)
=>
{
return
AddressService
.
getInstance
()
const
outlet
=
await
OutletDBService
.
getInstance
().
get
(
id
)
if
(
!
outlet
)
{
const
ret
=
await
AddressService
.
getInstance
().
getOutlet
({
id
,
})
if
(
ret
.
code
===
200
)
{
await
OutletDBService
.
getInstance
().
add
({
name
:
ret
.
data
.
outlet_name
,
id
:
ret
.
data
.
id
,
})
return
ret
.
data
.
outlet_name
}
}
else
{
AddressService
.
getInstance
()
.
getOutlet
({
.
getOutlet
({
id
,
id
,
})
})
.
then
((
ret
)
=>
{
.
then
((
ret
)
=>
{
if
(
ret
.
code
===
200
)
{
if
(
ret
.
code
===
200
)
{
return
ret
.
data
.
outlet_name
OutletDBService
.
getInstance
().
update
({
name
:
ret
.
data
.
outlet_name
,
id
:
ret
.
data
.
id
,
})
}
}
})
})
return
outlet
.
name
}
})
})
const
list
=
await
Promise
.
all
(
promiseList
)
const
list
=
await
Promise
.
all
(
promiseList
)
return
list
return
list
...
...
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