Commit 7bf2f6de08efb50884dcc63ebcd0fb5475ddcf7e

Authored by yvan.ni
1 parent 3e969607

佣金抵扣

packageC/pages/luckyGo/luckyGo_cart/luckyGo_cart.js
@@ -503,6 +503,7 @@ Page({ @@ -503,6 +503,7 @@ Page({
503 } 503 }
504 } 504 }
505 505
  506 +
506 //在分组的时候,就不要再调用接口,await 507 //在分组的时候,就不要再调用接口,await
507 for (var i = 0; i < carr.length; i++) { 508 for (var i = 0; i < carr.length; i++) {
508 var item = carr[i]; 509 var item = carr[i];
@@ -655,13 +656,28 @@ Page({ @@ -655,13 +656,28 @@ Page({
655 } 656 }
656 } 657 }
657 658
  659 + var cart_commission=0;
658 //-- 循环计算一下线下取价 -- 660 //-- 循环计算一下线下取价 --
659 for (var k = 0; k < arr.length; k++) { 661 for (var k = 0; k < arr.length; k++) {
660 var c_item = arr[k]; 662 var c_item = arr[k];
661 var item = arr[k].goods; 663 var item = arr[k].goods;
662 var offline_price = 0; 664 var offline_price = 0;
663 var offline_num = 0; 665 var offline_num = 0;
  666 +
  667 + //计算佣金的商品
  668 + var commission_gds=[];
664 for (var c = 0; c < item.length; c++) { 669 for (var c = 0; c < item.length; c++) {
  670 +
  671 + if(!item[c].is_gift){
  672 + var hr={
  673 + goods_id:item[c].goods_id,
  674 + goods_num:item[c].goods_num,
  675 + prom_type:item[c].prom_type,
  676 + prom_id:item[c].prom_id,
  677 + }
  678 + commission_gds.push(hr);
  679 + }
  680 +
665 if (th.data.sales_rules != 2) { 681 if (th.data.sales_rules != 2) {
666 item[c].offline_price = 0; 682 item[c].offline_price = 0;
667 } 683 }
@@ -676,6 +692,27 @@ Page({ @@ -676,6 +692,27 @@ Page({
676 c_item.offline_num = offline_num; 692 c_item.offline_num = offline_num;
677 c_item.is_offline = 1; 693 c_item.is_offline = 1;
678 } 694 }
  695 +
  696 + //获取购物车的佣金,此处要优化调用接口,获取佣金
  697 + var req_d = {
  698 + user_id:getApp().globalData.user_id,goods_ids:commission_gds,store_id: os.stoid
  699 + }
  700 + var back_data=null;
  701 + await getApp().request.promisePost("/api/weshop/order/getrebateSum", {
  702 + is_json: 1, data: req_d
  703 + }).then(rs => {
  704 + if (rs.data.code == 0) back_data =rs.data.data;
  705 + });
  706 +
  707 + if(back_data && parseFloat(back_data)) {
  708 + c_item.can_usecommise = parseFloat(back_data);
  709 + cart_commission += c_item.can_usecommise;
  710 + }
  711 +
  712 + }
  713 +
  714 + if(cart_commission){
  715 + th.setData({cart_commission});
679 } 716 }
680 717
681 718
@@ -862,6 +899,29 @@ Page({ @@ -862,6 +899,29 @@ Page({
862 t.data.data.prom_id = 0; 899 t.data.data.prom_id = 0;
863 t.data.data.prom_type = 0; 900 t.data.data.prom_type = 0;
864 901
  902 + //如果有开启佣金抵扣,同时会员是分销商的时候
  903 + if(!gg.collocation_goods && getApp().globalData.userInfo.is_distribut
  904 + && th.data.dis_config && th.data.dis_config.is_yongjin_dk){
  905 + var fir_num=0;
  906 + var sec_num=0;
  907 + var thi_num=0;
  908 + if(th.data.dis_config.pattern==1){
  909 + fir_num=(t.data.data.fir_rate || 0)*gg.goods_num;
  910 + sec_num=(t.data.data.sec_rate || 0)*gg.goods_num;
  911 + thi_num=(t.data.data.thi_rate || 0)*gg.goods_num;
  912 + }else{
  913 + fir_num=parseFloat((t.data.data.commission || 0) *gg.goods_num*(th.data.dis_config.firstRate || 0)/100).toFixed(2);
  914 + sec_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.secondRate || 0)/100).toFixed(2);
  915 + thi_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.thirdRate || 0)/100).toFixed(2);
  916 + }
  917 + var c_num=getApp().get_commission(fir_num,sec_num,thi_num,th);
  918 +
  919 + gd.use_commission=c_num;
  920 + t.data.data.use_commission=c_num;
  921 +
  922 + }
  923 +
  924 +
865 //如果立即购买那边过来,就要读取接口,查看活动的优惠内容 925 //如果立即购买那边过来,就要读取接口,查看活动的优惠内容
866 if (gg.prom_type == 3) { 926 if (gg.prom_type == 3) {
867 t.data.data.prom_id = gg.prom_id; 927 t.data.data.prom_id = gg.prom_id;
@@ -966,7 +1026,44 @@ Page({ @@ -966,7 +1026,44 @@ Page({
966 order_amount: 0, 1026 order_amount: 0,
967 user_note: 0 1027 user_note: 0
968 }; 1028 };
  1029 +
  1030 +
  1031 + var cart_commission=0;
  1032 + //-- 循环计算一下线下取价 --
  1033 + //计算佣金的商品
  1034 + var commission_gds=[];
  1035 + for (var c = 0; c < narr.length; c++) {
  1036 +
  1037 + var hr={
  1038 + goods_id:item[c].goods_id,
  1039 + goods_num:item[c].goods_num,
  1040 + prom_type:0,
  1041 + prom_id:0,
  1042 + }
  1043 + commission_gds.push(hr);
  1044 +
  1045 + }
  1046 + //获取购物车的佣金,此处要优化调用接口,获取佣金
  1047 + var req_d = {
  1048 + user_id:getApp().globalData.user_id,goods_ids:commission_gds,store_id: os.stoid
  1049 + }
  1050 + var back_data=null;
  1051 + await getApp().request.promisePost("/api/weshop/order/getrebateSum", {
  1052 + is_json: 1, data: req_d
  1053 + }).then(rs => {
  1054 + if (rs.data.code == 0) back_data =rs.data.data;
  1055 + });
  1056 +
  1057 + if(back_data && parseFloat(back_data)) {
  1058 + ie.can_usecommise =parseFloat(back_data);
  1059 + cart_commission = ie.can_usecommise;
  1060 + }
  1061 +
969 cart_arr.push(ie); 1062 cart_arr.push(ie);
  1063 + if(cart_commission){
  1064 + th.setData({cart_commission});
  1065 + }
  1066 +
970 th.data.old_cartlist = cart_arr; 1067 th.data.old_cartlist = cart_arr;
971 } 1068 }
972 th.setData({ 1069 th.setData({
@@ -1007,6 +1104,12 @@ Page({ @@ -1007,6 +1104,12 @@ Page({
1007 t.data.data.shop_price = tt.data.data.prom_user_price; 1104 t.data.data.shop_price = tt.data.data.prom_user_price;
1008 th.data.ckeck_quan_price = 0; 1105 th.data.ckeck_quan_price = 0;
1009 gd.is_xz_yh = 1; 1106 gd.is_xz_yh = 1;
  1107 +
  1108 + t.data.data.fir_rate=tt.data.data.fir_rate;
  1109 + t.data.data.sec_rate=tt.data.data.sec_rate;
  1110 + t.data.data.thi_rate=tt.data.data.thi_rate;
  1111 + t.data.data.commission=tt.data.data.commission;
  1112 +
1010 } else { 1113 } else {
1011 t.data.data.prom_id = 0; 1114 t.data.data.prom_id = 0;
1012 t.data.data.prom_type = 0; 1115 t.data.data.prom_type = 0;
@@ -1015,6 +1118,28 @@ Page({ @@ -1015,6 +1118,28 @@ Page({
1015 th.data.check_quan_ware_list = t.data.data.erpwareid + ""; 1118 th.data.check_quan_ware_list = t.data.data.erpwareid + "";
1016 } 1119 }
1017 1120
  1121 + //-- 计算获得佣金的金额 --
  1122 + if( getApp().globalData.userInfo.is_distribut
  1123 + && th.data.dis_config && th.data.dis_config.is_yongjin_dk){
  1124 + var fir_num=0;
  1125 + var sec_num=0;
  1126 + var thi_num=0;
  1127 + if(th.data.dis_config.pattern==1){
  1128 + fir_num=(t.data.data.fir_rate || 0)*gg.goods_num;
  1129 + sec_num=(t.data.data.sec_rate || 0)*gg.goods_num;
  1130 + thi_num=(t.data.data.thi_rate || 0)*gg.goods_num;
  1131 + }else{
  1132 + fir_num=parseFloat((t.data.data.commission || 0) *gg.goods_num*(th.data.dis_config.firstRate || 0)/100).toFixed(2);
  1133 + sec_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.secondRate || 0)/100).toFixed(2);
  1134 + thi_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.thirdRate || 0)/100).toFixed(2);
  1135 + }
  1136 + var c_num=getApp().get_commission(fir_num,sec_num,thi_num,th);
  1137 +
  1138 + gd.use_commission=c_num;
  1139 + t.data.data.use_commission=c_num;
  1140 +
  1141 + }
  1142 +
1018 th.setData({ 1143 th.setData({
1019 bn_goods: gd, 1144 bn_goods: gd,
1020 bn_pickname: gg.pick_name, 1145 bn_pickname: gg.pick_name,
@@ -1041,11 +1166,39 @@ Page({ @@ -1041,11 +1166,39 @@ Page({
1041 if (tt.data.code == 0) { 1166 if (tt.data.code == 0) {
1042 //t.data.data.shop_price = tt.data.data.prom_price; 1167 //t.data.data.shop_price = tt.data.data.prom_price;
1043 t.data.data.shop_price = tt.data.data.price; 1168 t.data.data.shop_price = tt.data.data.price;
  1169 +
  1170 + t.data.data.fir_rate=tt.data.data.fir_rate;
  1171 + t.data.data.sec_rate=tt.data.data.sec_rate;
  1172 + t.data.data.thi_rate=tt.data.data.thi_rate;
  1173 + t.data.data.commission=tt.data.data.commission;
1044 } else { 1174 } else {
1045 t.data.data.prom_id = 0; 1175 t.data.data.prom_id = 0;
1046 t.data.data.prom_type = 0; 1176 t.data.data.prom_type = 0;
1047 } 1177 }
1048 1178
  1179 + //-- 计算获得佣金的金额 --
  1180 + if( getApp().globalData.userInfo.is_distribut
  1181 + && th.data.dis_config && th.data.dis_config.is_yongjin_dk){
  1182 + var fir_num=0;
  1183 + var sec_num=0;
  1184 + var thi_num=0;
  1185 + if(th.data.dis_config.pattern==1){
  1186 + fir_num=(t.data.data.fir_rate || 0)*gg.goods_num;
  1187 + sec_num=(t.data.data.sec_rate || 0)*gg.goods_num;
  1188 + thi_num=(t.data.data.thi_rate || 0)*gg.goods_num;
  1189 + }else{
  1190 + fir_num=parseFloat((t.data.data.commission || 0) *gg.goods_num*(th.data.dis_config.firstRate || 0)/100).toFixed(2);
  1191 + sec_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.secondRate || 0)/100).toFixed(2);
  1192 + thi_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.thirdRate || 0)/100).toFixed(2);
  1193 + }
  1194 + var c_num=getApp().get_commission(fir_num,sec_num,thi_num,th);
  1195 +
  1196 + gd.use_commission=c_num;
  1197 + t.data.data.use_commission=c_num;
  1198 +
  1199 + }
  1200 +
  1201 +
1049 if (tt.data.data.isQuan) { 1202 if (tt.data.data.isQuan) {
1050 th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num; 1203 th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num;
1051 th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + ""; 1204 th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + "";
@@ -1670,6 +1823,10 @@ Page({ @@ -1670,6 +1823,10 @@ Page({
1670 cart_item.total_amount = cart_item.total_amount.toFixed(2); 1823 cart_item.total_amount = cart_item.total_amount.toFixed(2);
1671 cart_item.order_amount = cart_item.order_amount.toFixed(2); 1824 cart_item.order_amount = cart_item.order_amount.toFixed(2);
1672 1825
  1826 + if(th.data.cart_use_commission){
  1827 + cart_item.order_amount-=cart_item.can_usecommise;
  1828 + }
  1829 +
1673 //搭配购在使用余额 1830 //搭配购在使用余额
1674 if (th.data.bn_use_money == 1 && th.data.is_b_now == 1) { 1831 if (th.data.bn_use_money == 1 && th.data.is_b_now == 1) {
1675 1832
@@ -2032,6 +2189,14 @@ Page({ @@ -2032,6 +2189,14 @@ Page({
2032 var txt = "formData.user_money"; 2189 var txt = "formData.user_money";
2033 var txt2 = "formData.order_amount"; 2190 var txt2 = "formData.order_amount";
2034 var txt3 = "formData.coupon_price"; 2191 var txt3 = "formData.coupon_price";
  2192 + var txt4 = "formData.use_commission";
  2193 +
  2194 + if(th.data.bn_use_commission){
  2195 + order_m=parseFloat(order_m)- parseFloat(th.data.bn_goods.use_commission);
  2196 + th.setData({[txt4]:th.data.bn_goods.use_commission})
  2197 + }
  2198 +
  2199 +
2035 var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); 2200 var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
2036 //--------------如果使用余额--------------------- 2201 //--------------如果使用余额---------------------
2037 if (th.data.bn_use_money == 1) { 2202 if (th.data.bn_use_money == 1) {
@@ -2089,6 +2254,14 @@ Page({ @@ -2089,6 +2254,14 @@ Page({
2089 var txt = "formData.user_money"; 2254 var txt = "formData.user_money";
2090 var txt2 = "formData.order_amount"; 2255 var txt2 = "formData.order_amount";
2091 var txt3 = "formData.coupon_price"; 2256 var txt3 = "formData.coupon_price";
  2257 + var txt4= "formData.use_commission";
  2258 +
  2259 + if(th.data.bn_use_commission){
  2260 + order_m=parseFloat(order_m)- parseFloat(th.data.bn_goods.use_commission);
  2261 + th.setData({[txt4]:th.data.bn_goods.use_commission})
  2262 + }
  2263 +
  2264 +
2092 var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); 2265 var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
2093 //--------------如果使用余额--------------------- 2266 //--------------如果使用余额---------------------
2094 if (th.data.bn_use_money == 1) { 2267 if (th.data.bn_use_money == 1) {
packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js
@@ -111,9 +111,9 @@ Page({ @@ -111,9 +111,9 @@ Page({
111 111
112 112
113 113
114 - this.setData({//01  
115 - // kt_type: appD.kt_type  
116 - }); 114 + // this.setData({//01
  115 + // // kt_type: appD.kt_type
  116 + // });
117 117
118 // 01 118 // 01
119 // if (appD.is_pt_tz) th.data.is_pt_tz = appD.is_pt_tz; 119 // if (appD.is_pt_tz) th.data.is_pt_tz = appD.is_pt_tz;
@@ -121,6 +121,9 @@ Page({ @@ -121,6 +121,9 @@ Page({
121 121
122 //先获取物流,再获取用户信息,再展示页面 122 //先获取物流,再获取用户信息,再展示页面
123 // this.get_wuliu(th.get_info(th.show_page)); 123 // this.get_wuliu(th.get_info(th.show_page));
  124 +
  125 + //判断是不是佣金抵扣
  126 + getApp().is_distribut(this);
124 }, 127 },
125 128
126 onUnload: function () { 129 onUnload: function () {
@@ -335,6 +338,29 @@ Page({ @@ -335,6 +338,29 @@ Page({
335 et = th.data.bn_exp_type; 338 et = th.data.bn_exp_type;
336 } 339 }
337 340
  341 + //如果有开启佣金抵扣,同时会员是分销商的时候
  342 + if(getApp().globalData.userInfo.is_distribut
  343 + && th.data.dis_config && th.data.dis_config.is_yongjin_dk){
  344 + var fir_num=0;
  345 + var sec_num=0;
  346 + var thi_num=0;
  347 + if(th.data.dis_config.pattern==1){
  348 + fir_num=(t.data.data.fir_rate || 0)*gg.goods_num;
  349 + sec_num=(t.data.data.sec_rate || 0)*gg.goods_num;
  350 + thi_num=(t.data.data.thi_rate || 0)*gg.goods_num;
  351 + }else{
  352 + fir_num=parseFloat((t.data.data.commission || 0) *gg.goods_num*(th.data.dis_config.firstRate || 0)/100).toFixed(2);
  353 + sec_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.secondRate || 0)/100).toFixed(2);
  354 + thi_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.thirdRate || 0)/100).toFixed(2);
  355 + }
  356 + var c_num=getApp().get_commission(fir_num,sec_num,thi_num,th);
  357 +
  358 + t.data.data.use_commission=c_num;
  359 +
  360 + }
  361 +
  362 +
  363 +
338 364
339 th.setData({ 365 th.setData({
340 bn_goods: t.data.data, 366 bn_goods: t.data.data,
@@ -385,6 +411,29 @@ Page({ @@ -385,6 +411,29 @@ Page({
385 et = th.data.bn_exp_type; 411 et = th.data.bn_exp_type;
386 } 412 }
387 413
  414 +
  415 + //如果有开启佣金抵扣,同时会员是分销商的时候
  416 + if(getApp().globalData.userInfo.is_distribut
  417 + && th.data.dis_config && th.data.dis_config.is_yongjin_dk){
  418 + var fir_num=0;
  419 + var sec_num=0;
  420 + var thi_num=0;
  421 + if(th.data.dis_config.pattern==1){
  422 + fir_num=(t.data.data.fir_rate || 0)*gg.goods_num;
  423 + sec_num=(t.data.data.sec_rate || 0)*gg.goods_num;
  424 + thi_num=(t.data.data.thi_rate || 0)*gg.goods_num;
  425 + }else{
  426 + fir_num=parseFloat((t.data.data.commission || 0) *gg.goods_num*(th.data.dis_config.firstRate || 0)/100).toFixed(2);
  427 + sec_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.secondRate || 0)/100).toFixed(2);
  428 + thi_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.thirdRate || 0)/100).toFixed(2);
  429 + }
  430 + var c_num=getApp().get_commission(fir_num,sec_num,thi_num,th);
  431 +
  432 + t.data.data.use_commission=c_num;
  433 +
  434 + }
  435 +
  436 +
388 th.setData({ 437 th.setData({
389 bn_goods: t.data.data, 438 bn_goods: t.data.data,
390 bn_pickname: gg.pick_name, 439 bn_pickname: gg.pick_name,
@@ -729,6 +778,27 @@ Page({ @@ -729,6 +778,27 @@ Page({
729 778
730 var txt = "formData.user_money"; 779 var txt = "formData.user_money";
731 var txt2 = "formData.order_amount"; 780 var txt2 = "formData.order_amount";
  781 + var txt4= "formData.use_commission";
  782 +
  783 + if(parseFloat(order_m)<parseFloat(th.data.bn_goods.use_commission)){
  784 +
  785 + if(th.data.bn_use_commission){
  786 + wx.showToast({
  787 + title: '应付金额小于本单佣金,不可使用!',
  788 + icon: 'none',
  789 + duration: 2000
  790 + })
  791 + }
  792 +
  793 + th.setData({
  794 + bn_use_commission:0
  795 + })
  796 + }
  797 +
  798 + if(th.data.bn_use_commission){
  799 + order_m=parseFloat(order_m)- parseFloat(th.data.bn_goods.use_commission);
  800 + th.setData({[txt4]:th.data.bn_goods.use_commission})
  801 + }
732 //--------------如果使用余额--------------------- 802 //--------------如果使用余额---------------------
733 if (th.data.bn_use_money == 1 && th.data.yuer > 0) { 803 if (th.data.bn_use_money == 1 && th.data.yuer > 0) {
734 if (parseFloat(th.data.yuer) > total_m) { 804 if (parseFloat(th.data.yuer) > total_m) {
@@ -882,6 +952,11 @@ Page({ @@ -882,6 +952,11 @@ Page({
882 item.pt_listno = th.data.qh; 952 item.pt_listno = th.data.qh;
883 } 953 }
884 954
  955 + //-- 如果有使用佣金抵扣的话 --
  956 + if(th.data.bn_use_commission){
  957 + item.use_commission=th.data.bn_goods.use_commission;
  958 + }
  959 +
885 960
886 var gg = to.get_b_now(); 961 var gg = to.get_b_now();
887 var goods = { 962 var goods = {
@@ -1493,6 +1568,14 @@ Page({ @@ -1493,6 +1568,14 @@ Page({
1493 }, 1568 },
1494 1569
1495 1570
  1571 + //立即购买的时候,使用余额
  1572 + set_bn_commission:function(){
  1573 + var th = this;
  1574 + th.setData({ bn_use_commission: !th.data.bn_use_commission });
  1575 + th.calculatePrice2();
  1576 + },
  1577 +
  1578 +
1496 1579
1497 1580
1498 1581
packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.wxml
@@ -129,8 +129,20 @@ @@ -129,8 +129,20 @@
129 </view> 129 </view>
130 </block> 130 </block>
131 131
  132 + <!-----使用佣金------>
  133 + <view class="set-mes bdr_t-14" wx:if="{{bn_goods.use_commission>0 && can_commission}}">
  134 + <view class="use-item" bindtap='set_bn_commission'>
  135 + <icon color="{{bn_use_commission?'red':'gray'}}" size="16" type="success"></icon>
  136 + <view class="yu_er">使用佣金 :¥{{bn_goods.use_commission}} </view>
  137 + </view>
  138 + </view>
  139 +
132 <view class="information bdr14"> 140 <view class="information bdr14">
133 - <!-----使用余额------> 141 +
  142 +
  143 +
  144 +
  145 + <!-----使用余额------>
134 <view class="set-mes" wx:if="{{userinfo.user_money>0 && yuer>0}}"> 146 <view class="set-mes" wx:if="{{userinfo.user_money>0 && yuer>0}}">
135 <view class="use-item" bindtap='set_bn_useyuer' style="padding-left:0;padding-right:0;"> 147 <view class="use-item" bindtap='set_bn_useyuer' style="padding-left:0;padding-right:0;">
136 <icon color="{{bn_use_money?'red':'gray'}}" size="16" type="success"></icon> 148 <icon color="{{bn_use_money?'red':'gray'}}" size="16" type="success"></icon>
packageC/pages/presell/cart/cart.js
@@ -115,7 +115,8 @@ Page({ @@ -115,7 +115,8 @@ Page({
115 115
116 order_sn: '', 116 order_sn: '',
117 order_id: '', 117 order_id: '',
118 - 118 + exp_price:0,
  119 + order_prom_amount:0
119 }, 120 },
120 onLoad: function (t) { 121 onLoad: function (t) {
121 122
@@ -138,6 +139,9 @@ Page({ @@ -138,6 +139,9 @@ Page({
138 getApp().goto("/pages/togoin/togoin"); 139 getApp().goto("/pages/togoin/togoin");
139 } 140 }
140 141
  142 + //判断是不是佣金抵扣
  143 + getApp().is_distribut(this);
  144 +
141 }, 145 },
142 onUnload: function () { 146 onUnload: function () {
143 this.setData({ isclose: 1 }) 147 this.setData({ isclose: 1 })
@@ -517,6 +521,25 @@ Page({ @@ -517,6 +521,25 @@ Page({
517 521
518 } 522 }
519 523
  524 + //如果有开启佣金抵扣,同时会员是分销商的时候
  525 + if(getApp().globalData.userInfo.is_distribut
  526 + && th.data.dis_config && th.data.dis_config.is_yongjin_dk){
  527 + var fir_num=0;
  528 + var sec_num=0;
  529 + var thi_num=0;
  530 + if(th.data.dis_config.pattern==1){
  531 + fir_num=(goods.fir_rate || 0)*order_goods.goods_num;
  532 + sec_num=(goods.sec_rate || 0)*order_goods.goods_num;
  533 + thi_num=(goods.thi_rate || 0)*order_goods.goods_num;
  534 + }else{
  535 + fir_num=parseFloat((goods.commission || 0) *order_goods.goods_num*(th.data.dis_config.firstRate || 0)/100).toFixed(2);
  536 + sec_num=parseFloat((goods.commission || 0)*order_goods.goods_num*(th.data.dis_config.secondRate || 0)/100).toFixed(2);
  537 + thi_num=parseFloat((goods.commission || 0)*order_goods.goods_num*(th.data.dis_config.thirdRate || 0)/100).toFixed(2);
  538 + }
  539 + var c_num=getApp().get_commission(fir_num,sec_num,thi_num,th);
  540 + goods.use_commission=c_num;
  541 + }
  542 +
520 543
521 var g_url = "/packageC/pages/presell/goodsInfo/goodsInfo?goods_id=" + order_goods.goods_id + "&pre_id=" + pre_arr.id; 544 var g_url = "/packageC/pages/presell/goodsInfo/goodsInfo?goods_id=" + order_goods.goods_id + "&pre_id=" + pre_arr.id;
522 if (act.is_end || th.data.act.end_time < ut.gettimestamp()) { 545 if (act.is_end || th.data.act.end_time < ut.gettimestamp()) {
@@ -769,12 +792,23 @@ Page({ @@ -769,12 +792,23 @@ Page({
769 } 792 }
770 793
771 o_condition1 = parseFloat(o_condition1) - parseFloat(th.data.presell.presell_deposit); 794 o_condition1 = parseFloat(o_condition1) - parseFloat(th.data.presell.presell_deposit);
  795 +
772 if (o_condition1 < 0) o_condition1 = 0; 796 if (o_condition1 < 0) o_condition1 = 0;
  797 + else if(o_condition1>th.data.goods.use_commission && th.data.bn_use_commission){
  798 + o_condition1-=th.data.bn_use_commission;
  799 + }
  800 +
773 th.setData({ exp_price: 0, order_m: o_condition1, show_submit: 1, }) 801 th.setData({ exp_price: 0, order_m: o_condition1, show_submit: 1, })
774 }) 802 })
775 } else { 803 } else {
776 o_condition = parseFloat(o_condition) - parseFloat(th.data.presell.presell_deposit); 804 o_condition = parseFloat(o_condition) - parseFloat(th.data.presell.presell_deposit);
777 if (o_condition < 0) o_condition = 0; 805 if (o_condition < 0) o_condition = 0;
  806 +
  807 + if (o_condition1 < 0) o_condition1 = 0;
  808 + else if(o_condition1>th.data.goods.use_commission && th.data.bn_use_commission){
  809 + o_condition1-=th.data.bn_use_commission;
  810 + }
  811 +
778 th.setData({ exp_price: 0, order_m: o_condition, show_submit: 1, }) 812 th.setData({ exp_price: 0, order_m: o_condition, show_submit: 1, })
779 } 813 }
780 } 814 }
@@ -2120,14 +2154,59 @@ Page({ @@ -2120,14 +2154,59 @@ Page({
2120 ord_price = parseFloat(ord_price) - parseFloat(th.data.presell.presell_deposit); 2154 ord_price = parseFloat(ord_price) - parseFloat(th.data.presell.presell_deposit);
2121 if (ord_price < 0) ord_price = 0; 2155 if (ord_price < 0) ord_price = 0;
2122 2156
2123 - th.setData({ exp_price: exp_price, order_m: ord_price + parseFloat(exp_price), show_submit: 1, }) 2157 + var the_price=ord_price + parseFloat(exp_price);
  2158 +
  2159 + if(the_price<th.data.goods.use_commission){
  2160 +
  2161 + if(th.data.bn_use_commission){
  2162 + wx.showToast({
  2163 + title: '应付金额小于本单佣金,不可使用!',
  2164 + icon: 'none',
  2165 + duration: 2000
  2166 + })
  2167 + }
  2168 +
  2169 + th.setData({
  2170 + bn_use_commission:0
  2171 + });
  2172 +
  2173 + }
  2174 +
  2175 + if( th.data.bn_use_commission){
  2176 + the_price-=th.data.bn_use_commission;
  2177 + }
  2178 +
  2179 +
  2180 + th.setData({ exp_price: exp_price, order_m: the_price, show_submit: 1, })
2124 2181
2125 }) 2182 })
2126 } else { 2183 } else {
2127 2184
2128 var o_condition1 = parseFloat(o_condition) - parseFloat(th.data.presell.presell_deposit); 2185 var o_condition1 = parseFloat(o_condition) - parseFloat(th.data.presell.presell_deposit);
2129 if (o_condition1 < 0) o_condition1 = 0; 2186 if (o_condition1 < 0) o_condition1 = 0;
2130 - th.setData({ exp_price: exp_price, order_m: parseFloat(o_condition1) + parseFloat(exp_price), show_submit: 1, }) 2187 +
  2188 + var the_price=parseFloat(o_condition1) + parseFloat(exp_price);
  2189 +
  2190 + if(the_price<th.data.goods.use_commission){
  2191 +
  2192 + if(th.data.bn_use_commission){
  2193 + wx.showToast({
  2194 + title: '应付金额小于本单佣金,不可使用!',
  2195 + icon: 'none',
  2196 + duration: 2000
  2197 + })
  2198 + }
  2199 +
  2200 + th.setData({
  2201 + bn_use_commission:0
  2202 + })
  2203 + }
  2204 +
  2205 + if(th.data.bn_use_commission){
  2206 + the_price-=th.data.bn_use_commission;
  2207 + }
  2208 +
  2209 + th.setData({ exp_price: exp_price, order_m:the_price, show_submit: 1, })
2131 } 2210 }
2132 }, 2211 },
2133 2212
@@ -2243,6 +2322,11 @@ Page({ @@ -2243,6 +2322,11 @@ Page({
2243 dd.order_prom_list = e; 2322 dd.order_prom_list = e;
2244 } 2323 }
2245 2324
  2325 + if(th.data.bn_use_commission){
  2326 + dd.use_commission =th.data.goods.use_commission;
  2327 + }
  2328 +
  2329 +
2246 var bn_pick = th.data.pickup_id; 2330 var bn_pick = th.data.pickup_id;
2247 var quan_no = ''; 2331 var quan_no = '';
2248 if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined) 2332 if (th.data.using_quan[bn_pick] != null && th.data.using_quan[bn_pick] != undefined)
@@ -2809,6 +2893,13 @@ Page({ @@ -2809,6 +2893,13 @@ Page({
2809 //---------联系微信客服------------ 2893 //---------联系微信客服------------
2810 con_weixin: function () { 2894 con_weixin: function () {
2811 getApp().con_wx(this); 2895 getApp().con_wx(this);
  2896 + },
  2897 +
  2898 + //使用
  2899 + set_bn_commission:function(){
  2900 + var th = this;
  2901 + th.setData({bn_use_commission: !th.data.bn_use_commission});
  2902 + th.calculatePrice2();
2812 } 2903 }
2813 2904
2814 2905
packageC/pages/presell/cart/cart.wxml
@@ -295,6 +295,15 @@ @@ -295,6 +295,15 @@
295 </view> 295 </view>
296 296
297 297
  298 + <!-----使用佣金--- 佣金必须要小于尾款的支付的金额 ,同时订单优惠--->
  299 + <view class="set-mes bdr_t-14" wx:if="{{goods.use_commission>0 && can_commission && util.get_sum(tail_pay,exp_price,order_prom_amount)>goods.use_commission}}">
  300 + <view class="use-item" bindtap='set_bn_commission'>
  301 + <icon color="{{bn_use_commission?'red':'gray'}}" size="16" type="success"></icon>
  302 + <view class="yu_er">使用佣金 :¥{{goods.use_commission}} </view>
  303 + </view>
  304 + </view>
  305 +
  306 +
298 <view class="information bdr14"> 307 <view class="information bdr14">
299 <view class="item" wx:if="{{allpice>0}}"> 308 <view class="item" wx:if="{{allpice>0}}">
300 <view>商品金额</view> 309 <view>商品金额</view>
packageC/pages/presell/cart/cart2.js
@@ -125,6 +125,10 @@ Page({ @@ -125,6 +125,10 @@ Page({
125 in_zhact_gdmap: {}, //不同门店参与同一活动的限购 125 in_zhact_gdmap: {}, //不同门店参与同一活动的限购
126 hid_inp: 1, 126 hid_inp: 1,
127 user_note: {}, 127 user_note: {},
  128 +
  129 + dis_config:null,
  130 + bn_use_commission:0, //是不是使用佣金
  131 +
128 }, 132 },
129 onLoad: function (t) { 133 onLoad: function (t) {
130 wx.setNavigationBarTitle({ title: "填写订单", }) 134 wx.setNavigationBarTitle({ title: "填写订单", })
@@ -138,6 +142,9 @@ Page({ @@ -138,6 +142,9 @@ Page({
138 } 142 }
139 }); 143 });
140 144
  145 + //判断是不是佣金抵扣
  146 + getApp().is_distribut(this);
  147 +
141 }, 148 },
142 onUnload: function () { 149 onUnload: function () {
143 this.setData({ isclose: 1 }) 150 this.setData({ isclose: 1 })
@@ -510,6 +517,29 @@ Page({ @@ -510,6 +517,29 @@ Page({
510 return false; 517 return false;
511 } 518 }
512 519
  520 +
  521 + //如果有开启佣金抵扣,同时会员是分销商的时候
  522 + if(getApp().globalData.userInfo.is_distribut
  523 + && th.data.dis_config && th.data.dis_config.is_yongjin_dk){
  524 + var fir_num=0;
  525 + var sec_num=0;
  526 + var thi_num=0;
  527 + if(th.data.dis_config.pattern==1){
  528 + fir_num=(t.data.data.fir_rate || 0)*gg.goods_num;
  529 + sec_num=(t.data.data.sec_rate || 0)*gg.goods_num;
  530 + thi_num=(t.data.data.thi_rate || 0)*gg.goods_num;
  531 + }else{
  532 + fir_num=parseFloat((t.data.data.commission || 0) *gg.goods_num*(th.data.dis_config.firstRate || 0)/100).toFixed(2);
  533 + sec_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.secondRate || 0)/100).toFixed(2);
  534 + thi_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.thirdRate || 0)/100).toFixed(2);
  535 + }
  536 + var c_num=getApp().get_commission(fir_num,sec_num,thi_num,th);
  537 +
  538 + gd.use_commission=c_num;
  539 + t.data.data.use_commission=c_num;
  540 +
  541 + }
  542 +
513 //这个位置要拿活动的预售价 543 //这个位置要拿活动的预售价
514 t.data.data.shop_price = prelist.presell_money; 544 t.data.data.shop_price = prelist.presell_money;
515 th.setData({ 545 th.setData({
@@ -945,6 +975,28 @@ Page({ @@ -945,6 +975,28 @@ Page({
945 var txt = "formData.user_money"; 975 var txt = "formData.user_money";
946 var txt2 = "formData.order_amount"; 976 var txt2 = "formData.order_amount";
947 var txt3 = "formData.coupon_price"; 977 var txt3 = "formData.coupon_price";
  978 +
  979 + if(parseFloat(order_m)<parseFloat(th.data.bn_goods.use_commission)){
  980 +
  981 + wx.showToast({
  982 + title: '应付金额小于本单佣金,不可使用!',
  983 + icon: 'none',
  984 + duration: 2000
  985 + })
  986 +
  987 + th.setData({
  988 + bn_use_commission:0
  989 + })
  990 +
  991 + }
  992 +
  993 + var txt4 = "formData.use_commission";
  994 +
  995 + if(th.data.bn_use_commission){
  996 + order_m=parseFloat(order_m)- parseFloat(th.data.bn_goods.use_commission);
  997 + th.setData({[txt4]:th.data.bn_goods.use_commission})
  998 + }
  999 +
948 var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); 1000 var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
949 //--------------如果使用余额--------------------- 1001 //--------------如果使用余额---------------------
950 if (th.data.bn_use_money == 1) { 1002 if (th.data.bn_use_money == 1) {
@@ -1046,6 +1098,33 @@ Page({ @@ -1046,6 +1098,33 @@ Page({
1046 var txt = "formData.user_money"; 1098 var txt = "formData.user_money";
1047 var txt2 = "formData.order_amount"; 1099 var txt2 = "formData.order_amount";
1048 var txt3 = "formData.coupon_price"; 1100 var txt3 = "formData.coupon_price";
  1101 +
  1102 + if(parseFloat(order_m)<parseFloat(th.data.bn_goods.use_commission)){
  1103 +
  1104 + if(th.data.bn_use_commission){
  1105 + wx.showToast({
  1106 + title: '应付金额小于本单佣金,不可使用!',
  1107 + icon: 'none',
  1108 + duration: 2000
  1109 + })
  1110 + }
  1111 +
  1112 + th.setData({
  1113 + bn_use_commission:0
  1114 + })
  1115 + }
  1116 +
  1117 +
  1118 +
  1119 + var txt4 = "formData.use_commission";
  1120 +
  1121 + if(th.data.bn_use_commission){
  1122 + order_m=parseFloat(order_m)- parseFloat(th.data.bn_goods.use_commission);
  1123 + th.setData({[txt4]:th.data.bn_goods.use_commission})
  1124 + }
  1125 +
  1126 +
  1127 +
1049 var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); 1128 var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
1050 //--------------如果使用余额--------------------- 1129 //--------------如果使用余额---------------------
1051 if (th.data.bn_use_money == 1) { 1130 if (th.data.bn_use_money == 1) {
@@ -1148,6 +1227,11 @@ Page({ @@ -1148,6 +1227,11 @@ Page({
1148 //是不是重新提交 1227 //是不是重新提交
1149 if (th.data.is_continue == 1) item.is_continue = 1; 1228 if (th.data.is_continue == 1) item.is_continue = 1;
1150 1229
  1230 + //-- 如果有使用佣金抵扣的话 --
  1231 + if(th.data.bn_use_commission){
  1232 + item.use_commission=th.data.bn_goods.use_commission;
  1233 + }
  1234 +
1151 //获取立即购买的商品的信息 1235 //获取立即购买的商品的信息
1152 var gg = to.get_b_now(); 1236 var gg = to.get_b_now();
1153 //--商品的房间号-- 1237 //--商品的房间号--
@@ -1867,6 +1951,13 @@ Page({ @@ -1867,6 +1951,13 @@ Page({
1867 th.calculatePrice(); 1951 th.calculatePrice();
1868 }, 1952 },
1869 1953
  1954 + //使用佣金
  1955 + set_bn_commission:function(){
  1956 + var th = this;
  1957 + th.setData({ bn_use_commission: !th.data.bn_use_commission });
  1958 + th.calculatePrice2();
  1959 + },
  1960 +
1870 //----------立即购买,选择物流------------- 1961 //----------立即购买,选择物流-------------
1871 bindPickerChange: function (e) { 1962 bindPickerChange: function (e) {
1872 var ind = e.detail.value 1963 var ind = e.detail.value
@@ -2790,7 +2881,7 @@ Page({ @@ -2790,7 +2881,7 @@ Page({
2790 var index = e.currentTarget.dataset.index; 2881 var index = e.currentTarget.dataset.index;
2791 var txt = "cartlist[" + index + "].focus"; 2882 var txt = "cartlist[" + index + "].focus";
2792 this.setData({ [txt]: 0 }) 2883 this.setData({ [txt]: 0 })
2793 - }, 2884 + }
2794 2885
2795 2886
2796 2887
packageC/pages/presell/cart/cart2.wxml
@@ -200,6 +200,16 @@ @@ -200,6 +200,16 @@
200 <!-- 右边点击 --> 200 <!-- 右边点击 -->
201 <view class="xc-right" style="margin-right: 12rpx; border-color: #d7642b;"></view> 201 <view class="xc-right" style="margin-right: 12rpx; border-color: #d7642b;"></view>
202 </view> 202 </view>
  203 +
  204 + <!-----使用佣金------>
  205 + <view class="set-mes bdr_t-14" wx:if="{{bn_goods.use_commission>0 && can_commission}}">
  206 + <view class="use-item" bindtap='set_bn_commission'>
  207 + <icon color="{{bn_use_commission?'red':'gray'}}" size="16" type="success"></icon>
  208 + <view class="yu_er">使用佣金 :¥{{bn_goods.use_commission}} </view>
  209 + </view>
  210 + </view>
  211 +
  212 +
203 <!-----使用余额------> 213 <!-----使用余额------>
204 <view class="set-mes bdr_t-14" wx:if="{{yuer>0}}"> 214 <view class="set-mes bdr_t-14" wx:if="{{yuer>0}}">
205 <view class="use-item" bindtap='set_bn_useyuer'> 215 <view class="use-item" bindtap='set_bn_useyuer'>
packageC/pages/presell/cart/filter.wxs
@@ -6,6 +6,11 @@ var format = function (text) { @@ -6,6 +6,11 @@ var format = function (text) {
6 return text.replace(reg, '\n') 6 return text.replace(reg, '\n')
7 } 7 }
8 8
  9 +function get_sum(val1,val2,val3){
  10 + return parseFloat(val1)+parseFloat(val2)-parseFloat(val3)
  11 +}
  12 +
9 module.exports = { 13 module.exports = {
10 - format: format 14 + format: format,
  15 + get_sum:get_sum
11 } 16 }
pages/cart/cart2/cart2.js
@@ -9,6 +9,7 @@ var ladder_calc = require(&quot;ladder_calculate.js&quot;); @@ -9,6 +9,7 @@ var ladder_calc = require(&quot;ladder_calculate.js&quot;);
9 let timer; 9 let timer;
10 Page({ 10 Page({
11 data: { 11 data: {
  12 +
12 url: t.globalData.setting.url, 13 url: t.globalData.setting.url,
13 resourceUrl: t.globalData.setting.resourceUrl, 14 resourceUrl: t.globalData.setting.resourceUrl,
14 imgUrl: t.globalData.setting.imghost, 15 imgUrl: t.globalData.setting.imghost,
@@ -133,6 +134,10 @@ Page({ @@ -133,6 +134,10 @@ Page({
133 show_duo_gift: 0, 134 show_duo_gift: 0,
134 send_gf: {}, //多赠品的计算 135 send_gf: {}, //多赠品的计算
135 send_lb: {}, 136 send_lb: {},
  137 + dis_config:null,
  138 + bn_use_commission:0, //是不是使用佣金
  139 + cart_use_commission:0,
  140 + cart_commission:0
136 }, 141 },
137 onLoad: function (t) { 142 onLoad: function (t) {
138 wx.setNavigationBarTitle({ title: "填写订单", }) 143 wx.setNavigationBarTitle({ title: "填写订单", })
@@ -163,6 +168,10 @@ Page({ @@ -163,6 +168,10 @@ Page({
163 th.setData({ template_id: template_id }); 168 th.setData({ template_id: template_id });
164 } 169 }
165 }) 170 })
  171 +
  172 + //判断是不是佣金抵扣
  173 + getApp().is_distribut(this);
  174 +
166 }, 175 },
167 onUnload: function () { 176 onUnload: function () {
168 this.setData({ isclose: 1 }) 177 this.setData({ isclose: 1 })
@@ -745,13 +754,26 @@ Page({ @@ -745,13 +754,26 @@ Page({
745 } 754 }
746 } 755 }
747 756
  757 + var cart_commission=0;
748 //-- 循环计算一下线下取价 -- 758 //-- 循环计算一下线下取价 --
749 for (var k = 0; k < arr.length; k++) { 759 for (var k = 0; k < arr.length; k++) {
750 var c_item = arr[k]; 760 var c_item = arr[k];
751 var item = arr[k].goods; 761 var item = arr[k].goods;
752 var offline_price = 0; 762 var offline_price = 0;
753 var offline_num = 0; 763 var offline_num = 0;
  764 + //计算佣金的商品
  765 + var commission_gds=[];
754 for (var c = 0; c < item.length; c++) { 766 for (var c = 0; c < item.length; c++) {
  767 +
  768 + if(!item[c].is_gift){
  769 + var hr={
  770 + goods_id:item[c].goods_id,
  771 + goods_num:item[c].goods_num,
  772 + prom_type:item[c].prom_type,
  773 + prom_id:item[c].prom_id,
  774 + }
  775 + commission_gds.push(hr);
  776 + }
755 if (th.data.sales_rules != 2) { 777 if (th.data.sales_rules != 2) {
756 item[c].offline_price = 0; 778 item[c].offline_price = 0;
757 } 779 }
@@ -766,8 +788,28 @@ Page({ @@ -766,8 +788,28 @@ Page({
766 c_item.offline_num = offline_num; 788 c_item.offline_num = offline_num;
767 c_item.is_offline = 1; 789 c_item.is_offline = 1;
768 } 790 }
  791 +
  792 + //获取购物车的佣金,此处要优化调用接口,获取佣金
  793 + var req_d = {
  794 + user_id:getApp().globalData.user_id,goods_ids:commission_gds,store_id: os.stoid
  795 + }
  796 + var back_data=null;
  797 + await getApp().request.promisePost("/api/weshop/order/getrebateSum", {
  798 + is_json: 1, data: req_d
  799 + }).then(rs => {
  800 + if (rs.data.code == 0) back_data =rs.data.data;
  801 + });
  802 +
  803 + if(back_data && parseFloat(back_data)) {
  804 + c_item.can_usecommise = parseFloat(back_data);
  805 + cart_commission += c_item.can_usecommise;
  806 + }
  807 +
769 } 808 }
770 809
  810 + if(cart_commission){
  811 + th.setData({cart_commission});
  812 + }
771 813
772 //每一个门店内的组合购要进行拆分, 814 //每一个门店内的组合购要进行拆分,
773 //还得把组合商品的多余商品的线下价格算一算 815 //还得把组合商品的多余商品的线下价格算一算
@@ -956,6 +998,7 @@ Page({ @@ -956,6 +998,7 @@ Page({
956 gd.prom_id =gg.prom_id=0; 998 gd.prom_id =gg.prom_id=0;
957 } 999 }
958 1000
  1001 +
959 switch (gd.prom_type) { 1002 switch (gd.prom_type) {
960 case 0: 1003 case 0:
961 case 3: 1004 case 3:
@@ -985,6 +1028,29 @@ Page({ @@ -985,6 +1028,29 @@ Page({
985 t.data.data.prom_id = 0; 1028 t.data.data.prom_id = 0;
986 t.data.data.prom_type = 0; 1029 t.data.data.prom_type = 0;
987 1030
  1031 +
  1032 + //如果有开启佣金抵扣,同时会员是分销商的时候
  1033 + if(!gg.collocation_goods && getApp().globalData.userInfo.is_distribut
  1034 + && th.data.dis_config && th.data.dis_config.is_yongjin_dk){
  1035 + var fir_num=0;
  1036 + var sec_num=0;
  1037 + var thi_num=0;
  1038 + if(th.data.dis_config.pattern==1){
  1039 + fir_num=(t.data.data.fir_rate || 0)*gg.goods_num;
  1040 + sec_num=(t.data.data.sec_rate || 0)*gg.goods_num;
  1041 + thi_num=(t.data.data.thi_rate || 0)*gg.goods_num;
  1042 + }else{
  1043 + fir_num=parseFloat((t.data.data.commission || 0) *gg.goods_num*(th.data.dis_config.firstRate || 0)/100).toFixed(2);
  1044 + sec_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.secondRate || 0)/100).toFixed(2);
  1045 + thi_num=parseFloat((t.data.data.commission || 0)*gg.goods_num*(th.data.dis_config.thirdRate || 0)/100).toFixed(2);
  1046 + }
  1047 + var c_num=getApp().get_commission(fir_num,sec_num,thi_num,th);
  1048 +
  1049 + gd.use_commission=c_num;
  1050 + t.data.data.use_commission=c_num;
  1051 +
  1052 + }
  1053 +
988 //如果立即购买那边过来,就要读取接口,查看活动的优惠内容 1054 //如果立即购买那边过来,就要读取接口,查看活动的优惠内容
989 if (gg.prom_type == 3) { 1055 if (gg.prom_type == 3) {
990 t.data.data.prom_id = gg.prom_id; 1056 t.data.data.prom_id = gg.prom_id;
@@ -1030,6 +1096,7 @@ Page({ @@ -1030,6 +1096,7 @@ Page({
1030 bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et 1096 bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et
1031 }); 1097 });
1032 1098
  1099 +
1033 //计算价格 1100 //计算价格
1034 th.calculatePrice2(); 1101 th.calculatePrice2();
1035 //获取优惠券 1102 //获取优惠券
@@ -1086,7 +1153,6 @@ Page({ @@ -1086,7 +1153,6 @@ Page({
1086 et = 0; 1153 et = 0;
1087 } 1154 }
1088 1155
1089 -  
1090 var ie = { 1156 var ie = {
1091 pickup_id: gg.pick_id, 1157 pickup_id: gg.pick_id,
1092 pname: gg.pick_name, 1158 pname: gg.pick_name,
@@ -1102,7 +1168,44 @@ Page({ @@ -1102,7 +1168,44 @@ Page({
1102 order_amount: 0, 1168 order_amount: 0,
1103 user_note: "" 1169 user_note: ""
1104 }; 1170 };
1105 - cart_arr.push(ie); 1171 +
  1172 + var cart_commission=0;
  1173 + //-- 循环计算一下线下取价 --
  1174 + //计算佣金的商品
  1175 + var commission_gds=[];
  1176 + for (var c = 0; c < narr.length; c++) {
  1177 +
  1178 + var hr={
  1179 + goods_id:item[c].goods_id,
  1180 + goods_num:item[c].goods_num,
  1181 + prom_type:0,
  1182 + prom_id:0,
  1183 + }
  1184 + commission_gds.push(hr);
  1185 +
  1186 + }
  1187 + //获取购物车的佣金,此处要优化调用接口,获取佣金
  1188 + var req_d = {
  1189 + user_id:getApp().globalData.user_id,goods_ids:commission_gds,store_id: os.stoid
  1190 + }
  1191 + var back_data=null;
  1192 + await getApp().request.promisePost("/api/weshop/order/getrebateSum", {
  1193 + is_json: 1, data: req_d
  1194 + }).then(rs => {
  1195 + if (rs.data.code == 0) back_data =rs.data.data;
  1196 + });
  1197 +
  1198 + if(back_data && parseFloat(back_data)) {
  1199 + ie.can_usecommise =parseFloat(back_data);
  1200 + cart_commission = ie.can_usecommise;
  1201 + }
  1202 +
  1203 + cart_arr.push(ie);
  1204 + if(cart_commission){
  1205 + th.setData({cart_commission});
  1206 + }
  1207 +
  1208 +
1106 th.data.old_cartlist = cart_arr; 1209 th.data.old_cartlist = cart_arr;
1107 } 1210 }
1108 th.setData({ 1211 th.setData({
@@ -1146,6 +1249,13 @@ Page({ @@ -1146,6 +1249,13 @@ Page({
1146 t.data.data.shop_price = tt.data.data.prom_user_price; 1249 t.data.data.shop_price = tt.data.data.prom_user_price;
1147 th.data.ckeck_quan_price = 0; 1250 th.data.ckeck_quan_price = 0;
1148 gd.is_xz_yh = 1; 1251 gd.is_xz_yh = 1;
  1252 +
  1253 + t.data.data.fir_rate=tt.data.data.fir_rate;
  1254 + t.data.data.sec_rate=tt.data.data.sec_rate;
  1255 + t.data.data.thi_rate=tt.data.data.thi_rate;
  1256 + t.data.data.commission=tt.data.data.commission;
  1257 +
  1258 +
1149 } else { 1259 } else {
1150 t.data.data.prom_id = 0; 1260 t.data.data.prom_id = 0;
1151 t.data.data.prom_type = 0; 1261 t.data.data.prom_type = 0;
@@ -1154,6 +1264,29 @@ Page({ @@ -1154,6 +1264,29 @@ Page({
1154 th.data.check_quan_ware_list = t.data.data.erpwareid + ""; 1264 th.data.check_quan_ware_list = t.data.data.erpwareid + "";
1155 } 1265 }
1156 1266
  1267 + //-- 计算获得佣金的金额 --
  1268 + if( getApp().globalData.userInfo.is_distribut
  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);
  1283 +
  1284 + gd.use_commission=c_num;
  1285 + t.data.data.use_commission=c_num;
  1286 +
  1287 + }
  1288 +
  1289 +
1157 th.setData({ 1290 th.setData({
1158 bn_goods: gd, 1291 bn_goods: gd,
1159 bn_pickname: gg.pick_name, 1292 bn_pickname: gg.pick_name,
@@ -1180,11 +1313,40 @@ Page({ @@ -1180,11 +1313,40 @@ Page({
1180 if (tt.data.code == 0) { 1313 if (tt.data.code == 0) {
1181 //t.data.data.shop_price = tt.data.data.prom_price; 1314 //t.data.data.shop_price = tt.data.data.prom_price;
1182 t.data.data.shop_price = tt.data.data.price; 1315 t.data.data.shop_price = tt.data.data.price;
  1316 +
  1317 + t.data.data.fir_rate=tt.data.data.fir_rate;
  1318 + t.data.data.sec_rate=tt.data.data.sec_rate;
  1319 + t.data.data.thi_rate=tt.data.data.thi_rate;
  1320 + t.data.data.commission=tt.data.data.commission;
  1321 +
1183 } else { 1322 } else {
1184 t.data.data.prom_id = 0; 1323 t.data.data.prom_id = 0;
1185 t.data.data.prom_type = 0; 1324 t.data.data.prom_type = 0;
1186 } 1325 }
1187 1326
  1327 + //-- 计算获得佣金的金额 --
  1328 + if( getApp().globalData.userInfo.is_distribut
  1329 + && 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);
  1343 +
  1344 + gd.use_commission=c_num;
  1345 + t.data.data.use_commission=c_num;
  1346 +
  1347 + }
  1348 +
  1349 +
1188 if (tt.data.data.isQuan) { 1350 if (tt.data.data.isQuan) {
1189 th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num; 1351 th.data.ckeck_quan_price = t.data.data.shop_price * gg.goods_num;
1190 th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + ""; 1352 th.data.check_quan_price_list = t.data.data.shop_price * gg.goods_num + "";
@@ -2061,6 +2223,29 @@ Page({ @@ -2061,6 +2223,29 @@ Page({
2061 cart_item.total_amount = cart_item.total_amount.toFixed(2); 2223 cart_item.total_amount = cart_item.total_amount.toFixed(2);
2062 cart_item.order_amount = cart_item.order_amount.toFixed(2); 2224 cart_item.order_amount = cart_item.order_amount.toFixed(2);
2063 2225
  2226 + //-- 最后的金额小于佣金 --
  2227 + if(cart_item.order_amount<cart_item.can_usecommise){
  2228 +
  2229 + if(th.data.cart_use_commission){
  2230 + wx.showToast({
  2231 + title: '应付金额小于本单佣金,不可使用!',
  2232 + icon: 'none',
  2233 + duration: 2000
  2234 + })
  2235 + }
  2236 +
  2237 + th.setData({
  2238 + cart_use_commission:0
  2239 + });
  2240 +
  2241 +
  2242 + }
  2243 +
  2244 +
  2245 + if(th.data.cart_use_commission){
  2246 + cart_item.order_amount-=cart_item.can_usecommise;
  2247 + }
  2248 +
2064 //搭配购在使用余额 2249 //搭配购在使用余额
2065 if (th.data.bn_use_money == 1 && th.data.is_b_now == 1) { 2250 if (th.data.bn_use_money == 1 && th.data.is_b_now == 1) {
2066 2251
@@ -2565,6 +2750,34 @@ Page({ @@ -2565,6 +2750,34 @@ Page({
2565 var txt = "formData.user_money"; 2750 var txt = "formData.user_money";
2566 var txt2 = "formData.order_amount"; 2751 var txt2 = "formData.order_amount";
2567 var txt3 = "formData.coupon_price"; 2752 var txt3 = "formData.coupon_price";
  2753 +
  2754 + //-- 最后的金额小于佣金 --
  2755 + if(parseFloat(order_m)<parseFloat(th.data.bn_goods.use_commission) ){
  2756 +
  2757 + if(th.data.bn_use_commission){
  2758 + wx.showToast({
  2759 + title: '应付金额小于本单佣金,不可使用!',
  2760 + icon: 'none',
  2761 + duration: 2000
  2762 + })
  2763 + }
  2764 +
  2765 + th.setData({
  2766 + bn_use_commission:0
  2767 + });
  2768 +
  2769 +
  2770 + }
  2771 +
  2772 + var txt4 = "formData.use_commission";
  2773 +
  2774 + if(th.data.bn_use_commission){
  2775 + order_m=parseFloat(order_m)- parseFloat(th.data.bn_goods.use_commission);
  2776 + th.setData({[txt4]:th.data.bn_goods.use_commission})
  2777 + }
  2778 +
  2779 +
  2780 +
2568 var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); 2781 var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
2569 //--------------如果使用余额--------------------- 2782 //--------------如果使用余额---------------------
2570 if (th.data.bn_use_money == 1) { 2783 if (th.data.bn_use_money == 1) {
@@ -2685,10 +2898,35 @@ Page({ @@ -2685,10 +2898,35 @@ Page({
2685 var txt = "formData.user_money"; 2898 var txt = "formData.user_money";
2686 var txt2 = "formData.order_amount"; 2899 var txt2 = "formData.order_amount";
2687 var txt3 = "formData.coupon_price"; 2900 var txt3 = "formData.coupon_price";
  2901 +
  2902 + //-- 最后的金额小于佣金 --
  2903 + if(parseFloat(order_m)<parseFloat(th.data.bn_goods.use_commission) ){
  2904 +
  2905 + if(th.data.bn_use_commission){
  2906 + wx.showToast({
  2907 + title: '应付金额小于本单佣金,不可使用!',
  2908 + icon: 'none',
  2909 + duration: 2000
  2910 + })
  2911 + }
  2912 +
  2913 + th.setData({
  2914 + bn_use_commission:0
  2915 + });
  2916 + }
  2917 +
  2918 +
  2919 + var txt4= "formData.use_commission";
  2920 +
  2921 + if(th.data.bn_use_commission){
  2922 + order_m=parseFloat(order_m)- parseFloat(th.data.bn_goods.use_commission);
  2923 + th.setData({[txt4]:th.data.bn_goods.use_commission})
  2924 + }
  2925 +
2688 var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); 2926 var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
2689 //--------------如果使用余额--------------------- 2927 //--------------如果使用余额---------------------
2690 if (th.data.bn_use_money == 1) { 2928 if (th.data.bn_use_money == 1) {
2691 - if (amoney > order_m) { 2929 + if (amoney > parseFloat(order_m)) {
2692 order_m = parseFloat(order_m).toFixed(2); 2930 order_m = parseFloat(order_m).toFixed(2);
2693 th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1 ,submit:0}) 2931 th.setData({ [txt]: order_m, [txt2]: 0, [txt3]: coupon_price, show_submit: 1 ,submit:0})
2694 } else { 2932 } else {
@@ -2823,6 +3061,11 @@ Page({ @@ -2823,6 +3061,11 @@ Page({
2823 //是不是重新提交 3061 //是不是重新提交
2824 if (th.data.is_continue == 1) item.is_continue = 1; 3062 if (th.data.is_continue == 1) item.is_continue = 1;
2825 3063
  3064 + //-- 如果有使用佣金抵扣的话 --
  3065 + if(th.data.bn_use_commission){
  3066 + item.use_commission=th.data.bn_goods.use_commission;
  3067 + }
  3068 +
2826 //获取立即购买的商品的信息 3069 //获取立即购买的商品的信息
2827 var gg = to.get_b_now(); 3070 var gg = to.get_b_now();
2828 //--商品的房间号-- 3071 //--商品的房间号--
@@ -2979,6 +3222,7 @@ Page({ @@ -2979,6 +3222,7 @@ Page({
2979 pt_res = res.data.data; 3222 pt_res = res.data.data;
2980 } 3223 }
2981 }) 3224 })
  3225 +
2982 if (pt_res) { 3226 if (pt_res) {
2983 //平摊赋值 3227 //平摊赋值
2984 goods.account = pt_res[0].fisrt_account; 3228 goods.account = pt_res[0].fisrt_account;
@@ -3101,6 +3345,11 @@ Page({ @@ -3101,6 +3345,11 @@ Page({
3101 item.coupon_price = 0; 3345 item.coupon_price = 0;
3102 } 3346 }
3103 3347
  3348 + //-- 如果有使用佣金抵扣的话 --
  3349 + if(th.data.cart_use_commission){
  3350 + item.use_commission=t_item.can_usecommise;
  3351 + }
  3352 +
3104 var order_prom_list = {}; 3353 var order_prom_list = {};
3105 //--判断有没有优惠活动-- 3354 //--判断有没有优惠活动--
3106 if (t_item.order_prom_amount > 0) { 3355 if (t_item.order_prom_amount > 0) {
@@ -3372,7 +3621,6 @@ Page({ @@ -3372,7 +3621,6 @@ Page({
3372 if (pdata.length == 0) return; 3621 if (pdata.length == 0) return;
3373 var str = JSON.stringify(pdata); 3622 var str = JSON.stringify(pdata);
3374 3623
3375 -  
3376 wx.showLoading({ title: "加载中" }); 3624 wx.showLoading({ title: "加载中" });
3377 th.setData({ submit: 1,}) 3625 th.setData({ submit: 1,})
3378 wx.request({ 3626 wx.request({
@@ -3668,6 +3916,20 @@ Page({ @@ -3668,6 +3916,20 @@ Page({
3668 th.setData({ bn_use_money: !th.data.bn_use_money }); 3916 th.setData({ bn_use_money: !th.data.bn_use_money });
3669 th.calculatePrice2(); 3917 th.calculatePrice2();
3670 }, 3918 },
  3919 +
  3920 + //立即购买的时候,使用余额
  3921 + set_bn_commission:function(){
  3922 + var th = this;
  3923 + th.setData({ bn_use_commission: !th.data.bn_use_commission });
  3924 + th.calculatePrice2();
  3925 + },
  3926 + //加入购物车使用余额
  3927 + set_cart_commission:function(){
  3928 + var th = this;
  3929 + th.setData({ cart_use_commission: !th.data.cart_use_commission });
  3930 + th.calculatePrice();
  3931 + },
  3932 +
3671 set_js_useyuer: function () { 3933 set_js_useyuer: function () {
3672 var th = this; 3934 var th = this;
3673 th.setData({ js_use_money: !th.data.js_use_money }); 3935 th.setData({ js_use_money: !th.data.js_use_money });
@@ -3675,7 +3937,6 @@ Page({ @@ -3675,7 +3937,6 @@ Page({
3675 }, 3937 },
3676 3938
3677 3939
3678 -  
3679 //----------立即购买,选择物流------------- 3940 //----------立即购买,选择物流-------------
3680 bindPickerChange: function (e) { 3941 bindPickerChange: function (e) {
3681 var ind = e.detail.value 3942 var ind = e.detail.value
pages/cart/cart2/cart2.wxml
@@ -279,6 +279,16 @@ @@ -279,6 +279,16 @@
279 279
280 </view> 280 </view>
281 281
  282 +
  283 + <!-----使用佣金------>
  284 + <view class="set-mes bdr_t-14" wx:if="{{cart_commission>0 && can_commission}}">
  285 +
  286 + <view class="use-item" bindtap='set_cart_commission'>
  287 + <icon color="{{cart_use_commission?'red':'gray'}}" size="16" type="success"></icon>
  288 + <view class="yu_er">使用佣金 :¥{{cart_commission}} </view>
  289 + </view>
  290 + </view>
  291 +
282 <!-- ---使用余额---- --> 292 <!-- ---使用余额---- -->
283 <view class="set-mes bdr_t-14" wx:if="{{yuer>0}}"> 293 <view class="set-mes bdr_t-14" wx:if="{{yuer>0}}">
284 <view class="use-item" bindtap='set_js_useyuer'> 294 <view class="use-item" bindtap='set_js_useyuer'>
@@ -494,6 +504,15 @@ @@ -494,6 +504,15 @@
494 <view class="xc-right" style="margin-right: 12rpx; border-color: #d7642b;"></view> 504 <view class="xc-right" style="margin-right: 12rpx; border-color: #d7642b;"></view>
495 </view> 505 </view>
496 506
  507 +
  508 + <!-----使用佣金------>
  509 + <view class="set-mes bdr_t-14" wx:if="{{bn_goods.use_commission>0 && can_commission}}">
  510 + <view class="use-item" bindtap='set_bn_commission'>
  511 + <icon color="{{bn_use_commission?'red':'gray'}}" size="16" type="success"></icon>
  512 + <view class="yu_er">使用佣金 :¥{{bn_goods.use_commission}} </view>
  513 + </view>
  514 + </view>
  515 +
497 <!-----使用余额------> 516 <!-----使用余额------>
498 <view class="set-mes bdr_t-14" wx:if="{{yuer>0}}"> 517 <view class="set-mes bdr_t-14" wx:if="{{yuer>0}}">
499 <view class="use-item" bindtap='set_bn_useyuer'> 518 <view class="use-item" bindtap='set_bn_useyuer'>
pages/cart/cart2_inte/cart2_inte.js
@@ -142,6 +142,10 @@ Page({ @@ -142,6 +142,10 @@ Page({
142 }, 1); 142 }, 1);
143 143
144 144
  145 + //判断是不是佣金抵扣
  146 + getApp().is_distribut(this);
  147 +
  148 +
145 }, 149 },
146 onUnload: function () { this.setData({ isclose: 1 }) }, 150 onUnload: function () { this.setData({ isclose: 1 }) },
147 onHide: function () { 151 onHide: function () {
@@ -393,6 +397,30 @@ Page({ @@ -393,6 +397,30 @@ Page({
393 var inte_data = tt.data.data.pageData[0]; 397 var inte_data = tt.data.data.pageData[0];
394 t.data.data.shop_price = inte_data.addmoney; 398 t.data.data.shop_price = inte_data.addmoney;
395 t.data.data.integral = inte_data.integral; 399 t.data.data.integral = inte_data.integral;
  400 +
  401 + //-- 计算获得佣金的金额 --
  402 + if (getApp().globalData.userInfo.is_distribut
  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 +
  418 + t.data.data.use_commission = c_num;
  419 +
  420 + }
  421 +
  422 +
  423 +
396 th.setData({ 424 th.setData({
397 bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et, index: m_wind, 425 bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et, index: m_wind,
398 bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et 426 bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et
@@ -655,6 +683,31 @@ Page({ @@ -655,6 +683,31 @@ Page({
655 var txt2 = "formData.order_amount"; 683 var txt2 = "formData.order_amount";
656 var txt4 = "formData.integral"; 684 var txt4 = "formData.integral";
657 685
  686 +
  687 + //-- 最后的金额小于佣金 --
  688 + if(parseFloat(order_m)<parseFloat(th.data.bn_goods.use_commission)){
  689 +
  690 + if(th.data.bn_use_commission){
  691 + wx.showToast({
  692 + title: '应付金额小于本单佣金,不可使用!',
  693 + icon: 'none',
  694 + duration: 2000
  695 + })
  696 + }
  697 +
  698 + th.setData({
  699 + cart_use_commission:0
  700 + });
  701 +
  702 + }
  703 +
  704 +
  705 + var txt5 = "formData.use_commission";
  706 + if(th.data.bn_use_commission){
  707 + order_m=parseFloat(order_m)- parseFloat(th.data.bn_goods.use_commission);
  708 + th.setData({[txt5]:th.data.bn_goods.use_commission})
  709 + }
  710 +
658 var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money); 711 var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
659 //--------------如果使用余额--------------------- 712 //--------------如果使用余额---------------------
660 if (th.data.bn_use_money == 1) { 713 if (th.data.bn_use_money == 1) {
@@ -754,7 +807,13 @@ Page({ @@ -754,7 +807,13 @@ Page({
754 //是不是重新提交 807 //是不是重新提交
755 if (th.data.is_continue == 1) item.is_continue = 1; 808 if (th.data.is_continue == 1) item.is_continue = 1;
756 809
757 - //获取立即购买的商品的信息 810 + //-- 如果有使用佣金抵扣的话 --
  811 + if(th.data.bn_use_commission){
  812 + item.use_commission=th.data.bn_goods.use_commission;
  813 + }
  814 +
  815 +
  816 + //获取立即购买的商品的信息
758 var gg = to.get_b_now(); 817 var gg = to.get_b_now();
759 //--商品的房间号-- 818 //--商品的房间号--
760 if (gg.room_id && gg.room_id > 0) { 819 if (gg.room_id && gg.room_id > 0) {
@@ -1191,6 +1250,14 @@ Page({ @@ -1191,6 +1250,14 @@ Page({
1191 buycard: function () { 1250 buycard: function () {
1192 getApp().goto("/pages/user/plus/plus"); 1251 getApp().goto("/pages/user/plus/plus");
1193 getApp().globalData.plus_buy_back = 1; 1252 getApp().globalData.plus_buy_back = 1;
  1253 + },
  1254 +
  1255 + //使用佣金抵扣
  1256 + set_bn_commission:function () {
  1257 + var th = this;
  1258 + th.setData({bn_use_commission: !th.data.bn_use_commission});
  1259 + th.calculatePrice2();
1194 } 1260 }
1195 1261
  1262 +
1196 }); 1263 });
pages/cart/cart2_inte/cart2_inte.wxml
@@ -130,6 +130,16 @@ @@ -130,6 +130,16 @@
130 </view> 130 </view>
131 </view> 131 </view>
132 132
  133 +
  134 + <!-----使用佣金抵扣,只有佣金小于尾款金额的时候------>
  135 + <view class="set-mes bdr_t-14"
  136 + wx:if="{{bn_goods.use_commission>0 && can_commission && formData.all_price>0 && bn_goods.use_commission<=formData.all_price}}">
  137 + <view class="use-item" bindtap='set_bn_commission'>
  138 + <icon color="{{bn_use_commission?'red':'gray'}}" size="16" type="success"></icon>
  139 + <view class="yu_er">使用佣金 :¥{{bn_goods.use_commission}} </view>
  140 + </view>
  141 + </view>
  142 +
133 <!-- ---使用余额---- --> 143 <!-- ---使用余额---- -->
134 <view class="set-mes bdr_t-14" wx:if="{{yuer>0 && formData.all_price>0}}"> 144 <view class="set-mes bdr_t-14" wx:if="{{yuer>0 && formData.all_price>0}}">
135 <view class="use-item" bindtap='set_bn_useyuer'> 145 <view class="use-item" bindtap='set_bn_useyuer'>
pages/cart/cart2_pt/cart2_pt.js
1 var t = getApp(), app = t, a = t.request, e = require("../../../utils/common.js"), 1 var t = getApp(), app = t, a = t.request, e = require("../../../utils/common.js"),
2 - s = require("../../../utils/util.js"),ut=s, o = require("../../../utils/md5.js"), to = getApp(); 2 + s = require("../../../utils/util.js"), ut = s, o = require("../../../utils/md5.js"), to = getApp();
3 var oo = t.globalData.setting, os = oo; 3 var oo = t.globalData.setting, os = oo;
4 var regeneratorRuntime = require('../../../utils/runtime.js'); 4 var regeneratorRuntime = require('../../../utils/runtime.js');
5 var util_pay = require("../../../utils/pay.js"); 5 var util_pay = require("../../../utils/pay.js");
6 6
7 Page({ 7 Page({
8 - data: {  
9 - url: t.globalData.setting.url,  
10 - resourceUrl: t.globalData.setting.resourceUrl,  
11 - imgUrl: t.globalData.setting.imghost,  
12 - goods: null,  
13 - order: null,  
14 - orderPrices: null,  
15 - coupons: null,  
16 - coupon: null,  
17 - invoiceToggle: !0,  
18 - payWithUserMoney: !0,  
19 - payWithPoints: !0,  
20 - maxWord: 0,  
21 - enterAddressPage: !1,  
22 - firstEnter: !0,  
23 - //页面获取的参数  
24 - param: null,  
25 - postdata: null,  
26 - //提交订单的格式  
27 - formData: {  
28 - order_amount: 0,//支付金额  
29 - total_amount: 0,//总价  
30 - all_price: 0,//商品卖的总价  
31 - pay_points: 0,//使用积分  
32 - user_money: 0,//使用余额  
33 - couponCode: "",//使用优惠券(多单就用逗号隔开)  
34 - shipping_price: 0,//物流费用 8 + data: {
  9 + url: t.globalData.setting.url,
  10 + resourceUrl: t.globalData.setting.resourceUrl,
  11 + imgUrl: t.globalData.setting.imghost,
  12 + goods: null,
  13 + order: null,
  14 + orderPrices: null,
  15 + coupons: null,
  16 + coupon: null,
  17 + invoiceToggle: !0,
  18 + payWithUserMoney: !0,
  19 + payWithPoints: !0,
  20 + maxWord: 0,
  21 + enterAddressPage: !1,
  22 + firstEnter: !0,
  23 + //页面获取的参数
  24 + param: null,
  25 + postdata: null,
  26 + //提交订单的格式
  27 + formData: {
  28 + order_amount: 0,//支付金额
  29 + total_amount: 0,//总价
  30 + all_price: 0,//商品卖的总价
  31 + pay_points: 0,//使用积分
  32 + user_money: 0,//使用余额
  33 + couponCode: "",//使用优惠券(多单就用逗号隔开)
  34 + shipping_price: 0,//物流费用
  35 + },
  36 + is_no_by: {},
  37 + /*----------------立即购买---------------------*/
  38 + is_b_now: 0, //0是购物车结算 1立即购买
  39 + bn_goods: null, //立即购买时候的调用商品
  40 + bn_use_money: 0,//是否使用余额
  41 + bn_exp_type: 1, //0是物流 1自提
  42 + bn_pick: 0, //选择的门店
  43 + bn_pickname: "", //选择的门店名称
  44 + bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流
  45 + /*------------------------*/
  46 + user_addr: null,//物流
  47 + userinfo: null, //获取会员
  48 + /*----------物流选择--------*/
  49 + wu_arr: null,
  50 + index: 0,
  51 +
  52 + //判断页面是返回回来的还是 首次进入的
  53 + isclose: 1,
  54 + kt_type: 0, //开团类型
  55 + is_pt_tz: 0,//是否开团团长
  56 + qh: '', //期号
  57 + pt_listno: '',//期号
  58 + is_normal: 0,
  59 + is_express: 0,//选择物流的控制器
  60 + yuer: 0,
  61 +
  62 + rank_switch: 0, //是不是开同等级卡
  63 + show_card: null, //显示的等级卡
  64 + card_name: '', //显示的卡的名称
  65 + card_cut_price: null,//减价多少钱
  66 + show_btn: 0,
  67 +
  68 + dis_config: null,
  69 + bn_use_commission: 0 //是不是使用佣金
  70 +
35 }, 71 },
36 - is_no_by:{},  
37 - /*----------------立即购买---------------------*/  
38 - is_b_now: 0, //0是购物车结算 1立即购买  
39 - bn_goods: null, //立即购买时候的调用商品  
40 - bn_use_money: 0,//是否使用余额  
41 - bn_exp_type: 1, //0是物流 1自提  
42 - bn_pick: 0, //选择的门店  
43 - bn_pickname: "", //选择的门店名称  
44 - bn_t_exp_t: 0, //判断商品和门店一起决定的物流自提的方式0 都可以 1自提 2物流  
45 - /*------------------------*/  
46 - user_addr: null,//物流  
47 - userinfo: null, //获取会员  
48 - /*----------物流选择--------*/  
49 - wu_arr: null,  
50 - index: 0,  
51 -  
52 - //判断页面是返回回来的还是 首次进入的  
53 - isclose: 1,  
54 - kt_type: 0, //开团类型  
55 - is_pt_tz: 0,//是否开团团长  
56 - qh: '', //期号  
57 - pt_listno: '',//期号  
58 - is_normal: 0,  
59 - is_express: 0,//选择物流的控制器  
60 - yuer: 0,  
61 -  
62 - rank_switch: 0, //是不是开同等级卡  
63 - show_card: null, //显示的等级卡  
64 - card_name: '', //显示的卡的名称  
65 - card_cut_price: null,//减价多少钱  
66 - show_btn:0,  
67 - },  
68 - onLoad: function (t) {  
69 - console.log("onLoad_pt_cart");  
70 - var th = this; this.setData({ is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow, });  
71 - var appD = getApp().get_b_now();  
72 -  
73 - th.data.postdata = appD;  
74 - //如果期号有值  
75 - if (appD.qh) {  
76 - th.data.qh = appD.qh;  
77 - th.data.pt_listno = appD.qh;  
78 - }  
79 - //th.data.kt_type=appD.kt_type;  
80 - th.setData({ kt_type: appD.kt_type });  
81 - if (appD.is_pt_tz) th.data.is_pt_tz = appD.is_pt_tz;  
82 - th.data.param = t;  
83 - //先获取物流,再获取用户信息,再展示页面  
84 - //th.get_wuliu(th.get_info(th.show_page));  
85 - },  
86 - onUnload: function () { this.setData({ isclose: 1 }) },  
87 -  
88 - //------获取会员信息-----先获取用户信息,在进行下一步---  
89 - get_info: function (func) {  
90 - var user_id = t.globalData.user_id;  
91 - to.auth.get_u(func);  
92 - },  
93 -  
94 - //-------------------获取物流---------------  
95 - get_wuliu(func) {  
96 - var th = this;  
97 - console.log("getwuliu4545");  
98 - to.getwuliu(function (e) {  
99 - if (th.data.is_default_logistics) {  
100 - //如果第一个不是开启默认,说明要让用户自己选  
101 - if (!e[0].is_default) {  
102 - th.setData({ is_default_logistics: 0 }); 72 + onLoad: function (t) {
  73 + console.log("onLoad_pt_cart");
  74 + var th = this;
  75 + this.setData({is_b_now: t.is_bnow == undefined ? 0 : t.is_bnow,});
  76 + var appD = getApp().get_b_now();
  77 +
  78 + th.data.postdata = appD;
  79 + //如果期号有值
  80 + if (appD.qh) {
  81 + th.data.qh = appD.qh;
  82 + th.data.pt_listno = appD.qh;
103 } 83 }
104 - }  
105 - th.setData({ wu_arr: e })  
106 - typeof func == "function" && func();  
107 - })  
108 - },  
109 -  
110 - //------获取会员收货地址-----  
111 - getuser_addr: function (func) {  
112 - if (to.globalData.baddr != null) {  
113 - var user_addr = to.globalData.baddr;  
114 - to.globalData.baddr = null;  
115 - func(user_addr);  
116 - } else {  
117 - a.get("/api/weshop/useraddress/page", {  
118 - data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600 },  
119 - success: function (su) {  
120 -  
121 - var user_addr = su.data.data.pageData;  
122 - var item = null;  
123 - var def_item = null;  
124 - for (var i = 0; i < user_addr.length; i++) {  
125 - if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i]; }  
126 - if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; }  
127 - }  
128 - if (item == null) item = def_item;  
129 - if (item == null) item = user_addr[0];  
130 - if (item == undefined) item = null;  
131 - func(item); 84 + //th.data.kt_type=appD.kt_type;
  85 + th.setData({kt_type: appD.kt_type});
  86 + if (appD.is_pt_tz) th.data.is_pt_tz = appD.is_pt_tz;
  87 + th.data.param = t;
  88 + //先获取物流,再获取用户信息,再展示页面
  89 + //th.get_wuliu(th.get_info(th.show_page));
  90 + //判断是不是佣金抵扣
  91 + getApp().is_distribut(this);
  92 + },
  93 + onUnload: function () {
  94 + this.setData({isclose: 1})
  95 + },
  96 +
  97 + //------获取会员信息-----先获取用户信息,在进行下一步---
  98 + get_info: function (func) {
  99 + var user_id = t.globalData.user_id;
  100 + to.auth.get_u(func);
  101 + },
  102 +
  103 + //-------------------获取物流---------------
  104 + get_wuliu(func) {
  105 + var th = this;
  106 + console.log("getwuliu4545");
  107 + to.getwuliu(function (e) {
  108 + if (th.data.is_default_logistics) {
  109 + //如果第一个不是开启默认,说明要让用户自己选
  110 + if (!e[0].is_default) {
  111 + th.setData({is_default_logistics: 0});
  112 + }
  113 + }
  114 + th.setData({wu_arr: e})
  115 + typeof func == "function" && func();
  116 + })
  117 + },
  118 +
  119 + //------获取会员收货地址-----
  120 + getuser_addr: function (func) {
  121 + if (to.globalData.baddr != null) {
  122 + var user_addr = to.globalData.baddr;
  123 + to.globalData.baddr = null;
  124 + func(user_addr);
  125 + } else {
  126 + a.get("/api/weshop/useraddress/page", {
  127 + data: {user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600},
  128 + success: function (su) {
  129 +
  130 + var user_addr = su.data.data.pageData;
  131 + var item = null;
  132 + var def_item = null;
  133 + for (var i = 0; i < user_addr.length; i++) {
  134 + if (user_addr[i]['is_default'] == 1) {
  135 + def_item = user_addr[i];
  136 + }
  137 + if (user_addr[i]['is_pickup'] == 1) {
  138 + item = user_addr[i];
  139 + }
  140 + }
  141 + if (item == null) item = def_item;
  142 + if (item == null) item = user_addr[0];
  143 + if (item == undefined) item = null;
  144 + func(item);
  145 + }
  146 + });
132 } 147 }
133 - });  
134 - }  
135 - },  
136 - //----------------展示页面,是再获取用户信息之后--------------  
137 - show_page: function () {  
138 - var th = this;  
139 - //th.setData({ userinfo: to.globalData.userInfo}); 会员信息要时时获取  
140 - var user = getApp().globalData.userInfo;  
141 - getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, {  
142 - data: { r: Math.random() },  
143 - success: function (e) {  
144 -  
145 - getApp().globalData.userInfo = e.data.data;  
146 - th.setData({ userinfo: e.data.data });  
147 - //获取立即购买的商品信息  
148 - th.get_buy_goods();  
149 -  
150 - //获取提现金额  
151 - //noinspection JSUnresolvedFunction  
152 - getApp().request.get("/api/weshop/withdrawals/summoney", {  
153 - data: { user_id: to.globalData.user_id, store_id: oo.stoid, status: 0 },  
154 - success: function (su) {  
155 - if (su.data.code == 0) {  
156 - var yuer = parseFloat(th.data.userinfo.user_money -  
157 - (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2);  
158 - if (yuer < 0) yuer = 0;  
159 - //noinspection JSUnresolvedVariable  
160 - th.setData({ txmon: su.data.data.summoney, yuer: yuer }); 148 + },
  149 + //----------------展示页面,是再获取用户信息之后--------------
  150 + show_page: function () {
  151 + var th = this;
  152 + //th.setData({ userinfo: to.globalData.userInfo}); 会员信息要时时获取
  153 + var user = getApp().globalData.userInfo;
  154 + getApp().request.get("/api/weshop/users/get/" + oo.stoid + "/" + user.user_id, {
  155 + data: {r: Math.random()},
  156 + success: function (e) {
  157 +
  158 + getApp().globalData.userInfo = e.data.data;
  159 + th.setData({userinfo: e.data.data});
  160 + //获取立即购买的商品信息
  161 + th.get_buy_goods();
  162 +
  163 + //获取提现金额
  164 + //noinspection JSUnresolvedFunction
  165 + getApp().request.get("/api/weshop/withdrawals/summoney", {
  166 + data: {user_id: to.globalData.user_id, store_id: oo.stoid, status: 0},
  167 + success: function (su) {
  168 + if (su.data.code == 0) {
  169 + var yuer = parseFloat(th.data.userinfo.user_money -
  170 + (th.data.userinfo.frozen_money > 0 ? th.data.userinfo.frozen_money : 0) - su.data.data.summoney).toFixed(2);
  171 + if (yuer < 0) yuer = 0;
  172 + //noinspection JSUnresolvedVariable
  173 + th.setData({txmon: su.data.data.summoney, yuer: yuer});
  174 + }
  175 + }
  176 + });
161 } 177 }
162 - }  
163 }); 178 });
164 - }  
165 - });  
166 - },  
167 -  
168 - //-----获取立即购买的商品信息----  
169 - get_buy_goods: function () {  
170 - var th = this, a = getApp().request;  
171 - var gg = th.data.postdata;  
172 - //调用商品  
173 - a.get("/api/weshop/goods/get/" + oo.stoid + "/" + gg.goods_id, {  
174 - success:async function (t) {  
175 - var gd = t.data.data;  
176 - if (!gd) return false; 179 + },
177 180
  181 + //-----获取立即购买的商品信息----
  182 + get_buy_goods: function () {
  183 + var th = this, a = getApp().request;
  184 + var gg = th.data.postdata;
  185 + //调用商品
  186 + a.get("/api/weshop/goods/get/" + oo.stoid + "/" + gg.goods_id, {
  187 + success: async function (t) {
  188 + var gd = t.data.data;
  189 + if (!gd) return false;
  190 +
  191 +
  192 + //-- 如果商品有同城配送的参数的时候,一件代发商品不能显示同城配送按钮 --
  193 + if (gd.is_same_city && th.data.is_same_city && gd.whsle_id <= 0) {
  194 +
  195 + await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + gg.pick_id, {}).then(res => {
  196 + if (res.data.code == 0) {
  197 + var pk = res.data.data;
  198 + if (pk && pk.is_same_city) {
  199 + th.setData({show_same_city: 1})
  200 + }
  201 + }
178 202
179 - //-- 如果商品有同城配送的参数的时候,一件代发商品不能显示同城配送按钮 --  
180 - if(gd.is_same_city && th.data.is_same_city && gd.whsle_id<=0){ 203 + })
181 204
182 - await getApp().request.promiseGet("/api/weshop/pickup/get/"+os.stoid+"/"+gg.pick_id, {}).then(res=>{  
183 - if(res.data.code==0){  
184 - var pk=res.data.data;  
185 - if(pk && pk.is_same_city){  
186 - th.setData({show_same_city:1})  
187 - }  
188 - } 205 + }
189 206
190 - }) 207 + t.data.data.original_img = oo.imghost + t.data.data.original_img;
  208 + t.data.data['buynum'] = gg.goods_num;
  209 + console.log(t.data.data);
  210 + var distr_t = 0, et = 0;
191 211
192 - } 212 + if (t.data.data.is_minishop == 1 && getApp().is_sp_hao()) {
193 213
194 - t.data.data.original_img = oo.imghost + t.data.data.original_img;  
195 - t.data.data['buynum'] = gg.goods_num;  
196 - console.log(t.data.data);  
197 - var distr_t = 0, et = 0; 214 + if (t.data.data.distr_type == 1 || gg.pick_dis == 1) {
  215 + wx.showToast({
  216 + title: "视频号仅支持物流",
  217 + icon: 'none',
  218 + duration: 2000
  219 + })
198 220
199 - if(t.data.data.is_minishop==1 && getApp().is_sp_hao()){ 221 + setTimeout(function () {
  222 + wx.navigateBack({delta: 1})
  223 + }, 1000)
200 224
201 - if(t.data.data.distr_type==1 || gg.pick_dis==1) {  
202 - wx.showToast({  
203 - title: "视频号仅支持物流",  
204 - icon: 'none',  
205 - duration: 2000  
206 - })  
207 225
208 - setTimeout(function(){  
209 - wx.navigateBack({delta: 1})  
210 - },1000) 226 + return false
  227 + }
211 228
  229 + t.data.data.distr_type = 2;
  230 + th.setData({show_same_city: 0})
212 231
213 - return false  
214 - } 232 + }
215 233
216 - t.data.data.distr_type=2;  
217 - th.setData({show_same_city:0}) 234 + if (t.data.data.distr_type == 0) {
  235 + distr_t = gg.pick_dis;
  236 + } else {
  237 + distr_t = t.data.data.distr_type;
  238 + }
  239 + switch (distr_t) {
  240 + case 0:
  241 + et = 1;
  242 + //-- 系统后台有设置要默认的 --
  243 + if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0;
  244 + break;
  245 + case 1:
  246 + et = 1;
  247 + break;
  248 + case 2:
  249 + et = 0;
  250 + break;
  251 + }
218 252
219 - } 253 + t.data.data.shop_price = gg.goods_price;
  254 + //--如果是普通购买的时候--
  255 + if (gg.is_normal == 1) {
  256 + t.data.data.prom_id = 0;
  257 + t.data.data.prom_type = 0;
  258 + t.data.data.is_normal = 1;
  259 +
  260 + var gd = t.data.data;
  261 + //-- 用商品的手店价来显示 --
  262 + gg.goods_price = gd.shop_price;
  263 + //---是不是购买等级卡成功的返回---等级卡显示的判断---
  264 + var is_card_back = getApp().globalData.is_card_back;
  265 + if (is_card_back) {
  266 + gg.goods_price = gd[th.data.card_name];
  267 + t.data.data.shop_price = gg.goods_price;
  268 + getApp().globalData.is_card_back = 0;
  269 + th.setData({card_cut_price: 0});
  270 + } else {
  271 + //--- 商品不能是搭配购,商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格
  272 + if (th.data.card_name && gd[th.data.card_name] > 0 && gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) {
  273 + var cut_p = gg.goods_price - gd[th.data.card_name];
  274 + th.setData({card_cut_price: cut_p});
  275 + }
  276 + }
220 277
221 - if (t.data.data.distr_type == 0) {  
222 - distr_t = gg.pick_dis;  
223 - } else {  
224 - distr_t = t.data.data.distr_type;  
225 - }  
226 - switch (distr_t) {  
227 - case 0:  
228 - et = 1;  
229 - //-- 系统后台有设置要默认的 --  
230 - if (th.data.json_d.pickupway && th.data.json_d.pickupway == 1) et = 0;  
231 - break;  
232 - case 1:  
233 - et = 1;  
234 - break;  
235 - case 2:  
236 - et = 0;  
237 - break;  
238 - } 278 + if (th.data.bn_goods) {
  279 + et = th.data.bn_exp_type;
  280 + }
239 281
240 - t.data.data.shop_price = gg.goods_price;  
241 - //--如果是普通购买的时候--  
242 - if (gg.is_normal == 1) {  
243 - t.data.data.prom_id = 0;  
244 - t.data.data.prom_type = 0;  
245 - t.data.data.is_normal = 1;  
246 -  
247 - var gd = t.data.data;  
248 - //-- 用商品的手店价来显示 --  
249 - gg.goods_price = gd.shop_price;  
250 - //---是不是购买等级卡成功的返回---等级卡显示的判断---  
251 - var is_card_back = getApp().globalData.is_card_back;  
252 - if (is_card_back) {  
253 - gg.goods_price = gd[th.data.card_name];  
254 - t.data.data.shop_price = gg.goods_price;  
255 - getApp().globalData.is_card_back = 0;  
256 - th.setData({ card_cut_price: 0 });  
257 - } else {  
258 - //--- 商品不能是搭配购,商家等级卡开通的情况下, 会员不是等级会员的情况, 商品有设置等级卡价格,同时等级卡价格小于商品的价格  
259 - if (th.data.card_name && gd[th.data.card_name] > 0 && gg.goods_price > gd[th.data.card_name] && !th.data.userinfo.card_field) {  
260 - var cut_p = gg.goods_price - gd[th.data.card_name];  
261 - th.setData({ card_cut_price: cut_p });  
262 - }  
263 - }  
264 282
265 - if (th.data.bn_goods) {  
266 - et = th.data.bn_exp_type;  
267 - } 283 + //-- 计算获得佣金的金额 --
  284 + if (getApp().globalData.userInfo.is_distribut
  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);
268 299
  300 + gd.use_commission = c_num;
  301 + t.data.data.use_commission = c_num;
269 302
270 - th.setData({  
271 - bn_goods: t.data.data, bn_pickname: gg.pick_name,  
272 - bn_pick: gg.pick_id, bn_t_exp_t: distr_t, is_normal: 1, bn_exp_type: et  
273 - }); 303 + }
274 304
275 305
  306 + th.setData({
  307 + bn_goods: t.data.data, bn_pickname: gg.pick_name,
  308 + bn_pick: gg.pick_id, bn_t_exp_t: distr_t, is_normal: 1, bn_exp_type: et
  309 + });
276 310
277 - th.calculatePrice2();  
278 - } else {  
279 311
280 - //--阶梯团很特殊,不能用总表来拿价格--  
281 - getApp().request.get("/api/weshop/teamlist/get/" + oo.stoid + "/" + gd.prom_id, {  
282 - success: function (tt) {  
283 -  
284 - if (tt.data.code == 0) {  
285 - var pt_data = tt.data.data;  
286 - var now = s.gettimestamp();  
287 -  
288 - if (pt_data.is_end == 1) {  
289 - t.data.data.prom_id = 0;  
290 - t.data.data.prom_type = 0;  
291 - t.data.data.is_normal = 1;  
292 - } else if (now > pt_data.end_time) {  
293 - t.data.data.prom_id = 0;  
294 - t.data.data.prom_type = 0;  
295 - t.data.data.is_normal = 1; 312 + th.calculatePrice2();
296 } else { 313 } else {
297 - t.data.data.shop_price = tt.data.data.price; //活动价格  
298 - t.data.data.is_normal = 0;  
299 - if (pt_data.kttype == 3) {  
300 - t.data.data.shop_price = tt.data.data.yf_price; //用定金来购买  
301 - }  
302 - }  
303 - } else {  
304 - t.data.data.prom_id = 0;  
305 - t.data.data.prom_type = 0;  
306 - t.data.data.is_normal = 1;  
307 - }  
308 314
309 - if (th.data.bn_goods) {  
310 - et = th.data.bn_exp_type;  
311 - } 315 + //--阶梯团很特殊,不能用总表来拿价格--
  316 + getApp().request.get("/api/weshop/teamlist/get/" + oo.stoid + "/" + gd.prom_id, {
  317 + success: function (tt) {
  318 +
  319 + if (tt.data.code == 0) {
  320 + var pt_data = tt.data.data;
  321 + var now = s.gettimestamp();
  322 +
  323 + if (pt_data.is_end == 1) {
  324 + t.data.data.prom_id = 0;
  325 + t.data.data.prom_type = 0;
  326 + t.data.data.is_normal = 1;
  327 + } else if (now > pt_data.end_time) {
  328 + t.data.data.prom_id = 0;
  329 + t.data.data.prom_type = 0;
  330 + t.data.data.is_normal = 1;
  331 + } else {
  332 + t.data.data.shop_price = tt.data.data.price; //活动价格
  333 + t.data.data.is_normal = 0;
  334 +
  335 + t.data.data.fir_rate = tt.data.data.fir_rate;
  336 + t.data.data.sec_rate = tt.data.data.sec_rate;
  337 + t.data.data.thi_rate = tt.data.data.thi_rate;
  338 + t.data.data.commission = tt.data.data.commission;
  339 +
  340 +
  341 + if (pt_data.kttype == 3) {
  342 + t.data.data.shop_price = tt.data.data.yf_price; //用定金来购买
  343 + }
  344 + }
  345 + } else {
  346 + t.data.data.prom_id = 0;
  347 + t.data.data.prom_type = 0;
  348 + t.data.data.is_normal = 1;
  349 + }
  350 +
  351 + if (th.data.bn_goods) {
  352 + et = th.data.bn_exp_type;
  353 + }
  354 +
  355 +
  356 + //-- 计算获得佣金的金额 --
  357 + if (getApp().globalData.userInfo.is_distribut
  358 + && th.data.dis_config && th.data.dis_config.is_yongjin_dk) {
  359 + var fir_num = 0;
  360 + var sec_num = 0;
  361 + var thi_num = 0;
  362 + if (th.data.dis_config.pattern == 1) {
  363 + fir_num = (t.data.data.fir_rate || 0) * gg.goods_num;
  364 + sec_num = (t.data.data.sec_rate || 0) * gg.goods_num;
  365 + thi_num = (t.data.data.thi_rate || 0) * gg.goods_num;
  366 + } else {
  367 + fir_num = parseFloat((t.data.data.commission || 0) * gg.goods_num * (th.data.dis_config.firstRate || 0) / 100).toFixed(2);
  368 + sec_num = parseFloat((t.data.data.commission || 0) * gg.goods_num * (th.data.dis_config.secondRate || 0) / 100).toFixed(2);
  369 + thi_num = parseFloat((t.data.data.commission || 0) * gg.goods_num * (th.data.dis_config.thirdRate || 0) / 100).toFixed(2);
  370 + }
  371 + var c_num = getApp().get_commission(fir_num, sec_num, thi_num, th);
  372 +
  373 + gd.use_commission = c_num;
  374 + t.data.data.use_commission = c_num;
  375 +
  376 + }
  377 +
312 378
313 - th.setData({  
314 - bn_goods: t.data.data, bn_pickname: gg.pick_name,  
315 - bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et  
316 - }); 379 + th.setData({
  380 + bn_goods: t.data.data, bn_pickname: gg.pick_name,
  381 + bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et
  382 + });
317 383
318 384
319 - //计算价格  
320 - th.calculatePrice2(); 385 + //计算价格
  386 + th.calculatePrice2();
  387 + }
  388 + });
  389 + }
  390 + }
  391 + });
  392 + },
  393 +
  394 + //----------子页返回父页触发----------
  395 + onShow: function () {
  396 + var th = this;
  397 + if (th.data.isclose == 0) {
  398 + wx.navigateTo({
  399 + url: "/pages/index/index/index"
  400 + })
  401 + } else {
  402 + this.getuser_addr(function (ie) {
  403 + //更换地址回来要重新调用计算价钱的接口
  404 + th.setData({user_addr: ie});
  405 + if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) {
  406 + th.setData({add_back: 1});
  407 + if (th.data.bn_goods) th.calculatePrice2();
  408 + }
  409 + })
  410 + //--更新默认地址--,看一下是不是跳到地址页面
  411 + if (!getApp().globalData.is_cart_old) {
  412 + this.update_code();
  413 + } else {
  414 + getApp().globalData.is_cart_old = 0;
321 } 415 }
322 - });  
323 - }  
324 - }  
325 - });  
326 - },  
327 -  
328 - //----------子页返回父页触发----------  
329 - onShow: function () {  
330 - var th = this;  
331 - if (th.data.isclose == 0) {  
332 - wx.navigateTo({  
333 - url: "/pages/index/index/index"  
334 - })  
335 - } else {  
336 - this.getuser_addr(function (ie) {  
337 - //更换地址回来要重新调用计算价钱的接口  
338 - th.setData({ user_addr: ie });  
339 - if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) {  
340 - th.setData({ add_back: 1 });  
341 - if (th.data.bn_goods) th.calculatePrice2();  
342 } 416 }
343 - })  
344 - //--更新默认地址--,看一下是不是跳到地址页面  
345 - if (!getApp().globalData.is_cart_old) {  
346 - this.update_code();  
347 - } else {  
348 - getApp().globalData.is_cart_old = 0;  
349 - }  
350 - }  
351 417
352 418
353 - //先获取是否有关闭使用优惠券  
354 - getApp().getConfig2(function (ee) {  
355 - var json_d = JSON.parse(ee.switch_list);  
356 - th.data.json_d = json_d;  
357 - th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值  
358 - var is_default_logistics = json_d.is_default_logistics;  
359 - var is_same_city = json_d.is_same_city;  
360 -  
361 - th.setData({ is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules,is_same_city:is_same_city,  
362 - rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics });  
363 -  
364 - var rank_switch = json_d.rank_switch;  
365 - var max_price = -1;  
366 - var show_card = null;  
367 - var name = "";  
368 - //如果有开等级卡的时候,  
369 - //因为都是调接口,要返回在计算  
370 - if (rank_switch == 2) {  
371 - //-- 获取所有的等级卡, --  
372 - getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid,  
373 - {}).then(res => {  
374 - if (res.data.code == 0) {  
375 - var plusCard = res.data.data;  
376 - //-- 循环判断,拿到最贵的那张卡 --  
377 - for (var ih in plusCard) {  
378 - if (plusCard[ih].IsStopBuy == true) { continue; }  
379 - if (max_price < 0) {  
380 - max_price = plusCard[ih].CardFee;  
381 - name = 'card' + plusCard[ih]['CorrPrice'];  
382 - show_card = plusCard[ih];  
383 - } else {  
384 - if (max_price < plusCard[ih].CardFee) {  
385 - max_price = plusCard[ih].CardFee;  
386 - name = 'card' + plusCard[ih]['CorrPrice'];  
387 - show_card = plusCard[ih];  
388 - }  
389 - }  
390 - } 419 + //先获取是否有关闭使用优惠券
  420 + getApp().getConfig2(function (ee) {
  421 + var json_d = JSON.parse(ee.switch_list);
  422 + th.data.json_d = json_d;
  423 + th.data.ispt_goods = json_d.ispt_goods; //是不是平摊到单品的控制参数赋值
  424 + var is_default_logistics = json_d.is_default_logistics;
  425 + var is_same_city = json_d.is_same_city;
  426 +
  427 + th.setData({
  428 + is_close_quan: json_d.is_close_quan, sales_rules: ee.sales_rules, is_same_city: is_same_city,
  429 + rank_switch: json_d.rank_switch, is_default_logistics: is_default_logistics
  430 + });
  431 +
  432 + var rank_switch = json_d.rank_switch;
  433 + var max_price = -1;
  434 + var show_card = null;
  435 + var name = "";
  436 + //如果有开等级卡的时候,
  437 + //因为都是调接口,要返回在计算
  438 + if (rank_switch == 2) {
  439 + //-- 获取所有的等级卡, --
  440 + getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?storeId=" + os.stoid,
  441 + {}).then(res => {
  442 + if (res.data.code == 0) {
  443 + var plusCard = res.data.data;
  444 + //-- 循环判断,拿到最贵的那张卡 --
  445 + for (var ih in plusCard) {
  446 + if (plusCard[ih].IsStopBuy == true) {
  447 + continue;
  448 + }
  449 + if (max_price < 0) {
  450 + max_price = plusCard[ih].CardFee;
  451 + name = 'card' + plusCard[ih]['CorrPrice'];
  452 + show_card = plusCard[ih];
  453 + } else {
  454 + if (max_price < plusCard[ih].CardFee) {
  455 + max_price = plusCard[ih].CardFee;
  456 + name = 'card' + plusCard[ih]['CorrPrice'];
  457 + show_card = plusCard[ih];
  458 + }
  459 + }
  460 + }
391 461
392 - if (show_card) {  
393 - name = name.toLowerCase();  
394 - th.setData({ card_name: name, show_card: show_card })  
395 - } 462 + if (show_card) {
  463 + name = name.toLowerCase();
  464 + th.setData({card_name: name, show_card: show_card})
  465 + }
  466 + }
  467 + //-----先获取物流,再获取用户信息,再展示页面-----
  468 + th.get_wuliu(th.get_info(th.show_page));
  469 + })
  470 + } else {
  471 + //-----先获取物流,再获取用户信息,再展示页面-----
  472 + th.get_wuliu(th.get_info(th.show_page));
396 } 473 }
397 - //-----先获取物流,再获取用户信息,再展示页面-----  
398 - th.get_wuliu(th.get_info(th.show_page));  
399 - })  
400 - } else {  
401 - //-----先获取物流,再获取用户信息,再展示页面-----  
402 - th.get_wuliu(th.get_info(th.show_page));  
403 - }  
404 - }, 1)  
405 -  
406 - },  
407 - //---------------检查是否有收货地址-------------------  
408 - checkAddressList: function () {  
409 - var t = this;  
410 - return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({  
411 - title: "请先填写或选择收货地址~",  
412 - success: function (a) {  
413 - a.confirm ? t.enterAddressPage() : wx.navigateBack();  
414 - },  
415 - fail: function () {  
416 - wx.navigateBack();  
417 - }  
418 - }), !1);  
419 - },  
420 - showInvoice: function () {  
421 - this.setData({  
422 - invoiceToggle: !this.data.invoiceToggle  
423 - });  
424 - },  
425 - keyUpChangePay1: function (t) {  
426 - this.setData({  
427 - payWithUserMoney: !(t.detail.value.length > 0)  
428 - });  
429 - },  
430 - keyUpChangePay2: function (t) {  
431 - this.setData({  
432 - payWithPoints: !(t.detail.value.length > 0)  
433 - });  
434 - },  
435 - keyUpChangeNum: function (t) {  
436 - this.setData({  
437 - maxWord: t.detail.value.length  
438 - });  
439 - },  
440 - //---------计算立即购买----------  
441 - calculatePrice2:async function () {  
442 -  
443 - this.setData({submit:1});  
444 - wx.showLoading({  
445 - title: "处理中.",  
446 - mask:true  
447 - })  
448 -  
449 - var th = this, good = this.data.bn_goods;  
450 - //-----------计算商品总价--------------  
451 - var allpice = good.shop_price * good.buynum;  
452 - allpice = parseFloat(allpice).toFixed(2);  
453 - var txt = "formData.all_price";  
454 - th.setData({ [txt]: allpice, });  
455 -  
456 - //to.getwuliuprice(async function (rs) { 474 + }, 1)
  475 +
  476 + },
  477 + //---------------检查是否有收货地址-------------------
  478 + checkAddressList: function () {
  479 + var t = this;
  480 + return !(!this.data.order || null == this.data.order.userAddress) || (wx.showModal({
  481 + title: "请先填写或选择收货地址~",
  482 + success: function (a) {
  483 + a.confirm ? t.enterAddressPage() : wx.navigateBack();
  484 + },
  485 + fail: function () {
  486 + wx.navigateBack();
  487 + }
  488 + }), !1);
  489 + },
  490 + showInvoice: function () {
  491 + this.setData({
  492 + invoiceToggle: !this.data.invoiceToggle
  493 + });
  494 + },
  495 + keyUpChangePay1: function (t) {
  496 + this.setData({
  497 + payWithUserMoney: !(t.detail.value.length > 0)
  498 + });
  499 + },
  500 + keyUpChangePay2: function (t) {
  501 + this.setData({
  502 + payWithPoints: !(t.detail.value.length > 0)
  503 + });
  504 + },
  505 + keyUpChangeNum: function (t) {
  506 + this.setData({
  507 + maxWord: t.detail.value.length
  508 + });
  509 + },
  510 + //---------计算立即购买----------
  511 + calculatePrice2: async function () {
  512 +
  513 + this.setData({submit: 1});
  514 + wx.showLoading({
  515 + title: "处理中.",
  516 + mask: true
  517 + })
  518 +
  519 + var th = this, good = this.data.bn_goods;
  520 + //-----------计算商品总价--------------
  521 + var allpice = good.shop_price * good.buynum;
  522 + allpice = parseFloat(allpice).toFixed(2);
  523 + var txt = "formData.all_price";
  524 + th.setData({[txt]: allpice,});
  525 +
  526 + //to.getwuliuprice(async function (rs) {
457 console.log('calculatePrice2222'); 527 console.log('calculatePrice2222');
458 //console.log(rs); 528 //console.log(rs);
459 529
@@ -463,7 +533,7 @@ Page({ @@ -463,7 +533,7 @@ Page({
463 //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格---------- 533 //-----------当地址不为空,且是物流时,计算物流费用,同时阶梯团不计算拼团价格----------
464 if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) { 534 if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) {
465 535
466 - var user_addr=th.data.user_addr; 536 + var user_addr = th.data.user_addr;
467 var req_d = { 537 var req_d = {
468 province: user_addr.province, city: user_addr.city, district: user_addr.district, 538 province: user_addr.province, city: user_addr.city, district: user_addr.district,
469 wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid 539 wuliu: parseFloat(allpice).toFixed(2), store_id: os.stoid
@@ -480,13 +550,13 @@ Page({ @@ -480,13 +550,13 @@ Page({
480 var cut_good_weight = 0; 550 var cut_good_weight = 0;
481 for (let i in gd_arr_list) { 551 for (let i in gd_arr_list) {
482 let item = gd_arr_list[i]; 552 let item = gd_arr_list[i];
483 - 553 +
484 if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) { 554 if (back_data && back_data['is_by_all'] && (!back_data.no_free_goods || back_data.no_free_goods.indexOf(item.goods_id) == -1)) {
485 555
486 - if(item['exp_sum_type'] == 2) {  
487 - if (goods_weight < 0) goods_weight = 0;  
488 - cut_good_weight += item['weight'] * item['buynum'];  
489 - goods_weight += item['weight'] * item['buynum']; 556 + if (item['exp_sum_type'] == 2) {
  557 + if (goods_weight < 0) goods_weight = 0;
  558 + cut_good_weight += item['weight'] * item['buynum'];
  559 + goods_weight += item['weight'] * item['buynum'];
490 } 560 }
491 if (back_data.weight_free > 0) { 561 if (back_data.weight_free > 0) {
492 out_of_weight = (back_data.weight_free * 1000) - cut_good_weight; 562 out_of_weight = (back_data.weight_free * 1000) - cut_good_weight;
@@ -522,93 +592,101 @@ Page({ @@ -522,93 +592,101 @@ Page({
522 //如果是正值的时候 592 //如果是正值的时候
523 if (out_of_weight >= 0) out_of_weight = -cut_good_weight; 593 if (out_of_weight >= 0) out_of_weight = -cut_good_weight;
524 else out_of_weight = -back_data.weight_free * 1000; 594 else out_of_weight = -back_data.weight_free * 1000;
525 -  
526 -  
527 - var code = th.data.wu_arr[th.data.index].code;  
528 -  
529 - //--------------开始计算物流------------------  
530 - var shipping_price=0;  
531 - // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,  
532 - // goods_piece, th.data.user_addr, back_data, rs);  
533 -  
534 - var w_data={  
535 - store_id:os.stoid, code:code,  
536 - o_shipping_price:o_shipping_price,  
537 - goods_weight:goods_weight,  
538 - out_of_weight:out_of_weight,goods_piece:goods_piece,  
539 - user_addr_province:th.data.user_addr.province,  
540 - user_addr_city:th.data.user_addr.city,  
541 - user_addr_district:th.data.user_addr.district,  
542 - is_by_all:back_data && back_data.is_by_all?1:0,  
543 - no_free_goods:back_data && back_data.no_free_goods && back_data.no_free_goods.length>0?1:0, 595 +
  596 +
  597 + var code = th.data.wu_arr[th.data.index].code;
  598 +
  599 + //--------------开始计算物流------------------
  600 + var shipping_price = 0;
  601 + // var shipping_price = ut.calculatewuliu(code, o_shipping_price, goods_weight, out_of_weight,
  602 + // goods_piece, th.data.user_addr, back_data, rs);
  603 +
  604 + var w_data = {
  605 + store_id: os.stoid, code: code,
  606 + o_shipping_price: o_shipping_price,
  607 + goods_weight: goods_weight,
  608 + out_of_weight: out_of_weight, goods_piece: goods_piece,
  609 + user_addr_province: th.data.user_addr.province,
  610 + user_addr_city: th.data.user_addr.city,
  611 + user_addr_district: th.data.user_addr.district,
  612 + is_by_all: back_data && back_data.is_by_all ? 1 : 0,
  613 + no_free_goods: back_data && back_data.no_free_goods && back_data.no_free_goods.length > 0 ? 1 : 0,
544 } 614 }
545 615
546 - var is_ok=0;  
547 - await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {data:w_data,is_json:1}).then(res=>{  
548 - if(res.data.code==0){  
549 - shipping_price=res.data.data; is_ok=1; 616 + var is_ok = 0;
  617 + await getApp().request.promisePost('/api/weshop/order/getOrderWuLiPrice', {
  618 + data: w_data,
  619 + is_json: 1
  620 + }).then(res => {
  621 + if (res.data.code == 0) {
  622 + shipping_price = res.data.data;
  623 + is_ok = 1;
550 } 624 }
551 }) 625 })
552 - if(!is_ok){ 626 + if (!is_ok) {
553 wx.hideLoading(); 627 wx.hideLoading();
554 wx.showToast({ 628 wx.showToast({
555 - title: "计算物流错误", icon: 'none',duration: 2000 629 + title: "计算物流错误", icon: 'none', duration: 2000
556 }) 630 })
557 //th.setData({ show_submit:0 }); 631 //th.setData({ show_submit:0 });
558 632
559 return false; 633 return false;
560 } 634 }
561 635
562 - shipping_price = parseFloat(shipping_price).toFixed(2);  
563 - var wl_txt = "formData.shipping_price";  
564 - th.setData({ [wl_txt]: shipping_price, }) 636 + shipping_price = parseFloat(shipping_price).toFixed(2);
  637 + var wl_txt = "formData.shipping_price";
  638 + th.setData({[wl_txt]: shipping_price,})
565 639
566 - } else if(th.data.bn_exp_type == 1 ) {  
567 - var wl_txt = "formData.shipping_price";  
568 - th.setData({ [wl_txt]: 0, }) 640 + } else if (th.data.bn_exp_type == 1) {
  641 + var wl_txt = "formData.shipping_price";
  642 + th.setData({[wl_txt]: 0,})
569 } 643 }
570 644
571 - //判断是否同城配送,而且没有调用过  
572 - if(th.data.bn_exp_type==2 && th.data.user_addr){  
573 - var lon=0;var lat=0;  
574 - //-- 获取距离 --  
575 - await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", {  
576 - is_json: 1, data: {address:th.data.user_addr.more_address+th.data.user_addr.address}  
577 - }).then(res=>{  
578 - if(res.data.code==0){  
579 - var data= JSON.parse(res.data.data);  
580 - if(data.status==0){  
581 - lon=data.result.location.lng;  
582 - lat=data.result.location.lat;  
583 - }  
584 - }  
585 - })  
586 -  
587 - var gd_w=good['weight'] * good['buynum'];  
588 - //-- 获取距离 --  
589 - var req_data={  
590 - store_id:os.stoid,  
591 - order_amount:allpice,  
592 - lon:lon,lat:lat,  
593 - pickup_id:th.data.bn_pick,  
594 - goods_weight:gd_w  
595 - }  
596 -  
597 - var is_next=1;  
598 - //获取同城配送参数  
599 - await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", {is_json:1,data:req_data}).then(res=>{  
600 - if(res.data.code==0){  
601 - var wl_txt = "formData.shipping_price";  
602 - th.setData({ [wl_txt]: res.data.data, })  
603 - }else{  
604 - is_next=0;  
605 - wx.showToast({  
606 - title: res.data.msg, icon: 'none', duration: 2000  
607 - })  
608 - }  
609 - })  
610 - if(!is_next) return false  
611 - } 645 + //判断是否同城配送,而且没有调用过
  646 + if (th.data.bn_exp_type == 2 && th.data.user_addr) {
  647 + var lon = 0;
  648 + var lat = 0;
  649 + //-- 获取距离 --
  650 + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", {
  651 + is_json: 1, data: {address: th.data.user_addr.more_address + th.data.user_addr.address}
  652 + }).then(res => {
  653 + if (res.data.code == 0) {
  654 + var data = JSON.parse(res.data.data);
  655 + if (data.status == 0) {
  656 + lon = data.result.location.lng;
  657 + lat = data.result.location.lat;
  658 + }
  659 + }
  660 + })
  661 +
  662 + var gd_w = good['weight'] * good['buynum'];
  663 + //-- 获取距离 --
  664 + var req_data = {
  665 + store_id: os.stoid,
  666 + order_amount: allpice,
  667 + lon: lon, lat: lat,
  668 + pickup_id: th.data.bn_pick,
  669 + goods_weight: gd_w
  670 + }
  671 +
  672 + var is_next = 1;
  673 + //获取同城配送参数
  674 + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", {
  675 + is_json: 1,
  676 + data: req_data
  677 + }).then(res => {
  678 + if (res.data.code == 0) {
  679 + var wl_txt = "formData.shipping_price";
  680 + th.setData({[wl_txt]: res.data.data,})
  681 + } else {
  682 + is_next = 0;
  683 + wx.showToast({
  684 + title: res.data.msg, icon: 'none', duration: 2000
  685 + })
  686 + }
  687 + })
  688 + if (!is_next) return false
  689 + }
612 690
613 691
614 //-----------------总价----------------- 692 //-----------------总价-----------------
@@ -616,467 +694,509 @@ Page({ @@ -616,467 +694,509 @@ Page({
616 total_m = parseFloat(total_m).toFixed(2); 694 total_m = parseFloat(total_m).toFixed(2);
617 695
618 var atxt = "formData.total_amount"; 696 var atxt = "formData.total_amount";
619 - th.setData({ [atxt]: total_m, }) 697 + th.setData({[atxt]: total_m,})
620 var order_m = total_m; 698 var order_m = total_m;
621 699
622 var txt = "formData.user_money"; 700 var txt = "formData.user_money";
623 var txt2 = "formData.order_amount"; 701 var txt2 = "formData.order_amount";
  702 + var txt4 = "formData.use_commission";
  703 +
  704 + if(parseFloat(order_m)<parseFloat(th.data.bn_goods.use_commission)){
  705 + if(th.data.bn_use_commission){
  706 + wx.showToast({
  707 + title: '应付金额小于本单佣金,不可使用!',
  708 + icon: 'none',
  709 + duration: 2000
  710 + })
  711 + }
  712 +
  713 + th.setData({
  714 + bn_use_commission:0
  715 + });
  716 + }
  717 +
  718 +
  719 + if(th.data.bn_use_commission){
  720 + order_m=parseFloat(order_m)- parseFloat(th.data.bn_goods.use_commission);
  721 + th.setData({[txt4]:th.data.bn_goods.use_commission})
  722 + }
  723 +
624 //--------------如果使用余额--------------------- 724 //--------------如果使用余额---------------------
625 if (th.data.bn_use_money == 1 && th.data.yuer > 0) { 725 if (th.data.bn_use_money == 1 && th.data.yuer > 0) {
626 - if (parseFloat(th.data.yuer) > total_m) {  
627 - th.setData({ [txt]: total_m, [txt2]: 0,submit:0,show_btn:1 })  
628 - } else {  
629 - order_m = parseFloat(order_m) - parseFloat(th.data.yuer);  
630 - order_m = order_m.toFixed(2);  
631 - th.setData({ [txt]: th.data.yuer, [txt2]: order_m,submit:0,show_btn:1 })  
632 - } 726 + if (parseFloat(th.data.yuer) > total_m) {
  727 + th.setData({[txt]: total_m, [txt2]: 0, submit: 0, show_btn: 1})
  728 + } else {
  729 + order_m = parseFloat(order_m) - parseFloat(th.data.yuer);
  730 + order_m = order_m.toFixed(2);
  731 + th.setData({[txt]: th.data.yuer, [txt2]: order_m, submit: 0, show_btn: 1})
  732 + }
633 } else { 733 } else {
634 - th.setData({ [txt]: 0, [txt2]: order_m,submit:0,show_btn:1 }) 734 + th.setData({[txt]: 0, [txt2]: order_m, submit: 0, show_btn: 1})
635 } 735 }
636 736
637 wx.hideLoading(); 737 wx.hideLoading();
638 738
639 - //}); 739 + //});
640 740
641 - },  
642 - //--------------------提交订单-----------------------  
643 - submitForm: async function (t) {  
644 - if (this.data.is_summit_ing == 1) return false; //--提交中退出--  
645 - this.data.is_summit_ing = 1; 741 + },
  742 + //--------------------提交订单-----------------------
  743 + submitForm: async function (t) {
  744 + if (this.data.is_summit_ing == 1) return false; //--提交中退出--
  745 + this.data.is_summit_ing = 1;
  746 +
  747 + var th = this, pdata = new Array();
  748 + var ff = true;
  749 + //------------立即购买-------------
  750 + console.log("buy_new");
  751 +
  752 + //如果不是阶梯团,或者是普通购买,商家选择了物流,以及地址为空的时候
  753 + if (th.data.bn_exp_type == 0 && th.data.user_addr == null && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) {
  754 + ff = false;
  755 + getApp().my_warnning("请选择收货地址", 0, this);
  756 + this.data.is_summit_ing = 0;
  757 + }
  758 + if (!ff) return false;
  759 + var addr = th.data.user_addr;
  760 + if (th.data.bn_exp_type == 1) addr = null;
  761 +
  762 + console.log(th.data.formData);
  763 + console.log(th.data.wu_arr);
  764 + console.log(th.data.bn_exp_type);
  765 +
  766 + if (th.data.bn_exp_type == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) {
  767 + if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {
  768 + getApp().my_warnning("读取物流失败", 0, this);
  769 + this.data.is_summit_ing = 0;
  770 + return false;
  771 + }
  772 + }
646 773
647 - var th = this, pdata = new Array();  
648 - var ff = true;  
649 - //------------立即购买-------------  
650 - console.log("buy_new"); 774 + //阶梯团强制带1,自提~~~
  775 + if (th.data.kt_type == 3) {
  776 + th.data.bn_exp_type = 1;
  777 + }
651 778
652 - //如果不是阶梯团,或者是普通购买,商家选择了物流,以及地址为空的时候  
653 - if (th.data.bn_exp_type == 0 && th.data.user_addr == null && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) {  
654 - ff = false;  
655 - getApp().my_warnning("请选择收货地址", 0, this);  
656 - this.data.is_summit_ing = 0;  
657 - }  
658 - if (!ff) return false;  
659 - var addr = th.data.user_addr;  
660 - if (th.data.bn_exp_type == 1) addr = null;  
661 -  
662 - console.log(th.data.formData);  
663 - console.log(th.data.wu_arr);  
664 - console.log(th.data.bn_exp_type);  
665 -  
666 - if (th.data.bn_exp_type == 0 && (th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) {  
667 - if (th.data.wu_arr == null || th.data.wu_arr.length <= 0) {  
668 - getApp().my_warnning("读取物流失败", 0, this);  
669 - this.data.is_summit_ing = 0;  
670 - return false;  
671 - }  
672 - } 779 + var item = {
  780 + 'user_id': to.globalData.user_id,
  781 + 'consignee': addr == null ? "" : addr.consignee,
  782 + 'province': addr == null ? 0 : addr.province,
  783 + 'city': addr == null ? 0 : addr.city,
  784 + 'district': addr == null ? 0 : addr.district,
  785 + 'twon': addr == null ? 0 : addr.twon,
  786 + 'address': addr == null ? "" : addr.address,
  787 + 'more_address': addr == null ? "" : addr.more_address,
  788 + 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile,
  789 + 'email': '',
  790 + 'invoice_title': '',
  791 + 'goods_price': th.data.formData.all_price, //商品总价
  792 + 'shipping_price': th.data.formData.shipping_price, //物流金额
  793 + 'user_money': th.data.formData.user_money, //使用余额
  794 + 'total_amount': th.data.formData.total_amount, //订单总价
  795 + 'order_amount': th.data.formData.order_amount, //应付
  796 + 'user_note': t.detail.value.user_note, //用户备注
  797 + 'store_id': oo.stoid, //商家
  798 + 'pickup_id': th.data.bn_pick, //门店
  799 + 'exp_type': th.data.bn_exp_type, //配送方式
  800 + 'is_normal': th.data.bn_goods.is_normal, //是否是普通购买
  801 + 'pt_prom_id': th.data.bn_goods.prom_id, //拼单ID
  802 + 'is_pt_tz': th.data.is_pt_tz, //开团类型
  803 + 'order_goods': new Array(),
  804 + };
  805 +
  806 + //如果不是阶梯团,或者是普通购买,
  807 + if ((th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) {
  808 + item['shipping_code'] = th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code;
  809 + item['shipping_name'] = th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name;
  810 + }
673 811
674 - //阶梯团强制带1,自提~~~  
675 - if (th.data.kt_type == 3) {  
676 - th.data.bn_exp_type = 1;  
677 - } 812 + if (!th.data.bn_goods.is_normal) {
  813 + item.is_zsorder = th.data.kt_type + 1; //开团类型
  814 + }
  815 + //老会员成为分销下线需要的参数
  816 + if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) {
  817 + //判断一下分享人是不是分享商
  818 + await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => {
  819 + if (res.data.code == 0) {
  820 + var user = res.data.data;
  821 + if (user.is_distribut == 1) {
  822 + item.first_leader = parseInt(getApp().globalData.first_leader);
  823 + }
  824 + }
  825 + })
  826 + }
678 827
679 - var item = {  
680 - 'user_id': to.globalData.user_id,  
681 - 'consignee': addr == null ? "" : addr.consignee,  
682 - 'province': addr == null ? 0 : addr.province,  
683 - 'city': addr == null ? 0 : addr.city,  
684 - 'district': addr == null ? 0 : addr.district,  
685 - 'twon': addr == null ? 0 : addr.twon,  
686 - 'address': addr == null ? "" : addr.address,  
687 - 'more_address': addr == null ? "" : addr.more_address,  
688 - 'mobile': addr == null ? th.data.userinfo.mobile : addr.mobile,  
689 - 'email': '',  
690 - 'invoice_title': '',  
691 - 'goods_price': th.data.formData.all_price, //商品总价  
692 - 'shipping_price': th.data.formData.shipping_price, //物流金额  
693 - 'user_money': th.data.formData.user_money, //使用余额  
694 - 'total_amount': th.data.formData.total_amount, //订单总价  
695 - 'order_amount': th.data.formData.order_amount, //应付  
696 - 'user_note': t.detail.value.user_note, //用户备注  
697 - 'store_id': oo.stoid, //商家  
698 - 'pickup_id': th.data.bn_pick, //门店  
699 - 'exp_type': th.data.bn_exp_type, //配送方式  
700 - 'is_normal': th.data.bn_goods.is_normal, //是否是普通购买  
701 - 'pt_prom_id': th.data.bn_goods.prom_id, //拼单ID  
702 - 'is_pt_tz': th.data.is_pt_tz, //开团类型  
703 - 'order_goods': new Array(),  
704 - };  
705 -  
706 - //如果不是阶梯团,或者是普通购买,  
707 - if ((th.data.kt_type != 3 || th.data.bn_goods.is_normal == 1)) {  
708 - item['shipping_code'] = th.data.bn_exp_type == 1 ? 0 : th.data.wu_arr[th.data.index].code;  
709 - item['shipping_name'] = th.data.bn_exp_type == 1 ? '' : th.data.wu_arr[th.data.index].name;  
710 - } 828 + if (th.data.qh != '') {
  829 + item.team_qh = th.data.qh;
  830 + item.pt_listno = th.data.qh;
  831 + }
711 832
712 - if (!th.data.bn_goods.is_normal) {  
713 - item.is_zsorder = th.data.kt_type + 1; //开团类型  
714 - }  
715 - //老会员成为分销下线需要的参数  
716 - if (getApp().globalData.first_leader && !getApp().globalData.userInfo.first_leader) {  
717 - //判断一下分享人是不是分享商  
718 - await app.request.promiseGet("/api/weshop/users/get/" + os.stoid + "/" + getApp().globalData.first_leader, {}).then(res => {  
719 - if (res.data.code == 0) {  
720 - var user = res.data.data;  
721 - if (user.is_distribut == 1) {  
722 - item.first_leader = parseInt(getApp().globalData.first_leader);  
723 - } 833 + //-- 如果有使用佣金抵扣的话 --
  834 + if(th.data.bn_use_commission){
  835 + item.use_commission=th.data.bn_goods.use_commission;
724 } 836 }
725 - })  
726 - }  
727 837
728 - if (th.data.qh != '') {  
729 - item.team_qh = th.data.qh;  
730 - item.pt_listno = th.data.qh;  
731 - }  
732 838
733 - var gg = to.get_b_now();  
734 - var goods = {  
735 - 'goods_id': gg.goods_id,  
736 - 'goods_name': gg.goods_name,  
737 - 'goods_sn': gg.goods_sn,  
738 - 'goods_num': gg.goods_num,  
739 - 'market_price': th.data.bn_goods.market_price,  
740 - 'goods_price': th.data.bn_goods.shop_price,  
741 - 'member_goods_price': th.data.bn_goods.shop_price,  
742 - 'store_id': oo.stoid,  
743 - 'prom_type': th.data.bn_goods.prom_type, //促销活动类型  
744 - 'prom_id': th.data.bn_goods.prom_id, //促销活动id  
745 - };  
746 -  
747 - if(getApp().globalData.skinface_id){  
748 - goods.skinface_id=getApp().globalData.skinface_id;  
749 - }  
750 -  
751 - if(th.data.bn_goods.whsle_id){  
752 - item.is_whsle=1;  
753 - goods.is_whsle_goods=1;  
754 - }  
755 -  
756 - //--导购分享过来的id--  
757 - if (gg.guide_id) {  
758 - goods.guide_id = gg.guide_id;  
759 - goods.guide_type = gg.guide_type;  
760 - //调用接口判断是不是会员  
761 - await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => {  
762 - if (res.data.code == 0) {  
763 - goods.guide_name = res.data.data.salesman;  
764 - goods.guide_sn = res.data.data.salesman_no;  
765 - }  
766 - })  
767 - }  
768 839
  840 + var gg = to.get_b_now();
  841 + var goods = {
  842 + 'goods_id': gg.goods_id,
  843 + 'goods_name': gg.goods_name,
  844 + 'goods_sn': gg.goods_sn,
  845 + 'goods_num': gg.goods_num,
  846 + 'market_price': th.data.bn_goods.market_price,
  847 + 'goods_price': th.data.bn_goods.shop_price,
  848 + 'member_goods_price': th.data.bn_goods.shop_price,
  849 + 'store_id': oo.stoid,
  850 + 'prom_type': th.data.bn_goods.prom_type, //促销活动类型
  851 + 'prom_id': th.data.bn_goods.prom_id, //促销活动id
  852 + };
769 853
770 - //--商品的房间号--  
771 - if (gg.room_id && gg.room_id > 0) {  
772 - item.room_ids = gg.room_id;  
773 - goods.room_id = gg.room_id;  
774 - } 854 + if (getApp().globalData.skinface_id) {
  855 + goods.skinface_id = getApp().globalData.skinface_id;
  856 + }
775 857
776 - if (th.data.bn_goods.is_normal) { goods.is_pd_normal = 1; }  
777 -  
778 - item.order_goods.push(goods);  
779 - pdata.push(item);  
780 -  
781 - if (pdata.length == 0) return;  
782 - var str = JSON.stringify(pdata);  
783 - console.log("支付数据");  
784 - console.log(str);  
785 - //return false;  
786 - wx.showLoading({ title: "加载中" });  
787 - wx.request({  
788 - url: oo.url + '/api/weshop/order/createWxdOrder',  
789 - data: str,  
790 - method: 'POST',  
791 - header: {  
792 - 'content-type': 'application/json'  
793 - },// 设置请求的 header  
794 - success: function (res) { 858 + if (th.data.bn_goods.whsle_id) {
  859 + item.is_whsle = 1;
  860 + goods.is_whsle_goods = 1;
  861 + }
795 862
796 - wx.hideLoading();  
797 - if (res.statusCode == 200) {  
798 - var data = res.data;  
799 - if (data.code == 0) {  
800 - console.log(th.data.is_b_now);  
801 - //如果是购物车结算,还要删除购物车  
802 - if (th.data.is_b_now == 0) {  
803 - console.log(th.data.cartlist_y);  
804 - var list = th.data.cartlist_y;  
805 - for (var i = 0; i < list.length; i++) {  
806 - //删除购物车  
807 - getApp().request.delete("/api/weshop/cart/del/" + oo.stoid + "/" + list[i].id, {});  
808 - }  
809 - }  
810 - var order_amount = 0;  
811 - pdata.forEach(function (em, ind) {  
812 - order_amount += em.order_amount; 863 + //--导购分享过来的id--
  864 + if (gg.guide_id) {
  865 + goods.guide_id = gg.guide_id;
  866 + goods.guide_type = gg.guide_type;
  867 + //调用接口判断是不是会员
  868 + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then(res => {
  869 + if (res.data.code == 0) {
  870 + goods.guide_name = res.data.data.salesman;
  871 + goods.guide_sn = res.data.data.salesman_no;
  872 + }
813 }) 873 })
814 - //要进行判断,如果是用微信支付,就要跳转到支付界面  
815 - if (order_amount > 0) {  
816 - th.setData({ isclose: 0 });  
817 - //void e.jumpToCart4({  
818 - // order_sn: data.data,  
819 - // type:1,  
820 - // }, 1);  
821 - util_pay.pay(data.data, function () {  
822 - setTimeout(function () {  
823 - wx.reLaunch({  
824 - //url: "/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data,  
825 - url: "/pages/team/team_success/team_success?ordersn=" + data.data,  
826 - })  
827 - }, 1000)  
828 - }, function () {  
829 - //支付失败  
830 - setTimeout(function () {  
831 - //wx.navigateBack({ delta: 1 })  
832 - wx.reLaunch({  
833 - url: "/pages/user/order_list/order_list",  
834 - })  
835 - }, 1000)  
836 -  
837 - }, oo.stoid, 1); 874 + }
838 875
839 - } else {  
840 - var dd = {  
841 - parent_sn: data.data,  
842 - store_id: oo.stoid,  
843 - type: 1,  
844 - };  
845 - //return false;  
846 - getApp().request.post("/api/weshop/order/pay/createOrder", {  
847 - data: dd,  
848 - success: function (t) {  
849 - console.log(t);  
850 - // app.my_warnning("支付成功", 1, th);  
851 - wx.showToast({  
852 - title: '支付成功',  
853 - icon: 'success',  
854 - duration: 2000  
855 - });  
856 - setTimeout(function () {  
857 - th.setData({ isclose: 0 });  
858 -  
859 - if (th.data.is_normal == 1) {  
860 - /*--  
861 - wx.navigateTo({  
862 - url: "/pages/user/order_list/order_list",  
863 - })--*/  
864 - var url = "/pages/payment/pay_success/pay_success?type=1&order_sn=" + data.data;  
865 - wx.reLaunch({  
866 - url: url  
867 - })  
868 876
  877 + //--商品的房间号--
  878 + if (gg.room_id && gg.room_id > 0) {
  879 + item.room_ids = gg.room_id;
  880 + goods.room_id = gg.room_id;
  881 + }
  882 +
  883 + if (th.data.bn_goods.is_normal) {
  884 + goods.is_pd_normal = 1;
  885 + }
  886 +
  887 + item.order_goods.push(goods);
  888 + pdata.push(item);
  889 +
  890 + if (pdata.length == 0) return;
  891 + var str = JSON.stringify(pdata);
  892 + console.log("支付数据");
  893 + console.log(str);
  894 + //return false;
  895 + wx.showLoading({title: "加载中"});
  896 + wx.request({
  897 + url: oo.url + '/api/weshop/order/createWxdOrder',
  898 + data: str,
  899 + method: 'POST',
  900 + header: {
  901 + 'content-type': 'application/json'
  902 + },// 设置请求的 header
  903 + success: function (res) {
  904 +
  905 + wx.hideLoading();
  906 + if (res.statusCode == 200) {
  907 + var data = res.data;
  908 + if (data.code == 0) {
  909 + console.log(th.data.is_b_now);
  910 + //如果是购物车结算,还要删除购物车
  911 + if (th.data.is_b_now == 0) {
  912 + console.log(th.data.cartlist_y);
  913 + var list = th.data.cartlist_y;
  914 + for (var i = 0; i < list.length; i++) {
  915 + //删除购物车
  916 + getApp().request.delete("/api/weshop/cart/del/" + oo.stoid + "/" + list[i].id, {});
  917 + }
  918 + }
  919 + var order_amount = 0;
  920 + pdata.forEach(function (em, ind) {
  921 + order_amount += em.order_amount;
  922 + })
  923 + //要进行判断,如果是用微信支付,就要跳转到支付界面
  924 + if (order_amount > 0) {
  925 + th.setData({isclose: 0});
  926 + //void e.jumpToCart4({
  927 + // order_sn: data.data,
  928 + // type:1,
  929 + // }, 1);
  930 + util_pay.pay(data.data, function () {
  931 + setTimeout(function () {
  932 + wx.reLaunch({
  933 + //url: "/pages/payment/pay_success/pay_success?type=1&order_sn="+data.data,
  934 + url: "/pages/team/team_success/team_success?ordersn=" + data.data,
  935 + })
  936 + }, 1000)
  937 + }, function () {
  938 + //支付失败
  939 + setTimeout(function () {
  940 + //wx.navigateBack({ delta: 1 })
  941 + wx.reLaunch({
  942 + url: "/pages/user/order_list/order_list",
  943 + })
  944 + }, 1000)
  945 +
  946 + }, oo.stoid, 1);
  947 +
  948 + } else {
  949 + var dd = {
  950 + parent_sn: data.data,
  951 + store_id: oo.stoid,
  952 + type: 1,
  953 + };
  954 + //return false;
  955 + getApp().request.post("/api/weshop/order/pay/createOrder", {
  956 + data: dd,
  957 + success: function (t) {
  958 + console.log(t);
  959 + // app.my_warnning("支付成功", 1, th);
  960 + wx.showToast({
  961 + title: '支付成功',
  962 + icon: 'success',
  963 + duration: 2000
  964 + });
  965 + setTimeout(function () {
  966 + th.setData({isclose: 0});
  967 +
  968 + if (th.data.is_normal == 1) {
  969 + /*--
  970 + wx.navigateTo({
  971 + url: "/pages/user/order_list/order_list",
  972 + })--*/
  973 + var url = "/pages/payment/pay_success/pay_success?type=1&order_sn=" + data.data;
  974 + wx.reLaunch({
  975 + url: url
  976 + })
  977 +
  978 + } else {
  979 + wx.reLaunch({
  980 + url: "/pages/team/team_success/team_success?ordersn=" + data.data,
  981 + })
  982 + }
  983 +
  984 +
  985 + }, 1000)
  986 + }
  987 + });
  988 + }
869 } else { 989 } else {
870 - wx.reLaunch({  
871 - url: "/pages/team/team_success/team_success?ordersn=" + data.data,  
872 - }) 990 + th.data.is_summit_ing = 0; //是否提交中
  991 + getApp().confirmBox(data.msg);
873 } 992 }
  993 + } else {
  994 + th.data.is_summit_ing = 0; //是否提交中
  995 + console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode);
  996 + }
  997 + },
  998 + fail: function () {
  999 + th.data.is_summit_ing = 0; //是否提交中
  1000 + wx.hideLoading();
  1001 + console.log("index.js wx.request CheckCallUser fail");
  1002 + },
  1003 + complete: function () {
  1004 + }
  1005 + })
  1006 + },
  1007 + useCoupon: function () {
  1008 + if (this.data.order.couponNum <= 0) {
  1009 + //return t.showWarning("无可用优惠券");
  1010 + getApp().my_warnning("无可用优惠券", 0, this);
  1011 + return;
  1012 + }
  1013 + var a = {
  1014 + lid: this.data.coupon ? this.data.coupon.id : "0"
  1015 + };
  1016 + wx.navigateTo({
  1017 + url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a)
  1018 + });
  1019 + },
  1020 + //检查区域是不是包邮
  1021 + check_area: function (arr) {
  1022 + var user_addr = this.data.user_addr;
  1023 + if (!user_addr) return 0;
  1024 + for (var i in arr) {
  1025 + var item = arr[i];
  1026 + if (user_addr.twon == item || user_addr.district == item
  1027 + || user_addr.city == item || user_addr.province == item) {
  1028 + return 0;
  1029 + }
  1030 + }
  1031 + return 1;
  1032 + },
874 1033
  1034 + //检查立即购买的商品是不是不包邮
  1035 + check_good: function (arr, goods_id) {
  1036 + if (!goods_id) goods_id = this.data.goods.goods_id;
  1037 + for (var i in arr) {
  1038 + var item = arr[i];
  1039 + if (goods_id == item) return 0;
  1040 + }
  1041 + return 1;
  1042 + },
  1043 + check_by_area: function (region_list) {
  1044 + var arr = region_list.split(",");
  1045 + var check = this.check_area(arr);
  1046 + return !check;
  1047 + },
  1048 + check_by_goods: function (goods_list, goods_id) {
  1049 + var arr = goods_list.split(",");
  1050 + var check = this.check_good(arr, goods_id);
  1051 + return !check;
  1052 + },
  1053 + enterAddressPage: function () {
  1054 + getApp().globalData.is_cart_old = 1;
  1055 + this.data.enterAddressPage = !0, wx.navigateTo({
  1056 + url: "/pages/user/address_list/address_list"
  1057 + });
  1058 + },
875 1059
876 - }, 1000) 1060 + //--------立即购买时,选择自提和物流-----------
  1061 + setexptype_w: function (t) {
  1062 + var th = this;
  1063 + var ty = t.currentTarget.dataset.t, txt = t.currentTarget.dataset.txt;
  1064 + th.setData({[txt]: ty});
  1065 + var iszt = 1;
  1066 + if (ty == 0) {
  1067 + th.setData({is_all_zt: 0});
  1068 + } else {
  1069 + for (var i = 0; i < th.data.cartlist.length; i++) {
  1070 + var item = th.data.cartlist[i];
  1071 + if (item.exp_type == 0) {
  1072 + iszt = 0;
  1073 + break;
877 } 1074 }
878 - });  
879 } 1075 }
880 - }  
881 - else {  
882 - th.data.is_summit_ing = 0; //是否提交中  
883 - getApp().confirmBox(data.msg);  
884 - }  
885 - } else {  
886 - th.data.is_summit_ing = 0; //是否提交中  
887 - console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode);  
888 - }  
889 - },  
890 - fail: function () {  
891 - th.data.is_summit_ing = 0; //是否提交中  
892 - wx.hideLoading();  
893 - console.log("index.js wx.request CheckCallUser fail");  
894 - },  
895 - complete: function () { }  
896 - })  
897 - },  
898 - useCoupon: function () {  
899 - if (this.data.order.couponNum <= 0) {  
900 - //return t.showWarning("无可用优惠券");  
901 - getApp().my_warnning("无可用优惠券", 0, this);  
902 - return;  
903 - }  
904 - var a = {  
905 - lid: this.data.coupon ? this.data.coupon.id : "0"  
906 - };  
907 - wx.navigateTo({  
908 - url: "/pages/user/checkcoupon/checkcoupon?" + s.Obj2Str(a)  
909 - });  
910 - },  
911 - //检查区域是不是包邮  
912 - check_area: function (arr) {  
913 - var user_addr = this.data.user_addr;  
914 - if (!user_addr) return 0;  
915 - for (var i in arr) {  
916 - var item = arr[i];  
917 - if (user_addr.twon == item || user_addr.district == item  
918 - || user_addr.city == item || user_addr.province == item) {  
919 - return 0;  
920 - }  
921 - }  
922 - return 1;  
923 - },  
924 -  
925 - //检查立即购买的商品是不是不包邮  
926 - check_good: function (arr, goods_id) {  
927 - if (!goods_id) goods_id = this.data.goods.goods_id;  
928 - for (var i in arr) {  
929 - var item = arr[i];  
930 - if (goods_id == item) return 0;  
931 - }  
932 - return 1;  
933 - },  
934 - check_by_area: function (region_list) {  
935 - var arr = region_list.split(",");  
936 - var check = this.check_area(arr);  
937 - return !check;  
938 - },  
939 - check_by_goods: function (goods_list, goods_id) {  
940 - var arr = goods_list.split(",");  
941 - var check = this.check_good(arr, goods_id);  
942 - return !check;  
943 - },  
944 - enterAddressPage: function () {  
945 - getApp().globalData.is_cart_old = 1;  
946 - this.data.enterAddressPage = !0, wx.navigateTo({  
947 - url: "/pages/user/address_list/address_list"  
948 - });  
949 - },  
950 -  
951 - //--------立即购买时,选择自提和物流-----------  
952 - setexptype_w: function (t) {  
953 - var th = this;  
954 - var ty = t.currentTarget.dataset.t, txt = t.currentTarget.dataset.txt;  
955 - th.setData({ [txt]: ty });  
956 - var iszt = 1;  
957 - if (ty == 0) {  
958 - th.setData({ is_all_zt: 0 });  
959 - } else {  
960 - for (var i = 0; i < th.data.cartlist.length; i++) {  
961 - var item = th.data.cartlist[i];  
962 - if (item.exp_type == 0) { iszt = 0; break; }  
963 - }  
964 - th.setData({ is_all_zt: iszt });  
965 - }  
966 - //----计算此时购物车的价格----  
967 - th.calculatePrice();  
968 - },  
969 -  
970 - //--------立即购买时,选择自提和物流----------  
971 - setexptype: function (t) {  
972 - var th = this;  
973 - var ty = t.currentTarget.dataset.t;  
974 - th.setData({ bn_exp_type: ty });  
975 - //当物流为空的时候。  
976 - if (ty == 0 && th.data.wu_arr == null) {  
977 - return th.get_wuliu(th.calculatePrice2());  
978 - }  
979 - th.calculatePrice2()  
980 - console.log('setexptype');  
981 - },  
982 -  
983 - //--------立即购买时,使用余额--------  
984 - set_bn_useyuer: function () {  
985 - var th = this;  
986 - th.setData({ bn_use_money: !th.data.bn_use_money });  
987 - th.calculatePrice2();  
988 - },  
989 - set_js_useyuer: function () {  
990 - var th = this;  
991 - th.setData({ js_use_money: !th.data.js_use_money });  
992 - th.calculatePrice();  
993 - },  
994 -  
995 - //----------立即购买,选择物流-------------  
996 - bindPickerChange: function (e) {  
997 - var ind = e.detail.value  
998 - this.setData({ index: ind });  
999 - this.calculatePrice2();  
1000 - },  
1001 -  
1002 - //----------购物车结算,选择物流-------------  
1003 - bindPickerChange_w: function (e) {  
1004 - var ind = e.detail.value, txt = e.currentTarget.dataset.txt;  
1005 - this.setData({ [txt]: ind });  
1006 - this.calculatePrice();  
1007 - },  
1008 -  
1009 - cart_set_err: function (e) {  
1010 - var txt = e.currentTarget.dataset.err;  
1011 - var ob = {};  
1012 - ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif";  
1013 - this.setData(ob);  
1014 - },  
1015 -  
1016 - //// 开启物流的弹窗  
1017 - show_wu_arr: function (e) {  
1018 - this.setData({ open_express: 1 });  
1019 - },  
1020 -  
1021 - //更新下默认,在onshow里面  
1022 - update_code() {  
1023 - var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;  
1024 -  
1025 - var uii = setInterval(function () {  
1026 - if (th.data.wu_arr) {  
1027 - clearInterval(uii);  
1028 - for (var k = 0; k < th.data.wu_arr.length; k++) {  
1029 - var item = th.data.wu_arr[k];  
1030 - if (def_exp_code == item.code) {  
1031 - m_wind = k;  
1032 - } 1076 + th.setData({is_all_zt: iszt});
1033 } 1077 }
1034 - //--如果是立即购买--  
1035 - th.setData({ index: m_wind, is_express: m_wind });  
1036 - }  
1037 - }, 500)  
1038 - },  
1039 -  
1040 - // 关闭物流的弹窗  
1041 - close_express: function () {  
1042 - this.setData({ open_express: 0 });  
1043 - },  
1044 - // 选择物流  
1045 - click_express_name: function (e) {  
1046 - var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode;  
1047 - var index = e.currentTarget.dataset.idxe;  
1048 - var ob = { is_express: index, is_shipping_code: shippingcode, index: index };  
1049 - this.setData(ob);  
1050 - },  
1051 -  
1052 - //点击确定物流  
1053 - determine_expres: function (e) {  
1054 - this.setData({ open_express: 0 });  
1055 - this.calculatePrice2();  
1056 - },  
1057 - //设置默认物流  
1058 - select_default_logistics: function () {  
1059 - var th = this;  
1060 - var is_shipping_code = this.data.is_shipping_code  
1061 - getApp().request.put("/api/weshop/users/update", {  
1062 - data: { user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code },  
1063 - success: function (rse) {  
1064 - if (rse.data.code == 0) {  
1065 - getApp().globalData.userInfo.def_exp_code = is_shipping_code;  
1066 - th.setData({ open_express: 0 });  
1067 - //----计算此时购物车的价格,这个页面没有calculatePrice(),2021.7.19----  
1068 - //if(th.data.is_b_now==1) th.calculatePrice2();  
1069 - //else th.calculatePrice();  
1070 - th.calculatePrice2(); 1078 + //----计算此时购物车的价格----
  1079 + th.calculatePrice();
  1080 + },
  1081 +
  1082 + //--------立即购买时,选择自提和物流----------
  1083 + setexptype: function (t) {
  1084 + var th = this;
  1085 + var ty = t.currentTarget.dataset.t;
  1086 + th.setData({bn_exp_type: ty});
  1087 + //当物流为空的时候。
  1088 + if (ty == 0 && th.data.wu_arr == null) {
  1089 + return th.get_wuliu(th.calculatePrice2());
1071 } 1090 }
1072 - }  
1073 - })  
1074 - }, 1091 + th.calculatePrice2()
  1092 + console.log('setexptype');
  1093 + },
1075 1094
  1095 + //--------立即购买时,使用余额--------
  1096 + set_bn_useyuer: function () {
  1097 + var th = this;
  1098 + th.setData({bn_use_money: !th.data.bn_use_money});
  1099 + th.calculatePrice2();
  1100 + },
1076 1101
1077 - //跳转到购买卡  
1078 - buycard: function () {  
1079 - getApp().goto("/pages/user/plus/plus");  
1080 - getApp().globalData.plus_buy_back = 1;  
1081 - } 1102 + set_bn_commission: function () {
  1103 + var th = this;
  1104 + th.setData({bn_use_commission: !th.data.bn_use_commission});
  1105 + th.calculatePrice2();
  1106 + },
  1107 +
  1108 +
  1109 + set_js_useyuer: function () {
  1110 + var th = this;
  1111 + th.setData({js_use_money: !th.data.js_use_money});
  1112 + th.calculatePrice();
  1113 + },
  1114 +
  1115 + //----------立即购买,选择物流-------------
  1116 + bindPickerChange: function (e) {
  1117 + var ind = e.detail.value
  1118 + this.setData({index: ind});
  1119 + this.calculatePrice2();
  1120 + },
  1121 +
  1122 + //----------购物车结算,选择物流-------------
  1123 + bindPickerChange_w: function (e) {
  1124 + var ind = e.detail.value, txt = e.currentTarget.dataset.txt;
  1125 + this.setData({[txt]: ind});
  1126 + this.calculatePrice();
  1127 + },
  1128 +
  1129 + cart_set_err: function (e) {
  1130 + var txt = e.currentTarget.dataset.err;
  1131 + var ob = {};
  1132 + ob[txt] = this.data.imgUrl + "/miniapp/images/default_g_img.gif";
  1133 + this.setData(ob);
  1134 + },
  1135 +
  1136 + //// 开启物流的弹窗
  1137 + show_wu_arr: function (e) {
  1138 + this.setData({open_express: 1});
  1139 + },
  1140 +
  1141 + //更新下默认,在onshow里面
  1142 + update_code() {
  1143 + var th = this, m_wind = 0, def_exp_code = getApp().globalData.userInfo.def_exp_code;
  1144 +
  1145 + var uii = setInterval(function () {
  1146 + if (th.data.wu_arr) {
  1147 + clearInterval(uii);
  1148 + for (var k = 0; k < th.data.wu_arr.length; k++) {
  1149 + var item = th.data.wu_arr[k];
  1150 + if (def_exp_code == item.code) {
  1151 + m_wind = k;
  1152 + }
  1153 + }
  1154 + //--如果是立即购买--
  1155 + th.setData({index: m_wind, is_express: m_wind});
  1156 + }
  1157 + }, 500)
  1158 + },
  1159 +
  1160 + // 关闭物流的弹窗
  1161 + close_express: function () {
  1162 + this.setData({open_express: 0});
  1163 + },
  1164 + // 选择物流
  1165 + click_express_name: function (e) {
  1166 + var express_name = e.currentTarget.dataset.name, shippingcode = e.currentTarget.dataset.shippingcode;
  1167 + var index = e.currentTarget.dataset.idxe;
  1168 + var ob = {is_express: index, is_shipping_code: shippingcode, index: index};
  1169 + this.setData(ob);
  1170 + },
  1171 +
  1172 + //点击确定物流
  1173 + determine_expres: function (e) {
  1174 + this.setData({open_express: 0});
  1175 + this.calculatePrice2();
  1176 + },
  1177 + //设置默认物流
  1178 + select_default_logistics: function () {
  1179 + var th = this;
  1180 + var is_shipping_code = this.data.is_shipping_code
  1181 + getApp().request.put("/api/weshop/users/update", {
  1182 + data: {user_id: getApp().globalData.user_id, store_id: oo.stoid, def_exp_code: is_shipping_code},
  1183 + success: function (rse) {
  1184 + if (rse.data.code == 0) {
  1185 + getApp().globalData.userInfo.def_exp_code = is_shipping_code;
  1186 + th.setData({open_express: 0});
  1187 + //----计算此时购物车的价格,这个页面没有calculatePrice(),2021.7.19----
  1188 + //if(th.data.is_b_now==1) th.calculatePrice2();
  1189 + //else th.calculatePrice();
  1190 + th.calculatePrice2();
  1191 + }
  1192 + }
  1193 + })
  1194 + },
  1195 +
  1196 +
  1197 + //跳转到购买卡
  1198 + buycard: function () {
  1199 + getApp().goto("/pages/user/plus/plus");
  1200 + getApp().globalData.plus_buy_back = 1;
  1201 + }
1082 }); 1202 });
pages/cart/cart2_pt/cart2_pt.wxml
@@ -130,6 +130,14 @@ @@ -130,6 +130,14 @@
130 </block> 130 </block>
131 131
132 <view class="information bdr14"> 132 <view class="information bdr14">
  133 + <!-----使用佣金抵扣------>
  134 + <view class="set-mes" wx:if="{{bn_goods.use_commission>0 && can_commission && kt_type!=3}}">
  135 + <view class="use-item" bindtap='set_bn_commission' style="padding-left:0;padding-right:0;">
  136 + <icon color="{{bn_use_commission?'red':'gray'}}" size="16" type="success"></icon>
  137 + <view class="yu_er">使用余额 :¥{{bn_goods.use_commission}} </view>
  138 + </view>
  139 + </view>
  140 +
133 <!-----使用余额------> 141 <!-----使用余额------>
134 <view class="set-mes" wx:if="{{userinfo.user_money>0 && yuer>0}}"> 142 <view class="set-mes" wx:if="{{userinfo.user_money>0 && yuer>0}}">
135 <view class="use-item" bindtap='set_bn_useyuer' style="padding-left:0;padding-right:0;"> 143 <view class="use-item" bindtap='set_bn_useyuer' style="padding-left:0;padding-right:0;">
pages/cart/cart_wk/cart_wk.js
@@ -42,6 +42,9 @@ Page({ @@ -42,6 +42,9 @@ Page({
42 teamgroup: null, 42 teamgroup: null,
43 submit:1, //默认按钮是灰色 43 submit:1, //默认按钮是灰色
44 show_submit:0, //不线上 44 show_submit:0, //不线上
  45 +
  46 + dis_config: null,
  47 + bn_use_commission: 0 //是不是使用佣金
45 }, 48 },
46 49
47 /** 50 /**
@@ -69,6 +72,9 @@ Page({ @@ -69,6 +72,9 @@ Page({
69 th.get_wuliu(th.get_info(th.show_page)); 72 th.get_wuliu(th.get_info(th.show_page));
70 }, 1) 73 }, 1)
71 74
  75 + //判断是不是佣金抵扣
  76 + getApp().is_distribut(this);
  77 +
72 }, 78 },
73 /** 79 /**
74 * 生命周期函数--监听页面显示 80 * 生命周期函数--监听页面显示
@@ -327,6 +333,30 @@ Page({ @@ -327,6 +333,30 @@ Page({
327 } 333 }
328 334
329 order.order_goods = order_goods; 335 order.order_goods = order_goods;
  336 +
  337 + //-- 计算获得佣金的金额 --
  338 + if (getApp().globalData.userInfo.is_distribut
  339 + && th.data.dis_config && th.data.dis_config.is_yongjin_dk) {
  340 + var fir_num = 0;
  341 + var sec_num = 0;
  342 + var thi_num = 0;
  343 + if (th.data.dis_config.pattern == 1) {
  344 + fir_num = (inte_data.fir_rate || 0) * order_goods.goods_num;
  345 + sec_num = (inte_data.sec_rate || 0) * order_goods.goods_num;
  346 + thi_num = (inte_data.thi_rate || 0) * order_goods.goods_num;
  347 + } else {
  348 + fir_num = parseFloat((teamlist.commission || 0) * order_goods.goods_num * (th.data.dis_config.firstRate || 0) / 100).toFixed(2);
  349 + sec_num = parseFloat((teamlist.commission || 0) * order_goods.goods_num * (th.data.dis_config.secondRate || 0) / 100).toFixed(2);
  350 + thi_num = parseFloat((teamlist.commission || 0) * order_goods.goods_num * (th.data.dis_config.thirdRate || 0) / 100).toFixed(2);
  351 + }
  352 + var c_num = getApp().get_commission(fir_num, sec_num, thi_num, th);
  353 +
  354 + goods.use_commission = c_num;
  355 +
  356 + }
  357 +
  358 +
  359 +
330 this.setData({ 360 this.setData({
331 order: order, 361 order: order,
332 distr_type: distr_type, 362 distr_type: distr_type,
@@ -337,14 +367,32 @@ Page({ @@ -337,14 +367,32 @@ Page({
337 teamlist: teamlist, 367 teamlist: teamlist,
338 }); 368 });
339 369
340 - //--计算物流--  
341 - if (exp_type == 0) {  
342 - th.calculate_wuliu();  
343 - } else {  
344 - var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.tail_money;  
345 - allpice = allpice.toFixed(2);  
346 - th.setData({ exp_price: 0, allpice: allpice,submit:0,show_submit:1 })  
347 - } 370 + //--计算价格--
  371 + th.calculatePrice2();
  372 + },
  373 +
  374 +
  375 + calculatePrice2:function(){
  376 + wx.showLoading();
  377 + var th=this;
  378 + th.setData({submit:1})
  379 + //--计算物流--
  380 + if (th.data.exp_type == 0) {
  381 + th.calculate_wuliu();
  382 + } else {
  383 +
  384 +
  385 + var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.tail_money;
  386 + if(th.data.bn_use_commission){
  387 + allpice-=th.data.goods.use_commission;
  388 + }
  389 + allpice = allpice.toFixed(2);
  390 +
  391 +
  392 +
  393 + th.setData({ exp_price: 0, allpice: allpice,submit:0,show_submit:1 })
  394 + wx.hideLoading();
  395 + }
348 }, 396 },
349 397
350 //--图片失败,默认图片-- 398 //--图片失败,默认图片--
@@ -395,7 +443,6 @@ Page({ @@ -395,7 +443,6 @@ Page({
395 //--弹起支付框-- 443 //--弹起支付框--
396 to_pay() { 444 to_pay() {
397 445
398 -  
399 //如果有再计算价格的过程中,不能提交订单 446 //如果有再计算价格的过程中,不能提交订单
400 if(this.data.submit){ return false} 447 if(this.data.submit){ return false}
401 448
@@ -404,9 +451,6 @@ Page({ @@ -404,9 +451,6 @@ Page({
404 return getApp().my_warnning("请选择收货地址", 0, this); 451 return getApp().my_warnning("请选择收货地址", 0, this);
405 } 452 }
406 453
407 -  
408 -  
409 -  
410 this.setData({ show_pay_type: 1 }); 454 this.setData({ show_pay_type: 1 });
411 }, 455 },
412 456
@@ -453,6 +497,11 @@ Page({ @@ -453,6 +497,11 @@ Page({
453 dd.scene=getApp().globalData.scene; 497 dd.scene=getApp().globalData.scene;
454 } 498 }
455 499
  500 + if(th.data.bn_use_commission){
  501 + dd.use_commission=th.data.goods.use_commission;
  502 + }
  503 +
  504 +
456 var arr = []; 505 var arr = [];
457 arr.push(dd); 506 arr.push(dd);
458 console.log(JSON.stringify(arr)); 507 console.log(JSON.stringify(arr));
@@ -544,8 +593,16 @@ Page({ @@ -544,8 +593,16 @@ Page({
544 good.buynum=th.data.order.order_goods['goods_num']; 593 good.buynum=th.data.order.order_goods['goods_num'];
545 var gd_arr_list = []; 594 var gd_arr_list = [];
546 gd_arr_list.push(good); 595 gd_arr_list.push(good);
  596 +
  597 +
  598 +
  599 +
547 //--全部金额-- 600 //--全部金额--
548 var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.pt_tail_money; 601 var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.pt_tail_money;
  602 + if(th.data.bn_use_commission){
  603 + allpice-=th.data.goods.use_commission;
  604 + }
  605 +
549 606
550 //-----------当地址不为空,且是物流时,计算物流费用---------- 607 //-----------当地址不为空,且是物流时,计算物流费用----------
551 if (th.data.user_addr != null && th.data.exp_type == 0 && good.is_free_shipping == 0) { 608 if (th.data.user_addr != null && th.data.exp_type == 0 && good.is_free_shipping == 0) {
@@ -643,15 +700,57 @@ Page({ @@ -643,15 +700,57 @@ Page({
643 700
644 var exp_price = parseFloat(shipping_price).toFixed(2); 701 var exp_price = parseFloat(shipping_price).toFixed(2);
645 allpice = parseFloat(exp_price) + parseFloat(allpice); 702 allpice = parseFloat(exp_price) + parseFloat(allpice);
  703 +
  704 + if( allpice<th.data.goods.use_commission){
  705 + if(th.data.bn_use_commission){
  706 + wx.showToast({
  707 + title: '应付金额小于本单佣金,不可使用!',
  708 + icon: 'none',
  709 + duration: 2000
  710 + })
  711 + }
  712 +
  713 + th.setData({
  714 + bn_use_commission:0
  715 + });
  716 + }
  717 +
  718 +
  719 + if(th.data.bn_use_commission){
  720 + allpice-=th.data.goods.use_commission;
  721 + }
  722 +
  723 +
646 allpice = allpice.toFixed(2); 724 allpice = allpice.toFixed(2);
647 725
648 exp_price = parseFloat(exp_price); 726 exp_price = parseFloat(exp_price);
649 th.setData({ exp_price: exp_price, allpice: allpice,submit:0,show_submit:1 }) 727 th.setData({ exp_price: exp_price, allpice: allpice,submit:0,show_submit:1 })
650 } else { 728 } else {
651 var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.tail_money; 729 var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.tail_money;
652 - allpice = allpice.toFixed(2); 730 +
  731 + if( allpice<th.data.goods.use_commission) {
  732 + if (th.data.bn_use_commission) {
  733 + wx.showToast({
  734 + title: '应付金额小于本单佣金,不可使用!',
  735 + icon: 'none',
  736 + duration: 2000
  737 + })
  738 + }
  739 +
  740 + th.setData({
  741 + bn_use_commission: 0
  742 + });
  743 + }
  744 +
  745 + if(th.data.bn_use_commission){
  746 + allpice-=th.data.goods.use_commission;
  747 + }
  748 +
  749 + allpice = allpice.toFixed(2);
653 th.setData({ exp_price: 0, allpice: allpice,submit:0,show_submit:1}) 750 th.setData({ exp_price: 0, allpice: allpice,submit:0,show_submit:1})
654 } 751 }
  752 +
  753 + wx.hideLoading();
655 //}); 754 //});
656 755
657 }, 756 },
@@ -669,7 +768,6 @@ Page({ @@ -669,7 +768,6 @@ Page({
669 //-----------当地址不为空,且是物流时,计算物流费用---------- 768 //-----------当地址不为空,且是物流时,计算物流费用----------
670 if (th.data.user_addr != null) { 769 if (th.data.user_addr != null) {
671 770
672 -  
673 var lon=0;var lat=0; 771 var lon=0;var lat=0;
674 //-- 获取距离 -- 772 //-- 获取距离 --
675 await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { 773 await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", {
@@ -713,7 +811,12 @@ Page({ @@ -713,7 +811,12 @@ Page({
713 811
714 var exp_price = parseFloat(shipping_price).toFixed(2); 812 var exp_price = parseFloat(shipping_price).toFixed(2);
715 allpice = parseFloat(exp_price) + parseFloat(allpice); 813 allpice = parseFloat(exp_price) + parseFloat(allpice);
716 - allpice = allpice.toFixed(2); 814 + if(th.data.bn_use_commission){
  815 + allpice-=th.data.goods.use_commission;
  816 + }
  817 +
  818 +
  819 + allpice = allpice.toFixed(2);
717 820
718 exp_price = parseFloat(exp_price); 821 exp_price = parseFloat(exp_price);
719 th.setData({ exp_price: exp_price, allpice: allpice,submit:0,show_submit:1 }) 822 th.setData({ exp_price: exp_price, allpice: allpice,submit:0,show_submit:1 })
@@ -722,10 +825,17 @@ Page({ @@ -722,10 +825,17 @@ Page({
722 825
723 } else { 826 } else {
724 var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.tail_money; 827 var allpice = th.data.order.order_amount + th.data.order.user_money + th.data.order.tail_money;
  828 +
  829 + if(th.data.bn_use_commission){
  830 + allpice-=th.data.goods.use_commission;
  831 + }
  832 +
725 allpice = allpice.toFixed(2); 833 allpice = allpice.toFixed(2);
726 th.setData({ exp_price: 0, allpice: allpice,submit:0,show_submit:1}) 834 th.setData({ exp_price: 0, allpice: allpice,submit:0,show_submit:1})
727 } 835 }
728 836
  837 + wx.hideLoading();
  838 +
729 839
730 }, 840 },
731 841
@@ -850,4 +960,11 @@ Page({ @@ -850,4 +960,11 @@ Page({
850 }) 960 })
851 }, 961 },
852 962
  963 + //使用
  964 + set_bn_commission:function(){
  965 + var th = this;
  966 + th.setData({bn_use_commission: !th.data.bn_use_commission});
  967 + th.calculatePrice2();
  968 + }
  969 +
853 }) 970 })
854 \ No newline at end of file 971 \ No newline at end of file
pages/cart/cart_wk/cart_wk.wxml
@@ -96,7 +96,7 @@ @@ -96,7 +96,7 @@
96 </view> 96 </view>
97 97
98 <!--尾款--> 98 <!--尾款-->
99 -<view class='chentuan bdr14' style="margin-bottom: 100rpx;"> 99 +<view class='chentuan bdr14' >
100 <view class='ct_one jc_sb'> 100 <view class='ct_one jc_sb'>
101 <view class='ct_one_left'>尾款金额</view> 101 <view class='ct_one_left'>尾款金额</view>
102 <view class='ct_one_right'><text class='redwz'>¥{{order.tail_money}}</text> 102 <view class='ct_one_right'><text class='redwz'>¥{{order.tail_money}}</text>
@@ -110,16 +110,31 @@ @@ -110,16 +110,31 @@
110 </view> 110 </view>
111 </view> 111 </view>
112 112
  113 +
  114 +<!-----使用佣金抵扣,只有佣金小于尾款金额的时候------>
  115 +<view class="set-mes mgt20" wx:if="{{goods.use_commission>0 && can_commission && goods.use_commission<order.tail_money+exp_price}}">
  116 + <view class="use-item" bindtap='set_bn_commission'>
  117 + <icon color="{{bn_use_commission?'red':'gray'}}" size="16" type="success"></icon>
  118 + <view class="yu_er">使用佣金 :¥{{goods.use_commission}} </view>
  119 + </view>
  120 +</view>
  121 +
  122 +<view style="height:100rpx"></view>
  123 +
  124 +
113 <!--支付--> 125 <!--支付-->
114 <view class='zf shadow'> 126 <view class='zf shadow'>
115 <!-- <view class='zf_left'> 127 <!-- <view class='zf_left'>
116 <text class='zf_left_wz'>支付合计:</text> 128 <text class='zf_left_wz'>支付合计:</text>
117 <text class='zf_left_red'>¥{{filters.toFix(order.tail_money+exp_price,2)}}</text> 129 <text class='zf_left_red'>¥{{filters.toFix(order.tail_money+exp_price,2)}}</text>
118 </view> --> 130 </view> -->
119 - <view class='zf_left'>支付合计:<text class='zf_left_red'>¥{{filters.toFix(order.tail_money+exp_price,2)}}</text></view> 131 + <view class='zf_left'>支付合计:<text class='zf_left_red'>¥{{filters.toFix(order.tail_money+exp_price-(bn_use_commission?goods.use_commission:0) ,2)}}</text></view>
120 <view class="zf_btn {{submit?'gray':''}}" bindtap="to_pay">支付尾款</view> 132 <view class="zf_btn {{submit?'gray':''}}" bindtap="to_pay">支付尾款</view>
121 </view> 133 </view>
122 134
  135 +
  136 +
  137 +
123 <!--支付的方式选择,0微信支付 1余额支付--> 138 <!--支付的方式选择,0微信支付 1余额支付-->
124 <block wx:if="{{show_pay_type}}"> 139 <block wx:if="{{show_pay_type}}">
125 <view class="cover-layer" bindtap="close_show_pay"></view> 140 <view class="cover-layer" bindtap="close_show_pay"></view>
pages/user/order_detail/order_detail.js
@@ -68,7 +68,7 @@ Page({ @@ -68,7 +68,7 @@ Page({
68 requestOrderDetail: function(e) { 68 requestOrderDetail: function(e) {
69 var o = this,oid=e,th=this; 69 var o = this,oid=e,th=this;
70 r.get(o.data.url + "/api/weshop/order/get/"+os.stoid+"/"+e, { 70 r.get(o.data.url + "/api/weshop/order/get/"+os.stoid+"/"+e, {
71 - success: function(e) { 71 + success: async function(e) {
72 var r = e.data.data; 72 var r = e.data.data;
73 r.addTimeFormat = t.format(r.add_time); 73 r.addTimeFormat = t.format(r.add_time);
74 if (r.order_status == 0 && r.pay_status==0 ){ 74 if (r.order_status == 0 && r.pay_status==0 ){
@@ -119,6 +119,15 @@ Page({ @@ -119,6 +119,15 @@ Page({
119 } 119 }
120 120
121 121
  122 + r.use_commission=0;
  123 + //-- 如果有数据的话 --
  124 + await getApp().request.promiseGet("/api/weshop/orderMore/get/"+os.stoid + "/"+r.order_sn, {
  125 +
  126 + }).then(res=>{
  127 + if(res.data.code == 0 && res.data.data){
  128 + r.use_commission=res.data.data.use_commission;
  129 + }
  130 + })
122 131
123 132
124 //------获取订单商品------- 133 //------获取订单商品-------
pages/user/order_detail/order_detail.wxml
@@ -139,10 +139,16 @@ @@ -139,10 +139,16 @@
139 139
140 <view class="item"> 140 <view class="item">
141 <view>订单总价</view> 141 <view>订单总价</view>
142 - <view>¥ {{filters.toFix(order.order_amount+order.user_money+order.pt_tail_money,2)}}元</view> 142 + <view>¥ {{filters.toFix(order.order_amount+order.user_money+order.pt_tail_money+order.use_commission,2)}}元</view>
143 </view> 143 </view>
144 144
145 <view class="item-line"></view> 145 <view class="item-line"></view>
  146 +
  147 + <view class="item" wx:if="{{order.use_commission>0}}">
  148 + <view>使用佣金</view>
  149 + <view>¥ {{filters.toFix(order.use_commission,2)}}元</view>
  150 + </view>
  151 +
146 <view class="item" wx:if="{{order.user_money>0}}"> 152 <view class="item" wx:if="{{order.user_money>0}}">
147 <view>使用余额</view> 153 <view>使用余额</view>
148 <view wx:if="{{order.tail_pay_type==1}}">¥ {{filters.toFix(order.user_money+order.pt_tail_money,2)}}元</view> 154 <view wx:if="{{order.tail_pay_type==1}}">¥ {{filters.toFix(order.user_money+order.pt_tail_money,2)}}元</view>
pages/user/order_list/order_list.js
@@ -337,9 +337,24 @@ Page({ @@ -337,9 +337,24 @@ Page({
337 }); 337 });
338 data[ind]['g_num'] = g_num; 338 data[ind]['g_num'] = g_num;
339 }) 339 })
  340 +
  341 +
  342 + data[ind].use_commission=0;
  343 + //-- 如果有数据的话 --
  344 + await getApp().request.promiseGet("/api/weshop/orderMore/get/"+os.stoid + "/"+item.order_sn, {
  345 +
  346 + }).then(res=>{
  347 + if(res.data.code == 0 && res.data.data){
  348 + data[ind].use_commission=res.data.data.use_commission;
  349 + }
  350 + })
  351 +
  352 +
340 th.setData({orderList: data,}); 353 th.setData({orderList: data,});
341 354
342 }); 355 });
  356 +
  357 +
343 e.data.currentPage++ , 358 e.data.currentPage++ ,
344 wx.stopPullDownRefresh(); 359 wx.stopPullDownRefresh();
345 }, null, {store_id: os.stoid, user_id: oo.user_id}); 360 }, null, {store_id: os.stoid, user_id: oo.user_id});
pages/user/order_list/order_list.wxml
@@ -186,7 +186,7 @@ @@ -186,7 +186,7 @@
186 <view class="commodity_money flex baseline"> 186 <view class="commodity_money flex baseline">
187 <view>合计<text wx:if="{{item.discount!=underdefine && item.discount!=null && item.discount!=0}}" style="color:#d60021;">(改)</text>:</view> 187 <view>合计<text wx:if="{{item.discount!=underdefine && item.discount!=null && item.discount!=0}}" style="color:#d60021;">(改)</text>:</view>
188 <view class="fs24 c-r">¥</view> 188 <view class="fs24 c-r">¥</view>
189 - <view class="c-r">{{filters.toFix(item.order_amount+item.user_money+item.pt_tail_money,2)}} 189 + <view class="c-r">{{filters.toFix(item.order_amount+item.user_money+item.pt_tail_money+item.use_commission,2)}}
190 </view> 190 </view>
191 191
192 </view> 192 </view>
@@ -195,14 +195,14 @@ @@ -195,14 +195,14 @@
195 <view wx:if="{{item.is_zsorder==4}}" class="commodity_money flex baseline"> 195 <view wx:if="{{item.is_zsorder==4}}" class="commodity_money flex baseline">
196 <view>定金<text wx:if="{{item.discount!=underdefine && item.discount!=null && item.discount!=0}}" style="color:#d60021;">(改)</text>:</view> 196 <view>定金<text wx:if="{{item.discount!=underdefine && item.discount!=null && item.discount!=0}}" style="color:#d60021;">(改)</text>:</view>
197 <view class="fs24 c-r">¥</view> 197 <view class="fs24 c-r">¥</view>
198 - <view class="c-r">{{filters.toFix(item.order_amount+item.user_money,2)}} 198 + <view class="c-r">{{filters.toFix(item.order_amount+item.user_money+item.use_commission,2)}}
199 </view> 199 </view>
200 </view> 200 </view>
201 <view class="commodity_money flex baseline" wx:else> 201 <view class="commodity_money flex baseline" wx:else>
202 <view>合计<text wx:if="{{item.discount!=underdefine && item.discount!=null && item.discount!=0}}" style="color:#d60021;">(改)</text>:</view> 202 <view>合计<text wx:if="{{item.discount!=underdefine && item.discount!=null && item.discount!=0}}" style="color:#d60021;">(改)</text>:</view>
203 <view class="fs24 c-r">¥</view> 203 <view class="fs24 c-r">¥</view>
204 <view class="c-r"> 204 <view class="c-r">
205 - {{filters.toFix(item.order_amount+item.user_money,2)}} 205 + {{filters.toFix(item.order_amount+item.user_money+item.use_commission,2)}}
206 <text wx:if="{{item.coupon_price}}">+{{item.coupon_price}}元优惠券</text> 206 <text wx:if="{{item.coupon_price}}">+{{item.coupon_price}}元优惠券</text>
207 <text wx:if="{{item.integral}}">+{{item.integral}}积分</text> 207 <text wx:if="{{item.integral}}">+{{item.integral}}积分</text>
208 </view> 208 </view>
@@ -210,7 +210,7 @@ @@ -210,7 +210,7 @@
210 <view wx:if="{{item.pt_tail_money>0}}" class="commodity_money flex baseline"> 210 <view wx:if="{{item.pt_tail_money>0}}" class="commodity_money flex baseline">
211 <view>待支付尾款:</view> 211 <view>待支付尾款:</view>
212 <view class="fs24 c-r">¥</view> 212 <view class="fs24 c-r">¥</view>
213 - <view class="c-r">{{filters.toFix(item.pt_tail_money-item.shipping_price,2)}} 213 + <view class="c-r">{{filters.toFix(item.pt_tail_money+item.use_commission-item.shipping_price,2)}}
214 </view> 214 </view>
215 </view> 215 </view>
216 216