Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
self-support
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
李俊赕
self-support
Commits
7c9f25e9
Commit
7c9f25e9
authored
Aug 30, 2021
by
Damon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: 区分物料收货地址和我的收货地址
parent
48ffc955
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
263 additions
and
149 deletions
+263
-149
w-address.vue
src/components/w-address/w-address.vue
+5
-1
pages.json
src/pages.json
+9
-0
addSite.vue
src/pages/mine/address/addSite.vue
+28
-16
index.vue
src/pages/mine/address/index.vue
+33
-127
address.vue
src/pages/parts/address.vue
+184
-0
application.vue
src/pages/parts/application.vue
+4
-5
No files found.
src/components/w-address/w-address.vue
View file @
7c9f25e9
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
<u-icon
name=
"checkmark-circle"
:color=
"isDefault ? '#2272FF' : '#999'"
size=
"32"
></u-icon>
<u-icon
name=
"checkmark-circle"
:color=
"isDefault ? '#2272FF' : '#999'"
size=
"32"
></u-icon>
<text
class=
"txt"
>
默认地址
</text>
<text
class=
"txt"
>
默认地址
</text>
</view>
</view>
<view
@
click=
"$u.throttle(remove, 500)"
>
<view
@
click=
"$u.throttle(remove, 500)"
v-if=
"showRemove"
>
<text
class=
"txt"
>
删除
</text>
<text
class=
"txt"
>
删除
</text>
</view>
</view>
</view>
</view>
...
@@ -45,6 +45,10 @@ export default {
...
@@ -45,6 +45,10 @@ export default {
siteType
:
{
siteType
:
{
type
:
String
,
type
:
String
,
default
:
'edit'
default
:
'edit'
},
showRemove
:
{
type
:
Boolean
,
default
:
false
}
}
},
},
data
()
{
data
()
{
...
...
src/pages.json
View file @
7c9f25e9
...
@@ -563,6 +563,15 @@
...
@@ -563,6 +563,15 @@
"disableScroll"
:
true
"disableScroll"
:
true
}
}
},
},
{
"path"
:
"address"
,
"style"
:
{
"navigationBarTitleText"
:
"收货地址"
,
"enablePullDownRefresh"
:
false
,
"navigationStyle"
:
"custom"
,
"disableScroll"
:
true
}
},
{
{
"path"
:
"addParts"
,
"path"
:
"addParts"
,
"style"
:
{
"style"
:
{
...
...
src/pages/mine/address/addSite.vue
View file @
7c9f25e9
...
@@ -274,15 +274,13 @@ export default {
...
@@ -274,15 +274,13 @@ export default {
}
else
{
}
else
{
if
(
this
.
$u
.
test
.
isEmpty
(
this
.
siteInfo
))
{
if
(
this
.
$u
.
test
.
isEmpty
(
this
.
siteInfo
))
{
let
params
=
{
let
params
=
{
mobile
:
this
.
mobile
,
updateFlag
:
true
,
name
:
this
.
name
,
provinceName
:
this
.
region
[
0
],
provinceName
:
this
.
region
[
0
],
cityName
:
this
.
region
[
1
],
cityName
:
this
.
region
[
1
],
districtName
:
this
.
region
[
2
],
districtName
:
this
.
region
[
2
],
address
:
this
.
region
.
join
(
""
)
+
this
.
address
address
:
this
.
region
.
join
(
""
)
+
this
.
address
};
};
if
(
this
.
id
)
params
.
id
=
this
.
id
let
res
=
await
this
.
$u
.
api
.
updateAddress
(
params
);
let
res
=
await
this
.
$u
.
api
.
saveMyAddress
(
params
);
if
(
res
&&
res
.
code
==
200
)
{
if
(
res
&&
res
.
code
==
200
)
{
this
.
$u
.
route
({
type
:
'back'
});
this
.
$u
.
route
({
type
:
'back'
});
this
.
show
=
false
this
.
show
=
false
...
@@ -292,25 +290,39 @@ export default {
...
@@ -292,25 +290,39 @@ export default {
}
}
}
}
},
},
commitSite
()
{
async
commitSite
()
{
if
(
!
this
.
validateForm
())
{
if
(
!
this
.
validateForm
())
{
return
false
return
false
}
}
// 获取当前页面栈的实例,以数组形式按栈的顺序给出,第一个元素为首页,最后一个元素为当前页面。
let
params
=
{
var
pages
=
getCurrentPages
();
mobile
:
this
.
mobile
,
var
prevPage
=
pages
[
pages
.
length
-
2
];
//上一个页面
name
:
this
.
name
,
//prevPage.route获取上一页面的页面路径
provinceName
:
this
.
region
[
0
],
cityName
:
this
.
region
[
1
],
districtName
:
this
.
region
[
2
],
address
:
this
.
region
.
join
(
""
)
+
this
.
address
};
if
(
this
.
id
)
params
.
id
=
this
.
id
let
res
=
await
this
.
$u
.
api
.
saveMyAddress
(
params
);
if
(
res
&&
res
.
code
==
200
)
{
let
pages
=
getCurrentPages
()
let
prevPage
=
pages
[
pages
.
length
-
2
]
if
(
prevPage
.
route
===
'pages/parts/application'
)
{
let
address
=
this
.
region
.
join
(
""
)
+
this
.
address
let
address
=
this
.
region
.
join
(
""
)
+
this
.
address
let
site
=
{
let
site
=
{
name
:
this
.
name
,
name
:
this
.
name
,
mobile
:
this
.
mobile
,
mobile
:
this
.
mobile
,
address
:
address
,
address
:
address
,
region
:
this
.
region
region
:
this
.
region
,
id
:
this
.
id
}
}
prevPage
.
$vm
.
updateSite
(
site
)
prevPage
.
$vm
.
updateSite
(
site
)
}
this
.
show
=
false
this
.
$u
.
route
({
type
:
'back'
});
this
.
$u
.
route
({
type
:
'back'
});
}
}
}
}
}
};
};
</
script
>
</
script
>
...
...
src/pages/mine/address/index.vue
View file @
7c9f25e9
<
template
>
<
template
>
<view
class=
"
u-flex
address-wrap"
>
<view
class=
"address-wrap"
>
<w-navbar
title=
"收货地址"
></w-navbar>
<w-navbar
title=
"收货地址"
></w-navbar>
<view
class=
"lists"
>
<view
class=
"body"
v-if=
"hasAdderss"
>
<view
class=
"body"
v-for=
"(item, index) in lists"
:key=
"item.id"
>
<w-address
@
editSite=
"toAddSite"
:info=
"info"
:is-default=
"true"
/>
<w-address
@
editSite=
"toEditSite(item)"
@
selectSite=
"selectSite(item)"
@
setDefault=
"setDefault(item, index)"
@
remove=
"remove(item)"
:info=
"item"
:is-default=
"item.enable === 1"
/>
</view>
</view>
<view
class=
"addSite"
@
tap=
"toAddSite"
>
<view
class=
"add"
>
新建收货地址
</view>
</view>
</view>
</view>
</view>
</
template
>
</
template
>
...
@@ -23,24 +15,31 @@ export default {
...
@@ -23,24 +15,31 @@ export default {
background
:
{
background
:
{
backgroundColor
:
'none'
backgroundColor
:
'none'
},
},
lists
:
[],
info
:
{
type
:
''
name
:
''
,
mobile
:
''
,
address
:
''
,
region
:
[],
},
};
};
},
},
computed
:
{
computed
:
{
editPen
()
{
editPen
()
{
return
process
.
uniEnv
.
qn_base_url
+
'icon/edit-pen.png'
return
process
.
uniEnv
.
qn_base_url
+
'icon/edit-pen.png'
},
},
submitBtn
()
{
hasAdderss
()
{
return
this
.
info
.
address
},
addressInfo
()
{
return
{
return
{
color
:
'#FFFFFF'
,
name
:
this
.
name
,
backgroundColor
:
'#2272FF'
mobile
:
this
.
mobile
,
address
:
this
.
address
,
region
:
this
.
region
||
[],
}
}
}
}
},
},
onLoad
(
options
)
{
onLoad
()
{
if
(
options
)
this
.
type
=
options
.
type
getApp
().
trackPage
(
'我的收获地址页'
)
getApp
().
trackPage
(
'我的收获地址页'
)
},
},
onShow
()
{
onShow
()
{
...
@@ -54,98 +53,32 @@ export default {
...
@@ -54,98 +53,32 @@ export default {
this
.
getMineSite
()
this
.
getMineSite
()
},
},
getMineSite
()
{
getMineSite
()
{
this
.
$u
.
api
.
get
My
Address
().
then
((
res
)
=>
{
this
.
$u
.
api
.
get
Site
Address
().
then
((
res
)
=>
{
const
data
=
res
.
data
const
data
=
res
.
data
if
(
data
.
length
>
0
)
{
if
(
res
.
code
==
200
&&
!
this
.
$u
.
test
.
isEmpty
(
data
))
{
this
.
lists
=
data
.
map
(
v
=>
{
let
region
=
[]
let
region
=
[]
if
(
v
.
provinceName
&&
v
.
cityName
&&
v
.
districtName
)
{
if
(
data
.
provinceName
&&
data
.
cityName
&&
data
.
districtName
)
{
region
=
[
v
.
provinceName
,
v
.
cityName
,
v
.
districtName
]
region
=
[
data
.
provinceName
,
data
.
cityName
,
data
.
districtName
]
}
v
.
region
=
region
return
v
})
}
})
},
toAddSite
()
{
this
.
$u
.
route
({
url
:
'pages/mine/address/addSite'
,
params
:
{
type
:
'add'
}
})
},
setDefault
(
val
)
{
this
.
$u
.
api
.
setDefaultAddress
({
id
:
val
.
id
}).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
this
.
lists
.
forEach
(
v
=>
{
this
.
$set
(
v
,
'enable'
,
v
.
id
===
val
.
id
?
1
:
0
)
})
this
.
getMineSite
()
if
(
this
.
type
===
'parts'
)
{
let
pages
=
getCurrentPages
()
let
prevPage
=
pages
[
pages
.
length
-
2
]
prevPage
.
$vm
.
loadAddress
()
}
}
}
this
.
info
=
{
})
name
:
data
.
name
,
},
mobile
:
data
.
mobile
,
remove
(
val
)
{
address
:
data
.
address
,
uni
.
showModal
({
region
:
region
,
title
:
'温馨提示'
,
content
:
'确定要删除该收货地址?'
,
success
:
(
res
)
=>
{
if
(
res
.
confirm
)
{
uni
.
showLoading
({
title
:
'加载中'
,
})
this
.
$u
.
api
.
deleteMyAddress
({
id
:
val
.
id
}).
then
((
res
)
=>
{
uni
.
hideLoading
()
if
(
res
.
code
===
200
)
{
this
.
getMineSite
()
}
else
{
uni
.
showToast
({
icon
:
"none"
,
title
:
res
.
message
,
})
}
})
}
}
}
}
})
})
},
},
selectSite
(
val
)
{
toAddSite
(
title
){
if
(
this
.
type
===
'parts'
)
{
const
region
=
this
.
info
.
region
.
join
(
'-'
)
let
pages
=
getCurrentPages
();
let
prevPage
=
pages
[
pages
.
length
-
2
];
//上一个页面
let
address
=
val
.
region
.
join
(
""
)
+
val
.
address
let
site
=
{
name
:
val
.
name
,
mobile
:
val
.
mobile
,
address
:
address
,
region
:
val
.
region
,
id
:
val
.
id
}
prevPage
.
$vm
.
updateSite
(
site
)
this
.
$u
.
route
({
type
:
'back'
})
}
else
{
this
.
toEditSite
(
val
)
}
},
toEditSite
(
val
){
const
region
=
val
.
region
.
join
(
'-'
)
this
.
$u
.
route
({
this
.
$u
.
route
({
url
:
'pages/mine/address/addSite'
,
url
:
'pages/mine/address/addSite'
,
params
:
{
params
:
{
type
:
'edit'
,
type
:
'edit'
,
region
:
region
,
region
:
region
,
name
:
val
.
name
,
name
:
this
.
info
.
name
,
mobile
:
val
.
mobile
,
mobile
:
this
.
info
.
mobile
,
address
:
val
.
address
,
address
:
this
.
info
.
address
,
id
:
val
.
id
}
}
})
})
}
}
...
@@ -156,13 +89,6 @@ export default {
...
@@ -156,13 +89,6 @@ export default {
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.address-wrap
{
.address-wrap
{
background-color
:
#F4F5F7
;
background-color
:
#F4F5F7
;
flex-direction
:column
;
height
:
100vh
;
.lists
{
width
:
100%
;
flex
:
1
;
overflow-y
:auto
;
}
}
}
.body
{
.body
{
padding
:
30rpx
;
padding
:
30rpx
;
...
@@ -170,24 +96,4 @@ export default {
...
@@ -170,24 +96,4 @@ export default {
border-radius
:
12rpx
;
border-radius
:
12rpx
;
background-color
:
#FFFFFF
;
background-color
:
#FFFFFF
;
}
}
.addSite
{
display
:
flex
;
justify-content
:
space-around
;
width
:
600rpx
;
height
:
100rpx
;
line-height
:
100rpx
;
margin
:
50rpx
0
;
background-color
:
#2272FF
;
border-radius
:
60rpx
;
font-size
:
30rpx
;
.add
{
display
:
flex
;
align-items
:
center
;
color
:
#ffffff
;
.icon
{
margin-right
:
10rpx
;
}
}
}
</
style
>
</
style
>
src/pages/parts/address.vue
0 → 100644
View file @
7c9f25e9
<
template
>
<view
class=
"u-flex address-wrap"
>
<w-navbar
title=
"收货地址"
></w-navbar>
<view
class=
"lists"
>
<view
class=
"body"
v-for=
"(item, index) in lists"
:key=
"item.id"
>
<w-address
@
editSite=
"toEditSite(item)"
@
selectSite=
"selectSite(item)"
@
setDefault=
"setDefault(item, index)"
@
remove=
"remove(item)"
:info=
"item"
:is-default=
"item.enable === 1"
:showRemove=
"true"
/>
</view>
</view>
<view
class=
"addSite"
@
tap=
"toAddSite"
>
<view
class=
"add"
>
新建收货地址
</view>
</view>
</view>
</
template
>
<
script
>
const
app
=
getApp
();
export
default
{
data
()
{
return
{
background
:
{
backgroundColor
:
'none'
},
lists
:
[]
};
},
computed
:
{
editPen
()
{
return
process
.
uniEnv
.
qn_base_url
+
'icon/edit-pen.png'
},
submitBtn
()
{
return
{
color
:
'#FFFFFF'
,
backgroundColor
:
'#2272FF'
}
}
},
onLoad
(
options
)
{
getApp
().
trackPage
(
'我的收获地址页'
)
},
onShow
()
{
if
(
this
.
$u
.
test
.
isEmpty
(
this
.
vuex_token
))
{
this
.
$u
.
route
({
url
:
'pages/login/index'
})
}
this
.
getData
();
},
methods
:
{
getData
()
{
this
.
getMineSite
()
},
getMineSite
()
{
this
.
$u
.
api
.
getMyAddress
().
then
((
res
)
=>
{
const
data
=
res
.
data
if
(
data
.
length
>
0
)
{
this
.
lists
=
data
.
map
(
v
=>
{
let
region
=
[]
if
(
v
.
provinceName
&&
v
.
cityName
&&
v
.
districtName
)
{
region
=
[
v
.
provinceName
,
v
.
cityName
,
v
.
districtName
]
}
v
.
region
=
region
return
v
})
}
})
},
toAddSite
()
{
this
.
$u
.
route
({
url
:
'pages/mine/address/addSite'
,
params
:
{
type
:
'select'
}
})
},
setDefault
(
val
)
{
this
.
$u
.
api
.
setDefaultAddress
({
id
:
val
.
id
}).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
this
.
lists
.
forEach
(
v
=>
{
this
.
$set
(
v
,
'enable'
,
v
.
id
===
val
.
id
?
1
:
0
)
})
this
.
getMineSite
()
let
pages
=
getCurrentPages
()
let
prevPage
=
pages
[
pages
.
length
-
2
]
prevPage
.
$vm
.
loadAddress
()
}
})
},
remove
(
val
)
{
uni
.
showModal
({
title
:
'温馨提示'
,
content
:
'确定要删除该收货地址?'
,
success
:
(
res
)
=>
{
if
(
res
.
confirm
)
{
uni
.
showLoading
({
title
:
'加载中'
,
})
this
.
$u
.
api
.
deleteMyAddress
({
id
:
val
.
id
}).
then
((
res
)
=>
{
uni
.
hideLoading
()
if
(
res
.
code
===
200
)
{
this
.
getMineSite
()
}
else
{
uni
.
showToast
({
icon
:
"none"
,
title
:
res
.
message
,
})
}
})
}
}
})
},
selectSite
(
val
)
{
let
pages
=
getCurrentPages
();
let
prevPage
=
pages
[
pages
.
length
-
2
];
//上一个页面
let
address
=
val
.
region
.
join
(
""
)
+
val
.
address
let
site
=
{
name
:
val
.
name
,
mobile
:
val
.
mobile
,
address
:
address
,
region
:
val
.
region
,
id
:
val
.
id
}
prevPage
.
$vm
.
updateSite
(
site
)
this
.
$u
.
route
({
type
:
'back'
})
},
toEditSite
(
val
){
const
region
=
val
.
region
.
join
(
'-'
)
this
.
$u
.
route
({
url
:
'pages/mine/address/addSite'
,
params
:
{
type
:
'select'
,
region
:
region
,
name
:
val
.
name
,
mobile
:
val
.
mobile
,
address
:
val
.
address
,
id
:
val
.
id
}
})
}
}
};
</
script
>
<
style
lang=
"scss"
scoped
>
.address-wrap
{
background-color
:
#F4F5F7
;
flex-direction
:column
;
height
:
100vh
;
.lists
{
width
:
100%
;
flex
:
1
;
overflow-y
:auto
;
}
}
.body
{
padding
:
30rpx
;
margin
:
30rpx
;
border-radius
:
12rpx
;
background-color
:
#FFFFFF
;
}
.addSite
{
display
:
flex
;
justify-content
:
space-around
;
width
:
600rpx
;
height
:
100rpx
;
line-height
:
100rpx
;
margin
:
50rpx
0
;
background-color
:
#2272FF
;
border-radius
:
60rpx
;
font-size
:
30rpx
;
.add
{
display
:
flex
;
align-items
:
center
;
color
:
#ffffff
;
.icon
{
margin-right
:
10rpx
;
}
}
}
</
style
>
src/pages/parts/application.vue
View file @
7c9f25e9
...
@@ -68,7 +68,7 @@ export default {
...
@@ -68,7 +68,7 @@ export default {
remark
:
''
,
remark
:
''
,
curType
:
0
,
curType
:
0
,
addressInfo
:
{
addressInfo
:
{
name
:
''
,
mobile
:
''
,
address
:
''
,
region
:
[]
id
:
''
,
name
:
''
,
mobile
:
''
,
address
:
''
,
region
:
[]
},
},
};
};
},
},
...
@@ -106,6 +106,7 @@ export default {
...
@@ -106,6 +106,7 @@ export default {
loadAddress
()
{
loadAddress
()
{
this
.
$u
.
api
.
getDefaultAddress
().
then
((
res
)
=>
{
this
.
$u
.
api
.
getDefaultAddress
().
then
((
res
)
=>
{
if
(
res
.
code
==
200
&&
res
.
data
)
{
if
(
res
.
code
==
200
&&
res
.
data
)
{
this
.
addressInfo
.
id
=
res
.
data
.
id
this
.
addressInfo
.
name
=
res
.
data
.
name
this
.
addressInfo
.
name
=
res
.
data
.
name
this
.
addressInfo
.
mobile
=
res
.
data
.
mobile
this
.
addressInfo
.
mobile
=
res
.
data
.
mobile
this
.
addressInfo
.
address
=
res
.
data
.
address
this
.
addressInfo
.
address
=
res
.
data
.
address
...
@@ -136,6 +137,7 @@ export default {
...
@@ -136,6 +137,7 @@ export default {
url
:
"pages/mine/address/addSite"
,
url
:
"pages/mine/address/addSite"
,
params
:
{
params
:
{
type
:
'select'
,
type
:
'select'
,
id
:
this
.
addressInfo
.
id
,
name
:
this
.
addressInfo
.
name
,
name
:
this
.
addressInfo
.
name
,
mobile
:
this
.
addressInfo
.
mobile
,
mobile
:
this
.
addressInfo
.
mobile
,
address
:
this
.
addressInfo
.
address
,
address
:
this
.
addressInfo
.
address
,
...
@@ -145,10 +147,7 @@ export default {
...
@@ -145,10 +147,7 @@ export default {
},
},
toAddress
()
{
toAddress
()
{
this
.
$u
.
route
({
this
.
$u
.
route
({
url
:
"pages/mine/address/index"
,
url
:
"pages/parts/address"
params
:
{
type
:
'parts'
}
})
})
},
},
updateSite
(
site
)
{
updateSite
(
site
)
{
...
...
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