From 25cf202326af9c64b9b57c80a881cd5f054d0d18 Mon Sep 17 00:00:00 2001 From: yvan.ni <765199919@qq.com> Date: Thu, 26 Sep 2019 17:14:16 +0800 Subject: [PATCH] 取货门店的默认效果,加入购物车的提示小效果 --- app.js | 4 ++-- components/long_warn/long_warn.js | 9 +++++++-- components/long_warn/long_warn.wxml | 2 +- pages/goods/goodsInfo/goodsInfo.js | 32 +++++--------------------------- utils/util.js | 14 +++++++++++++- 5 files changed, 28 insertions(+), 33 deletions(-) diff --git a/app.js b/app.js index 5ccdd67..aa6d577 100644 --- a/app.js +++ b/app.js @@ -284,9 +284,9 @@ App({ }, //显示提示,word提示内容,type 0失败,提示 1成功 - my_warnning(word,type,that){ + my_warnning(word,type,that,width){ var warn = that.selectComponent("#warn"); //组件的id - warn.open(word,type); + warn.open(word,type,width); return 1; }, diff --git a/components/long_warn/long_warn.js b/components/long_warn/long_warn.js index 00bb68f..0431c7a 100644 --- a/components/long_warn/long_warn.js +++ b/components/long_warn/long_warn.js @@ -8,12 +8,17 @@ Component({ is_show:0, type:0, //0 提示,失败 1成功 iurl:t.globalData.setting.imghost, + width:0, }, methods: { - open:function (e,type) { + open:function (e,type,width) { var that=this; - this.setData({is_show:1,val:e,type:type}); + if(width!=undefined) { + this.setData({is_show:1,val:e,type:type,width:width}); + }else{ + this.setData({is_show:1,val:e,type:type}); + } setTimeout(function () { that.setData({is_show:0}); },2000); diff --git a/components/long_warn/long_warn.wxml b/components/long_warn/long_warn.wxml index ebd4096..2eef76d 100644 --- a/components/long_warn/long_warn.wxml +++ b/components/long_warn/long_warn.wxml @@ -1,6 +1,6 @@ - + diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index c19d96a..d565aaf 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -274,15 +274,14 @@ Page({ var w_time=setInterval(function () { if(that.data.is_get_local_ok==0) return false; var distance=null; - if( that.data.lat!=null){ - distance=Math.sqrt(e.lat*th.data.lat+e.lon*th.data.lon); + if( that.data.lat!=null && e.distance==undefined){ + //distance=Math.sqrt((e.lat-th.data.lat)*(e.lat-th.data.lat)+(e.lon-th.data.lon)* (e.lon-th.data.lon)); + var distance=ut.getDistance(e.lat,th.data.lat,e.lon,th.data.lon); e.distance=distance; } - console.log(e,"def_pick_store,刷新进来") if(e) that.setData({def_pick_store:e,sto_sele_name:e.pickup_name,sto_sele_id:e.pickup_id,sto_sele_distr:e.distr_type}) clearInterval(w_time); },500) - }) @@ -765,7 +764,6 @@ Page({ //-------如果购物车中有相关的数据--------- if (re.data.data.total > 0) { var item = re.data.data.pageData[0]; - var updata = { id: item.id, goods_num: e.data.goodsInputNum + item.goods_num, @@ -775,34 +773,14 @@ Page({ i.put("/api/weshop/cart/update", { data: updata, success: function(t) { - getApp().my_warnning(' 加入购物车成功 ', 1, th); - // wx.showModal({ - // title: "添加成功!", - // cancelText: "去购物车", - // confirmText: "再逛逛", - // success: function(t) { - // t.cancel ? wx.switchTab({ - // url: "/pages/cart/cart/cart" - // }) : e.requestCardNum(); - // } - // }); + getApp().my_warnning('加入购物车成功', 1, th,450); } }); } else { i.post("/api/weshop/cart/save", { data: newd, success: function(t) { - getApp().my_warnning(' 加入购物车成功 ', 1, th); - // wx.showModal({ - // title: "添加成功!", - // cancelText: "去购物车", - // confirmText: "再逛逛", - // success: function(t) { - // t.cancel ? wx.switchTab({ - // url: "/pages/cart/cart/cart" - // }) : e.requestCardNum(); - // } - // }); + getApp().my_warnning('加入购物车成功', 1, th,450); } }); } diff --git a/utils/util.js b/utils/util.js index 9d1d4a5..53015ab 100644 --- a/utils/util.js +++ b/utils/util.js @@ -248,6 +248,18 @@ function check_mobile(phoneMobile){ return ob; } +function getDistance(lat1, lng1, lat2, lng2){ + var radLat1 = lat1*Math.PI / 180.0; + var radLat2 = lat2*Math.PI / 180.0; + var a = radLat1 - radLat2; + var b = lng1*Math.PI / 180.0 - lng2*Math.PI / 180.0; + var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) + + Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2))); + s = s *6378.137 ;// EARTH_RADIUS; + return s; +} + + module.exports = { formatTime: function(e, r) { var t = e ? new Date(1e3 * e) : new Date(), n = t.getFullYear(), o = t.getMonth() + 1, a = t.getDate(), u = t.getHours(), i = t.getMinutes(), f = t.getSeconds(), s = function(e) { @@ -337,5 +349,5 @@ module.exports = { sub_last: sub_last,//去掉末尾一个字符 measureText: measureText,//画布需要的函数 check_mobile: check_mobile,//验证手机 - + getDistance:getDistance //获取俩个经纬网度之间的距离 }; -- libgit2 0.21.4