Commit 8a1b15442ba9cb35c361511b13ab2e739570f99f

Authored by 后端研发-苏泰源
2 parents 4a56429a 7a1412d3

Merge branch 'dev' of http://git.vipzhuang.cn/wxd/MShopWeApp into dev

# Conflicts:
#	pages/goods/goodsInfo/goodsInfo.js
#	pages/goods/goodsInfo/goodsInfo.wxss
Showing 50 changed files with 1782 additions and 448 deletions
@@ -50,7 +50,7 @@ App({ @@ -50,7 +50,7 @@ App({
50 config: null, //门店参数 50 config: null, //门店参数
51 config2: null, //门店配置 51 config2: null, //门店配置
52 code: null, 52 code: null,
53 - user_id:null,//3277,// 6519901,//6453964,// 4687,// 6519870,//5682094, 53 + user_id:null,// 6519870,//5682094,
54 buy_now:null, 54 buy_now:null,
55 picklist:null, //门店列表 55 picklist:null, //门店列表
56 wuliuprice: null, //物流价格表 56 wuliuprice: null, //物流价格表
@@ -661,8 +661,10 @@ App({ @@ -661,8 +661,10 @@ App({
661 this.globalData.config=null; //清除config的缓存 661 this.globalData.config=null; //清除config的缓存
662 this.globalData.gr_index=0; //商品分组的序列 662 this.globalData.gr_index=0; //商品分组的序列
663 this.globalData.pk_store=null; 663 this.globalData.pk_store=null;
664 - this.globalData.wxapp_buy_obj=null  
665 - 664 + this.globalData.wxapp_buy_obj=null;
  665 + this.globalData.dis_buy_obj=null; //等级卡的购买记录
  666 + this.globalData.storeFooter=null; //底部的导航
  667 + this.globalData.full_screen=null; //全屏
666 }, 668 },
667 669
668 clear_word:function (word) { 670 clear_word:function (word) {
components/diy_goodsGroup/diy_goodsGroup.js
@@ -432,7 +432,9 @@ Component({ @@ -432,7 +432,9 @@ Component({
432 set_good:async function(goods){ 432 set_good:async function(goods){
433 var now=ut.gettimestamp(); 433 var now=ut.gettimestamp();
434 var th=this; 434 var th=this;
435 - if(!goods || goods.length==0) return false; 435 + if(!goods || goods.length==0) return false;
  436 + var user_id=getApp().globalData.userInfo.user_id;
  437 + if(!user_id) user_id=0;
436 for(var i in goods){ 438 for(var i in goods){
437 var val=goods[i]; 439 var val=goods[i];
438 var item = {}; 440 var item = {};
@@ -441,7 +443,7 @@ Component({ @@ -441,7 +443,7 @@ Component({
441 443
442 var url="/api/weshop/activitylist/getGoodActInfo"; 444 var url="/api/weshop/activitylist/getGoodActInfo";
443 var req_data={ 445 var req_data={
444 - store_id:os.stoid,goodsidlist:val.goods_id,is_detail:1 446 + store_id:os.stoid,goodsidlist:val.goods_id,is_detail:1,user_id:user_id
445 }; 447 };
446 448
447 //获取商品的实际活动 449 //获取商品的实际活动
components/diy_goodsGroup/diy_goodsGroup.wxml
@@ -669,7 +669,7 @@ @@ -669,7 +669,7 @@
669 <view class="sp"> 669 <view class="sp">
670 <swiper-item class="s_it" wx:for="{{goods_array}}"> 670 <swiper-item class="s_it" wx:for="{{goods_array}}">
671 <block wx:for="{{item}}" wx:for-item="aitem" wx:for-index="aind"> 671 <block wx:for="{{item}}" wx:for-item="aitem" wx:for-index="aind">
672 - <navigator url="{{g_filter.get_url_by_type(item)}}" style="width: 32%" > 672 + <navigator url="{{g_filter.get_url_by_type(aitem)}}" style="width: 32%" >
673 <view class="one {{object.big_order_type==0?'zj':''}}{{object.big_order_type==1?'yj':''}} " style="margin-left: 10rpx"> 673 <view class="one {{object.big_order_type==0?'zj':''}}{{object.big_order_type==1?'yj':''}} " style="margin-left: 10rpx">
674 <view class='sp_top'> 674 <view class='sp_top'>
675 <view class='s_img' style="position: relative; width: 100%"> 675 <view class='s_img' style="position: relative; width: 100%">
components/diy_pingd_buy/diy_pingd_buy.js
@@ -47,7 +47,12 @@ Component({ @@ -47,7 +47,12 @@ Component({
47 th.countDown2(th); 47 th.countDown2(th);
48 }, 1000); 48 }, 1000);
49 } 49 }
50 - } 50 + },
  51 +
  52 + hide:function () {
  53 + // 页面被被销毁的时候,清除定时器
  54 + clearInterval(this.data.timer);
  55 + }
51 }, 56 },
52 57
53 58
components/diy_seckill/diy_seckill.js
@@ -35,6 +35,7 @@ Component({ @@ -35,6 +35,7 @@ Component({
35 ylp_img: "https://mshopimg.yolipai.net/", 35 ylp_img: "https://mshopimg.yolipai.net/",
36 imghost: os.imghost, 36 imghost: os.imghost,
37 timer: null, 37 timer: null,
  38 + user_id:0
38 }, 39 },
39 40
40 pageLifetimes: { 41 pageLifetimes: {
@@ -43,7 +44,12 @@ Component({ @@ -43,7 +44,12 @@ Component({
43 //会员身份变化 44 //会员身份变化
44 var th = this; 45 var th = this;
45 var g_id = this.data.object; 46 var g_id = this.data.object;
46 - this.init(g_id); 47 + //只有再会员登陆之后,才重新调用接口
  48 +
  49 + if(this.data.user_id!=getApp().globalData.user_id){
  50 + this.data.user_id=getApp().globalData.user_id
  51 + this.init(g_id);
  52 + }
47 setTimeout(function () { 53 setTimeout(function () {
48 if (th.data.goods_array && th.data.goods_array.length > 0) { 54 if (th.data.goods_array && th.data.goods_array.length > 0) {
49 th.data.timer = setInterval(function () { 55 th.data.timer = setInterval(function () {
@@ -51,12 +57,18 @@ Component({ @@ -51,12 +57,18 @@ Component({
51 }, 1000); 57 }, 1000);
52 } 58 }
53 },600) 59 },600)
  60 + },
  61 +
  62 + hide:function () {
  63 + // 页面被被销毁的时候,清除定时器
  64 + clearInterval(this.data.timer);
54 } 65 }
55 }, 66 },
56 67
57 ready: function () { 68 ready: function () {
58 var g_id = this.data.object; 69 var g_id = this.data.object;
59 this.init(g_id); 70 this.init(g_id);
  71 + this.data.user_id=getApp().globalData.user_id;
60 }, 72 },
61 detached() { 73 detached() {
62 // 页面被被销毁的时候,清除定时器 74 // 页面被被销毁的时候,清除定时器
components/goods_list/goods_list.js
@@ -207,5 +207,11 @@ Component({ @@ -207,5 +207,11 @@ Component({
207 func(ob); 207 func(ob);
208 }) 208 })
209 }, 209 },
  210 +
  211 + go_url:function (e) {
  212 + var url=e.currentTarget.dataset.url;
  213 + getApp().goto(url);
  214 + }
  215 +
210 }, 216 },
211 }) 217 })
212 \ No newline at end of file 218 \ No newline at end of file
components/goods_list/goods_list.wxml
@@ -5,17 +5,17 @@ @@ -5,17 +5,17 @@
5 <view class="hang "> 5 <view class="hang ">
6 <!-- 商品详情 --> 6 <!-- 商品详情 -->
7 7
8 - <view class="collect ib" wx:for="{{recommend}}" bindtap="go_url" data-url="{{get_url_by_type(item)}}"> 8 + <view class="collect ib" wx:for="{{recommend}}" bindtap="go_url" data-url="{{g_filter.get_url_by_type(item)}}">
9 <!--<view class="collect ib" wx:for="{{recommend}}" bindtap="go_url" data-url="{{item.prom_type == 9 ? ('/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=' + item.goods_id + '&group_id=' + item.prom_id):('/pages/goods/goodsInfo/goodsInfo?goods_id='+item.goods_id+'&title='+item.goods_name+'&prom_type='+item.prom_type+'&prom_id='+item.prom_id)}}">--> 9 <!--<view class="collect ib" wx:for="{{recommend}}" bindtap="go_url" data-url="{{item.prom_type == 9 ? ('/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=' + item.goods_id + '&group_id=' + item.prom_id):('/pages/goods/goodsInfo/goodsInfo?goods_id='+item.goods_id+'&title='+item.goods_name+'&prom_type='+item.prom_type+'&prom_id='+item.prom_id)}}">-->
10 <!-- <navigator url="/pages/goods/goodsInfo/goodsInfo?goods_id={{item.goods_id}}&title={{item.goods_name}}&prom_type={{item.prom_type}}&prom_id={{item.prom_id}}" hover-class="none"> --> 10 <!-- <navigator url="/pages/goods/goodsInfo/goodsInfo?goods_id={{item.goods_id}}&title={{item.goods_name}}&prom_type={{item.prom_type}}&prom_id={{item.prom_id}}" hover-class="none"> -->
11 - <navigator url="{{item.prom_type == 9 ? ('/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=' + item.goods_id + '&group_id=' + item.prom_id):('/pages/goods/goodsInfo/goodsInfo?goods_id='+item.goods_id+'&title='+item.goods_name+'&prom_type='+item.prom_type+'&prom_id='+item.prom_id)}}" hover-class="none"> 11 + <navigator hover-class="none">
12 <!-- 商品图⽚ --> 12 <!-- 商品图⽚ -->
13 <image class="sp" src="{{url+item.original_img}}" mode="aspectFill" binderror="bind_bnerr_xc" data-url="{{url+item.original_img}}" data-errorimg="recommend[{{index}}].original_img"></image> 13 <image class="sp" src="{{url+item.original_img}}" mode="aspectFill" binderror="bind_bnerr_xc" data-url="{{url+item.original_img}}" data-errorimg="recommend[{{index}}].original_img"></image>
14 <view class="bottom"> 14 <view class="bottom">
15 <!-- 商品名称 --> 15 <!-- 商品名称 -->
16 <view class="goods_name ellipsis-2 fs28">{{item.goods_name}}</view> 16 <view class="goods_name ellipsis-2 fs28">{{item.goods_name}}</view>
17 <!-- 判断是否有活动价 --> 17 <!-- 判断是否有活动价 -->
18 - <block wx:if="{{(item.prom_price>0 || item.prom_integral>0) && item.prom_id>0 && item.prom_type!=7}}"> 18 + <block wx:if="{{(item.prom_price>0 || item.prom_integral>0) && item.prom_id>0 && item.prom_type!=7 && item.prom_type!=10}}">
19 <view class="pdt10"> 19 <view class="pdt10">
20 <view class="money flex xc-wc" > 20 <view class="money flex xc-wc" >
21 <text wx:if="{{item.prom_integral}}"><text class="fs35" style="font-weight: bold;">{{item.prom_integral}}</text>积分</text> 21 <text wx:if="{{item.prom_integral}}"><text class="fs35" style="font-weight: bold;">{{item.prom_integral}}</text>积分</text>
custom-tab-bar/index.js
@@ -9,33 +9,43 @@ Component({ @@ -9,33 +9,43 @@ Component({
9 list:app.def_list, 9 list:app.def_list,
10 cartGoodsNum:0, 10 cartGoodsNum:0,
11 }, 11 },
12 -  
13 12
14 lifetimes: { 13 lifetimes: {
15 attached: function() { 14 attached: function() {
16 var th=this; 15 var th=this;
17 -  
18 getApp().promiseGet("/api/weshop/storeDistribut/get/"+os.stoid,{}).then(rs=>{ 16 getApp().promiseGet("/api/weshop/storeDistribut/get/"+os.stoid,{}).then(rs=>{
19 var dis=rs.data.data; 17 var dis=rs.data.data;
20 if( dis && dis.switch==0){ 18 if( dis && dis.switch==0){
21 th.setData({is_no_distri:1}) 19 th.setData({is_no_distri:1})
22 } 20 }
23 - })  
24 -  
25 - getApp().promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=5",{}).then(res=>{  
26 - if(res.data.code==0){  
27 - var arr = res.data.data.pageData;  
28 - if (arr.length > 0) {  
29 - var item=arr[0];  
30 - if(item.is_sy==0){  
31 - var now = Date.parse(new Date());now = now / 1000;  
32 - if(item.end_time<now) th.setData({is_no_distri:1})  
33 - }  
34 - }  
35 - }  
36 }) 21 })
37 -  
38 - 22 +
  23 + //购买的信息用全局缓存
  24 + if(getApp().globalData.dis_buy_obj){
  25 + var arr = getApp().globalData.dis_buy_obj;
  26 + if (arr.length > 0) {
  27 + var item=arr[0];
  28 + if(item.is_sy==0){
  29 + var now = Date.parse(new Date());now = now / 1000;
  30 + if(item.end_time<now) th.setData({is_no_distri:1})
  31 + }
  32 + }
  33 + }else{
  34 + getApp().promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=5",{}).then(res=>{
  35 + if(res.data.code==0){
  36 + var arr = res.data.data.pageData;
  37 + getApp().globalData.dis_buy_obj=arr;
  38 + if (arr.length > 0) {
  39 + var item=arr[0];
  40 + if(item.is_sy==0){
  41 + var now = Date.parse(new Date());now = now / 1000;
  42 + if(item.end_time<now) th.setData({is_no_distri:1})
  43 + }
  44 + }
  45 + }
  46 + })
  47 + }
  48 +
39 //购物车显示商品金额 49 //购物车显示商品金额
40 this.setData({cartGoodsNum:getApp().globalData.cartGoodsNum}); 50 this.setData({cartGoodsNum:getApp().globalData.cartGoodsNum});
41 var th=this; 51 var th=this;
@@ -47,24 +57,37 @@ Component({ @@ -47,24 +57,37 @@ Component({
47 this.set_list(custum_data); 57 this.set_list(custum_data);
48 } 58 }
49 }else{ 59 }else{
50 - var stoid=os.stoid  
51 - getApp().request.promiseGet("/api/weshop/storeFooter/get/"+stoid, {  
52 - }).then(res => {  
53 - getApp().globalData.is_read=true;  
54 - var e = res;  
55 - if(e.data.code != -1 && e.data.data && e.data.data.data){  
56 - var itemList = e.data.data.data;  
57 - itemList = JSON.parse(itemList)  
58 - //如果是有定义自定义导航的小程序链接  
59 - if(itemList[0].weappurl && itemList[0].weappurl!=""){  
60 - getApp().globalData.custum_data=e.data.data;  
61 - var custum_data=e.data.data;  
62 - th.set_list(custum_data);  
63 - }  
64 -  
65 - }  
66 -  
67 - }) 60 +
  61 + //全局缓存
  62 + if(getApp().globalData.storeFooter) {
  63 + var itemList = getApp().globalData.storeFooter;
  64 + itemList = JSON.parse(itemList)
  65 + //-- 如果是有定义自定义导航的小程序链接 --
  66 + if (itemList[0].weappurl && itemList[0].weappurl != "") {
  67 + getApp().globalData.custum_data = e.data.data;
  68 + var custum_data = e.data.data;
  69 + th.set_list(custum_data);
  70 + }
  71 +
  72 + }else{
  73 + var stoid = os.stoid;
  74 + getApp().request.promiseGet("/api/weshop/storeFooter/get/" + stoid, {}).then(res => {
  75 + getApp().globalData.is_read = true;
  76 + var e = res;
  77 + if (e.data.code != -1 && e.data.data && e.data.data.data) {
  78 + var itemList = e.data.data.data;
  79 + getApp().globalData.storeFooter=itemList;
  80 + itemList = JSON.parse(itemList)
  81 + //-- 如果是有定义自定义导航的小程序链接 --
  82 + if (itemList[0].weappurl && itemList[0].weappurl != "") {
  83 + getApp().globalData.custum_data = e.data.data;
  84 + var custum_data = e.data.data;
  85 + th.set_list(custum_data);
  86 + }
  87 + }
  88 +
  89 + })
  90 + }
68 } 91 }
69 }, 92 },
70 }, 93 },
packageA/pages/goodsInfo/goodsInfo.js
@@ -333,7 +333,7 @@ Page({ @@ -333,7 +333,7 @@ Page({
333 getApp().request.promiseGet("/api/weshop/pickup/list",{ 333 getApp().request.promiseGet("/api/weshop/pickup/list",{
334 data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon, is_pos: 1}, 334 data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon, is_pos: 1},
335 }).then(res=>{ 335 }).then(res=>{
336 - if(res.data.code==0){ 336 + if(ut.ajax_ok(res)){
337 e=res.data.data.pageData[0]; 337 e=res.data.data.pageData[0];
338 if (e){ 338 if (e){
339 e.is_no_dis=ee.is_no_dis; 339 e.is_no_dis=ee.is_no_dis;
packageA/pages/my_service/appment_main.js
@@ -697,7 +697,7 @@ Page({ @@ -697,7 +697,7 @@ Page({
697 } 697 }
698 }).then(res => { 698 }).then(res => {
699 //-- 如果是门店的话 -- 699 //-- 如果是门店的话 --
700 - if (res.data.code == 0 && res.data.data && res.data.data.pageData) { 700 + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length) {
701 var store_data=null; 701 var store_data=null;
702 for(var i in res.data.data.pageData){ 702 for(var i in res.data.data.pageData){
703 var it=res.data.data.pageData[i]; 703 var it=res.data.data.pageData[i];
packageA/pages/profile/profile.js
@@ -1246,13 +1246,15 @@ Page({ @@ -1246,13 +1246,15 @@ Page({
1246 getApp().request.promiseGet("/api/weshop/pickup/list", { 1246 getApp().request.promiseGet("/api/weshop/pickup/list", {
1247 data: dd, 1247 data: dd,
1248 }).then(res => { 1248 }).then(res => {
1249 - var top_store=res.data.data.pageData[0];  
1250 - th.setData({  
1251 - stoname: top_store.pickup_name,  
1252 - sto_sele_name: top_store.pickup_name,  
1253 - sto_sele_id: top_store.pickup_id,  
1254 - sto_sele_distr: top_store.distr_type,  
1255 - }) 1249 + if(ut.ajax_ok(res)){
  1250 + var top_store=res.data.data.pageData[0];
  1251 + th.setData({
  1252 + stoname: top_store.pickup_name,
  1253 + sto_sele_name: top_store.pickup_name,
  1254 + sto_sele_id: top_store.pickup_id,
  1255 + sto_sele_distr: top_store.distr_type,
  1256 + })
  1257 + }
1256 }) 1258 })
1257 1259
1258 }else{ 1260 }else{
packageA/pages/prom_list/prom_list.js
@@ -120,7 +120,7 @@ Page({ @@ -120,7 +120,7 @@ Page({
120 getApp().request.promiseGet("/api/weshop/pickup/list",{ 120 getApp().request.promiseGet("/api/weshop/pickup/list",{
121 data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon,is_pos: 1}, 121 data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon,is_pos: 1},
122 }).then(res=>{ 122 }).then(res=>{
123 - if(res.data.code==0 && res.data.data && res.data.data.pageData){ 123 + if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){
124 e=res.data.data.pageData[0]; 124 e=res.data.data.pageData[0];
125 if (e){ 125 if (e){
126 appd.pk_store=e; 126 appd.pk_store=e;
@@ -1030,7 +1030,7 @@ Page({ @@ -1030,7 +1030,7 @@ Page({
1030 }) 1030 })
1031 }).then(res=>{ 1031 }).then(res=>{
1032 if(res.data.code==0){ 1032 if(res.data.code==0){
1033 - if(res.data.data.pageData){ 1033 + if(res.data.data.pageData && res.data.data.pageData.length){
1034 var plist=res.data.data.pageData; 1034 var plist=res.data.data.pageData;
1035 var def_pick_store=th.data.def_pick_store; 1035 var def_pick_store=th.data.def_pick_store;
1036 //以原来的数组为外循环,保证距离的顺序 1036 //以原来的数组为外循环,保证距离的顺序
packageB/pages/user/add_comment/add_comment.js
1 -var t = getApp(), oo = t.globalData, a = t.globalData.setting, os = a, e = t.request, s = require("../../../../utils/util.js"), 1 +var t = getApp(), oo = t.globalData, a = t.globalData.setting, os = a, e = t.request, s = require("../../../../utils/util.js"),ut=s,
2 i = require("../../../../utils/selectFiles.js"); 2 i = require("../../../../utils/selectFiles.js");
3 var regeneratorRuntime = require('../../../../utils/runtime.js'); 3 var regeneratorRuntime = require('../../../../utils/runtime.js');
4 4
@@ -27,9 +27,11 @@ Page({ @@ -27,9 +27,11 @@ Page({
27 var th = this; 27 var th = this;
28 await getApp().request.promiseGet("/api/weshop/ordergoods/pageGoods", { data:{store_id:os.stoid,goods_id:a.goods_id, order_id:a.order_id}}).then(res => { 28 await getApp().request.promiseGet("/api/weshop/ordergoods/pageGoods", { data:{store_id:os.stoid,goods_id:a.goods_id, order_id:a.order_id}}).then(res => {
29 29
30 - a.img = th.data.iurl + res.data.data.pageData[0].original_img;  
31 - a.goods_name=res.data.data.pageData[0].goods_name;  
32 - a.goods_num=res.data.data.pageData[0].goods_num; 30 + if(ut.ajax_ok(res)) {
  31 + a.img = th.data.iurl + res.data.data.pageData[0].original_img;
  32 + a.goods_name = res.data.data.pageData[0].goods_name;
  33 + a.goods_num = res.data.data.pageData[0].goods_num;
  34 + }
33 }) 35 })
34 this.setData({ options: a }); 36 this.setData({ options: a });
35 t.getUserInfo(function (e) { 37 t.getUserInfo(function (e) {
packageC/pages/luckyGo/luckyGo_cart_ct/luckyGo_cart_ct.js
@@ -1042,7 +1042,7 @@ Page({ @@ -1042,7 +1042,7 @@ Page({
1042 th = this; 1042 th = this;
1043 price += parseFloat(o_shipping_price); 1043 price += parseFloat(o_shipping_price);
1044 //如果是包邮 1044 //如果是包邮
1045 - if (freight_free > 0 && o_price > freight_free) { 1045 + if (freight_free > 0 && o_price >= freight_free) {
1046 return 0; 1046 return 0;
1047 } 1047 }
1048 if (user_addr == null) { 1048 if (user_addr == null) {
packageC/pages/luckyGo/luckyGo_order/luckyGo_order.js
@@ -531,6 +531,7 @@ Page({ @@ -531,6 +531,7 @@ Page({
531 check_more_order:async function(item){ 531 check_more_order:async function(item){
532 var pickup=null,th=this; 532 var pickup=null,th=this;
533 var user_id=getApp().globalData.userInfo.user_id; 533 var user_id=getApp().globalData.userInfo.user_id;
  534 + if(!user_id) user_id=0;
534 wx.showLoading(); 535 wx.showLoading();
535 //--------获取门店----------- 536 //--------获取门店-----------
536 await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + item.pickup_id, { 537 await getApp().request.promiseGet("/api/weshop/pickup/get/" + os.stoid + "/" + item.pickup_id, {
@@ -617,7 +618,7 @@ Page({ @@ -617,7 +618,7 @@ Page({
617 618
618 var url="/api/weshop/activitylist/getGoodActInfo"; 619 var url="/api/weshop/activitylist/getGoodActInfo";
619 var req_data={ 620 var req_data={
620 - store_id:g_item.store_id,goodsidlist:g_item.goods_id,is_detail:1 621 + store_id:g_item.store_id,goodsidlist:g_item.goods_id,is_detail:1,user_id:user_id
621 }; 622 };
622 await getApp().request.promiseGet(url, {data:req_data}).then(res=>{ 623 await getApp().request.promiseGet(url, {data:req_data}).then(res=>{
623 if(res.data.code==0){ 624 if(res.data.code==0){
packageC/pages/presell/cart/cart2_pre.js
@@ -706,7 +706,7 @@ Page({ @@ -706,7 +706,7 @@ Page({
706 var price =0,th=this; 706 var price =0,th=this;
707 price +=parseFloat(o_shipping_price); 707 price +=parseFloat(o_shipping_price);
708 //如果是包邮 708 //如果是包邮
709 - if (freight_free > 0 && o_price > freight_free){ return 0;} 709 + if (freight_free > 0 && o_price >= freight_free){ return 0;}
710 if (user_addr==null) { return 0; } 710 if (user_addr==null) { return 0; }
711 //计算物流的config item; 711 //计算物流的config item;
712 var item=null; 712 var item=null;
pages/activity/pind_list/pind_list.js
@@ -129,12 +129,13 @@ Page({ @@ -129,12 +129,13 @@ Page({
129 await getApp().request.promiseGet(i, 129 await getApp().request.promiseGet(i,
130 {isShowLoading:1,data:{store_id:os.stoid,is_end:0,is_show:1}} 130 {isShowLoading:1,data:{store_id:os.stoid,is_end:0,is_show:1}}
131 ).then(res=>{ 131 ).then(res=>{
132 - plist=res.data.data.pageData; 132 + if(ut.ajax_ok(res)) plist=res.data.data.pageData;
133 }); 133 });
134 134
135 - if(plist.length<=0){ 135 + if(!plist || plist.length<=0){
136 getApp().showWarning("没有更多数据"); 136 getApp().showWarning("没有更多数据");
137 th.data.ismore=0; 137 th.data.ismore=0;
  138 + return false;
138 } 139 }
139 //--循环读取接口--- 140 //--循环读取接口---
140 for(var i=0;i<plist.length;i++){ 141 for(var i=0;i<plist.length;i++){
pages/activity/seckill_list/seckill_list.js
@@ -131,8 +131,8 @@ Page({ @@ -131,8 +131,8 @@ Page({
131 await getApp().request.promiseGet(i, 131 await getApp().request.promiseGet(i,
132 {isShowLoading:1,data:req} 132 {isShowLoading:1,data:req}
133 ).then(res=>{ 133 ).then(res=>{
134 - plist=res.data.data.pageData;  
135 - console.log("是什么即将开始",plist); 134 + if(ut.ajax_ok(res)) plist=res.data.data.pageData;
  135 +
136 }); 136 });
137 137
138 if(plist.length<=0){ 138 if(plist.length<=0){
pages/cart/cart/cart.js
@@ -5,8 +5,9 @@ var t = getApp(), @@ -5,8 +5,9 @@ var t = getApp(),
5 app = getApp(), 5 app = getApp(),
6 rq = t.request, 6 rq = t.request,
7 ut = require("../../../utils/util.js"), 7 ut = require("../../../utils/util.js"),
8 - zh_calc = require("zh_calculate.js");  
9 - var regeneratorRuntime = require('../../../utils/runtime.js'); 8 + zh_calc = require("zh_calculate.js"),
  9 + ladder_calc = require("ladder_calculate.js");
  10 + var regeneratorRuntime = require('../../../utils/runtime.js');
10 11
11 Page({ 12 Page({
12 data: { 13 data: {
@@ -38,6 +39,8 @@ Page({ @@ -38,6 +39,8 @@ Page({
38 zuhe_map:{}, 39 zuhe_map:{},
39 zuhe_map_good:{}, 40 zuhe_map_good:{},
40 in_zhact_gdmap:{}, //不同门店参与同一活动的限购 41 in_zhact_gdmap:{}, //不同门店参与同一活动的限购
  42 +
  43 + ladder_map:{}, //阶梯促销需要的map
41 }, 44 },
42 onLoad: function() { 45 onLoad: function() {
43 var a = this,ee=a; 46 var a = this,ee=a;
@@ -83,7 +86,6 @@ Page({ @@ -83,7 +86,6 @@ Page({
83 th.setData({ 86 th.setData({
84 bconfig: e,sales_rules:e.sales_rules 87 bconfig: e,sales_rules:e.sales_rules
85 }); 88 });
86 -  
87 getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=6",{}).then(res=>{ 89 getApp().request.promiseGet("/store/storemoduleendtime/page?store_id=" +os.stoid + "&type=6",{}).then(res=>{
88 //未购买 90 //未购买
89 if(res.data.code!=0 || !res.data.data || !res.data.data.pageData || !res.data.data.pageData.length){ 91 if(res.data.code!=0 || !res.data.data || !res.data.data.pageData || !res.data.data.pageData.length){
@@ -210,6 +212,8 @@ Page({ @@ -210,6 +212,8 @@ Page({
210 get_cart: function() { 212 get_cart: function() {
211 var th = this; 213 var th = this;
212 th.data.in_zhact_gdmap={}; 214 th.data.in_zhact_gdmap={};
  215 + th.data.ladder_map={};
  216 +
213 var rd = Math.random().toString(36).substr(2, 15); 217 var rd = Math.random().toString(36).substr(2, 15);
214 var user_id=getApp().globalData.userInfo.user_id; 218 var user_id=getApp().globalData.userInfo.user_id;
215 getApp().request.get("/api/weshop/cart/list", { 219 getApp().request.get("/api/weshop/cart/list", {
@@ -223,8 +227,7 @@ Page({ @@ -223,8 +227,7 @@ Page({
223 success:async function(su) { 227 success:async function(su) {
224 console.log(su,10000); 228 console.log(su,10000);
225 //按门店分类的数组 229 //按门店分类的数组
226 - var arr = new Array(),  
227 - carr = su.data.data.pageData; 230 + var arr = new Array(), carr = su.data.data.pageData;
228 var all_num = 0; 231 var all_num = 0;
229 232
230 if(carr && carr.length>0) { 233 if(carr && carr.length>0) {
@@ -353,21 +356,22 @@ Page({ @@ -353,21 +356,22 @@ Page({
353 }) 356 })
354 } 357 }
355 } 358 }
356 -  
357 - //--判断优惠活动有没有过期-- 359 + //--判断优惠活动有没有过期,--
358 else if (item.prom_type == 3) { 360 else if (item.prom_type == 3) {
359 var isok = 1,is_g_prom=0; 361 var isok = 1,is_g_prom=0;
  362 +
360 //因为有全场优惠活动,商品参加的活动还未开始 363 //因为有全场优惠活动,商品参加的活动还未开始
361 var url="/api/weshop/activitylist/getGoodActInfo"; 364 var url="/api/weshop/activitylist/getGoodActInfo";
362 var req_data={ 365 var req_data={
363 - store_id:os.stoid,goodsidlist:item.goods_id,is_detail:1,user_id:user_id 366 + store_id:os.stoid,goodsidlist:item.goods_id,is_detail:1,user_id:user_id
364 }; 367 };
365 await getApp().request.promiseGet(url, {data:req_data}).then(async function (res) { 368 await getApp().request.promiseGet(url, {data:req_data}).then(async function (res) {
366 if(res.data.code==0 && res.data.data && res.data.data.length){ 369 if(res.data.code==0 && res.data.data && res.data.data.length){
367 for(let i in res.data.data){ 370 for(let i in res.data.data){
368 - let item=res.data.data[i];  
369 - if(item.prom_type==3) {  
370 - is_g_prom=1; break; 371 + let item=res.data.data[i];
  372 + if(item.prom_type==3) {
  373 + is_g_prom=1; break;
  374 +
371 } 375 }
372 } 376 }
373 } 377 }
@@ -430,6 +434,7 @@ Page({ @@ -430,6 +434,7 @@ Page({
430 } 434 }
431 435
432 if (!isok) continue; 436 if (!isok) continue;
  437 +
433 } 438 }
434 else if (item.prom_type == 7) { 439 else if (item.prom_type == 7) {
435 if(!th.data.zuhe_map[item.prom_id]){ 440 if(!th.data.zuhe_map[item.prom_id]){
@@ -517,6 +522,68 @@ Page({ @@ -517,6 +522,68 @@ Page({
517 // continue; 522 // continue;
518 // } 523 // }
519 } 524 }
  525 + else if (item.prom_type == 10) {
  526 + if(!th.data.ladder_map[item.prom_id]){
  527 + //如果有组合购
  528 + var isok = 1;
  529 + var is_flag=1;
  530 + var act=null;
  531 + var url="/api/weshop/prom/ladderForm/getNew/"+os.stoid+"/"+user_id+"/"+item.prom_id;
  532 + await getApp().request.promiseGet(url, {}).then(res => {
  533 + console.log(res,1000);
  534 + if(res.data.code==0 && res.data.data){
  535 + if(res.data.data.isuse!=1){
  536 + isok=0;
  537 + }
  538 + //如果活动已经结束
  539 + if(res.data.data.is_end==1){
  540 + isok=0;
  541 + }
  542 + //已经结束
  543 + if(ut.gettimestamp()>res.data.data.end_time){
  544 + isok=0;
  545 + }
  546 + //还未开始
  547 + if(ut.gettimestamp()<res.data.data.start_time){
  548 + isok=0;
  549 + }
  550 + act=res.data.data;
  551 +
  552 + }else{
  553 + //未找到商品的活动
  554 + isok = 0;
  555 + }
  556 + })
  557 + if (!isok){
  558 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  559 + getApp().request.delete(url, {});
  560 + th.data.ladder_map[item.prom_id]=-1;
  561 + continue;
  562 + }
  563 + th.data.ladder_map[item.prom_id]=act;
  564 +
  565 + //-- 获取阶梯规则 --
  566 + var url1 = "/api/weshop/prom/ladderList/list";
  567 + var req_data = {
  568 + store_id: os.stoid,
  569 + form_id: item.prom_id,
  570 + }
  571 + await getApp().request.promiseGet(url1, {
  572 + data: req_data
  573 + }).then(rs1 => {
  574 + if (rs1.data.code==0 && rs1.data.data) {
  575 + var gdlist = rs1.data.data;
  576 + th.data.ladder_map[item.prom_id].ladder_list=gdlist;
  577 + }
  578 + })
  579 + }
  580 + //直接把活动赋值给元素
  581 + if(th.data.ladder_map[item.prom_id] && th.data.ladder_map[item.prom_id]!=-1 ){
  582 + item.act=th.data.ladder_map[item.prom_id];
  583 + }
  584 +
  585 + }
  586 +
520 else if(item.prom_type == 0) { 587 else if(item.prom_type == 0) {
521 //如果有优惠活动,要更新活动 588 //如果有优惠活动,要更新活动
522 await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + item.goods_id + "/1", {}).then(res => { 589 await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + item.goods_id + "/1", {}).then(res => {
@@ -529,9 +596,86 @@ Page({ @@ -529,9 +596,86 @@ Page({
529 }); 596 });
530 item.prom_type=3; 597 item.prom_type=3;
531 item.prom_id=r_data.promGoodsLists[0].prom_id; 598 item.prom_id=r_data.promGoodsLists[0].prom_id;
  599 + }else if(r_data.ladderLists){
  600 +
  601 + item.prom_type=10;
  602 + item.prom_id=r_data.ladderLists[0].form_id;
  603 +
532 } 604 }
533 } 605 }
534 }) 606 })
  607 +
  608 + //如果是阶梯购的时候
  609 + if(item.prom_type==10){
  610 +
  611 +
  612 + if(!th.data.ladder_map[item.prom_id]){
  613 + //如果有阶梯购,要判断身份
  614 + var isok = 1;
  615 + var is_flag=1;
  616 + var act=null;
  617 + var url="/api/weshop/prom/ladderForm/getNew/"+os.stoid+"/"+user_id+"/"+item.prom_id;
  618 + await getApp().request.promiseGet(url, {}).then(res => {
  619 + console.log(res,1000);
  620 + if(res.data.code==0 && res.data.data){
  621 + if(res.data.data.isuse!=1){
  622 + isok=0;
  623 + }
  624 + //如果活动已经结束
  625 + if(res.data.data.is_end==1){
  626 + isok=0;
  627 + }
  628 + //已经结束
  629 + if(ut.gettimestamp()>res.data.data.end_time){
  630 + isok=0;
  631 + }
  632 + //还未开始
  633 + if(ut.gettimestamp()<res.data.data.start_time){
  634 + isok=0;
  635 + }
  636 + act=res.data.data;
  637 +
  638 + }else{
  639 + //未找到商品的活动
  640 + isok = 0;
  641 + }
  642 + })
  643 + if (!isok){
  644 + item.prom_type=0;
  645 + item.prom_id=0;
  646 + }else{
  647 +
  648 + th.data.ladder_map[item.prom_id]=act;
  649 + //-- 获取阶梯规则 --
  650 + var url1 = "/api/weshop/prom/ladderList/list";
  651 + var req_data = {
  652 + store_id: os.stoid,
  653 + form_id: item.prom_id,
  654 + }
  655 + await getApp().request.promiseGet(url1, {
  656 + data: req_data
  657 + }).then(rs1 => {
  658 + if (rs1.data.code==0 && rs1.data.data) {
  659 + var gdlist = rs1.data.data;
  660 + th.data.ladder_map[item.prom_id].ladder_list=gdlist;
  661 + }
  662 + })
  663 + }
  664 +
  665 + }
  666 + //直接把活动赋值给元素
  667 + if(th.data.ladder_map[item.prom_id] && th.data.ladder_map[item.prom_id]!=-1 ){
  668 + item.act=th.data.ladder_map[item.prom_id];
  669 +
  670 + //如果有活动,就更新商品的活动那个
  671 + var url = '/api/weshop/cart/update';
  672 + getApp().request.put(url, {
  673 + data:{id:item.id,store_id:oo.stoid,prom_type:10,prom_id:item.prom_id}
  674 + });
  675 +
  676 + }
  677 + }
  678 +
535 } 679 }
536 680
537 all_num += item.goods_num; 681 all_num += item.goods_num;
@@ -622,9 +766,6 @@ Page({ @@ -622,9 +766,6 @@ Page({
622 } 766 }
623 } 767 }
624 768
625 - // console.log('AAAAAAAAAAAA', all_num);  
626 - // getApp().globalData.cartGoodsNum = all_num;  
627 -  
628 th.setData({ 769 th.setData({
629 requestData: arr, 770 requestData: arr,
630 all_num: all_num, 771 all_num: all_num,
@@ -995,11 +1136,13 @@ Page({ @@ -995,11 +1136,13 @@ Page({
995 if(item[j].is_gift) continue; 1136 if(item[j].is_gift) continue;
996 1137
997 var obj=JSON.parse(JSON.stringify(item[j])); 1138 var obj=JSON.parse(JSON.stringify(item[j]));
998 - //计算之前先移除 1139 + //计算之前先移除组合购的计算
999 if(obj.prom_type==7) 1140 if(obj.prom_type==7)
1000 zh_calc.remove_zhprom(dda,i,obj); 1141 zh_calc.remove_zhprom(dda,i,obj);
1001 -  
1002 - 1142 + //计算之前先移除阶梯购的计算
  1143 + if(obj.prom_type==10)
  1144 + ladder_calc.remove_ladder_prom(dda,i,obj);
  1145 +
1003 if (fir == 0) { 1146 if (fir == 0) {
1004 fir = item[j].distr_type; 1147 fir = item[j].distr_type;
1005 } else { 1148 } else {
@@ -1012,8 +1155,12 @@ Page({ @@ -1012,8 +1155,12 @@ Page({
1012 var txt = "requestData[" + i + "].goods[" + j + "].selected"; 1155 var txt = "requestData[" + i + "].goods[" + j + "].selected";
1013 1156
1014 if(e.data.checkAllToggle) obj.goods_num=0; 1157 if(e.data.checkAllToggle) obj.goods_num=0;
1015 - if(obj.prom_type==7)  
1016 - zh_calc.add_zhprom(dda,i,obj); 1158 +
  1159 + //加入组合购计算
  1160 + if(obj.prom_type==7) zh_calc.add_zhprom(dda,i,obj);
  1161 + //加入阶梯促销计算
  1162 + if(obj.prom_type==10) ladder_calc.add_ladder_prom(dda,i,obj);
  1163 +
1017 1164
1018 e.setData({ 1165 e.setData({
1019 [txt]: !e.data.checkAllToggle, 1166 [txt]: !e.data.checkAllToggle,
@@ -1021,7 +1168,7 @@ Page({ @@ -1021,7 +1168,7 @@ Page({
1021 1168
1022 if (!e.data.checkAllToggle) { 1169 if (!e.data.checkAllToggle) {
1023 //组合购的金额要另外算 1170 //组合购的金额要另外算
1024 - if(item[j].prom_type!=7) 1171 + if(item[j].prom_type!=7 && item[j].prom_type!=10)
1025 tfeel += item[j].goods_num * item[j].goods_price; 1172 tfeel += item[j].goods_num * item[j].goods_price;
1026 t_num += item[j].goods_num; 1173 t_num += item[j].goods_num;
1027 } 1174 }
@@ -1059,6 +1206,12 @@ Page({ @@ -1059,6 +1206,12 @@ Page({
1059 offline_price+=zh_calc_res.offline_price; 1206 offline_price+=zh_calc_res.offline_price;
1060 offline_num+=zh_calc_res.offline_num; 1207 offline_num+=zh_calc_res.offline_num;
1061 1208
  1209 + //总的价格,把阶梯促销的商品的价格拿出来
  1210 + var ladder_calc_res=ladder_calc.calculate_ladder(dda,i,this);
  1211 + tfeel+=ladder_calc_res.tfeel;
  1212 + offline_price+=ladder_calc_res.offline_price;
  1213 + offline_num+=ladder_calc_res.offline_num;
  1214 +
1062 //当有线下取价的时候 1215 //当有线下取价的时候
1063 if(offline_price){ 1216 if(offline_price){
1064 var txt1= "requestData[" + i + "].offline_price"; 1217 var txt1= "requestData[" + i + "].offline_price";
@@ -1363,8 +1516,7 @@ Page({ @@ -1363,8 +1516,7 @@ Page({
1363 if(car && car.length>0){ 1516 if(car && car.length>0){
1364 th.data.in_zhact_gdmap={}; 1517 th.data.in_zhact_gdmap={};
1365 for (var a = 0; a < car.length; a++) { 1518 for (var a = 0; a < car.length; a++) {
1366 - var item = car[a].goods,  
1367 - is_s_sele = 1; 1519 + var item = car[a].goods,is_s_sele = 1;
1368 var offline_price=0; 1520 var offline_price=0;
1369 var offline_num=0; 1521 var offline_num=0;
1370 for (var c = 0; c < item.length; c++) { 1522 for (var c = 0; c < item.length; c++) {
@@ -1373,7 +1525,10 @@ Page({ @@ -1373,7 +1525,10 @@ Page({
1373 1525
1374 //不管怎么样都要移出去 1526 //不管怎么样都要移出去
1375 var obj=JSON.parse(JSON.stringify(item[c])); 1527 var obj=JSON.parse(JSON.stringify(item[c]));
  1528 +
1376 zh_calc.remove_zhprom(car,a,obj); 1529 zh_calc.remove_zhprom(car,a,obj);
  1530 + ladder_calc.remove_ladder_prom(car,a,obj);
  1531 +
1377 if (item[c].selected == 0) { 1532 if (item[c].selected == 0) {
1378 ischeck = 0; 1533 ischeck = 0;
1379 is_s_sele = 0; 1534 is_s_sele = 0;
@@ -1381,11 +1536,20 @@ Page({ @@ -1381,11 +1536,20 @@ Page({
1381 obj.goods_num=0; 1536 obj.goods_num=0;
1382 zh_calc.add_zhprom(car,a,obj); 1537 zh_calc.add_zhprom(car,a,obj);
1383 } 1538 }
  1539 + if(item[c].prom_type==10) {
  1540 + obj.goods_num=0;
  1541 + ladder_calc.add_ladder_prom(car,a,obj);
  1542 + }
  1543 +
  1544 +
1384 } else { 1545 } else {
1385 if(item[c].prom_type==7){ 1546 if(item[c].prom_type==7){
1386 - //先把商品放入组合计算的专用的区域  
1387 - zh_calc.add_zhprom(car,a,obj);  
1388 - }else{ 1547 + //先把商品放入组合计算的专用的区域
  1548 + zh_calc.add_zhprom(car,a,obj);
  1549 + }else if(item[c].prom_type==10){
  1550 + ladder_calc.add_ladder_prom(car,a,obj);
  1551 + }
  1552 + else{
1389 tfeel += item[c].goods_num * item[c].goods_price; 1553 tfeel += item[c].goods_num * item[c].goods_price;
1390 } 1554 }
1391 t_num += item[c].goods_num; 1555 t_num += item[c].goods_num;
@@ -1400,10 +1564,17 @@ Page({ @@ -1400,10 +1564,17 @@ Page({
1400 1564
1401 //总的价格,把组合商品的价格拿出来 1565 //总的价格,把组合商品的价格拿出来
1402 var zh_calc_res=zh_calc.calculate_zh(car,a,th); 1566 var zh_calc_res=zh_calc.calculate_zh(car,a,th);
  1567 + //总的价格,把阶梯促销商品的价格拿出来
  1568 + var ladder_calc_res=ladder_calc.calculate_ladder(car,a,th);
  1569 +
1403 tfeel+=zh_calc_res.tfeel; 1570 tfeel+=zh_calc_res.tfeel;
1404 offline_price+=zh_calc_res.offline_price; 1571 offline_price+=zh_calc_res.offline_price;
1405 offline_num+=zh_calc_res.offline_num; 1572 offline_num+=zh_calc_res.offline_num;
1406 1573
  1574 + tfeel+=ladder_calc_res.tfeel;
  1575 + offline_price+=ladder_calc_res.offline_price;
  1576 + offline_num+=ladder_calc_res.offline_num;
  1577 +
1407 var txt = "requestData[" + a + "].selected"; 1578 var txt = "requestData[" + a + "].selected";
1408 th.setData({ 1579 th.setData({
1409 [txt]: Number(is_s_sele) 1580 [txt]: Number(is_s_sele)
@@ -1456,9 +1627,6 @@ Page({ @@ -1456,9 +1627,6 @@ Page({
1456 }); 1627 });
1457 } 1628 }
1458 } 1629 }
1459 -  
1460 - // getApp().globalData.cartGoodsNum = all_num;  
1461 - // console.log('CCCCCCC', all_num, getApp().globalData.cartGoodsNum);  
1462 1630
1463 this.setData({ 1631 this.setData({
1464 checkAllToggle: ischeck, 1632 checkAllToggle: ischeck,
@@ -1494,6 +1662,8 @@ Page({ @@ -1494,6 +1662,8 @@ Page({
1494 1662
1495 // console.log('update'); 1663 // console.log('update');
1496 // console.log('9995959595959',t); 1664 // console.log('9995959595959',t);
  1665 + var e = this,th=e;
  1666 + var user_id = getApp().globalData.user_id;
1497 rq.get("/api/weshop/goods/get/" + oo.stoid + "/" + t.goods_id, { 1667 rq.get("/api/weshop/goods/get/" + oo.stoid + "/" + t.goods_id, {
1498 isShowLoading: 0, 1668 isShowLoading: 0,
1499 async success(d) { 1669 async success(d) {
@@ -1523,8 +1693,10 @@ Page({ @@ -1523,8 +1693,10 @@ Page({
1523 } 1693 }
1524 goodsbuynum = buy_num_data.goodsbuynum; 1694 goodsbuynum = buy_num_data.goodsbuynum;
1525 1695
  1696 +
1526 }) 1697 })
1527 1698
  1699 +
1528 var buyed_mum2 = t.goods_num + goodsbuynum; 1700 var buyed_mum2 = t.goods_num + goodsbuynum;
1529 if (buyed_mum2 > limit && limit > 0) { 1701 if (buyed_mum2 > limit && limit > 0) {
1530 wx.showModal({ 1702 wx.showModal({
@@ -1778,7 +1950,7 @@ Page({ @@ -1778,7 +1950,7 @@ Page({
1778 await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{ 1950 await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
1779 data:{storageNos:pick_no,wareIds:encodeURIComponent(erpwareid),storeId:os.stoid} 1951 data:{storageNos:pick_no,wareIds:encodeURIComponent(erpwareid),storeId:os.stoid}
1780 }).then(res=>{ 1952 }).then(res=>{
1781 - if(res.data.code==0){ 1953 + if(ut.ajax_ok(res)){
1782 plist=res.data.data.pageData[0]; 1954 plist=res.data.data.pageData[0];
1783 } 1955 }
1784 }) 1956 })
@@ -2075,7 +2247,7 @@ Page({ @@ -2075,7 +2247,7 @@ Page({
2075 2247
2076 //如果会员是等级会员,商品有等级价,且不是活动商品 2248 //如果会员是等级会员,商品有等级价,且不是活动商品
2077 if (card_field && val[card_field] > 0 && 2249 if (card_field && val[card_field] > 0 &&
2078 - ((val.prom_type == 0 && g_arr[i].prom_type==0) || val.prom_type == 3 || val.prom_type == 4 || val.prom_type == 5 || val.prom_type == 7 || normal_arr[val.goods_id])) { 2250 + ((val.prom_type == 0 && g_arr[i].prom_type==0) || val.prom_type == 3 || val.prom_type == 4 || val.prom_type == 5 || val.prom_type == 7 || val.prom_type == 10 || normal_arr[val.goods_id])) {
2079 if (g_arr[i].goods_price != val[card_field]) { 2251 if (g_arr[i].goods_price != val[card_field]) {
2080 isok = 0; 2252 isok = 0;
2081 gname = val.goods_name; 2253 gname = val.goods_name;
@@ -2514,17 +2686,30 @@ Page({ @@ -2514,17 +2686,30 @@ Page({
2514 2686
2515 //跳转到商品 2687 //跳转到商品
2516 go_gd:function (e) { 2688 go_gd:function (e) {
  2689 + var user_id=getApp().globalData.user_id;
  2690 + if(!user_id) user_id=0;
2517 var gd= e.currentTarget.dataset.gd; 2691 var gd= e.currentTarget.dataset.gd;
2518 var good_url="/pages/goods/goodsInfo/goodsInfo?goods_id=" + gd; 2692 var good_url="/pages/goods/goodsInfo/goodsInfo?goods_id=" + gd;
2519 var url="/api/weshop/activitylist/getGoodActInfo"; 2693 var url="/api/weshop/activitylist/getGoodActInfo";
2520 var req_data={ 2694 var req_data={
2521 - store_id:os.stoid,goodsidlist:gd,is_detail:1 2695 + store_id:os.stoid,goodsidlist:gd,is_detail:1,user_id:user_id
2522 }; 2696 };
2523 //获取秒杀的多规格 2697 //获取秒杀的多规格
2524 getApp().request.promiseGet(url, {data:req_data}).then(res=>{ 2698 getApp().request.promiseGet(url, {data:req_data}).then(res=>{
2525 if(res.data.code==0 && res.data.data){ 2699 if(res.data.code==0 && res.data.data){
2526 if(res.data.data.length==1){ 2700 if(res.data.data.length==1){
2527 - good_url+="&prom_type="+res.data.data[0].prom_type+"&prom_id="+res.data.data[0].act_id; 2701 + var item=res.data.data[0];
  2702 + switch (item.prom_type){
  2703 + case 9:
  2704 + good_url= '/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=' + gd + '&group_id=' + item.prom_id;
  2705 + break;
  2706 + case 8:
  2707 + good_url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+gd+"&prom_id="+item.prom_id
  2708 + break;
  2709 + default:
  2710 + good_url="/pages/goods/goodsInfo/goodsInfo?goods_id="+gd+"&prom_id="+item.prom_id+"&prom_type=1";
  2711 + break
  2712 + }
2528 } 2713 }
2529 getApp().goto(good_url); 2714 getApp().goto(good_url);
2530 2715
pages/cart/cart/cart.wxml
@@ -164,6 +164,15 @@ @@ -164,6 +164,15 @@
164 </view> 164 </view>
165 </block> 165 </block>
166 166
  167 + <!-- 阶梯促销提示多少件的优惠 -->
  168 + <block wx:if="{{item.l_need_list && item.l_need_list.length>0 && !is_edit}}">
  169 +
  170 + <view class="fs28 pdr20 pdl20 pdb20 c-red2 flex jc_sb" wx:for="{{item.l_need_list}}">
  171 + <text>{{item.title}}</text>
  172 + <text data-url="/pages/goods/goodsList/goodsList?ladder_id={{item.id}}" bindtap="go_url">去凑单</text>
  173 + </view>
  174 + </block>
  175 +
167 176
168 <!-- 线下取价 --> 177 <!-- 线下取价 -->
169 <view style="margin:10rpx 0; padding: 0 30rpx;color: #999" wx:if="{{item.offline_price}}" class="fs28"> 178 <view style="margin:10rpx 0; padding: 0 30rpx;color: #999" wx:if="{{item.offline_price}}" class="fs28">
pages/cart/cart/ladder_calculate.js 0 → 100644
  1 +module.exports = {
  2 + //辅助数组添加元素功能
  3 + find_in_add: function(list, ele) {
  4 + var idx=list.findIndex(function (e) {
  5 + return e.goods_id==ele.goods_id;
  6 + })
  7 + if(idx>-1) return false;
  8 + list.push(ele);
  9 + },
  10 + //辅助数组添加元素功能
  11 + find_in_remove: function(list, ele) {
  12 + var idx=list.findIndex(function (e) {
  13 + return e.goods_id==ele.goods_id;
  14 + })
  15 + if(idx==-1) return false;
  16 + list.splice(idx, 1);
  17 + },
  18 +
  19 + //主要是把组合购的商品分离出来
  20 + add_ladder_prom: function(car, a, ele) {
  21 + var point = car[a];
  22 + if (point.ladder_map) {
  23 + if (point.ladder_map[ele.prom_id]) {
  24 + this.find_in_add(point.ladder_map[ele.prom_id].goods, ele);
  25 + } else {
  26 + point.ladder_map[ele.prom_id] = {
  27 + goods: [],
  28 + act: ele.act
  29 + };
  30 + point.ladder_map[ele.prom_id].goods.push(ele);
  31 + }
  32 + } else {
  33 + point.ladder_map = {};
  34 + point.ladder_map[ele.prom_id] = {
  35 + goods: [],
  36 + act: ele.act
  37 + };
  38 + point.ladder_map[ele.prom_id].goods.push(ele);
  39 + }
  40 + },
  41 + //未选中的商品,要从中剔除
  42 + remove_ladder_prom: function(car, a, ele) {
  43 + var point = car[a];
  44 + if (point.ladder_map) {
  45 + if (point.ladder_map[ele.prom_id]) {
  46 + this.find_in_remove(point.ladder_map[ele.prom_id].goods, ele);
  47 + }
  48 + }
  49 + },
  50 +
  51 + //把组合购的商品价格计算出来,同时每个会员都有购买组合商品的上限!ladder_b_num是已经购买了多少件
  52 + calculate_ladder: function(car, a, th) {
  53 + var car_item = car[a];
  54 + var tfeel = 0,offline_price = 0,offline_num = 0;
  55 + var txt = "requestData[" + a + "].l_need_list";
  56 + var need_to=[];
  57 +
  58 + //活动的列表都存储在这里面,可以快速查询
  59 + if (!car_item.ladder_map) {
  60 + var res = {
  61 + tfeel: tfeel,
  62 + offline_price: offline_price,
  63 + offline_num: offline_num
  64 + };
  65 + th.setData({
  66 + [txt]: null
  67 + });
  68 + return res;
  69 + }
  70 +
  71 + //因为可能有多个组合购的活动
  72 + for (var mi in car_item.ladder_map) {
  73 + var bitem = car_item.ladder_map[mi];
  74 + var act = bitem.act; //获取到组合购的详情
  75 + var all_num = 0; //商品数量之和
  76 + var all_price = 0;
  77 + var aprice=0;
  78 + var no_in_arr = []; //剩余的未加入组合购
  79 +
  80 + var title =""; //提示语;
  81 + var goods = car_item.goods;
  82 +
  83 + //-- 每件商品要剔除的量 --
  84 + for (let v3 in car_item.goods) {
  85 + car_item.goods[v3].l_need_downlow_num=0;
  86 + }
  87 +
  88 + //寻找一下
  89 + function get_num2(ite) {
  90 + var vh=car_item.goods.findIndex(function (e) {
  91 + return e.goods_id == ite.goods_id
  92 + })
  93 + if(vh>-1) return car_item.goods[vh];
  94 + return 0;
  95 + }
  96 +
  97 + for (var i in goods) {
  98 + if(goods[i].prom_type!=10) continue;
  99 + if(!goods[i].selected) continue;
  100 + if(goods[i].prom_id!=act.id) continue;
  101 + var item = goods[i];
  102 + item.goods_price=item.goods_price;
  103 + item.offline_price=item.offline_price;
  104 + item.cart_num =item.goods_num;
  105 + all_num += item.cart_num;
  106 + for (var j = 0; j < item.cart_num; j++) {
  107 + no_in_arr.push({
  108 + price: item.goods_price,offline_price:item.offline_price,goods_id:item.goods_id,shop_price:item.shop_price
  109 + })
  110 + }
  111 + }
  112 +
  113 + function sortData(a, b) {
  114 + return a.price - b.price
  115 + }
  116 + no_in_arr.sort(sortData);
  117 +
  118 + //开始阶梯计算价格
  119 + var lev=0;
  120 + for(let j in act.ladder_list){
  121 + if(no_in_arr.length==0) break;
  122 + let item_j=act.ladder_list[j];
  123 + var end=no_in_arr.pop();
  124 + var new_price=parseInt(item_j.discount_field)==1?end.shop_price:end.price;
  125 + aprice+=new_price* parseFloat(item_j.discount)/10;
  126 + lev++;
  127 + }
  128 +
  129 + //获取阶梯促销的下一个促销
  130 + if(lev>0 && lev<act.ladder_list.length){
  131 + title = "再买1件,第"+(lev+1)+"件"+act.ladder_list[lev].discount+"折";
  132 + var it = {
  133 + id: act.id,
  134 + pickup_id: car_item.pid,
  135 + title: title
  136 + };
  137 + need_to.push(it);
  138 + }
  139 +
  140 + all_price+=aprice;
  141 + //算一下剩余的钱
  142 + if (no_in_arr.length) {
  143 + for (var ii in no_in_arr) {
  144 + var item = no_in_arr[ii];
  145 + var gitem=get_num2(item);
  146 + if(gitem) {
  147 + if (!gitem.l_need_downlow_num) {
  148 + gitem.l_need_downlow_num = 1;
  149 + }
  150 + else {
  151 + gitem.l_need_downlow_num++;
  152 + }
  153 + all_price += item.price;
  154 + if (item.offline_price) {
  155 + offline_price += gitem.goods_price - gitem.offline_price;
  156 + offline_num += 1;
  157 + }
  158 + }
  159 + }
  160 + }
  161 + tfeel += all_price;
  162 + }
  163 + var res = {
  164 + tfeel: tfeel,
  165 + aprice:aprice,
  166 + offline_price: offline_price,
  167 + offline_num: offline_num,
  168 + };
  169 +
  170 + th.setData({ [txt]: need_to});
  171 + return res;
  172 + },
  173 +
  174 + find_need_to: function(list, iter) {
  175 + if (!list || list.length <= 0) return -1;
  176 + for (var i in list) {
  177 + var item = list[i];
  178 + if (item.id == iter.id) {
  179 + return i;
  180 + }
  181 + }
  182 + return -1;
  183 + },
  184 +
  185 + //筛选阶梯促销,纯粹的数组按活动id分组
  186 + find_split: function(arr) {
  187 + //过滤只有团购的商品
  188 + var oarr = arr.goods.filter(function(ele) {
  189 + return ele.prom_type == 10
  190 + })
  191 + if(!oarr || oarr.length==0) return null;
  192 + //看一下有多少个不同的团购
  193 + var map = {},dest = [];
  194 + for (var i = 0; i < oarr.length; i++) {
  195 + var ai = oarr[i];
  196 + var index=map[ai.prom_id]
  197 + if (!index) {
  198 + dest.push({
  199 + prom_id: ai.prom_id,
  200 + data: [ai]
  201 + });
  202 + map[ai.prom_id]=dest.length; //存储下标
  203 + } else {
  204 + var dj = dest[index-1];
  205 + dj.data.push(ai);
  206 + }
  207 + }
  208 + return dest;
  209 + }
  210 +
  211 +
  212 +}
pages/cart/cart2/cart2.js
@@ -4,6 +4,7 @@ var oo = t.globalData.setting, os = oo; @@ -4,6 +4,7 @@ var oo = t.globalData.setting, os = oo;
4 var regeneratorRuntime = require('../../../utils/runtime.js'); 4 var regeneratorRuntime = require('../../../utils/runtime.js');
5 var util_pay = require("../../../utils/pay.js"); 5 var util_pay = require("../../../utils/pay.js");
6 var zh_calc = require("zh_calculate.js"); 6 var zh_calc = require("zh_calculate.js");
  7 +var ladder_calc = require("ladder_calculate.js");
7 8
8 Page({ 9 Page({
9 data: { 10 data: {
@@ -33,6 +34,7 @@ Page({ @@ -33,6 +34,7 @@ Page({
33 couponCode: "",//使用优惠券(多单就用逗号隔开) 34 couponCode: "",//使用优惠券(多单就用逗号隔开)
34 shipping_price: 0,//物流费用 35 shipping_price: 0,//物流费用
35 }, 36 },
  37 +
36 /*-----------当是购物车结算的时候-------------*/ 38 /*-----------当是购物车结算的时候-------------*/
37 cartlist: null, 39 cartlist: null,
38 old_cartlist: null, 40 old_cartlist: null,
@@ -124,7 +126,11 @@ Page({ @@ -124,7 +126,11 @@ Page({
124 in_zhact_gdmap:{}, //不同门店参与同一活动的限购 126 in_zhact_gdmap:{}, //不同门店参与同一活动的限购
125 hid_inp:1, 127 hid_inp:1,
126 user_note:{}, 128 user_note:{},
127 - zuhe_map_good:{}, 129 + zhhe_act_map:{}, //组合活动的map表
  130 + zuhe_map_good:{}, //组合购的map表
  131 + ladder_map:{}, //阶梯促销的map表
  132 +
  133 + state:0, //阶梯促销的的立即购买也走购物车流程state=1
128 }, 134 },
129 onLoad: function (t) { 135 onLoad: function (t) {
130 wx.setNavigationBarTitle({title: "填写订单",}) 136 wx.setNavigationBarTitle({title: "填写订单",})
@@ -140,6 +146,11 @@ Page({ @@ -140,6 +146,11 @@ Page({
140 } 146 }
141 }); 147 });
142 148
  149 + //阶梯购的立即购买
  150 + if(t.state){
  151 + th.data.state=1;
  152 + }
  153 +
143 154
144 }, 155 },
145 onUnload: function () { 156 onUnload: function () {
@@ -407,9 +418,11 @@ Page({ @@ -407,9 +418,11 @@ Page({
407 //-----真的获取购物车,入口-------- 418 //-----真的获取购物车,入口--------
408 get_cart: function () { 419 get_cart: function () {
409 var th = this, app = getApp(); 420 var th = this, app = getApp();
  421 + var state=0;
  422 + if(th.data.state) state=1;
410 a.get("/api/weshop/cart/list", { 423 a.get("/api/weshop/cart/list", {
411 data: { 424 data: {
412 - user_id: to.globalData.user_id, selected: 1, state: 0, 425 + user_id: to.globalData.user_id, selected: 1, state: state,
413 store_id: oo.stoid, pageSize: 600 426 store_id: oo.stoid, pageSize: 600
414 }, 427 },
415 success: async function (su) { 428 success: async function (su) {
@@ -452,54 +465,118 @@ Page({ @@ -452,54 +465,118 @@ Page({
452 } 465 }
453 466
454 //要把组合购的东西拿出来算一下 467 //要把组合购的东西拿出来算一下
455 - if (item1.prom_type == 7) {  
456 - var isok = 1;  
457 - var is_flag=1;  
458 - //如果有组合购  
459 - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item1.prom_id+'/'+getApp().globalData.userInfo.user_id;  
460 - await getApp().request.promiseGet(url, {}).then(res => {  
461 - if (res.data.code == 0 && res.data.data) {  
462 - //如果活动已经结束  
463 - if (res.data.data.is_end == 1) {  
464 - isok = 0;  
465 - }  
466 - if (ut.gettimestamp() > res.data.data.end_time) {  
467 - isok = 0; 468 + if(item1.prom_type == 7) {
  469 + if(!th.data.zuhe_map_good[item1.prom_id]) {
  470 + var isok = 1;
  471 + var is_flag = 1;
  472 + //如果有组合购
  473 + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + item1.prom_id + '/' + getApp().globalData.userInfo.user_id;
  474 + await getApp().request.promiseGet(url, {}).then(res => {
  475 + if (res.data.code == 0 && res.data.data) {
  476 + //如果活动已经结束
  477 + if (res.data.data.is_end == 1) {
  478 + isok = 0;
  479 + }
  480 + if (ut.gettimestamp() > res.data.data.end_time) {
  481 + isok = 0;
  482 + }
  483 + item1.act = res.data.data;
  484 + th.data.zhhe_act_map[item1.prom_id] = res.data.data;
  485 + } else {
  486 + //未找到商品的活动
  487 + is_flag = 0;
468 } 488 }
469 - item1.act = res.data.data;  
470 - } else {  
471 - //未找到商品的活动  
472 - is_flag = 0; 489 + })
  490 + if (!isok) {
  491 + getApp().my_warnning("组合购的活动已经过期", 0, th);
  492 + return false;
473 } 493 }
474 - })  
475 - if (!isok) {  
476 - getApp().my_warnning("组合购的活动已经过期", 0, th);  
477 - return false; 494 + var url1 = "/api/weshop/prom/zhbuyGoods/page";
  495 + var req_data = {
  496 + page: 1,
  497 + pageSize: 2000,
  498 + store_id: os.stoid,
  499 + zh_id: item1.prom_id,
  500 + }
  501 + await getApp().request.promiseGet(url1, {
  502 + data: req_data
  503 + }).then(res => {
  504 + if (ut.ajax_ok(res)) {
  505 + var gdlist = res.data.data.pageData;
  506 + gdlist.forEach(i => {
  507 + if (item1.goods_id == i.goods_id && !is_flag) {
  508 + item1.prom_type = 0;
  509 + item1.prom_type1 = 0;
  510 + item1.prom_id = 0;
  511 + item1.prom_id1 = 0
  512 + }
  513 + })
  514 + th.data.zuhe_map_good[item1.prom_id] = gdlist;
  515 + }
  516 + })
478 } 517 }
479 - var url1 = "/api/weshop/prom/zhbuyGoods/page";  
480 - var req_data = {  
481 - page: 1,  
482 - pageSize: 2000,  
483 - store_id: os.stoid,  
484 - zh_id: item1.prom_id, 518 + else
  519 + {
  520 + item1.act = th.data.zhhe_act_map[item1.prom_id];
485 } 521 }
486 - await getApp().request.promiseGet(url1, {  
487 - data: req_data  
488 - }).then(res => {  
489 - if (ut.ajax_ok(res)) {  
490 - var gdlist = res.data.data.pageData;  
491 - gdlist.forEach(i=>{  
492 - if(item1.goods_id==i.goods_id&&!is_flag){  
493 - item1.prom_type=0;  
494 - item1.prom_type1=0;  
495 - item1.prom_id=0;  
496 - item1.prom_id1=0 522 + }
  523 + if(item1.prom_type==10){
  524 + if(!th.data.ladder_map[item1.prom_id]){
  525 + //如果有组合购
  526 + var isok = 1;
  527 + var is_flag=1;
  528 + var act=null;
  529 + var url="/api/weshop/prom/ladderForm/get/"+os.stoid+"/"+item1.prom_id;
  530 + await getApp().request.promiseGet(url, {}).then(res => {
  531 + console.log(res,1000);
  532 + if(res.data.code==0 && res.data.data){
  533 + if(res.data.data.isuse!=1){
  534 + isok=0;
497 } 535 }
498 - })  
499 - th.data.zuhe_map_good[item1.prom_id]=gdlist; 536 + //如果活动已经结束
  537 + if(res.data.data.is_end==1){
  538 + isok=0;
  539 + }
  540 + //已经结束
  541 + if(ut.gettimestamp()>res.data.data.end_time){
  542 + isok=0;
  543 + }
  544 + //还未开始
  545 + if(ut.gettimestamp()<res.data.data.start_time){
  546 + isok=0;
  547 + }
  548 + act=res.data.data;
  549 +
  550 + }else{
  551 + //未找到商品的活动
  552 + is_flag = 0;
  553 + }
  554 + })
  555 + if (!isok){
  556 + var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
  557 + getApp().request.delete(url, {});
  558 + th.data.ladder_map[item1.prom_id]=-1;
  559 + continue;
500 } 560 }
501 - }) 561 + th.data.ladder_map[item1.prom_id]=act;
  562 +
  563 + //-- 获取阶梯规则 --
  564 + var url1 = "/api/weshop/prom/ladderList/list";
  565 + var req_data = {
  566 + store_id: os.stoid,
  567 + form_id: item1.prom_id,
  568 + }
  569 + await getApp().request.promiseGet(url1, {
  570 + data: req_data
  571 + }).then(rs1 => {
  572 + if (rs1.data.code==0 && rs1.data.data) {
  573 + var gdlist = rs1.data.data;
  574 + th.data.ladder_map[item1.prom_id].ladder_list=gdlist;
  575 + }
  576 + })
  577 + }
502 } 578 }
  579 +
503 } 580 }
504 581
505 //在分组的时候,就不要再调用接口,await 582 //在分组的时候,就不要再调用接口,await
@@ -560,6 +637,7 @@ Page({ @@ -560,6 +637,7 @@ Page({
560 } 637 }
561 arr[j].exp_type = e_t; 638 arr[j].exp_type = e_t;
562 if (e_t == 0) th.setData({is_all_zt: 0}); 639 if (e_t == 0) th.setData({is_all_zt: 0});
  640 + else if(e_t==1) th.setData({is_all_zt: 1});
563 //} 641 //}
564 642
565 //-- 把等级卡会优惠多少钱装进去 -- 643 //-- 把等级卡会优惠多少钱装进去 --
@@ -688,31 +766,31 @@ Page({ @@ -688,31 +766,31 @@ Page({
688 //存储不同活动的商品列表 766 //存储不同活动的商品列表
689 u_item.zh_prom_goods = {}; 767 u_item.zh_prom_goods = {};
690 for (let var1 in obj) { 768 for (let var1 in obj) {
691 - var h_item=obj[var1];  
692 - var gdlist= th.data.zuhe_map_good[h_item.prom_id];  
693 - //获取活动需要的商品列表  
694 - // u_item.zh_prom_goods[h_item.prom_id]=gdlist;  
695 - // var h_item = obj[var1];  
696 - // var gdlist = null;  
697 - // var url1 = "/api/weshop/prom/zhbuyGoods/page";  
698 - // var req_data = {  
699 - // page: 1,  
700 - // pageSize: 2000,  
701 - // store_id: os.stoid,  
702 - // zh_id: h_item.prom_id,  
703 - // }  
704 - // await getApp().request.promiseGet(url1, {  
705 - // data: req_data  
706 - // }).then(res => {  
707 - // if (ut.ajax_ok(res)) {  
708 - // gdlist = res.data.data.pageData;  
709 - // }  
710 - // }) 769 + var h_item = obj[var1];
  770 + var gdlist = th.data.zuhe_map_good[h_item.prom_id];
711 //获取活动需要的商品列表 771 //获取活动需要的商品列表
712 u_item.zh_prom_goods[h_item.prom_id] = {gdlist: gdlist, act: h_item.act}; 772 u_item.zh_prom_goods[h_item.prom_id] = {gdlist: gdlist, act: h_item.act};
713 } 773 }
714 zh_calc.fir_set_arr(u_item, th); 774 zh_calc.fir_set_arr(u_item, th);
715 } 775 }
  776 +
  777 + //每一个门店内的阶梯促销要进行拆分,
  778 + //还得把阶梯促销商品的多余商品的线下价格算一算
  779 + for (let var1 in arr) {
  780 + //把阶梯促销进行分组
  781 + var obj = ladder_calc.find_split(u_item);
  782 + if (!obj) continue;
  783 + //存储不同阶梯促销活动的商品列表
  784 + u_item.ladder_map = {};
  785 + for (let var1 in obj) {
  786 + var h_item=obj[var1];
  787 + var act= th.data.ladder_map[h_item.prom_id];
  788 + //获取活动需要的商品列表
  789 + u_item.ladder_map[h_item.prom_id] =act;
  790 + }
  791 + ladder_calc.fir_set_arr(u_item, th);
  792 + }
  793 +
716 //深拷贝 794 //深拷贝
717 th.data.old_cartlist = JSON.parse(JSON.stringify(arr)); 795 th.data.old_cartlist = JSON.parse(JSON.stringify(arr));
718 th.setData({ 796 th.setData({
@@ -806,8 +884,8 @@ Page({ @@ -806,8 +884,8 @@ Page({
806 } 884 }
807 885
808 886
809 - gd.prom_type=gg.prom_type;  
810 - gd.prom_id=gg.prom_id; 887 + gd.prom_type=gg.prom_type?gg.prom_type:0;
  888 + gd.prom_id=gg.prom_id?gg.prom_id:0;
811 889
812 switch (gd.prom_type) { 890 switch (gd.prom_type) {
813 case 0: 891 case 0:
@@ -1270,6 +1348,7 @@ Page({ @@ -1270,6 +1348,7 @@ Page({
1270 var all_coupon_price_m = 0; //所有的订单用户使用优惠券价格 1348 var all_coupon_price_m = 0; //所有的订单用户使用优惠券价格
1271 var all_cutprice = 0; //所有的优惠减 1349 var all_cutprice = 0; //所有的优惠减
1272 var all_zh_cutprice = 0; //所有的组合优惠减 1350 var all_zh_cutprice = 0; //所有的组合优惠减
  1351 + var all_ladder_cutprice = 0; //所有的阶梯促销优惠减
1273 var all_order_prom = 0; //所有的订单优惠 1352 var all_order_prom = 0; //所有的订单优惠
1274 1353
1275 var umoney = th.data.userinfo.user_money - th.data.txmon - (th.data.userinfo.frozen_money ? th.data.userinfo.frozen_money : 0); 1354 var umoney = th.data.userinfo.user_money - th.data.txmon - (th.data.userinfo.frozen_money ? th.data.userinfo.frozen_money : 0);
@@ -1302,6 +1381,8 @@ Page({ @@ -1302,6 +1381,8 @@ Page({
1302 await th.calc_per(c_arr); 1381 await th.calc_per(c_arr);
1303 //调用函数计算每件组合购商品的单价, 1382 //调用函数计算每件组合购商品的单价,
1304 await zh_calc.calc_zh_split_price(c_arr,th); 1383 await zh_calc.calc_zh_split_price(c_arr,th);
  1384 + //调用函数计算每件阶梯促销商品的单价,
  1385 + await ladder_calc.calc_split_price(c_arr,th);
1305 //调用函数计算,优惠券优惠什么商品价格,优惠券优惠什么商品 1386 //调用函数计算,优惠券优惠什么商品价格,优惠券优惠什么商品
1306 await th.get_cart_quan(c_arr); 1387 await th.get_cart_quan(c_arr);
1307 //---循环购物车--- 1388 //---循环购物车---
@@ -1333,7 +1414,10 @@ Page({ @@ -1333,7 +1414,10 @@ Page({
1333 var coupon_price = 0; 1414 var coupon_price = 0;
1334 var quan_no = null; 1415 var quan_no = null;
1335 var is_has_zh=c_arr[i].is_has_zh; 1416 var is_has_zh=c_arr[i].is_has_zh;
1336 - var zh_prom_goods=c_arr[i].zh_prom_goods; //组合购计算的原始数据存储空间 1417 + var is_has_ladder=c_arr[i].is_has_ladder;
  1418 +
  1419 + var zh_prom_goods=c_arr[i].zh_prom_goods; //组合购计算的原始数据存储空间
  1420 + var ladder_prom_goods=c_arr[i].ladder_prom_goods; //组合购计算的原始数据存储空间
1337 1421
1338 if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined) 1422 if (th.data.using_quan[pickid] != null && th.data.using_quan[pickid] != undefined)
1339 quan_no = th.data.using_quan[pickid].coupon_no; 1423 quan_no = th.data.using_quan[pickid].coupon_no;
@@ -1361,12 +1445,24 @@ Page({ @@ -1361,12 +1445,24 @@ Page({
1361 1445
1362 //--------循环计算总价----------- 1446 //--------循环计算总价-----------
1363 for (var j = 0; j < item.length; j++) { 1447 for (var j = 0; j < item.length; j++) {
1364 - if(item[j].prom_type!=7){  
1365 - o_price_no_zh += item[j].goods_price * item[j].goods_num; 1448 +
  1449 + var is_no_zh=0;
  1450 + if(item[j].prom_type!=7 && item[j].prom_type!=10 ) is_no_zh=1;
  1451 +
  1452 + //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加
  1453 + if(item[j].prom_type==7 && th.data.zhhe_act_map && th.data.zhhe_act_map[item[j].prom_id]
  1454 + && th.data.zhhe_act_map[item[j].prom_id].is_orderyh )
  1455 + {
  1456 + is_no_zh=1;
1366 } 1457 }
1367 //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加 1458 //组合购的商品,且有订单优惠的叠加,is_orderyh就是优惠叠加
1368 - else if(zh_prom_goods && zh_prom_goods[item[j].prom_id] && zh_prom_goods[item[j].prom_id].act.is_orderyh ) 1459 + if(item[j].prom_type==10 && ladder_prom_goods && ladder_prom_goods[item[j].prom_id]
  1460 + && th.data.ladder_map[item[j].prom_id].is_useorderyh )
1369 { 1461 {
  1462 + is_no_zh=1;
  1463 + }
  1464 +
  1465 + if(is_no_zh){
1370 o_price_no_zh += item[j].goods_price * item[j].goods_num; 1466 o_price_no_zh += item[j].goods_price * item[j].goods_num;
1371 } 1467 }
1372 o_price += item[j].goods_price * item[j].goods_num; 1468 o_price += item[j].goods_price * item[j].goods_num;
@@ -1385,13 +1481,25 @@ Page({ @@ -1385,13 +1481,25 @@ Page({
1385 //找到那些可以订单优惠叠加的 1481 //找到那些可以订单优惠叠加的
1386 for(let ij in zh_prom_goods){ 1482 for(let ij in zh_prom_goods){
1387 let kitem=zh_prom_goods[ij]; 1483 let kitem=zh_prom_goods[ij];
1388 - var is_has_zh=kitem.is_has_zh;  
1389 if(kitem.act.is_orderyh) 1484 if(kitem.act.is_orderyh)
1390 o_price_no_zh-=kitem.cut_price; 1485 o_price_no_zh-=kitem.cut_price;
1391 } 1486 }
1392 } 1487 }
1393 } 1488 }
1394 1489
  1490 + //如果有组合购优惠的钱,就要减价
  1491 + if (c_arr[i].ladder_cut_price>0 || c_arr[i].ladder_cut_price<0){
  1492 + o_price -= c_arr[i].ladder_cut_price;
  1493 + if(o_price_no_zh>0){
  1494 + //找到那些可以订单优惠叠加的
  1495 + for(let ij in ladder_prom_goods){
  1496 + let kitem=ladder_prom_goods[ij];
  1497 + if(th.data.ladder_map[ij].is_useorderyh )
  1498 + o_price_no_zh-=kitem.cut_price;
  1499 + }
  1500 + }
  1501 + }
  1502 +
1395 //-- 计算线下取价的功能 -- 1503 //-- 计算线下取价的功能 --
1396 if (cart_item.is_offline == 1) { 1504 if (cart_item.is_offline == 1) {
1397 o_price = o_price - cart_item.offline_price; 1505 o_price = o_price - cart_item.offline_price;
@@ -1581,6 +1689,13 @@ Page({ @@ -1581,6 +1689,13 @@ Page({
1581 o_condition=o_price_no_zh-quan_price; 1689 o_condition=o_price_no_zh-quan_price;
1582 } 1690 }
1583 1691
  1692 + //看一下是不是不用组合购的订单优惠的叠加
  1693 + if(is_has_ladder){
  1694 + o_condition=o_price_no_zh-quan_price;
  1695 + }
  1696 +
  1697 +
  1698 +
1584 var order_m = 0; 1699 var order_m = 0;
1585 //---判断是不是有订单优惠--- 1700 //---判断是不是有订单优惠---
1586 await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { 1701 await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", {
@@ -1664,6 +1779,7 @@ Page({ @@ -1664,6 +1779,7 @@ Page({
1664 all_coupon_price_m += parseFloat(cart_item.coupon_price); 1779 all_coupon_price_m += parseFloat(cart_item.coupon_price);
1665 all_cutprice += parseFloat(cart_item.cut_price); 1780 all_cutprice += parseFloat(cart_item.cut_price);
1666 all_zh_cutprice += parseFloat(cart_item.zh_cut_price); 1781 all_zh_cutprice += parseFloat(cart_item.zh_cut_price);
  1782 + all_ladder_cutprice += parseFloat(cart_item.ladder_cut_price);
1667 all_order_prom += parseFloat(cart_item.order_prom_amount); 1783 all_order_prom += parseFloat(cart_item.order_prom_amount);
1668 } 1784 }
1669 1785
@@ -1677,6 +1793,7 @@ Page({ @@ -1677,6 +1793,7 @@ Page({
1677 all_cutprice = all_cutprice.toFixed(2); 1793 all_cutprice = all_cutprice.toFixed(2);
1678 all_order_prom = all_order_prom.toFixed(2); 1794 all_order_prom = all_order_prom.toFixed(2);
1679 all_zh_cutprice = parseFloat(all_zh_cutprice).toFixed(2); 1795 all_zh_cutprice = parseFloat(all_zh_cutprice).toFixed(2);
  1796 + all_ladder_cutprice = parseFloat(all_ladder_cutprice).toFixed(2);
1680 1797
1681 var atxt = "formData.total_amount"; 1798 var atxt = "formData.total_amount";
1682 var atxt1 = "formData.order_amount"; 1799 var atxt1 = "formData.order_amount";
@@ -1687,12 +1804,13 @@ Page({ @@ -1687,12 +1804,13 @@ Page({
1687 var atxt6 = "formData.cut_price"; 1804 var atxt6 = "formData.cut_price";
1688 var atxt7 = "formData.order_prom_amount"; 1805 var atxt7 = "formData.order_prom_amount";
1689 var atxt8 = "formData.zh_cut_price"; 1806 var atxt8 = "formData.zh_cut_price";
  1807 + var atxt9 = "formData.ladder_cut_price";
1690 1808
1691 th.setData({ 1809 th.setData({
1692 [atxt]: all_total_m, [atxt1]: all_order_m, 1810 [atxt]: all_total_m, [atxt1]: all_order_m,
1693 [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m, 1811 [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m,
1694 [atxt5]: all_coupon_price_m, [atxt6]: all_cutprice, 1812 [atxt5]: all_coupon_price_m, [atxt6]: all_cutprice,
1695 - [atxt7]: all_order_prom, show_submit: 1, [atxt8]: all_zh_cutprice 1813 + [atxt7]: all_order_prom, show_submit: 1, [atxt8]: all_zh_cutprice, [atxt9]: all_ladder_cutprice
1696 }) 1814 })
1697 th.data.order_prom_list_cart = c_arr; 1815 th.data.order_prom_list_cart = c_arr;
1698 th.set_can_num(); 1816 th.set_can_num();
@@ -2380,13 +2498,22 @@ Page({ @@ -2380,13 +2498,22 @@ Page({
2380 //--判断优惠活动的提交-- 2498 //--判断优惠活动的提交--
2381 if (t_item.cut_price > 0) { 2499 if (t_item.cut_price > 0) {
2382 order_prom_list.discount_amount += t_item.cut_price; 2500 order_prom_list.discount_amount += t_item.cut_price;
2383 - order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json);  
2384 } 2501 }
2385 //--判断组合优惠活动的提交-- 2502 //--判断组合优惠活动的提交--
2386 if (t_item.zh_cut_price > 0 || t_item.zh_cut_price<0) { 2503 if (t_item.zh_cut_price > 0 || t_item.zh_cut_price<0) {
2387 order_prom_list.discount_amount += t_item.zh_cut_price; 2504 order_prom_list.discount_amount += t_item.zh_cut_price;
2388 order_prom_list.zh_pt_json = JSON.stringify(t_item.zh_pt_json); 2505 order_prom_list.zh_pt_json = JSON.stringify(t_item.zh_pt_json);
2389 } 2506 }
  2507 +
  2508 + //--判断阶梯优惠活动的提交--
  2509 + if (t_item.ladder_cut_price > 0 || t_item.ladder_cut_price<0) {
  2510 + order_prom_list.discount_amount += t_item.ladder_cut_price;
  2511 + }
  2512 +
  2513 + if(t_item.prom_pt_json){
  2514 + order_prom_list.prom_pt_json = JSON.stringify(t_item.prom_pt_json);
  2515 + }
  2516 +
2390 if (t_item.s_intValue > 0) { 2517 if (t_item.s_intValue > 0) {
2391 order_prom_list.give_integral = t_item.s_intValue; 2518 order_prom_list.give_integral = t_item.s_intValue;
2392 } 2519 }
@@ -2423,6 +2550,15 @@ Page({ @@ -2423,6 +2550,15 @@ Page({
2423 2550
2424 //房间号的ids 2551 //房间号的ids
2425 var room_ids = ""; 2552 var room_ids = "";
  2553 +
  2554 + //-- 把券的钱,写入从表 ---
  2555 + if (t_item.quan_youhui_list && t_item.coupon_price) {
  2556 + for (var kk in t_item.quan_youhui_list) {
  2557 + var you_item = t_item.quan_youhui_list[kk];
  2558 + //-- 对券的价格进行平摊 --
  2559 + await th.split_set_goods_quanprice(you_item,t_item);
  2560 + }
  2561 + }
2426 //-------------让商品添加到商品列表-------------------- 2562 //-------------让商品添加到商品列表--------------------
2427 for (var k = 0; k < t_item.goods.length; k++) { 2563 for (var k = 0; k < t_item.goods.length; k++) {
2428 var g_item = t_item.goods[k]; 2564 var g_item = t_item.goods[k];
@@ -2445,22 +2581,15 @@ Page({ @@ -2445,22 +2581,15 @@ Page({
2445 goods.offline_cut = (g_item.goods_price - g_item.offline_price).toFixed(2); 2581 goods.offline_cut = (g_item.goods_price - g_item.offline_price).toFixed(2);
2446 goods.pricing_type = g_item.pricing_type; 2582 goods.pricing_type = g_item.pricing_type;
2447 } 2583 }
2448 -  
2449 - //--把券的钱,写入从表---  
2450 - if (t_item.quan_youhui_list && t_item.coupon_price) {  
2451 - for (var kk in t_item.quan_youhui_list) {  
2452 - var you_item = t_item.quan_youhui_list[kk];  
2453 - if (g_item.prom_type!=7 && g_item.erpwareid == you_item.WareId) {  
2454 - goods.quan_num = you_item.WareCashSum;  
2455 - goods.quan_no = you_item.CashRepNo;  
2456 - }  
2457 - } 2584 + if(g_item.quan_num){
  2585 + goods.quan_num=g_item.quan_num;
  2586 + goods.quan_no=g_item.quan_no;
2458 } 2587 }
2459 -  
2460 //--判断活动的类型-- 2588 //--判断活动的类型--
2461 switch (g_item.prom_type) { 2589 switch (g_item.prom_type) {
2462 case 1: 2590 case 1:
2463 case 2: 2591 case 2:
  2592 + case 10:
2464 goods.prom_type = g_item.prom_type; 2593 goods.prom_type = g_item.prom_type;
2465 goods.prom_id = g_item.prom_id; 2594 goods.prom_id = g_item.prom_id;
2466 break; 2595 break;
@@ -2525,6 +2654,12 @@ Page({ @@ -2525,6 +2654,12 @@ Page({
2525 goods.room_id = g_item.room_id; 2654 goods.room_id = g_item.room_id;
2526 room_ids += g_item.room_id + ","; 2655 room_ids += g_item.room_id + ",";
2527 } 2656 }
  2657 +
  2658 + //如果有阶梯促销
  2659 + if(g_item.ladder_list_id){
  2660 + goods.ladder_list_id=g_item.ladder_list_id;
  2661 + }
  2662 +
2528 item.order_goods.push(goods); 2663 item.order_goods.push(goods);
2529 } 2664 }
2530 2665
@@ -3409,6 +3544,7 @@ Page({ @@ -3409,6 +3544,7 @@ Page({
3409 get_cart_quan: async function (order_prom_list_cart) { 3544 get_cart_quan: async function (order_prom_list_cart) {
3410 var th = this; 3545 var th = this;
3411 var is_xz_yh = 1; 3546 var is_xz_yh = 1;
  3547 + var user_id=getApp().globalData.user_id;
3412 //等待值的出现 3548 //等待值的出现
3413 //getApp().waitfor2(this,"g_cart_q_time","order_prom_list_cart",async function () { 3549 //getApp().waitfor2(this,"g_cart_q_time","order_prom_list_cart",async function () {
3414 //var arr=th.data.order_prom_list_cart; 3550 //var arr=th.data.order_prom_list_cart;
@@ -3442,7 +3578,19 @@ Page({ @@ -3442,7 +3578,19 @@ Page({
3442 }).then(res => { 3578 }).then(res => {
3443 if (res.data.code == 0) prom1 = res.data.data; 3579 if (res.data.code == 0) prom1 = res.data.data;
3444 }) 3580 })
3445 - if(!prom1.isQuan){ 3581 + if(prom1 && !prom1.isQuan){
  3582 + continue;
  3583 + }
  3584 + }
  3585 +
  3586 + //--如果是团购,要判断有没有限制使用优惠券
  3587 + if(gd.prom_type == 10){
  3588 + var prom1=null;
  3589 + await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/"+ os.stoid +"/"+user_id+"/"+ gd.prom_id, {
  3590 + }).then(res => {
  3591 + if (res.data.code == 0) prom1 = res.data.data;
  3592 + })
  3593 + if(prom1 && prom1.isuse && prom1. is_usecoupon){
3446 continue; 3594 continue;
3447 } 3595 }
3448 } 3596 }
@@ -3482,6 +3630,16 @@ Page({ @@ -3482,6 +3630,16 @@ Page({
3482 } 3630 }
3483 } 3631 }
3484 3632
  3633 + var prom_pt_json= ep.prom_pt_json;
  3634 + if(prom_pt_json){
  3635 + for(let oj in prom_pt_json){
  3636 + let item_j=prom_pt_json[oj];
  3637 + if(item_j.ladder_prom_id){
  3638 + cut_price += parseFloat(item_j.dis);
  3639 + }
  3640 + }
  3641 + }
  3642 +
3485 arr[ind].ckeck_quan_price = ckeck_quan_price - cut_price; 3643 arr[ind].ckeck_quan_price = ckeck_quan_price - cut_price;
3486 arr[ind].check_quan_ware_list = check_quan_ware_list; 3644 arr[ind].check_quan_ware_list = check_quan_ware_list;
3487 arr[ind].check_quan_price_list = check_quan_price_list; 3645 arr[ind].check_quan_price_list = check_quan_price_list;
@@ -3899,6 +4057,73 @@ Page({ @@ -3899,6 +4057,73 @@ Page({
3899 go_url:function (e) { 4057 go_url:function (e) {
3900 var url = e.currentTarget.dataset.url; 4058 var url = e.currentTarget.dataset.url;
3901 getApp().goto(url); 4059 getApp().goto(url);
  4060 + },
  4061 +
  4062 + //进行对商品的平摊g_item是单个商品,you_item是这个商品分多少优惠券的钱,goods是商品列表
  4063 + split_set_goods_quanprice:async function (you_item,t_item) {
  4064 + var coupon_price=you_item.WareCashSum;
  4065 + var goods=t_item.goods;
  4066 + var arr=[];
  4067 + //判断是不是有goods_id重复
  4068 + for(var i=0;i<goods.length;i++){
  4069 + if(goods[i].prom_type!=7 && goods[i].erpwareid==you_item.WareId){
  4070 + var gg_ite={
  4071 + goods_id:goods[i].goods_id,
  4072 + goods_num:goods[i].goods_num,
  4073 + goods_price:goods[i].goods_price,
  4074 + };
  4075 + if(goods[i].account) gg_ite.goods_price=goods[i].account;
  4076 + gg_ite.idx=i;arr.push(gg_ite);
  4077 + }
  4078 + }
  4079 +
  4080 + if(arr.length<=0) return false;
  4081 + if(arr.length==1){
  4082 + var idx=arr[0].idx;
  4083 + t_item.goods[idx].quan_num =Math.floor(coupon_price* 100) / 100;
  4084 + t_item.goods[idx].quan_no=t_item.quan_no;
  4085 + return false;
  4086 + }
  4087 +
  4088 + var pt_data = {
  4089 + 'dis': parseFloat(coupon_price),
  4090 + 'goods': arr,
  4091 + }
  4092 +
  4093 + var pt_res = null;
  4094 + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit", {
  4095 + is_json: 1,
  4096 + data: pt_data
  4097 + }).then(res => {
  4098 + if (res.data.code == 0) {
  4099 + pt_res = res.data.data;
  4100 + }
  4101 + })
  4102 + if (pt_res) {
  4103 + var q_s_num = 0;
  4104 + for (var i in pt_res) {
  4105 + var idx = pt_res[i].idx;
  4106 + //有account的实收价,就要用account实收价
  4107 + var price=(t_item.goods[idx].account?t_item.goods[idx].account:t_item.goods[idx].goods_price);
  4108 + price=(price - pt_res[i].fisrt_account)* t_item.goods[idx].goods_num;
  4109 + t_item.goods[idx].quan_num =price;
  4110 +
  4111 + t_item.goods[idx].quan_num =Math.floor(t_item.goods[idx].quan_num * 100) / 100;
  4112 + t_item.goods[idx].quan_no=t_item.quan_no;
  4113 + q_s_num += t_item.goods[idx].quan_num;
  4114 + }
  4115 +
  4116 + if (q_s_num > parseFloat(coupon_price) || q_s_num < parseFloat(coupon_price)){
  4117 + for (var ik in arr) {
  4118 + if (arr[ik].goods_num == 1) {
  4119 + var id = arr[ik].idx;
  4120 + var pri=Math.floor(coupon_price*100)/100-Math.floor(q_s_num*100)/100
  4121 + t_item.goods[id].quan_num+=pri;
  4122 + break;
  4123 + }
  4124 + }
  4125 + }
  4126 + }
3902 } 4127 }
3903 4128
3904 4129
pages/cart/cart2/cart2.wxml
@@ -95,7 +95,8 @@ @@ -95,7 +95,8 @@
95 95
96 <!-----商品名称规格------> 96 <!-----商品名称规格------>
97 <view class="order-num flex-space-between"> 97 <view class="order-num flex-space-between">
98 - <view class="co-red">¥<text class="fs36">{{filters.toFix(items.goods_price,2)}}</text></view> 98 + <view wx:if="{{items.prom_type==10}}" class="co-red">¥<text class="fs36">{{filters.toFix(items.goods_price,2)}}</text><text>({{items.discount}}折)</text></view>
  99 + <view wx:else class="co-red">¥<text class="fs36">{{filters.toFix(items.goods_price,2)}}</text></view>
99 <view class="goods-num">x{{items.goods_num}}</view> 100 <view class="goods-num">x{{items.goods_num}}</view>
100 </view> 101 </view>
101 </navigator> 102 </navigator>
@@ -431,6 +432,11 @@ @@ -431,6 +432,11 @@
431 <view>组合购优惠</view> 432 <view>组合购优惠</view>
432 <view class="co-red">- ¥ {{filters.toFix(formData.zh_cut_price,2)}}元</view> 433 <view class="co-red">- ¥ {{filters.toFix(formData.zh_cut_price,2)}}元</view>
433 </view> 434 </view>
  435 + <!-- 组合购优惠金额 -->
  436 + <view class="item" wx:if="{{formData.ladder_cut_price>0 || formData.ladder_cut_price<0}}">
  437 + <view>阶梯促销优惠</view>
  438 + <view class="co-red">- ¥ {{filters.toFix(formData.ladder_cut_price,2)}}元</view>
  439 + </view>
434 440
435 <!-- 订单优惠优惠金额 --> 441 <!-- 订单优惠优惠金额 -->
436 <view class="item" wx:if="{{formData.order_prom_amount>0}}"> 442 <view class="item" wx:if="{{formData.order_prom_amount>0}}">
pages/cart/cart2/ladder_calculate.js 0 → 100644
  1 +var regeneratorRuntime = require('../../../utils/runtime.js');
  2 +module.exports = {
  3 + //主要的作用,就是把阶梯促销多余的商品进行拆分,
  4 + //如果没有达成阶梯促销的要求,所有的商品都打回原价购买
  5 + fir_set_arr: function (c_item, th) {
  6 + //寻找一下
  7 + function get_num2(ite) {
  8 + var vh = c_item.goods.findIndex(function (e) {
  9 + return e.goods_id == ite.goods_id
  10 + })
  11 + if (vh > -1) return vh;
  12 + return 0;
  13 + }
  14 +
  15 + //组合活动,以及组合活动从表的商品
  16 + let ladder_map = c_item.ladder_map;
  17 + let goods = c_item.goods; //一个门店中所有的商品
  18 + let tfeel = 0, cut_price = 0, offline_price = 0, offline_num = 0;
  19 + //多个活动要拿来循环一下
  20 + for (let i in ladder_map) {
  21 + let title = ""; //提示语;
  22 + //其中的一个活动
  23 + let act_item = ladder_map[i];
  24 + let ladder_list = act_item.ladder_list;
  25 +
  26 + let all_num = 0; //商品数量之和
  27 + let all_price0 = 0; //商品数量之和
  28 + let aprice = 0; //达到活动条件的购买价格
  29 +
  30 + let no_in_arr = []; //剩余的未加入组合购
  31 + let del_g=[];
  32 + for (var li in goods) {
  33 + if (goods[li].prom_type != 10) continue;
  34 + if (goods[li].prom_id != act_item.id) continue;
  35 + var item = goods[li];
  36 + item.goods_price = item.goods_price;
  37 + item.offline_price = item.offline_price;
  38 + item.cart_num = item.goods_num;
  39 + all_num += item.cart_num;
  40 + for (var j = 0; j < item.cart_num; j++) {
  41 + no_in_arr.push({
  42 + price: item.goods_price,
  43 + offline_price: item.offline_price,
  44 + goods_id: item.goods_id,
  45 + shop_price: item.shop_price,
  46 + item:item
  47 + })
  48 + }
  49 + del_g.push(item);
  50 + }
  51 +
  52 + function sortData(a, b) {
  53 + return a.price - b.price
  54 + }
  55 + no_in_arr.sort(sortData);
  56 +
  57 + //开始阶梯计算价格
  58 + var lev = 0;
  59 + for (let j in ladder_list) {
  60 + if (no_in_arr.length == 0) break;
  61 + let item_j =ladder_list[j];
  62 + var end = no_in_arr.pop();
  63 + var new_price = parseInt(item_j.discount_field) == 1 ? end.shop_price : end.price;
  64 + var account=new_price * parseFloat(item_j.discount) / 10;
  65 + aprice +=account;
  66 +
  67 + //-- 单个文件新增 --
  68 + let new_g = JSON.parse(JSON.stringify(end.item));
  69 + new_g.goods_num = 1;
  70 + //如果有平摊到单品的时候,account要显示
  71 + if(!th.data.ispt_goods) new_g.account = account.toFixed(2);
  72 + new_g.discount = item_j.discount;
  73 + new_g.goods_price =new_price;
  74 + new_g.ladder_list_id =item_j.id;
  75 + goods.push(new_g);
  76 + lev++;
  77 + }
  78 +
  79 + let goods_map = {};
  80 + //算一下剩余的商品
  81 + if (no_in_arr.length) {
  82 + for (let ii in no_in_arr) {
  83 + let item = no_in_arr[ii];
  84 + if (item.offline_price) {
  85 + offline_price += item.price - item.offline_price;
  86 + offline_num += 1;
  87 + }
  88 + if (goods_map[item.goods_id]) {
  89 + var num = goods_map[item.goods_id];
  90 + goods_map[item.goods_id] = ++num;
  91 + } else {
  92 + goods_map[item.goods_id] = 1;
  93 + }
  94 + }
  95 + }
  96 +
  97 + if (Object.keys(goods_map).length) {
  98 + //这里就开始拆分提交订单时的列表
  99 + for (let j in goods_map) {
  100 + //map中存的就是商品的数量
  101 + let num = goods_map[j];
  102 + //找到相应的商品
  103 + let idx = goods.findIndex(function (ele) {
  104 + return ele.goods_id == j;
  105 + })
  106 + //goods[idx].goods_num -= num;
  107 + let new_g = JSON.parse(JSON.stringify(goods[idx]));
  108 + new_g.goods_num = num;
  109 + new_g.prom_type = 0;
  110 + new_g.prom_id = 0;
  111 + goods.push(new_g);
  112 + //goods.splice(idx, 1);
  113 + }
  114 + }
  115 +
  116 + //-- 最后剔除不要参与的数据 --
  117 + for(var h in del_g){
  118 + var it=del_g[h];
  119 + let idx = goods.findIndex(function (ele) {
  120 + return ele.goods_id == it.goods_id
  121 + })
  122 + goods.splice(idx, 1);
  123 + }
  124 +
  125 + //-- 只统计是参与活动的商品 --
  126 + for (var ij in goods) {
  127 + var iter = goods[ij];
  128 + if (iter.prom_type != 10 || iter.prom_id != act_item.id) {
  129 + continue;
  130 + }
  131 + all_price0 += iter.goods_num * iter.goods_price;
  132 + }
  133 +
  134 + if(!c_item.ladder_prom_goods) c_item.ladder_prom_goods={};
  135 + if(!c_item.ladder_prom_goods[act_item.id]) c_item.ladder_prom_goods[act_item.id]={};
  136 +
  137 + //-- 活动的条件已经满足 --
  138 + c_item.ladder_prom_goods[act_item.id].is_has_ladder = 1;
  139 + c_item.is_has_ladder = 1;
  140 + c_item.ladder_prom_goods[act_item.id].actual_price = aprice;
  141 + c_item.ladder_prom_goods[act_item.id].cut_price = all_price0 - aprice;
  142 +
  143 + tfeel += aprice;
  144 + cut_price += all_price0 - aprice;
  145 +
  146 + }
  147 +
  148 + c_item.ladder_all_price = tfeel;
  149 + c_item.ladder_cut_price = cut_price;
  150 +
  151 + if (c_item.is_offline == 1) {
  152 + c_item.offline_price += offline_price;
  153 + c_item.offline_num += offline_num;
  154 + } else {
  155 + c_item.is_offline == 1;
  156 + c_item.offline_price = offline_price;
  157 + c_item.offline_num = offline_num;
  158 + }
  159 + },
  160 + //筛选组合购,纯粹的数组按活动id分组
  161 + find_split: function (arr) {
  162 + //过滤只有团购的商品
  163 + let oarr = arr.goods.filter(function (ele) {
  164 + return ele.prom_type == 10
  165 + })
  166 + if (!oarr || oarr.length == 0) return null;
  167 + //看一下有多少个不同的团购
  168 + let map = {},
  169 + dest = [];
  170 + for (let i = 0; i < oarr.length; i++) {
  171 + let ai = oarr[i];
  172 + let index = map[ai.prom_id]
  173 + if (!index) {
  174 + dest.push({
  175 + prom_id: ai.prom_id,
  176 + act: ai.act,
  177 + data: [ai]
  178 + });
  179 + map[ai.prom_id] = dest.length; //存储下标
  180 + } else {
  181 + let dj = dest[index - 1];
  182 + dj.data.push(ai);
  183 + }
  184 + }
  185 + return dest;
  186 + },
  187 +
  188 + //-- 组装阶梯购的价格 --
  189 + calc_split_price: async function (c_arr, th) {
  190 + //-- 循环处理 --
  191 + for (var k in c_arr) {
  192 + var cart_item = c_arr[k]; //就是每一单的意思
  193 + var ord_goods = c_arr[k].goods; //就是每一单的从表的意思
  194 +
  195 + var ladder_map = cart_item.ladder_prom_goods; //一单中所有的组合购的集合
  196 + var item_map = {};
  197 + for (let i in ladder_map) {
  198 + let item = ladder_map[i];
  199 + let prom_id = i;
  200 + //如果这个活动还没有达到要求,继续下一个计算
  201 + if (!item.is_has_ladder) continue;
  202 + //过滤出相应组合购活动的商品
  203 + let glist = ord_goods.filter(function (ele) {
  204 + return ele.prom_type == 10 && ele.prom_id == i;
  205 + })
  206 +
  207 + var all_good_price = 0;
  208 + var post_gd = [];
  209 + for (let j in glist) {
  210 + let item = glist[j];
  211 + all_good_price += item.goods_price * item.goods_num;
  212 + var gitem = {
  213 + goods_id: item.goods_id,
  214 + goods_num: item.goods_num,
  215 + goods_price: item.goods_price
  216 + }
  217 + post_gd.push(gitem);
  218 + }
  219 + //要进行优惠的计算
  220 + if (all_good_price - item.actual_price) {
  221 + if (cart_item.prom_pt_json) {
  222 + cart_item.prom_pt_json.push({
  223 + "ladder_prom_id": prom_id,
  224 + "dis": (all_good_price - item.actual_price).toFixed(2),
  225 + "ispt": 0
  226 + })
  227 + } else {
  228 + cart_item.prom_pt_json = [{
  229 + "ladder_prom_id": prom_id,
  230 + "dis": (all_good_price - item.actual_price).toFixed(2),
  231 + "ispt": 0
  232 + }];
  233 + }
  234 + }
  235 + }
  236 +
  237 +
  238 + }
  239 + }
  240 +
  241 +
  242 +}
pages/cart/cart2/zh_calculate.js
@@ -15,6 +15,7 @@ module.exports = { @@ -15,6 +15,7 @@ module.exports = {
15 let act_item = zh_prom_goods[i]; 15 let act_item = zh_prom_goods[i];
16 let act_goos = act_item.gdlist; 16 let act_goos = act_item.gdlist;
17 let act = act_item.act; 17 let act = act_item.act;
  18 + if(!act) continue;
18 19
19 let all_num = 0; //商品数量之和 20 let all_num = 0; //商品数量之和
20 let all_price0 = 0; //商品数量之和 21 let all_price0 = 0; //商品数量之和
@@ -103,7 +104,7 @@ module.exports = { @@ -103,7 +104,7 @@ module.exports = {
103 } 104 }
104 105
105 //当满足组合的要求:总数要满足,起购数要满足 106 //当满足组合的要求:总数要满足,起购数要满足
106 - if (all_num >= act.zhbuyqty && !need_to_buy) { 107 + if (act && all_num >= act.zhbuyqty && !need_to_buy) {
107 108
108 //商品的列表 109 //商品的列表
109 for (var u in act_goos) { 110 for (var u in act_goos) {
pages/cart/cart2_inte/cart2_inte.js
@@ -839,7 +839,7 @@ Page({ @@ -839,7 +839,7 @@ Page({
839 await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{ 839 await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
840 data:{storageNos:pick_no,wareIds:encodeURIComponent(erpwareid),storeId:os.stoid} 840 data:{storageNos:pick_no,wareIds:encodeURIComponent(erpwareid),storeId:os.stoid}
841 }).then(res=>{ 841 }).then(res=>{
842 - if(res.data.code==0){ 842 + if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){
843 plist=res.data.data.pageData[0]; 843 plist=res.data.data.pageData[0];
844 } 844 }
845 }) 845 })
pages/cart/cart2_pt/cart2_pt.js
@@ -296,7 +296,7 @@ Page({ @@ -296,7 +296,7 @@ Page({
296 th.setData({ user_addr: ie }); 296 th.setData({ user_addr: ie });
297 if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) { 297 if (!th.data.user_addr || th.data.user_addr.address_id != ie.address_id) {
298 th.setData({ add_back: 1 }); 298 th.setData({ add_back: 1 });
299 - if (this.data.bn_goods) th.calculatePrice2(); 299 + if (th.data.bn_goods) th.calculatePrice2();
300 } 300 }
301 }) 301 })
302 //--更新默认地址--,看一下是不是跳到地址页面 302 //--更新默认地址--,看一下是不是跳到地址页面
@@ -779,7 +779,7 @@ Page({ @@ -779,7 +779,7 @@ Page({
779 var price =0,th=this; 779 var price =0,th=this;
780 price +=parseFloat(o_shipping_price); 780 price +=parseFloat(o_shipping_price);
781 //如果是包邮 781 //如果是包邮
782 - if (freight_free > 0 && o_price > freight_free){ return 0;} 782 + if (freight_free > 0 && o_price >= freight_free){ return 0;}
783 if (user_addr==null) { return 0; } 783 if (user_addr==null) { return 0; }
784 //计算物流的config item; 784 //计算物流的config item;
785 var item=null; 785 var item=null;
pages/cart/cart_wk/cart_wk.js
@@ -470,7 +470,7 @@ Page({ @@ -470,7 +470,7 @@ Page({
470 var price = 0, th = this; 470 var price = 0, th = this;
471 price += parseFloat(o_shipping_price); 471 price += parseFloat(o_shipping_price);
472 //如果是包邮 472 //如果是包邮
473 - if (freight_free > 0 && o_price > freight_free) { return 0; } 473 + if (freight_free > 0 && o_price >= freight_free) { return 0; }
474 if (user_addr == null) { return 0; } 474 if (user_addr == null) { return 0; }
475 //计算物流的config item; 475 //计算物流的config item;
476 var item = null; 476 var item = null;
pages/giftpack/giftpacklist/giftpacklist.js
@@ -39,6 +39,8 @@ Page({ @@ -39,6 +39,8 @@ Page({
39 orderSn: options.orderSn, 39 orderSn: options.orderSn,
40 getUserID: d.user_id, 40 getUserID: d.user_id,
41 }) 41 })
  42 +
  43 + if(options.lbId) th.data.lbId=options.lbId;
42 //-- 获取分享人的ID -- 44 //-- 获取分享人的ID --
43 var first_leader = options.first_leader || getApp().globalData.first_leader; 45 var first_leader = options.first_leader || getApp().globalData.first_leader;
44 if (first_leader) { 46 if (first_leader) {
pages/goods/goodsInfo/goodsInfo.js
@@ -850,7 +850,7 @@ Page({ @@ -850,7 +850,7 @@ Page({
850 850
851 851
852 //获取统一条形码,普通商品和优惠促销的商品 852 //获取统一条形码,普通商品和优惠促销的商品
853 - if (ee.data.data.prom_type == 0 || ee.data.data.prom_type == 3 || ee.data.data.prom_type == 5 || ee.data.data.prom_type == 7 || ee.data.data.prom_type == 9) { 853 + if (ee.data.data.prom_type == 0 || ee.data.data.prom_type == 3 || ee.data.data.prom_type == 5 || ee.data.data.prom_type == 7 || ee.data.data.prom_type == 9 || ee.data.data.prom_type == 10) {
854 //默认门店要拿下门店库存 854 //默认门店要拿下门店库存
855 if (that.data.sales_rules == 2 && that.data.is_newsales_rules) { 855 if (that.data.sales_rules == 2 && that.data.is_newsales_rules) {
856 //获取门店 856 //获取门店
@@ -1353,10 +1353,15 @@ Page({ @@ -1353,10 +1353,15 @@ Page({
1353 }) 1353 })
1354 1354
1355 } 1355 }
1356 - else if (th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 4 || th.data.prom_type == 5) { 1356 + else if (th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 4 || th.data.prom_type == 5 || th.data.prom_type==10) {
1357 newd.prom_type = 0; 1357 newd.prom_type = 0;
1358 newd.prom_id = 0; 1358 newd.prom_id = 0;
1359 1359
  1360 + if(th.data.prom_type == 10){
  1361 + newd.prom_type = th.data.prom_type;
  1362 + newd.prom_id = th.data.prom_id;
  1363 + }
  1364 +
1360 //---如果是线下门店销售的时候--- 1365 //---如果是线下门店销售的时候---
1361 if (th.data.sales_rules == 2) { 1366 if (th.data.sales_rules == 2) {
1362 var pick = th.get_pick_from_list(th.data.sto_sele_id) 1367 var pick = th.get_pick_from_list(th.data.sto_sele_id)
@@ -1449,6 +1454,7 @@ Page({ @@ -1449,6 +1454,7 @@ Page({
1449 user_id: oo.user_id, 1454 user_id: oo.user_id,
1450 goods_id: a, 1455 goods_id: a,
1451 pick_id: e.data.sto_sele_id, 1456 pick_id: e.data.sto_sele_id,
  1457 + state:0
1452 }, 1458 },
1453 success: function (re) { 1459 success: function (re) {
1454 1460
@@ -1517,9 +1523,41 @@ Page({ @@ -1517,9 +1523,41 @@ Page({
1517 }); 1523 });
1518 1524
1519 } 1525 }
1520 - //else "exchange" == t.currentTarget.dataset.action ? this.exchange(d) : this.buyNow(d);  
1521 else { 1526 else {
1522 1527
  1528 + if(newd.prom_type==10){
  1529 + //----先看会员在购物车中是否加入了该商品,立即购买的-----
  1530 + getApp().request.get("/api/weshop/cart/page", {
  1531 + data: {
  1532 + store_id: e.data.stoid,
  1533 + user_id: oo.user_id,
  1534 + state:1
  1535 + },
  1536 + success: function (res) {
  1537 + //-------如果购物车中有相关的数据---------
  1538 + if (res.data.code==0 && res.data.data.total > 0) {
  1539 + for(let j in res.data.data.pageData){
  1540 + let item_j=res.data.data.pageData[j];
  1541 + var url = '/api/weshop/cart/del/' +e.data.stoid+ '/' + item_j.id;
  1542 + getApp().request.delete(url, {});
  1543 + }
  1544 + }
  1545 + newd.state=1;
  1546 + getApp().request.post("/api/weshop/cart/save", {
  1547 + data: newd,
  1548 + success: function (t) {
  1549 + th.closeSpecModal();
  1550 + getApp().goto("/pages/cart/cart2/cart2?state=1");
  1551 + }
  1552 + });
  1553 +
  1554 +
  1555 + }
  1556 + })
  1557 + return false;
  1558 + }
  1559 +
  1560 +
1523 if (th.data.prom_goods) { 1561 if (th.data.prom_goods) {
1524 var prom_d = th.data.prom_goods; 1562 var prom_d = th.data.prom_goods;
1525 for (var i in prom_d) { 1563 for (var i in prom_d) {
@@ -1825,6 +1863,7 @@ Page({ @@ -1825,6 +1863,7 @@ Page({
1825 }); 1863 });
1826 }, 1864 },
1827 1865
  1866 +
1828 openSpecModel: function (t) { 1867 openSpecModel: function (t) {
1829 var th = this; 1868 var th = this;
1830 var open_store = t.currentTarget.dataset.ind; 1869 var open_store = t.currentTarget.dataset.ind;
@@ -1869,9 +1908,35 @@ Page({ @@ -1869,9 +1908,35 @@ Page({
1869 //var is_open=th.data.config 1908 //var is_open=th.data.config
1870 th.get_off_price(); 1909 th.get_off_price();
1871 }) 1910 })
  1911 + //--先判断会员状态--
  1912 + var user_info = getApp().globalData.userInfo;
  1913 + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
  1914 + wx.navigateTo({
  1915 + url: '/pages/togoin/togoin',
  1916 + })
  1917 + return false;
  1918 + }
  1919 + var is_go_next = 1;
  1920 + if (th.data.more_flash && th.data.more_flash.length > 1 && open_store == 1) {
  1921 + is_go_next = 0;
  1922 + }
  1923 + if (is_go_next) {
  1924 + var ind = t.currentTarget.dataset.ind;
  1925 + //回调。判断是不是优惠促销
  1926 + th.check_is_prom_goods(function () {
  1927 + th.setData({
  1928 + openSpecModal: !0,
  1929 + openSpecModal_ind: ind,
  1930 + });
  1931 + //var is_open=th.data.config
  1932 + th.get_off_price();
  1933 + })
  1934 + } else {
  1935 + th.setData({is_pop_more: 1});
  1936 +
  1937 + }
1872 } 1938 }
1873 }, 1939 },
1874 -  
1875 open_next(){ 1940 open_next(){
1876 var th=this; 1941 var th=this;
1877 //回调。判断是不是优惠促销 1942 //回调。判断是不是优惠促销
@@ -2261,10 +2326,12 @@ Page({ @@ -2261,10 +2326,12 @@ Page({
2261 2326
2262 switch (goodsinfo.prom_type) { 2327 switch (goodsinfo.prom_type) {
2263 case 1: 2328 case 1:
2264 - await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + goodsinfo.prom_id, {  
2265 - }).then(res => {  
2266 - if (res.data.code == 0) prom = res.data.data;  
2267 - }) 2329 +
  2330 + if(goodsinfo.prom_id) {
  2331 + await getApp().request.promiseGet("/api/ms/flash_sale/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => {
  2332 + if (res.data.code == 0) prom = res.data.data;
  2333 + })
  2334 + }
2268 2335
2269 break; 2336 break;
2270 case 6: 2337 case 6:
@@ -3040,7 +3107,7 @@ Page({ @@ -3040,7 +3107,7 @@ Page({
3040 var user_id=getApp().globalData.user_id; 3107 var user_id=getApp().globalData.user_id;
3041 if(!user_id) user_id=0; 3108 if(!user_id) user_id=0;
3042 3109
3043 - if (prom_type == 3 || prom_type == 0 || prom_type == 5 || prom_type == 7 || prom_type == 9) { 3110 + if (prom_type == 3 || prom_type == 0 || prom_type == 5 || prom_type == 7 || prom_type == 9 || prom_type == 10) {
3044 this.setData({ 3111 this.setData({
3045 prom_type: 0,isshow: 1, 3112 prom_type: 0,isshow: 1,
3046 }); 3113 });
@@ -3642,7 +3709,16 @@ Page({ @@ -3642,7 +3709,16 @@ Page({
3642 //如果是秒杀的时候 3709 //如果是秒杀的时候
3643 if(th.data.prom_type==0 && gd.prom_type == 1 ){ 3710 if(th.data.prom_type==0 && gd.prom_type == 1 ){
3644 gd.prom_type= 0; 3711 gd.prom_type= 0;
3645 - } 3712 + }
  3713 + //如果全场优惠,商品做了秒杀
  3714 + if(th.data.prom_type==3 && gd.prom_type == 1 ){
  3715 + gd.prom_type= 0;
  3716 + }
  3717 + //如果全场阶梯优惠,商品做了秒杀
  3718 + if(th.data.prom_type==10 && gd.prom_type == 1 ){
  3719 + gd.prom_type= 0;
  3720 + }
  3721 +
3646 3722
3647 if (!th.data.is_normal && ( gd.prom_type == 1 || gd.prom_type == 2 || gd.prom_type == 4 || gd.prom_type == 6)) { 3723 if (!th.data.is_normal && ( gd.prom_type == 1 || gd.prom_type == 2 || gd.prom_type == 4 || gd.prom_type == 6)) {
3648 //----获取活动购买数---- 3724 //----获取活动购买数----
@@ -5660,12 +5736,40 @@ Page({ @@ -5660,12 +5736,40 @@ Page({
5660 //---检查有没有优惠活动--- 5736 //---检查有没有优惠活动---
5661 check_is_youhui: function (gid, is_nor) { 5737 check_is_youhui: function (gid, is_nor) {
5662 var th = this; 5738 var th = this;
  5739 + var user_id=getApp().globalData.user_id;
  5740 + if(!user_id) user_id=0;
5663 //如果是普通购买的时候,要进行调用 5741 //如果是普通购买的时候,要进行调用
5664 if (is_nor) { 5742 if (is_nor) {
5665 getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + gid, { 5743 getApp().request.get("/api/weshop/goods/getGoodsPromNormal/" + os.stoid + "/" + gid, {
5666 success: function (res) { 5744 success: function (res) {
5667 if (res.data.code == 0) { 5745 if (res.data.code == 0) {
5668 var r_data = res.data.data; 5746 var r_data = res.data.data;
  5747 +
  5748 + if(r_data.ladderLists){
  5749 + var act_id=r_data.ladderLists[0].form_id;
  5750 + //-- 判断会员能不能参与阶梯促销 --
  5751 + getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid+"/"+user_id + "/"+act_id, {
  5752 + }).then(res=>{
  5753 + if(res.data.code==0 && res.data.data){
  5754 + var prom_content="";
  5755 + for(let jj in r_data.ladderLists){
  5756 + if(r_data.ladderLists[jj].discount==10){
  5757 + prom_content+="第"+(parseInt(jj)+1)+"件原价,";
  5758 + }else{
  5759 + prom_content+="第"+(parseInt(jj)+1)+"件"+r_data.ladderLists[jj].discount+"折,";
  5760 + }
  5761 + }
  5762 + prom_content=ut.sub_last(prom_content);
  5763 + th.data.prom_type=10;
  5764 + th.data.prom_id=act_id;
  5765 + th.setData({
  5766 + jieti_prom:prom_content,
  5767 + ladder_act_id:act_id
  5768 + })
  5769 + }
  5770 + })
  5771 + }
  5772 +
5669 th.setData({ 5773 th.setData({
5670 prom_goods: r_data.promGoodsLists, 5774 prom_goods: r_data.promGoodsLists,
5671 }) 5775 })
@@ -5679,7 +5783,7 @@ Page({ @@ -5679,7 +5783,7 @@ Page({
5679 getApp().request.get("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + gid + "/0", { 5783 getApp().request.get("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + gid + "/0", {
5680 success: function (res) { 5784 success: function (res) {
5681 console.log(res); 5785 console.log(res);
5682 - if (res.data.code == 0) { 5786 + if (res.data.code == 0 && res.data.data) {
5683 var r_data = res.data.data; 5787 var r_data = res.data.data;
5684 var max = 0, min = 0; 5788 var max = 0, min = 0;
5685 if (r_data.collocationList) { 5789 if (r_data.collocationList) {
@@ -5693,6 +5797,32 @@ Page({ @@ -5693,6 +5797,32 @@ Page({
5693 r_data.collocationPromList.max = (max + th.data.data.shop_price).toFixed(2); 5797 r_data.collocationPromList.max = (max + th.data.data.shop_price).toFixed(2);
5694 r_data.collocationPromList.min = (min + th.data.data.shop_price).toFixed(2); 5798 r_data.collocationPromList.min = (min + th.data.data.shop_price).toFixed(2);
5695 } 5799 }
  5800 +
  5801 + if(r_data.ladderLists){
  5802 + var act_id=r_data.ladderLists[0].form_id;
  5803 + //-- 判断会员能不能参与阶梯促销 --
  5804 + getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid+"/"+user_id + "/"+act_id, {
  5805 + }).then(res=>{
  5806 + if(res.data.code==0 && res.data.data){
  5807 + var prom_content="";
  5808 + for(let jj in r_data.ladderLists){
  5809 + if(r_data.ladderLists[jj].discount==10){
  5810 + prom_content+="第"+(parseInt(jj)+1)+"件原价,";
  5811 + }else{
  5812 + prom_content+="第"+(parseInt(jj)+1)+"件"+r_data.ladderLists[jj].discount+"折,";
  5813 + }
  5814 + }
  5815 + prom_content=ut.sub_last(prom_content);
  5816 + th.data.prom_type=10;
  5817 + th.data.prom_id=act_id;
  5818 + th.setData({
  5819 + jieti_prom:prom_content,
  5820 + ladder_act_id:act_id
  5821 + })
  5822 + }
  5823 + })
  5824 + }
  5825 +
5696 th.setData({ 5826 th.setData({
5697 order_prom: r_data.promOrder, 5827 order_prom: r_data.promOrder,
5698 collocationGoods: r_data.collocationPromList, 5828 collocationGoods: r_data.collocationPromList,
@@ -5701,11 +5831,8 @@ Page({ @@ -5701,11 +5831,8 @@ Page({
5701 th.is_show_more_buy(); 5831 th.is_show_more_buy();
5702 } 5832 }
5703 } 5833 }
5704 -  
5705 }) 5834 })
5706 } 5835 }
5707 -  
5708 -  
5709 }, 5836 },
5710 5837
5711 closePoster() { 5838 closePoster() {
@@ -6026,13 +6153,31 @@ Page({ @@ -6026,13 +6153,31 @@ Page({
6026 check_has_flash:function () { 6153 check_has_flash:function () {
6027 var th=this; 6154 var th=this;
6028 var url="/api/weshop/activitylist/getGoodActInfo"; 6155 var url="/api/weshop/activitylist/getGoodActInfo";
  6156 + var user_id=getApp().globalData.user_id;
  6157 + if(!user_id) user_id=0;
  6158 +
6029 var req_data={ 6159 var req_data={
6030 - store_id:os.stoid,goodsidlist:this.data.data.goods_id,is_detail:1 6160 + store_id:os.stoid,goodsidlist:this.data.data.goods_id,is_detail:1,user_id:user_id
6031 }; 6161 };
6032 //获取秒杀的多规格 6162 //获取秒杀的多规格
6033 - getApp().request.promiseGet(url, {data:req_data}).then(res=>{ 6163 + getApp().request.promiseGet(url, {data:req_data}).then(async function (res) {
6034 if(res.data.code==0 && res.data.data && res.data.data.length){ 6164 if(res.data.code==0 && res.data.data && res.data.data.length){
6035 - th.setData({more_flash:res.data.data}); 6165 + var arr_data=res.data.data;
  6166 + var new_arr=[];
  6167 + for(let i in arr_data){
  6168 + let item=arr_data[i];
  6169 + //找不到活动要剔除
  6170 + if(!item.act_name) continue;
  6171 + if(item.prom_type!=1) continue;
  6172 + new_arr.push(item);
  6173 + }
  6174 +
  6175 + if(new_arr.length==1){
  6176 + th.data.prom_id=new_arr[0].act_id;
  6177 + th.data.prom_type=new_arr[0].prom_type;
  6178 + }
  6179 +
  6180 + th.setData({more_flash:new_arr});
6036 } 6181 }
6037 }) 6182 })
6038 }, 6183 },
@@ -6058,7 +6203,6 @@ Page({ @@ -6058,7 +6203,6 @@ Page({
6058 success(res) {} 6203 success(res) {}
6059 }) 6204 })
6060 }, 6205 },
6061 -  
6062 get_normal(gid){ 6206 get_normal(gid){
6063 this.setData({ 6207 this.setData({
6064 prom_type: 0, 6208 prom_type: 0,
@@ -6069,6 +6213,7 @@ Page({ @@ -6069,6 +6213,7 @@ Page({
6069 this.check_is_youhui(gid,1); 6213 this.check_is_youhui(gid,1);
6070 this.data.is_normal=1; 6214 this.data.is_normal=1;
6071 }, 6215 },
  6216 +
6072 6217
6073 // 促销 -> 送礼包 -> 查看详情 6218 // 促销 -> 送礼包 -> 查看详情
6074 viewLbDetails(e) { 6219 viewLbDetails(e) {
@@ -6076,8 +6221,12 @@ Page({ @@ -6076,8 +6221,12 @@ Page({
6076 let url = `/packageA/pages/myGiftDetails/myGiftDetails?btn=0&index=0&id=${id}`; // btn=0 控制跳转到的页面不显示按钮 6221 let url = `/packageA/pages/myGiftDetails/myGiftDetails?btn=0&index=0&id=${id}`; // btn=0 控制跳转到的页面不显示按钮
6077 // console.log('myurl', url); 6222 // console.log('myurl', url);
6078 getApp().goto(url); 6223 getApp().goto(url);
6079 - } 6224 + },
6080 6225
  6226 + go_more_ladder:function (e) {
  6227 + var prom_id=e.currentTarget.dataset.id;
  6228 + getApp().goto("/pages/goods/goodsList/goodsList?ladder_id="+prom_id);
  6229 + }
6081 6230
6082 6231
6083 6232
pages/goods/goodsInfo/goodsInfo.wxml
@@ -619,6 +619,24 @@ @@ -619,6 +619,24 @@
619 </view> 619 </view>
620 </block> 620 </block>
621 621
  622 + <block wx:if="{{jieti_prom}}">
  623 + <view class="cx-frame flex jc_sb" bindtap="go_more_ladder" data-id="{{ladder_act_id}}"
  624 + style="position: relative; height: auto">
  625 + <view class="flex" style="width: 92%">
  626 + <view class="cx-sizs fs30" style="width: 90rpx;flex-shrink: 0">阶梯促</view>
  627 + <!-- 中间显示层 -->
  628 + <view class="ellipsis-1 fs24">
  629 + <text class="jie_show fs22">阶</text>
  630 + {{jieti_prom}}
  631 + </view>
  632 + </view>
  633 + <view data-coupon="1" bindtap="show_more_cx" class="cx-obtain-coupon wsize">
  634 + <text class="bg_jj" style="position: relative;right: 3rpx"></text>
  635 + </view>
  636 + </view>
  637 + </block>
  638 +
  639 +
622 <!-- 要判断是不是有订单优惠 --> 640 <!-- 要判断是不是有订单优惠 -->
623 <block wx:if="{{order_prom}}"> 641 <block wx:if="{{order_prom}}">
624 <view class="cx-frame flex" style="position: relative; height: auto"> 642 <view class="cx-frame flex" style="position: relative; height: auto">
@@ -659,26 +677,30 @@ @@ -659,26 +677,30 @@
659 <!-- 判断是不是有秒杀 --> 677 <!-- 判断是不是有秒杀 -->
660 <block wx:if="{{more_flash}}"> 678 <block wx:if="{{more_flash}}">
661 679
662 - <block wx:for="{{more_flash}}">  
663 -  
664 - <view class="cx-frame flex" style="position: relative; height: auto" wx:if="{{item.prom_type==1}}" >  
665 - <view class="cx-sizs wsize" style="width: 144rpx">秒杀</view>  
666 - <!-- 中间显示层 -->  
667 - <view class="flex ai-center jc_sb" style="width: 570rpx" bindtap="go_more_flash" data-id="{{item.act_id}}">  
668 - <view class="flex">  
669 - <view class="miao_lab">秒</view>  
670 - <view class="order_hui">  
671 - <view class="fs28 ellipsis-1">{{item.act_name}}</view>  
672 - <view class="fs26">  
673 - (活动时间:{{tool.format_tt(item.s_time)}} - {{tool.format_tt(item.e_time)}}) 680 + <block wx:for="{{more_flash}}">
  681 + <view class="cx-frame flex" style="position: relative; height: auto" wx:if="{{item.prom_type==1}}">
  682 + <view class="cx-sizs wsize" style="width: 144rpx">秒杀</view>
  683 + <!-- 中间显示层 -->
  684 + <view class="flex ai-center jc_sb" style="width: 570rpx" bindtap="go_more_flash"
  685 + data-id="{{item.act_id}}">
  686 + <view class="flex">
  687 + <view class="miao_lab">秒</view>
  688 + <view class="order_hui">
  689 + <view class="fs28 ellipsis-1">{{item.act_name}}</view>
  690 + <view class="fs26">
  691 + (活动时间:{{tool.format_tt(item.s_time)}} - {{tool.format_tt(item.e_time)}})
  692 + </view>
674 </view> 693 </view>
675 </view> 694 </view>
  695 + <view>
  696 + <text class="bg_jj is_more_cx" style="position: relative;top:-10rpx"></text>
  697 + </view>
676 </view> 698 </view>
677 - <view><text class="bg_jj is_more_cx" style="position: relative;top:-10rpx"></text></view>  
678 </view> 699 </view>
679 - </view>  
680 </block> 700 </block>
681 </block> 701 </block>
  702 +
  703 + <!-- 保障服务 -->
682 <view class="bz_view flex bdt16" wx:if="{{bconfig}}" style=""> 704 <view class="bz_view flex bdt16" wx:if="{{bconfig}}" style="">
683 <image class="bzfu_img" src="{{iurl}}/miniapp/images/bzfu_w.png"></image> 705 <image class="bzfu_img" src="{{iurl}}/miniapp/images/bzfu_w.png"></image>
684 <view class="flex f1 ai_c rel"> 706 <view class="flex f1 ai_c rel">
@@ -686,8 +708,6 @@ @@ -686,8 +708,6 @@
686 <view bindtap="clickCollapse" class="cx-obtain-coupon wsize arrow"> 708 <view bindtap="clickCollapse" class="cx-obtain-coupon wsize arrow">
687 <text class="bg_jj {{flag?'down1':''}}"></text> 709 <text class="bg_jj {{flag?'down1':''}}"></text>
688 </view> 710 </view>
689 - <!-- <text class="bg_jj" bindtap="clickCollapse"></text> -->  
690 - <!-- <text class="iconfont icon-shuangjiantouxia c-db"></text> -->  
691 </view> 711 </view>
692 </view> 712 </view>
693 <!-- - 搭配促销 -- --> 713 <!-- - 搭配促销 -- -->
pages/goods/goodsInfo/goodsInfo.wxss
@@ -3838,6 +3838,7 @@ button.custom-service::after { @@ -3838,6 +3838,7 @@ button.custom-service::after {
3838 color: #aaa; 3838 color: #aaa;
3839 } 3839 }
3840 3840
  3841 +
3841 .tick { 3842 .tick {
3842 position: relative; 3843 position: relative;
3843 } 3844 }
@@ -3880,3 +3881,6 @@ button.custom-service::after { @@ -3880,3 +3881,6 @@ button.custom-service::after {
3880 border-radius: 0 0 10rpx 0; 3881 border-radius: 0 0 10rpx 0;
3881 margin-right: 4rpx; 3882 margin-right: 4rpx;
3882 } 3883 }
  3884 +
  3885 +.jie_show{ display: inline-block; width: 40rpx; height: 40rpx; background-color:#ff0505;border-radius:50%;color: #fff;text-align: center; margin: 0 20rpx }
  3886 +
pages/goods/goodsList/goodsList.js
@@ -22,7 +22,8 @@ Page({ @@ -22,7 +22,8 @@ Page({
22 is_hot:0, 22 is_hot:0,
23 prom_goods_list:null, 23 prom_goods_list:null,
24 rq_data:null, 24 rq_data:null,
25 - isToggle: false, //切换商品视图控制符 25 + isToggle: false, //切换商品视图控制符
  26 + show_all:1, //判断显示
26 }, 27 },
27 28
28 onLoad: function(t) { 29 onLoad: function(t) {
@@ -69,8 +70,18 @@ Page({ @@ -69,8 +70,18 @@ Page({
69 70
70 if (0 != t.is_new && t.is_new != undefined) { url += "&is_new=" + t.is_new; } 71 if (0 != t.is_new && t.is_new != undefined) { url += "&is_new=" + t.is_new; }
71 if (0 != t.is_hot && t.is_hot != undefined) { url += "&is_hot=" + t.is_hot; } 72 if (0 != t.is_hot && t.is_hot != undefined) { url += "&is_hot=" + t.is_hot; }
72 -  
73 - 73 + if (0 != t.ladder_id && t.ladder_id != undefined) {
  74 + url += "&ladder_id=" + t.ladder_id;
  75 + this.setData({
  76 + ladder_id:t.ladder_id,
  77 + baseUrl:url,
  78 + })
  79 + }
  80 +
  81 + var user_id=getApp().globalData.user_id;
  82 + if(!user_id) user_id=0;
  83 + url += "&user_id="+user_id;
  84 +
74 // 优惠促销列表 85 // 优惠促销列表
75 if(t.prom_goods_id) { 86 if(t.prom_goods_id) {
76 url += '&prom_goods_id=' + t.prom_goods_id; 87 url += '&prom_goods_id=' + t.prom_goods_id;
@@ -96,6 +107,54 @@ Page({ @@ -96,6 +107,54 @@ Page({
96 } 107 }
97 }) 108 })
98 } 109 }
  110 +
  111 + //--- 阶梯优惠活动的凑单 ---
  112 + if(t.ladder_id){
  113 + var user_id=getApp().globalData.user_id;
  114 + if(!user_id) user_id=0;
  115 + getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/"+oo.stoid+"/"+user_id+"/"+t.ladder_id,{
  116 + }).then(res=>{
  117 + if(res.data.code==0 && res.data.data){
  118 + var arr= res.data.data;
  119 +
  120 + if(arr.is_end==1){
  121 + th.setData({show_all:0,err_txt:'活动已结束'});
  122 + return false;
  123 + }
  124 + if(arr.start_time>ut.gettimestamp()){
  125 + th.setData({show_all:0,err_txt:'活动还未开始'});
  126 + return false;
  127 + }
  128 + if(arr.end_time<ut.gettimestamp()){
  129 + th.setData({show_all:0});
  130 + th.setData({show_all:0,err_txt:'活动已结束'});
  131 + return false;
  132 + }
  133 +
  134 + var url1="/api/weshop/prom/ladderList/list?store_id="+oo.stoid+"&form_id="+arr.id;
  135 + getApp().request.promiseGet(url1, {}).then(rs=>{
  136 + if(rs.data.code==0 && rs.data.data && rs.data.data.length) {
  137 + var prom_content="";
  138 + for(let jj in rs.data.data){
  139 + if(rs.data.data[jj].discount==10){
  140 + prom_content+="第"+(parseInt(jj)+1)+"件原价,";
  141 + }else{
  142 + prom_content+="第"+(parseInt(jj)+1)+"件"+rs.data.data[jj].discount+"折,";
  143 + }
  144 + }
  145 + prom_content=ut.sub_last(prom_content);
  146 + th.setData({jieti_prom:prom_content})
  147 + }
  148 + })
  149 + }
  150 + else{
  151 + th.setData({show_all:0,err_txt:'未找到活动或者身份不符'});
  152 + }
  153 + })
  154 + }
  155 +
  156 +
  157 +
99 this.requestGoodsList(url); 158 this.requestGoodsList(url);
100 getApp().getConfig2(function(rs){ 159 getApp().getConfig2(function(rs){
101 //计算等级价相关 160 //计算等级价相关
@@ -152,7 +211,7 @@ Page({ @@ -152,7 +211,7 @@ Page({
152 //-- 获取 -- 211 //-- 获取 --
153 await getApp().request.promiseGet("/api/weshop/prom/gift/page?id="+content.gift+"&store_id="+oo.stoid, { 212 await getApp().request.promiseGet("/api/weshop/prom/gift/page?id="+content.gift+"&store_id="+oo.stoid, {
154 }).then(res => { 213 }).then(res => {
155 - if(res.data.code==0) 214 + if(ut.ajax_ok(res))
156 arr[i].content.gift_name=res.data.data.pageData[0].goods_name; 215 arr[i].content.gift_name=res.data.data.pageData[0].goods_name;
157 }) 216 })
158 } 217 }
@@ -179,6 +238,9 @@ Page({ @@ -179,6 +238,9 @@ Page({
179 var e = this,th=e; 238 var e = this,th=e;
180 this.data.requestUrl = t; 239 this.data.requestUrl = t;
181 240
  241 +
  242 + var user_id=getApp().globalData.user_id;
  243 + if(!user_id) user_id=0;
182 //不是商品分组的,不是默认排序的 244 //不是商品分组的,不是默认排序的
183 if(t.indexOf("group_id")==-1 || e.data.tabname!="sort" ){ 245 if(t.indexOf("group_id")==-1 || e.data.tabname!="sort" ){
184 t += "&orderField=" + e.data.tabname; 246 t += "&orderField=" + e.data.tabname;
@@ -195,10 +257,10 @@ Page({ @@ -195,10 +257,10 @@ Page({
195 for(let i in res.data.data.pageData){ 257 for(let i in res.data.data.pageData){
196 let item=res.data.data.pageData[i]; 258 let item=res.data.data.pageData[i];
197 item.original_img = th.data.url + item.original_img; 259 item.original_img = th.data.url + item.original_img;
198 - 260 + /*--
199 var url="/api/weshop/activitylist/getGoodActInfo"; 261 var url="/api/weshop/activitylist/getGoodActInfo";
200 var req_data={ 262 var req_data={
201 - store_id:oo.stoid,goodsidlist:item.goods_id,is_detail:1 263 + store_id:oo.stoid,goodsidlist:item.goods_id,is_detail:1,user_id:user_id
202 }; 264 };
203 //获取商品的实际活动 265 //获取商品的实际活动
204 await getApp().request.promiseGet(url, {data:req_data}).then(res=>{ 266 await getApp().request.promiseGet(url, {data:req_data}).then(res=>{
@@ -206,7 +268,7 @@ Page({ @@ -206,7 +268,7 @@ Page({
206 item.prom_type=res.data.data[0].prom_type; 268 item.prom_type=res.data.data[0].prom_type;
207 item.prom_id=res.data.data[0].act_id; 269 item.prom_id=res.data.data[0].act_id;
208 } 270 }
209 - }) 271 + })--*/
210 272
211 var prom_type = item.prom_type; //0普通商品 1秒杀 6拼单 2团购 4积分购 273 var prom_type = item.prom_type; //0普通商品 1秒杀 6拼单 2团购 4积分购
212 var prom_id=item.prom_id; 274 var prom_id=item.prom_id;
@@ -379,4 +441,10 @@ Page({ @@ -379,4 +441,10 @@ Page({
379 }, 441 },
380 442
381 443
  444 + go_url:function (e) {
  445 + var url=e.currentTarget.dataset.url;
  446 + getApp().goto(url);
  447 + }
  448 +
  449 +
382 }); 450 });
383 \ No newline at end of file 451 \ No newline at end of file
pages/goods/goodsList/goodsList.wxml
1 <wxs module="g_filter" src="g_filter.wxs"></wxs> 1 <wxs module="g_filter" src="g_filter.wxs"></wxs>
2 -<view class="container"> 2 +<view class="container" wx:if="{{show_all}}">
3 <view> 3 <view>
4 <block wx:for="{{prom_goods_list}}"> 4 <block wx:for="{{prom_goods_list}}">
5 <view class="fs30 ellipsis-1" style="padding: 20rpx 30rpx"> 5 <view class="fs30 ellipsis-1" style="padding: 20rpx 30rpx">
@@ -12,12 +12,14 @@ @@ -12,12 +12,14 @@
12 <text space="{{true}}" wx:if="{{item.content.is_libao && item.content.is_libao!='0'}}">送{{item.content.lb_name}} </text> 12 <text space="{{true}}" wx:if="{{item.content.is_libao && item.content.is_libao!='0'}}">送{{item.content.lb_name}} </text>
13 </view> 13 </view>
14 </block> 14 </block>
  15 + <!-- 新增 -->
  16 + <view wx:if="{{jieti_prom}}" class="fs30 ellipsis-1" style="padding: 20rpx">阶梯促销:{{jieti_prom}}</view>
  17 +
15 </view> 18 </view>
16 -  
17 <view class="pd20 flex ai-center jc_sb"> 19 <view class="pd20 flex ai-center jc_sb">
18 <!-- 搜索框 --> 20 <!-- 搜索框 -->
19 <view class="search-box f1"> 21 <view class="search-box f1">
20 - <navigator hover-class="none" url="/pages/goods/search/search"><text class="iconfont icon-sousuo pdr10"></text>搜索店铺商品</navigator> 22 + <navigator hover-class="none" url="/pages/goods/search/search?ladder_id={{ladder_id}}"><text class="iconfont icon-sousuo pdr10"></text>搜索店铺商品</navigator>
21 </view> 23 </view>
22 <!-- 单列/双列 显示切换 --> 24 <!-- 单列/双列 显示切换 -->
23 <text class="iconfont {{isToggle ? 'icon-fenxiang':'icon-fenlie'}} pdl30 fs36" bindtap="bindToggleDisplay"></text> 25 <text class="iconfont {{isToggle ? 'icon-fenxiang':'icon-fenlie'}} pdl30 fs36" bindtap="bindToggleDisplay"></text>
@@ -290,10 +292,10 @@ @@ -290,10 +292,10 @@
290 <view class="no-data" wx:if="{{(!requestData||requestData.length==0) && is_go}}"> 292 <view class="no-data" wx:if="{{(!requestData||requestData.length==0) && is_go}}">
291 <image class="cart-image" src="{{iurl}}/miniapp/images/cart-null.png"></image> 293 <image class="cart-image" src="{{iurl}}/miniapp/images/cart-null.png"></image>
292 <view class="no-data-title">暂无相关商品</view> 294 <view class="no-data-title">暂无相关商品</view>
293 - <navigator class="lookat" url="/pages/index/index/index">回到首页</navigator> 295 + <navigator bindtap="go_url" class="lookat" data-url="/pages/index/index/index">回到首页</navigator>
294 </view> 296 </view>
295 </view> 297 </view>
296 - <view hidden="{{!openFilterModal}}"> 298 +<view hidden="{{!openFilterModal}}">
297 <view bindtap="closeFilterModal" class="cover-layer"></view> 299 <view bindtap="closeFilterModal" class="cover-layer"></view>
298 <view class="filter-modal"> 300 <view class="filter-modal">
299 <icon bindtap="closeFilterModal" class="modal-close" color="gray" size="22" type="cancel"></icon> 301 <icon bindtap="closeFilterModal" class="modal-close" color="gray" size="22" type="cancel"></icon>
@@ -330,4 +332,11 @@ @@ -330,4 +332,11 @@
330 </view> 332 </view>
331 </view> 333 </view>
332 334
333 -<share_box id="share"></share_box>  
334 \ No newline at end of file 335 \ No newline at end of file
  336 +<share_box id="share"></share_box>
  337 +<view class="t-c fs32" wx:if="{{err_txt}}">
  338 + <view class="no-data">
  339 + <image class="cart-image" src="{{iurl}}/miniapp/images/cart-null.png"></image>
  340 + <view class="no-data-title">{{err_txt}}</view>
  341 + <navigator bindtap="go_url" class="lookat" data-url="/pages/index/index/index">回到首页</navigator>
  342 + </view>
  343 +</view>
335 \ No newline at end of file 344 \ No newline at end of file
pages/goods/search/search.js
@@ -108,7 +108,13 @@ Page({ @@ -108,7 +108,13 @@ Page({
108 if (0 != t.brand_id && t.brand_id!=undefined){ url += "&brand_id=" + t.brand_id;} 108 if (0 != t.brand_id && t.brand_id!=undefined){ url += "&brand_id=" + t.brand_id;}
109 if (0 != t.nation_id && t.nation_id!=undefined) { url += "&nation_id=" + t.nation_id;} 109 if (0 != t.nation_id && t.nation_id!=undefined) { url += "&nation_id=" + t.nation_id;}
110 if (0 != t.max_price && t.max_price!=undefined) { url += "&min_pirce=" + t.min_pirce + "&max_price=" + t.max_price;} 110 if (0 != t.max_price && t.max_price!=undefined) { url += "&min_pirce=" + t.min_pirce + "&max_price=" + t.max_price;}
111 - 111 + if (0 != t.ladder_id && t.ladder_id != undefined) {
  112 + url += "&ladder_id=" + t.ladder_id;
  113 + this.setData({
  114 + baseUrl:url,
  115 +
  116 + })
  117 + }
112 if (url != this.data.baseUrl) return this.requestSearch(url); 118 if (url != this.data.baseUrl) return this.requestSearch(url);
113 this.openSearchModal(); 119 this.openSearchModal();
114 // 获取历史搜索记录 120 // 获取历史搜索记录
@@ -139,6 +145,10 @@ Page({ @@ -139,6 +145,10 @@ Page({
139 t += "&user_id=" + getApp().globalData.userInfo.user_id; 145 t += "&user_id=" + getApp().globalData.userInfo.user_id;
140 } 146 }
141 this.data.requestUrl = t; 147 this.data.requestUrl = t;
  148 +
  149 + var user_id=getApp().globalData.user_id;
  150 + if(!user_id) user_id=0;
  151 +
142 getApp().request.promiseGet(t, {data:{is_mainshow: 1, isonsale: 1, store_id: oo.stoid,orderField: e.data.tabname, orderType: e.data.adname, page: e.data.currentPage}}).then(async res=>{ 152 getApp().request.promiseGet(t, {data:{is_mainshow: 1, isonsale: 1, store_id: oo.stoid,orderField: e.data.tabname, orderType: e.data.adname, page: e.data.currentPage}}).then(async res=>{
143 th.data.loading=0; 153 th.data.loading=0;
144 if(ut.ajax_ok(res)){ 154 if(ut.ajax_ok(res)){
@@ -146,9 +156,11 @@ Page({ @@ -146,9 +156,11 @@ Page({
146 for(let i in res.data.data.pageData){ 156 for(let i in res.data.data.pageData){
147 let item=res.data.data.pageData[i]; 157 let item=res.data.data.pageData[i];
148 item.original_img = th.data.url + item.original_img; 158 item.original_img = th.data.url + item.original_img;
  159 +
  160 + /*--
149 var url="/api/weshop/activitylist/getGoodActInfo"; 161 var url="/api/weshop/activitylist/getGoodActInfo";
150 var req_data={ 162 var req_data={
151 - store_id:oo.stoid,goodsidlist:item.goods_id,is_detail:1 163 + store_id:oo.stoid,goodsidlist:item.goods_id,is_detail:1,user_id:user_id
152 }; 164 };
153 //获取商品的实际活动 165 //获取商品的实际活动
154 await getApp().request.promiseGet(url, {data:req_data}).then(res=>{ 166 await getApp().request.promiseGet(url, {data:req_data}).then(res=>{
@@ -156,7 +168,7 @@ Page({ @@ -156,7 +168,7 @@ Page({
156 item.prom_type=res.data.data[0].prom_type; 168 item.prom_type=res.data.data[0].prom_type;
157 item.prom_id=res.data.data[0].act_id; 169 item.prom_id=res.data.data[0].act_id;
158 } 170 }
159 - }) 171 + })--*/
160 172
161 var prom_type = item.prom_type; //0普通商品 1秒杀 6拼单 2团购 4积分购 173 var prom_type = item.prom_type; //0普通商品 1秒杀 6拼单 2团购 4积分购
162 var prom_id=item.prom_id; 174 var prom_id=item.prom_id;
@@ -164,8 +176,6 @@ Page({ @@ -164,8 +176,6 @@ Page({
164 var url = ""; 176 var url = "";
165 switch (prom_type){ 177 switch (prom_type){
166 case 1: 178 case 1:
167 - var user_id=getApp().globalData.user_id;  
168 - if(!user_id) user_id=0;  
169 url = "/api/ms/flash_sale/getNew/" +oo.stoid + "/" +user_id+"/"+ prom_id; 179 url = "/api/ms/flash_sale/getNew/" +oo.stoid + "/" +user_id+"/"+ prom_id;
170 break; 180 break;
171 case 2: 181 case 2:
@@ -200,23 +210,30 @@ Page({ @@ -200,23 +210,30 @@ Page({
200 break 210 break
201 } 211 }
202 if(url!=null && url!=''){ 212 if(url!=null && url!=''){
203 - await getApp().request.promiseGet(url, {}).then(res => { 213 + await getApp().request.promiseGet(url, {}).then(async res => {
204 var prom =null; 214 var prom =null;
205 - if(res && res.data) prom=res.data.data;  
206 - if (prom != null && prom.is_end==0 && prom.end_time>now && (prom.start_time<now || (prom.show_time && prom.show_time<now)) ) {  
207 - item.prom_price = res.data.data.price;  
208 - if(res.data.data.user_price) item.prom_price=res.data.data.user_price;  
209 - var vNum=res.data.data.virtual_num?res.data.data.virtual_num:0;  
210 - var vNum1=res.data.data.virtualNum?res.data.data.virtualNum:0;  
211 - var vNum2=res.data.data.virtual?res.data.data.virtual:0;  
212 - item.sales_sum=res.data.data.buy_num+(vNum+vNum1+vNum2);  
213 - }else{  
214 - item.prom_type=0;  
215 - item.prom_id=0;  
216 - item.prom_price=null; 215 + var flag=null;
  216 + if(res.data.code==0 && res.data.data){
  217 + prom=res.data.data;
  218 +
  219 + if (prom != null && prom.is_end==0 && prom.end_time>now && (prom.start_time<now || (prom.show_time && prom.show_time<now)) ) {
  220 + item.prom_price = res.data.data.price;
  221 + if(res.data.data.user_price) item.prom_price=res.data.data.user_price;
  222 + var vNum=prom.virtual_num?prom.virtual_num:0;
  223 + var vNum1=prom.virtualNum?prom.virtualNum:0;
  224 + var vNum2=prom.virtual?prom.virtual:0;
  225 + item.sales_sum=prom.buy_num+(vNum+vNum1+vNum2);
  226 + }else{
  227 + item.prom_type=0;
  228 + item.prom_id=0;
  229 + item.prom_price=null;
  230 + }
  231 +
  232 +
217 } 233 }
218 }) 234 })
219 } 235 }
  236 + if(!th.data.requestData) th.data.requestData=[];
220 th.data.requestData.push(item); 237 th.data.requestData.push(item);
221 e.setData({requestData: e.data.requestData}); 238 e.setData({requestData: e.data.requestData});
222 } 239 }
@@ -270,7 +287,6 @@ Page({ @@ -270,7 +287,6 @@ Page({
270 if(!val){ 287 if(!val){
271 a.showWarning("请输入搜索关键词"); 288 a.showWarning("请输入搜索关键词");
272 } 289 }
273 -  
274 this.search(val); 290 this.search(val);
275 291
276 }, 292 },
@@ -425,4 +441,9 @@ Page({ @@ -425,4 +441,9 @@ Page({
425 searchRecord: [] 441 searchRecord: []
426 }); 442 });
427 }, 443 },
  444 +
  445 + go_url:function (e) {
  446 + var url=e.currentTarget.dataset.url;
  447 + getApp().goto(url);
  448 + }
428 }); 449 });
429 \ No newline at end of file 450 \ No newline at end of file
pages/goods/search/search.wxml
@@ -120,7 +120,7 @@ @@ -120,7 +120,7 @@
120 <view class="no-data" wx:if="{{!requestData||requestData.length==0}}"> 120 <view class="no-data" wx:if="{{!requestData||requestData.length==0}}">
121 <image class="cart-image" src="{{url}}/miniapp/images/cart-null.png"></image> 121 <image class="cart-image" src="{{url}}/miniapp/images/cart-null.png"></image>
122 <view class="no-data-title">没有相关的数据</view> 122 <view class="no-data-title">没有相关的数据</view>
123 - <navigator class="lookat" url="/pages/index/index/index"> 去逛逛 </navigator> 123 + <navigator bindtap="go_url" class="lookat" data-url="/pages/index/index/index"> 去逛逛 </navigator>
124 </view> 124 </view>
125 </view> 125 </view>
126 <view hidden="{{!openFilterModal}}"> 126 <view hidden="{{!openFilterModal}}">
pages/index/index/full_screen.js
1 module.exports = { 1 module.exports = {
2 //判断要不要显示全屏广告 2 //判断要不要显示全屏广告
3 get_the_full_screen(th){ 3 get_the_full_screen(th){
4 - var stoid=getApp().globalData.setting.stoid;  
5 - if(th.data.full_ad) { 4 + var stoid=getApp().globalData.setting.stoid;
  5 + if(getApp().globalData.full_screen) {
  6 + return false;
  7 + }
  8 + if(th.data.full_ad) {
6 return false; 9 return false;
7 } 10 }
  11 +
8 //获取全屏的广告 12 //获取全屏的广告
9 getApp().promiseGet("/api/weshop/ad/page?pid=1001&store_id=" + stoid,{ 13 getApp().promiseGet("/api/weshop/ad/page?pid=1001&store_id=" + stoid,{
10 data: { enabled: 1 } 14 data: { enabled: 1 }
11 }).then(res=>{ 15 }).then(res=>{
12 - //判断是不是有全屏广告  
13 - if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0){  
14 - th.setData({  
15 - is_full_screen_show:1,  
16 - full_ad:res.data.data.pageData[0],  
17 - })  
18 - //--定时关闭--  
19 - th.data.full_screen=setInterval(function(){  
20 - if(!th.data.sec_show) {  
21 - clearInterval(th.data.full_screen);  
22 - th.close_full_screen();  
23 - return false;  
24 - }  
25 - th.data.sec_show--;  
26 - th.setData({sec_show:th.data.sec_show});  
27 - },1000)  
28 - } 16 + //判断是不是有全屏广告
  17 + if(res.data.code==0 && res.data.data.pageData && res.data.data.pageData.length>0){
  18 + getApp().globalData.full_screen=res.data.data.pageData[0];
  19 + th.setData({
  20 + is_full_screen_show:1,
  21 + full_ad:res.data.data.pageData[0],
  22 + })
  23 + //--定时关闭--
  24 + th.data.full_screen=setInterval(function(){
  25 + if(!th.data.sec_show) {
  26 + clearInterval(th.data.full_screen);
  27 + th.close_full_screen();
  28 + return false;
  29 + }
  30 + th.data.sec_show--;
  31 + th.setData({sec_show:th.data.sec_show});
  32 + },1000)
  33 + }else{
  34 + getApp().globalData.full_screen=true;
  35 + }
29 }) 36 })
  37 +
  38 +
  39 +
  40 +
30 } 41 }
31 } 42 }
32 \ No newline at end of file 43 \ No newline at end of file
pages/index/index/index.js
@@ -318,74 +318,99 @@ Page({ @@ -318,74 +318,99 @@ Page({
318 } 318 }
319 } 319 }
320 320
321 - var pre_data={store_id:os.stoid,is_end:0,timetype:1,isuse:1};  
322 - if(user_id){  
323 - pre_data.user_id= user_id;  
324 - } 321 + console.log(this.data.isTemplate,'首页');
325 322
326 - getApp().request.get("/api/weshop/marketing/marketingPresellList/page",{  
327 - data:pre_data,  
328 - success:function (e) {  
329 - if(e.data.code==0 && e.data.data.pageData && e.data.data.pageData.length>0 ){  
330 - var pre_data=e.data.data.pageData;  
331 - var arr = new Array();  
332 - //--三个三个一组---  
333 - for (var i = 0; i < pre_data.length; i += 3) {  
334 - arr.push(pre_data.slice(i, i + 3)); 323 + if(!this.data.isTemplate){
  324 + var pre_data={store_id:os.stoid,is_end:0,timetype:1,isuse:1};
  325 + if(user_id){
  326 + pre_data.user_id= user_id;
  327 + }
  328 +
  329 + getApp().request.get("/api/weshop/marketing/marketingPresellList/page",{
  330 + data:pre_data,
  331 + success:function (e) {
  332 + if(e.data.code==0 && e.data.data.pageData && e.data.data.pageData.length>0 ){
  333 + var pre_data=e.data.data.pageData;
  334 + var arr = new Array();
  335 + //--三个三个一组---
  336 + for (var i = 0; i < pre_data.length; i += 3) {
  337 + arr.push(pre_data.slice(i, i + 3));
  338 + }
  339 + th.setData({
  340 + preGoods: arr
  341 + });
  342 + }else{
  343 + th.setData({
  344 + preGoods: null
  345 + });
335 } 346 }
  347 + }
  348 + })
  349 +
  350 + // 获取幸运购活动列表
  351 + getApp().request.promiseGet('/api/weshop/prom/luckyActivity/page', {
  352 + data: {
  353 + store_id: getApp().globalData.setting.stoid,
  354 + is_end: 0,
  355 + timetype: 1,
  356 + }
  357 + }).then(res => {
  358 + if(res.data.code == 0) {
336 th.setData({ 359 th.setData({
337 - preGoods: arr 360 + luckGo_list: res.data.data.pageData.slice(0,3),
  361 + });
  362 + }
  363 + });
  364 +
  365 + //-----秒杀-----
  366 + var flash_data = null;
  367 + var f_req={
  368 + store_id: os.stoid,
  369 + timetype: 2,
  370 + is_end: 0,
  371 + is_show: 1,
  372 + pageSize: 9,
  373 + user_id:0
  374 + };
  375 + if(user_id) f_req.user_id=user_id;
  376 + //--获取活动--
  377 + await getApp().request.promiseGet("/api/ms/flash_sale/spikepage", {
  378 + data:f_req ,
  379 + }).then(res => {
  380 + var e = res;
  381 + if (e.data.code == 0) {
  382 + flash_data = e.data.data.pageData;
  383 + if (flash_data == null || flash_data.length <= 0) return false;
  384 +
  385 + //当前时间戳
  386 + var nt = ut.gettimestamp();
  387 +
  388 + flash_data.forEach(function (val, ind) {
  389 +
  390 + if(val.user_price) val.price=val.user_price;
  391 + if (val.start_time > nt) flash_data[ind].status = 0;
  392 + else if (val.end_time > nt) flash_data[ind].status = 1;
  393 + if (val.buy_num >= val.goods_num) flash_data[ind].status = 2;
338 }); 394 });
339 - }else{ 395 +
  396 + var arr = new Array();
  397 + //--三个三个一组---
  398 + for (var i = 0; i < flash_data.length; i += 3) {
  399 + arr.push(flash_data.slice(i, i + 3));
  400 + }
340 th.setData({ 401 th.setData({
341 - preGoods: null 402 + saleGoods: arr
342 }); 403 });
343 } 404 }
344 - }  
345 - }) 405 + });
  406 +
  407 + }
  408 +
  409 +
  410 +
  411 +
346 412
347 413
348 - //-----秒杀-----  
349 - var flash_data = null;  
350 - var f_req={  
351 - store_id: os.stoid,  
352 - timetype: 2,  
353 - is_end: 0,  
354 - is_show: 1,  
355 - pageSize: 9,  
356 - user_id:0  
357 - };  
358 - if(user_id) f_req.user_id=user_id;  
359 - //--获取活动--  
360 - await getApp().request.promiseGet("/api/ms/flash_sale/spikepage", {  
361 - data:f_req ,  
362 - }).then(res => {  
363 - var e = res;  
364 - if (e.data.code == 0) {  
365 - flash_data = e.data.data.pageData;  
366 - if (flash_data == null || flash_data.length <= 0) return false;  
367 -  
368 - //当前时间戳  
369 - var nt = ut.gettimestamp();  
370 -  
371 - flash_data.forEach(function (val, ind) {  
372 -  
373 - if(val.user_price) val.price=val.user_price;  
374 - if (val.start_time > nt) flash_data[ind].status = 0;  
375 - else if (val.end_time > nt) flash_data[ind].status = 1;  
376 - if (val.buy_num >= val.goods_num) flash_data[ind].status = 2;  
377 - });  
378 -  
379 - var arr = new Array();  
380 - //--三个三个一组---  
381 - for (var i = 0; i < flash_data.length; i += 3) {  
382 - arr.push(flash_data.slice(i, i + 3));  
383 - }  
384 - th.setData({  
385 - saleGoods: arr  
386 - });  
387 - }  
388 - });  
389 414
390 415
391 416
@@ -394,7 +419,7 @@ Page({ @@ -394,7 +419,7 @@ Page({
394 var json_d = JSON.parse(e.switch_list); 419 var json_d = JSON.parse(e.switch_list);
395 th.setData({ is_closecoupon: json_d.is_closecoupon }) 420 th.setData({ is_closecoupon: json_d.is_closecoupon })
396 th.setData({ is_topstore: json_d.is_show_storeselect }) 421 th.setData({ is_topstore: json_d.is_show_storeselect })
397 - th.setData({is_gz_h5:json_d.is_gz_h5}) 422 + if(json_d.is_gz_h5) th.setData({is_gz_h5:json_d.is_gz_h5})
398 }, 1) 423 }, 1)
399 424
400 if (typeof this.getTabBar === 'function' && this.getTabBar()) { 425 if (typeof this.getTabBar === 'function' && this.getTabBar()) {
@@ -403,7 +428,7 @@ Page({ @@ -403,7 +428,7 @@ Page({
403 active: index //数字是当前页面在tabbar的索引 428 active: index //数字是当前页面在tabbar的索引
404 }) 429 })
405 430
406 - //sty 431 +
407 getApp().requestCardNum(this); 432 getApp().requestCardNum(this);
408 } 433 }
409 434
@@ -434,22 +459,6 @@ Page({ @@ -434,22 +459,6 @@ Page({
434 } 459 }
435 }, 1500) 460 }, 1500)
436 461
437 -  
438 - // 获取幸运购活动列表  
439 - getApp().request.promiseGet('/api/weshop/prom/luckyActivity/page', {  
440 - data: {  
441 - store_id: getApp().globalData.setting.stoid,  
442 - is_end: 0,  
443 - timetype: 1,  
444 - }  
445 - }).then(res => {  
446 - if(res.data.code == 0) {  
447 - th.setData({  
448 - luckGo_list: res.data.data.pageData.slice(0,3),  
449 - });  
450 - }  
451 - });  
452 -  
453 462
454 }, 463 },
455 //当隐藏的时候就关闭计时器 464 //当隐藏的时候就关闭计时器
pages/payment/pay_success/pay_success.js
1 var e = getApp(); 1 var e = getApp();
2 var regeneratorRuntime = require('../../../utils/runtime.js'); 2 var regeneratorRuntime = require('../../../utils/runtime.js');
  3 +var ut = require("../../../utils/util.js");
3 Page({ 4 Page({
4 /** 5 /**
5 * 页面的初始数据 6 * 页面的初始数据
@@ -30,21 +31,28 @@ Page({ @@ -30,21 +31,28 @@ Page({
30 if(type==1){ 31 if(type==1){
31 await getApp().request.promiseGet("/api/weshop/order/page", 32 await getApp().request.promiseGet("/api/weshop/order/page",
32 {data:{store_id:e.globalData.setting.stoid,order_sn:order_sn}}).then(res=>{ 33 {data:{store_id:e.globalData.setting.stoid,order_sn:order_sn}}).then(res=>{
33 - order=res.data.data.pageData[0];  
34 - th.setData({order:order,order_sn:order_sn}) 34 + if(ut.ajax_ok(res)){
  35 + order=res.data.data.pageData[0];
  36 + th.setData({order:order,order_sn:order_sn})
  37 + }
  38 +
35 }) 39 })
36 }else{ 40 }else{
37 await getApp().request.promiseGet("/api/weshop/order/page", 41 await getApp().request.promiseGet("/api/weshop/order/page",
38 {data:{store_id:e.globalData.setting.stoid,parent_sn:order_sn}}).then(res=>{ 42 {data:{store_id:e.globalData.setting.stoid,parent_sn:order_sn}}).then(res=>{
39 43
40 - var allmoney=0,user_money=0;  
41 - for(var i in res.data.data.pageData){  
42 - var item=res.data.data.pageData[i];  
43 - allmoney+=item.order_amount;  
44 - user_money += item.user_money?item.user_money:0;  
45 - }  
46 - order=res.data.data.pageData[0];  
47 - th.setData({ order: order, type: 2, allmoney: allmoney, order_sn: order_sn, user_money: user_money}) 44 + if(ut.ajax_ok(res)){
  45 + var allmoney=0,user_money=0;
  46 + for(var i in res.data.data.pageData){
  47 + var item=res.data.data.pageData[i];
  48 + allmoney+=item.order_amount;
  49 + user_money += item.user_money?item.user_money:0;
  50 + }
  51 + order=res.data.data.pageData[0];
  52 + th.setData({ order: order, type: 2, allmoney: allmoney, order_sn: order_sn, user_money: user_money})
  53 + }
  54 +
  55 +
48 }) 56 })
49 } 57 }
50 //--获取门店-- 58 //--获取门店--
pages/team/team_show/team_show.js
@@ -561,7 +561,9 @@ Page({ @@ -561,7 +561,9 @@ Page({
561 is_show: 1 561 is_show: 1
562 } 562 }
563 }).then(res => { 563 }).then(res => {
564 - pageteam = res.data.data.pageData; 564 + if(ut.ajax_ok(res)){
  565 + pageteam = res.data.data.pageData;
  566 + }
565 }); 567 });
566 568
567 //-- 获取用户的默认门店 -- 569 //-- 获取用户的默认门店 --
@@ -604,7 +606,7 @@ Page({ @@ -604,7 +606,7 @@ Page({
604 getApp().request.promiseGet("/api/weshop/pickup/list",{ 606 getApp().request.promiseGet("/api/weshop/pickup/list",{
605 data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon,is_pos: 1}, 607 data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon,is_pos: 1},
606 }).then(res=>{ 608 }).then(res=>{
607 - if(res.data.code==0){ 609 + if(ut.ajax_ok(res)){
608 e=res.data.data.pageData[0]; 610 e=res.data.data.pageData[0];
609 if (e){ 611 if (e){
610 appd.pk_store=e; 612 appd.pk_store=e;
pages/user/cardinfo/cardinfo.js
@@ -765,7 +765,7 @@ Page({ @@ -765,7 +765,7 @@ Page({
765 var th = this,is_card = 0,end_time=0; 765 var th = this,is_card = 0,end_time=0;
766 await getApp().request.promiseGet("/store/storemoduleendtime/page?store_id="+os.stoid+"&type=3", 766 await getApp().request.promiseGet("/store/storemoduleendtime/page?store_id="+os.stoid+"&type=3",
767 {1:1}).then(res => { 767 {1:1}).then(res => {
768 - if (res.data.code == 0) { 768 + if (ut.ajax_ok(res)) {
769 end_time=res.data.data.pageData[0].end_time; 769 end_time=res.data.data.pageData[0].end_time;
770 } 770 }
771 }) 771 })
@@ -828,7 +828,7 @@ Page({ @@ -828,7 +828,7 @@ Page({
828 var th = this,card_id =e.currentTarget.dataset.cid ,end_time=0; 828 var th = this,card_id =e.currentTarget.dataset.cid ,end_time=0;
829 await getApp().request.promiseGet("/store/storemoduleendtime/page?store_id="+os.stoid+"&type=3", 829 await getApp().request.promiseGet("/store/storemoduleendtime/page?store_id="+os.stoid+"&type=3",
830 {1:1}).then(res => { 830 {1:1}).then(res => {
831 - if (res.data.code == 0) { 831 + if (ut.ajax_ok(res)) {
832 end_time=res.data.data.pageData[0].end_time; 832 end_time=res.data.data.pageData[0].end_time;
833 } 833 }
834 }) 834 })
pages/user/deposit/prepaid/prepaid.js
@@ -125,7 +125,16 @@ Page({ @@ -125,7 +125,16 @@ Page({
125 } 125 }
126 }).then(res => { 126 }).then(res => {
127 console.log(res); 127 console.log(res);
128 - 128 + var getcode=res.data.code;
  129 + if (getcode!=0)
  130 + {
  131 + wx.showModal({
  132 + title: '提示',
  133 + content:res.data.msg
  134 + });
  135 + return false;
  136 + }
  137 +
129 138
130 var msg = res.data.data; 139 var msg = res.data.data;
131 var parentSn = msg.order_sn; 140 var parentSn = msg.order_sn;
pages/user/index/index.js
@@ -63,7 +63,7 @@ Page({ @@ -63,7 +63,7 @@ Page({
63 //-- 读取会员中心按钮列表 -- 63 //-- 读取会员中心按钮列表 --
64 getApp().request.get("/api/weshop/userTool/page?pageSize=100", { 64 getApp().request.get("/api/weshop/userTool/page?pageSize=100", {
65 success:function(res){ 65 success:function(res){
66 - if(res.data.code==0 ){ 66 + if(ut.ajax_ok(res)) {
67 var d_list=res.data.data.pageData; 67 var d_list=res.data.data.pageData;
68 getApp().promiseGet("/api/weshop/storeDistribut/get/"+os.stoid,{}).then(rs=>{ 68 getApp().promiseGet("/api/weshop/storeDistribut/get/"+os.stoid,{}).then(rs=>{
69 var dis=rs.data.data; 69 var dis=rs.data.data;
@@ -79,7 +79,7 @@ Page({ @@ -79,7 +79,7 @@ Page({
79 enabled: 1 79 enabled: 1
80 }, 80 },
81 success:function(res){ 81 success:function(res){
82 - if(res.data.code==0 && res.data.data){ 82 + if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){
83 var item=res.data.data.pageData[0]; 83 var item=res.data.data.pageData[0];
84 if (item && item.ad_code) th.setData({ad_img:item.ad_code}) 84 if (item && item.ad_code) th.setData({ad_img:item.ad_code})
85 } 85 }
pages/user/my_service/appment_main.js
@@ -657,7 +657,7 @@ Page({ @@ -657,7 +657,7 @@ Page({
657 } 657 }
658 }).then(res => { 658 }).then(res => {
659 //-- 如果是门店的话 -- 659 //-- 如果是门店的话 --
660 - if (res.data.code == 0 && res.data.data && res.data.data.pageData) { 660 + if (res.data.code == 0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length) {
661 var store_data=null; 661 var store_data=null;
662 for(var i in res.data.data.pageData){ 662 for(var i in res.data.data.pageData){
663 var it=res.data.data.pageData[i]; 663 var it=res.data.data.pageData[i];
pages/user/order_detail/order_detail.js
@@ -101,7 +101,25 @@ Page({ @@ -101,7 +101,25 @@ Page({
101 r.order_status_detail = "组团中"; 101 r.order_status_detail = "组团中";
102 102
103 103
104 - r['is_all_return'] = 0; 104 + r['is_all_return'] = 0;
  105 +
  106 + var discount_price=r['discount_amount'];
  107 + var dis_json=r['prom_pt_json'];
  108 +
  109 + if(dis_json && discount_price){
  110 + var prom_pt_json=JSON.parse(dis_json);
  111 + var ladder_amount=0;
  112 + for (var ll_item of prom_pt_json) {
  113 + if(ll_item['ladder_prom_id']){
  114 + ladder_amount += ll_item['dis'];
  115 + }
  116 + }
  117 + r['ladder_amount']=ladder_amount;
  118 + r['discount_amount']=Math.floor((discount_price-ladder_amount)*100)/100;
  119 + }
  120 +
  121 +
  122 +
105 123
106 //------获取订单商品------- 124 //------获取订单商品-------
107 rq.get("/api/weshop/ordergoods/list",{ 125 rq.get("/api/weshop/ordergoods/list",{
@@ -553,7 +571,7 @@ Page({ @@ -553,7 +571,7 @@ Page({
553 await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{ 571 await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{
554 data:{store_id:os.stoid,goods_id:gg.goods_id} 572 data:{store_id:os.stoid,goods_id:gg.goods_id}
555 }).then(res=>{ 573 }).then(res=>{
556 - if(res.data.code==0 && res.data.data && res.data.data.pageData){ 574 + if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){
557 prom=res.data.data.pageData[0]; 575 prom=res.data.data.pageData[0];
558 } 576 }
559 }) 577 })
@@ -672,7 +690,7 @@ Page({ @@ -672,7 +690,7 @@ Page({
672 await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{ 690 await getApp().request.promiseGet("/api/weshop/integralbuy/pageIntegralBuyGoodsList?stype=1&stypeup=1",{
673 data:{store_id:os.stoid,goods_id:goodsinfo.goods_id} 691 data:{store_id:os.stoid,goods_id:goodsinfo.goods_id}
674 }).then(res=>{ 692 }).then(res=>{
675 - if(res.data.code==0 && res.data.data && res.data.data.pageData){ 693 + if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length){
676 prom=res.data.data.pageData[0]; 694 prom=res.data.data.pageData[0];
677 } 695 }
678 }) 696 })
@@ -993,7 +1011,8 @@ Page({ @@ -993,7 +1011,8 @@ Page({
993 var back_goods_arr=[]; 1011 var back_goods_arr=[];
994 var err_text=""; 1012 var err_text="";
995 for(var i in goods_list){ 1013 for(var i in goods_list){
996 - var g_item=goods_list[i]; 1014 + var g_item=goods_list[i];
  1015 + var b_item={};
997 //--如果是赠品,不加入购物车-- 1016 //--如果是赠品,不加入购物车--
998 if(g_item['is_gift']) continue; 1017 if(g_item['is_gift']) continue;
999 if(g_item['prom_type']==4 ){ 1018 if(g_item['prom_type']==4 ){
@@ -1015,7 +1034,22 @@ Page({ @@ -1015,7 +1034,22 @@ Page({
1015 1034
1016 }).then(res=>{ 1035 }).then(res=>{
1017 good=res.data.data; 1036 good=res.data.data;
1018 - }) 1037 + })
  1038 +
  1039 + //调用接口判断订单优惠,
  1040 + const res = await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + g_item.goods_id + "/0", {})
  1041 + if (res.data.code == 0 && res.data.data) {
  1042 + var r_data = res.data.data;
  1043 + if (r_data.ladderLists) {
  1044 + var act_id = r_data.ladderLists[0].form_id;
  1045 + //-- 判断会员能不能参与阶梯促销 --
  1046 + const data = await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + act_id, {})
  1047 + if (data.data.code == 0 && data.data.data && data.data.data.isuse && data.data.data.is_end == 0) {
  1048 + b_item.prom_type = 10;
  1049 + b_item.prom_id = data.data.data.id;
  1050 + }
  1051 + }
  1052 + }
1019 1053
1020 if(!good){ 1054 if(!good){
1021 err_text+= g_item['goods_name']+"未找到商品\n"; 1055 err_text+= g_item['goods_name']+"未找到商品\n";
@@ -1045,7 +1079,7 @@ Page({ @@ -1045,7 +1079,7 @@ Page({
1045 } 1079 }
1046 1080
1047 var prom=null; 1081 var prom=null;
1048 - var b_item={} 1082 +
1049 b_item.goods_id=g_item.goods_id; 1083 b_item.goods_id=g_item.goods_id;
1050 b_item.goods_name=g_item.goods_name; 1084 b_item.goods_name=g_item.goods_name;
1051 b_item.goods_num=g_item.goods_num; 1085 b_item.goods_num=g_item.goods_num;
@@ -1065,7 +1099,7 @@ Page({ @@ -1065,7 +1099,7 @@ Page({
1065 1099
1066 var url="/api/weshop/activitylist/getGoodActInfo"; 1100 var url="/api/weshop/activitylist/getGoodActInfo";
1067 var req_data={ 1101 var req_data={
1068 - store_id:g_item.store_id,goodsidlist:g_item.goods_id,is_detail:1 1102 + store_id:g_item.store_id,goodsidlist:g_item.goods_id,is_detail:1,user_id:user_id
1069 }; 1103 };
1070 await getApp().request.promiseGet(url, {data:req_data}).then(res=>{ 1104 await getApp().request.promiseGet(url, {data:req_data}).then(res=>{
1071 if(res.data.code==0){ 1105 if(res.data.code==0){
@@ -1110,28 +1144,38 @@ Page({ @@ -1110,28 +1144,38 @@ Page({
1110 b_item.price = prom.price; 1144 b_item.price = prom.price;
1111 } 1145 }
1112 break; 1146 break;
1113 - case 6:  
1114 - b_item.is_pd_normal = 1;  
1115 - break;  
1116 - case 7:  
1117 - //如果有组合购  
1118 - var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + good.prom_id + "/" + getApp().globalData.userInfo.user_id;  
1119 - await getApp().request.promiseGet(url, {}).then(res => {  
1120 - if (res.data.code == 0 && res.data.data) {  
1121 - if (res.data.data.is_show == 1 && res.data.data.is_end == 0  
1122 - && ut.gettimestamp() < res.data.data.end_time  
1123 - && ut.gettimestamp() > res.data.data.start_time  
1124 - ) {  
1125 - b_item.prom_type = 7;  
1126 - b_item.prom_id = res.data.data.id;  
1127 - good.prom_type = 7;  
1128 - good.prom_id = res.data.data.id;  
1129 - }  
1130 - }  
1131 - })  
1132 - break;  
1133 - }  
1134 - } 1147 + case 6:
  1148 + b_item.is_pd_normal = 1;
  1149 + break;
  1150 + case 7:
  1151 + //如果有组合购
  1152 + var url = "/api/weshop/prom/zhbuy/get/" + os.stoid + "/" + good.prom_id + "/" + getApp().globalData.userInfo.user_id;
  1153 + await getApp().request.promiseGet(url, {}).then(res => {
  1154 + if (res.data.code == 0 && res.data.data) {
  1155 + if (res.data.data.is_show == 1 && res.data.data.is_end == 0
  1156 + && ut.gettimestamp() < res.data.data.end_time
  1157 + && ut.gettimestamp() > res.data.data.start_time
  1158 + ) {
  1159 + b_item.prom_type = 7;
  1160 + b_item.prom_id = res.data.data.id;
  1161 + good.prom_type = 7;
  1162 + good.prom_id = res.data.data.id;
  1163 + }
  1164 + }
  1165 + })
  1166 + break;
  1167 + case 10:
  1168 + let user_id = getApp().globalData.userInfo.user_id;
  1169 + var url = `/api/weshop/prom/ladderForm/getNew/${os.stoid}/${user_id}/${good.prom_id}`;
  1170 + await getApp().request.promiseGet(url, {}).then(res => {
  1171 + if (res.data.code == 0 && res.data.data && res.data.data.isuse && res.data.data.is_end == 0) {
  1172 + b_item.prom_type = 10;
  1173 + b_item.prom_id = res.data.data.id;
  1174 + }
  1175 + })
  1176 + break;
  1177 + }
  1178 + }
1135 1179
1136 //如果有优惠促销的时候,要看下商品的优惠活动有没有过期 1180 //如果有优惠促销的时候,要看下商品的优惠活动有没有过期
1137 if(g_item.prom_type==3 || good.prom_type==3){ 1181 if(g_item.prom_type==3 || good.prom_type==3){
@@ -1560,17 +1604,32 @@ Page({ @@ -1560,17 +1604,32 @@ Page({
1560 1604
1561 //跳转到商品 1605 //跳转到商品
1562 go_gd:function (e) { 1606 go_gd:function (e) {
  1607 +
  1608 + var user_id=getApp().globalData.user_id;
  1609 + if(!user_id) user_id=0;
  1610 +
1563 var gd= e.currentTarget.dataset.gd; 1611 var gd= e.currentTarget.dataset.gd;
1564 var good_url="/pages/goods/goodsInfo/goodsInfo?goods_id=" + gd; 1612 var good_url="/pages/goods/goodsInfo/goodsInfo?goods_id=" + gd;
1565 var url="/api/weshop/activitylist/getGoodActInfo"; 1613 var url="/api/weshop/activitylist/getGoodActInfo";
1566 var req_data={ 1614 var req_data={
1567 - store_id:os.stoid,goodsidlist:gd,is_detail:1 1615 + store_id:os.stoid,goodsidlist:gd,is_detail:1,user_id:user_id
1568 }; 1616 };
1569 //获取秒杀的多规格 1617 //获取秒杀的多规格
1570 getApp().request.promiseGet(url, {data:req_data}).then(res=>{ 1618 getApp().request.promiseGet(url, {data:req_data}).then(res=>{
1571 if(res.data.code==0 && res.data.data){ 1619 if(res.data.code==0 && res.data.data){
1572 if(res.data.data.length==1){ 1620 if(res.data.data.length==1){
1573 - good_url+="&prom_type="+res.data.data[0].prom_type+"&prom_id="+res.data.data[0].act_id; 1621 + var item=res.data.data[0];
  1622 + switch (item.prom_type){
  1623 + case 9:
  1624 + good_url= '/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=' + gd + '&group_id=' + item.prom_id;
  1625 + break;
  1626 + case 8:
  1627 + good_url="/packageC/pages/presell/goodsInfo/goodsInfo?goods_id="+gd+"&prom_id="+item.prom_id
  1628 + break;
  1629 + default:
  1630 + good_url="/pages/goods/goodsInfo/goodsInfo?goods_id="+gd+"&prom_id="+item.prom_id+"&prom_type=1";
  1631 + break
  1632 + }
1574 } 1633 }
1575 getApp().goto(good_url); 1634 getApp().goto(good_url);
1576 1635
pages/user/order_detail/order_detail.wxml
@@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
32 </navigator> 32 </navigator>
33 33
34 <view class="order-num"> 34 <view class="order-num">
35 - <view class="goods-price">¥{{item.member_goods_price}}</view> 35 + <view class="goods-price">¥{{item.member_goods_price}}<text wx:if="{{item.prom_type==10}}" style="margin-left: 5rpx">({{item.ladder_discount}}折)</text> </view>
36 <view class="goods-num">×{{item.goods_num}}</view> 36 <view class="goods-num">×{{item.goods_num}}</view>
37 37
38 <!-- 不是整单退的时候 --> 38 <!-- 不是整单退的时候 -->
@@ -120,7 +120,12 @@ @@ -120,7 +120,12 @@
120 120
121 <view class="item pnew" wx:if="{{order.discount_amount>0}}"> 121 <view class="item pnew" wx:if="{{order.discount_amount>0}}">
122 <view>优惠活动</view> 122 <view>优惠活动</view>
123 - <view>¥ {{order.discount_amount}}元</view> 123 + <view>¥ {{filters.toFix(order.discount_amount,2)}}元</view>
  124 + </view>
  125 +
  126 + <view class="item pnew" wx:if="{{order.ladder_amount>0}}">
  127 + <view>阶梯优惠活动</view>
  128 + <view>¥ {{filters.toFix(order.ladder_amount,2)}}元</view>
124 </view> 129 </view>
125 130
126 <view class="item pnew" wx:if="{{order.order_prom_amount>0}}"> 131 <view class="item pnew" wx:if="{{order.order_prom_amount>0}}">
pages/user/order_list/order_list.js
@@ -1205,6 +1205,7 @@ Page({ @@ -1205,6 +1205,7 @@ Page({
1205 var err_text=""; 1205 var err_text="";
1206 for(var i in goods_list){ 1206 for(var i in goods_list){
1207 var g_item=goods_list[i]; 1207 var g_item=goods_list[i];
  1208 + var b_item={};
1208 //--如果是赠品,不加入购物车-- 1209 //--如果是赠品,不加入购物车--
1209 if(g_item['is_gift']) continue; 1210 if(g_item['is_gift']) continue;
1210 if(g_item['prom_type']==4 ){ 1211 if(g_item['prom_type']==4 ){
@@ -1228,6 +1229,20 @@ Page({ @@ -1228,6 +1229,20 @@ Page({
1228 good=res.data.data; 1229 good=res.data.data;
1229 }) 1230 })
1230 1231
  1232 + //调用接口判断订单优惠,
  1233 + // const res = await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + g_item.goods_id + "/0", {})
  1234 + // if (res.data.code == 0 && res.data.data) {
  1235 + // var r_data = res.data.data;
  1236 + // if (r_data.ladderLists) {
  1237 + // var act_id = r_data.ladderLists[0].form_id;
  1238 + // //-- 判断会员能不能参与阶梯促销 --
  1239 + // const data = await getApp().request.promiseGet("/api/weshop/prom/ladderForm/getNew/" + os.stoid + "/" + user_id + "/" + act_id, {})
  1240 + // if (data.data.code == 0 && data.data.data && data.data.data.isuse && data.data.data.is_end == 0) {
  1241 + // b_item.prom_type = 10;
  1242 + // b_item.prom_id = data.data.data.id;
  1243 + // }
  1244 + // }
  1245 + // }
1231 if(!good){ 1246 if(!good){
1232 err_text+= g_item['goods_name']+"未找到商品\n"; 1247 err_text+= g_item['goods_name']+"未找到商品\n";
1233 continue; 1248 continue;
@@ -1256,7 +1271,7 @@ Page({ @@ -1256,7 +1271,7 @@ Page({
1256 } 1271 }
1257 1272
1258 var prom=null; 1273 var prom=null;
1259 - var b_item={} 1274 +
1260 b_item.goods_id=g_item.goods_id; 1275 b_item.goods_id=g_item.goods_id;
1261 b_item.goods_name=g_item.goods_name; 1276 b_item.goods_name=g_item.goods_name;
1262 b_item.goods_num=g_item.goods_num; 1277 b_item.goods_num=g_item.goods_num;
@@ -1276,7 +1291,7 @@ Page({ @@ -1276,7 +1291,7 @@ Page({
1276 1291
1277 var url="/api/weshop/activitylist/getGoodActInfo"; 1292 var url="/api/weshop/activitylist/getGoodActInfo";
1278 var req_data={ 1293 var req_data={
1279 - store_id:g_item.store_id,goodsidlist:g_item.goods_id,is_detail:1 1294 + store_id:g_item.store_id,goodsidlist:g_item.goods_id,is_detail:1,user_id:user_id
1280 }; 1295 };
1281 await getApp().request.promiseGet(url, {data:req_data}).then(res=>{ 1296 await getApp().request.promiseGet(url, {data:req_data}).then(res=>{
1282 if(res.data.code==0){ 1297 if(res.data.code==0){
@@ -1287,7 +1302,6 @@ Page({ @@ -1287,7 +1302,6 @@ Page({
1287 } 1302 }
1288 } 1303 }
1289 }) 1304 })
1290 -  
1291 if(!prom) { 1305 if(!prom) {
1292 //--判断商品当前的活动情况-- 1306 //--判断商品当前的活动情况--
1293 switch (good.prom_type) { 1307 switch (good.prom_type) {
@@ -1342,6 +1356,16 @@ Page({ @@ -1342,6 +1356,16 @@ Page({
1342 } 1356 }
1343 }) 1357 })
1344 break; 1358 break;
  1359 + case 10:
  1360 + let user_id = getApp().globalData.userInfo.user_id;
  1361 + var url = `/api/weshop/prom/ladderForm/getNew/${os.stoid}/${user_id}/${good.prom_id}`;
  1362 + await getApp().request.promiseGet(url, {}).then(res => {
  1363 + if (res.data.code == 0 && res.data.data && res.data.data.isuse && res.data.data.is_end == 0) {
  1364 + b_item.prom_type = 10;
  1365 + b_item.prom_id = res.data.data.id;
  1366 + }
  1367 + })
  1368 + break;
1345 } 1369 }
1346 } 1370 }
1347 1371
@@ -1682,7 +1706,8 @@ Page({ @@ -1682,7 +1706,8 @@ Page({
1682 store_id: os.stoid, 1706 store_id: os.stoid,
1683 user_id: oo.user_id, 1707 user_id: oo.user_id,
1684 goods_id: g_item.goods_id, 1708 goods_id: g_item.goods_id,
1685 - pick_id: g_item.pickup_id, 1709 + pick_id: g_item.pickup_id,
  1710 + state:0,
1686 }, 1711 },
1687 }).then(res=>{ 1712 }).then(res=>{
1688 //-------如果购物车中有相关的数据------- 1713 //-------如果购物车中有相关的数据-------
pages/user/order_list/order_list.wxml
@@ -148,7 +148,7 @@ @@ -148,7 +148,7 @@
148 <!-- 幸运购prom_type等于9 --> 148 <!-- 幸运购prom_type等于9 -->
149 <!-- 如果是幸运购就显示幸运购参团价格 --> 149 <!-- 如果是幸运购就显示幸运购参团价格 -->
150 <view class="fs26" wx:if="{{goods.prom_type == 9}}">{{filters.toFix(goods.goods_price,2)}}</view> 150 <view class="fs26" wx:if="{{goods.prom_type == 9}}">{{filters.toFix(goods.goods_price,2)}}</view>
151 - <view class="fs26" wx:else>{{filters.toFix(goods.member_goods_price,2)}}</view> 151 + <view class="fs26" wx:else>{{filters.toFix(goods.member_goods_price,2)}} <text wx:if="{{goods.prom_type==10}}">({{goods.ladder_discount}}折)</text> </view>
152 </view> 152 </view>
153 <view class="fs26 c-a9">x{{goods.goods_num}}</view> 153 <view class="fs26 c-a9">x{{goods.goods_num}}</view>
154 </view> 154 </view>
pages/user/userqy/userqy.js
@@ -81,7 +81,7 @@ Page({ @@ -81,7 +81,7 @@ Page({
81 await getApp().request.promiseGet("/api/weshop/users/grade/vipgradeinfo/page",{ 81 await getApp().request.promiseGet("/api/weshop/users/grade/vipgradeinfo/page",{
82 data:{ storeId:os.stoid} 82 data:{ storeId:os.stoid}
83 }).then(res=>{ 83 }).then(res=>{
84 - if (res.data.data) 84 + if (res.data.data && res.data.data.pageData && res.data.data.pageData.length)
85 backClass=res.data.data.pageData; 85 backClass=res.data.data.pageData;
86 }) 86 })
87 87
@@ -100,7 +100,7 @@ Page({ @@ -100,7 +100,7 @@ Page({
100 await getApp().request.promiseGet("/api/weshop/users/grade/vipprivilegeinfo/page",{ 100 await getApp().request.promiseGet("/api/weshop/users/grade/vipprivilegeinfo/page",{
101 data:{storeId:os.stoid,pageSize:100} 101 data:{storeId:os.stoid,pageSize:100}
102 }).then(res=>{ 102 }).then(res=>{
103 - if (res.data.data) 103 + if (res.data.data && res.data.data.pageData && res.data.data.pageData.length)
104 qy_list=res.data.data.pageData; 104 qy_list=res.data.data.pageData;
105 }) 105 })
106 106
@@ -108,7 +108,7 @@ Page({ @@ -108,7 +108,7 @@ Page({
108 await getApp().request.promiseGet("/api/weshop/users/grade/privilegeform/list/page",{ 108 await getApp().request.promiseGet("/api/weshop/users/grade/privilegeform/list/page",{
109 data: { storeId: os.stoid, GradeId: gradeId, userId: gl_data.user_id, pageSize: 100 } 109 data: { storeId: os.stoid, GradeId: gradeId, userId: gl_data.user_id, pageSize: 100 }
110 }).then(res=>{ 110 }).then(res=>{
111 - if (res.data.data) 111 + if (res.data.data && res.data.data.pageData && res.data.data.pageData.length)
112 g_qy_list=res.data.data.pageData; 112 g_qy_list=res.data.data.pageData;
113 }); 113 });
114 114
@@ -227,7 +227,7 @@ Page({ @@ -227,7 +227,7 @@ Page({
227 await getApp().request.promiseGet("/api/weshop/users/grade/privilegeform/list/page",{ 227 await getApp().request.promiseGet("/api/weshop/users/grade/privilegeform/list/page",{
228 data: { storeId: os.stoid, GradeId: gr_id, userId: gl_data.user_id, pageSize: 100} 228 data: { storeId: os.stoid, GradeId: gr_id, userId: gl_data.user_id, pageSize: 100}
229 }).then(res=>{ 229 }).then(res=>{
230 - g_qy_list=res.data.data.pageData; 230 + if(ut.ajax_ok(res)) g_qy_list=res.data.data.pageData;
231 }) 231 })
232 232
233 for(var i in qy_list){ 233 for(var i in qy_list){
utils/LoadMore.js
@@ -59,52 +59,49 @@ var e = function() { @@ -59,52 +59,49 @@ var e = function() {
59 var n = !0; 59 var n = !0;
60 60
61 var i, r = s.data.listName, l = s.data.resultName, d = s.data.resultListName; 61 var i, r = s.data.listName, l = s.data.resultName, d = s.data.resultListName;
62 - i = "" != r ? t.data.data[r] : t.data.data.pageData; //data.pageData是接口固定会出现的,封装好了 62 + i = "" != r ? t.data.data[r] : (t.data.data && t.data.data.pageData?t.data.data.pageData:null); //data.pageData是接口固定会出现的,封装好了
63 var u = !1, g = null, c = s.data.page; 63 var u = !1, g = null, c = s.data.page;
64 64
65 - console.log('loadmore');  
66 - console.log(t.data.data.pageData);  
67 - console.log(c );  
68 -  
69 //如果已经的第二页的时候,就是把数据加入数组 65 //如果已经的第二页的时候,就是把数据加入数组
70 if (c !=undefined && c.data[l]) { 66 if (c !=undefined && c.data[l]) {
71 u = !0; 67 u = !0;
72 var f = null; 68 var f = null;
73 f = "" != d ? c.data[l][d] : c.data[l], [].push.apply(f, i), g = c.data[l]; 69 f = "" != d ? c.data[l][d] : c.data[l], [].push.apply(f, i), g = c.data[l];
74 - } else g = t.data.data.pageData; 70 + } else g = (t.data.data && t.data.data.pageData?t.data.data.pageData:null);
75 71
76 72
77 //格式化 73 //格式化
78 var glist=""; 74 var glist="";
79 -  
80 - for (var ii = 0; ii < g.length; ii++) {  
81 - //if(g[i].prom_type == 1 || g[i].prom_type == 2 || g[i].prom_type == 6) {  
82 - if (g[ii].prom_type && g[ii].prom_type == 1) {  
83 - glist += g[ii].goods_id+",";  
84 - }  
85 - if (g[ii].original_img!=undefined){  
86 - if (g[ii].original_img.indexOf(oo.imghost)==-1)  
87 - g[ii].original_img = oo.imghost + g[ii].original_img;  
88 - }  
89 -  
90 - if (g[ii].add_time != undefined && rurl.indexOf("goodscollect")<0){  
91 - var tx = g[ii].add_time + "";  
92 - if (tx.indexOf('-') == -1) {  
93 - g[ii].add_time = ut.formatTime(g[ii].add_time, 'yyyy-MM-dd hh:mm:ss'); 75 + if(g) {
  76 + for (var ii = 0; ii < g.length; ii++) {
  77 + //if(g[i].prom_type == 1 || g[i].prom_type == 2 || g[i].prom_type == 6) {
  78 + if (g[ii].prom_type && g[ii].prom_type == 1) {
  79 + glist += g[ii].goods_id + ",";
  80 + }
  81 + if (g[ii].original_img != undefined) {
  82 + if (g[ii].original_img.indexOf(oo.imghost) == -1)
  83 + g[ii].original_img = oo.imghost + g[ii].original_img;
  84 + }
  85 +
  86 + if (g[ii].add_time != undefined && rurl.indexOf("goodscollect") < 0) {
  87 + var tx = g[ii].add_time + "";
  88 + if (tx.indexOf('-') == -1) {
  89 + g[ii].add_time = ut.formatTime(g[ii].add_time, 'yyyy-MM-dd hh:mm:ss');
  90 + }
  91 + }
  92 + if (rurl.indexOf('comment/page') != -1) {
  93 + console.log('comment/page');
  94 + console.log(g[ii].img);
  95 + var tx1 = g[ii].img;
  96 +
  97 + if (tx1 != "" && tx1 != null && ut.isString(tx1)) {
  98 + var arr = ut.unserialize(tx1);
  99 + g[ii].img = arr;
  100 + } else if (!ut.isArray(tx1)) {
  101 + g[ii].img = "";
  102 + }
  103 + }
94 } 104 }
95 - }  
96 - if (rurl.indexOf('comment/page')!=-1){  
97 - console.log('comment/page');  
98 - console.log(g[ii].img);  
99 - var tx1 = g[ii].img;  
100 -  
101 - if (tx1 != "" && tx1 != null && ut.isString(tx1)){  
102 - var arr = ut.unserialize(tx1);  
103 - g[ii].img=arr;  
104 - } else if (!ut.isArray(tx1)){  
105 - g[ii].img="";  
106 - }  
107 - }  
108 } 105 }
109 106
110 107