Commit d70192cc750e095df2b9d10833446d6305eef685
1 parent
e153dbf5
购买流程的优化
Showing
2 changed files
with
344 additions
and
22 deletions
packageC/pages/presell/cart/cart2.js
... | ... | @@ -1226,8 +1226,170 @@ Page({ |
1226 | 1226 | |
1227 | 1227 | }, |
1228 | 1228 | |
1229 | + | |
1230 | + //-- 服务卡项的支付的下一步 -- | |
1231 | + submitForm_card_next: async function() { | |
1232 | + | |
1233 | + if (this.data.is_summit_ing == 1) return false; //--提交中退出-- | |
1234 | + this.data.is_summit_ing = 1; | |
1235 | + var th = this,pdata = new Array(); | |
1236 | + | |
1237 | + var item = { | |
1238 | + 'user_id': to.globalData.user_id, | |
1239 | + 'account': th.data.formData.order_amount, //使用余额 | |
1240 | + 'store_id': oo.stoid, //商家 | |
1241 | + 'list': new Array(), | |
1242 | + }; | |
1243 | + | |
1244 | + //判断是不是购物车购买还是立即购买 | |
1245 | + var gg = getApp().globalData.service_now; | |
1246 | + if (!gg.pick_id) { | |
1247 | + getApp().showWarning("未找到门店"); | |
1248 | + return false; | |
1249 | + } | |
1250 | + var goods = { | |
1251 | + 'card_id': th.data.bn_goods.id, | |
1252 | + 'itemid': th.data.bn_goods.erpItemID, | |
1253 | + 'qty': gg.goods_num, | |
1254 | + 'price': th.data.bn_goods.money, | |
1255 | + // 'price': th.data.formData.order_amount, | |
1256 | + 'pickup_id': gg.pick_id, | |
1257 | + 'pickup_keyid': gg.keyid, | |
1258 | + 'prom_type': this.data.postdata.prom_type, //促销活动类型 | |
1259 | + 'prom_id': this.data.postdata.prom_id, //促销活动id | |
1260 | + }; | |
1261 | + | |
1262 | + if(this.data.postdata.prom_type == 1) { | |
1263 | + goods.price = this.data.postdata.prom_price; | |
1264 | + }; | |
1265 | + | |
1266 | + if(getApp().globalData.skinface_id){ | |
1267 | + goods.skinface_id=getApp().globalData.skinface_id; | |
1268 | + } | |
1269 | + | |
1270 | + if(this.data.postdata && this.data.postdata.is_pd_normal==1){ | |
1271 | + goods.is_pd_normal=1; | |
1272 | + } | |
1273 | + | |
1274 | + | |
1275 | + //--导购分享过来的id-- | |
1276 | + if (gg.guide_id) { | |
1277 | + goods.guide_id = gg.guide_id; | |
1278 | + goods.guide_type = gg.guide_type; | |
1279 | + //调用接口判断是不是会员 | |
1280 | + await getApp().request.promiseGet("/api/weshop/shoppingGuide/getId/" + oo.stoid + "/" + gg.guide_id, {}).then( | |
1281 | + res => { | |
1282 | + if (res.data.code == 0) { | |
1283 | + goods.guide_name = res.data.data.salesman; | |
1284 | + goods.guide_sn = res.data.data.salesman_no; | |
1285 | + } | |
1286 | + }) | |
1287 | + } | |
1288 | + | |
1289 | + if(gg.groupchat_id){ | |
1290 | + goods.groupchat_id=gg.groupchat_id | |
1291 | + } | |
1292 | + item.list.push(goods); | |
1293 | + | |
1294 | + pdata = item; | |
1295 | + var str = JSON.stringify(pdata); | |
1296 | + console.log("支付数据"); | |
1297 | + console.log(str); | |
1298 | + //return false; | |
1299 | + wx.showLoading({ | |
1300 | + title: "加载中" | |
1301 | + }); | |
1302 | + wx.request({ | |
1303 | + url: oo.url + '/api/weshop/recharge/saveRecharge', | |
1304 | + data: str, | |
1305 | + method: 'POST', | |
1306 | + header: { | |
1307 | + 'content-type': 'application/json' | |
1308 | + }, // 设置请求的 header | |
1309 | + success: function(res) { | |
1310 | + | |
1311 | + wx.hideLoading(); | |
1312 | + if (res.statusCode == 200) { | |
1313 | + var data = res.data; | |
1314 | + if (data.code == 0) { | |
1315 | + th.data.order_id = data.data.order_id; | |
1316 | + // console.log('myyyyyyyyyyyyyyyyyy', data.data); | |
1317 | + if (th.data.is_cart) { | |
1318 | + var list = th.data.cartlist_y; | |
1319 | + for (var i = 0; i < list.length; i++) { | |
1320 | + //删除购物车 | |
1321 | + a.delete("/api/weshop/cartService/del/" + oo.stoid + "/" + list[i].id, {}); | |
1322 | + } | |
1323 | + } | |
1324 | + var order_amount = pdata.account; | |
1325 | + //要进行判断,如果是用微信支付,就要跳转到支付界面 | |
1326 | + if (order_amount > 0) { | |
1327 | + th.setData({ | |
1328 | + isclose: 0 | |
1329 | + }); | |
1330 | + | |
1331 | + t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder") | |
1332 | + t_pay.pay( | |
1333 | + { | |
1334 | + parentSn: data.data.order_sn, | |
1335 | + store_id: oo.stoid | |
1336 | + },function (){ | |
1337 | + wx.showToast({ | |
1338 | + title: '购买成功', | |
1339 | + icon: 'success', | |
1340 | + duration: 2000 | |
1341 | + }); | |
1342 | + setTimeout(function () { | |
1343 | + wx.reLaunch({ | |
1344 | + url: "/pages/payment/pay_success/pay_success?card=1&order_id=" + th.data.order_id, | |
1345 | + }) | |
1346 | + }, 1000) | |
1347 | + | |
1348 | + },function (e){ | |
1349 | + | |
1350 | + console.log('kkkkkkk'); | |
1351 | + | |
1352 | + wx.showToast({ | |
1353 | + title: e, | |
1354 | + icon: 'none', | |
1355 | + duration: 2000 | |
1356 | + }); | |
1357 | + | |
1358 | + setTimeout(function () { | |
1359 | + wx.reLaunch({ | |
1360 | + url: "/pages/user/order_list/order_list?index=2&tabindex=1", | |
1361 | + }) | |
1362 | + }, 1000) | |
1363 | + | |
1364 | + } | |
1365 | + ) | |
1366 | + } | |
1367 | + } else { | |
1368 | + th.data.is_summit_ing = 0; //是否提交中 | |
1369 | + getApp().confirmBox(data.msg); | |
1370 | + } | |
1371 | + } else { | |
1372 | + th.data.is_summit_ing = 0; //是否提交中 | |
1373 | + console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode); | |
1374 | + } | |
1375 | + }, | |
1376 | + fail: function() { | |
1377 | + th.data.is_summit_ing = 0; //是否提交中 | |
1378 | + wx.hideLoading(); | |
1379 | + console.log("index.js wx.request CheckCallUser fail"); | |
1380 | + }, | |
1381 | + complete: function() {} | |
1382 | + }) | |
1383 | + }, | |
1384 | + | |
1229 | 1385 | //--------------------提交订单----------------------- |
1230 | 1386 | async submitForm(t) { |
1387 | + | |
1388 | + if(th.data.fwk==1){ | |
1389 | + this.submitForm_card_next(); | |
1390 | + return false; | |
1391 | + } | |
1392 | + | |
1231 | 1393 | var sub_value = t; |
1232 | 1394 | |
1233 | 1395 | if (this.data.is_summit_ing == 1) return false; //--提交中退出-- | ... | ... |
packageC/pages/presell/cart/cart2_pre.js
... | ... | @@ -3,6 +3,7 @@ var t = getApp(), app = t, a = t.request, ut = require("../../../../utils/util.j |
3 | 3 | var os = t.globalData.setting; |
4 | 4 | var regeneratorRuntime = require('../../../../utils/runtime.js'); |
5 | 5 | var util_pay = require("../../../../utils/pay.js"); |
6 | +const t_pay = require("../../../utils/pay2.js"); | |
6 | 7 | |
7 | 8 | Page({ |
8 | 9 | data: { |
... | ... | @@ -239,7 +240,7 @@ Page({ |
239 | 240 | t.data.data.shop_price = prelist.presell_money; |
240 | 241 | th.setData({ |
241 | 242 | bn_goods: t.data.data, bn_pickname: gg.pick_name, prelist: prelist, act: act, |
242 | - bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et | |
243 | + bn_pick: gg.pick_id, bn_t_exp_t: distr_t, bn_exp_type: et,fwk:1 | |
243 | 244 | }); |
244 | 245 | //计算价格 |
245 | 246 | th.calculatePrice2(); |
... | ... | @@ -813,7 +814,163 @@ Page({ |
813 | 814 | |
814 | 815 | }, |
815 | 816 | |
816 | - // -- 支付的下一步 -- | |
817 | + | |
818 | + //-- 服务卡项的支付的下一步 -- | |
819 | + submitForm_card_next: async function() { | |
820 | + | |
821 | + if (this.data.is_summit_ing == 1) return false; //--提交中退出-- | |
822 | + this.data.is_summit_ing = 1; | |
823 | + var th = this,pdata = new Array(); | |
824 | + | |
825 | + var item = { | |
826 | + 'user_id': to.globalData.user_id, | |
827 | + 'account': th.data.formData.order_amount, //使用余额 | |
828 | + 'store_id': oo.stoid, //商家 | |
829 | + 'list': new Array(), | |
830 | + }; | |
831 | + | |
832 | + //判断是不是购物车购买还是立即购买 | |
833 | + var gg = getApp().globalData.service_now; | |
834 | + if (!gg.pick_id) { | |
835 | + getApp().showWarning("未找到门店"); | |
836 | + return false; | |
837 | + } | |
838 | + var goods = { | |
839 | + 'card_id': th.data.bn_goods.id, | |
840 | + 'itemid': th.data.bn_goods.erpItemID, | |
841 | + 'qty': gg.goods_num, | |
842 | + 'price': th.data.bn_goods.money, | |
843 | + // 'price': th.data.formData.order_amount, | |
844 | + 'pickup_id': gg.pick_id, | |
845 | + 'pickup_keyid': gg.keyid, | |
846 | + 'prom_type': this.data.postdata.prom_type, //促销活动类型 | |
847 | + 'prom_id': this.data.postdata.prom_id, //促销活动id | |
848 | + }; | |
849 | + | |
850 | + if(this.data.postdata.prom_type == 1) { | |
851 | + goods.price = this.data.postdata.prom_price; | |
852 | + }; | |
853 | + | |
854 | + if(getApp().globalData.skinface_id){ | |
855 | + goods.skinface_id=getApp().globalData.skinface_id; | |
856 | + } | |
857 | + | |
858 | + if(this.data.postdata && this.data.postdata.is_pd_normal==1){ | |
859 | + goods.is_pd_normal=1; | |
860 | + } | |
861 | + | |
862 | + | |
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( | |
869 | + res => { | |
870 | + if (res.data.code == 0) { | |
871 | + goods.guide_name = res.data.data.salesman; | |
872 | + goods.guide_sn = res.data.data.salesman_no; | |
873 | + } | |
874 | + }) | |
875 | + } | |
876 | + | |
877 | + if(gg.groupchat_id){ | |
878 | + goods.groupchat_id=gg.groupchat_id | |
879 | + } | |
880 | + item.list.push(goods); | |
881 | + | |
882 | + pdata = item; | |
883 | + var str = JSON.stringify(pdata); | |
884 | + console.log("支付数据"); | |
885 | + console.log(str); | |
886 | + //return false; | |
887 | + wx.showLoading({ | |
888 | + title: "加载中" | |
889 | + }); | |
890 | + wx.request({ | |
891 | + url: oo.url + '/api/weshop/recharge/saveRecharge', | |
892 | + data: str, | |
893 | + method: 'POST', | |
894 | + header: { | |
895 | + 'content-type': 'application/json' | |
896 | + }, // 设置请求的 header | |
897 | + success: function(res) { | |
898 | + | |
899 | + wx.hideLoading(); | |
900 | + if (res.statusCode == 200) { | |
901 | + var data = res.data; | |
902 | + if (data.code == 0) { | |
903 | + th.data.order_id = data.data.order_id; | |
904 | + // console.log('myyyyyyyyyyyyyyyyyy', data.data); | |
905 | + if (th.data.is_cart) { | |
906 | + var list = th.data.cartlist_y; | |
907 | + for (var i = 0; i < list.length; i++) { | |
908 | + //删除购物车 | |
909 | + a.delete("/api/weshop/cartService/del/" + oo.stoid + "/" + list[i].id, {}); | |
910 | + } | |
911 | + } | |
912 | + var order_amount = pdata.account; | |
913 | + //要进行判断,如果是用微信支付,就要跳转到支付界面 | |
914 | + if (order_amount > 0) { | |
915 | + th.setData({ | |
916 | + isclose: 0 | |
917 | + }); | |
918 | + | |
919 | + t_pay.set_pay_url("/api/weshop/order/pay/createRechargeOrder") | |
920 | + t_pay.pay( | |
921 | + { | |
922 | + parentSn: data.data.order_sn, | |
923 | + store_id: oo.stoid | |
924 | + },function (){ | |
925 | + wx.showToast({ | |
926 | + title: '购买成功', | |
927 | + icon: 'success', | |
928 | + duration: 2000 | |
929 | + }); | |
930 | + setTimeout(function () { | |
931 | + wx.reLaunch({ | |
932 | + url: "/pages/payment/pay_success/pay_success?card=1&order_id=" + th.data.order_id, | |
933 | + }) | |
934 | + }, 1000) | |
935 | + | |
936 | + },function (e){ | |
937 | + | |
938 | + console.log('kkkkkkk'); | |
939 | + | |
940 | + wx.showToast({ | |
941 | + title: e, | |
942 | + icon: 'none', | |
943 | + duration: 2000 | |
944 | + }); | |
945 | + | |
946 | + setTimeout(function () { | |
947 | + wx.reLaunch({ | |
948 | + url: "/pages/user/order_list/order_list?index=2&tabindex=1", | |
949 | + }) | |
950 | + }, 1000) | |
951 | + | |
952 | + } | |
953 | + ) | |
954 | + } | |
955 | + } else { | |
956 | + th.data.is_summit_ing = 0; //是否提交中 | |
957 | + getApp().confirmBox(data.msg); | |
958 | + } | |
959 | + } else { | |
960 | + th.data.is_summit_ing = 0; //是否提交中 | |
961 | + console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode); | |
962 | + } | |
963 | + }, | |
964 | + fail: function() { | |
965 | + th.data.is_summit_ing = 0; //是否提交中 | |
966 | + wx.hideLoading(); | |
967 | + console.log("index.js wx.request CheckCallUser fail"); | |
968 | + }, | |
969 | + complete: function() {} | |
970 | + }) | |
971 | + }, | |
972 | + | |
973 | + // -- 商品支付的下一步 -- | |
817 | 974 | submitForm_next: async function (t) { |
818 | 975 | if (this.data.is_summit_ing == 1) return false; //--提交中退出-- |
819 | 976 | this.data.is_summit_ing = 1; |
... | ... | @@ -1029,14 +1186,11 @@ Page({ |
1029 | 1186 | setTimeout(function () { |
1030 | 1187 | th.setData({ isclose: 0 }); |
1031 | 1188 | |
1032 | - | |
1033 | 1189 | var url = "/packageC/pages/presell/cart/cart?order_sn=" + data.data; |
1034 | 1190 | wx.reLaunch({ |
1035 | 1191 | url: url |
1036 | 1192 | }) |
1037 | 1193 | |
1038 | - | |
1039 | - | |
1040 | 1194 | }, 1000) |
1041 | 1195 | } |
1042 | 1196 | }); |
... | ... | @@ -1060,29 +1214,35 @@ Page({ |
1060 | 1214 | }) |
1061 | 1215 | }, |
1062 | 1216 | |
1063 | - | |
1064 | 1217 | //--------------------提交订单----------------------- |
1065 | 1218 | submitForm: function (t) { |
1066 | 1219 | var th = this; |
1067 | 1220 | //如果是部分定金,商家不同意退定金, |
1068 | 1221 | if (this.data.act.presell_type != 1 && !this.data.act.is_refundmoney && !th.agree_no_ref) { |
1069 | - wx.showModal({ | |
1070 | - content: ' 预售商品不允许退定金!是否继续下单?', | |
1071 | - showCancel: true,//是否显示取消按钮 | |
1072 | - cancelText: "我在想想",//默认是“取消” | |
1073 | - confirmText: "继续下单",//默认是“确定” | |
1074 | - success: function (res) { | |
1075 | - if (res.cancel) { | |
1076 | - //点击取消,默认隐藏弹框 | |
1077 | - } else { | |
1078 | - th.setData({ agree_no_ref: 1 }) | |
1079 | - th.submitForm_next(t) | |
1080 | - } | |
1081 | - }, | |
1082 | - }) | |
1083 | - | |
1222 | + wx.showModal({ | |
1223 | + content: ' 预售商品不允许退定金!是否继续下单?', | |
1224 | + showCancel: true,//是否显示取消按钮 | |
1225 | + cancelText: "我在想想",//默认是“取消” | |
1226 | + confirmText: "继续下单",//默认是“确定” | |
1227 | + success: function (res) { | |
1228 | + if (res.cancel) { | |
1229 | + //点击取消,默认隐藏弹框 | |
1230 | + } else { | |
1231 | + th.setData({ agree_no_ref: 1 }) | |
1232 | + if(th.data.fwk==1){ | |
1233 | + th.submitForm_card_next(t) | |
1234 | + }else{ | |
1235 | + th.submitForm_next(t) | |
1236 | + } | |
1237 | + } | |
1238 | + }, | |
1239 | + }) | |
1084 | 1240 | } else { |
1085 | - this.submitForm_next(t); | |
1241 | + if(th.data.fwk==1){ | |
1242 | + th.submitForm_card_next(t) | |
1243 | + }else{ | |
1244 | + th.submitForm_next(t) | |
1245 | + } | |
1086 | 1246 | } |
1087 | 1247 | }, |
1088 | 1248 | ... | ... |