Commit bbc2b008fd15f94d20aeea6b91ee4baa8d2c3ce6

Authored by 后端开发-许程
1 parent d662d782

加入购物车

pages/goods/goodsInfo/goodsInfo.js
@@ -225,6 +225,7 @@ Page({ @@ -225,6 +225,7 @@ Page({
225 region_name:"门店分类",//区域的名字 225 region_name:"门店分类",//区域的名字
226 is_gps:1, 226 is_gps:1,
227 open_ind_store:0,//哪里打开的门店列表的控制属性 227 open_ind_store:0,//哪里打开的门店列表的控制属性
  228 + default_store:{},//创建添加默认门店地址的对象
228 }, 229 },
229 230
230 //------初始化加载---------- 231 //------初始化加载----------
@@ -232,7 +233,7 @@ Page({ @@ -232,7 +233,7 @@ Page({
232 wx.setNavigationBarTitle({ title: "商品详情",}) 233 wx.setNavigationBarTitle({ title: "商品详情",})
233 var ee = this, that=ee,th=ee, 234 var ee = this, that=ee,th=ee,
234 gid = t.goods_id; 235 gid = t.goods_id;
235 - 236 +
236 //---获取手机地址坐标-- 237 //---获取手机地址坐标--
237 //--如果tg_id是空的话,分享回来-- 238 //--如果tg_id是空的话,分享回来--
238 if (gid == undefined || gid == null || gid == "") { 239 if (gid == undefined || gid == null || gid == "") {
@@ -242,8 +243,8 @@ Page({ @@ -242,8 +243,8 @@ Page({
242 243
243 //----获取系统参数----- 244 //----获取系统参数-----
244 getApp().getConfig2(function (e) { 245 getApp().getConfig2(function (e) {
245 - ee.setData({bconfig:e});  
246 - 246 + ee.setData({bconfig:e});
  247 +
247 if (e.categoryset.indexOf("," + 1 + ",") != -1) { ee.setData({ is_show_pl: 1 }); } 248 if (e.categoryset.indexOf("," + 1 + ",") != -1) { ee.setData({ is_show_pl: 1 }); }
248 if (e.categoryset.indexOf("," + 3 + ",") != -1) { ee.setData({ is_show_pp: 1 }); } 249 if (e.categoryset.indexOf("," + 3 + ",") != -1) { ee.setData({ is_show_pp: 1 }); }
249 if (e.categoryset.indexOf("," + 2 + ",") != -1) { ee.setData({ is_show_gb: 1 }); } 250 if (e.categoryset.indexOf("," + 2 + ",") != -1) { ee.setData({ is_show_gb: 1 }); }
@@ -283,31 +284,7 @@ Page({ @@ -283,31 +284,7 @@ Page({
283 284
284 }) 285 })
285 286
286 - if (e.is_sort_storage) {  
287 - wx.getLocation({  
288 - type: 'wgs84',  
289 - success: function (res) {  
290 - th.data.lat = res.latitude;  
291 - th.data.lon = res.longitude;  
292 - th.data.is_get_local_ok = 1;  
293 - },  
294 - fail: function (res) {  
295 - if (res.errCode == 2) {  
296 - th.setData({ is_gps: 0 });  
297 - if (th.data.is_gps == 0) {  
298 - s.showWarning("请开启GPS定位", null, 3800000, !1);  
299 - }  
300 -  
301 - } else {  
302 - th.setData({ is_gps: "3" });  
303 - }  
304 -  
305 - th.data.is_get_local_ok = 1;  
306 - }  
307 - })  
308 - } else {  
309 - th.data.is_get_local_ok = 1;  
310 - } 287 +
311 288
312 }, 289 },
313 290
@@ -458,6 +435,9 @@ Page({ @@ -458,6 +435,9 @@ Page({
458 435
459 this.data.is_timer=1; 436 this.data.is_timer=1;
460 var ee = this,gid = this.data.gid,i=getApp().request; 437 var ee = this,gid = this.data.gid,i=getApp().request;
  438 +
  439 + this.wait_for_store_config();
  440 +
461 i.get("/api/weshop/goods/get/" + o.stoid + "/" + ee.data.gid, { 441 i.get("/api/weshop/goods/get/" + o.stoid + "/" + ee.data.gid, {
462 failRollback: !0, 442 failRollback: !0,
463 success: function(t) { 443 success: function(t) {
@@ -578,6 +558,8 @@ Page({ @@ -578,6 +558,8 @@ Page({
578 }); 558 });
579 this.data.enterAddressPage && (this.data.enterAddressPage = !1); 559 this.data.enterAddressPage && (this.data.enterAddressPage = !1);
580 560
  561 +
  562 +
581 }, 563 },
582 enterAddress: function() { 564 enterAddress: function() {
583 this.data.enterAddressPage = !0, wx.navigateTo({ 565 this.data.enterAddressPage = !0, wx.navigateTo({
@@ -2752,7 +2734,7 @@ Page({ @@ -2752,7 +2734,7 @@ Page({
2752 var th=this; 2734 var th=this;
2753 var ind=ee.currentTarget.dataset.ind; 2735 var ind=ee.currentTarget.dataset.ind;
2754 var bconfig = th.data.bconfig; 2736 var bconfig = th.data.bconfig;
2755 - console.log("男士水水水水水", bconfig); 2737 +
2756 if (bconfig.is_sort_storage){ 2738 if (bconfig.is_sort_storage){
2757 wx.getLocation({ 2739 wx.getLocation({
2758 type: 'wgs84', 2740 type: 'wgs84',
@@ -2769,7 +2751,7 @@ Page({ @@ -2769,7 +2751,7 @@ Page({
2769 if (res.errCode == 2) { 2751 if (res.errCode == 2) {
2770 th.setData({ is_gps: 0 }); 2752 th.setData({ is_gps: 0 });
2771 if (th.data.is_gps == 0) { 2753 if (th.data.is_gps == 0) {
2772 - s.showWarning("请开启GPS定位", null, 25000, !1); 2754 + getApp().confirmBox("请开启GPS定位", null, 25000, !1);
2773 } 2755 }
2774 } else { 2756 } else {
2775 th.setData({ is_gps: "3" }); 2757 th.setData({ is_gps: "3" });
@@ -2827,29 +2809,22 @@ close_popup:function(e){ @@ -2827,29 +2809,22 @@ close_popup:function(e){
2827 sure_pick:function (e) { 2809 sure_pick:function (e) {
2828 var th=this; var item=null; 2810 var th=this; var item=null;
2829 var openindstore = e.currentTarget.dataset.openindstore; 2811 var openindstore = e.currentTarget.dataset.openindstore;
2830 - console.log("加入购物车 还是立即购买,商品主页", openindstore);  
2831 if (openindstore == 1) { 2812 if (openindstore == 1) {
2832 - console.log("加入购物车 ", openindstore); 2813 +
2833 th.setData({ 2814 th.setData({
2834 openSpecModal: !0, 2815 openSpecModal: !0,
2835 openSpecModal_ind: openindstore, }); 2816 openSpecModal_ind: openindstore, });
2836 } else if (openindstore == 2) { 2817 } else if (openindstore == 2) {
2837 - console.log("立即购买 ", openindstore); 2818 +
2838 th.setData({ 2819 th.setData({
2839 openSpecModal: !0, 2820 openSpecModal: !0,
2840 openSpecModal_ind: openindstore, }); 2821 openSpecModal_ind: openindstore, });
2841 } else { 2822 } else {
2842 - console.log("商品主页", openindstore); 2823 +
2843 th.setData({ 2824 th.setData({
2844 store: 0, choice_sort_store: 0, sort_store: 0 2825 store: 0, choice_sort_store: 0, sort_store: 0
2845 }) 2826 })
2846 } 2827 }
2847 -  
2848 -  
2849 -  
2850 -  
2851 -  
2852 -  
2853 if(th.data.choice_sort_store==0 ){ 2828 if(th.data.choice_sort_store==0 ){
2854 var index=th.data.fir_pick_index; 2829 var index=th.data.fir_pick_index;
2855 if(th.data.is_show_sto_cat==1){ 2830 if(th.data.is_show_sto_cat==1){
@@ -2866,8 +2841,29 @@ close_popup:function(e){ @@ -2866,8 +2841,29 @@ close_popup:function(e){
2866 }, 2841 },
2867 2842
2868 //把选择的门店设置成默认的门店def_pick 2843 //把选择的门店设置成默认的门店def_pick
2869 - set_def_pick:function () {  
2870 - var th=this; var item=null; 2844 + set_def_pick:function (e) {
  2845 + var th = this; var item = null;
  2846 + var openindstore = e.currentTarget.dataset.openindstore;
  2847 + if (openindstore == 1) {
  2848 +
  2849 + th.setData({
  2850 + openSpecModal: !0,
  2851 + openSpecModal_ind: openindstore,
  2852 + store: 0, choice_sort_store: 0, sort_store: 0
  2853 + });
  2854 + } else if (openindstore == 2) {
  2855 +
  2856 + th.setData({
  2857 + openSpecModal: !0,
  2858 + openSpecModal_ind: openindstore,
  2859 + store: 0, choice_sort_store: 0, sort_store: 0
  2860 + });
  2861 + } else {
  2862 + th.setData({
  2863 + store: 0, choice_sort_store: 0, sort_store: 0
  2864 + })
  2865 + }
  2866 +
2871 if(th.data.choice_sort_store==0 ){ 2867 if(th.data.choice_sort_store==0 ){
2872 var index=th.data.fir_pick_index; 2868 var index=th.data.fir_pick_index;
2873 if(th.data.is_show_sto_cat==1){ 2869 if(th.data.is_show_sto_cat==1){
@@ -2879,8 +2875,62 @@ close_popup:function(e){ @@ -2879,8 +2875,62 @@ close_popup:function(e){
2879 var index=th.data.sec_pick_index; 2875 var index=th.data.sec_pick_index;
2880 item=th.data.sec_sto.s_arr[index]; 2876 item=th.data.sec_sto.s_arr[index];
2881 } 2877 }
  2878 +
  2879 + var store_id=o.stoid;
  2880 + var user_id = getApp().globalData.user_id;
  2881 + var pickup_id = item.pickup_id;
  2882 +
  2883 + getApp().request.put('/api/weshop/users/save',{
  2884 + data: { store_id, user_id, pickup_id},
  2885 + success:function(res){
  2886 + if (res.code!=-1){
  2887 + s.showWarning("设置门店地址成功", null, 500, !1);
  2888 + }else{
  2889 + s.showWarning("设置默认门店地址失败", null, 500, !1);
  2890 + }
  2891 +
  2892 + }
  2893 + });
  2894 + th.setData({
  2895 + def_pick_store: item, sto_sele_name: item.pickup_name,
  2896 + sto_sele_id: item.pickup_id, sto_sele_distr: item.distr_type, store: 0, choice_sort_store: 0
  2897 + });
2882 2898
2883 - } 2899 + },
  2900 +
  2901 + wait_for_store_config:function(){
  2902 + var th=this;
  2903 + var t_time=setInterval(function(){
  2904 + if (th.data.bconfig==null) false;
  2905 + var e = th.data.bconfig;
  2906 + if (e.is_sort_storage) {
  2907 + wx.getLocation({
  2908 + type: 'wgs84',
  2909 + success: function (res) {
  2910 + th.data.lat = res.latitude;
  2911 + th.data.lon = res.longitude;
  2912 + th.data.is_get_local_ok = 1;
  2913 + },
  2914 + fail: function (res) {
  2915 + if (res.errCode == 2) {
  2916 + th.setData({ is_gps: 0 });
  2917 + if (th.data.is_gps == 0) {
  2918 + getApp().confirmBox("请开启GPS定位", null, 10000, !1);
  2919 + }
2884 2920
  2921 + } else {
  2922 + th.setData({ is_gps: "3" });
  2923 + }
  2924 +
  2925 + th.data.is_get_local_ok = 1;
  2926 + }
  2927 + })
  2928 + } else {
  2929 + th.data.is_get_local_ok = 1;
  2930 + }
  2931 + clearInterval(t_time);
  2932 + },500)
  2933 + }
  2934 +
2885 2935
2886 }); 2936 });
2887 \ No newline at end of file 2937 \ No newline at end of file
pages/goods/goodsInfo/goodsInfo.wxml
@@ -1154,7 +1154,7 @@ @@ -1154,7 +1154,7 @@
1154 <view class="store-bottom flex-vertical-between"> 1154 <view class="store-bottom flex-vertical-between">
1155 <view class="determine red-b fs28 white t-c" bindtap="sure_pick" 1155 <view class="determine red-b fs28 white t-c" bindtap="sure_pick"
1156 data-openindstore="{{open_ind_store}}">确定</view> 1156 data-openindstore="{{open_ind_store}}">确定</view>
1157 - <view class="default t-c fs28" bindtap="set_def_pick">设为默认</view> 1157 + <view class="default t-c fs28" bindtap="set_def_pick"data-openindstore="{{open_ind_store}}">设为默认</view>
1158 </view> 1158 </view>
1159 </view> 1159 </view>
1160 1160