Commit cb450afca3ca6503c1a58ba2182ca2a229803dfc

Authored by vking
1 parent e4ba0e5e

new 2.0

@@ -4,7 +4,8 @@ Component({ @@ -4,7 +4,8 @@ Component({
4 * 组件的属性列表 4 * 组件的属性列表
5 */ 5 */
6 properties: { 6 properties: {
7 - 7 + seller:Object,
  8 + activeSellerID:String,
8 }, 9 },
9 10
10 /** 11 /**
@@ -13,11 +14,18 @@ Component({ @@ -13,11 +14,18 @@ Component({
13 data: { 14 data: {
14 15
15 }, 16 },
16 - 17 + attached(){
  18 + this.initSeller()
  19 + },
17 /** 20 /**
18 * 组件的方法列表 21 * 组件的方法列表
19 */ 22 */
20 methods: { 23 methods: {
21 - 24 + initSeller(){
  25 + let seller=this.data.seller
  26 + this.setData({
  27 + seller:seller,
  28 + })
  29 + },
22 } 30 }
23 }) 31 })
1 <!--components/2.0/seller/card.wxml--> 1 <!--components/2.0/seller/card.wxml-->
2 -<view class="view seller padding-sm margin-sm"> 2 +<wxs src="../../../utils/util.wxs" module="util" />
  3 +<view class="view seller padding-sm margin-sm {{activeSellerID==seller.id?'active':''}}">
3 <view class="view flex avatar-block"> 4 <view class="view flex avatar-block">
4 <view class="view avatar"> 5 <view class="view avatar">
5 - <image src="" class="avatar-image" mode="aspectFill" lazy-load></image>  
6 - <view class="avatar-txt text-white text-xs text-center">111</view> 6 + <image src="{{seller.seller_image?seller.seller_image+'?imageView2/2/w/320/interlace/0/q/100':'http://nosqn.colorcun.com/reserve/images/3x/%E6%9A%82%E6%97%A0.png'}}" class="avatar-image" mode="aspectFill" lazy-load></image>
  7 + <view class="avatar-txt text-white text-xs text-center" wx:if="{{seller.brand.name}}">{{seller.brand.name}}</view>
7 </view> 8 </view>
8 <view class="view detail margin-left-sm flex-treble margin-top-sm"> 9 <view class="view detail margin-left-sm flex-treble margin-top-sm">
9 <view class="view flex align-center justify-between" style="height: 52rpx;"> 10 <view class="view flex align-center justify-between" style="height: 52rpx;">
10 - <view class="title">123{{seller.seller_name}}</view>  
11 - <view class="text-gray" style="font-size: 26rpx;">123</view> 11 + <view class="title">{{seller.sellername}}</view>
  12 + <view class="text-gray" style="font-size: 26rpx;">{{util.distance(seller.distance||seller.distance_centre)}}</view>
12 </view> 13 </view>
13 <view class="view flex align-center text-gray margin-top-xs" style="height: 36rpx;"> 14 <view class="view flex align-center text-gray margin-top-xs" style="height: 36rpx;">
14 - <view class="caixi">123{{seller.seller_name}}</view> 15 + <view class="caixi flex">
  16 + <view class="caixi-item" wx:for="{{seller.cate}}" wx:key="sellercatekey" wx:if="{{index<3}}">{{item.name}}</view>
  17 + </view>
15 <view class="renjun flex margin-left-lg align-center"> 18 <view class="renjun flex margin-left-lg align-center">
16 <view class="text-22">¥</view> 19 <view class="text-22">¥</view>
17 - <view class="text-26" style="margin: 0 4rpx;">123</view> 20 + <view class="text-26" style="margin: 0 4rpx;">{{seller.average}}</view>
18 <view class="text-22">/人</view> 21 <view class="text-22">/人</view>
19 </view> 22 </view>
20 </view> 23 </view>
21 <view class="view flex align-center margin-top-xs active" style="height: 36rpx;"> 24 <view class="view flex align-center margin-top-xs active" style="height: 36rpx;">
22 - <view class="cu-tag line-yellow text-orange view">123</view>  
23 - <view class="cu-tag view">123</view>  
24 - <view class="cu-tag view">123</view>  
25 - <view class="cu-tag view">123</view> 25 + <block wx:for="{{seller.activity}}" wx:key="selleractivitykey" wx:if="{{index<3}}">
  26 + <view class="cu-tag line-yellow text-orange view">{{item.title}}</view>
  27 + </block>
