Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mallapp
Project
Project
Details
Activity
Releases
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
viitto
mallapp
Commits
31ca577d
Commit
31ca577d
authored
Jul 06, 2020
by
黄媛媛
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
地址自动获取功能
parent
79c331f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
285 additions
and
295 deletions
+285
-295
address.vue
pages/address/address.vue
+285
-295
No files found.
pages/address/address.vue
View file @
31ca577d
<
template
>
<
template
>
<view
class=
"addressStyle"
v-if=
"!isloading"
:style=
"
{'height':contentHeight}">
<view
class=
"addressStyle"
v-if=
"!isloading"
:style=
"
{ height: contentHeight }">
<scroll-view
<scroll-view
:scroll-y=
"true"
:enable-back-to-top=
"true"
:enable-flex=
"true"
:style=
"
{ height: '100%' }">
:scroll-y=
"true"
<view
v-for=
"(item, index) in list"
:key=
"index"
class=
"addresbox"
@
click=
"chosenHandler(item)"
>
:enable-back-to-top=
"true"
<view
class=
"addresclo"
>
:enable-flex=
"true"
<Text>
收件人:
{{
item
.
Name
}}
</Text>
:style=
"
{ height: '100%' }"
<Text>
{{
item
.
Mobile
}}
</Text>
>
</view>
<view
v-for=
"(item, index) in list"
:key=
"index"
class=
"addresbox"
@
click=
"chosenHandler(item)"
>
<Text
style=
"width: 100%;"
>
收货地址:
{{
item
.
DistrictAddress
}}{{
item
.
Address
}}
</Text>
<view
class=
"addresclo"
>
<view
style=
"width: 100%;height: 2rpx;background: #f5f5f5;margin-top: 15rpx;"
></view>
<Text>
收件人:
{{
item
.
Name
}}
</Text>
<view
class=
"addresclo"
>
<Text>
{{
item
.
Mobile
}}
</Text>
<u-checkbox-group
@
change=
"isdefault(item)"
>
</view>
<u-checkbox
v-model=
"item.IsDefault == 1 ? true : false"
shape=
"circle"
:active-color=
"mainColor"
>
<Text
style=
'width: 100%;'
>
收货地址:
{{
item
.
DistrictAddress
}}{{
item
.
Address
}}
</Text>
<Text
:style=
"
{ color: item.IsDefault == 1 ? mainColor : '#c8c9cc' }">
{{
item
.
IsDefault
==
1
?
'已设为默认'
:
'设为默认'
}}
</Text>
<view
style=
"width: 100%;height: 2rpx;background: #f5f5f5;margin-top: 15rpx;"
></view>
</u-checkbox>
<view
class=
"addresclo"
>
</u-checkbox-group>
<u-checkbox-group
@
change=
"isdefault(item)"
>
<view
style=
"display: flex;flex-direction: row;align-items: center;"
>
<u-checkbox
v-model=
"item.IsDefault==1?true:false"
shape=
"circle"
:active-color=
"mainColor"
>
<view
style=
"display: flex;flex-direction: row;align-items: center;"
@
click
.
stop=
"btn_edit(item)"
>
<Text
<u-icon
name=
"edit"
color=
"#c8c9cc"
size=
"40"
></u-icon>
:style=
"
{'color':item.IsDefault==1?mainColor:'#c8c9cc' }"
<Text
style=
"color:#c8c9cc;"
>
编辑
</Text>
>
{{
item
.
IsDefault
==
1
?
'已设为默认'
:
'设为默认'
}}
</Text>
</view>
</u-checkbox>
<view
style=
"display: flex;flex-direction: row;align-items: center;margin: 0 30rpx"
@
click
.
stop=
"btn_delete(item)"
>
</u-checkbox-group>
<u-icon
name=
"delete"
color=
"#c8c9cc"
size=
"40"
></u-icon>
<view
style=
"display: flex;flex-direction: row;align-items: center;"
>
<Text
style=
"color:#c8c9cc;"
>
删除
</Text>
<view
</view>
style=
"display: flex;flex-direction: row;align-items: center;"
</view>
@
click
.
stop=
"btn_edit(item)"
</view>
>
</view>
<u-icon
name=
"edit"
color=
"#c8c9cc"
size=
"40"
></u-icon>
<view
class=
"bottom_btn"
>
<Text
style=
"color:#c8c9cc;"
>
编辑
</Text>
<view
class=
"bottom_btn_item"
:style=
"
{ background: mainColor }" @click="ManualAdd">
</view>
<u-icon
name=
"add-o"
color=
"#fff"
size=
"30"
></u-icon>
<view
<Text
style=
"color:#fff;margin-left: 10rpx;"
>
手动添加
</Text>
style=
"display: flex;flex-direction: row;align-items: center;margin: 0 30rpx"
</view>
@
click
.
stop=
"btn_delete(item)"
<!-- TODO 自动获取 -->
>
<view
class=
"bottom_btn_item"
style=
"background: #5CBF39;"
@
click=
"automatic"
>
<u-icon
name=
"delete"
color=
"#c8c9cc"
size=
"40"
></u-icon>
<u-icon
name=
"location"
color=
"#fff"
size=
"30"
></u-icon>
<Text
style=
"color:#c8c9cc;"
>
删除
</Text>
<Text
style=
"color:#fff;margin-left: 10rpx"
>
自动获取
</Text>
</view>
</view>
</view>
</view>
</view>
</scroll-view>
</view>
<!-- 删除的弹框 -->
<view
class=
"bottom_btn"
>
<u-modal
v-model=
"showModal"
content=
"确实删除收货地址"
:show-cancel-button=
"true"
:show-title=
"false"
@
confirm=
"confirm"
></u-modal>
<view
class=
"bottom_btn_item"
:style=
"
{'background':mainColor}" @click="ManualAdd">
<u-toast
ref=
"uToast"
/>
<u-icon
name=
"add-o"
color=
"#fff"
size=
"30"
></u-icon>
<auth
v-if=
"showAuth"
@
changeuserinfo=
"reloadUserinfo"
@
gbAuth=
"gbAuth"
></auth>
<Text
style=
"color:#fff;margin-left: 10rpx;"
>
手动添加
</Text>
</view>
</view>
<!-- TODO 自动获取 -->
<view
class=
"bottom_btn_item"
style=
"background: #5CBF39;"
@
click=
"automatic"
>
<u-icon
name=
"location"
color=
"#fff"
size=
"30"
></u-icon>
<Text
style=
"color:#fff;margin-left: 10rpx"
>
自动获取
</Text>
</view>
</view>
</scroll-view>
<!-- 删除的弹框 -->
<u-modal
v-model=
"showModal"
content=
"确实删除收货地址"
:show-cancel-button=
"true"
:show-title=
"false"
@
confirm=
"confirm"
></u-modal>
<u-toast
ref=
"uToast"
/>
<auth
v-if=
"showAuth"
@
changeuserinfo=
"reloadUserinfo"
@
gbAuth=
'gbAuth'
></auth>
</view>
</
template
>
</
template
>
<
script
>
<
script
>
import
auth
from
"../../components/auth/index.vue"
;
import
auth
from
'../../components/auth/index.vue'
;
export
default
{
export
default
{
data
()
{
data
()
{
return
{
return
{
pageTitle
:
'收货地址'
,
pageTitle
:
'收货地址'
,
loading
:
true
,
loading
:
true
,
list
:
[],
list
:
[],
showAuth
:
false
,
showAuth
:
false
,
mainColor
:
""
,
mainColor
:
''
,
u
:
{},
u
:
{},
contentHeight
:
0
,
contentHeight
:
0
,
showModal
:
false
,
showModal
:
false
,
deleteID
:
0
,
deleteID
:
0
,
msg
:{
msg
:
{
Name
:
''
,
Name
:
''
,
IsDefault
:
0
,
IsDefault
:
0
,
Mobile
:
''
,
Mobile
:
''
},
},
source
:
""
,
source
:
''
,
defaultId
:
0
,
defaultId
:
0
,
currentAddress
:
{},
currentAddress
:
{},
list
:
[],
list
:
[],
mc
:
""
,
mc
:
''
,
addressmsg
:
{
};
Id
:
0
,
},
Name
:
''
,
components
:
{
Mobile
:
''
,
auth
Province
:
''
,
},
City
:
''
,
created
()
{
District
:
''
,
this
.
contentHeight
=
this
.
$utils
.
calcContentHeight
(
-
40
)
+
"px"
;
Address
:
''
this
.
mainColor
=
this
.
$uiConfig
.
mainColor
;
}
};
},
},
mounted
()
{
components
:
{
let
currentPages
=
getCurrentPages
();
auth
let
u
=
"/"
+
currentPages
[
currentPages
.
length
-
1
].
route
;
let
pages
=
wx
.
getStorageSync
(
"basedata"
)
?
wx
.
getStorageSync
(
"basedata"
).
bar_title
:
[];
pages
.
forEach
((
x
)
=>
{
if
(
x
.
value
==
u
)
{
this
.
pageTitle
=
x
.
new_name
?
x
.
new_name
:
x
.
name
;
}
});
uni
.
setNavigationBarTitle
({
title
:
this
.
pageTitle
,
});
},
onLoad
(
option
)
{
this
.
u
=
uni
.
getStorageSync
(
"mall_UserInfo"
);
if
(
!
this
.
u
)
{
this
.
u
=
{
nickName
:
"未登录"
,
avatarUrl
:
""
};
this
.
showAuth
=
true
;
}
else
{
this
.
init
();
}
if
(
option
&&
option
.
form
)
{
(
this
.
source
=
option
.
form
),
(
this
.
defaultId
=
option
.
id
);
}
},
methods
:
{
chosenHandler
(
item
){
console
.
log
(
"chosenHandler"
,
item
)
let
pages
=
getCurrentPages
()
let
prevPage
=
pages
[
pages
.
length
-
2
]
prevPage
.
$vm
.
formData
.
address_id
=
item
.
Id
;
prevPage
.
$vm
.
formdata
.
AddressId
=
item
.
Id
;
prevPage
.
$vm
.
adressInfo
=
item
;
uni
.
navigateBack
({
delta
:
1
})
},
init
()
{
this
.
loading
=
false
;
uni
.
showNavigationBarLoading
();
this
.
request2
(
{
url
:
'/api/AppletUser/GetUserShippingAddressList'
,
data
:
this
.
msg
},
res
=>
{
uni
.
hideNavigationBarLoading
();
if
(
res
.
resultCode
==
1
){
this
.
isloading
=
false
;
this
.
list
=
res
.
data
;
}
}
);
},
reloadUserinfo
()
{
this
.
u
=
uni
.
getStorageSync
(
"mall_UserInfo"
);
this
.
showAuth
=
false
;
this
.
init
();
},
//关闭登录窗口
gbAuth
(){
uni
.
navigateBack
()
},
},
isdefault
(
item
)
{
created
()
{
//设置默认地址
this
.
contentHeight
=
this
.
$utils
.
calcContentHeight
(
-
40
)
+
'px'
;
uni
.
showNavigationBarLoading
();
this
.
mainColor
=
this
.
$uiConfig
.
mainColor
;
this
.
request2
(
},
{
mounted
()
{
url
:
'/api/AppletUser/SetUserShippingAddressDefault'
,
let
currentPages
=
getCurrentPages
();
data
:
{
let
u
=
'/'
+
currentPages
[
currentPages
.
length
-
1
].
route
;
AddressId
:
item
.
Id
let
pages
=
wx
.
getStorageSync
(
'basedata'
)
?
wx
.
getStorageSync
(
'basedata'
).
bar_title
:
[];
pages
.
forEach
(
x
=>
{
if
(
x
.
value
==
u
)
{
this
.
pageTitle
=
x
.
new_name
?
x
.
new_name
:
x
.
name
;
}
}
},
});
uni
.
setNavigationBarTitle
({
res
=>
{
title
:
this
.
pageTitle
this
.
init
();
uni
.
hideNavigationBarLoading
();
}
);
},
btn_edit
(
item
)
{
uni
.
navigateTo
({
url
:
"/pages/address/AddAddress?AddressId="
+
item
.
Id
});
});
},
},
btn_delete
(
item
)
{
onLoad
(
option
)
{
this
.
deleteID
=
item
.
Id
;
this
.
u
=
uni
.
getStorageSync
(
'mall_UserInfo'
);
this
.
showModal
=
true
;
if
(
!
this
.
u
)
{
},
this
.
u
=
{
confirm
()
{
nickName
:
'未登录'
,
uni
.
showNavigationBarLoading
();
avatarUrl
:
''
this
.
request2
(
};
{
this
.
showAuth
=
true
;
url
:
"/api/AppletUser/DelUserShippingAddress"
,
}
else
{
data
:
{
this
.
init
();
AddressId
:
this
.
deleteID
}
if
(
option
&&
option
.
form
)
{
}
(
this
.
source
=
option
.
form
),
(
this
.
defaultId
=
option
.
id
);
},
}
},
methods
:
{
chosenHandler
(
item
)
{
console
.
log
(
'chosenHandler'
,
item
);
let
pages
=
getCurrentPages
();
let
prevPage
=
pages
[
pages
.
length
-
2
];
prevPage
.
$vm
.
formData
.
address_id
=
item
.
Id
;
prevPage
.
$vm
.
formdata
.
AddressId
=
item
.
Id
;
prevPage
.
$vm
.
adressInfo
=
item
;
uni
.
navigateBack
({
delta
:
1
});
},
init
()
{
this
.
loading
=
false
;
uni
.
showNavigationBarLoading
();
this
.
request2
(
{
url
:
'/api/AppletUser/GetUserShippingAddressList'
,
data
:
this
.
msg
},
res
=>
{
uni
.
hideNavigationBarLoading
();
if
(
res
.
resultCode
==
1
)
{
this
.
isloading
=
false
;
this
.
list
=
res
.
data
;
}
}
);
},
reloadUserinfo
()
{
this
.
u
=
uni
.
getStorageSync
(
'mall_UserInfo'
);
this
.
showAuth
=
false
;
this
.
init
();
},
//关闭登录窗口
gbAuth
()
{
uni
.
navigateBack
();
},
isdefault
(
item
)
{
//设置默认地址
uni
.
showNavigationBarLoading
();
this
.
request2
(
{
url
:
'/api/AppletUser/SetUserShippingAddressDefault'
,
data
:
{
AddressId
:
item
.
Id
}
},
res
=>
{
this
.
init
();
uni
.
hideNavigationBarLoading
();
}
);
},
btn_edit
(
item
)
{
uni
.
navigateTo
({
url
:
'/pages/address/AddAddress?AddressId='
+
item
.
Id
});
},
btn_delete
(
item
)
{
this
.
deleteID
=
item
.
Id
;
this
.
showModal
=
true
;
},
confirm
()
{
uni
.
showNavigationBarLoading
();
this
.
request2
(
{
url
:
'/api/AppletUser/DelUserShippingAddress'
,
data
:
{
AddressId
:
this
.
deleteID
}
},
res
=>
{
res
=>
{
this
.
init
();
this
.
init
();
uni
.
hideNavigationBarLoading
();
uni
.
hideNavigationBarLoading
();
}
}
);
);
},
},
automatic
()
{
automatic
()
{
this
.
$refs
.
uToast
.
show
({
// this.$refs.uToast.show({
title
:
"正在开发,敬请期待!"
// title: "正在开发,敬请期待!"
});
// });
// wx.getSetting({
// success(res) {
// console.log("vres.authSetting['scope.address']:",res.authSetting['scope.address'])
// if (res.authSetting['scope.address']) {
// console.log("111")
// wx.chooseAddress({
// success(res) {
// console.log(res.userName)
// console.log(res.postalCode)
// console.log(res.provinceName)
// console.log(res.cityName)
// console.log(res.countyName)
// console.log(res.detailInfo)
// console.log(res.nationalCode)
// console.log(res.telNumber)
// }
// })
// // 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问
// } else {
// if (res.authSetting['scope.address'] == false) {
// console.log("222")
// wx.openSetting({
// success(res) {
// console.log(res.authSetting)
// }
// })
// } else {
// console.log("eee")
// wx.chooseAddress({
// success(res) {
// console.log(res.userName)
// console.log(res.postalCode)
// console.log(res.provinceName)
// console.log(res.cityName)
// console.log(res.countyName)
// console.log(res.detailInfo)
// console.log(res.nationalCode)
// console.log(res.telNumber)
// }
// })
// }
// }
// }
// })
},
ManualAdd
()
{
//手动添加
uni
.
navigateTo
({
url
:
"/pages/address/AddAddress"
});
}
},
let
that
=
this
;
if
(
wx
.
chooseAddress
)
{
wx
.
chooseAddress
({
success
:
function
(
res
)
{
console
.
log
(
res
);
let
nameList
=
[
res
.
provinceName
,
res
.
cityName
,
res
.
countyName
];
that
.
addressmsg
.
Name
=
res
.
userName
;
that
.
addressmsg
.
Mobile
=
res
.
telNumber
;
that
.
addressmsg
.
Address
=
res
.
detailInfo
;
that
.
getDestination
(
nameList
);
},
fail
:
function
(
err
)
{
that
.
$refs
.
uToast
.
show
({
title
:
'授权失败,请重新点击自动获取'
,
type
:
'error'
});
}
});
}
else
{
that
.
$refs
.
uToast
.
show
({
title
:
'当前微信版本不支持自动获取收货地址'
,
type
:
'error'
});
}
},
getDestination
(
nameList
)
{
this
.
request2
(
{
url
:
'/api/AppletUser/GetDestinationListByNames'
,
data
:
{
area
:
nameList
}
},
res
=>
{
console
.
log
(
'res'
,
res
);
this
.
addressmsg
.
Province
=
res
.
data
[
0
].
ID
;
this
.
addressmsg
.
City
=
res
.
data
[
1
].
ID
;
this
.
addressmsg
.
District
=
res
.
data
[
2
].
ID
;
if
(
res
.
data
.
length
>
0
)
{
this
.
request2
(
{
url
:
'/api/AppletUser/SetUserShippingAddress'
,
data
:
this
.
addressmsg
},
res
=>
{
uni
.
showToast
({
title
:
'保存成功'
,
icon
:
'none'
});
this
.
init
();
}
);
}
}
);
},
ManualAdd
()
{
//手动添加
uni
.
navigateTo
({
url
:
'/pages/address/AddAddress'
});
}
}
};
};
</
script
>
</
script
>
<
style
>
<
style
>
.addressStyle
{
.addressStyle
{
background
:
#f3f4f6
;
background
:
#f3f4f6
;
}
}
.addressStyle
.addresbox
{
.addressStyle
.addresbox
{
width
:
94%
;
width
:
94%
;
margin-left
:
3%
;
margin-left
:
3%
;
border-radius
:
10
rpx
;
border-radius
:
10
rpx
;
background
:
#fff
;
background
:
#fff
;
display
:
flex
;
display
:
flex
;
flex-direction
:
column
;
flex-direction
:
column
;
align-items
:
center
;
align-items
:
center
;
justify-content
:
space-around
;
justify-content
:
space-around
;
padding
:
0
20
rpx
;
padding
:
0
20
rpx
;
margin-top
:
30
rpx
;
margin-top
:
30
rpx
;
}
}
.addressStyle
.addresclo
{
.addressStyle
.addresclo
{
display
:
flex
;
display
:
flex
;
flex-direction
:
row
;
flex-direction
:
row
;
width
:
100%
;
width
:
100%
;
padding
:
20
rpx
0
;
padding
:
20
rpx
0
;
align-items
:
center
;
align-items
:
center
;
justify-content
:
space-between
;
justify-content
:
space-between
;
}
}
.addressStyle
.bottom_btn
{
.addressStyle
.bottom_btn
{
width
:
94%
;
width
:
94%
;
height
:
90
rpx
;
height
:
90
rpx
;
display
:
flex
;
display
:
flex
;
flex-direction
:
row
;
flex-direction
:
row
;
align-items
:
center
;
align-items
:
center
;
justify-content
:
space-between
;
justify-content
:
space-between
;
margin-left
:
3%
;
margin-left
:
3%
;
margin-top
:
30
rpx
;
margin-top
:
30
rpx
;
}
}
.addressStyle
.bottom_btn
.bottom_btn_item
{
.addressStyle
.bottom_btn
.bottom_btn_item
{
width
:
48%
;
width
:
48%
;
height
:
80
rpx
;
height
:
80
rpx
;
border-radius
:
40
rpx
;
border-radius
:
40
rpx
;
display
:
flex
;
display
:
flex
;
flex-direction
:
row
;
flex-direction
:
row
;
align-items
:
center
;
align-items
:
center
;
justify-content
:
center
;
justify-content
:
center
;
}
}
</
style
>
</
style
>
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