Authored by yyq

fix

@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 </view> 6 </view>
7 <view class="edit-row"> 7 <view class="edit-row">
8 <text class="left-cell">手机号码</text> 8 <text class="left-cell">手机号码</text>
9 - <input data-name="mobile" class="right-cell" placeholder="手机号码" maxlength="18" bindinput="onInputChanged" value="{{mobile}}"/> 9 + <input type="number" data-name="mobile" class="right-cell" placeholder="手机号码" maxlength="18" bindinput="onInputChanged" value="{{mobile}}"/>
10 </view> 10 </view>
11 <view class="edit-row" bindtap="chooseArea"> 11 <view class="edit-row" bindtap="chooseArea">
12 <text class="left-cell">选择地区</text> 12 <text class="left-cell">选择地区</text>
@@ -11,12 +11,19 @@ let CACHE_AREA_LIST = {}; @@ -11,12 +11,19 @@ let CACHE_AREA_LIST = {};
11 const yas = new Yas(); 11 const yas = new Yas();
12 12
13 const validateAddress = function(data) { 13 const validateAddress = function(data) {
14 - let regx = { 14 + const errorTip = {
  15 + consignee: '请输入正确的收件人姓名',
  16 + area_code: '请选择省市区',
  17 + mobile: '请输入正确的手机号',
  18 + address: '请输入详细的收件地址'
  19 + };
  20 + const regx = {
15 consignee: /^([\u4e00-\u9fa5\w*]{1,20})$/, 21 consignee: /^([\u4e00-\u9fa5\w*]{1,20})$/,
16 area_code: /^[0-9]{6,9}$/, 22 area_code: /^[0-9]{6,9}$/,
17 mobile: /^\d{3}(\d{4}|\*{4})\d{4,11}$/ 23 mobile: /^\d{3}(\d{4}|\*{4})\d{4,11}$/
18 - },  
19 - pass = true; 24 + };
  25 + let pass = true;
  26 + let errorType;
20 27
21 data = data || {}; 28 data = data || {};
22 29
@@ -25,11 +32,21 @@ const validateAddress = function(data) { @@ -25,11 +32,21 @@ const validateAddress = function(data) {
25 regx[i] && 32 regx[i] &&
26 !regx[i].test(data[i])) { 33 !regx[i].test(data[i])) {
27 pass = false; 34 pass = false;
  35 + !errorType && (errorType = i);
28 } 36 }
29 } 37 }
30 38
31 if (data.hasOwnProperty('address') && !data.address) { 39 if (data.hasOwnProperty('address') && !data.address) {
32 pass = false; 40 pass = false;
  41 + !errorType && (errorType = 'address');
  42 + }
  43 +
  44 + if (!pass) {
  45 + wx.showToast({
  46 + title: errorTip[errorType] || '请输入正确的信息',
  47 + icon: 'none',
  48 + duration: 2000
  49 + });
33 } 50 }
34 51
35 return pass; 52 return pass;
@@ -80,7 +97,12 @@ Page({ @@ -80,7 +97,12 @@ Page({
80 loadAddrList() { 97 loadAddrList() {
81 addressModel.addressList().then(res => { 98 addressModel.addressList().then(res => {
82 if (res.code === 200) { 99 if (res.code === 200) {
83 - this.setData({addressList: res.data}); 100 + let list = res.data;
  101 +
  102 + this.setData({
  103 + addressEmpty: !list || !list.length,
  104 + addressList: list
  105 + });
84 } 106 }
85 }); 107 });
86 }, 108 },
@@ -272,8 +294,8 @@ Page({ @@ -272,8 +294,8 @@ Page({
272 is_default: address.is_default 294 is_default: address.is_default
273 }).then(result => { 295 }).then(result => {
274 if (!result || result.code !== 200) { 296 if (!result || result.code !== 200) {
275 - wx.showModal({  
276 - content: '保存失败,请稍后重试', 297 + return wx.showModal({
  298 + content: result.message || '保存失败,请稍后重试',
277 confirmText: '好的', 299 confirmText: '好的',
278 showCancel: false 300 showCancel: false
279 }); 301 });
@@ -4,6 +4,10 @@ @@ -4,6 +4,10 @@
4 <template is="addressEditer" data="{{...editAddrPageData, areaPicker, pickerProvice, pickerCity, pickerArea, areaValue}}"/> 4 <template is="addressEditer" data="{{...editAddrPageData, areaPicker, pickerProvice, pickerCity, pickerArea, areaValue}}"/>
5 </view> 5 </view>
6 <view wx:else class="container"> 6 <view wx:else class="container">
  7 + <view wx:if="{{addressEmpty}}" class="empty-address">
  8 + <image src="https://cdn.yoho.cn/yoho-brand-shop/assets/img/home/location.png" class="empty-img"></image>
  9 + <view>尚无地址,点击底部新增</view>
  10 + </view>
7 <view wx:for="{{addressList}}" wx:key="{{item.address_id}}" class="addr-item" data-key="{{index}}" bindtap="chooseAddr"> 11 <view wx:for="{{addressList}}" wx:key="{{item.address_id}}" class="addr-item" data-key="{{index}}" bindtap="chooseAddr">
8 <view wx:if="{{item.address_id === selectedId}}" class="selected"><text class="iconfont icon-duihao"></text></view> 12 <view wx:if="{{item.address_id === selectedId}}" class="selected"><text class="iconfont icon-duihao"></text></view>
9 <view class="info"> 13 <view class="info">
@@ -15,7 +19,7 @@ @@ -15,7 +19,7 @@
15 <block wx:if="{{item.is_default === 'Y'}}"> 19 <block wx:if="{{item.is_default === 'Y'}}">
16 <text class="iconfont icon-round-checked left-icon"></text> 20 <text class="iconfont icon-round-checked left-icon"></text>
17 <text class="left-icon"> 默认地址</text> 21 <text class="left-icon"> 默认地址</text>
18 - </block> 22 + </block>
19 <block wx:else> 23 <block wx:else>
20 <text class="iconfont icon-round left-icon" data-key="{{index}}" catchtap="setDefaultAddr"></text> 24 <text class="iconfont icon-round left-icon" data-key="{{index}}" catchtap="setDefaultAddr"></text>
21 <text class="left-icon" data-key="{{index}}" catchtap="setDefaultAddr"> 设为默认</text> 25 <text class="left-icon" data-key="{{index}}" catchtap="setDefaultAddr"> 设为默认</text>
@@ -12,6 +12,18 @@ page { @@ -12,6 +12,18 @@ page {
12 padding-bottom: 100rpx; 12 padding-bottom: 100rpx;
13 } 13 }
14 14
  15 +.empty-address {
  16 + text-align: center;
  17 + padding-top: 240rpx;
  18 +}
  19 +
  20 +.empty-address .empty-img {
  21 + width: 150rpx;
  22 + height: 150rpx;
  23 + display: block;
  24 + margin: 20rpx auto;
  25 +}
  26 +
15 .addr-item { 27 .addr-item {
16 background-color: #fff; 28 background-color: #fff;
17 margin-bottom: 20rpx; 29 margin-bottom: 20rpx;
@@ -9,7 +9,7 @@ const router = global.router; @@ -9,7 +9,7 @@ const router = global.router;
9 9
10 Page({ 10 Page({
11 data: { 11 data: {
12 - scrollHeight: app.globalData.systemInfo.windowHeight - 80, 12 + scrollHeight: app.globalData.systemInfo.windowHeight - 120,
13 currentId: null, 13 currentId: null,
14 currentName: '', 14 currentName: '',
15 categoryList: [], 15 categoryList: [],
@@ -117,12 +117,10 @@ Page({ @@ -117,12 +117,10 @@ Page({
117 }); 117 });
118 118
119 if (defaultCate) { 119 if (defaultCate) {
120 - setTimeout(() => {  
121 - this.changeCategory({currentTarget: {dataset: {  
122 - id: defaultCate.category_id,  
123 - name: defaultCate.category_name  
124 - }}});  
125 - }, 100); 120 + this.changeCategory({currentTarget: {dataset: {
  121 + id: defaultCate.category_id,
  122 + name: defaultCate.category_name
  123 + }}});
126 } 124 }
127 }, 125 },
128 changeCategory(e) { 126 changeCategory(e) {
1 <wxs src="../../../wxs/helper.wxs" module="helper" /> 1 <wxs src="../../../wxs/helper.wxs" module="helper" />
2 2
3 -<view wx:if="{{pageLoaded}}" class="container"> 3 +<view class="container">
4 <view wx:if="{{channelLength > 1}}" class="channel-list channel-list-{{channelLength}}"> 4 <view wx:if="{{channelLength > 1}}" class="channel-list channel-list-{{channelLength}}">
5 <text wx:for="{{channelList}}" wx:key="{{item.id}}" class="channel-item {{currentChannel == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="changeChannel">{{item.name}}</text> 5 <text wx:for="{{channelList}}" wx:key="{{item.id}}" class="channel-item {{currentChannel == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="changeChannel">{{item.name}}</text>
6 </view> 6 </view>
@@ -119,6 +119,11 @@ @@ -119,6 +119,11 @@
119 bottom: 14rpx; 119 bottom: 14rpx;
120 } 120 }
121 121
  122 +.category-wrap .more-item .item-name {
  123 + bottom: 50%;
  124 + margin-bottom: -10rpx
  125 +}
  126 +
122 .hot-shops .shop-list { 127 .hot-shops .shop-list {
123 padding-left: 30rpx; 128 padding-left: 30rpx;
124 } 129 }