获取当前地址
This commit is contained in:
parent
323555e509
commit
6013badb61
@ -2,9 +2,6 @@
|
||||
App({
|
||||
onLaunch: function () {
|
||||
//调用API从本地缓存中获取数据
|
||||
var logs = wx.getStorageSync('logs') || []
|
||||
logs.unshift(Date.now())
|
||||
wx.setStorageSync('logs', logs)
|
||||
},
|
||||
getUserInfo:function(cb){
|
||||
var that = this
|
||||
|
@ -1,15 +1,15 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/mine/mine",
|
||||
"pages/shop/show",
|
||||
"pages/index/index",
|
||||
"pages/shop/show",
|
||||
"pages/index/address",
|
||||
"pages/mine/mine",
|
||||
"pages/order/show",
|
||||
"pages/order/quasi",
|
||||
"pages/order/list",
|
||||
"pages/address/list",
|
||||
"pages/address/add",
|
||||
"pages/address/select",
|
||||
"pages/index/address",
|
||||
"pages/shop/category",
|
||||
"pages/shop/search"
|
||||
],
|
||||
|
12
app/app.wxss
12
app/app.wxss
@ -42,18 +42,6 @@ page {
|
||||
|
||||
button[type=primary], .weui-btn_primary {
|
||||
position: relative;
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
padding-left: 14px;
|
||||
padding-right: 14px;
|
||||
box-sizing: border-box;
|
||||
font-size: 18px;
|
||||
text-align: center;
|
||||
text-decoration: none;
|
||||
line-height: 2.55555556;
|
||||
border-radius: 5px;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
color: #fff;
|
||||
background-color: #ff5801;
|
||||
}
|
||||
|
BIN
app/images/location-arrow.png
Normal file
BIN
app/images/location-arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 768 B After Width: | Height: | Size: 1.7 KiB |
@ -1,19 +1,125 @@
|
||||
// pages/index/address.js
|
||||
import {
|
||||
getCurrentAddressList,
|
||||
searchAddressList,
|
||||
splitByKeyword
|
||||
} from '../../utils/util'
|
||||
import debounce from '../../utils/debounce'
|
||||
|
||||
|
||||
|
||||
var initReLocateLabel = '重新定位'
|
||||
Page({
|
||||
data:{},
|
||||
onLoad:function(options){
|
||||
// 页面初始化 options为页面跳转所带来的参数
|
||||
data: {
|
||||
reLocateLabel: initReLocateLabel,
|
||||
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: [],
|
||||
|
||||
showSearchList: false,
|
||||
searchKey: '',
|
||||
searchList: []
|
||||
},
|
||||
onReady:function(){
|
||||
onLoad: function (options) {
|
||||
// 页面初始化 options为页面跳转所带来的参数
|
||||
this.initPoiList()
|
||||
this.onSearchInput = debounce(this.onSearchInput, 300)
|
||||
},
|
||||
onReady: function () {
|
||||
// 页面渲染完成
|
||||
},
|
||||
onShow:function(){
|
||||
onShow: function () {
|
||||
// 页面显示
|
||||
},
|
||||
onHide:function(){
|
||||
onHide: function () {
|
||||
// 页面隐藏
|
||||
},
|
||||
onUnload:function(){
|
||||
onUnload: function () {
|
||||
// 页面关闭
|
||||
},
|
||||
|
||||
reLocate(e) {
|
||||
this.initPoiList()
|
||||
},
|
||||
|
||||
onSearchInput(e) {
|
||||
var that = this
|
||||
var {value} = e.detail
|
||||
this.setData({
|
||||
searchKey: value,
|
||||
showSearchList: !!value
|
||||
})
|
||||
|
||||
if (value) {
|
||||
searchAddressList({
|
||||
keyword: value,
|
||||
success(data) {
|
||||
data = data.map(item => {
|
||||
item['titleSplit'] = splitByKeyword(item.title, value)
|
||||
return item
|
||||
})
|
||||
that.setData({
|
||||
searchList: data
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
clearSearchKey(e) {
|
||||
this.setData({
|
||||
searchKey: '',
|
||||
showSearchList: false
|
||||
})
|
||||
},
|
||||
onSearchItemTap(e) {
|
||||
console.log(e)
|
||||
},
|
||||
|
||||
initPoiList() {
|
||||
var that = this
|
||||
this.setData({
|
||||
reLocateLabel: '定位中...'
|
||||
})
|
||||
getCurrentAddressList({
|
||||
success(addressList) {
|
||||
that.setData({
|
||||
poiList: addressList,
|
||||
reLocateLabel: initReLocateLabel
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
@ -1,2 +1,55 @@
|
||||
|
||||
<!--pages/index/address.wxml-->
|
||||
<text>pages/index/address.wxml</text>
|
||||
<view class="container">
|
||||
<view class="search-box">
|
||||
<view class="search-box__input-wrap">
|
||||
<icon bindtap="clearSearchKey" wx:if="{{searchKey}}" type="clear" class="search-box__input-clear" />
|
||||
<input bindinput="onSearchInput" value="{{searchKey}}" class="search-box__input" placeholder="请输入您的收货地址" />
|
||||
</view>
|
||||
<button class="weui-btn mini-btn weui-btn_search" type="primary" size="mini">搜索</button>
|
||||
</view>
|
||||
<view wx:if="{{showSearchList}}" class="content">
|
||||
<view class="search-list">
|
||||
<view bindtap="onSearchItemTap" id="{{index}}" wx:for="{{searchList}}" wx:key="{{index}}" class="search-item">
|
||||
<view class="search-item__name">
|
||||
<text class="{{item.isKeyword ? 'primary-color': ''}}" wx:for="{{item.titleSplit}}" wx:key="{{index}}">{{item.text}}</text>
|
||||
</view>
|
||||
<view class="search-item__address">{{item.address}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:else class="content">
|
||||
<view class="address-box">
|
||||
<view class="address-box__title">
|
||||
<image class="address-box__title-img" src="/images/takeout_ic_account.png"></image> 您的收货地址
|
||||
</view>
|
||||
<view class="address-list">
|
||||
<view wx:for="{{addressList}}" wx:key="addr_id" class="address-item">
|
||||
<view class="address-item__addr">{{item.addr}}</view>
|
||||
<view class="address-item__name grey-color text-small">
|
||||
{{item.receiver}} {{item.phone}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="address-box">
|
||||
<view class="address-box__title">
|
||||
<image class="address-box__title-img" src="/images/takeout_ic_address.png"></image> 定位地址
|
||||
</view>
|
||||
<view class="address-list">
|
||||
<view wx:for="{{poiList}}" wx:key="{{index}}" class="address-item">
|
||||
<view class="address-item__addr">{{item.title}}</view>
|
||||
<block wx:if="{{index == 0}}">
|
||||
<view class="grey-color text-small">
|
||||
当前定位地址
|
||||
</view>
|
||||
<view bindtap="reLocate" class="re-locate">
|
||||
<image class="re-locate__img" src="/images/location-arrow.png"></image>
|
||||
<view class="primary-color text-small">{{reLocateLabel}}</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
@ -1 +1,94 @@
|
||||
/* pages/index/address.wxss */
|
||||
/* pages/index/address.wxss */
|
||||
page {
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.content {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 10px;
|
||||
border-bottom: 1rpx solid #e8e8e8;
|
||||
}
|
||||
|
||||
.search-box__input-wrap {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
padding-right: 40px;
|
||||
}
|
||||
|
||||
.search-box__input-clear {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
right: 10px;
|
||||
transform: translateY(-50%);
|
||||
}
|
||||
|
||||
.weui-btn_search {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/*address-box*/
|
||||
.address-box {
|
||||
margin-top: 15px;
|
||||
}
|
||||
.address-box__title {
|
||||
padding: 5px 10px;
|
||||
font-size: 14px;
|
||||
color: #999;
|
||||
}
|
||||
.address-box__title-img {
|
||||
margin-top: -2px;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.address-list {
|
||||
margin-left: 30px;
|
||||
}
|
||||
|
||||
.address-item {
|
||||
position: relative;
|
||||
padding: 10px 0;
|
||||
border-bottom: 1rpx solid #e8e8e8;
|
||||
}
|
||||
|
||||
.re-locate {
|
||||
position: absolute;
|
||||
right: 10px;
|
||||
top: 10px;
|
||||
min-width: 5em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.re-locate__img {
|
||||
height: 15px;
|
||||
width: 15px;
|
||||
}
|
||||
|
||||
/* search-list */
|
||||
.search-list {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.search-item {
|
||||
padding: 10px 0 10px 0;
|
||||
border-bottom: 1rpx solid #e8e8e8;
|
||||
}
|
||||
|
||||
|
||||
.search-item__address {
|
||||
font-size: 0.8em;
|
||||
color: #999;
|
||||
}
|
@ -1,6 +1,13 @@
|
||||
//index.js
|
||||
//获取应用实例
|
||||
var app = getApp()
|
||||
import {
|
||||
getCurrentAddress
|
||||
} from '../../utils/util'
|
||||
|
||||
import {
|
||||
getSellers
|
||||
} from '../../utils/apis'
|
||||
|
||||
Page({
|
||||
data: {
|
||||
category: [
|
||||
@ -45,81 +52,59 @@ Page({
|
||||
"icon": "/images/category/8.png"
|
||||
}
|
||||
],
|
||||
shop: [
|
||||
{
|
||||
"seller_id": "2",
|
||||
"seller_name": "鲜极道",
|
||||
"state": "1",
|
||||
"city_id": "330300",
|
||||
"address": "温州龙湾区衢江路2011号",
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller/20170314/1489479032148947903230424.png",
|
||||
"pic_hd": "http://mtest.ipaotui.com/Uploadfile/Img/seller/20170314/hd_1489479032148947903230424.png",
|
||||
"longitude": "120.748973",
|
||||
"latitude": "27.984401",
|
||||
"phone": "88888888",
|
||||
"start_sell_time": "08:00:00",
|
||||
"end_sell_time": "09:00:00",
|
||||
"sell_time": "08:00-20:00,08:00-20:00",
|
||||
"is_rest": "0",
|
||||
"notice": "东池便当,好吃西",
|
||||
"reach_time": "30",
|
||||
"reserve_day": "0",
|
||||
"min_price": "5",
|
||||
"sales": "73",
|
||||
"service": "0.0",
|
||||
"quality": "0.0",
|
||||
"overall": "0.0",
|
||||
"distance": "11",
|
||||
"favorite": "0",
|
||||
"promotion": [
|
||||
{
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_promotion/first_cut.png",
|
||||
"info": "新用户在线支付满15元减10元,满20元减13元"
|
||||
},
|
||||
{
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_promotion/cut.png",
|
||||
"info": "在线支付满15元减5元,满20元减8元"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"seller_id": "24",
|
||||
"seller_name": "测试",
|
||||
"state": "1",
|
||||
"city_id": "330300",
|
||||
"address": "skldfjhkls",
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller/1468462647146846264750782.jpg",
|
||||
"pic_hd": "http://mtest.ipaotui.com/Uploadfile/Img/seller/hd_1468462647146846264750782.jpg",
|
||||
"longitude": "120.70507",
|
||||
"latitude": "28.003041",
|
||||
"phone": "13900000000",
|
||||
"start_sell_time": "08:00:00",
|
||||
"end_sell_time": "22:00:00",
|
||||
"sell_time": "08:00-22:00",
|
||||
"is_rest": "0",
|
||||
"notice": null,
|
||||
"reach_time": "30",
|
||||
"reserve_day": "0",
|
||||
"min_price": "5",
|
||||
"sales": "0",
|
||||
"service": "0.0",
|
||||
"quality": "0.0",
|
||||
"overall": "0.0",
|
||||
"distance": "4784",
|
||||
"favorite": "0",
|
||||
"promotion": []
|
||||
},
|
||||
]
|
||||
page: 0,
|
||||
hasMore: true,
|
||||
loading: false
|
||||
},
|
||||
onLoad: function () {
|
||||
console.log('onLoad')
|
||||
this.initAddress()
|
||||
},
|
||||
|
||||
initAddress() {
|
||||
var that = this
|
||||
//调用应用实例的方法获取全局数据
|
||||
app.getUserInfo(function (userInfo) {
|
||||
//更新数据
|
||||
getCurrentAddress(function(address) {
|
||||
that.setData({
|
||||
userInfo: userInfo
|
||||
currentAddress: address
|
||||
})
|
||||
that.loadData()
|
||||
})
|
||||
}
|
||||
},
|
||||
loadData() {
|
||||
if (this.data.loading) {
|
||||
return;
|
||||
}
|
||||
var that = this
|
||||
var {
|
||||
page, currentAddress,
|
||||
} = this.data
|
||||
|
||||
this.setData({
|
||||
loading: true
|
||||
})
|
||||
getSellers({
|
||||
page,
|
||||
address: currentAddress,
|
||||
success(data) {
|
||||
var {
|
||||
shopList
|
||||
} = that.data
|
||||
|
||||
var list = data.list.map(item => {
|
||||
item['distanceFormat'] = (item.distance / 1000).toFixed(2)
|
||||
return item
|
||||
})
|
||||
that.setData({
|
||||
shopList: shopList ? shopList.concat(list) : list,
|
||||
page: page + 1,
|
||||
hasMore: data.count == 10,
|
||||
loading: false
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
onReachBottom(e) {
|
||||
if (this.data.hasMore) {
|
||||
this.loadData()
|
||||
}
|
||||
},
|
||||
})
|
||||
|
@ -1,10 +1,10 @@
|
||||
<import src="/templates/star-rate.wxml" />
|
||||
<import src="/templates/load-more.wxml" />
|
||||
|
||||
<!--index.wxml-->
|
||||
<view class="topbar">
|
||||
<view class="address trangle">
|
||||
<image class="address__icon" src="/images/location.png"></image>
|
||||
电商大厦电商大厦(兴区路)
|
||||
<image class="address__icon" src="/images/location.png"></image>{{currentAddress ? currentAddress.title : '定位中...'}}
|
||||
</view>
|
||||
<view class="search">
|
||||
<icon type="search" size="20" /> 搜索
|
||||
@ -19,9 +19,8 @@
|
||||
</navigator>
|
||||
</view>
|
||||
<view class="weui-panel weui-panel_access">
|
||||
<view class="weui-panel__hd">推荐商家</view>
|
||||
<view class="weui-panel__bd shop__list">
|
||||
<navigator url="" wx:for="{{shop}}" wx:key="{{seller_id}}" class="weui-media-box weui-media-box_appmsg shop__item" hover-class="weui-cell_active">
|
||||
<navigator url="/pages/shop/show?id={{item.seller_id}}" wx:for="{{shopList}}" wx:key="{{seller_id}}" class="weui-media-box weui-media-box_appmsg shop__item" hover-class="weui-cell_active">
|
||||
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
|
||||
<image class="weui-media-box__thumb" src="{{item.pic_url}}" />
|
||||
</view>
|
||||
@ -39,7 +38,7 @@
|
||||
<view class="shop__fee weui-flex__item">
|
||||
起送 ¥{{item.min_price}}
|
||||
</view>
|
||||
<text class="shop__reach-time grey-color">{{item.distance/1000}}km</text> |
|
||||
<text class="shop__reach-time grey-color">{{item.distanceFormat}}km</text> |
|
||||
<text class="shop__reach-time primary-color">{{item.reach_time}}分钟</text>
|
||||
</view>
|
||||
</view>
|
||||
@ -52,4 +51,5 @@
|
||||
</view>
|
||||
</navigator>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<template is="load-more" data="{{loading: loading, hasMore: hasMore, noMoreLabel: '更多商家接入中, 敬请期待'}}"></template>
|
@ -2,6 +2,7 @@
|
||||
|
||||
@import './shop.wxss';
|
||||
@import '/templates/star-rate.wxss';
|
||||
@import '/templates/load-more.wxss';
|
||||
|
||||
.topbar {
|
||||
display: flex;
|
||||
@ -11,7 +12,7 @@
|
||||
|
||||
.address {
|
||||
position: relative;
|
||||
padding: 3px 5px;
|
||||
padding: 3px 15px 3px 5px;
|
||||
min-width: 40%;
|
||||
max-width: 50%;
|
||||
font-size: 14px;
|
||||
|
@ -33,7 +33,8 @@
|
||||
}
|
||||
|
||||
.shop__promotion-icon {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
margin-top: -2px;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
vertical-align: middle;
|
||||
}
|
@ -1,6 +1,16 @@
|
||||
// pages/shop/show.js
|
||||
|
||||
import {makePhoneCall} from '../../utils/util'
|
||||
import {
|
||||
makePhoneCall,
|
||||
getCurrentAddress,
|
||||
datetimeFormat
|
||||
} from '../../utils/util'
|
||||
|
||||
import {
|
||||
getSellerInfo,
|
||||
getReviews
|
||||
} from '../../utils/apis'
|
||||
|
||||
|
||||
var initOrder = {
|
||||
totalNum: 0,
|
||||
@ -14,7 +24,7 @@ var initOrder = {
|
||||
Page({
|
||||
data: {
|
||||
tabs: ["商品", "评价", "商家"],
|
||||
activeIndex: 1,
|
||||
activeIndex: 0,
|
||||
|
||||
activeMenuIndex: 0,
|
||||
showCart: false,
|
||||
@ -24,607 +34,18 @@ Page({
|
||||
order: initOrder,
|
||||
|
||||
review: {
|
||||
"list": [
|
||||
{
|
||||
"order_id": "1272",
|
||||
"user_id": "4",
|
||||
"seller_id": "1",
|
||||
"service": "5",
|
||||
"reach_time": "0",
|
||||
"quality": "5",
|
||||
"content": "",
|
||||
"pic_url": null,
|
||||
"time": "1488951898",
|
||||
"nick": "te***",
|
||||
"head_pic": null
|
||||
},
|
||||
{
|
||||
"order_id": "1271",
|
||||
"user_id": "4",
|
||||
"seller_id": "1",
|
||||
"service": "5",
|
||||
"reach_time": "0",
|
||||
"quality": "5",
|
||||
"content": "123455",
|
||||
"pic_url": null,
|
||||
"time": "1488944987",
|
||||
"nick": "te***",
|
||||
"head_pic": null
|
||||
},
|
||||
{
|
||||
"order_id": "1270",
|
||||
"user_id": "4",
|
||||
"seller_id": "1",
|
||||
"service": "4",
|
||||
"reach_time": "0",
|
||||
"quality": "4",
|
||||
"content": "hoohoo",
|
||||
"pic_url": null,
|
||||
"time": "1488944700",
|
||||
"nick": "te***",
|
||||
"head_pic": null
|
||||
},
|
||||
{
|
||||
"order_id": "1267",
|
||||
"user_id": "4",
|
||||
"seller_id": "1",
|
||||
"service": "5",
|
||||
"reach_time": "0",
|
||||
"quality": "5",
|
||||
"content": "hoho",
|
||||
"pic_url": null,
|
||||
"time": "1488936939",
|
||||
"nick": "te***",
|
||||
"head_pic": null
|
||||
},
|
||||
{
|
||||
"order_id": "1266",
|
||||
"user_id": "5",
|
||||
"seller_id": "1",
|
||||
"service": "5",
|
||||
"reach_time": "0",
|
||||
"quality": "5",
|
||||
"content": "",
|
||||
"pic_url": "",
|
||||
"time": "1488863802",
|
||||
"nick": "te***",
|
||||
"head_pic": null
|
||||
}
|
||||
],
|
||||
"count": 10,
|
||||
"page": 0
|
||||
hasMore: true,
|
||||
loading: false,
|
||||
page: 0,
|
||||
},
|
||||
|
||||
info: {
|
||||
"seller_id": "2",
|
||||
"seller_name": "鲜极道",
|
||||
"state": "1",
|
||||
"city_id": "330300",
|
||||
"address": "温州龙湾区衢江路2011号",
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller/20170314/1489479032148947903230424.png",
|
||||
"pic_hd": "http://mtest.ipaotui.com/Uploadfile/Img/seller/20170314/hd_1489479032148947903230424.png",
|
||||
"longitude": "120.748973",
|
||||
"latitude": "27.984401",
|
||||
"phone": "88888888",
|
||||
"start_sell_time": "08:00:00",
|
||||
"end_sell_time": "09:00:00",
|
||||
"sell_time": "08:00-20:00,08:00-20:00",
|
||||
"is_rest": "0",
|
||||
"notice": "东池便当,好吃西",
|
||||
"reach_time": "30",
|
||||
"reserve_day": "0",
|
||||
"min_price": "5",
|
||||
"sales": "74",
|
||||
"service": "4.2",
|
||||
"quality": "3.5",
|
||||
"overall": "4.5",
|
||||
"distance": "20434",
|
||||
"delivery_fee": 45,
|
||||
"favorite": "0",
|
||||
"promotion": [
|
||||
{
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_promotion/first_cut.png",
|
||||
"info": "新用户在线支付满15元减10元,满20元减13元"
|
||||
},
|
||||
{
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_promotion/cut.png",
|
||||
"info": "在线支付满15元减5元,满20元减8元"
|
||||
}
|
||||
],
|
||||
"menus": [
|
||||
{
|
||||
"menu_id": "10",
|
||||
"menu_name": "热销排行",
|
||||
"seller_id": "2",
|
||||
"sort": "0",
|
||||
"is_use": "1",
|
||||
"goods": "29,32,31,30,46",
|
||||
"goods2": [
|
||||
{
|
||||
"goods_id": "29",
|
||||
"goods_name": "鸡腿饭",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461034075146103407535640.jpg",
|
||||
"pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461034075146103407535640.jpg",
|
||||
"pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461034075146103407535640.jpg",
|
||||
"detail": "鸡腿饭 xx",
|
||||
"price": "22.00",
|
||||
"packing_fee": "2.00",
|
||||
"sales": "46",
|
||||
"praise": "0",
|
||||
"stock": "76",
|
||||
"sub_goods": [
|
||||
{
|
||||
"sub_id": "50",
|
||||
"sub_name": "大",
|
||||
"price": "22.98",
|
||||
"packing_fee": "2.00",
|
||||
"stock": "74"
|
||||
},
|
||||
{
|
||||
"sub_id": "51",
|
||||
"sub_name": "小",
|
||||
"price": "22.00",
|
||||
"packing_fee": "2.00",
|
||||
"stock": "76"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"goods_id": "32",
|
||||
"goods_name": "鸡翅饭",
|
||||
"seller_id": "2",
|
||||
"pic_url": null,
|
||||
"pic_hd1": null,
|
||||
"pic_hd2": null,
|
||||
"detail": "鸡翅饭 xx",
|
||||
"price": "20.00",
|
||||
"packing_fee": "2.00",
|
||||
"sales": "41",
|
||||
"praise": "0",
|
||||
"stock": "59",
|
||||
"sub_goods": []
|
||||
},
|
||||
{
|
||||
"goods_id": "31",
|
||||
"goods_name": "招牌饭",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461033463146103346359875.jpg",
|
||||
"pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461033463146103346359875.jpg",
|
||||
"pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461033463146103346359875.jpg",
|
||||
"detail": "招牌饭 xx",
|
||||
"price": "20.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "14",
|
||||
"praise": "0",
|
||||
"stock": "86",
|
||||
"sub_goods": []
|
||||
},
|
||||
{
|
||||
"goods_id": "30",
|
||||
"goods_name": "排骨饭",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461034058146103405829482.jpg",
|
||||
"pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461034058146103405829482.jpg",
|
||||
"pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461034058146103405829482.jpg",
|
||||
"detail": "排骨饭 xx",
|
||||
"price": "20.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "10",
|
||||
"praise": "0",
|
||||
"stock": "0",
|
||||
"sub_goods": []
|
||||
},
|
||||
{
|
||||
"goods_id": "46",
|
||||
"goods_name": "香肠2",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1466411009146641100940750.jpg",
|
||||
"pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1466411009146641100940750.jpg",
|
||||
"pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1466411009146641100940750.jpg",
|
||||
"detail": "",
|
||||
"price": "2.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "13",
|
||||
"praise": "0",
|
||||
"stock": "187",
|
||||
"sub_goods": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"menu_id": "11",
|
||||
"menu_name": "便当",
|
||||
"seller_id": "2",
|
||||
"sort": "0",
|
||||
"is_use": "1",
|
||||
"goods": "29,33,32,31,30,46",
|
||||
"goods2": [
|
||||
{
|
||||
"goods_id": "29",
|
||||
"goods_name": "鸡腿饭",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461034075146103407535640.jpg",
|
||||
"pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461034075146103407535640.jpg",
|
||||
"pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461034075146103407535640.jpg",
|
||||
"detail": "鸡腿饭 xx",
|
||||
"price": "22.00",
|
||||
"packing_fee": "2.00",
|
||||
"sales": "46",
|
||||
"praise": "0",
|
||||
"stock": "76",
|
||||
"sub_goods": [
|
||||
{
|
||||
"sub_id": "50",
|
||||
"sub_name": "大",
|
||||
"price": "22.98",
|
||||
"packing_fee": "2.00",
|
||||
"stock": "74"
|
||||
},
|
||||
{
|
||||
"sub_id": "51",
|
||||
"sub_name": "小",
|
||||
"price": "22.00",
|
||||
"packing_fee": "2.00",
|
||||
"stock": "76"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"goods_id": "33",
|
||||
"goods_name": "香肠饭",
|
||||
"seller_id": "2",
|
||||
"pic_url": null,
|
||||
"pic_hd1": null,
|
||||
"pic_hd2": null,
|
||||
"detail": "香肠饭 xx",
|
||||
"price": "20.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "0",
|
||||
"praise": "0",
|
||||
"stock": "100",
|
||||
"sub_goods": []
|
||||
},
|
||||
{
|
||||
"goods_id": "32",
|
||||
"goods_name": "鸡翅饭",
|
||||
"seller_id": "2",
|
||||
"pic_url": null,
|
||||
"pic_hd1": null,
|
||||
"pic_hd2": null,
|
||||
"detail": "鸡翅饭 xx",
|
||||
"price": "20.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "41",
|
||||
"praise": "0",
|
||||
"stock": "59",
|
||||
"sub_goods": []
|
||||
},
|
||||
{
|
||||
"goods_id": "31",
|
||||
"goods_name": "招牌饭",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461033463146103346359875.jpg",
|
||||
"pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461033463146103346359875.jpg",
|
||||
"pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461033463146103346359875.jpg",
|
||||
"detail": "招牌饭 xx",
|
||||
"price": "20.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "14",
|
||||
"praise": "0",
|
||||
"stock": "86",
|
||||
"sub_goods": []
|
||||
},
|
||||
{
|
||||
"goods_id": "30",
|
||||
"goods_name": "排骨饭",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461034058146103405829482.jpg",
|
||||
"pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461034058146103405829482.jpg",
|
||||
"pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461034058146103405829482.jpg",
|
||||
"detail": "排骨饭 xx",
|
||||
"price": "20.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "10",
|
||||
"praise": "0",
|
||||
"stock": "0",
|
||||
"sub_goods": []
|
||||
},
|
||||
{
|
||||
"goods_id": "46",
|
||||
"goods_name": "香肠2",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1466411009146641100940750.jpg",
|
||||
"pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1466411009146641100940750.jpg",
|
||||
"pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1466411009146641100940750.jpg",
|
||||
"detail": "",
|
||||
"price": "2.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "13",
|
||||
"praise": "0",
|
||||
"stock": "187",
|
||||
"sub_goods": []
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
"goods_map": {
|
||||
"29": {
|
||||
"goods_id": "29",
|
||||
"goods_name": "鸡腿饭",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461034075146103407535640.jpg",
|
||||
"pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461034075146103407535640.jpg",
|
||||
"pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461034075146103407535640.jpg",
|
||||
"detail": "鸡腿饭 xx",
|
||||
"price": "22.00",
|
||||
"packing_fee": "2.00",
|
||||
"sales": "46",
|
||||
"praise": "0",
|
||||
"stock": "76",
|
||||
"sub_goods": [
|
||||
{
|
||||
"sub_id": "50",
|
||||
"sub_name": "大",
|
||||
"price": "22.98",
|
||||
"packing_fee": "2.00",
|
||||
"stock": "74"
|
||||
},
|
||||
{
|
||||
"sub_id": "51",
|
||||
"sub_name": "小",
|
||||
"price": "22.00",
|
||||
"packing_fee": "2.00",
|
||||
"stock": "76"
|
||||
}
|
||||
],
|
||||
"sub_goods_map": {
|
||||
"50": {
|
||||
"sub_id": "50",
|
||||
"sub_name": "大",
|
||||
"price": "22.98",
|
||||
"packing_fee": "2.00",
|
||||
"stock": "74"
|
||||
},
|
||||
"51": {
|
||||
"sub_id": "51",
|
||||
"sub_name": "小",
|
||||
"price": "22.00",
|
||||
"packing_fee": "2.00",
|
||||
"stock": "76"
|
||||
}
|
||||
}
|
||||
},
|
||||
"30": {
|
||||
"goods_id": "30",
|
||||
"goods_name": "排骨饭",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461034058146103405829482.jpg",
|
||||
"pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461034058146103405829482.jpg",
|
||||
"pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461034058146103405829482.jpg",
|
||||
"detail": "排骨饭 xx",
|
||||
"price": "20.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "10",
|
||||
"praise": "0",
|
||||
"stock": "0",
|
||||
"sub_goods": [],
|
||||
"sub_goods_map": []
|
||||
},
|
||||
"31": {
|
||||
"goods_id": "31",
|
||||
"goods_name": "招牌饭",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1461033463146103346359875.jpg",
|
||||
"pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1461033463146103346359875.jpg",
|
||||
"pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1461033463146103346359875.jpg",
|
||||
"detail": "招牌饭 xx",
|
||||
"price": "20.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "15",
|
||||
"praise": "0",
|
||||
"stock": "85",
|
||||
"sub_goods": [],
|
||||
"sub_goods_map": []
|
||||
},
|
||||
"32": {
|
||||
"goods_id": "32",
|
||||
"goods_name": "鸡翅饭",
|
||||
"seller_id": "2",
|
||||
"pic_url": null,
|
||||
"pic_hd1": null,
|
||||
"pic_hd2": null,
|
||||
"detail": "鸡翅饭 xx",
|
||||
"price": "20.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "43",
|
||||
"praise": "0",
|
||||
"stock": "57",
|
||||
"sub_goods": [],
|
||||
"sub_goods_map": []
|
||||
},
|
||||
"33": {
|
||||
"goods_id": "33",
|
||||
"goods_name": "香肠饭",
|
||||
"seller_id": "2",
|
||||
"pic_url": null,
|
||||
"pic_hd1": null,
|
||||
"pic_hd2": null,
|
||||
"detail": "香肠饭 xx",
|
||||
"price": "20.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "0",
|
||||
"praise": "0",
|
||||
"stock": "100",
|
||||
"sub_goods": [],
|
||||
"sub_goods_map": []
|
||||
},
|
||||
"34": {
|
||||
"goods_id": "34",
|
||||
"goods_name": "咸蛋",
|
||||
"seller_id": "2",
|
||||
"pic_url": null,
|
||||
"pic_hd1": null,
|
||||
"pic_hd2": null,
|
||||
"detail": "咸蛋 xx",
|
||||
"price": "20.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "0",
|
||||
"praise": "0",
|
||||
"stock": "100",
|
||||
"sub_goods": [],
|
||||
"sub_goods_map": []
|
||||
},
|
||||
"35": {
|
||||
"goods_id": "35",
|
||||
"goods_name": "可乐",
|
||||
"seller_id": "2",
|
||||
"pic_url": null,
|
||||
"pic_hd1": null,
|
||||
"pic_hd2": null,
|
||||
"detail": "可乐 xx",
|
||||
"price": "3.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "0",
|
||||
"praise": "0",
|
||||
"stock": "100",
|
||||
"sub_goods": [],
|
||||
"sub_goods_map": []
|
||||
},
|
||||
"36": {
|
||||
"goods_id": "36",
|
||||
"goods_name": "雪碧",
|
||||
"seller_id": "2",
|
||||
"pic_url": null,
|
||||
"pic_hd1": null,
|
||||
"pic_hd2": null,
|
||||
"detail": "雪碧 xx",
|
||||
"price": "3.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "0",
|
||||
"praise": "0",
|
||||
"stock": "100",
|
||||
"sub_goods": [],
|
||||
"sub_goods_map": []
|
||||
},
|
||||
"37": {
|
||||
"goods_id": "37",
|
||||
"goods_name": "香肠",
|
||||
"seller_id": "2",
|
||||
"pic_url": null,
|
||||
"pic_hd1": null,
|
||||
"pic_hd2": null,
|
||||
"detail": "香肠 xx",
|
||||
"price": "3.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "0",
|
||||
"praise": "0",
|
||||
"stock": "100",
|
||||
"sub_goods": [],
|
||||
"sub_goods_map": []
|
||||
},
|
||||
"40": {
|
||||
"goods_id": "40",
|
||||
"goods_name": "香蕉",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/",
|
||||
"pic_hd1": null,
|
||||
"pic_hd2": null,
|
||||
"detail": "",
|
||||
"price": "6.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "0",
|
||||
"praise": "0",
|
||||
"stock": "100",
|
||||
"sub_goods": [],
|
||||
"sub_goods_map": []
|
||||
},
|
||||
"41": {
|
||||
"goods_id": "41",
|
||||
"goods_name": "香蕉2",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/",
|
||||
"pic_hd1": null,
|
||||
"pic_hd2": null,
|
||||
"detail": "",
|
||||
"price": "6.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "0",
|
||||
"praise": "0",
|
||||
"stock": "100",
|
||||
"sub_goods": [],
|
||||
"sub_goods_map": []
|
||||
},
|
||||
"42": {
|
||||
"goods_id": "42",
|
||||
"goods_name": "香蕉3",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/",
|
||||
"pic_hd1": null,
|
||||
"pic_hd2": null,
|
||||
"detail": "",
|
||||
"price": "6.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "0",
|
||||
"praise": "0",
|
||||
"stock": "100",
|
||||
"sub_goods": [],
|
||||
"sub_goods_map": []
|
||||
},
|
||||
"43": {
|
||||
"goods_id": "43",
|
||||
"goods_name": "香蕉3",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/",
|
||||
"pic_hd1": null,
|
||||
"pic_hd2": null,
|
||||
"detail": "",
|
||||
"price": "6.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "0",
|
||||
"praise": "0",
|
||||
"stock": "100",
|
||||
"sub_goods": [],
|
||||
"sub_goods_map": []
|
||||
},
|
||||
"44": {
|
||||
"goods_id": "44",
|
||||
"goods_name": "香蕉3",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/",
|
||||
"pic_hd1": null,
|
||||
"pic_hd2": null,
|
||||
"detail": "",
|
||||
"price": "6.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "0",
|
||||
"praise": "0",
|
||||
"stock": "100",
|
||||
"sub_goods": [],
|
||||
"sub_goods_map": []
|
||||
},
|
||||
"46": {
|
||||
"goods_id": "46",
|
||||
"goods_name": "香肠2",
|
||||
"seller_id": "2",
|
||||
"pic_url": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/1466411009146641100940750.jpg",
|
||||
"pic_hd1": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd1_1466411009146641100940750.jpg",
|
||||
"pic_hd2": "http://mtest.ipaotui.com/Uploadfile/Img/seller_goods/hd2_1466411009146641100940750.jpg",
|
||||
"detail": "",
|
||||
"price": "2.00",
|
||||
"packing_fee": "0.00",
|
||||
"sales": "13",
|
||||
"praise": "0",
|
||||
"stock": "187",
|
||||
"sub_goods": [],
|
||||
"sub_goods_map": []
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
onLoad: function (options) {
|
||||
// 页面初始化 options为页面跳转所带来的参数
|
||||
this.id = options.id || 1
|
||||
this.loadData()
|
||||
this.loadReview()
|
||||
},
|
||||
onReady: function () {
|
||||
// 页面渲染完成
|
||||
@ -639,17 +60,65 @@ Page({
|
||||
// 页面关闭
|
||||
},
|
||||
|
||||
initTab: function () {
|
||||
var that = this;
|
||||
wx.getSystemInfo({
|
||||
success: function (res) {
|
||||
that.setData({
|
||||
sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2,
|
||||
sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex
|
||||
});
|
||||
}
|
||||
});
|
||||
loadData() {
|
||||
var that = this
|
||||
var id = this.id;
|
||||
wx.showNavigationBarLoading()
|
||||
getCurrentAddress(function (address) {
|
||||
getSellerInfo({
|
||||
address,
|
||||
seller_id: id,
|
||||
success(data) {
|
||||
data['distanceFormat'] = +(data['distance'] / 1000).toFixed(2)
|
||||
that.setData({
|
||||
info: data
|
||||
})
|
||||
wx.setNavigationBarTitle({
|
||||
title: data.seller_name
|
||||
})
|
||||
},
|
||||
complete() {
|
||||
wx.hideNavigationBarLoading()
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
loadReview() {
|
||||
var that = this;
|
||||
var id = this.id
|
||||
var {review: {
|
||||
page, loading
|
||||
}} = this.data
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({
|
||||
'review.loading': true
|
||||
})
|
||||
getReviews({
|
||||
page,
|
||||
seller_id: id,
|
||||
success(data) {
|
||||
var {review: {
|
||||
list
|
||||
}} = that.data
|
||||
var list2 = data.list.map(item => {
|
||||
item['timeFormat'] = datetimeFormat(item['time']);
|
||||
return item
|
||||
})
|
||||
|
||||
that.setData({
|
||||
'review.list': list ? list.concat(list2) : list2,
|
||||
'review.loading': false,
|
||||
'review.page': page + 1,
|
||||
'review.hasMore': data.count == 10
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
tabClick: function (e) {
|
||||
this.setData({
|
||||
activeIndex: e.currentTarget.id
|
||||
@ -853,5 +322,14 @@ Page({
|
||||
onPhoneTap(e) {
|
||||
var {phone} = e.currentTarget.dataset
|
||||
makePhoneCall(phone)
|
||||
},
|
||||
|
||||
onScrolltolower(e) {
|
||||
var {
|
||||
hasMore, loading
|
||||
} = this.data.review
|
||||
if (hasMore && !loading) {
|
||||
this.loadReview()
|
||||
}
|
||||
}
|
||||
})
|
@ -1,4 +1,5 @@
|
||||
<import src="/templates/star-rate.wxml" />
|
||||
<import src="/templates/load-more.wxml" />
|
||||
<import src="templates/goods-actions.wxml" />
|
||||
<import src="templates/cart-box.wxml" />
|
||||
<import src="templates/sub-goods.wxml" />
|
||||
@ -15,7 +16,7 @@
|
||||
<view class="weui-media-box__title">{{info.seller_name}}</view>
|
||||
<view class="weui-media-box__desc shop-info__desc">
|
||||
<view>
|
||||
{{info.min_price}}元起送 | {{info.reach_time}}分钟 | 距离{{info.distance / 1000}}km
|
||||
{{info.min_price}}元起送 | {{info.reach_time}}分钟 | 距离{{info.distanceFormat}}km
|
||||
</view>
|
||||
<view wx:if="{{info.notice}}">
|
||||
公告: {{info.notice}}
|
||||
@ -93,46 +94,49 @@
|
||||
</view>
|
||||
</swiper-item>
|
||||
<swiper-item class="weui-tab__content weui-tab__content_review">
|
||||
<view class="shop-rate">
|
||||
<view class="shop-rate__overall">
|
||||
<view class="shop-rate__overall-num">{{info.overall}}</view>
|
||||
<view class="classname">综合评分</view>
|
||||
</view>
|
||||
<view class="shop-rate__score">
|
||||
<view class="shop-rate__score-item">
|
||||
<view class="shop-rate__score-item-label">商家评分</view>
|
||||
<template is="star-rate" data="{{value: info.quality}}"></template>
|
||||
<view class="shop-rate__score-item-num">{{info.quality}}</view>
|
||||
<scroll-view class="scroll-view_review" enable-back-to-top="true" bindscrolltolower="onScrolltolower" scroll-y="true">
|
||||
<view class="shop-rate">
|
||||
<view class="shop-rate__overall">
|
||||
<view class="shop-rate__overall-num">{{info.overall}}</view>
|
||||
<view class="classname">综合评分</view>
|
||||
</view>
|
||||
<view class="shop-rate__score-item">
|
||||
<view class="shop-rate__score-item-label">配送评分</view>
|
||||
<template is="star-rate" data="{{value: info.service}}"></template>
|
||||
<view class="shop-rate__score-item-num">{{info.service}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="shop-review">
|
||||
<view class="review-list">
|
||||
<view wx:for="{{review.list}}" wx:key="order_id" class="review-item">
|
||||
<view class="">
|
||||
<image class="review-item__head-img" src="{{item.head_pic || '/images/default-image.png'}}"></image>
|
||||
<view class="shop-rate__score">
|
||||
<view class="shop-rate__score-item">
|
||||
<view class="shop-rate__score-item-label">商家评分</view>
|
||||
<template is="star-rate" data="{{value: info.quality}}"></template>
|
||||
<view class="shop-rate__score-item-num">{{info.quality}}</view>
|
||||
</view>
|
||||
<view class="review-item__content">
|
||||
<view class="review-item__hd">
|
||||
<view class="review-item__add-time">{{item.time}}</view>
|
||||
<view class="review-item__nick">{{item.nick}}</view>
|
||||
<view class="weui-flex">
|
||||
<template is="star-rate" data="{{value: item.quality, mini: true}}"></template>
|
||||
<view class="review-item__reach-time text-small grey-color">及时到达</view>
|
||||
<view class="shop-rate__score-item">
|
||||
<view class="shop-rate__score-item-label">配送评分</view>
|
||||
<template is="star-rate" data="{{value: info.service}}"></template>
|
||||
<view class="shop-rate__score-item-num">{{info.service}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="shop-review">
|
||||
<view class="review-list">
|
||||
<view wx:for="{{review.list}}" wx:key="{{index}}" class="review-item">
|
||||
<view class="">
|
||||
<image class="review-item__head-img" src="{{item.head_pic || '/images/default-image.png'}}"></image>
|
||||
</view>
|
||||
<view class="review-item__content">
|
||||
<view class="review-item__hd">
|
||||
<view class="review-item__add-time">{{item.timeFormat}}</view>
|
||||
<view class="review-item__nick">{{item.nick}}</view>
|
||||
<view class="weui-flex">
|
||||
<template is="star-rate" data="{{value: item.quality, mini: true}}"></template>
|
||||
<view class="review-item__reach-time text-small grey-color">及时到达</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="review-item__bd">
|
||||
{{item.content}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="review-item__bd">
|
||||
{{item.content}}
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<template is="load-more" data="{{loading: review.loading, hasMore: review.hasMore}}"></template>
|
||||
</scroll-view>
|
||||
</swiper-item>
|
||||
<swiper-item class="weui-tab__content weui-tab__content_info">
|
||||
<block wx:if="{{info.promotion.length > 0}}">
|
||||
@ -169,7 +173,6 @@
|
||||
</view>
|
||||
<view class="weui-cell__bd">{{info.address}}</view>
|
||||
</view>
|
||||
|
||||
<view class="weui-cell">
|
||||
<view class="weui-cell__hd weui-cell__hd_info">
|
||||
营业时间
|
||||
|
@ -1,5 +1,6 @@
|
||||
/* pages/shop/show.wxss */
|
||||
@import '/templates/star-rate.wxss';
|
||||
@import '/templates/load-more.wxss';
|
||||
@import './templates/goods-actions.wxss';
|
||||
@import './templates/cart-box.wxss';
|
||||
@import './templates/sub-goods.wxss';
|
||||
@ -240,6 +241,9 @@
|
||||
.weui-tab__content_review {
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
.scroll-view_review{
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.shop-rate {
|
||||
display: flex;
|
||||
|
14
app/templates/load-more.wxml
Normal file
14
app/templates/load-more.wxml
Normal file
@ -0,0 +1,14 @@
|
||||
<template name="load-more">
|
||||
<view wx:if="{{loading}}" class="weui-loadmore">
|
||||
<view class="weui-loading"></view>
|
||||
<view class="weui-loadmore__tips">正在加载</view>
|
||||
</view>
|
||||
<view wx:elif="{{hasMore}}" class="weui-loadmore weui-loadmore_line">
|
||||
<view class="weui-loadmore__tips weui-loadmore__tips_in-line">加载更多</view>
|
||||
</view>
|
||||
<view wx:else class="weui-loadmore weui-loadmore_line">
|
||||
<view class="weui-loadmore__tips weui-loadmore__tips_in-line">
|
||||
{{noMoreLabel ? noMoreLabel : '没有更多数据'}}
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
3
app/templates/load-more.wxss
Normal file
3
app/templates/load-more.wxss
Normal file
@ -0,0 +1,3 @@
|
||||
.weui-loadmore__tips_in-line {
|
||||
background-color: #f8f8f8;
|
||||
}
|
61
app/utils/apis.js
Normal file
61
app/utils/apis.js
Normal file
@ -0,0 +1,61 @@
|
||||
import {
|
||||
fetch, coordFormat,
|
||||
alert, confirm
|
||||
} from './util'
|
||||
|
||||
// 获取商店列表
|
||||
export function getSellers(options) {
|
||||
var {
|
||||
page, address,
|
||||
success
|
||||
} = options
|
||||
page = page || 0
|
||||
var location = coordFormat(address.location)
|
||||
fetch({
|
||||
url: 'index.php?m=Mall&c=Seller&a=getSellers',
|
||||
data: {
|
||||
page,
|
||||
city_name: address.city,
|
||||
city_id: address.city_id,
|
||||
district_name: address.district,
|
||||
district_id: address.district_id,
|
||||
longitude: location.longitude,
|
||||
latitude: location.latitude
|
||||
},
|
||||
success
|
||||
})
|
||||
}
|
||||
|
||||
// 获取商店详情
|
||||
export function getSellerInfo(options) {
|
||||
var {
|
||||
seller_id, address,
|
||||
success, complete
|
||||
} = options
|
||||
var location = coordFormat(address.location)
|
||||
fetch({
|
||||
url: 'index.php?m=Mall&c=Seller&a=getSellerInfo',
|
||||
data: {
|
||||
seller_id,
|
||||
longitude: location.longitude,
|
||||
latitude: location.latitude
|
||||
},
|
||||
success, complete
|
||||
})
|
||||
}
|
||||
|
||||
// 获取商店评论
|
||||
export function getReviews(options) {
|
||||
var {
|
||||
seller_id, page,
|
||||
success
|
||||
} = options
|
||||
page = page || 0
|
||||
fetch({
|
||||
url: 'index.php?m=Mall&c=Seller&a=getReviews',
|
||||
data: {
|
||||
seller_id, page
|
||||
},
|
||||
success
|
||||
})
|
||||
}
|
56
app/utils/debounce.js
Normal file
56
app/utils/debounce.js
Normal file
@ -0,0 +1,56 @@
|
||||
/**
|
||||
* Returns a function, that, as long as it continues to be invoked, will not
|
||||
* be triggered. The function will be called after it stops being called for
|
||||
* N milliseconds. If `immediate` is passed, trigger the function on the
|
||||
* leading edge, instead of the trailing. The function also has a property 'clear'
|
||||
* that is a function which will clear the timer to prevent previously scheduled executions.
|
||||
*
|
||||
* @source underscore.js
|
||||
* @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/
|
||||
* @param {Function} function to wrap
|
||||
* @param {Number} timeout in ms (`100`)
|
||||
* @param {Boolean} whether to execute at the beginning (`false`)
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function debounce(func, wait, immediate){
|
||||
var timeout, args, context, timestamp, result;
|
||||
if (null == wait) wait = 100;
|
||||
|
||||
function later() {
|
||||
var last = Date.now() - timestamp;
|
||||
|
||||
if (last < wait && last >= 0) {
|
||||
timeout = setTimeout(later, wait - last);
|
||||
} else {
|
||||
timeout = null;
|
||||
if (!immediate) {
|
||||
result = func.apply(context, args);
|
||||
context = args = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var debounced = function(){
|
||||
context = this;
|
||||
args = arguments;
|
||||
timestamp = Date.now();
|
||||
var callNow = immediate && !timeout;
|
||||
if (!timeout) timeout = setTimeout(later, wait);
|
||||
if (callNow) {
|
||||
result = func.apply(context, args);
|
||||
context = args = null;
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
debounced.clear = function() {
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
timeout = null;
|
||||
}
|
||||
};
|
||||
|
||||
return debounced;
|
||||
};
|
@ -36,7 +36,7 @@ export function reverseGeocoder(options) {
|
||||
}
|
||||
|
||||
// 获取当前地理位置
|
||||
export function getCurrentAddress(options) {
|
||||
export function getCurrentAddressList(options) {
|
||||
const {
|
||||
success, complete
|
||||
} = options
|
||||
@ -50,25 +50,93 @@ export function getCurrentAddress(options) {
|
||||
},
|
||||
success, complete
|
||||
})
|
||||
},
|
||||
fail(e) {
|
||||
console.log(res.errMsg)
|
||||
alert('获取用户地址失败')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 地点搜索
|
||||
export function searchAddressList(options) {
|
||||
const {
|
||||
keyword, success
|
||||
} = options
|
||||
getCurrentCity(function (cityName) {
|
||||
qqmap.getSuggestion({
|
||||
region: cityName,
|
||||
keyword,
|
||||
success(res) {
|
||||
success && success(res.data)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 获取当期地址
|
||||
var currentAddress;
|
||||
export function getCurrentAddress(callback) {
|
||||
if(currentAddress) {
|
||||
return callback && callback(currentAddress)
|
||||
}
|
||||
|
||||
getCurrentAddressList({
|
||||
success(addressList) {
|
||||
if(addressList.length > 0) {
|
||||
currentAddress = addressList[0]
|
||||
callback(currentAddress)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 获取当前城市
|
||||
var cityName;
|
||||
export function getCurrentCity(callback) {
|
||||
if (cityName) {
|
||||
return callback && callback(cityName)
|
||||
}
|
||||
wx.getLocation({
|
||||
type: 'gcj02',
|
||||
success(res) {
|
||||
qqmap.reverseGeocoder({
|
||||
location: {
|
||||
longitude: res.longitude,
|
||||
latitude: res.latitude
|
||||
},
|
||||
success: function (res) {
|
||||
cityName = res.result.address_component.city
|
||||
callback && callback(cityName)
|
||||
}
|
||||
})
|
||||
},
|
||||
fail(res) {
|
||||
console.log(res.errMsg)
|
||||
alert('获取用户地址失败')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 根据坐标获取地址信息
|
||||
export function getAddressFromLocation(options) {
|
||||
const {location, success} = options
|
||||
getPois({
|
||||
location,
|
||||
success(pois) {
|
||||
var poi = pois[0]
|
||||
if (poi) {
|
||||
var address = Object.assign({
|
||||
address_name: poi.title,
|
||||
location,
|
||||
}, resolveAdInfo(poi.ad_info))
|
||||
|
||||
success && success(address)
|
||||
}
|
||||
var addressList = []
|
||||
pois.forEach(poi => {
|
||||
var {
|
||||
title, location,
|
||||
address, ad_info
|
||||
} = poi
|
||||
addressList.push(Object.assign({
|
||||
title, location, address
|
||||
}, resolveAdInfo(ad_info)))
|
||||
})
|
||||
success && success(addressList)
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -100,7 +168,7 @@ export function fetch(options) {
|
||||
wx.request({
|
||||
url: `https://${host}/${options.url}`,
|
||||
data: Object.assign(options.data, {
|
||||
'app_v': 'ipaotui_mini'
|
||||
'app_v': 'ipaotui_mall'
|
||||
}),
|
||||
method: options.method || 'POST',
|
||||
header: {
|
||||
@ -179,8 +247,18 @@ export function datetimeFormat(unix_timestamp) {
|
||||
|
||||
// 坐标格式化
|
||||
export function coordFormat(location) {
|
||||
if(location.lat && location.lng) {
|
||||
location = {
|
||||
longitude: location.lng,
|
||||
latitude: location.lat
|
||||
}
|
||||
}
|
||||
// gcj02 转 bd09
|
||||
return gcj02tobd09(location.longitude, location.latitude).join(',')
|
||||
var location = gcj02tobd09(location.longitude, location.latitude)
|
||||
return {
|
||||
longitude: location[0],
|
||||
latitude: location[1]
|
||||
}
|
||||
}
|
||||
|
||||
// 倒计时格式化
|
||||
@ -189,4 +267,28 @@ export function countdownFormat(count) {
|
||||
count = Math.floor(count / 60)
|
||||
var minutes = count % 60
|
||||
return `${minutes}分钟${seconds}秒`
|
||||
}
|
||||
|
||||
// 字符串关键字分组
|
||||
|
||||
export function splitByKeyword(text, keyword) {
|
||||
if (!text) {
|
||||
return []
|
||||
}
|
||||
var arr = text.split(keyword)
|
||||
var res = []
|
||||
res.push({
|
||||
text: arr[0],
|
||||
isKeyword: false
|
||||
})
|
||||
for (let i = 1, len = arr.length; i < len; i++) {
|
||||
res.push({
|
||||
text: keyword,
|
||||
isKeyword: true
|
||||
}, {
|
||||
text: arr[i],
|
||||
isKeyword: false
|
||||
})
|
||||
}
|
||||
return res
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user