Skip to content

Commit

Permalink
收获地址系列页面修正
Browse files Browse the repository at this point in the history
* 修复从获取微信收获地址的省、市、区不正确的问题。
* 修复从微信获取收获地址报解析错误的问题。
  • Loading branch information
exsystem committed Jan 12, 2023
1 parent 08bb403 commit 81519b6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
5 changes: 5 additions & 0 deletions pages/usercenter/address/edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ Page({
verifyTips: '',
},
onLoad(options) {
const eventChannel = this.getOpenerEventChannel();
const self = this;
eventChannel.on('onWeixinAddressPassed', function (params) {
self.getWeixinAddress({ detail: params });
});
const { id } = options;
this.init(id);
},
Expand Down
4 changes: 3 additions & 1 deletion pages/usercenter/address/list/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@
title="微信地址导入"
isOrderSure="{{isOrderSure}}"
isDisabledBtn="{{addressList.length >= 20}}"
navigator="{{true}}"
navigateUrl="/pages/usercenter/address/edit/index"
navigateEvent="onWeixinAddressPassed"
t-class="location-btn"
isCustomStyle="{{true}}"
bind:navigate="waitForNewAddress"
/>
<view class="address-btn {{addressList.length >= 20 ? 'btn-default':''}}" bind:tap="createHandle">
<t-icon
Expand Down
26 changes: 17 additions & 9 deletions pages/usercenter/components/t-location/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ Component({
title: {
type: String,
},
navigator: {
type: Boolean,
navigateUrl: {
type: String,
},
navigateEvent: {
type: String,
},
isCustomStyle: {
type: Boolean,
Expand All @@ -35,7 +38,7 @@ Component({
const {
provinceName,
cityName,
countryName,
countyName,
detailInfo,
userName,
telNumber,
Expand All @@ -58,16 +61,14 @@ Component({
detailAddress: detailInfo,
provinceName: provinceName,
cityName: cityName,
districtName: countryName,
districtName: countyName,
isDefault: false,
isOrderSure: this.properties.isOrderSure,
};

addressParse(provinceName, cityName, countryName);

try {
const { provinceCode, cityCode, districtCode } =
await addressParse(provinceName, cityName, countryName);
await addressParse(provinceName, cityName, countyName);

const params = Object.assign(target, {
provinceCode,
Expand All @@ -76,8 +77,15 @@ Component({
});
if (this.properties.isOrderSure) {
this.onHandleSubmit(params);
} else if (this.properties.navigator) {
Navigator.gotoPage('/address-detail', params);
} else if (this.properties.navigateUrl != '') {
const { navigateEvent } = this.properties;
this.triggerEvent('navigate');
wx.navigateTo({
url: this.properties.navigateUrl,
success: function (res) {
res.eventChannel.emit(navigateEvent, params);
}
});
} else {
this.triggerEvent('change', params);
}
Expand Down

0 comments on commit 81519b6

Please sign in to comment.