Commit 24041c26d78f5b8455ce08e33a82648a975ee04e
1 parent
1f429d3f
啦一下,压缩代码
Showing
5 changed files
with
31 additions
and
69 deletions
app.js
| ... | ... | @@ -1042,17 +1042,31 @@ App({ |
| 1042 | 1042 | }, |
| 1043 | 1043 | |
| 1044 | 1044 | //获取佣金的比例 |
| 1045 | - get_commission(first_money,second_money,third_money,th) { | |
| 1045 | + get_commission(dis_config,gd_data,goods_num) { | |
| 1046 | + | |
| 1047 | + var fir_num=0; | |
| 1048 | + var sec_num=0; | |
| 1049 | + var thi_num=0; | |
| 1050 | + if(dis_config.pattern==1){ | |
| 1051 | + fir_num=(gd_data.fir_rate || 0)*goods_num; | |
| 1052 | + sec_num=(gd_data.sec_rate || 0)*goods_num; | |
| 1053 | + thi_num=(gd_data.thi_rate || 0)*goods_num; | |
| 1054 | + }else{ | |
| 1055 | + fir_num=parseFloat((gd_data.commission || 0) *goods_num*(dis_config.firstRate || 0)/100).toFixed(2); | |
| 1056 | + sec_num=parseFloat((gd_data.commission || 0)*goods_num*(dis_config.secondRate || 0)/100).toFixed(2); | |
| 1057 | + thi_num=parseFloat((gd_data.commission || 0)*goods_num*(dis_config.thirdRate || 0)/100).toFixed(2); | |
| 1058 | + } | |
| 1059 | + | |
| 1046 | 1060 | if(getApp().globalData.userInfo.is_distribut){ |
| 1047 | - var pattern = th.data.dis_config.pattern; // 分销模式 | |
| 1048 | - var first_rate = th.data.dis_config.first_rate; // 一级比例 | |
| 1049 | - var second_rate = th.data.dis_config.second_rate; // 二级比例 | |
| 1050 | - var third_rate = th.data.dis_config.third_rate; // 三级比例 | |
| 1061 | + var pattern = dis_config.pattern; // 分销模式 | |
| 1062 | + var first_rate = dis_config.first_rate; // 一级比例 | |
| 1063 | + var second_rate = dis_config.second_rate; // 二级比例 | |
| 1064 | + var third_rate = dis_config.third_rate; // 三级比例 | |
| 1051 | 1065 | |
| 1052 | 1066 | if(this.globalData.userInfo.first_leader){ |
| 1053 | 1067 | return parseFloat(parseFloat(first_money).toFixed(2)); |
| 1054 | 1068 | }else{ |
| 1055 | - return parseFloat((parseFloat(first_money)+parseFloat(second_money)+parseFloat(third_money)).toFixed(2)); | |
| 1069 | + return parseFloat((parseFloat(fir_num)+parseFloat(sec_num)+parseFloat(thi_num)).toFixed(2)); | |
| 1056 | 1070 | } |
| 1057 | 1071 | } |
| 1058 | 1072 | }, | ... | ... |
pages/cart/cart/cart.js
| ... | ... | @@ -50,13 +50,7 @@ Page({ |
| 50 | 50 | onLoad: function () { |
| 51 | 51 | var a = this, |
| 52 | 52 | ee = a; |
| 53 | - //----获取系统参数----- | |
| 54 | - // getApp().getConfig2(function (e) { | |
| 55 | - // ee.setData({ | |
| 56 | - // bconfig: e, | |
| 57 | - // sales_rules: e.sales_rules | |
| 58 | - // }); | |
| 59 | - // }) | |
| 53 | + | |
| 60 | 54 | |
| 61 | 55 | wx.setNavigationBarTitle({ |
| 62 | 56 | title: "购物车", |
| ... | ... | @@ -122,7 +116,7 @@ Page({ |
| 122 | 116 | enabled: 1 |
| 123 | 117 | } |
| 124 | 118 | }).then(res => { |
| 125 | - if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){ | |
| 119 | + if( ut.ajax_ok(res)){ | |
| 126 | 120 | var a = res.data.data.pageData; |
| 127 | 121 | var narr=[]; |
| 128 | 122 | for(var i in a){ |
| ... | ... | @@ -150,7 +144,7 @@ Page({ |
| 150 | 144 | getApp().request.promiseGet("/api/ms/flash_sale/spikepage", { |
| 151 | 145 | data: req_d, |
| 152 | 146 | }).then(res => { |
| 153 | - if (res.data.code == 0 && res.data.data && res.data.data.pageData.length > 0) { | |
| 147 | + if (ut.ajax_ok(res)) { | |
| 154 | 148 | th.setData({ |
| 155 | 149 | is_has_flash: 1 |
| 156 | 150 | }) |
| ... | ... | @@ -269,7 +263,7 @@ Page({ |
| 269 | 263 | |
| 270 | 264 | }, |
| 271 | 265 | }).then(res => { |
| 272 | - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) { | |
| 266 | + if(ut.ajax_ok2(res)) { | |
| 273 | 267 | by_map = {}; |
| 274 | 268 | for (let i in res.data.data) { |
| 275 | 269 | let item = res.data.data[i]; | ... | ... |
pages/cart/cart2/cart2.js
| ... | ... | @@ -1267,19 +1267,8 @@ Page({ |
| 1267 | 1267 | //-- 计算获得佣金的金额 -- |
| 1268 | 1268 | if( getApp().globalData.userInfo.is_distribut |
| 1269 | 1269 | && th.data.dis_config && th.data.dis_config.is_yongjin_dk){ |
| 1270 | - var fir_num=0; | |
| 1271 | - var sec_num=0; | |
| 1272 | - var thi_num=0; | |
| 1273 | - if(th.data.dis_config.pattern==1){ | |
| 1274 | - fir_num=(t.data.data.fir_rate || 0)*gg.goods_num; | |
| 1275 | - sec_num=(t.data.data.sec_rate || 0)*gg.goods_num; | |
| 1276 | - thi_num=(t.data.data.thi_rate || 0)*gg.goods_num; | |
| 1277 | - }else{ | |
| 1278 | - fir_num=parseFloat((t.data.data.commission || 0) *gg.goods_num*(th.data.dis_config.firstRate || 0)/100).toFixed(2); | |
| 1279 | - sec_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.secondRate || 0)/100).toFixed(2); | |
| 1280 | - thi_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.thirdRate || 0)/100).toFixed(2); | |
| 1281 | - } | |
| 1282 | - var c_num=getApp().get_commission(fir_num,sec_num,thi_num,th); | |
| 1270 | + | |
| 1271 | + var c_num=getApp().get_commission(th.data.dis_config,t.data.data,gg.goods_num); | |
| 1283 | 1272 | |
| 1284 | 1273 | gd.use_commission=c_num; |
| 1285 | 1274 | t.data.data.use_commission=c_num; |
| ... | ... | @@ -1327,19 +1316,8 @@ Page({ |
| 1327 | 1316 | //-- 计算获得佣金的金额 -- |
| 1328 | 1317 | if( getApp().globalData.userInfo.is_distribut |
| 1329 | 1318 | && th.data.dis_config && th.data.dis_config.is_yongjin_dk){ |
| 1330 | - var fir_num=0; | |
| 1331 | - var sec_num=0; | |
| 1332 | - var thi_num=0; | |
| 1333 | - if(th.data.dis_config.pattern==1){ | |
| 1334 | - fir_num=(t.data.data.fir_rate || 0)*gg.goods_num; | |
| 1335 | - sec_num=(t.data.data.sec_rate || 0)*gg.goods_num; | |
| 1336 | - thi_num=(t.data.data.thi_rate || 0)*gg.goods_num; | |
| 1337 | - }else{ | |
| 1338 | - fir_num=parseFloat((t.data.data.commission || 0) *gg.goods_num*(th.data.dis_config.firstRate || 0)/100).toFixed(2); | |
| 1339 | - sec_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.secondRate || 0)/100).toFixed(2); | |
| 1340 | - thi_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.thirdRate || 0)/100).toFixed(2); | |
| 1341 | - } | |
| 1342 | - var c_num=getApp().get_commission(fir_num,sec_num,thi_num,th); | |
| 1319 | + | |
| 1320 | + var c_num=getApp().get_commission(th.data.dis_config,t.data.data,gg.goods_num); | |
| 1343 | 1321 | |
| 1344 | 1322 | gd.use_commission=c_num; |
| 1345 | 1323 | t.data.data.use_commission=c_num; | ... | ... |
pages/cart/cart2_inte/cart2_inte.js
| ... | ... | @@ -401,20 +401,7 @@ Page({ |
| 401 | 401 | //-- 计算获得佣金的金额 -- |
| 402 | 402 | if (getApp().globalData.userInfo.is_distribut |
| 403 | 403 | && th.data.dis_config && th.data.dis_config.is_yongjin_dk) { |
| 404 | - var fir_num = 0; | |
| 405 | - var sec_num = 0; | |
| 406 | - var thi_num = 0; | |
| 407 | - if (th.data.dis_config.pattern == 1) { | |
| 408 | - fir_num = (inte_data.fir_rate || 0) * gg.goods_num; | |
| 409 | - sec_num = (inte_data.sec_rate || 0) * gg.goods_num; | |
| 410 | - thi_num = (inte_data.thi_rate || 0) * gg.goods_num; | |
| 411 | - } else { | |
| 412 | - fir_num = parseFloat((inte_data.commission || 0) * gg.goods_num * (th.data.dis_config.firstRate || 0) / 100).toFixed(2); | |
| 413 | - sec_num = parseFloat((inte_data.commission || 0) * gg.goods_num * (th.data.dis_config.secondRate || 0) / 100).toFixed(2); | |
| 414 | - thi_num = parseFloat((inte_data.commission || 0) * gg.goods_num * (th.data.dis_config.thirdRate || 0) / 100).toFixed(2); | |
| 415 | - } | |
| 416 | - var c_num = getApp().get_commission(fir_num, sec_num, thi_num, th); | |
| 417 | - | |
| 404 | + var c_num = getApp().get_commission(th.data.dis_config,inte_data, gg.goods_num); | |
| 418 | 405 | t.data.data.use_commission = c_num; |
| 419 | 406 | |
| 420 | 407 | } | ... | ... |
pages/cart/cart2_pt/cart2_pt.js
| ... | ... | @@ -283,19 +283,8 @@ Page({ |
| 283 | 283 | //-- 计算获得佣金的金额 -- |
| 284 | 284 | if (getApp().globalData.userInfo.is_distribut |
| 285 | 285 | && th.data.dis_config && th.data.dis_config.is_yongjin_dk) { |
| 286 | - var fir_num = 0; | |
| 287 | - var sec_num = 0; | |
| 288 | - var thi_num = 0; | |
| 289 | - if (th.data.dis_config.pattern == 1) { | |
| 290 | - fir_num = (t.data.data.fir_rate || 0) * gg.goods_num; | |
| 291 | - sec_num = (t.data.data.sec_rate || 0) * gg.goods_num; | |
| 292 | - thi_num = (t.data.data.thi_rate || 0) * gg.goods_num; | |
| 293 | - } else { | |
| 294 | - fir_num = parseFloat((t.data.data.commission || 0) * gg.goods_num * (th.data.dis_config.firstRate || 0) / 100).toFixed(2); | |
| 295 | - sec_num = parseFloat((t.data.data.commission || 0) * gg.goods_num * (th.data.dis_config.secondRate || 0) / 100).toFixed(2); | |
| 296 | - thi_num = parseFloat((t.data.data.commission || 0) * gg.goods_num * (th.data.dis_config.thirdRate || 0) / 100).toFixed(2); | |
| 297 | - } | |
| 298 | - var c_num = getApp().get_commission(fir_num, sec_num, thi_num, th); | |
| 286 | + | |
| 287 | + var c_num = getApp().get_commission(th.data.dis_config, t.data.data, gg.goods_num); | |
| 299 | 288 | |
| 300 | 289 | gd.use_commission = c_num; |
| 301 | 290 | t.data.data.use_commission = c_num; | ... | ... |