Commit 1128c163 by 严立

LL - 我的地址优化

parent 13035af7
......@@ -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
}
......
......@@ -40,7 +40,7 @@ let styleOption = [
// 9 - pages/campsite/home/home
'normal': { titleColor: '#f6dada;', bgColor: 'rgba(246, 218, 218, 0);', iconBack: '', iconHome: '', logo: '', logoSize: { width: '', height: '' } },
'scroll': { titleColor: '#000000;', bgColor: 'rgba(246, 218, 218, 1);', iconBack: '', iconHome: '', logo: '', logoSize: { width: '', height: '' } }
},
},
]
let output = function () {
......
......@@ -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,
......
......@@ -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
......
......@@ -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.priceTotal + ' 积分'}}</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.priceTotal + ' 积分'}}</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.priceTotal + ' 积分'}}</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.priceTotal + ' 积分'}}</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
.container {
width: 750rpx;
min-height: 100vh;
padding: 0 40rpx 120rpx 40rpx;
}
......@@ -71,4 +70,20 @@
font-weight: 500;
line-height: 32rpx;
color: #FFFFFF;
}
\ No newline at end of file
}
.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({
// 兑换商品数据
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: funcIntegralTotal,
integralTotal: funcData.totalMoney,
isExpress: Boolean(Number(funcData.expressType)),
isViewDataReady: true,
})
......
......@@ -37,7 +37,14 @@ Page({
},
onShow: function () {
this.queryUserAddress()
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,
'default': Boolean(Number(funcData[i].defaultFlag)),
'isDefault': Boolean(Number(funcData[i].defaultFlag)),
}
funcList.push(funcItem)
// 设置默认地址
if (funcItem.default) {
// 当前没有选择地址,自动选择默认地址。
if (Object.keys(this.data.addressSelection).length === 0 && funcItem.isDefault) {
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 () {
......
......@@ -25,9 +25,12 @@
</view>
<view class="goods_info_other row cb ac">
<view class="row ac">
<text class="goods_info_price">{{goodsInfo.price}}</text>
<text class="goods_info_unit">积分</text>
<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>
......
.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 {
......
let App = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
imageBase: App.globalData.appImageBase,
addressList:[],
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getAddressList()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
/**
* 地址编辑操作
* @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),
})
},
/**
* 地址添加操作
* @function
* @param {object} - funcEvent
* @returns
*/
onAddressAdd: function (event) {
let param = {
type: "add",
}
wx.navigateTo({
url: '../address-operate/address-operate?param='+JSON.stringify(param),
})
},
/**
* 获取收货地址
*/
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
data: {
options: {},
addressList:[],
},
onLoad: function (options) {
this.setData({
options: options
})
that.setData({
addressList: response.data
},
onShow: function () {
this.getAddressList()
},
/**
* 设置当前收货地址,仅从积分兑换下单页面进入有效
* @function
* @param {object} - funcEvent
* @returns
*/
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 (funcEvent) {
let funcItem = funcEvent.currentTarget.dataset.item
wx.navigateTo({ url: '../address-operate/address-operate?id=' + funcItem.id })
},
/**
* 地址添加操作
* @function
* @param {object} - funcEvent
* @returns
*/
onAddressAdd: function (event) {
let param = {
type: "add",
}
wx.navigateTo({
url: '../address-operate/address-operate?param='+JSON.stringify(param),
})
} else {
App.ui.showToast({
iconType: 'error',
title: response.message,
duration: 3000
},
/**
* 获取收货地址
*/
getAddressList: function () {
App.request({
url: 'v3/shippingAddress/getAddressList',
}).then((response) => {
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',
title: response.message,
duration: 3000
})
})
}
}).catch((response) => {
App.ui.showToast({
iconType: 'error',
title: response.message,
duration: 3000
})
})
}
}
})
\ No newline at end of file
......@@ -2,29 +2,29 @@
<m-nav titleText="收货地址"></m-nav>
<view class="container">
<view class="address_list" wx:if="{{addressList.length > 0}}">
<block wx:for="{{addressList}}" wx:key="index">
<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 class="icon_32" src="{{imageBase + 'icon/edit-1.png'}}" data-item="{{item}}" catchtap="onAddressEdit"></image>
</view>
</block>
</view>
<view class="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>
</view>
<image src="{{imageBase + 'icon/edit-1.png'}}" bindtap="onAddressEdit" data-index="{{index}}"></image>
</view>
</block>
</view>
<view class="empty" wx:else>
<text >暂无收货地址</text>
</view>
<view class="empty" wx:else>
<text>暂无收货地址</text>
</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 {
min-height: 85vh;
background-color: #F8F8FA;
}
.list {
width: 750rpx;
height: 100%;
}
.address {
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;
page {
background: #F8F8FA;
}
.empty {
height: 80vh;
padding-top: 35vh;
color: #999CA2;
.address_list {
width: 750rpx;
height: 100%;
padding: 0 40rpx;
}
.address_item {
width: 670rpx;
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 {
height: 80vh;
padding-top: 35vh;
color: #999CA2;
}
\ No newline at end of file
......@@ -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="{{addressError}}">请填写详细地址</text>
<text class="text_error" wx:if="{{addressInfo.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 con-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 cc 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
.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: 150rpx;
min-width: 160rpx;
font-size: 30rpx;
font-weight: 400;
color: #15191F;
......
// 程序缓存关键字说明
// shopInfoBuffer: 门店详情信息
// orderInfoBuffer: 订单信息缓存
// clubExamine: 我的俱乐部待审核数量
\ No newline at end of file
// clubExamine: 我的俱乐部待审核数量
// tempOptions: 页面跳转特殊参数临时缓存,用于页面退后,跳转主页等无法路径传参的场景。
\ No newline at end of file
/* SAMCSS-layout */
page {
display: flex;
flex-direction: column;
min-height: 100vh;
}
.container {
display: flex;
flex-direction: column;
align-items: center;
flex-grow: 1;
}
.row {
......
......@@ -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; }
......
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