Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mayi-mp-shop
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
程默
mayi-mp-shop
Commits
0fb9db35
Commit
0fb9db35
authored
Feb 14, 2023
by
李嘉林
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取地址数据优化
parent
3363fa67
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
30 deletions
+55
-30
src/pages/address/index.vue
+11
-5
src/utils/app.area.js
+0
-0
src/utils/tool.js
+44
-25
No files found.
src/pages/address/index.vue
View file @
0fb9db35
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
area
from
"@/utils/app.area.js"
;
import
tool
from
"@/utils/tool"
import
addres
from
"@/api/userAddress"
;
import
addres
from
"@/api/userAddress"
;
export
default
{
export
default
{
data
()
{
data
()
{
...
@@ -29,15 +29,21 @@ export default {
...
@@ -29,15 +29,21 @@ export default {
cityName
:
""
,
cityName
:
""
,
areaName
:
""
areaName
:
""
},
},
areaList
:
area
,
areaList
:
[]
,
province_list
:
area
.
province_list
,
province_list
:
[]
,
city_list
:
area
.
city_list
,
city_list
:
[]
,
county_list
:
area
.
county_list
,
county_list
:
[]
,
provinceTwoKey
:
0
,
provinceTwoKey
:
0
,
openSetting
:
false
openSetting
:
false
};
};
},
},
onLoad
(
options
)
{
onLoad
(
options
)
{
tool
.
appArea
().
then
(
res
=>
{
this
.
areaList
=
res
;
this
.
province_list
=
res
.
province_list
;
this
.
city_list
=
res
.
city_list
;
this
.
county_list
=
res
.
county_list
;
})
Object
.
assign
(
this
.
$data
,
this
.
$options
.
data
());
Object
.
assign
(
this
.
$data
,
this
.
$options
.
data
());
this
.
options
=
options
;
this
.
options
=
options
;
if
(
options
.
sessionid
){
if
(
options
.
sessionid
){
...
...
src/utils/app.area.js
deleted
100644 → 0
View file @
3363fa67
This source diff could not be displayed because it is too large. You can
view the blob
instead.
src/utils/tool.js
View file @
0fb9db35
// 地址JSON
const
appArea
=
()
=>
{
let
obj
=
""
;
console
.
log
(
"---appArea"
);
return
new
Promise
(
async
(
response
,
reject
)
=>
{
await
wx
.
request
({
url
:
`https://cdn.mayi888.com/static/js/app.area.json`
,
success
:
res
=>
{
obj
=
res
.
data
;
response
(
obj
);
console
.
log
(
obj
,
"--------appArea-success"
);
},
fail
:
err
=>
{
console
.
log
(
err
,
"-------err"
);
reject
(
err
);
}
});
});
};
/*函数节流*/
/*函数节流*/
function
throttle
(
fn
,
interval
)
{
function
throttle
(
fn
,
interval
)
{
var
enterTime
=
0
;
//触发的时间
var
enterTime
=
0
;
//触发的时间
var
gapTime
=
interval
||
300
;
//间隔时间,如果interval不传,则默认300ms
var
gapTime
=
interval
||
300
;
//间隔时间,如果interval不传,则默认300ms
return
function
()
{
return
function
()
{
var
context
=
this
;
var
context
=
this
;
var
backTime
=
new
Date
();
//第一次函数return即触发的时间
var
backTime
=
new
Date
();
//第一次函数return即触发的时间
if
(
backTime
-
enterTime
>
gapTime
)
{
if
(
backTime
-
enterTime
>
gapTime
)
{
fn
.
call
(
context
,
arguments
);
fn
.
call
(
context
,
arguments
);
enterTime
=
backTime
;
//赋值给第一次触发的时间,这样就保存了第二次触发的时间
enterTime
=
backTime
;
//赋值给第一次触发的时间,这样就保存了第二次触发的时间
}
}
};
};
}
}
/*函数防抖*/
/*函数防抖*/
function
debounce
(
fn
,
interval
)
{
function
debounce
(
fn
,
interval
)
{
console
.
log
(
'防抖抖~~~'
);
console
.
log
(
"防抖抖~~~"
);
var
timer
;
var
timer
;
var
gapTime
=
interval
||
1000
;
//间隔时间,如果interval不传,则默认1000ms
var
gapTime
=
interval
||
1000
;
//间隔时间,如果interval不传,则默认1000ms
return
function
()
{
return
function
()
{
clearTimeout
(
timer
);
clearTimeout
(
timer
);
var
context
=
this
;
var
context
=
this
;
var
args
=
arguments
;
//保存此处的arguments,因为setTimeout是全局的,arguments不是防抖函数需要的。
var
args
=
arguments
;
//保存此处的arguments,因为setTimeout是全局的,arguments不是防抖函数需要的。
timer
=
setTimeout
(
function
()
{
timer
=
setTimeout
(
function
()
{
fn
.
call
(
context
,
args
);
fn
.
call
(
context
,
args
);
},
gapTime
);
},
gapTime
);
};
};
}
}
export
default
{
export
default
{
throttle
,
throttle
,
debounce
debounce
,
};
appArea
\ No newline at end of file
};
李嘉林
@lijialin
mentioned in commit
e52e2dbe
Apr 16, 2023
mentioned in commit
e52e2dbe
mentioned in commit e52e2dbe5229a97ee8daa23cd5255aa3580bf69d
Toggle commit 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