Commit 7d200411018e3419beb5bdabfa461562ce6d009c
1 parent
c445af20
显示购物车数量的函数
Showing
1 changed file
with
25 additions
and
2 deletions
app.js
@@ -47,7 +47,6 @@ App({ | @@ -47,7 +47,6 @@ App({ | ||
47 | app.globalData.user_id= app.globalData.userInfo.user_id; | 47 | app.globalData.user_id= app.globalData.userInfo.user_id; |
48 | } | 48 | } |
49 | } | 49 | } |
50 | - | ||
51 | }, | 50 | }, |
52 | 51 | ||
53 | //---初始化第三方---- | 52 | //---初始化第三方---- |
@@ -58,6 +57,8 @@ App({ | @@ -58,6 +57,8 @@ App({ | ||
58 | var t = wx.getExtConfigSync(), o = this.globalData.setting; | 57 | var t = wx.getExtConfigSync(), o = this.globalData.setting; |
59 | console.log(t); | 58 | console.log(t); |
60 | t.appName ? (o.appName = t.appName, o.stoid = t.stoid) : tt=1; | 59 | t.appName ? (o.appName = t.appName, o.stoid = t.stoid) : tt=1; |
60 | + | ||
61 | + | ||
61 | }, | 62 | }, |
62 | 63 | ||
63 | //首页的第一次登录 | 64 | //首页的第一次登录 |
@@ -287,6 +288,28 @@ App({ | @@ -287,6 +288,28 @@ App({ | ||
287 | var warn = that.selectComponent("#warn"); //组件的id | 288 | var warn = that.selectComponent("#warn"); //组件的id |
288 | warn.open(word,type); | 289 | warn.open(word,type); |
289 | return 1; | 290 | return 1; |
290 | - } | 291 | + }, |
292 | + | ||
293 | + | ||
294 | + //-------获取购物车数量---------- | ||
295 | + requestCardNum: function() { | ||
296 | + var th = this; | ||
297 | + th.request.get("/api/weshop/cart/page", { | ||
298 | + data: { | ||
299 | + store_id: th.globalData.setting.stoid, | ||
300 | + user_id: th.globalData.user_id, | ||
301 | + }, | ||
302 | + success: function(e) { | ||
303 | + var num = 0; | ||
304 | + for (var i = 0; i < e.data.data.pageData.length; i++) { | ||
305 | + num += e.data.data.pageData[i].goods_num; | ||
306 | + } | ||
307 | + wx.setTabBarBadge({ //tabbar右上角添加文本 | ||
308 | + index: 2, ////tabbar下标 | ||
309 | + text: '' + num //显示的内容 | ||
310 | + }); | ||
311 | + } | ||
312 | + }); | ||
313 | + }, | ||
291 | 314 | ||
292 | }); | 315 | }); |