26 </view> 28 </view>
27 </view> 29 </view>
28 </view> 30 </view>
29 <view class="view flex align-center justify-between margin-top-sm reserve-view"> 31 <view class="view flex align-center justify-between margin-top-sm reserve-view">
30 <view class="view rooms flex-treble flex" style="overflow-x: auto"> 32 <view class="view rooms flex-treble flex" style="overflow-x: auto">
31 - <view class="cu-tag round line-blue text-blue view">123</view>  
32 - <view class="cu-tag round line-blue text-blue view">123</view>  
33 - <view class="cu-tag round line-blue text-blue view">123</view>  
34 - <view class="cu-tag round line-blue text-blue view">123</view>  
35 - <view class="cu-tag round line-blue text-blue view">123</view>  
36 - <view class="cu-tag round line-blue text-blue view">123</view>  
37 - <view class="cu-tag round line-blue text-blue view">123</view>  
38 - <view class="cu-tag round line-blue text-blue view">123</view>  
39 - <view class="cu-tag round line-blue text-blue view">123</view>  
40 - <view class="cu-tag round line-blue text-blue view">123</view>  
41 - <view class="cu-tag round view cu-tag-end"></view> 33 + <block wx:for="{{seller.class}}" wx:key="se-class">
  34 + <view class="cu-tag round line-blue text-blue view">{{item.name}}</view>
  35 + </block>
  36 + <view class="cu-tag round line-white text-blue view cu-tag-end"></view>
42 </view> 37 </view>
43 <view class="view button-view flex justify-end"> 38 <view class="view button-view flex justify-end">
44 - <view class="cu-btn bg-blue text-white round reserve-button text-df text-bold view">111</view> 39 + <view class="cu-btn bg-blue text-white round reserve-button text-df text-bold view padding-xs">订包间</view>
45 </view> 40 </view>
46 </view> 41 </view>
47 </view> 42 </view>
@@ -7,6 +7,9 @@ @@ -7,6 +7,9 @@
7 border-radius: 20rpx; 7 border-radius: 20rpx;
8 position: relative; 8 position: relative;
9 } 9 }
  10 +.seller.active{
  11 + border: 2rpx solid #FFC9AA;
  12 +}
10 .avatar{ 13 .avatar{
11 position: relative; 14 position: relative;
12 } 15 }
@@ -87,6 +90,9 @@ @@ -87,6 +90,9 @@
87 content: ""; 90 content: "";
88 display: block; 91 display: block;
89 } 92 }
  93 +.seller.active .button-view:after{
  94 + top:-26rpx;
  95 +}
90 .reserve-button{ 96 .reserve-button{
91 width: 124rpx; 97 width: 124rpx;
92 height: 56rpx; 98 height: 56rpx;
@@ -6,6 +6,7 @@ const {regeneratorRuntime} = global @@ -6,6 +6,7 @@ const {regeneratorRuntime} = global
6 const mapScale = 15//18; 6 const mapScale = 15//18;
7 const def_latitude = 39.684670; 7 const def_latitude = 39.684670;
8 const def_longitude = 118.176300; 8 const def_longitude = 118.176300;
  9 +const cates_version = '?1.2';
9 Page({ 10 Page({
10 data:{ 11 data:{
11 map:{}, 12 map:{},
@@ -80,6 +81,196 @@ Page({ @@ -80,6 +81,196 @@ Page({
80 return; 81 return;
81 } 82 }
82 }, 83 },
  84 + debounceTimer:null,
  85 + debounce(func,wait){
  86 + if(this.debounceTimer){
  87 + clearTimeout(this.debounceTimer)
  88 + }
  89 + this.debounceTimer=setTimeout(()=>{
  90 + this.debounceTimer=null;
  91 + func()
  92 + },wait);
  93 + },
  94 + regionChange(e){
  95 + if(e.type=='end'){
  96 + console.log('regionChange', e)
  97 + this.debounce(this.regionChangeDo,800)
  98 + }
  99 + },
  100 + mapCtx:null,
  101 + mapData: {
  102 + latitude: 0,
  103 + longitude: 0,
  104 + scale: 30,
  105 + hasRegionchange: false,
  106 + region: {
  107 + southwest: {},
  108 + northeast: {},
  109 + },
  110 + },
  111 + regionChangeDo(){
  112 + console.log('regionChangeDo')
  113 + if(!this.mapCtx){
  114 + this.mapCtx = wx.createMapContext('map')
  115 + }
  116 + if(!this.mapCtx) return;
  117 + this.mapCtx.getRegion({
  118 + success: (res) => {
  119 + this.hasClickMoveToLocation = false
  120 + if (res.southwest.latitude) {
  121 + this.mapData.region = res
  122 + }
  123 + ;
  124 + this.getSellers();
  125 + },
  126 + })
  127 + },
  128 + hasSellers:0,
  129 + sellers:[],
  130 + getSellers(){
  131 + console.log('getSellers',this.mapScale,this.mapData)
  132 + let param = {
  133 + lat: this.user.latitude == def_latitude ? '' : this.user.latitude,
  134 + lng: this.user.longitude == def_longitude ? '' : this.user.longitude,
  135 + offset: 0,
  136 + rows: 100,
  137 + distance: 100000,
  138 + map: JSON.stringify({...this.mapData.region, scale: 50})
  139 + }
  140 + if (param.lat) {
  141 + param.centre_pos = `${param.lat},${param.lng}`
  142 + } else {
  143 + let lat = (this.mapData.region.southwest.latitude + this.mapData.region.northeast.latitude) / 2
  144 + let lng = (this.mapData.region.southwest.longitude + this.mapData.region.northeast.longitude) / 2
  145 + param.centre_pos = `${lat},${lng}`
  146 + }
  147 + /*
  148 + if (this.data.multiIndex[0] > 0) {
  149 + param.cuisine = await DA.getCatesID(this.data.multiIndex[0] - 1);
  150 + }
  151 + let tags = [];
  152 + this.data.tags.forEach(t => {
  153 + if (t.active) {
  154 + tags.push(t.id)
  155 + }
  156 + })
  157 + if (tags.length > 0) {
  158 + param.tags = tags;
  159 + }
  160 + if (param.lat) {
  161 + param.centre_pos = `${param.lat},${param.lng}`
  162 + } else {
  163 + let lat = (this.mapData.region.southwest.latitude + this.mapData.region.northeast.latitude) / 2
  164 + let lng = (this.mapData.region.southwest.longitude + this.mapData.region.northeast.longitude) / 2
  165 + param.centre_pos = `${lat},${lng}`
  166 + }
  167 + if (this.data.hasSuggestion) {
  168 + param.centre_pos = `${this.data.suggestion.latitude},${this.data.suggestion.longitude}`
  169 + }
  170 + if (this.findSellerData) {
  171 + param = Object.assign(param, this.findSellerData.paramObj)
  172 + }
  173 + if (this.filterParams) {//人均过滤
  174 + let filterParams = this.filterParams.min + ',' + this.filterParams.max
  175 + if (this.filterParams.min == this.filterParams.max && this.filterParams.min == 300) {
  176 + filterParams = this.filterParams.min + ',' + parseInt(new Date() / 1000)
  177 + }
  178 + param.average = filterParams
  179 + }
  180 + */
  181 + //this.selectComponent('#list').getList(param);
  182 + this.param = param;
  183 + App.Customer.SellerList(param).then(async res => {
  184 + if (res.ret == 200) {
  185 + this.hasSellers=res.data.flag
  186 + this.sellers=res.data.list
  187 + this.makeMarker();
  188 + this.makeSellers();
  189 + }
  190 + })
  191 +
  192 + },
  193 + makeMarker(){
  194 + this.mapCtx.getScale({
  195 + success: (res) => {
  196 + this.mapData.scale = res.scale;
  197 + let markers=[]
  198 + let sellersLength=this.sellers.length
  199 + this.sellers.forEach((seller,si)=>{
  200 + let marker = {
  201 + id: seller.id,
  202 + iconPath: "http://nosqn.colorcun.com/custom/lite-online/cates/circle1x5.png" + cates_version,
  203 + latitude: seller.lat,
  204 + longitude: seller.long,
  205 + width: 8,
  206 + height: 8,
  207 + //title:seller.seller_name,
  208 + zIndex: sellersLength - si,
  209 + zIndexBak: sellersLength - si,
  210 + //seller: seller,
  211 + };
  212 + if (seller.mode.length > 0) {
  213 + seller.mode.forEach(x => {
  214 + if (x.id == 1) {//大图标
  215 + marker.iconPath = "http://nosqn.colorcun.com/custom/lite-online/cates/其他菜品.png";
  216 + if (seller.cate.length > 0) {
  217 + marker.iconPath = seller.cate[0].icon
  218 + }
  219 + marker.iconPath = marker.iconPath.replace(/\/cates\/(.*)\.png/, function ($0, $1) {
  220 + return '/cates/' + encodeURI($1) + '.png'
  221 + })
  222 + marker.iconPath += cates_version
  223 + marker.width = 20;
  224 + marker.height = 25;
  225 + }
  226 + })
  227 + }
  228 + markers.push(marker)
  229 + })
  230 + this.setData({
  231 + markers:markers,
  232 + })
  233 + },
  234 + })
  235 + },
  236 + makeSellers(){
  237 + this.setData({
  238 + sellers:this.sellers,
  239 + })
  240 + },
  241 + markertap(e){
  242 + let markers=this.data.markers
  243 + this.activeSellerID = e.markerId
  244 + let bl = 1.2;
  245 + markers.forEach((m, i) => {
  246 + m.iconPath = m.iconPath.replace('/cates-active/', '/cates/')
  247 + m.zIndex = m.zIndexBak
  248 + if (m.width == 20 * bl) {
  249 + m.width = 20;
  250 + m.height = 25;
  251 + }
  252 + if (m.width == 12) {
  253 + m.width = 8;
  254 + m.height = 8;
  255 + }
  256 + if (m.id == e.markerId) {
  257 + m.iconPath = m.iconPath.replace('/cates/', '/cates-active/')
  258 + if (m.width == 20) {
  259 + m.width = 20 * bl;
  260 + m.height = 25 * bl;
  261 + } else {
  262 + m.width = 12;
  263 + m.height = 12;
  264 + }
  265 + m.zIndex = 9999
  266 + }
  267 + })
  268 + let obj = {
  269 + markers: markers,
  270 + activeSellerID:this.activeSellerID,
  271 + };
  272 + this.setData(obj)
  273 + },
83 back:function() { 274 back:function() {
84 /* 275 /*
85 var mta = require('mta-wechat-analysis') 276 var mta = require('mta-wechat-analysis')
@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 markers="{{markers}}" polygons="{{polygons}}" 4 markers="{{markers}}" polygons="{{polygons}}"
5 bindmarkertap="markertap" 5 bindmarkertap="markertap"
6 bindcallouttap="markertap" 6 bindcallouttap="markertap"
7 - bindregionchange="regionchange" 7 + bindregionchange="regionChange"
8 bindupdated="mapUpdated" 8 bindupdated="mapUpdated"
9 show-location="{{false}}" 9 show-location="{{false}}"
10 enable-3D="{{false}}" 10 enable-3D="{{false}}"
@@ -17,7 +17,9 @@ @@ -17,7 +17,9 @@
17 <view class="view content" style="height: {{height}}px;"> 17 <view class="view content" style="height: {{height}}px;">
18 <filter-group height="{{height}}"></filter-group> 18 <filter-group height="{{height}}"></filter-group>
19 <scroll-view class="view scroll-view" scroll-y="true" bindscroll="scroll" style="width:100%;height: {{height-50}}px;"> 19 <scroll-view class="view scroll-view" scroll-y="true" bindscroll="scroll" style="width:100%;height: {{height-50}}px;">
20 - <seller-card class="seller-card" seller="{{item}}" wx:for="{{['','','','']}}" wx:key="sellers"></seller-card> 20 + <seller-card class="seller-card"
  21 + activeSellerID="{{activeSellerID}}"
  22 + seller="{{item}}" wx:for="{{sellers}}" wx:key="sellers"></seller-card>
21 <view class="view" style="height: 192rpx;"></view> 23 <view class="view" style="height: 192rpx;"></view>
22 </scroll-view> 24 </scroll-view>
23 </view> 25 </view>
@@ -25,10 +27,12 @@ @@ -25,10 +27,12 @@
25 <view bindtap="moveToLocation" class="view moveToLocation flex align-center justify-center"> 27 <view bindtap="moveToLocation" class="view moveToLocation flex align-center justify-center">
26 <image class="moveToLocation-image" src="http://nosqn.colorcun.com/2.0/home%20%2811%29.png"></image> 28 <image class="moveToLocation-image" src="http://nosqn.colorcun.com/2.0/home%20%2811%29.png"></image>
27 </view> 29 </view>
28 -<view class="me view flex flex-direction align-center justify-center bg-white round">  
29 - <view class="icon view"></view>  
30 - <view class="text">我的</view>  
31 -</view> 30 +<navigator url="/pages/me/index" hover-class="navigator-hover">
  31 + <view class="me view flex flex-direction align-center justify-center bg-white round">
  32 + <view class="icon view"></view>
  33 + <view class="text">我的</view>
  34 + </view>
  35 +</navigator>
32 <!-- 36 <!--
33 37
34 <view class="toast" wx:if="{{hasGetSellersEnd && listMoreCount<1 && !hasSearchLimit}}">该地区没有可供预订的餐厅哦!努力开通中</view> 38 <view class="toast" wx:if="{{hasGetSellersEnd && listMoreCount<1 && !hasSearchLimit}}">该地区没有可供预订的餐厅哦!努力开通中</view>