Commit c7930fd48783c9b397571d6fdfd69d21d42def3a

Authored by yvan.ni
1 parent b7df6b4b

1. 活动的分享优化 商品的分享优化

2.   购物车的功能优化
packageA/pages/activity_share/activity_share.js
... ... @@ -161,7 +161,10 @@ Page({
161 161 //---秒杀,拼团,促销---
162 162 var item=this.data.share_good;
163 163 if(item){
164   - var price = item.shop_price;
  164 + var price = item.price;
  165 + if(!price) price=item.shop_price;
  166 +
  167 +
165 168 var title= item.goods_name;
166 169 var img=this.data.url+item.original_img;
167 170 var url="/pages/goods/goodsInfo/goodsInfo?goods_id=" + th.data.gid;
... ...
packageA/pages/goods_share/goods_share.wxml
... ... @@ -10,8 +10,21 @@
10 10 <!-- 标题 -->
11 11 <view class="title">
12 12 <view class="title-item" bindtap="sale_sort">销量</view>
13   - <view class="title-item" bindtap="sort1">价格<text class="iconfont {{orderType=='asc'?'icon-shang':'icon-xia'}}"></text></view>
14   - <view class="title-item" bindtap="sort2">佣金<text class="iconfont {{orderType=='asc'?'icon-shang':'icon-xia'}}"></text></view>
  13 +
  14 + <block wx:if="{{orderField=='shop_price'}}">
  15 + <view class="title-item" bindtap="sort1">价格<text class="iconfont {{orderType=='asc'?'icon-shang':'icon-xia'}}"></text></view>
  16 + </block>
  17 + <block wx:else>
  18 + <view class="title-item" bindtap="sort1">价格<text class="iconfont icon-shang"></text></view>
  19 + </block>
  20 +
  21 + <block wx:if="{{orderField=='commission'}}">
  22 + <view class="title-item" bindtap="sort2">佣金<text class="iconfont {{orderType=='asc'?'icon-shang':'icon-xia'}}"></text></view>
  23 + </block>
  24 + <block wx:else>
  25 + <view class="title-item" bindtap="sort2">佣金<text class="iconfont icon-xia"></text></view>
  26 + </block>
  27 +
15 28 <view class="title-item" bindtap='new_sort'>最新</view>
16 29 </view>
17 30 <!-- 列表项 -->
... ...
pages/cart/cart2/cart2.js
... ... @@ -112,6 +112,8 @@ Page({
112 112 show_card:null, //显示的等级卡
113 113 card_name:'', //显示的卡的名称
114 114 card_cut_price:null,//减价多少钱
  115 +
  116 + show_submit:0, //提交按钮变正常显示
115 117  
116 118 },
117 119 onLoad: function(t) {
... ... @@ -140,8 +142,9 @@ Page({
140 142 //----------子页返回父页触发----------
141 143 onShow: function() {
142 144 var th=this;
  145 + th.setData({show_submit:0});
  146 +
143 147 if (th.data.isclose==0){
144   -
145 148 wx.navigateTo({
146 149 url: "/pages/index/index/index"
147 150 })
... ... @@ -153,7 +156,7 @@ Page({
153 156 console.log(ie)
154 157  
155 158 //地址切换要把包邮券清空
156   - if( !th.data.user_addr || th.data.user_addr.address_id!=ie.address_id){
  159 + if( !th.data.user_addr || !ie || th.data.user_addr.address_id!=ie.address_id){
157 160 var using_quan=th.data.using_quan;
158 161 for(var i in using_quan){
159 162 var item=using_quan[i];
... ... @@ -164,19 +167,22 @@ Page({
164 167 }
165 168 th.data.isget_by_quan={};
166 169 }
167   -
  170 +
  171 +
  172 + th.data.prom_goods_map={};
  173 + th.data.is_summit_ing=0;
168 174 //更换地址回来要重新调用计算价钱的接口
169 175 if(!th.data.user_addr || th.data.user_addr.address_id!=ie.address_id){
170 176 th.setData({user_addr: ie });
171 177 if (th.data.is_b_now == 1) {
172 178 if(th.data.bn_goods) {
173 179 th.setData({add_back:1});
174   - th.calculatePrice2();
  180 + //th.calculatePrice2();
175 181 }
176 182 }else{
177 183 if (th.data.cartlist){
178 184 th.setData({add_back:1});
179   - th.calculatePrice();
  185 + //th.calculatePrice();
180 186 }
181 187 }
182 188 }else{
... ... @@ -277,26 +283,31 @@ Page({
277 283  
278 284 //------获取会员收货地址-----
279 285 getuser_addr:function(func){
  286 + var th=this;
280 287 a.get("/api/weshop/useraddress/page", {
281   - data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600 },
  288 + data: { user_id: to.globalData.user_id, store_id: oo.stoid, pageSize: 600,t:Math.random()},
282 289 success: function (su) {
283 290 /*---
284 291 var user_addr=[
285 292 { 'address_id': 882, 'user_id': 2661, 'consignee': '测试测试测', 'province': 3102, 'city': 3431, 'district': 3466,
286 293 'address': 'ed', 'more_address': '山西-长治市-襄垣县-虎(音si)亭镇', 'mobile': 13012345678,'is_default':1},
287   - ];---*/
288   - var user_addr = su.data.data.pageData;
289   - var item = null;
290   - var def_item=null;
291   - for (var i = 0; i < user_addr.length; i++) {
292   - if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i];}
293   - if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; }
294   - }
295   -
296   - if (item == null) item = def_item;
297   - if (item == null) item = user_addr[0];
  294 + ];---*/
  295 + var item = null;
  296 + if(su.data.code==0 && su.data.data && su.data.data.pageData){
  297 + var user_addr = su.data.data.pageData;
  298 + var def_item=null;
  299 + for (var i = 0; i < user_addr.length; i++) {
  300 + if (user_addr[i]['is_default'] == 1) { def_item = user_addr[i];}
  301 + if (user_addr[i]['is_pickup'] == 1) { item = user_addr[i]; }
  302 + }
  303 +
  304 + if (item == null) item = def_item;
  305 + if (item == null) item = user_addr[0];
  306 + }
298 307  
299 308 if(item==undefined) item=null;
  309 + if(!item) th.setData({user_addr:null}); //地址为空的时候,要清空,因为返回的时候,有缓存
  310 +
300 311 func(item);
301 312 }
302 313 });
... ... @@ -341,7 +352,8 @@ Page({
341 352 }
342 353 });
343 354 },
344   -
  355 +
  356 +
345 357 //-----真的获取购物车,入口--------
346 358 get_cart: function () {
347 359 var th = this,app=getApp();
... ... @@ -360,11 +372,7 @@ Page({
360 372  
361 373 for (var i = 0; i < carr.length; i++) {
362 374 var item = carr[i];
363   - //要把优惠活动加入,prom_goods_map中,赠品不要运算
364   - if(item.prom_type==3 && item.is_gift!=1){
365   - await th.add_prom_goods_map(item);
366   - }
367   -
  375 +
368 376 //-- 如果是等级会员注册返回 --
369 377 if(is_card_back){
370 378 th.data.card_name=th.data.userinfo.card_field;
... ... @@ -383,12 +391,17 @@ Page({
383 391 // 拼团,搭配购不计算,赠品也不计算,同时会员还未购买等级会员
384 392 if(item[th.data.card_name]>0 && item['prom_type']!=5 && item['prom_type']!=6 && !th.data.userinfo.card_field
385 393 && !item.is_gift && !item['is_collocation'] && item.goods_price>item[th.data.card_name] ){
386   - item.cut_price= item.goods_price-item[th.data.card_name];
387   - carr[i].cut_price=(item.goods_price-item[th.data.card_name])*item.goods_num;
  394 + item.cut_price1= item.goods_price-item[th.data.card_name];
  395 + carr[i].cut_price1=(item.goods_price-item[th.data.card_name])*item.goods_num;
388 396 }
389 397  
390 398 }
391 399  
  400 + //要把优惠活动加入,prom_goods_map中,赠品不要运算
  401 + if(item.prom_type==3 && item.is_gift!=1){
  402 + await th.add_prom_goods_map(item);
  403 + }
  404 +
392 405  
393 406 item.original_img = oo.imghost + item.original_img;
394 407 /*----接口要弄出来的,先顶着-----*/
... ... @@ -399,7 +412,22 @@ Page({
399 412 if (arr.length > 0) {
400 413 for (var j = 0; j < arr.length; j++) {
401 414 if (arr[j].pickup_id == pcid) {
402   - arr[j].goods.push(item);
  415 + arr[j].goods.push(item);
  416 + if(item.is_gift!=1){
  417 + //确定配送方式
  418 + if(arr[j].distr_t==0){
  419 + arr[j].distr_t=item.distr_type;
  420 + }
  421 + var e_t=0
  422 + switch (arr[j].distr_t) {
  423 + case 0: e_t = 1; break;
  424 + case 1: e_t = 1; break;
  425 + case 2: e_t = 0; break;
  426 + }
  427 + arr[j].exp_type=e_t;
  428 + if (e_t == 0) th.setData({ is_all_zt:0});
  429 + }
  430 +
403 431 //-- 把等级卡会优惠多少钱装进去 --
404 432 if(item.cut_price) arr[j].card_cut_price+=item.cut_price;
405 433 find = 1;break;
... ... @@ -426,7 +454,6 @@ Page({
426 454 case 1: e_t = 1; break;
427 455 case 2: e_t = 0; break;
428 456 }
429   -
430 457 //如果是物流的话,全部自提的控制要弄成0
431 458 if (e_t == 0) th.setData({ is_all_zt:0});
432 459  
... ... @@ -441,14 +468,21 @@ Page({
441 468 }
442 469  
443 470 var ie = {
444   - pickup_id: pcid, pname: pikname, goods: narr, wind: m_wind, distr_t: dis_t,card_cut_price:0,
  471 + pickup_id: pcid, pname: pikname, goods: narr, wind: m_wind, distr_t: dis_t,card_cut_price:0,exp_type:e_t,
445 472 goods_price: 0, shipping_price: 0, user_money: 0, total_amount: 0, order_amount: 0, user_note:0};
446   -
447   - if(!th.data.add_back){
448   - ie.exp_type= e_t
449   - }
  473 +
  474 + //-- 如果是回退回来的情况 --
  475 + if(th.data.cartlist && th.data.cartlist.length>0) {
  476 + for(var kj in th.data.cartlist){
  477 + if(ie.pickup_id==th.data.cartlist[kj].pickup_id){
  478 + ie.exp_type=th.data.cartlist[kj].exp_type;
  479 + break;
  480 + }
  481 + }
  482 + }
  483 +
450 484 //-- 把等级卡会优惠多少钱装进去 --
451   - if(item.cut_price) ie.card_cut_price+=item.cut_price;
  485 + if(item.cut_price1) ie.card_cut_price+=item.cut_price1;
452 486 arr.push(ie);
453 487  
454 488 }
... ... @@ -496,7 +530,9 @@ Page({
496 530 case 1: et = 1; break;
497 531 case 2: et = 0; break;
498 532 }
499   -
  533 +
  534 + if(th.data.bn_goods) et=th.data.bn_exp_type
  535 +
500 536 var m_wind=0,def_exp_code=getApp().globalData.userInfo.def_exp_code;
501 537 if(et==0 && def_exp_code){
502 538 for(var k=0;k<th.data.wu_arr.length;k++){
... ... @@ -579,12 +615,9 @@ Page({
579 615  
580 616 th.setData({
581 617 bn_goods: data, bn_pickname: gg.pick_name,index:m_wind,
582   - bn_pick: gg.pick_id, bn_t_exp_t: distr_t
  618 + bn_pick: gg.pick_id, bn_t_exp_t: distr_t,bn_exp_type: et
583 619 });
584   -
585   - if(!th.data.add_back){
586   - th.setData({ bn_exp_type: et })
587   - }
  620 +
588 621 //计算价格
589 622 th.calculatePrice2();
590 623 //获取优惠券
... ... @@ -615,13 +648,10 @@ Page({
615 648 }
616 649 th.setData({
617 650 bn_goods: t.data.data, bn_pickname: gg.pick_name,index:m_wind,
618   - bn_pick: gg.pick_id, bn_t_exp_t: distr_t
  651 + bn_pick: gg.pick_id, bn_t_exp_t: distr_t,bn_exp_type: et
619 652 });
620 653  
621   - if(!th.data.add_back){
622   - th.setData({ bn_exp_type: et })
623   - }
624   -
  654 +
625 655 //--搭配促销也是按照购物车的方式来计算优惠券--
626 656 if(gg.prom_type==5){
627 657 var frozenQuan=null;
... ... @@ -658,13 +688,9 @@ Page({
658 688  
659 689 th.setData({
660 690 bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind,
661   - bn_pick: gg.pick_id, bn_t_exp_t: distr_t
  691 + bn_pick: gg.pick_id, bn_t_exp_t: distr_t,bn_exp_type: et
662 692 });
663   -
664   - if(!th.data.add_back){
665   - th.setData({ bn_exp_type: et })
666   - }
667   -
  693 +
668 694 //计算价格
669 695 th.calculatePrice2();
670 696 //获取优惠券
... ... @@ -822,7 +848,8 @@ Page({
822 848  
823 849 //有活动,且优惠活动并没有限制使用优惠券,且有减价
824 850 //--看有没有减价--
825   - if(item_map.prom_price>=0 && item_map.price-item_map.prom_price){
  851 + //if(item_map.prom_price>=0 && item_map.price-item_map.prom_price){
  852 + if(item_map.price-item_map.prom_price && item_map.prom_price!==null){
826 853 if(cart_item.prom_pt_json){
827 854 cart_item.prom_pt_json.push({"prom_id":item_map.prom_id,"dis":(item_map.price-item_map.prom_price).toFixed(2),"ispt":0})
828 855 }else{
... ... @@ -892,6 +919,7 @@ Page({
892 919 cart_item.g_coupon_num.push({'c_id':item_map.s_coupon_id,"num": item_map.s_coupon_num})
893 920 }
894 921 }
  922 +
895 923 //-- 如果有送优包邮券的情况 --
896 924 if(item_map.s_libao){
897 925 if(!cart_item.s_libao) {
... ... @@ -1004,15 +1032,18 @@ Page({
1004 1032 if(no_ex_good){
1005 1033 is_good_no_by=th.check_by_goods(no_ex_good,item[j].goods_id);
1006 1034 }
  1035 +
1007 1036 //如果达到全场包邮的条件,同时,没有地区不包邮,或者商品不包邮
1008 1037 if(o_price>=freight_free && freight_free>0 && !is_good_no_by && th.data.is_no_by[pickid]!=1){
1009 1038 continue;
1010 1039 }
  1040 +
1011 1041 //--如果是包邮券使用的情况下,如果商品是包邮的,那么就不进行计算--
1012 1042 if(th.data.using_quan[pickid] && th.data.using_quan[pickid].isby==1 && !is_good_no_by){
1013 1043 continue;
1014 1044 }
1015 1045  
  1046 +
1016 1047 //----------------如果是选择了物流---------------------
1017 1048 if(cart_item.exp_type == 0 && item[j].is_free_shipping==0){
1018 1049 //如果地址不为空
... ... @@ -1197,7 +1228,7 @@ Page({
1197 1228 th.setData({ [atxt]: all_total_m, [atxt1]: all_order_m,
1198 1229 [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m,
1199 1230 [atxt5]: all_coupon_price_m,[atxt6]: all_cutprice,
1200   - [atxt7]: all_order_prom,
  1231 + [atxt7]: all_order_prom, show_submit:1
1201 1232 })
1202 1233 th.data.order_prom_list_cart=c_arr;
1203 1234 th.set_can_num();
... ... @@ -1247,7 +1278,7 @@ Page({
1247 1278 //-----------计算商品总价--------------
1248 1279 var allpice = good.shop_price * good.buynum;
1249 1280 var cut_price=0;
1250   - if(good.prom_type==3 && good.prom_price){
  1281 + if(good.prom_type==3 && good.prom_price!==null){
1251 1282 cut_price=allpice-good.prom_price;
1252 1283 }
1253 1284 allpice=parseFloat(allpice).toFixed(2);
... ... @@ -1429,14 +1460,14 @@ Page({
1429 1460 if (th.data.bn_use_money == 1) {
1430 1461 if (amoney> order_m) {
1431 1462 order_m = order_m.toFixed(2);
1432   - th.setData({ [txt]: order_m, [txt2]:0,[txt3]:coupon_price })
  1463 + th.setData({ [txt]: order_m, [txt2]:0,[txt3]:coupon_price,show_submit:1 })
1433 1464 }else{
1434 1465 order_m =parseFloat(order_m - amoney);
1435 1466 order_m = order_m.toFixed(2);
1436   - th.setData({ [txt]: amoney, [txt2]: order_m,[txt3]:coupon_price })
  1467 + th.setData({ [txt]: amoney, [txt2]: order_m,[txt3]:coupon_price,show_submit:1 })
1437 1468 }
1438 1469 }else{
1439   - th.setData({ [txt]: 0, [txt2]: order_m,[txt3]:coupon_price })
  1470 + th.setData({ [txt]: 0, [txt2]: order_m,[txt3]:coupon_price,show_submit:1})
1440 1471 }
1441 1472 //优惠活动送积分
1442 1473 if(good.s_intValue){
... ... @@ -1476,14 +1507,14 @@ Page({
1476 1507 if (th.data.bn_use_money == 1) {
1477 1508 if (amoney> order_m) {
1478 1509 order_m = order_m.toFixed(2);
1479   - th.setData({ [txt]: order_m, [txt2]:0,[txt3]:coupon_price })
  1510 + th.setData({ [txt]: order_m, [txt2]:0,[txt3]:coupon_price,show_submit:1 })
1480 1511 }else{
1481 1512 order_m =parseFloat(order_m - amoney);
1482 1513 order_m = order_m.toFixed(2);
1483   - th.setData({ [txt]: amoney, [txt2]: order_m,[txt3]:coupon_price })
  1514 + th.setData({ [txt]: amoney, [txt2]: order_m,[txt3]:coupon_price,show_submit:1 })
1484 1515 }
1485 1516 }else{
1486   - th.setData({ [txt]: 0, [txt2]: order_m,[txt3]:coupon_price })
  1517 + th.setData({ [txt]: 0, [txt2]: order_m,[txt3]:coupon_price, show_submit:1 })
1487 1518 }
1488 1519 //优惠活动送积分
1489 1520 if(good.s_intValue){
... ... @@ -1527,7 +1558,7 @@ Page({
1527 1558  
1528 1559 if(th.data.bn_exp_type == 0 && th.data.user_addr==null ){
1529 1560 ff = false; getApp().my_warnning("请选择收货地址",0,th);
1530   - this.data.is_summit_ing = 0;
  1561 + th.data.is_summit_ing = 0;
1531 1562 }
1532 1563 if (!ff) return false;
1533 1564 var addr = th.data.user_addr;
... ... @@ -1536,6 +1567,7 @@ Page({
1536 1567 if(th.data.bn_exp_type==0)
1537 1568 if(th.data.wu_arr==null || th.data.wu_arr.length<=0){
1538 1569 getApp().my_warnning("读取物流失败",0,th);
  1570 + th.data.is_summit_ing = 0;
1539 1571 return false;
1540 1572 }
1541 1573  
... ... @@ -1716,7 +1748,9 @@ Page({
1716 1748 console.log(pdata);
1717 1749 }else{
1718 1750 //---------购物车的结算---------
1719   - if (th.data.is_all_zt == 0 && th.data.user_addr == null) { ff = false; getApp().confirmBox("请新建收货地址");}
  1751 + if (th.data.is_all_zt == 0 && th.data.user_addr == null) {
  1752 + th.data.is_summit_ing = 0;
  1753 + ff = false; getApp().confirmBox("请新建收货地址");}
1720 1754 if (!ff) return false;
1721 1755  
1722 1756 var addr = th.data.user_addr;
... ... @@ -1726,6 +1760,7 @@ Page({
1726 1760  
1727 1761 if(th.data.is_all_zt !=1)
1728 1762 if(th.data.wu_arr==null || th.data.wu_arr.length<=0 ){
  1763 + th.data.is_summit_ing = 0;
1729 1764 getApp().confirmBox("读取物流失败");
1730 1765 return false;
1731 1766 }
... ... @@ -1939,7 +1974,7 @@ Page({
1939 1974 util_pay.pay(data.data, function() {
1940 1975 //app.my_warnning("支付成功",1,th);
1941 1976 //setTimeout(function () {
1942   - wx.navigateTo({
  1977 + wx.redirectTo({
1943 1978 url: "/pages/payment/pay_success/pay_success?type=2&order_sn="+data.data
1944 1979 })
1945 1980 //},1000)
... ... @@ -1965,7 +2000,7 @@ Page({
1965 2000 //app.my_warnning("支付成功",1,th);
1966 2001 //setTimeout(function () {
1967 2002 th.setData({ isclose: 0 });
1968   - wx.navigateTo({
  2003 + wx.redirectTo({
1969 2004 url: "/pages/payment/pay_success/pay_success?type=2&order_sn="+data.data,
1970 2005 })
1971 2006 //}, 1000)
... ... @@ -2084,6 +2119,7 @@ Page({
2084 2119  
2085 2120 //--------购物车购买时,选择自提和物流-----------
2086 2121 setexptype_w:function(t){
  2122 +
2087 2123 var def_exp_code= getApp().globalData.userInfo.def_exp_code,th=this;
2088 2124 var ty = t.currentTarget.dataset.t, txt = t.currentTarget.dataset.txt,
2089 2125 wl_txt = t.currentTarget.dataset.wl_txt,
... ...
pages/cart/cart2/cart2.wxml
... ... @@ -4,7 +4,7 @@
4 4  
5 5 <form bindsubmit="submitForm">
6 6 <view class="container">
7   - <!--要进行判断地址是否显示---->
  7 + <!--要进行判断地址是否显示---->
8 8 <view bindtap="enterAddressPage" class="user-mes mgt20" hidden='{{(bn_exp_type==1 && is_b_now==1) || (is_all_zt==1 && is_b_now==0)}}'>
9 9 <!---默认地址显示------>
10 10 <block wx:if="{{user_addr!=null}}">
... ... @@ -371,12 +371,12 @@
371 371 </view>
372 372 </view>
373 373  
374   - <view class="btn-wrap shadow-1">
  374 + <view class="btn-wrap shadow-1" wx:if="{{show_submit}}">
375 375 <view class="pay-amount">
376 376 <view class="payable">应付金额:<text class="co-red">¥{{formData.order_amount}}</text></view>
377 377 <!-- <view class="co-red big"></view> -->
378 378 </view>
379   - <button class="tips-btn" formType="submit" id="submitOrder">提交订单</button>
  379 + <button class="tips-btn" formType="submit" id="submitOrder">提交订单</button>
380 380 </view>
381 381 </form>
382 382  
... ...