Commit a87d33389fdef4a95b378f6ac9caba751d424d06

Authored by yvan.ni
1 parent 0f5046ac

1、小程序计算距离,要调用接口而不是用js计算

2、会员资料分享事件
pages/goods/goodsInfo/goodsInfo.js
... ... @@ -231,13 +231,13 @@ Page({
231 231 comments_no_more:0,
232 232 get_c:0, //获取评价是不是成
233 233 is_collect_load:0, //是不是处理
  234 + is_newsales_rules:0, //是否开启最新的门店规则,此时会新读门店,当点击选择门店时会触发读取线下库存
  235 + sales_rules:1, //默认是线上销售
234 236 },
235 237  
236 238 //------初始化加载----------
237 239 onLoad: function(t) {
238 240  
239   -
240   -
241 241 wx.setNavigationBarTitle({
242 242 title: "商品详情",
243 243 })
... ... @@ -251,14 +251,13 @@ Page({
251 251 if (gid == undefined || gid == null || gid == "") {
252 252 gid = decodeURIComponent(t.scene);
253 253 }
254   - ee.setData({
255   - gid: gid
256   - });
  254 + ee.setData({ gid: gid});
257 255  
258 256 //----获取系统参数-----
259 257 getApp().getConfig2(function(e) {
260 258 ee.setData({
261   - bconfig: e
  259 + bconfig: e,
  260 + sales_rules:e.sales_rules
262 261 });
263 262  
264 263 if (e.categoryset.indexOf("," + 1 + ",") != -1) {
... ... @@ -280,7 +279,8 @@ Page({
280 279 var json_d = JSON.parse(e.switch_list);
281 280 ee.setData({
282 281 store_config: e,
283   - is_closecoupon: json_d.is_closecoupon
  282 + is_closecoupon: json_d.is_closecoupon,
  283 + is_newsales_rules:json_d.is_newsales_rules
284 284 });
285 285 ee.init(gid);
286 286 //------几人评价-------
... ... @@ -339,21 +339,65 @@ Page({
339 339 //获取用户的默认门店
340 340 getApp().get_user_store(function(e) {
341 341 if(!e) return false;
  342 + var appd=getApp().globalData;
342 343 var w_time = setInterval(function() {
343 344 if (that.data.is_get_local_ok == 0) return false;
  345 + clearInterval(w_time);
344 346 var distance = null;
345   - if (that.data.lat != null && e.distance == undefined) {
346   - //distance=Math.sqrt((e.lat-th.data.lat)*(e.lat-th.data.lat)+(e.lon-th.data.lon)* (e.lon-th.data.lon));
347   - var distance = ut.getDistance(e.lat, th.data.lat, e.lon, th.data.lon);
348   - e.distance = distance;
349   - }
350   - if (e) that.setData({
351   - def_pick_store: e,
352   - sto_sele_name: e.pickup_name,
353   - sto_sele_id: e.pickup_id,
354   - sto_sele_distr: e.distr_type
355   - })
356   - clearInterval(w_time);
  347 +
  348 + //如果有开启近距离的话,同时距离优不一样了
  349 + if (that.data.lat != null) {
  350 + //如果经纬度有变化的话
  351 + if( appd.lat==that.data.lat && appd.lon==that.data.lon && e.distance>0 ){
  352 + that.setData({
  353 + def_pick_store: e,
  354 + sto_sele_name: e.pickup_name,
  355 + sto_sele_id: e.pickup_id,
  356 + sto_sele_distr: e.distr_type
  357 + })
  358 + }else{
  359 + //要用接口是获取距离,js的计算不准
  360 + getApp().request.get("/api/weshop/pickup/list",{
  361 + data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon},
  362 + success:function (res) {
  363 + if(res.data.code==0){
  364 + e=res.data.data.pageData[0];
  365 + if (e){
  366 + appd.pk_store=e;
  367 + that.setData({
  368 + def_pick_store: e,
  369 + sto_sele_name: e.pickup_name,
  370 + sto_sele_id: e.pickup_id,
  371 + sto_sele_distr: e.distr_type
  372 + })
  373 + }
  374 +
  375 +
  376 +
  377 + }
  378 + }
  379 + })
  380 + }
  381 +
  382 + //e.distance = distance;
  383 + appd.lat=that.data.lat;
  384 + appd.lon=that.data.lon;
  385 +
  386 + }else{
  387 + if (e) {
  388 + e.distance = null;
  389 + that.setData({
  390 + def_pick_store: e,
  391 + sto_sele_name: e.pickup_name,
  392 + sto_sele_id: e.pickup_id,
  393 + sto_sele_distr: e.distr_type
  394 + })
  395 + }
  396 +
  397 +
  398 + }
  399 +
  400 +
357 401 }, 500)
358 402 });
359 403  
... ... @@ -1356,6 +1400,12 @@ Page({
1356 1400 }
1357 1401 e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加
1358 1402 }
  1403 +
  1404 + //--获取线下库存--
  1405 + if(this.data.sales_rules){
  1406 +
  1407 + }
  1408 +
1359 1409  
1360 1410 //单总量超出5个的时候
1361 1411 if (e.data.data.total > 5) {
... ...
pages/user/userinfo/userinfo.js
... ... @@ -838,6 +838,11 @@ Page({
838 838 });
839 839 getApp().goto(url);
840 840 },
  841 +
  842 + //--点击分享事件---
  843 + onShareAppMessage: function(t) {
  844 + return o.share;
  845 + },
841 846  
842 847  
843 848 });
844 849 \ No newline at end of file
... ...