Commit 1128c163 by 严立

LL - 我的地址优化

parent 13035af7
...@@ -13,10 +13,12 @@ function showToast (funcOption) { ...@@ -13,10 +13,12 @@ function showToast (funcOption) {
} }
// 如果传参包含 duration 数值,使用该数值。 // 如果传参包含 duration 数值,使用该数值。
// 删除该属性是为了不污染 toast 组件中的默认值。 // 删除该属性是为了不污染 toast 实例中的默认值。
let funcToastDuration = App.ui.toast.data.duration let funcToastDuration = App.ui.toast.data.duration
if (funcOption.duration) { if (funcOption.duration) {
funcToastDuration = funcOption.duration funcToastDuration = funcOption.duration
// 设置 loading 默认时间为 30s
if (App.ui.toast.data.iconType === 'loading') funcToastDuration = 30000
delete funcOption.duration delete funcOption.duration
} }
......
...@@ -52,6 +52,7 @@ Component({ ...@@ -52,6 +52,7 @@ Component({
query.exec((response) => { query.exec((response) => {
let funcElementInfo = response[0] let funcElementInfo = response[0]
console.log(funcElementInfo) console.log(funcElementInfo)
if (!funcElementInfo) return
this.setData({ this.setData({
deviationX: funcElementInfo.width, deviationX: funcElementInfo.width,
deviationY: funcElementInfo.height, deviationY: funcElementInfo.height,
......
...@@ -32,15 +32,24 @@ Page({ ...@@ -32,15 +32,24 @@ Page({
'name': funcData[i].smOrderDetails[0].name + '-' + Number(funcData[i].status), 'name': funcData[i].smOrderDetails[0].name + '-' + Number(funcData[i].status),
'cover': funcData[i].smOrderDetails[0].imgUrl, 'cover': funcData[i].smOrderDetails[0].imgUrl,
'price': funcData[i].smOrderDetails[0].unitPrice, 'price': funcData[i].smOrderDetails[0].unitPrice,
'priceTotal': funcData[i].smOrderDetails[0].totalPrices, 'priceTotal': 0,
'quantity': funcData[i].smOrderDetails[0].number, 'quantity': 0,
'state': Number(funcData[i].status), '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) funcList.push(funcItem)
} }
this.setData({ this.setData({
recordList: this.data.recordList.concat(funcList) recordList: this.data.pageIndex === 1 ? funcList : this.data.recordList.concat(funcList)
}) })
}).catch((response) => { }).catch((response) => {
...@@ -55,7 +64,6 @@ Page({ ...@@ -55,7 +64,6 @@ Page({
*/ */
onRecordDetail: function (funcEvent) { onRecordDetail: function (funcEvent) {
let funcItem = funcEvent.currentTarget.dataset.item let funcItem = funcEvent.currentTarget.dataset.item
console.log(funcItem)
wx.navigateTo({ url: '/pages/mall/exchange-state/exchange-state?id=' + funcItem.id }) wx.navigateTo({ url: '/pages/mall/exchange-state/exchange-state?id=' + funcItem.id })
}, },
...@@ -93,7 +101,6 @@ Page({ ...@@ -93,7 +101,6 @@ Page({
}) })
this.setData({ this.setData({
pageIndex: 1, pageIndex: 1,
recordList: [],
}) })
this.queryRecord() this.queryRecord()
}).catch((response) => {}) }).catch((response) => {})
...@@ -137,7 +144,6 @@ Page({ ...@@ -137,7 +144,6 @@ Page({
}) })
this.setData({ this.setData({
pageIndex: 1, pageIndex: 1,
recordList: [],
}) })
this.queryRecord() this.queryRecord()
}).catch((response) => {}) }).catch((response) => {})
...@@ -146,6 +152,10 @@ Page({ ...@@ -146,6 +152,10 @@ Page({
}) })
}, },
onMallHome: function () {
wx.navigateBack()
},
/** /**
* 页面触底事件 * 页面触底事件
* @function * @function
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<m-nav titleText="兑换记录" scrollHeight="{{navScroll}}" styleIndex="{{1}}"></m-nav> <m-nav titleText="兑换记录" scrollHeight="{{navScroll}}" styleIndex="{{1}}"></m-nav>
<view class="container bg-gradient"> <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"> <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"> <view class="record_item column" wx:if="{{item.state === 1}}" data-item="{{item}}" bindtap="onRecordDetail">
...@@ -19,8 +19,8 @@ ...@@ -19,8 +19,8 @@
<text class="font_bold_30 color_regular">{{item.name}}</text> <text class="font_bold_30 color_regular">{{item.name}}</text>
</view> </view>
<view class="record_item_info_price column ce ae"> <view class="record_item_info_price column ce ae">
<text class="font_bold_30 color_regular">{{item.priceTotal + ' 积分'}}</text> <text class="font_bold_30 color_regular">{{item.price + ' 积分'}}</text>
<text class="font_normal_26 color_secondary">x1</text> <text class="font_normal_26 color_secondary">{{'x' + item.quantity}}</text>
</view> </view>
</view> </view>
<view class="record_item_operation row ce ac"> <view class="record_item_operation row ce ac">
...@@ -42,8 +42,8 @@ ...@@ -42,8 +42,8 @@
<text class="font_bold_30 color_regular">{{item.name}}</text> <text class="font_bold_30 color_regular">{{item.name}}</text>
</view> </view>
<view class="record_item_info_price column ce ae"> <view class="record_item_info_price column ce ae">
<text class="font_bold_30 color_regular">{{item.priceTotal + ' 积分'}}</text> <text class="font_bold_30 color_regular">{{item.price + ' 积分'}}</text>
<text class="font_normal_26 color_secondary">x1</text> <text class="font_normal_26 color_secondary">{{'x' + item.quantity}}</text>
</view> </view>
</view> </view>
<view class="record_item_operation row ce ac"> <view class="record_item_operation row ce ac">
...@@ -65,8 +65,8 @@ ...@@ -65,8 +65,8 @@
<text class="font_bold_30 color_regular">{{item.name}}</text> <text class="font_bold_30 color_regular">{{item.name}}</text>
</view> </view>
<view class="record_item_info_price column ce ae"> <view class="record_item_info_price column ce ae">
<text class="font_bold_30 color_regular">{{item.priceTotal + ' 积分'}}</text> <text class="font_bold_30 color_regular">{{item.price + ' 积分'}}</text>
<text class="font_normal_26 color_secondary">x1</text> <text class="font_normal_26 color_secondary">{{'x' + item.quantity}}</text>
</view> </view>
</view> </view>
<view class="record_item_operation row ce ac"> <view class="record_item_operation row ce ac">
...@@ -88,8 +88,8 @@ ...@@ -88,8 +88,8 @@
<text class="font_bold_30 color_regular">{{item.name}}</text> <text class="font_bold_30 color_regular">{{item.name}}</text>
</view> </view>
<view class="record_item_info_price column ce ae"> <view class="record_item_info_price column ce ae">
<text class="font_bold_30 color_regular">{{item.priceTotal + ' 积分'}}</text> <text class="font_bold_30 color_regular">{{item.price + ' 积分'}}</text>
<text class="font_normal_26 color_secondary">x1</text> <text class="font_normal_26 color_secondary">{{'x' + item.quantity}}</text>
</view> </view>
</view> </view>
<view class="record_item_operation row ce ac"> <view class="record_item_operation row ce ac">
...@@ -98,4 +98,11 @@ ...@@ -98,4 +98,11 @@
</view> </view>
</block> </block>
</view> </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> </view>
\ No newline at end of file
.container { .container {
width: 750rpx; width: 750rpx;
min-height: 100vh;
padding: 0 40rpx 120rpx 40rpx; padding: 0 40rpx 120rpx 40rpx;
} }
...@@ -72,3 +71,19 @@ ...@@ -72,3 +71,19 @@
line-height: 32rpx; line-height: 32rpx;
color: #FFFFFF; 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;
}
...@@ -102,17 +102,15 @@ Page({ ...@@ -102,17 +102,15 @@ Page({
// 兑换商品数据 // 兑换商品数据
let funcGoodsInfo = [] let funcGoodsInfo = []
let funcIntegralTotal = 0
for (let i = 0, l = funcData.smOrderDetails.length; i < l; i++) { for (let i = 0, l = funcData.smOrderDetails.length; i < l; i++) {
let funcItem = { let funcItem = {
'name': funcData.smOrderDetails[i].name, 'name': funcData.smOrderDetails[i].name,
'cover': funcData.smOrderDetails[i].imgUrl, 'cover': funcData.smOrderDetails[i].imgUrl,
'price': funcData.smOrderDetails[i].totalPrices, 'price': funcData.smOrderDetails[i].unitPrice,
'quantity': funcData.smOrderDetails[i].number, 'quantity': funcData.smOrderDetails[i].number,
'state': funcData.smOrderDetails[i].status, 'state': funcData.smOrderDetails[i].status,
} }
funcGoodsInfo.push(funcItem) funcGoodsInfo.push(funcItem)
funcIntegralTotal = funcIntegralTotal + funcItem.price * funcItem.quantity
} }
// 寄送地址 // 寄送地址
...@@ -143,7 +141,7 @@ Page({ ...@@ -143,7 +141,7 @@ Page({
addressInfo: funcAddressInfo, addressInfo: funcAddressInfo,
addressSelection: funcAddressInfo, addressSelection: funcAddressInfo,
otherInfo: funcOtherInfo, otherInfo: funcOtherInfo,
integralTotal: funcIntegralTotal, integralTotal: funcData.totalMoney,
isExpress: Boolean(Number(funcData.expressType)), isExpress: Boolean(Number(funcData.expressType)),
isViewDataReady: true, isViewDataReady: true,
}) })
......
...@@ -37,7 +37,14 @@ Page({ ...@@ -37,7 +37,14 @@ Page({
}, },
onShow: function () { onShow: function () {
let funcTempOptions = wx.getStorageSync('tempOptions')
if (funcTempOptions) {
this.setData({
addressSelection: funcTempOptions
})
wx.removeStorageSync('tempOptions')
this.queryUserAddress() this.queryUserAddress()
}
}, },
/** /**
...@@ -130,12 +137,12 @@ Page({ ...@@ -130,12 +137,12 @@ Page({
'area': funcData[i].area.replace(/,/g, ''), 'area': funcData[i].area.replace(/,/g, ''),
'address': funcData[i].address, 'address': funcData[i].address,
'phone': funcData[i].mobile, 'phone': funcData[i].mobile,
'default': Boolean(Number(funcData[i].defaultFlag)), 'isDefault': Boolean(Number(funcData[i].defaultFlag)),
} }
funcList.push(funcItem) funcList.push(funcItem)
// 设置默认地址 // 当前没有选择地址,自动选择默认地址。
if (funcItem.default) { if (Object.keys(this.data.addressSelection).length === 0 && funcItem.isDefault) {
this.setData({ this.setData({
addressSelection: funcItem addressSelection: funcItem
}) })
...@@ -180,12 +187,12 @@ Page({ ...@@ -180,12 +187,12 @@ Page({
onAddressSelection: function () { onAddressSelection: function () {
// 地址列表为空,默认添加。 // 地址列表为空,默认添加。
if (this.data.addressList.length < 1) { 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 return
} }
// 地址列表不为空,跳转选择地址。 // 地址列表不为空,跳转选择地址。
wx.navigateTo({ url: '/pages/mine/address-list/address-list' }) wx.navigateTo({ url: '/pages/mine/address-list/address-list?fromPage=exchange' })
}, },
onGoodsNotes: function () { onGoodsNotes: function () {
......
...@@ -25,10 +25,13 @@ ...@@ -25,10 +25,13 @@
</view> </view>
<view class="goods_info_other row cb ac"> <view class="goods_info_other row cb ac">
<view class="column">
<view class="row ac"> <view class="row ac">
<text class="goods_info_price">{{goodsInfo.price}}</text> <text class="goods_info_price">{{goodsInfo.price}}</text>
<text class="goods_info_unit">积分</text> <text class="goods_info_unit">积分</text>
</view> </view>
<text class="font_normal_26 color_secondary" wx:if="{{goodsInfo.isExpress}}">不含运费</text>
</view>
<view class="operation"> <view class="operation">
<button class="row cc ac" bindtap="onExchange">去兑换</button> <button class="row cc ac" bindtap="onExchange">去兑换</button>
</view> </view>
......
.container {
padding: 0 0 160rpx 0;
}
/* banner 样式 */ /* banner 样式 */
.banner { .banner {
position: relative; position: relative;
...@@ -79,6 +83,7 @@ ...@@ -79,6 +83,7 @@
/* 去兑换 */ /* 去兑换 */
.goods_info_other { .goods_info_other {
z-index: 4;
position: fixed; position: fixed;
bottom: 0; bottom: 0;
left: 0; left: 0;
...@@ -86,6 +91,7 @@ ...@@ -86,6 +91,7 @@
height: 128rpx; height: 128rpx;
padding: 0 40rpx; padding: 0 40rpx;
border-top: 1px #E2E7EF solid; border-top: 1px #E2E7EF solid;
background: #FFFFFF;
} }
.goods_info_price { .goods_info_price {
......
let App = getApp() let App = getApp()
Page({ Page({
/**
* 页面的初始数据
*/
data: { data: {
imageBase: App.globalData.appImageBase, options: {},
addressList:[], addressList:[],
}, },
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) { onLoad: function (options) {
this.setData({
options: options
})
}, },
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () { onShow: function () {
this.getAddressList() this.getAddressList()
}, },
/** /**
* 生命周期函数--监听页面隐藏 * 设置当前收货地址,仅从积分兑换下单页面进入有效
*/ * @function
onHide: function () { * @param {object} - funcEvent
* @returns
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/ */
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 * @param {event} event
*/ */
onAddressEdit: function (event) { onAddressEdit: function (funcEvent) {
let funcItem = funcEvent.currentTarget.dataset.item
let index = event.currentTarget.dataset.index wx.navigateTo({ url: '../address-operate/address-operate?id=' + funcItem.id })
let param = {
type: "edit",
detail: this.data.addressList[index],
}
wx.navigateTo({
url: '../address-operate/address-operate?param='+JSON.stringify(param),
})
}, },
...@@ -100,25 +58,27 @@ Page({ ...@@ -100,25 +58,27 @@ Page({
* 获取收货地址 * 获取收货地址
*/ */
getAddressList: function () { getAddressList: function () {
let that = this
App.request({ App.request({
url: 'v3/shippingAddress/getAddressList', url: 'v3/shippingAddress/getAddressList',
}).then((response) => { }).then((response) => {
console.log(response) let funcData = response.data
if (response.code == 200) { let funcList = []
response.data.forEach(item => { for (let i = 0, l = funcData.length; i < l; i++) {
item['showAddress'] = item.area.replace(/,/g,'') + item.address let funcItem = {
}) 'id': funcData[i].id,
that.setData({ 'name': funcData[i].name,
addressList: response.data 'phone': funcData[i].mobile,
}) 'area': funcData[i].area.replace(/,/g, ''),
} else { 'address': funcData[i].address,
App.ui.showToast({ 'isDefault': Boolean(Number(funcData[i].defaultFlag)),
iconType: 'error',
title: response.message,
duration: 3000
})
} }
funcList.push(funcItem)
}
console.log(funcList)
this.setData({
addressList: funcList
})
}).catch((response) => { }).catch((response) => {
App.ui.showToast({ App.ui.showToast({
iconType: 'error', iconType: 'error',
......
...@@ -2,29 +2,29 @@ ...@@ -2,29 +2,29 @@
<m-nav titleText="收货地址"></m-nav> <m-nav titleText="收货地址"></m-nav>
<view class="container"> <view class="container">
<view class="address_list" wx:if="{{addressList.length > 0}}">
<view class="list" wx:if="{{addressList.length > 0}}">
<block wx:for="{{addressList}}" wx:key="index"> <block wx:for="{{addressList}}" wx:key="index">
<view class="address row ac cb" bindtap="onService"> <view class="address_item row ac cb" data-item="{{item}}" bindtap="onSetCurrentAddress">
<view> <view class="address_item_info">
<text class="name">{{item.name}}</text> <view class="row ac">
<text class="phone">{{item.mobile}}</text> <text class="address_item_info_name font_bold_30 color_regular">{{item.name}}</text>
<text class="tag" wx:if="{{item.defaultFlag*1 == 1}}">默认</text> <text class="address_item_info_phone font_normal_26 color_secondary">{{item.phone}}</text>
<view class="address-text"> <view class="address_item_info_tag row cc ac" wx:if="{{item.isDefault}}">
<text>{{item.showAddress}}</text> <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>
</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> </view>
</block> </block>
</view> </view>
<view class="empty" wx:else> <view class="empty" wx:else>
<text >暂无收货地址</text> <text>暂无收货地址</text>
</view> </view>
</view> </view>
<m-button-bottom text="﹢添加新地址" bindclick="onAddressAdd"></m-button-bottom> <m-button-bottom text="﹢添加新地址" bindclick="onAddressAdd"></m-button-bottom>
\ No newline at end of file
.container { page {
min-height: 85vh; background: #F8F8FA;
background-color: #F8F8FA;
} }
.list {
.address_list {
width: 750rpx; width: 750rpx;
height: 100%; height: 100%;
padding: 0 40rpx;
} }
.address { .address_item {
width: 670rpx; width: 670rpx;
margin: 48rpx 40rpx; min-height: 174rpx;
padding: 32rpx; margin: 32rpx 0 0 0;
background-color: #fff; padding: 38rpx 32rpx;
border-radius: 4rpx; border-radius: 2px;
} background: #FFFFFF;
.address > view { }
width: 560rpx;
} .address_item_info_name {
.address > image { margin: 0 16rpx 0 0;
width: 40rpx; }
height: 40rpx;
margin-top: 10rpx; .address_item_info_phone {
} margin: 4rpx 16rpx 0 0;
.name { }
font-size: 36rpx;
font-weight: 400; .address_item_info_tag {
margin-right: 12rpx; width: 60rpx;
} height: 32rpx;
.phone { margin: 4rpx 0 0 0;
font-size: 26rpx; border-radius: 2px;
font-weight: 400; background: #86C5E1;
margin-right: 12rpx; }
color: #A8A8AA;
} .address_item_info_address {
.tag { width: 534rpx;
font-size: 22rpx; margin: 16rpx 0 0 0;
font-weight: 400; }
padding: 2rpx 10rpx;
color: #FFFFFF; .address_item_info_address > text {
background-color: #88C5E0; display: block;
} line-height: 40rpx;
.address-text {
font-size: 26rpx;
font-weight: 400;
margin-top: 10rpx;
} }
.empty { .empty {
......
let App = getApp() let App = getApp()
Page({ Page({
/**
* 页面的初始数据
*/
data: { data: {
navTitle: '添加收货地址', // 导航标题 navTitle: '',
operate: 'add', // add:添加操作;edit: 修改操作;默认添加
addressInfo: {
imageBase: App.globalData.appImageBase, 'id': '',
name: '', 'name': '',
phone: '', 'phone': '',
region: ['福建省', '厦门市', '思明区'], 'area': ['广东省', '江门市', '新会区'],
address: '', // 详细地址 'address': '',
isDefault: true, // 是否默认地址 'isDefault': false,
'errorName': '',
nameError: false, 'errorPhone': '',
phoneError: false, 'errorArea': '',
addressError: false, 'errorAddress': '',
},
}, },
/**
* 生命周期函数--监听页面加载
* options 参数设置
* ① {param: "{"type":"edit","detail":{"area":"福建省,厦门市,思明区","add…6b8bfdd6531f7f306","showAddress":"福建省厦门市思明区001"}}"}
* ② {param: "{"type":"add"}"}
*/
onLoad: function (options) { onLoad: function (options) {
// 编辑地址判断其它情况为添加地址
if (options) {
let param = JSON.parse(options.param)
if (param.type === 'edit') {
this.setData({ this.setData({
navTitle: '编辑收货地址', navTitle: options.id ? '编辑收货地址' : '添加收货地址',
operate: 'edit', addressInfo: Object.assign(this.data.addressInfo, { id: options.id }),
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
}) })
} console.log(this.data.addressInfo)
} this.queryAddressList()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
}, },
/** /**
* 用户点击右上角分享 * 获取收货地址
*/ */
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 * @param {event} event
*/ */
onInputBlur: function (event) { onInputBlur: function (funcEvent) {
console.log(event.detail) let funcType = funcEvent.detail.id
let id = event.detail.id let funcValue = funcEvent.detail.value
let value = event.detail.value
if (id === 'name') { switch (funcType) {
case 'name':
this.setData({ this.setData({
name: value, addressInfo: Object.assign(this.data.addressInfo, {
nameError: (value.length == 0) name: funcValue,
errorName: App.modular.rule.item('name', funcValue)
}) })
} else if (id === 'phone') { })
break
case 'phone':
this.setData({ this.setData({
phone: value, addressInfo: Object.assign(this.data.addressInfo, {
phoneError: (value.length == 0) phone: funcValue,
errorPhone: App.modular.rule.item('phone', funcValue)
}) })
} else if (id === 'address') { })
break
case 'address':
this.setData({ this.setData({
address: value, addressInfo: Object.assign(this.data.addressInfo, {
addressError: (value.length == 0) 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 * @param {event} event
*/ */
onRegionChange: function (event) { onSelectionRegion: function (event) {
// console.log('picker发送选择改变,携带值为', event.detail.value)
this.setData({ this.setData({
region: event.detail.value addressInfo: Object.assign(this.data.addressInfo, { 'area': event.detail.value })
}) })
}, },
...@@ -136,10 +128,9 @@ Page({ ...@@ -136,10 +128,9 @@ Page({
* 设置是否为默认地址 * 设置是否为默认地址
* @param {event}} event * @param {event}} event
*/ */
onSwitchChange: function (event) { onSetDefaultAddress: function (event) {
// console.log(event.detail)
this.setData({ this.setData({
isDefault: event.detail.value addressInfo: Object.assign(this.data.addressInfo, { 'isDefault': event.detail.value })
}) })
}, },
...@@ -147,68 +138,47 @@ Page({ ...@@ -147,68 +138,47 @@ Page({
* 保存地址 * 保存地址
* @param {event} event * @param {event} event
*/ */
onSubmit: function (event) { onSaveAddress: function (event) {
if (!this.inspectForm()) return
if (this.data.name.length == 0 ||
this.data.phone.length == 0 || let funcParams = {
this.data.address.length == 0) { 'name': this.data.addressInfo.name,
this.setData({ 'mobile': this.data.addressInfo.phone,
nameError: (this.data.name.length == 0), 'area': this.data.addressInfo.area.join(','),
phoneError: (this.data.phone.length == 0), 'address': this.data.addressInfo.address,
addressError: (this.data.address.length == 0), 'defaultFlag': this.data.addressInfo.isDefault ? 1 : 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,
} }
if (this.data.operate === 'edit') { if (this.data.addressInfo.id) funcParams.id = this.data.addressInfo.id
param['id'] = this.data.id
}
App.ui.showToast({ App.ui.showToast({
'iconType': 'loading', 'iconType': 'loading',
'title': '提交中', 'title': '提交中',
'duration': 60000
}) })
App.request({ App.request({
url: 'v3/shippingAddress/saveAddress', url: 'v3/shippingAddress/saveAddress',
params: param params: funcParams
}).then((response) => { }).then((response) => {
console.log(response)
if (response.code == 200) {
App.ui.showToast({ App.ui.showToast({
iconType: 'success', iconType: 'success',
title: '提交成功', title: '提交成功',
duration: 2000 ending: () => {
})
setTimeout(() => {
wx.navigateBack() wx.navigateBack()
}, 2000) }
} else { })
}).catch((response) => {
App.ui.showToast({ App.ui.showToast({
iconType: 'error', iconType: 'error',
title: response.message, title: response.message,
duration: 2000
}) })
}
}) })
}, },
/** /**
* 删除地址 * 删除地址
* @param {event} event * @param {event} event
*/ */
onDelete: function (event) { onDeleteAddress: function (event) {
App.ui.showDialog({ App.ui.showDialog({
type: 'confirm', type: 'confirm',
title: '提示', title: '提示',
...@@ -219,27 +189,32 @@ Page({ ...@@ -219,27 +189,32 @@ Page({
App.ui.showToast({ App.ui.showToast({
'iconType': 'loading', 'iconType': 'loading',
'title': '处理中', 'title': '处理中',
'duration': 60000 'duration': 30000
}) })
App.wxRequest({ App.request({
url: 'v3/shippingAddress/del', url: 'v3/shippingAddress/del',
data: { params: {
'id': this.data.id, 'id': this.data.addressInfo.id,
}, }
success: (response) => { }).then((response) => {
App.ui.showToast({ App.ui.showToast({
iconType: 'success', iconType: 'success',
title: '删除成功', title: '删除成功',
duration: 2000 ending: () => {
wx.navigateBack()
}
}) })
setTimeout(() => { }).catch((response) => {
App.ui.showToast({
iconType: 'error',
title: response.message,
ending: () => {
wx.navigateBack() wx.navigateBack()
}, 2000)
} }
}) })
})
}, },
fail: () => {}, fail: () => {},
}) })
} }
}) })
\ No newline at end of file
...@@ -4,33 +4,45 @@ ...@@ -4,33 +4,45 @@
<view class="container"> <view class="container">
<view class="address_info"> <view class="address_info">
<view class="address_item bottom_line"> <view class="address_item">
<view class="row ac"> <view class="row ac">
<text class="title">收货人</text> <text class="title">收货人</text>
<m-input inputId="name" className="address_item_input row ac" value="{{name}}" placeholder="请输入" maxlength="20" <m-input
bindblur="onInputBlur"> inputId="name"
className="address_item_input row ac"
value="{{addressInfo.name}}"
placeholder="请输入"
maxlength="20"
bindblur="onInputBlur"
>
</m-input> </m-input>
</view> </view>
<text class="text_error" wx:if="{{nameError}}">请填写收货人</text> <text class="text_error" wx:if="{{addressInfo.errorName}}">请填写收货人</text>
</view> </view>
<view class="address_item bottom_line"> <view class="address_item">
<view class="row ac"> <view class="row ac">
<text class="title">手机号</text> <text class="title">手机号</text>
<m-input inputId="phone" className="address_item_input row ac" value="{{phone}}" placeholder="请输入" <m-input
maxlength="11" type="number" bindblur="onInputBlur"> inputId="phone"
className="address_item_input row ac"
value="{{addressInfo.phone}}"
placeholder="请输入"
maxlength="11"
type="number"
bindblur="onInputBlur"
>
</m-input> </m-input>
</view> </view>
<text class="text_error" wx:if="{{phoneError}}">请填写手机号</text> <text class="text_error" wx:if="{{addressInfo.errorPhone}}">请填写手机号</text>
</view> </view>
<view class="address_item row ac bottom_line"> <view class="address_item row ac">
<text class="title">所在地区</text> <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 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> <image class="icon_32" src="{{imageBase + 'icon/arrow-r-2.png'}}"></image>
</view> </view>
</picker> </picker>
...@@ -39,19 +51,27 @@ ...@@ -39,19 +51,27 @@
<view class="address_item"> <view class="address_item">
<view class="row ac"> <view class="row ac">
<text class="title">详细地址</text> <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> </view>
<text class="text_error" wx:if="{{addressError}}">请填写详细地址</text> <text class="text_error" wx:if="{{addressInfo.errorAddress}}">请填写详细地址</text>
</view> </view>
</view> </view>
<view class="address_info top30rpx"> <view class="address_info top30rpx">
<view class="address_item row ac cb"> <view class="address_item row ac cb">
<text class="title">设为默认地址</text> <text class="title">设为默认地址</text>
<switch checked="{{isDefault}}" bindchange="onSwitchChange"></switch> <switch checked="{{addressInfo.isDefault}}" bindchange="onSetDefaultAddress"></switch>
</view> </view>
</view> </view>
<button class="button row con-c align-c top40rpx" bindtap="onSubmit">保存</button> <button class="button row cc ac top40rpx" bindtap="onSaveAddress">保存</button>
<button wx:if="{{operate === 'edit'}}" class="button-delete row con-c align-c" bindtap="onDelete">删除收货地址</button> <button wx:if="{{addressInfo.id}}" class="button-delete row cc ac" bindtap="onDeleteAddress">删除收货地址</button>
</view> </view>
\ No newline at end of file
.container { .container {
min-height: 90vh; min-height: 90vh;
margin: 32rpx 0 0 0;
background-color: #F8F8FA; background-color: #F8F8FA;
} }
.bottom_line {
border-bottom: 1px #F8F8FA solid;
}
.top30rpx { .top30rpx {
margin-top: 30rpx; margin-top: 30rpx;
} }
...@@ -24,11 +21,17 @@ ...@@ -24,11 +21,17 @@
.address_item { .address_item {
width: 670rpx; width: 670rpx;
min-height: 90rpx; 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 { .title {
min-width: 150rpx; min-width: 160rpx;
font-size: 30rpx; font-size: 30rpx;
font-weight: 400; font-weight: 400;
color: #15191F; color: #15191F;
......
...@@ -2,3 +2,5 @@ ...@@ -2,3 +2,5 @@
// shopInfoBuffer: 门店详情信息 // shopInfoBuffer: 门店详情信息
// orderInfoBuffer: 订单信息缓存 // orderInfoBuffer: 订单信息缓存
// clubExamine: 我的俱乐部待审核数量 // clubExamine: 我的俱乐部待审核数量
// tempOptions: 页面跳转特殊参数临时缓存,用于页面退后,跳转主页等无法路径传参的场景。
\ No newline at end of file
/* SAMCSS-layout */ /* SAMCSS-layout */
page {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.container { .container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
flex-grow: 1;
} }
.row { .row {
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
.bgcolor_disable { background-color: #86C5E1; } .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_22 { font-size: 22rpx; font-weight: 400; line-height: 32rpx; }
.font_normal_26 { font-size: 26rpx; font-weight: 400; line-height: 36rpx; } .font_normal_26 { font-size: 26rpx; font-weight: 400; line-height: 36rpx; }
.font_normal_30 { font-size: 30rpx; font-weight: 400; line-height: 40rpx; } .font_normal_30 { font-size: 30rpx; font-weight: 400; line-height: 40rpx; }
...@@ -38,6 +39,7 @@ ...@@ -38,6 +39,7 @@
.font_normal_54 { font-size: 54rpx; font-weight: 400; line-height: 76rpx; } .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_22 { font-size: 22rpx; font-weight: 700; line-height: 32rpx; }
.font_bold_26 { font-size: 26rpx; font-weight: 700; line-height: 36rpx; } .font_bold_26 { font-size: 26rpx; font-weight: 700; line-height: 36rpx; }
.font_bold_30 { font-size: 30rpx; font-weight: 700; line-height: 40rpx; } .font_bold_30 { font-size: 30rpx; font-weight: 700; line-height: 40rpx; }
...@@ -48,6 +50,7 @@ ...@@ -48,6 +50,7 @@
.font_bold_54 { font-size: 54rpx; font-weight: 700; line-height: 76rpx; } .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_22 { font-size: 22rpx; font-weight: 900; line-height: 32rpx; }
.font_bolder_26 { font-size: 26rpx; font-weight: 900; line-height: 36rpx; } .font_bolder_26 { font-size: 26rpx; font-weight: 900; line-height: 36rpx; }
.font_bolder_30 { font-size: 30rpx; font-weight: 900; line-height: 40rpx; } .font_bolder_30 { font-size: 30rpx; font-weight: 900; line-height: 40rpx; }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment