Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
严立
/
mini-shimao
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
1128c163
authored
Nov 06, 2020
by
严立
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
LL - 我的地址优化
parent
13035af7
Show whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
346 additions
and
329 deletions
component/m-init.js
component/m-nav/option.js
component/m-popup/m-popup.js
pages/mall/exchange-record/exchange-record.js
pages/mall/exchange-record/exchange-record.wxml
pages/mall/exchange-record/exchange-record.wxss
pages/mall/exchange-state/exchange-state.js
pages/mall/exchange-submit/exchange-submit.js
pages/mall/goods/goods.wxml
pages/mall/goods/goods.wxss
pages/mine/address-list/address-list.js
pages/mine/address-list/address-list.wxml
pages/mine/address-list/address-list.wxss
pages/mine/address-operate/address-operate.js
pages/mine/address-operate/address-operate.wxml
pages/mine/address-operate/address-operate.wxss
utils/storage.js
wxss/samcss-layout.wxss
wxss/samcss-theme.wxss
component/m-init.js
View file @
1128c163
...
...
@@ -13,10 +13,12 @@ function showToast (funcOption) {
}
// 如果传参包含 duration 数值,使用该数值。
// 删除该属性是为了不污染 toast
组件
中的默认值。
// 删除该属性是为了不污染 toast
实例
中的默认值。
let
funcToastDuration
=
App
.
ui
.
toast
.
data
.
duration
if
(
funcOption
.
duration
)
{
funcToastDuration
=
funcOption
.
duration
// 设置 loading 默认时间为 30s
if
(
App
.
ui
.
toast
.
data
.
iconType
===
'loading'
)
funcToastDuration
=
30000
delete
funcOption
.
duration
}
...
...
component/m-nav/option.js
View file @
1128c163
component/m-popup/m-popup.js
View file @
1128c163
...
...
@@ -52,6 +52,7 @@ Component({
query
.
exec
((
response
)
=>
{
let
funcElementInfo
=
response
[
0
]
console
.
log
(
funcElementInfo
)
if
(
!
funcElementInfo
)
return
this
.
setData
({
deviationX
:
funcElementInfo
.
width
,
deviationY
:
funcElementInfo
.
height
,
...
...
pages/mall/exchange-record/exchange-record.js
View file @
1128c163
...
...
@@ -32,15 +32,24 @@ Page({
'name'
:
funcData
[
i
].
smOrderDetails
[
0
].
name
+
'-'
+
Number
(
funcData
[
i
].
status
),
'cover'
:
funcData
[
i
].
smOrderDetails
[
0
].
imgUrl
,
'price'
:
funcData
[
i
].
smOrderDetails
[
0
].
unitPrice
,
'priceTotal'
:
funcData
[
i
].
smOrderDetails
[
0
].
totalPrices
,
'quantity'
:
funcData
[
i
].
smOrderDetails
[
0
].
number
,
'priceTotal'
:
0
,
'quantity'
:
0
,
'state'
:
Number
(
funcData
[
i
].
status
),
'timeCreate'
:
App
.
modular
.
miment
(
funcData
[
i
].
createDate
).
format
(
'YYYY-MM-DD hh:mm:ss'
)
'timeCreate'
:
App
.
modular
.
miment
(
funcData
[
i
].
createDate
).
format
(
'YYYY-MM-DD hh:mm:ss'
),
'goods'
:
[],
}
let
funcGoodsList
=
funcData
[
i
].
smOrderDetails
for
(
let
ii
=
0
,
ll
=
funcGoodsList
.
length
;
ii
<
ll
;
ii
++
)
{
funcItem
.
quantity
=
funcItem
.
quantity
+
funcGoodsList
[
ii
].
number
funcItem
.
priceTotal
=
funcItem
.
priceTotal
+
funcGoodsList
[
ii
].
totalPrices
}
funcList
.
push
(
funcItem
)
}
this
.
setData
({
recordList
:
this
.
data
.
recordList
.
concat
(
funcList
)
recordList
:
this
.
data
.
pageIndex
===
1
?
funcList
:
this
.
data
.
recordList
.
concat
(
funcList
)
})
}).
catch
((
response
)
=>
{
...
...
@@ -55,7 +64,6 @@ Page({
*/
onRecordDetail
:
function
(
funcEvent
)
{
let
funcItem
=
funcEvent
.
currentTarget
.
dataset
.
item
console
.
log
(
funcItem
)
wx
.
navigateTo
({
url
:
'/pages/mall/exchange-state/exchange-state?id='
+
funcItem
.
id
})
},
...
...
@@ -93,7 +101,6 @@ Page({
})
this
.
setData
({
pageIndex
:
1
,
recordList
:
[],
})
this
.
queryRecord
()
}).
catch
((
response
)
=>
{})
...
...
@@ -137,7 +144,6 @@ Page({
})
this
.
setData
({
pageIndex
:
1
,
recordList
:
[],
})
this
.
queryRecord
()
}).
catch
((
response
)
=>
{})
...
...
@@ -146,6 +152,10 @@ Page({
})
},
onMallHome
:
function
()
{
wx
.
navigateBack
()
},
/**
* 页面触底事件
* @function
...
...
pages/mall/exchange-record/exchange-record.wxml
View file @
1128c163
...
...
@@ -3,7 +3,7 @@
<m-nav titleText="兑换记录" scrollHeight="{{navScroll}}" styleIndex="{{1}}"></m-nav>
<view class="container bg-gradient">
<view class="record_list">
<view class="record_list"
wx:if="{{recordList.length > 0}}"
>
<block wx:for="{{recordList}}" wx:for-index="index" wx:for-item="item" wx:key="index">
<!-- 待发货 -->
<view class="record_item column" wx:if="{{item.state === 1}}" data-item="{{item}}" bindtap="onRecordDetail">
...
...
@@ -19,8 +19,8 @@
<text class="font_bold_30 color_regular">{{item.name}}</text>
</view>
<view class="record_item_info_price column ce ae">
<text class="font_bold_30 color_regular">{{item.price
Total
+ ' 积分'}}</text>
<text class="font_normal_26 color_secondary">
x1
</text>
<text class="font_bold_30 color_regular">{{item.price + ' 积分'}}</text>
<text class="font_normal_26 color_secondary">
{{'x' + item.quantity}}
</text>
</view>
</view>
<view class="record_item_operation row ce ac">
...
...
@@ -42,8 +42,8 @@
<text class="font_bold_30 color_regular">{{item.name}}</text>
</view>
<view class="record_item_info_price column ce ae">
<text class="font_bold_30 color_regular">{{item.price
Total
+ ' 积分'}}</text>
<text class="font_normal_26 color_secondary">
x1
</text>
<text class="font_bold_30 color_regular">{{item.price + ' 积分'}}</text>
<text class="font_normal_26 color_secondary">
{{'x' + item.quantity}}
</text>
</view>
</view>
<view class="record_item_operation row ce ac">
...
...
@@ -65,8 +65,8 @@
<text class="font_bold_30 color_regular">{{item.name}}</text>
</view>
<view class="record_item_info_price column ce ae">
<text class="font_bold_30 color_regular">{{item.price
Total
+ ' 积分'}}</text>
<text class="font_normal_26 color_secondary">
x1
</text>
<text class="font_bold_30 color_regular">{{item.price + ' 积分'}}</text>
<text class="font_normal_26 color_secondary">
{{'x' + item.quantity}}
</text>
</view>
</view>
<view class="record_item_operation row ce ac">
...
...
@@ -88,8 +88,8 @@
<text class="font_bold_30 color_regular">{{item.name}}</text>
</view>
<view class="record_item_info_price column ce ae">
<text class="font_bold_30 color_regular">{{item.price
Total
+ ' 积分'}}</text>
<text class="font_normal_26 color_secondary">
x1
</text>
<text class="font_bold_30 color_regular">{{item.price + ' 积分'}}</text>
<text class="font_normal_26 color_secondary">
{{'x' + item.quantity}}
</text>
</view>
</view>
<view class="record_item_operation row ce ac">
...
...
@@ -98,4 +98,11 @@
</view>
</block>
</view>
<view class="record_list_nothing row cc ac" wx:if="{{recordList.length === 0}}">
<view class="column cc ac">
<text class="font_bold_38 color_secondary">暂无兑换记录</text>
<button class="record_list_nothing_mall row cc ac font_normal_30 color_submit" bindtap="onMallHome">去逛逛</button>
</view>
</view>
</view>
\ No newline at end of file
pages/mall/exchange-record/exchange-record.wxss
View file @
1128c163
.container {
width: 750rpx;
min-height: 100vh;
padding: 0 40rpx 120rpx 40rpx;
}
...
...
@@ -72,3 +71,19 @@
line-height: 32rpx;
color: #FFFFFF;
}
.record_list_nothing {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.record_list_nothing_mall {
width: 308rpx;
height: 96rpx;
margin: 68rpx 0 0 0;
border-radius: 2px;
background: #86C5E1;
}
pages/mall/exchange-state/exchange-state.js
View file @
1128c163
...
...
@@ -102,17 +102,15 @@ Page({
// 兑换商品数据
let
funcGoodsInfo
=
[]
let
funcIntegralTotal
=
0
for
(
let
i
=
0
,
l
=
funcData
.
smOrderDetails
.
length
;
i
<
l
;
i
++
)
{
let
funcItem
=
{
'name'
:
funcData
.
smOrderDetails
[
i
].
name
,
'cover'
:
funcData
.
smOrderDetails
[
i
].
imgUrl
,
'price'
:
funcData
.
smOrderDetails
[
i
].
totalPrices
,
'price'
:
funcData
.
smOrderDetails
[
i
].
unitPrice
,
'quantity'
:
funcData
.
smOrderDetails
[
i
].
number
,
'state'
:
funcData
.
smOrderDetails
[
i
].
status
,
}
funcGoodsInfo
.
push
(
funcItem
)
funcIntegralTotal
=
funcIntegralTotal
+
funcItem
.
price
*
funcItem
.
quantity
}
// 寄送地址
...
...
@@ -143,7 +141,7 @@ Page({
addressInfo
:
funcAddressInfo
,
addressSelection
:
funcAddressInfo
,
otherInfo
:
funcOtherInfo
,
integralTotal
:
func
IntegralTotal
,
integralTotal
:
func
Data
.
totalMoney
,
isExpress
:
Boolean
(
Number
(
funcData
.
expressType
)),
isViewDataReady
:
true
,
})
...
...
pages/mall/exchange-submit/exchange-submit.js
View file @
1128c163
...
...
@@ -37,7 +37,14 @@ Page({
},
onShow
:
function
()
{
let
funcTempOptions
=
wx
.
getStorageSync
(
'tempOptions'
)
if
(
funcTempOptions
)
{
this
.
setData
({
addressSelection
:
funcTempOptions
})
wx
.
removeStorageSync
(
'tempOptions'
)
this
.
queryUserAddress
()
}
},
/**
...
...
@@ -130,12 +137,12 @@ Page({
'area'
:
funcData
[
i
].
area
.
replace
(
/,/g
,
''
),
'address'
:
funcData
[
i
].
address
,
'phone'
:
funcData
[
i
].
mobile
,
'
d
efault'
:
Boolean
(
Number
(
funcData
[
i
].
defaultFlag
)),
'
isD
efault'
:
Boolean
(
Number
(
funcData
[
i
].
defaultFlag
)),
}
funcList
.
push
(
funcItem
)
//
设置默认地址
if
(
funcItem
.
d
efault
)
{
//
当前没有选择地址,自动选择默认地址。
if
(
Object
.
keys
(
this
.
data
.
addressSelection
).
length
===
0
&&
funcItem
.
isD
efault
)
{
this
.
setData
({
addressSelection
:
funcItem
})
...
...
@@ -180,12 +187,12 @@ Page({
onAddressSelection
:
function
()
{
// 地址列表为空,默认添加。
if
(
this
.
data
.
addressList
.
length
<
1
)
{
wx
.
navigateTo
({
url
:
'/pages/mine/address-operate/address-operate'
})
wx
.
navigateTo
({
url
:
'/pages/mine/address-operate/address-operate
?fromPage=exchange
'
})
return
}
// 地址列表不为空,跳转选择地址。
wx
.
navigateTo
({
url
:
'/pages/mine/address-list/address-list'
})
wx
.
navigateTo
({
url
:
'/pages/mine/address-list/address-list
?fromPage=exchange
'
})
},
onGoodsNotes
:
function
()
{
...
...
pages/mall/goods/goods.wxml
View file @
1128c163
...
...
@@ -25,10 +25,13 @@
</view>
<view class="goods_info_other row cb ac">
<view class="column">
<view class="row ac">
<text class="goods_info_price">{{goodsInfo.price}}</text>
<text class="goods_info_unit">积分</text>
</view>
<text class="font_normal_26 color_secondary" wx:if="{{goodsInfo.isExpress}}">不含运费</text>
</view>
<view class="operation">
<button class="row cc ac" bindtap="onExchange">去兑换</button>
</view>
...
...
pages/mall/goods/goods.wxss
View file @
1128c163
.container {
padding: 0 0 160rpx 0;
}
/* banner 样式 */
.banner {
position: relative;
...
...
@@ -79,6 +83,7 @@
/* 去兑换 */
.goods_info_other {
z-index: 4;
position: fixed;
bottom: 0;
left: 0;
...
...
@@ -86,6 +91,7 @@
height: 128rpx;
padding: 0 40rpx;
border-top: 1px #E2E7EF solid;
background: #FFFFFF;
}
.goods_info_price {
...
...
pages/mine/address-list/address-list.js
View file @
1128c163
let
App
=
getApp
()
Page
({
/**
* 页面的初始数据
*/
data
:
{
imageBase
:
App
.
globalData
.
appImageBase
,
options
:
{}
,
addressList
:[],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad
:
function
(
options
)
{
this
.
setData
({
options
:
options
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady
:
function
()
{
},
/**
* 生命周期函数--监听页面显示
*/
onShow
:
function
()
{
this
.
getAddressList
()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide
:
function
()
{
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload
:
function
()
{
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh
:
function
()
{
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom
:
function
()
{
},
/**
* 用户点击右上角分享
* 设置当前收货地址,仅从积分兑换下单页面进入有效
* @function
* @param {object} - funcEvent
* @returns
*/
onShareAppMessage
:
function
()
{
onSetCurrentAddress
:
function
(
funcEvent
)
{
let
funcItem
=
funcEvent
.
currentTarget
.
dataset
.
item
if
(
this
.
data
.
options
.
fromPage
===
'exchange'
)
{
wx
.
setStorageSync
(
'tempOptions'
,
funcItem
)
wx
.
navigateBack
()
}
},
/**
* 地址编辑操作
* @param {event} event
*/
onAddressEdit
:
function
(
event
)
{
let
index
=
event
.
currentTarget
.
dataset
.
index
let
param
=
{
type
:
"edit"
,
detail
:
this
.
data
.
addressList
[
index
],
}
wx
.
navigateTo
({
url
:
'../address-operate/address-operate?param='
+
JSON
.
stringify
(
param
),
})
onAddressEdit
:
function
(
funcEvent
)
{
let
funcItem
=
funcEvent
.
currentTarget
.
dataset
.
item
wx
.
navigateTo
({
url
:
'../address-operate/address-operate?id='
+
funcItem
.
id
})
},
...
...
@@ -100,25 +58,27 @@ Page({
* 获取收货地址
*/
getAddressList
:
function
()
{
let
that
=
this
App
.
request
({
url
:
'v3/shippingAddress/getAddressList'
,
}).
then
((
response
)
=>
{
console
.
log
(
response
)
if
(
response
.
code
==
200
)
{
response
.
data
.
forEach
(
item
=>
{
item
[
'showAddress'
]
=
item
.
area
.
replace
(
/,/g
,
''
)
+
item
.
address
})
that
.
setData
({
addressList
:
response
.
data
})
}
else
{
App
.
ui
.
showToast
({
iconType
:
'error'
,
title
:
response
.
message
,
duration
:
3000
})
let
funcData
=
response
.
data
let
funcList
=
[]
for
(
let
i
=
0
,
l
=
funcData
.
length
;
i
<
l
;
i
++
)
{
let
funcItem
=
{
'id'
:
funcData
[
i
].
id
,
'name'
:
funcData
[
i
].
name
,
'phone'
:
funcData
[
i
].
mobile
,
'area'
:
funcData
[
i
].
area
.
replace
(
/,/g
,
''
),
'address'
:
funcData
[
i
].
address
,
'isDefault'
:
Boolean
(
Number
(
funcData
[
i
].
defaultFlag
)),
}
funcList
.
push
(
funcItem
)
}
console
.
log
(
funcList
)
this
.
setData
({
addressList
:
funcList
})
}).
catch
((
response
)
=>
{
App
.
ui
.
showToast
({
iconType
:
'error'
,
...
...
pages/mine/address-list/address-list.wxml
View file @
1128c163
...
...
@@ -2,29 +2,29 @@
<m-nav titleText="收货地址"></m-nav>
<view class="container">
<view class="list" wx:if="{{addressList.length > 0}}">
<view class="address_list" wx:if="{{addressList.length > 0}}">
<block wx:for="{{addressList}}" wx:key="index">
<view class="address row ac cb" bindtap="onService">
<view>
<text class="name">{{item.name}}</text>
<text class="phone">{{item.mobile}}</text>
<text class="tag" wx:if="{{item.defaultFlag*1 == 1}}">默认</text>
<view class="address-text">
<text>{{item.showAddress}}</text>
<view class="address_item row ac cb" data-item="{{item}}" bindtap="onSetCurrentAddress">
<view class="address_item_info">
<view class="row ac">
<text class="address_item_info_name font_bold_30 color_regular">{{item.name}}</text>
<text class="address_item_info_phone font_normal_26 color_secondary">{{item.phone}}</text>
<view class="address_item_info_tag row cc ac" wx:if="{{item.isDefault}}">
<text class="font_bold_18 color_submit">默认</text>
</view>
</view>
<view class="address_item_info_address">
<text class="font_normal_26 color_regular">{{item.area + item.address}}</text>
</view>
</view>
<image src="{{imageBase + 'icon/edit-1.png'}}" bindtap="onAddressEdit" data-index="{{index}}
"></image>
<image class="icon_32" src="{{imageBase + 'icon/edit-1.png'}}" data-item="{{item}}" catchtap="onAddressEdit
"></image>
</view>
</block>
</view>
<view class="empty" wx:else>
<text
>暂无收货地址</text>
<text
>暂无收货地址</text>
</view>
</view>
<m-button-bottom text="﹢添加新地址" bindclick="onAddressAdd"></m-button-bottom>
\ No newline at end of file
pages/mine/address-list/address-list.wxss
View file @
1128c163
.container {
min-height: 85vh;
background-color: #F8F8FA;
page {
background: #F8F8FA;
}
.list {
.address_list {
width: 750rpx;
height: 100%;
padding: 0 40rpx;
}
.address {
.address
_item
{
width: 670rpx;
margin: 48rpx 40rpx;
padding: 32rpx;
background-color: #fff;
border-radius: 4rpx;
}
.address > view {
width: 560rpx;
}
.address > image {
width: 40rpx;
height: 40rpx;
margin-top: 10rpx;
}
.name {
font-size: 36rpx;
font-weight: 400;
margin-right: 12rpx;
}
.phone {
font-size: 26rpx;
font-weight: 400;
margin-right: 12rpx;
color: #A8A8AA;
}
.tag {
font-size: 22rpx;
font-weight: 400;
padding: 2rpx 10rpx;
color: #FFFFFF;
background-color: #88C5E0;
}
.address-text {
font-size: 26rpx;
font-weight: 400;
margin-top: 10rpx;
min-height: 174rpx;
margin: 32rpx 0 0 0;
padding: 38rpx 32rpx;
border-radius: 2px;
background: #FFFFFF;
}
.address_item_info_name {
margin: 0 16rpx 0 0;
}
.address_item_info_phone {
margin: 4rpx 16rpx 0 0;
}
.address_item_info_tag {
width: 60rpx;
height: 32rpx;
margin: 4rpx 0 0 0;
border-radius: 2px;
background: #86C5E1;
}
.address_item_info_address {
width: 534rpx;
margin: 16rpx 0 0 0;
}
.address_item_info_address > text {
display: block;
line-height: 40rpx;
}
.empty {
...
...
pages/mine/address-operate/address-operate.js
View file @
1128c163
let
App
=
getApp
()
Page
({
/**
* 页面的初始数据
*/
data
:
{
navTitle
:
'添加收货地址'
,
// 导航标题
operate
:
'add'
,
// add:添加操作;edit: 修改操作;默认添加
imageBase
:
App
.
globalData
.
appImageBase
,
name
:
''
,
phone
:
''
,
region
:
[
'福建省'
,
'厦门市'
,
'思明区'
],
address
:
''
,
// 详细地址
isDefault
:
true
,
// 是否默认地址
nameError
:
false
,
phoneError
:
false
,
addressError
:
false
,
navTitle
:
''
,
addressInfo
:
{
'id'
:
''
,
'name'
:
''
,
'phone'
:
''
,
'area'
:
[
'广东省'
,
'江门市'
,
'新会区'
],
'address'
:
''
,
'isDefault'
:
false
,
'errorName'
:
''
,
'errorPhone'
:
''
,
'errorArea'
:
''
,
'errorAddress'
:
''
,
},
},
/**
* 生命周期函数--监听页面加载
* options 参数设置
* ① {param: "{"type":"edit","detail":{"area":"福建省,厦门市,思明区","add…6b8bfdd6531f7f306","showAddress":"福建省厦门市思明区001"}}"}
* ② {param: "{"type":"add"}"}
*/
onLoad
:
function
(
options
)
{
// 编辑地址判断其它情况为添加地址
if
(
options
)
{
let
param
=
JSON
.
parse
(
options
.
param
)
if
(
param
.
type
===
'edit'
)
{
this
.
setData
({
navTitle
:
'编辑收货地址'
,
operate
:
'edit'
,
id
:
param
.
detail
.
id
,
name
:
param
.
detail
.
name
,
phone
:
param
.
detail
.
mobile
,
region
:
param
.
detail
.
area
.
split
(
','
),
address
:
param
.
detail
.
address
,
isDefault
:
param
.
detail
.
defaultFlag
*
1
==
1
navTitle
:
options
.
id
?
'编辑收货地址'
:
'添加收货地址'
,
addressInfo
:
Object
.
assign
(
this
.
data
.
addressInfo
,
{
id
:
options
.
id
}),
})
}
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady
:
function
()
{
},
/**
* 生命周期函数--监听页面显示
*/
onShow
:
function
()
{
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide
:
function
()
{
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload
:
function
()
{
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh
:
function
()
{
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom
:
function
()
{
console
.
log
(
this
.
data
.
addressInfo
)
this
.
queryAddressList
()
},
/**
*
用户点击右上角分享
*
获取收货地址
*/
onShareAppMessage
:
function
()
{
queryAddressList
:
function
()
{
App
.
request
({
url
:
'v3/shippingAddress/getAddressList'
,
}).
then
((
response
)
=>
{
let
funcData
=
response
.
data
for
(
let
i
=
0
,
l
=
funcData
.
length
;
i
<
l
;
i
++
)
{
if
(
this
.
data
.
addressInfo
.
id
===
funcData
[
i
].
id
)
{
this
.
setData
({
addressInfo
:
{
'id'
:
funcData
[
i
].
id
,
'name'
:
funcData
[
i
].
name
,
'phone'
:
funcData
[
i
].
mobile
,
'area'
:
funcData
[
i
].
area
.
split
(
','
),
'address'
:
funcData
[
i
].
address
,
'isDefault'
:
Boolean
(
Number
(
funcData
[
i
].
defaultFlag
)),
}
})
break
}
}
}).
catch
((
response
)
=>
{
App
.
ui
.
showToast
({
iconType
:
'error'
,
title
:
response
.
message
,
duration
:
3000
})
})
},
/**
* 文本输入
* @param {event} event
*/
onInputBlur
:
function
(
event
)
{
console
.
log
(
event
.
detail
)
let
id
=
event
.
detail
.
id
let
value
=
event
.
detail
.
value
if
(
id
===
'name'
)
{
onInputBlur
:
function
(
funcEvent
)
{
let
funcType
=
funcEvent
.
detail
.
id
let
funcValue
=
funcEvent
.
detail
.
value
switch
(
funcType
)
{
case
'name'
:
this
.
setData
({
name
:
value
,
nameError
:
(
value
.
length
==
0
)
addressInfo
:
Object
.
assign
(
this
.
data
.
addressInfo
,
{
name
:
funcValue
,
errorName
:
App
.
modular
.
rule
.
item
(
'name'
,
funcValue
)
})
}
else
if
(
id
===
'phone'
)
{
})
break
case
'phone'
:
this
.
setData
({
phone
:
value
,
phoneError
:
(
value
.
length
==
0
)
addressInfo
:
Object
.
assign
(
this
.
data
.
addressInfo
,
{
phone
:
funcValue
,
errorPhone
:
App
.
modular
.
rule
.
item
(
'phone'
,
funcValue
)
})
}
else
if
(
id
===
'address'
)
{
})
break
case
'address'
:
this
.
setData
({
address
:
value
,
addressError
:
(
value
.
length
==
0
)
addressInfo
:
Object
.
assign
(
this
.
data
.
addressInfo
,
{
address
:
funcValue
,
errorAddress
:
App
.
modular
.
rule
.
item
(
'address'
,
funcValue
)
})
})
break
}
console
.
log
(
this
.
data
.
addressInfo
)
},
inspectForm
:
function
()
{
let
funcPass
=
true
let
funcFormKeys
=
Object
.
keys
(
this
.
data
.
addressInfo
)
for
(
let
i
=
0
,
l
=
funcFormKeys
.
length
;
i
<
l
;
i
++
)
{
// error 信息验证,如果存在非空字段,则表示有数据校验不通过。
if
(
funcFormKeys
[
i
].
indexOf
(
'error'
)
>=
0
&&
this
.
data
.
addressInfo
[
funcFormKeys
[
i
]])
{
funcPass
=
false
}
// 常规字段验证,确保没有非空字段。
if
(
funcFormKeys
[
i
].
indexOf
(
'error'
)
<
0
&&
this
.
data
.
addressInfo
[
funcFormKeys
[
i
]]
===
''
)
{
funcPass
=
false
}
}
return
funcPass
},
/**
* 省市区选择
* @param {event} event
*/
onRegionChange
:
function
(
event
)
{
// console.log('picker发送选择改变,携带值为', event.detail.value)
onSelectionRegion
:
function
(
event
)
{
this
.
setData
({
region
:
event
.
detail
.
value
addressInfo
:
Object
.
assign
(
this
.
data
.
addressInfo
,
{
'area'
:
event
.
detail
.
value
})
})
},
...
...
@@ -136,10 +128,9 @@ Page({
* 设置是否为默认地址
* @param {event}} event
*/
onSwitchChange
:
function
(
event
)
{
// console.log(event.detail)
onSetDefaultAddress
:
function
(
event
)
{
this
.
setData
({
isDefault
:
event
.
detail
.
value
addressInfo
:
Object
.
assign
(
this
.
data
.
addressInfo
,
{
'isDefault'
:
event
.
detail
.
value
})
})
},
...
...
@@ -147,68 +138,47 @@ Page({
* 保存地址
* @param {event} event
*/
onSubmit
:
function
(
event
)
{
if
(
this
.
data
.
name
.
length
==
0
||
this
.
data
.
phone
.
length
==
0
||
this
.
data
.
address
.
length
==
0
)
{
this
.
setData
({
nameError
:
(
this
.
data
.
name
.
length
==
0
),
phoneError
:
(
this
.
data
.
phone
.
length
==
0
),
addressError
:
(
this
.
data
.
address
.
length
==
0
),
})
return
}
let
regionStr
=
this
.
data
.
region
.
join
(
','
)
let
param
=
{
name
:
this
.
data
.
name
,
mobile
:
this
.
data
.
phone
,
area
:
regionStr
,
address
:
this
.
data
.
address
,
defaultFlag
:
this
.
data
.
isDefault
?
1
:
0
,
onSaveAddress
:
function
(
event
)
{
if
(
!
this
.
inspectForm
())
return
let
funcParams
=
{
'name'
:
this
.
data
.
addressInfo
.
name
,
'mobile'
:
this
.
data
.
addressInfo
.
phone
,
'area'
:
this
.
data
.
addressInfo
.
area
.
join
(
','
),
'address'
:
this
.
data
.
addressInfo
.
address
,
'defaultFlag'
:
this
.
data
.
addressInfo
.
isDefault
?
1
:
0
,
}
if
(
this
.
data
.
operate
===
'edit'
)
{
param
[
'id'
]
=
this
.
data
.
id
}
if
(
this
.
data
.
addressInfo
.
id
)
funcParams
.
id
=
this
.
data
.
addressInfo
.
id
App
.
ui
.
showToast
({
'iconType'
:
'loading'
,
'title'
:
'提交中'
,
'duration'
:
60000
})
App
.
request
({
url
:
'v3/shippingAddress/saveAddress'
,
params
:
param
params
:
funcParams
}).
then
((
response
)
=>
{
console
.
log
(
response
)
if
(
response
.
code
==
200
)
{
App
.
ui
.
showToast
({
iconType
:
'success'
,
title
:
'提交成功'
,
duration
:
2000
})
setTimeout
(()
=>
{
ending
:
()
=>
{
wx
.
navigateBack
()
},
2000
)
}
else
{
}
})
}).
catch
((
response
)
=>
{
App
.
ui
.
showToast
({
iconType
:
'error'
,
title
:
response
.
message
,
duration
:
2000
})
}
})
},
/**
* 删除地址
* @param {event} event
*/
onDelete
:
function
(
event
)
{
onDelete
Address
:
function
(
event
)
{
App
.
ui
.
showDialog
({
type
:
'confirm'
,
title
:
'提示'
,
...
...
@@ -219,27 +189,32 @@ Page({
App
.
ui
.
showToast
({
'iconType'
:
'loading'
,
'title'
:
'处理中'
,
'duration'
:
6
0000
'duration'
:
3
0000
})
App
.
wxR
equest
({
App
.
r
equest
({
url
:
'v3/shippingAddress/del'
,
data
:
{
'id'
:
this
.
data
.
id
,
}
,
success
:
(
response
)
=>
{
params
:
{
'id'
:
this
.
data
.
addressInfo
.
id
,
}
}).
then
(
(
response
)
=>
{
App
.
ui
.
showToast
({
iconType
:
'success'
,
title
:
'删除成功'
,
duration
:
2000
ending
:
()
=>
{
wx
.
navigateBack
()
}
})
setTimeout
(()
=>
{
}).
catch
((
response
)
=>
{
App
.
ui
.
showToast
({
iconType
:
'error'
,
title
:
response
.
message
,
ending
:
()
=>
{
wx
.
navigateBack
()
},
2000
)
}
})
})
},
fail
:
()
=>
{},
})
}
})
\ No newline at end of file
pages/mine/address-operate/address-operate.wxml
View file @
1128c163
...
...
@@ -4,33 +4,45 @@
<view class="container">
<view class="address_info">
<view class="address_item
bottom_line
">
<view class="address_item">
<view class="row ac">
<text class="title">收货人</text>
<m-input inputId="name" className="address_item_input row ac" value="{{name}}" placeholder="请输入" maxlength="20"
bindblur="onInputBlur">
<m-input
inputId="name"
className="address_item_input row ac"
value="{{addressInfo.name}}"
placeholder="请输入"
maxlength="20"
bindblur="onInputBlur"
>
</m-input>
</view>
<text class="text_error" wx:if="{{nameError}}">请填写收货人</text>
<text class="text_error" wx:if="{{addressInfo.errorName}}">请填写收货人</text>
</view>
<view class="address_item
bottom_line
">
<view class="address_item">
<view class="row ac">
<text class="title">手机号</text>
<m-input inputId="phone" className="address_item_input row ac" value="{{phone}}" placeholder="请输入"
maxlength="11" type="number" bindblur="onInputBlur">
<m-input
inputId="phone"
className="address_item_input row ac"
value="{{addressInfo.phone}}"
placeholder="请输入"
maxlength="11"
type="number"
bindblur="onInputBlur"
>
</m-input>
</view>
<text class="text_error" wx:if="{{
phoneError
}}">请填写手机号</text>
<text class="text_error" wx:if="{{
addressInfo.errorPhone
}}">请填写手机号</text>
</view>
<view class="address_item row ac
bottom_line
">
<view class="address_item row ac">
<text class="title">所在地区</text>
<picker class="address_item_picker" mode="region"
bindchange="onRegionChange" value="{{region}}
">
<picker class="address_item_picker" mode="region"
value="{{addressInfo.area}}" bindchange="onSelectionRegion
">
<view class="row ac cb">
<view>{{
region[0]}}{{region[1]}}{{region
[2]}}</view>
<view>{{
addressInfo.area[0] + addressInfo.area[1] + addressInfo.area
[2]}}</view>
<image class="icon_32" src="{{imageBase + 'icon/arrow-r-2.png'}}"></image>
</view>
</picker>
...
...
@@ -39,19 +51,27 @@
<view class="address_item">
<view class="row ac">
<text class="title">详细地址</text>
<m-input inputId="address" className="address_item_input" value="{{address}}" placeholder="如街道、门牌号、小区、楼栋号等" maxlength="30" bindblur="onInputBlur"></m-input>
<m-input
inputId="address"
className="address_item_input"
value="{{addressInfo.address}}"
placeholder="如街道、门牌号、小区、楼栋号等"
maxlength="30"
bindblur="onInputBlur"
>
</m-input>
</view>
<text class="text_error" wx:if="{{address
Error
}}">请填写详细地址</text>
<text class="text_error" wx:if="{{address
Info.errorAddress
}}">请填写详细地址</text>
</view>
</view>
<view class="address_info top30rpx">
<view class="address_item row ac cb">
<text class="title">设为默认地址</text>
<switch checked="{{
isDefault}}" bindchange="onSwitchChange
"></switch>
<switch checked="{{
addressInfo.isDefault}}" bindchange="onSetDefaultAddress
"></switch>
</view>
</view>
<button class="button row c
on-c align-c top40rpx" bindtap="onSubmit
">保存</button>
<button wx:if="{{
operate === 'edit'}}" class="button-delete row con-c align-c" bindtap="onDelete
">删除收货地址</button>
<button class="button row c
c ac top40rpx" bindtap="onSaveAddress
">保存</button>
<button wx:if="{{
addressInfo.id}}" class="button-delete row cc ac" bindtap="onDeleteAddress
">删除收货地址</button>
</view>
\ No newline at end of file
pages/mine/address-operate/address-operate.wxss
View file @
1128c163
.container {
min-height: 90vh;
margin: 32rpx 0 0 0;
background-color: #F8F8FA;
}
.bottom_line {
border-bottom: 1px #F8F8FA solid;
}
.top30rpx {
margin-top: 30rpx;
}
...
...
@@ -24,11 +21,17 @@
.address_item {
width: 670rpx;
min-height: 90rpx;
padding: 28rpx 0;
padding: 26rpx 0;
border-bottom: 1px #E2E7EF solid;
}
.address_item:last-child {
padding: 26rpx 0 112rpx 0;
border: none;
}
.title {
min-width: 1
5
0rpx;
min-width: 1
6
0rpx;
font-size: 30rpx;
font-weight: 400;
color: #15191F;
...
...
utils/storage.js
View file @
1128c163
...
...
@@ -2,3 +2,5 @@
// shopInfoBuffer: 门店详情信息
// orderInfoBuffer: 订单信息缓存
// clubExamine: 我的俱乐部待审核数量
// tempOptions: 页面跳转特殊参数临时缓存,用于页面退后,跳转主页等无法路径传参的场景。
\ No newline at end of file
wxss/samcss-layout.wxss
View file @
1128c163
/* SAMCSS-layout */
page {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.container {
display: flex;
flex-direction: column;
align-items: center;
flex-grow: 1;
}
.row {
...
...
wxss/samcss-theme.wxss
View file @
1128c163
...
...
@@ -28,6 +28,7 @@
.bgcolor_disable { background-color: #86C5E1; }
/* 常规 */
.font_normal_18 { font-size: 18rpx; font-weight: 400; line-height: 26rpx; }
.font_normal_22 { font-size: 22rpx; font-weight: 400; line-height: 32rpx; }
.font_normal_26 { font-size: 26rpx; font-weight: 400; line-height: 36rpx; }
.font_normal_30 { font-size: 30rpx; font-weight: 400; line-height: 40rpx; }
...
...
@@ -38,6 +39,7 @@
.font_normal_54 { font-size: 54rpx; font-weight: 400; line-height: 76rpx; }
/* 粗体 */
.font_bold_18 { font-size: 18rpx; font-weight: 700; line-height: 26rpx; }
.font_bold_22 { font-size: 22rpx; font-weight: 700; line-height: 32rpx; }
.font_bold_26 { font-size: 26rpx; font-weight: 700; line-height: 36rpx; }
.font_bold_30 { font-size: 30rpx; font-weight: 700; line-height: 40rpx; }
...
...
@@ -48,6 +50,7 @@
.font_bold_54 { font-size: 54rpx; font-weight: 700; line-height: 76rpx; }
/* 更粗 */
.font_bolder_18 { font-size: 18rpx; font-weight: 900; line-height: 26rpx; }
.font_bolder_22 { font-size: 22rpx; font-weight: 900; line-height: 32rpx; }
.font_bolder_26 { font-size: 26rpx; font-weight: 900; line-height: 36rpx; }
.font_bolder_30 { font-size: 30rpx; font-weight: 900; line-height: 40rpx; }
...
...
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