首页地址选择
This commit is contained in:
parent
6013badb61
commit
952c42afdf
@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"pages": [
|
"pages": [
|
||||||
"pages/index/index",
|
"pages/index/index",
|
||||||
"pages/shop/show",
|
|
||||||
"pages/index/address",
|
"pages/index/address",
|
||||||
|
"pages/shop/show",
|
||||||
"pages/mine/mine",
|
"pages/mine/mine",
|
||||||
"pages/order/show",
|
"pages/order/show",
|
||||||
"pages/order/quasi",
|
"pages/order/quasi",
|
||||||
|
@ -1,51 +1,17 @@
|
|||||||
// pages/index/address.js
|
// pages/index/address.js
|
||||||
import {
|
import {
|
||||||
getCurrentAddressList,
|
getPrevPage,
|
||||||
|
getCurrentAddressList, setCurrentAddress,
|
||||||
searchAddressList,
|
searchAddressList,
|
||||||
splitByKeyword
|
splitByKeyword
|
||||||
} from '../../utils/util'
|
} from '../../utils/util'
|
||||||
import debounce from '../../utils/debounce'
|
import debounce from '../../utils/debounce'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var initReLocateLabel = '重新定位'
|
var initReLocateLabel = '重新定位'
|
||||||
Page({
|
Page({
|
||||||
data: {
|
data: {
|
||||||
reLocateLabel: initReLocateLabel,
|
reLocateLabel: initReLocateLabel,
|
||||||
addressList: [
|
addressList: [],
|
||||||
{
|
|
||||||
"addr_id": "170",
|
|
||||||
"user_id": "4",
|
|
||||||
"city_id": "330300",
|
|
||||||
"district_id": null,
|
|
||||||
"addr": "龙华大厦",
|
|
||||||
"detail": "",
|
|
||||||
"longitude": "120.69101",
|
|
||||||
"latitude": "28.002974",
|
|
||||||
"receiver": "test4",
|
|
||||||
"phone": "13000000005",
|
|
||||||
"create_time": "2017-02-20 10:38:11",
|
|
||||||
"delete": "0",
|
|
||||||
"district_name": "",
|
|
||||||
"city_name": "温州市"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"addr_id": "160",
|
|
||||||
"user_id": "4",
|
|
||||||
"city_id": "330300",
|
|
||||||
"district_id": null,
|
|
||||||
"addr": "电商大厦",
|
|
||||||
"detail": "",
|
|
||||||
"longitude": "120.737561",
|
|
||||||
"latitude": "27.979617",
|
|
||||||
"receiver": "test4",
|
|
||||||
"phone": "13000000004",
|
|
||||||
"create_time": "2016-12-16 13:37:10",
|
|
||||||
"delete": "0",
|
|
||||||
"district_name": "",
|
|
||||||
"city_name": "温州市"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
|
|
||||||
poiList: [],
|
poiList: [],
|
||||||
|
|
||||||
@ -55,6 +21,7 @@ Page({
|
|||||||
},
|
},
|
||||||
onLoad: function (options) {
|
onLoad: function (options) {
|
||||||
// 页面初始化 options为页面跳转所带来的参数
|
// 页面初始化 options为页面跳转所带来的参数
|
||||||
|
this.callback = options.cb || 'callback'
|
||||||
this.initPoiList()
|
this.initPoiList()
|
||||||
this.onSearchInput = debounce(this.onSearchInput, 300)
|
this.onSearchInput = debounce(this.onSearchInput, 300)
|
||||||
},
|
},
|
||||||
@ -88,8 +55,8 @@ Page({
|
|||||||
keyword: value,
|
keyword: value,
|
||||||
success(data) {
|
success(data) {
|
||||||
data = data.map(item => {
|
data = data.map(item => {
|
||||||
item['titleSplit'] = splitByKeyword(item.title, value)
|
item['titleSplit'] = splitByKeyword(item.title, value)
|
||||||
return item
|
return item
|
||||||
})
|
})
|
||||||
that.setData({
|
that.setData({
|
||||||
searchList: data
|
searchList: data
|
||||||
@ -105,7 +72,26 @@ Page({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
onSearchItemTap(e) {
|
onSearchItemTap(e) {
|
||||||
console.log(e)
|
var {id} = e.currentTarget
|
||||||
|
var {searchList} = this.data
|
||||||
|
var {
|
||||||
|
title, address, location,
|
||||||
|
city, district, adcode
|
||||||
|
} = searchList[id]
|
||||||
|
|
||||||
|
getPrevPage()[this.callback]({
|
||||||
|
location, title, address,
|
||||||
|
city, district,
|
||||||
|
district_id: adcode.toString(),
|
||||||
|
city_id: adcode.toString().replace(/\d{2}$/, '00')
|
||||||
|
})
|
||||||
|
wx.navigateBack()
|
||||||
|
},
|
||||||
|
onAddressItemTap(e) {
|
||||||
|
var {id} = e.currentTarget
|
||||||
|
var {poiList} = this.data
|
||||||
|
getPrevPage()[this.callback](poiList[id])
|
||||||
|
wx.navigateBack()
|
||||||
},
|
},
|
||||||
|
|
||||||
initPoiList() {
|
initPoiList() {
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view wx:else class="content">
|
<view wx:else class="content">
|
||||||
<view class="address-box">
|
<view wx:if="{{addressList && addressList.length > 0}}" class="address-box">
|
||||||
<view class="address-box__title">
|
<view class="address-box__title">
|
||||||
<image class="address-box__title-img" src="/images/takeout_ic_account.png"></image> 您的收货地址
|
<image class="address-box__title-img" src="/images/takeout_ic_account.png"></image> 您的收货地址
|
||||||
</view>
|
</view>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
<image class="address-box__title-img" src="/images/takeout_ic_address.png"></image> 定位地址
|
<image class="address-box__title-img" src="/images/takeout_ic_address.png"></image> 定位地址
|
||||||
</view>
|
</view>
|
||||||
<view class="address-list">
|
<view class="address-list">
|
||||||
<view wx:for="{{poiList}}" wx:key="{{index}}" class="address-item">
|
<view id="{{index}}" bindtap="onAddressItemTap" wx:for="{{poiList}}" wx:key="{{index}}" class="address-item">
|
||||||
<view class="address-item__addr">{{item.title}}</view>
|
<view class="address-item__addr">{{item.title}}</view>
|
||||||
<block wx:if="{{index == 0}}">
|
<block wx:if="{{index == 0}}">
|
||||||
<view class="grey-color text-small">
|
<view class="grey-color text-small">
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
//index.js
|
//index.js
|
||||||
//获取应用实例
|
//获取应用实例
|
||||||
import {
|
import {
|
||||||
getCurrentAddress
|
getCurrentAddress, setCurrentAddress
|
||||||
} from '../../utils/util'
|
} from '../../utils/util'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -62,7 +62,7 @@ Page({
|
|||||||
|
|
||||||
initAddress() {
|
initAddress() {
|
||||||
var that = this
|
var that = this
|
||||||
getCurrentAddress(function(address) {
|
getCurrentAddress(function (address) {
|
||||||
that.setData({
|
that.setData({
|
||||||
currentAddress: address
|
currentAddress: address
|
||||||
})
|
})
|
||||||
@ -102,9 +102,25 @@ Page({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
invalidateData() {
|
||||||
|
this.setData({
|
||||||
|
page: 0,
|
||||||
|
hasMore: true,
|
||||||
|
loading: false,
|
||||||
|
shopList: null
|
||||||
|
})
|
||||||
|
},
|
||||||
onReachBottom(e) {
|
onReachBottom(e) {
|
||||||
if (this.data.hasMore) {
|
if (this.data.hasMore) {
|
||||||
this.loadData()
|
this.loadData()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
callback(address) {
|
||||||
|
setCurrentAddress(address)
|
||||||
|
this.setData({
|
||||||
|
currentAddress: address
|
||||||
|
})
|
||||||
|
this.invalidateData()
|
||||||
|
this.loadData()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
|
|
||||||
<!--index.wxml-->
|
<!--index.wxml-->
|
||||||
<view class="topbar">
|
<view class="topbar">
|
||||||
<view class="address trangle">
|
<navigator url="./address?cb=callback" class="address trangle">
|
||||||
<image class="address__icon" src="/images/location.png"></image>{{currentAddress ? currentAddress.title : '定位中...'}}
|
<image class="address__icon" src="/images/location.png"></image>{{currentAddress ? currentAddress.title : '定位中...'}}
|
||||||
</view>
|
</navigator>
|
||||||
<view class="search">
|
<view class="search">
|
||||||
<icon type="search" size="20" /> 搜索
|
<icon type="search" size="20" /> 搜索
|
||||||
</view>
|
</view>
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
.address {
|
.address {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 3px 15px 3px 5px;
|
padding: 3px 15px 3px 5px;
|
||||||
min-width: 40%;
|
min-width: 100px;
|
||||||
max-width: 50%;
|
max-width: 50%;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
@ -161,7 +161,7 @@
|
|||||||
<image class="info__phone-icon" src="/images/chat_phone_normal.png"></image>
|
<image class="info__phone-icon" src="/images/chat_phone_normal.png"></image>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="weui-cell">
|
<view wx:if="{{info.notice}}" class="weui-cell">
|
||||||
<view class="weui-cell__hd weui-cell__hd_info">
|
<view class="weui-cell__hd weui-cell__hd_info">
|
||||||
商家公告
|
商家公告
|
||||||
</view>
|
</view>
|
||||||
|
@ -91,6 +91,10 @@ export function getCurrentAddress(callback) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setCurrentAddress(address) {
|
||||||
|
currentAddress = address
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 获取当前城市
|
// 获取当前城市
|
||||||
var cityName;
|
var cityName;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user