Authored by yyq

fix

... ... @@ -6,7 +6,7 @@
</view>
<view class="edit-row">
<text class="left-cell">手机号码</text>
<input data-name="mobile" class="right-cell" placeholder="手机号码" maxlength="18" bindinput="onInputChanged" value="{{mobile}}"/>
<input type="number" data-name="mobile" class="right-cell" placeholder="手机号码" maxlength="18" bindinput="onInputChanged" value="{{mobile}}"/>
</view>
<view class="edit-row" bindtap="chooseArea">
<text class="left-cell">选择地区</text>
... ...
... ... @@ -11,12 +11,19 @@ let CACHE_AREA_LIST = {};
const yas = new Yas();
const validateAddress = function(data) {
let regx = {
const errorTip = {
consignee: '请输入正确的收件人姓名',
area_code: '请选择省市区',
mobile: '请输入正确的手机号',
address: '请输入详细的收件地址'
};
const regx = {
consignee: /^([\u4e00-\u9fa5\w*]{1,20})$/,
area_code: /^[0-9]{6,9}$/,
mobile: /^\d{3}(\d{4}|\*{4})\d{4,11}$/
},
pass = true;
};
let pass = true;
let errorType;
data = data || {};
... ... @@ -25,11 +32,21 @@ const validateAddress = function(data) {
regx[i] &&
!regx[i].test(data[i])) {
pass = false;
!errorType && (errorType = i);
}
}
if (data.hasOwnProperty('address') && !data.address) {
pass = false;
!errorType && (errorType = 'address');
}
if (!pass) {
wx.showToast({
title: errorTip[errorType] || '请输入正确的信息',
icon: 'none',
duration: 2000
});
}
return pass;
... ... @@ -80,7 +97,12 @@ Page({
loadAddrList() {
addressModel.addressList().then(res => {
if (res.code === 200) {
this.setData({addressList: res.data});
let list = res.data;
this.setData({
addressEmpty: !list || !list.length,
addressList: list
});
}
});
},
... ... @@ -272,8 +294,8 @@ Page({
is_default: address.is_default
}).then(result => {
if (!result || result.code !== 200) {
wx.showModal({
content: '保存失败,请稍后重试',
return wx.showModal({
content: result.message || '保存失败,请稍后重试',
confirmText: '好的',
showCancel: false
});
... ...
... ... @@ -4,6 +4,10 @@
<template is="addressEditer" data="{{...editAddrPageData, areaPicker, pickerProvice, pickerCity, pickerArea, areaValue}}"/>
</view>
<view wx:else class="container">
<view wx:if="{{addressEmpty}}" class="empty-address">
<image src="https://cdn.yoho.cn/yoho-brand-shop/assets/img/home/location.png" class="empty-img"></image>
<view>尚无地址,点击底部新增</view>
</view>
<view wx:for="{{addressList}}" wx:key="{{item.address_id}}" class="addr-item" data-key="{{index}}" bindtap="chooseAddr">
<view wx:if="{{item.address_id === selectedId}}" class="selected"><text class="iconfont icon-duihao"></text></view>
<view class="info">
... ... @@ -15,7 +19,7 @@
<block wx:if="{{item.is_default === 'Y'}}">
<text class="iconfont icon-round-checked left-icon"></text>
<text class="left-icon"> 默认地址</text>
</block>
</block>
<block wx:else>
<text class="iconfont icon-round left-icon" data-key="{{index}}" catchtap="setDefaultAddr"></text>
<text class="left-icon" data-key="{{index}}" catchtap="setDefaultAddr"> 设为默认</text>
... ...
... ... @@ -12,6 +12,18 @@ page {
padding-bottom: 100rpx;
}
.empty-address {
text-align: center;
padding-top: 240rpx;
}
.empty-address .empty-img {
width: 150rpx;
height: 150rpx;
display: block;
margin: 20rpx auto;
}
.addr-item {
background-color: #fff;
margin-bottom: 20rpx;
... ...
... ... @@ -9,7 +9,7 @@ const router = global.router;
Page({
data: {
scrollHeight: app.globalData.systemInfo.windowHeight - 80,
scrollHeight: app.globalData.systemInfo.windowHeight - 120,
currentId: null,
currentName: '',
categoryList: [],
... ... @@ -117,12 +117,10 @@ Page({
});
if (defaultCate) {
setTimeout(() => {
this.changeCategory({currentTarget: {dataset: {
id: defaultCate.category_id,
name: defaultCate.category_name
}}});
}, 100);
this.changeCategory({currentTarget: {dataset: {
id: defaultCate.category_id,
name: defaultCate.category_name
}}});
}
},
changeCategory(e) {
... ...
<wxs src="../../../wxs/helper.wxs" module="helper" />
<view wx:if="{{pageLoaded}}" class="container">
<view class="container">
<view wx:if="{{channelLength > 1}}" class="channel-list channel-list-{{channelLength}}">
<text wx:for="{{channelList}}" wx:key="{{item.id}}" class="channel-item {{currentChannel == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="changeChannel">{{item.name}}</text>
</view>
... ...
... ... @@ -119,6 +119,11 @@
bottom: 14rpx;
}
.category-wrap .more-item .item-name {
bottom: 50%;
margin-bottom: -10rpx
}
.hot-shops .shop-list {
padding-left: 30rpx;
}
... ...