Commit db3f190bf7db813f7c10f3f9f600385a98ebf6e0

Authored by yvan.ni
1 parent 2a8cec4c

1. 带支付订单立即支付

2.   组合购加速
3.   商品组件滑倒底部加载更多
components/diy_goodsGroup/diy_goodsGroup.js
@@ -50,11 +50,19 @@ Component({ @@ -50,11 +50,19 @@ Component({
50 ready: function () {}, 50 ready: function () {},
51 51
52 lifetimes: { 52 lifetimes: {
53 - attached: function() { 53 + attached: function() {
  54 +
54 55
55 //要兼容性的写法,因为有些商家都还未更新商品分组的最新的效果~~3.0公众号的html页面所以不用兼容写法 56 //要兼容性的写法,因为有些商家都还未更新商品分组的最新的效果~~3.0公众号的html页面所以不用兼容写法
56 var nav_item=this.data.object; 57 var nav_item=this.data.object;
57 var nav_list= this.data.object.nav_list; 58 var nav_list= this.data.object.nav_list;
  59 +
  60 + if(parseInt(nav_item.is_automore)){
  61 + if(!getApp().globalData.func_list) getApp().globalData.func_list=[];
  62 + getApp().globalData.func_list.push(this);
  63 + }
  64 +
  65 +
58 //最新的版本才有nav_list 66 //最新的版本才有nav_list
59 if(nav_list){ 67 if(nav_list){
60 nav_item=nav_list[0]; 68 nav_item=nav_list[0];
@@ -158,6 +166,7 @@ Component({ @@ -158,6 +166,7 @@ Component({
158 await app.request.get("/api/weshop/goods/getgoodslistOrdby?store_id=" + os.stoid + "&goodsidlist=" + str, { 166 await app.request.get("/api/weshop/goods/getgoodslistOrdby?store_id=" + os.stoid + "&goodsidlist=" + str, {
159 isShowLoading:false, 167 isShowLoading:false,
160 success: function(res) { 168 success: function(res) {
  169 + th.data.loading=0;
161 170
162 if(res.data.code==0 && res.data.data){ 171 if(res.data.code==0 && res.data.data){
163 var rData = th.data.requestData; 172 var rData = th.data.requestData;
@@ -210,6 +219,7 @@ Component({ @@ -210,6 +219,7 @@ Component({
210 await app.request.promiseGet("/api/weshop/goods/page", { 219 await app.request.promiseGet("/api/weshop/goods/page", {
211 data:r_data 220 data:r_data
212 }).then(res => { 221 }).then(res => {
  222 + th.data.loading=0;
213 //商品地址 223 //商品地址
214 var goods = res.data.data.pageData; 224 var goods = res.data.data.pageData;
215 th.setData({ 225 th.setData({
@@ -233,6 +243,7 @@ Component({ @@ -233,6 +243,7 @@ Component({
233 isonsale: 1, 243 isonsale: 1,
234 } 244 }
235 }).then(res => { 245 }).then(res => {
  246 + th.data.loading=0;
236 //商品地址 247 //商品地址
237 var goods = res.data.data.pageData; 248 var goods = res.data.data.pageData;
238 th.setData({ 249 th.setData({
@@ -250,6 +261,8 @@ Component({ @@ -250,6 +261,8 @@ Component({
250 261
251 setLoading: function () { 262 setLoading: function () {
252 var that = this; 263 var that = this;
  264 + if(this.data.loading) return false;
  265 + this.data.loading=1;
253 that.init(that.data.classstyle_id, that.data.wgroup); 266 that.init(that.data.classstyle_id, that.data.wgroup);
254 }, 267 },
255 268
@@ -461,7 +474,16 @@ Component({ @@ -461,7 +474,16 @@ Component({
461 }); 474 });
462 } 475 }
463 476
464 - } 477 + },
  478 +
  479 + re_show:function () {
  480 + if(this.data.object.goodscount *this.data.page <this.data.total ){
  481 + this.setLoading()
  482 + }
  483 + }
  484 +
  485 +
  486 +
465 487
466 } 488 }
467 }) 489 })
468 \ No newline at end of file 490 \ No newline at end of file
pages/cart/cart/cart.js
@@ -35,6 +35,8 @@ Page({ @@ -35,6 +35,8 @@ Page({
35 max_sw_height:200, 35 max_sw_height:200,
36 36
37 zhhe_prom:[], //组合活动需要显示差多少件 37 zhhe_prom:[], //组合活动需要显示差多少件
  38 + zuhe_map:{},
  39 + zuhe_map_good:{}
38 }, 40 },
39 onLoad: function() { 41 onLoad: function() {
40 var a = this,ee=a; 42 var a = this,ee=a;
@@ -148,20 +150,6 @@ Page({ @@ -148,20 +150,6 @@ Page({
148 //-------------获取购物车列表,要安装门店进行分类订单----------- 150 //-------------获取购物车列表,要安装门店进行分类订单-----------
149 getCardList: function() { 151 getCardList: function() {
150 var th = this; 152 var th = this;
151 - //如果门店还未读出来的时候  
152 - if (th.data.allsto == null) {  
153 - //读取门店  
154 - app.get_allsto(function(e) {  
155 - th.setData({  
156 - allsto: e  
157 - });  
158 - th.get_cart();  
159 - th.get_ser_cart();  
160 - })  
161 - } else {  
162 - th.get_cart();  
163 - th.get_ser_cart();  
164 - }  
165 153
166 //要获取会员是不是等级会员 154 //要获取会员是不是等级会员
167 getApp().getConfig2(function(conf){ 155 getApp().getConfig2(function(conf){
@@ -181,6 +169,22 @@ Page({ @@ -181,6 +169,22 @@ Page({
181 th.setData({card_field:user.card_field}) 169 th.setData({card_field:user.card_field})
182 } 170 }
183 } 171 }
  172 +
  173 + //如果门店还未读出来的时候
  174 + if (th.data.allsto == null) {
  175 + //读取门店
  176 + app.get_allsto(function(e) {
  177 + th.setData({
  178 + allsto: e
  179 + });
  180 + th.get_cart();
  181 + th.get_ser_cart();
  182 + })
  183 + } else {
  184 + th.get_cart();
  185 + th.get_ser_cart();
  186 + }
  187 +
184 } 188 }
185 }) 189 })
186 if( (!this.data.requestData || this.data.requestData.length==0) && (!this.data.service_data || this.data.service_data.length==0)) { 190 if( (!this.data.requestData || this.data.requestData.length==0) && (!this.data.service_data || this.data.service_data.length==0)) {
@@ -252,6 +256,7 @@ Page({ @@ -252,6 +256,7 @@ Page({
252 } 256 }
253 var goodsbuynum=0,promgoodsbuynum=0,limit=0; 257 var goodsbuynum=0,promgoodsbuynum=0,limit=0;
254 258
  259 +
255 //--要获得商品,该用户买了多少件,同步应用-- 260 //--要获得商品,该用户买了多少件,同步应用--
256 await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", { 261 await getApp().request.promiseGet("/api/weshop/ordergoods/getUserBuyGoodsNum", {
257 data: { 262 data: {
@@ -349,57 +354,71 @@ Page({ @@ -349,57 +354,71 @@ Page({
349 if (!isok) continue; 354 if (!isok) continue;
350 } 355 }
351 else if (item.prom_type == 7) { 356 else if (item.prom_type == 7) {
352 - var isok = 1;  
353 - //如果有组合购  
354 - var url="/api/weshop/prom/zhbuy/get/"+os.stoid+"/"+item.prom_id+"/"+getApp().globalData.userInfo.user_id;  
355 - await getApp().request.promiseGet(url, {}).then(res => {  
356 - if(res.data.code==0 && res.data.data){  
357 - if(res.data.data.is_show!=1){  
358 - isok=0;  
359 - }  
360 - //如果活动已经结束  
361 - if(res.data.data.is_end==1){  
362 - isok=0;  
363 - }  
364 - //已经结束  
365 - if(ut.gettimestamp()>res.data.data.end_time){  
366 - isok=0;  
367 - }  
368 - //还未开始  
369 - if(ut.gettimestamp()<res.data.data.start_time){  
370 - isok=0; 357 + if(!th.data.zuhe_map[item.prom_id]){
  358 + //如果有组合购
  359 + var isok = 1;
  360 + var act=null;
  361 + var url="/api/weshop/prom/zhbuy/get/"+os.stoid+"/"+item.prom_id+"/"+getApp().globalData.userInfo.user_id;
  362 + await getApp().request.promiseGet(url, {}).then(res => {
  363 + if(res.data.code==0 && res.data.data){
  364 + if(res.data.data.is_show!=1){
  365 + isok=0;
  366 + }
  367 + //如果活动已经结束
  368 + if(res.data.data.is_end==1){
  369 + isok=0;
  370 + }
  371 + //已经结束
  372 + if(ut.gettimestamp()>res.data.data.end_time){
  373 + isok=0;
  374 + }
  375 + //还未开始
  376 + if(ut.gettimestamp()<res.data.data.start_time){
  377 + isok=0;
  378 + }
  379 + act=res.data.data;
  380 +
  381 + }else{
  382 + //未找到商品的活动
  383 + isok = 0;
371 } 384 }
372 385
373 - }else{  
374 - //未找到商品的活动  
375 - isok = 0;  
376 - }  
377 - item.act=res.data.data;  
378 - })  
379 - if (!isok){  
380 - var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;  
381 - getApp().request.delete(url, {});  
382 - continue;  
383 - }  
384 - item.zh_b_num=promgoodsbuynum;  
385 -  
386 - var url1 = "/api/weshop/prom/zhbuyGoods/page";  
387 - var req_data = {  
388 - page: 1,  
389 - pageSize: 2000,  
390 - store_id: os.stoid,  
391 - zh_id: item.prom_id,  
392 - goods_id:item.goods_id  
393 - }  
394 - await getApp().request.promiseGet(url1, {  
395 - data: req_data  
396 - }).then(res => {  
397 - if (ut.ajax_ok(res)) {  
398 - gdlist = res.data.data.pageData[0];  
399 - item.buyqty=gdlist.buyqty; 386 + })
  387 + if (!isok){
  388 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  389 + getApp().request.delete(url, {});
  390 + th.data.zuhe_map[item.prom_id]=-1;
  391 + continue;
400 } 392 }
401 - }) 393 + th.data.zuhe_map[item.prom_id]=act;
  394 +
  395 + var url1 = "/api/weshop/prom/zhbuyGoods/page";
  396 + var req_data = {
  397 + page: 1,
  398 + pageSize: 2000,
  399 + store_id: os.stoid,
  400 + zh_id: item.prom_id,
  401 + goods_id:item.goods_id
  402 + }
  403 + await getApp().request.promiseGet(url1, {
  404 + data: req_data
  405 + }).then(res => {
  406 + if (ut.ajax_ok(res)) {
  407 + var gdlist = res.data.data.pageData;
  408 + th.data.zuhe_map_good[item.prom_id]=gdlist;
  409 + }
  410 + })
  411 + }
402 412
  413 + if(th.data.zuhe_map[item.prom_id] && th.data.zuhe_map[item.prom_id]!=-1 ){
  414 + var gdlist=th.data.zuhe_map_good[item.prom_id];
  415 + var t_item=gdlist.find(function (ele) {
  416 + return ele.goods_id==item.goods_id
  417 + })
  418 + item.buyqty=t_item.buyqty;
  419 + item.zh_b_num=promgoodsbuynum;
  420 + item.act=th.data.zuhe_map[item.prom_id];
  421 + }
403 } 422 }
404 else if(item.prom_type == 0) { 423 else if(item.prom_type == 0) {
405 //如果有优惠活动,要更新活动 424 //如果有优惠活动,要更新活动
@@ -425,6 +444,19 @@ Page({ @@ -425,6 +444,19 @@ Page({
425 item.erpwareid=good.erpwareid; //要同步下线商品的id 444 item.erpwareid=good.erpwareid; //要同步下线商品的id
426 item.shop_price=good.shop_price; //要同步下线商品的id 445 item.shop_price=good.shop_price; //要同步下线商品的id
427 446
  447 + //当商品要计算等级价的售
  448 + if(item.prom_type == 0 || item.prom_type == 3 || item.prom_type == 5 || item.prom_type == 7){
  449 + if(th.data.card_field){
  450 + item.goods_price=good[th.data.card_field]; //要同步下线商品的id
  451 + }else{
  452 + item.goods_price=good.shop_price;
  453 + }
  454 +
  455 + var t=item;
  456 + getApp().request.put("/api/weshop/cart/update", {isShowLoading:0,data: t,})
  457 +
  458 + }
  459 +
428 var pcid = item.pick_id; 460 var pcid = item.pick_id;
429 var find = 0; 461 var find = 0;
430 //---------循环查找门店--- 462 //---------循环查找门店---
pages/cart/cart/zh_calculate.js
@@ -60,7 +60,7 @@ module.exports = { @@ -60,7 +60,7 @@ module.exports = {
60 var txt = "requestData[" + a + "].need_list"; 60 var txt = "requestData[" + a + "].need_list";
61 //活动的列表都存储在这里面,可以快速查询 61 //活动的列表都存储在这里面,可以快速查询
62 var zh_prom_goods=car_item.zh_prom_goods; 62 var zh_prom_goods=car_item.zh_prom_goods;
63 - if (!car_item.zh_map && !zh_prom_goods) { 63 + if (!car_item.zh_map || !zh_prom_goods) {
64 var res = { 64 var res = {
65 tfeel: tfeel, 65 tfeel: tfeel,
66 offline_price: offline_price, 66 offline_price: offline_price,
pages/index/index/index.js
@@ -601,6 +601,14 @@ Page({ @@ -601,6 +601,14 @@ Page({
601 onReachBottom: function() { 601 onReachBottom: function() {
602 var goods_list = this.selectComponent("#goods_list"); //组件的id 602 var goods_list = this.selectComponent("#goods_list"); //组件的id
603 if (goods_list) goods_list.get_list(); 603 if (goods_list) goods_list.get_list();
  604 +
  605 + if(getApp().globalData.func_list)
  606 + {
  607 + for(let i in getApp().globalData.func_list){
  608 + let item=getApp().globalData.func_list[i];
  609 + item.re_show();
  610 + }
  611 + }
604 }, 612 },
605 613
606 onPullDownRefresh: function(e) { 614 onPullDownRefresh: function(e) {
pages/template/index.js
@@ -82,16 +82,27 @@ Page({ @@ -82,16 +82,27 @@ Page({
82 setCountTime: function(e) { 82 setCountTime: function(e) {
83 83
84 }, 84 },
85 -  
86 - 85 +
  86 +
87 onPageScroll: function(e) { 87 onPageScroll: function(e) {
88 - 88 +
89 }, 89 },
90 90
91 onShareAppMessage: function(e) { 91 onShareAppMessage: function(e) {
92 92
93 }, 93 },
94 94
  95 + //---加载更多是靠这个函数----
  96 + onReachBottom: function() {
  97 + if(getApp().globalData.func_list)
  98 + {
  99 + for(let i in getApp().globalData.func_list){
  100 + let item=getApp().globalData.func_list[i];
  101 + item.re_show();
  102 + }
  103 + }
  104 + },
  105 +
95 106
96 107
97 }); 108 });
98 \ No newline at end of file 109 \ No newline at end of file
pages/user/order_detail/order_detail.js
1 var e = getApp(), r = e.request,rq=r,t = require("../../../utils/util.js"), o = require("../../../utils/common.js"),oo=e.globalData,os=oo.setting; 1 var e = getApp(), r = e.request,rq=r,t = require("../../../utils/util.js"), o = require("../../../utils/common.js"),oo=e.globalData,os=oo.setting;
2 var regeneratorRuntime = require('../../../utils/runtime.js'); 2 var regeneratorRuntime = require('../../../utils/runtime.js');
3 var ut= require('../../../utils/util.js'); 3 var ut= require('../../../utils/util.js');
  4 +var py = require("../../../utils/pay.js");
4 5
5 6
6 Page({ 7 Page({
@@ -637,12 +638,20 @@ Page({ @@ -637,12 +638,20 @@ Page({
637 } 638 }
638 639
639 } 640 }
640 - 641 +
  642 + /*---
641 o.jumpToCart4({ 643 o.jumpToCart4({
642 order_sn: this.data.order.order_sn, 644 order_sn: this.data.order.order_sn,
643 order_amount: this.data.order.order_amount, 645 order_amount: this.data.order.order_amount,
644 type: 1 //正常单 646 type: 1 //正常单
645 - }, 1); 647 + }, 1);--*/
  648 +
  649 + py.pay(this.data.order.order_sn, function() {
  650 + wx.showToast({title: '支付成功'})
  651 + wx.navigateBack();
  652 + },null,os.stoid,1);
  653 +
  654 +
646 }, 655 },
647 checkTeam: function() { 656 checkTeam: function() {
648 wx.navigateTo({ 657 wx.navigateTo({
pages/user/order_list/order_list.js
@@ -13,6 +13,7 @@ var t = function(t) { @@ -13,6 +13,7 @@ var t = function(t) {
13 s = new t.default(); 13 s = new t.default();
14 var regeneratorRuntime = require('../../../utils/runtime.js'); 14 var regeneratorRuntime = require('../../../utils/runtime.js');
15 var ut= require('../../../utils/util.js'); 15 var ut= require('../../../utils/util.js');
  16 +var t = require("../../../utils/pay.js");
16 17
17 Page({ 18 Page({
18 data: { 19 data: {
@@ -435,7 +436,7 @@ Page({ @@ -435,7 +436,7 @@ Page({
435 /*----------跳转支付-----------*/ 436 /*----------跳转支付-----------*/
436 async jumpToCart4(t) { 437 async jumpToCart4(t) {
437 var o_index = t.currentTarget.dataset.idx; 438 var o_index = t.currentTarget.dataset.idx;
438 - var e = this.data.orderList[t.currentTarget.dataset.idx]; 439 + var e = this.data.orderList[o_index];
439 var th = this; 440 var th = this;
440 var order=e ; 441 var order=e ;
441 var order_goods=e.order_goods; 442 var order_goods=e.order_goods;
@@ -753,15 +754,12 @@ Page({ @@ -753,15 +754,12 @@ Page({
753 754
754 } 755 }
755 756
756 - th.pay_next(e); 757 + th.pay_next(e,o_index);
757 }, 758 },
758 759
759 760
760 - pay_next(e){ 761 + pay_next(e,o_index){
761 var th=this; 762 var th=this;
762 -  
763 -  
764 -  
765 if (e.order_amount == 0) { 763 if (e.order_amount == 0) {
766 var dd = { 764 var dd = {
767 parent_sn: e.order_sn, 765 parent_sn: e.order_sn,
@@ -779,12 +777,22 @@ Page({ @@ -779,12 +777,22 @@ Page({
779 } 777 }
780 }) 778 })
781 return false; 779 return false;
782 - } 780 + }
  781 +
  782 + /*---
783 a.jumpToCart4({ 783 a.jumpToCart4({
784 order_sn: e.order_sn, 784 order_sn: e.order_sn,
785 order_amount: e.order_amount, 785 order_amount: e.order_amount,
786 type: 1 //正常单 786 type: 1 //正常单
787 - }); 787 + });--*/
  788 +
  789 + t.pay(e.order_sn, function() {
  790 + wx.showToast({title: '支付成功'})
  791 + th.data.orderList.splice(o_index,1);
  792 + th.setData({orderList:th.data.orderList});
  793 + },null,os.stoid,1);
  794 +
  795 +
788 }, 796 },
789 797
790 //---检验线下库存的数量的子函数--- 798 //---检验线下库存的数量的子函数---