Commit 8792522b6b28340368d045ae135ce804b24cb4ab
1 parent
42c847a4
购物车模块
Showing
3 changed files
with
69 additions
and
31 deletions
pages/goods/goodsInfo/goodsInfo.js
... | ... | @@ -224,6 +224,7 @@ Page({ |
224 | 224 | is_get_local_ok:0,//获取坐标是否完成 |
225 | 225 | region_name:"门店分类",//区域的名字 |
226 | 226 | is_gps:1, |
227 | + open_ind_store:0,//哪里打开的门店列表的控制属性 | |
227 | 228 | }, |
228 | 229 | |
229 | 230 | //------初始化加载---------- |
... | ... | @@ -678,8 +679,10 @@ Page({ |
678 | 679 | }, |
679 | 680 | |
680 | 681 | //------------加入购物车-------------- |
681 | - addCart: function(t) { | |
682 | + addCart: function(t) { | |
682 | 683 | var th=this; |
684 | + var ind = t.currentTarget.dataset.openSpecModal_ind; | |
685 | + th.setData({open_ind_store: ind}); | |
683 | 686 | //如果是秒杀的话,要看redis够不够 |
684 | 687 | if(this.data.prom_type==1){ |
685 | 688 | this.getactLen(function (num) { |
... | ... | @@ -924,8 +927,10 @@ Page({ |
924 | 927 | }); |
925 | 928 | }, |
926 | 929 | openSpecModel: function(t) { |
930 | + var open_store = t.currentTarget.dataset.ind; | |
931 | + console.log(t,"加入购物车头",open_store); | |
927 | 932 | this.setData({ |
928 | - store: 0, choice_sort_store: 0, sort_store: 0 | |
933 | + store: 0, choice_sort_store: 0, sort_store: 0, open_ind_store: open_store, | |
929 | 934 | }) |
930 | 935 | //--先判断会员状态-- |
931 | 936 | var user_info=getApp().globalData.userInfo; |
... | ... | @@ -1127,7 +1132,14 @@ Page({ |
1127 | 1132 | |
1128 | 1133 | //-----------选择属性的按钮事件---------- |
1129 | 1134 | sele_spec: function(e) { |
1130 | - var gid = e.target.dataset.gid; | |
1135 | + var gid = e.currentTarget.dataset.gid; | |
1136 | + var sku_g = this.data.sku_g; | |
1137 | + var item = null; | |
1138 | + for (var i in sku_g) { | |
1139 | + if (sku_g[i].goods_id == gid) { item = sku_g[i]; break } | |
1140 | + } | |
1141 | + if (item) this.setData({ sele_g: item, gid: gid }); | |
1142 | + | |
1131 | 1143 | }, |
1132 | 1144 | //---------拿出门店分类和门店------------ |
1133 | 1145 | get_sto(e) { |
... | ... | @@ -2730,24 +2742,24 @@ Page({ |
2730 | 2742 | }) |
2731 | 2743 | }, |
2732 | 2744 | // 选择门店 |
2733 | - choice_store:function(){ | |
2745 | + choice_store:function(ee){ | |
2734 | 2746 | var th=this; |
2747 | + var ind=ee.currentTarget.dataset.ind; | |
2735 | 2748 | wx.getLocation({ |
2736 | 2749 | type: 'wgs84', |
2737 | 2750 | success: function (res) { |
2738 | - console.log("GPS成功的回调是上面"); | |
2751 | + | |
2739 | 2752 | th.data.lat = res.latitude; |
2740 | 2753 | th.data.lon = res.longitude; |
2741 | 2754 | th.data.is_get_local_ok = 1; |
2742 | 2755 | th.setData({ is_gps: 1 }); |
2756 | + th.onShow(); | |
2743 | 2757 | }, |
2744 | 2758 | fail: function (res) { |
2745 | - console.log("GPS失败的回调"); | |
2759 | + th.onShow(); | |
2746 | 2760 | if (res.errCode == 2) { |
2747 | - console.log("GPS失败的回调22222222222222222"); | |
2748 | 2761 | th.setData({ is_gps: 0 }); |
2749 | - if (this.data.is_gps == 0) { | |
2750 | - console.log(this.data.is_gps, "GPS提示框"); | |
2762 | + if (th.data.is_gps == 0) { | |
2751 | 2763 | s.showWarning("请开启GPS定位", null, 1000, !1); |
2752 | 2764 | } |
2753 | 2765 | } else { |
... | ... | @@ -2759,15 +2771,18 @@ Page({ |
2759 | 2771 | }) |
2760 | 2772 | |
2761 | 2773 | this.setData({ |
2774 | + open_ind_store: ind, | |
2762 | 2775 | store:1, |
2763 | 2776 | openSpecModal: !1, |
2764 | 2777 | openSpecModal_pt: !1 |
2765 | 2778 | }) |
2766 | 2779 | }, |
2767 | 2780 | //关闭选择门店 |
2768 | -close_popup:function(){ | |
2781 | +close_popup:function(e){ | |
2782 | + | |
2769 | 2783 | this.setData({ |
2770 | - store: 0, choice_sort_store: 0,sort_store:0}) | |
2784 | + store: 0, choice_sort_store: 0, sort_store: 0 | |
2785 | + }) | |
2771 | 2786 | }, |
2772 | 2787 | //选择更多门店 |
2773 | 2788 | more_store:function(){ |
... | ... | @@ -2800,8 +2815,32 @@ close_popup:function(){ |
2800 | 2815 | }, |
2801 | 2816 | |
2802 | 2817 | //确定def_pick为选择的门店 |
2803 | - sure_pick:function () { | |
2818 | + sure_pick:function (e) { | |
2804 | 2819 | var th=this; var item=null; |
2820 | + var openindstore = e.currentTarget.dataset.openindstore; | |
2821 | + console.log("加入购物车 还是立即购买,商品主页", openindstore); | |
2822 | + if (openindstore == 1) { | |
2823 | + console.log("加入购物车 ", openindstore); | |
2824 | + th.setData({ | |
2825 | + openSpecModal: !0, | |
2826 | + openSpecModal_ind: openindstore, }); | |
2827 | + } else if (openindstore == 2) { | |
2828 | + console.log("立即购买 ", openindstore); | |
2829 | + th.setData({ | |
2830 | + openSpecModal: !0, | |
2831 | + openSpecModal_ind: openindstore, }); | |
2832 | + } else { | |
2833 | + console.log("商品主页", openindstore); | |
2834 | + th.setData({ | |
2835 | + store: 0, choice_sort_store: 0, sort_store: 0 | |
2836 | + }) | |
2837 | + } | |
2838 | + | |
2839 | + | |
2840 | + | |
2841 | + | |
2842 | + | |
2843 | + | |
2805 | 2844 | if(th.data.choice_sort_store==0 ){ |
2806 | 2845 | var index=th.data.fir_pick_index; |
2807 | 2846 | if(th.data.is_show_sto_cat==1){ | ... | ... |
pages/goods/goodsInfo/goodsInfo.wxml
... | ... | @@ -43,7 +43,7 @@ |
43 | 43 | </view> |
44 | 44 | <view class="xc-video-picture abs"> |
45 | 45 | <view class="xc-video" data-vipi="0" bindtap="videopicture"> |
46 | - <view class=" {{videopicture==0 ? 'xc-video-button':'xc-video-buttons'}} {{videopicture==0 ? 'xc-sn':''}}"> | |
46 | + <view class="{{videopicture==0 ? 'xc-video-button':'xc-video-buttons'}} {{videopicture==0 ? 'xc-sn':''}}"> | |
47 | 47 | 视频 |
48 | 48 | </view> |
49 | 49 | </view> |
... | ... | @@ -308,7 +308,7 @@ |
308 | 308 | <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image> |
309 | 309 | <view class="fs28">选择门店</view> |
310 | 310 | </view> |
311 | - <view class="red_bb fs32" bindtap="choice_store"> | |
311 | + <view class="red_bb fs32" bindtap="choice_store"data-ind="0"> | |
312 | 312 | 更多门店 |
313 | 313 | <text class="bg_jj"></text> |
314 | 314 | </view> |
... | ... | @@ -755,7 +755,7 @@ |
755 | 755 | <view class="spec-goods"> |
756 | 756 | <image class="wh100 spec-img xc-distance-bottom" src="{{data.original_img}}" binderror="pop_err_img" data-errorimg="data.original_img"></image> |
757 | 757 | <view class="spec-goods-info"> |
758 | - <view class="spec-goods-name ellipsis-1">{{data.goods_name}}</view> | |
758 | + <view class="spec-goods-name ellipsis-1">{{sele_g.goods_name}}</view> | |
759 | 759 | <view class="flex ai_end xc-val-money"> |
760 | 760 | <view class="spec-goods-price" wx:if="{{prom_price==null}}"><text class="fs20">¥</text>{{sele_g.shop_price}}</view> |
761 | 761 | <view class="spec-goods-price" wx:else><text class="fs20">¥</text>{{prom_price}}</view> |
... | ... | @@ -788,12 +788,12 @@ |
788 | 788 | </view> |
789 | 789 | |
790 | 790 | <!-- 没有门店的时候 --> |
791 | - <view class="flex" bindtap="choice_store" wx:else> | |
791 | + <view class="flex" bindtap="choice_store"wx:else> | |
792 | 792 | <image class="stores-img" src="{{iurl}}/miniapp/images/stores.png"></image> |
793 | 793 | <view class="fs28">选择门店</view> |
794 | 794 | </view> |
795 | 795 | |
796 | - <view class="red-co fs28" bindtap="choice_store"> | |
796 | + <view class="red-co fs28" bindtap="choice_store" > | |
797 | 797 | 更多门店 |
798 | 798 | <text class="right-arrow"></text> |
799 | 799 | </view> |
... | ... | @@ -804,7 +804,7 @@ |
804 | 804 | <view class="xc-goods-attribute"> |
805 | 805 | <view hidden="{{ismend==1}}" class="spec-name">商品属性</view> |
806 | 806 | <view hidden="{{ismend==1}}" class="flex"> |
807 | - <view class="spec_bt {{gid==item.goods_id?'act':''}}" bindtap="sele_spec" data-gid='item.goods_id' wx:for="{{sku_g}}" wx:key="sku_g"> | |
807 | + <view class="spec_bt {{gid==item.goods_id?'act':''}}" bindtap="sele_spec" data-gid='{{item.goods_id}}' wx:for="{{sku_g}}" wx:key="sku_g"> | |
808 | 808 | {{item.gg}} |
809 | 809 | </view> |
810 | 810 | </view> |
... | ... | @@ -834,8 +834,8 @@ |
834 | 834 | <view class="spec-cart-btns"> |
835 | 835 | |
836 | 836 | <block> |
837 | - <view wx:if="{{openSpecModal_ind==1}}" bindtap="addCart" class="spec-cart-btn yellow fs32" data-action="add">加入购物车</view> | |
838 | - <view wx:if="{{openSpecModal_ind==2}}" bindtap="addCart" class="spec-cart-btn spec-buy" data-action="buy">立即购买</view> | |
837 | + <view wx:if="{{openSpecModal_ind==1}}" bindtap="addCart"data-openSpecModal_ind="{{openSpecModal_ind}}" class="spec-cart-btn yellow fs32" data-action="add">加入购物车</view> | |
838 | + <view wx:if="{{openSpecModal_ind==2}}" bindtap="addCart"data-openSpecModal_ind="{{openSpecModal_ind}}" class="spec-cart-btn spec-buy" data-action="buy">立即购买</view> | |
839 | 839 | </block> |
840 | 840 | </view> |
841 | 841 | |
... | ... | @@ -896,14 +896,14 @@ |
896 | 896 | <view hidden="{{ismend==1}}" class="spec-name">商品属性</view> |
897 | 897 | <block wx:if="{{is_normal==0}}"> |
898 | 898 | <view hidden="{{ismend==1}}" class="flex"> |
899 | - <view class="spec_bt {{gid==item.goods_id?'act':''}}" bindtap="sele_spec" data-gid='item.goods_id' wx:for="{{sku_g}}" wx:key="sku_g">{{item.gg}} | |
899 | + <view class="spec_bt {{gid==item.goods_id?'act':''}}" bindtap="sele_spec" data-gid='{{item.goods_id}}' wx:for="{{sku_g}}" wx:key="sku_g">{{item.gg}} | |
900 | 900 | </view> |
901 | 901 | </view> |
902 | 902 | </block> |
903 | 903 | |
904 | 904 | <block wx:else> |
905 | 905 | <view hidden="{{ismend==1}}" class="flex"> |
906 | - <view class="spec_bt {{gid==item.goods_id?'act':''}}" bindtap="sele_spec" data-gid='item.goods_id' wx:for="{{sku_g}}" wx:key="sku_g">{{item.gg}} | |
906 | + <view class="spec_bt {{gid==item.goods_id?'act':''}}" bindtap="sele_spec" data-gid='{{item.goods_id}}' wx:for="{{sku_g}}" wx:key="sku_g">{{item.gg}} | |
907 | 907 | </view> |
908 | 908 | </view> |
909 | 909 | </block> |
... | ... | @@ -1152,7 +1152,8 @@ |
1152 | 1152 | <!-- 门店列表底部 --> |
1153 | 1153 | <view class="store-bottom-frame"> |
1154 | 1154 | <view class="store-bottom flex-vertical-between"> |
1155 | - <view class="determine red-b fs28 white t-c" bindtap="sure_pick">确定</view> | |
1155 | + <view class="determine red-b fs28 white t-c" bindtap="sure_pick" | |
1156 | + data-openindstore="{{open_ind_store}}">确定</view> | |
1156 | 1157 | <view class="default t-c fs28" bindtap="set_def_pick">设为默认</view> |
1157 | 1158 | </view> |
1158 | 1159 | </view> | ... | ... |
pages/goods/goodsInfo/goodsInfo.wxss
... | ... | @@ -2348,7 +2348,7 @@ height: 70%; |
2348 | 2348 | } |
2349 | 2349 | .store-list .store_choose{ |
2350 | 2350 | width: 100%; |
2351 | - height: 125rpx; | |
2351 | + height: 120rpx; | |
2352 | 2352 | line-height: 125rpx; |
2353 | 2353 | border-bottom: 1rpx solid #eee; |
2354 | 2354 | |
... | ... | @@ -2361,10 +2361,10 @@ padding-left: 20rpx; |
2361 | 2361 | |
2362 | 2362 | } |
2363 | 2363 | .xc-hook{ |
2364 | - width: 33rpx; | |
2365 | - height: 33rpx; | |
2364 | + width: 35rpx; | |
2365 | + height: 35rpx; | |
2366 | 2366 | transform: rotate(-145deg); |
2367 | -line-height: 35rpx; | |
2367 | +line-height: 37rpx; | |
2368 | 2368 | text-align: center; |
2369 | 2369 | } |
2370 | 2370 | .xc-hooks{ |
... | ... | @@ -2392,7 +2392,7 @@ line-height: 30rpx; |
2392 | 2392 | .store-bottom{ |
2393 | 2393 | width: 85%; |
2394 | 2394 | margin: auto; |
2395 | - height: 90rpx; | |
2395 | + height: 97rpx; | |
2396 | 2396 | |
2397 | 2397 | |
2398 | 2398 | } |
... | ... | @@ -2411,10 +2411,8 @@ line-height: 30rpx; |
2411 | 2411 | } |
2412 | 2412 | .store-bottom-frame{ |
2413 | 2413 | width: 95%; |
2414 | - border-top: 3rpx solid #eee; | |
2415 | 2414 | margin: auto; |
2416 | - margin-top: 10rpx; | |
2417 | - | |
2415 | + | |
2418 | 2416 | } |
2419 | 2417 | /* 门店分类列表 */ |
2420 | 2418 | .sort_store_list{ | ... | ... |