Commit 25cf202326af9c64b9b57c80a881cd5f054d0d18
1 parent
3a93e45f
取货门店的默认效果,加入购物车的提示小效果
Showing
5 changed files
with
28 additions
and
33 deletions
app.js
... | ... | @@ -284,9 +284,9 @@ App({ |
284 | 284 | }, |
285 | 285 | |
286 | 286 | //显示提示,word提示内容,type 0失败,提示 1成功 |
287 | - my_warnning(word,type,that){ | |
287 | + my_warnning(word,type,that,width){ | |
288 | 288 | var warn = that.selectComponent("#warn"); //组件的id |
289 | - warn.open(word,type); | |
289 | + warn.open(word,type,width); | |
290 | 290 | return 1; |
291 | 291 | }, |
292 | 292 | ... | ... |
components/long_warn/long_warn.js
... | ... | @@ -8,12 +8,17 @@ Component({ |
8 | 8 | is_show:0, |
9 | 9 | type:0, //0 提示,失败 1成功 |
10 | 10 | iurl:t.globalData.setting.imghost, |
11 | + width:0, | |
11 | 12 | }, |
12 | 13 | |
13 | 14 | methods: { |
14 | - open:function (e,type) { | |
15 | + open:function (e,type,width) { | |
15 | 16 | var that=this; |
16 | - this.setData({is_show:1,val:e,type:type}); | |
17 | + if(width!=undefined) { | |
18 | + this.setData({is_show:1,val:e,type:type,width:width}); | |
19 | + }else{ | |
20 | + this.setData({is_show:1,val:e,type:type}); | |
21 | + } | |
17 | 22 | setTimeout(function () { |
18 | 23 | that.setData({is_show:0}); |
19 | 24 | },2000); | ... | ... |
components/long_warn/long_warn.wxml
1 | 1 | <view class="rim" wx:if="{{is_show}}"> |
2 | 2 | <view class="content flex-center"> |
3 | - <view class="con_view"> | |
3 | + <view class="con_view" style="width:{{width>0?width+'rpx':'auto'}}"> | |
4 | 4 | <view class="con_view_img"> |
5 | 5 | <image wx:if="{{type}}" src="{{iurl}}/miniapp/images/sucess_g.png"></image><!-- 成功 --> |
6 | 6 | <image wx:else src="{{iurl}}/miniapp/images/gt.png"></image> <!-- 失败 --> | ... | ... |
pages/goods/goodsInfo/goodsInfo.js
... | ... | @@ -274,15 +274,14 @@ Page({ |
274 | 274 | var w_time=setInterval(function () { |
275 | 275 | if(that.data.is_get_local_ok==0) return false; |
276 | 276 | var distance=null; |
277 | - if( that.data.lat!=null){ | |
278 | - distance=Math.sqrt(e.lat*th.data.lat+e.lon*th.data.lon); | |
277 | + if( that.data.lat!=null && e.distance==undefined){ | |
278 | + //distance=Math.sqrt((e.lat-th.data.lat)*(e.lat-th.data.lat)+(e.lon-th.data.lon)* (e.lon-th.data.lon)); | |
279 | + var distance=ut.getDistance(e.lat,th.data.lat,e.lon,th.data.lon); | |
279 | 280 | e.distance=distance; |
280 | 281 | } |
281 | - console.log(e,"def_pick_store,刷新进来") | |
282 | 282 | 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}) |
283 | 283 | clearInterval(w_time); |
284 | 284 | },500) |
285 | - | |
286 | 285 | }) |
287 | 286 | |
288 | 287 | |
... | ... | @@ -765,7 +764,6 @@ Page({ |
765 | 764 | //-------如果购物车中有相关的数据--------- |
766 | 765 | if (re.data.data.total > 0) { |
767 | 766 | var item = re.data.data.pageData[0]; |
768 | - | |
769 | 767 | var updata = { |
770 | 768 | id: item.id, |
771 | 769 | goods_num: e.data.goodsInputNum + item.goods_num, |
... | ... | @@ -775,34 +773,14 @@ Page({ |
775 | 773 | i.put("/api/weshop/cart/update", { |
776 | 774 | data: updata, |
777 | 775 | success: function(t) { |
778 | - getApp().my_warnning(' 加入购物车成功 ', 1, th); | |
779 | - // wx.showModal({ | |
780 | - // title: "添加成功!", | |
781 | - // cancelText: "去购物车", | |
782 | - // confirmText: "再逛逛", | |
783 | - // success: function(t) { | |
784 | - // t.cancel ? wx.switchTab({ | |
785 | - // url: "/pages/cart/cart/cart" | |
786 | - // }) : e.requestCardNum(); | |
787 | - // } | |
788 | - // }); | |
776 | + getApp().my_warnning('加入购物车成功', 1, th,450); | |
789 | 777 | } |
790 | 778 | }); |
791 | 779 | } else { |
792 | 780 | i.post("/api/weshop/cart/save", { |
793 | 781 | data: newd, |
794 | 782 | success: function(t) { |
795 | - getApp().my_warnning(' 加入购物车成功 ', 1, th); | |
796 | - // wx.showModal({ | |
797 | - // title: "添加成功!", | |
798 | - // cancelText: "去购物车", | |
799 | - // confirmText: "再逛逛", | |
800 | - // success: function(t) { | |
801 | - // t.cancel ? wx.switchTab({ | |
802 | - // url: "/pages/cart/cart/cart" | |
803 | - // }) : e.requestCardNum(); | |
804 | - // } | |
805 | - // }); | |
783 | + getApp().my_warnning('加入购物车成功', 1, th,450); | |
806 | 784 | } |
807 | 785 | }); |
808 | 786 | } | ... | ... |
utils/util.js
... | ... | @@ -248,6 +248,18 @@ function check_mobile(phoneMobile){ |
248 | 248 | return ob; |
249 | 249 | } |
250 | 250 | |
251 | +function getDistance(lat1, lng1, lat2, lng2){ | |
252 | + var radLat1 = lat1*Math.PI / 180.0; | |
253 | + var radLat2 = lat2*Math.PI / 180.0; | |
254 | + var a = radLat1 - radLat2; | |
255 | + var b = lng1*Math.PI / 180.0 - lng2*Math.PI / 180.0; | |
256 | + var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a/2),2) + | |
257 | + Math.cos(radLat1)*Math.cos(radLat2)*Math.pow(Math.sin(b/2),2))); | |
258 | + s = s *6378.137 ;// EARTH_RADIUS; | |
259 | + return s; | |
260 | +} | |
261 | + | |
262 | + | |
251 | 263 | module.exports = { |
252 | 264 | formatTime: function(e, r) { |
253 | 265 | 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 = { |
337 | 349 | sub_last: sub_last,//去掉末尾一个字符 |
338 | 350 | measureText: measureText,//画布需要的函数 |
339 | 351 | check_mobile: check_mobile,//验证手机 |
340 | - | |
352 | + getDistance:getDistance //获取俩个经纬网度之间的距离 | |
341 | 353 | }; | ... | ... |