Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
肖康
/
H5_2.0
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
7936e972
authored
May 22, 2023
by
LJM
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
地址管理
parent
19aefa65
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
120 additions
and
39 deletions
pages/mine/userAddressEdit.vue
pages/mine/userAddressEdit.vue
View file @
7936e972
...
...
@@ -2,7 +2,7 @@
<view
class=
"page-userAddress"
>
<navElement
title=
"编辑地址"
>
<template
slot=
"title-bar"
>
<view
class=
"delete"
style=
"font-size: 28rpx;color: #1969F9;text-align: right;"
>
删除
</view>
<view
class=
"delete"
@
click=
"deleteAdress(formParams.address_id)"
style=
"font-size: 28rpx;color: #1969F9;text-align: right;"
>
删除
</view>
</
template
>
</navElement>
<view
class=
"form-box"
>
...
...
@@ -30,10 +30,10 @@
</view>
<view
class=
"setting-default row verCenter bothSide"
>
<text
class=
"tt"
>
设为默认地址
</text>
<view><switch
@
change=
"onSwitchChange"
checked
style=
"transform:scale(0.7)"
/></view>
<view><switch
@
change=
"onSwitchChange"
:checked=
"is_default"
style=
"transform:scale(0.7)"
/></view>
</view>
<view
class=
"btn row verCenter"
>
<view
class=
"btn1 row rowCenter verCenter"
><text
class=
"text"
>
保存修改
</text></view>
<view
class=
"btn1 row rowCenter verCenter"
@
click=
"update()"
><text
class=
"text"
>
保存修改
</text></view>
</view>
</view>
</template>
...
...
@@ -52,9 +52,11 @@ export default {
multiIndex
:
[
0
,
0
,
0
],
index
:
0
,
array
:
[
'0086'
,
'00886'
,
'00853'
,
'00852'
],
arrayText
:
[
'中国'
,
'台湾省'
,
'澳门'
,
'香港'
],
selectText
:
'请选择省市区'
,
address_id
:
''
,
is_default
:
true
,
formParams
:
{
address_id
:
''
,
address_type
:
0
,
consignee
:
''
,
province
:
''
,
...
...
@@ -68,7 +70,7 @@ export default {
};
},
onLoad
(
options
)
{
this
.
address_id
=
options
.
address_id
||
''
;
this
.
formParams
.
address_id
=
options
.
address_id
||
''
;
},
onShow
()
{
this
.
getData
();
...
...
@@ -83,6 +85,32 @@ export default {
this
.
formParams
.
is_default
=
e
.
detail
.
value
?
1
:
0
;
},
/**
* @param {Object} arr
* @param {Object} target
*/
findIndex
(
arr
,
target
)
{
const
result
=
[];
arr
.
map
((
item
,
index
)
=>
{
if
(
item
.
value
==
target
)
{
result
.
push
(
index
);
}
});
return
result
;
},
/**
* @param {Object} arr
* @param {Object} target
*/
findIndexFilte
(
arr
,
target
)
{
const
result
=
[];
arr
.
map
((
item
,
index
)
=>
{
if
(
item
==
target
)
{
result
.
push
(
index
);
}
});
return
result
;
},
/**
* 地址监听
* @param {Object} e
*/
...
...
@@ -125,47 +153,119 @@ export default {
* 获取信息
*/
getData
()
{
this
.
request
(
Api_Url
+
'/address/info'
,
'POST'
,
{
address_id
:
this
.
address_id
},
true
,
true
).
then
(
res
=>
{
this
.
request
(
Api_Url
+
'/address/info'
,
'POST'
,
{
address_id
:
this
.
formParams
.
address_id
},
true
,
true
).
then
(
res
=>
{
if
(
res
.
err_code
===
0
)
{
this
.
formParams
.
consignee
=
res
.
data
.
consignee
;
this
.
formParams
.
mobile
=
res
.
data
.
mobile
;
this
.
selectText
=
`
${
res
.
data
.
province_val
+
','
+
res
.
data
.
city_val
+
','
+
res
.
data
.
district_val
}
`
;
this
.
formParams
.
province
=
res
.
data
.
province
;
this
.
formParams
.
city
=
res
.
data
.
city
;
this
.
formParams
.
district
=
res
.
data
.
district
;
this
.
formParams
.
detail_address
=
res
.
data
.
detail_address
;
this
.
is_default
=
res
.
data
.
is_default
==
1
?
true
:
false
;
//初始化省市区
this
.
getProvince
(
1
,
res
.
data
.
province
);
let
index
=
this
.
findIndexFilte
(
this
.
array
,
res
.
data
.
intl_code
);
this
.
index
=
index
;
}
});
},
/**
* 删除地址
* @param {Object} address_id
*/
deleteAdress
(
address_id
)
{
uni
.
showModal
({
title
:
''
,
content
:
'您确定删除该地址嘛'
,
success
:
res
=>
{
if
(
res
.
confirm
)
{
this
.
request
(
Api_Url
+
'/address/delete'
,
'POST'
,
{
address_id
:
address_id
},
true
,
true
).
then
(
res
=>
{
if
(
res
.
err_code
===
0
)
{
uni
.
showToast
({
title
:
'删除成功'
,
icon
:
'success'
});
setTimeout
(()
=>
{
uni
.
navigateBack
({
delta
:
1
});
},
2000
);
}
else
{
uni
.
showToast
({
title
:
res
.
err_msg
,
icon
:
'none'
});
}
});
}
else
if
(
res
.
cancel
)
{
console
.
log
(
'用户点击取消'
);
}
}
});
},
/**
* 更新
*/
update
()
{
this
.
request
(
Api_Url
+
'/address/update'
,
'POST'
,
this
.
formParams
,
true
,
true
).
then
(
res
=>
{
if
(
res
.
err_code
===
0
)
{
uni
.
showToast
({
title
:
'修改成功'
,
icon
:
'success'
});
setTimeout
(()
=>
{
uni
.
navigateBack
({
delta
:
1
});
},
2000
);
}
else
{
uni
.
showToast
({
title
:
res
.
err_msg
,
icon
:
'none'
});
}
});
},
/**
* 获取省数据
*/
getProvince
(
id
=
1
)
{
getProvince
(
id
=
1
,
defaultValue
)
{
console
.
log
(
'获取省数据id:'
+
id
);
this
.
request
(
Api_Url
+
'/address/pcd'
,
'POST'
,
{
id
:
id
},
tru
e
,
true
).
then
(
res
=>
{
this
.
request
(
Api_Url
+
'/address/pcd'
,
'POST'
,
{
id
:
id
},
fals
e
,
true
).
then
(
res
=>
{
if
(
res
.
err_code
===
0
)
{
var
arr
=
[];
for
(
var
key
in
res
.
data
)
{
arr
.
push
({
name
:
res
.
data
[
key
],
value
:
parseInt
(
key
)
});
}
this
.
multiArray
[
0
]
=
arr
;
this
.
getCity
(
2
,
true
);
if
(
defaultValue
)
{
let
index
=
this
.
findIndex
(
arr
,
defaultValue
);
this
.
multiIndex
.
splice
(
0
,
1
,
index
[
0
]);
}
this
.
getCity
(
this
.
formParams
.
province
,
this
.
formParams
.
city
);
this
.
$forceUpdate
();
}
});
},
/**
* @param {Object} id
* @param {Object} default
* @param {Object} default
Value
*/
getCity
(
id
,
default
Parms
)
{
getCity
(
id
,
default
Value
)
{
console
.
log
(
'获取市数据id:'
+
id
);
this
.
request
(
Api_Url
+
'/address/pcd'
,
'POST'
,
{
id
:
id
},
tru
e
,
true
).
then
(
res
=>
{
this
.
request
(
Api_Url
+
'/address/pcd'
,
'POST'
,
{
id
:
id
},
fals
e
,
true
).
then
(
res
=>
{
if
(
res
.
err_code
===
0
)
{
var
arr
=
[];
for
(
var
key
in
res
.
data
)
{
arr
.
push
({
name
:
res
.
data
[
key
],
value
:
parseInt
(
key
)
});
}
this
.
multiArray
[
1
]
=
arr
;
if
(
defaultParms
)
{
this
.
getDistrict
(
arr
[
0
].
value
);
if
(
defaultValue
)
{
let
index
=
this
.
findIndex
(
arr
,
defaultValue
);
this
.
multiIndex
.
splice
(
1
,
1
,
index
[
0
]);
this
.
getDistrict
(
this
.
formParams
.
city
,
this
.
formParams
.
district
);
}
this
.
$forceUpdate
();
}
...
...
@@ -175,41 +275,22 @@ export default {
* 获取区数据
* @param {Object} id
*/
getDistrict
(
id
)
{
getDistrict
(
id
,
defaultValue
)
{
console
.
log
(
'获取区数据id:'
+
id
);
this
.
request
(
Api_Url
+
'/address/pcd'
,
'POST'
,
{
id
:
id
},
tru
e
,
true
).
then
(
res
=>
{
this
.
request
(
Api_Url
+
'/address/pcd'
,
'POST'
,
{
id
:
id
},
fals
e
,
true
).
then
(
res
=>
{
if
(
res
.
err_code
===
0
)
{
var
arr
=
[];
for
(
var
key
in
res
.
data
)
{
arr
.
push
({
name
:
res
.
data
[
key
],
value
:
parseInt
(
key
)
});
}
this
.
multiArray
[
2
]
=
arr
;
if
(
defaultValue
)
{
let
index
=
this
.
findIndex
(
arr
,
defaultValue
);
this
.
multiIndex
.
splice
(
2
,
1
,
index
[
0
]);
}
this
.
$forceUpdate
();
}
});
},
/**
* 保存地址
*/
create
()
{
this
.
request
(
Api_Url
+
'/address/create'
,
'POST'
,
this
.
formParams
,
true
,
true
).
then
(
res
=>
{
if
(
res
.
err_code
===
0
)
{
uni
.
showToast
({
title
:
'保存成功'
,
icon
:
'success'
});
setTimeout
(()
=>
{
uni
.
navigateBack
({
delta
:
1
});
},
2000
);
}
else
{
uni
.
showToast
({
title
:
res
.
err_msg
,
icon
:
'none'
});
}
});
}
}
};
...
...
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