diff --git a/.idea/mshopweapp.iml b/.idea/mshopweapp.iml
new file mode 100644
index 0000000..c956989
--- /dev/null
+++ b/.idea/mshopweapp.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app.js b/app.js
index 47bb739..0df5ad2 100644
--- a/app.js
+++ b/app.js
@@ -5,30 +5,88 @@ var api = require("./api/api.js")
//公共方法和变量
App({
- globalData: {
- setting: t,
- wechatUser: null,
- userInfo: null,
- config: null, //门店参数
- config2: null, //门店配置
- code: null,
- heigth:0,
- user_id:null,// 3674923,// 4379287,// null,// 5682068,
- buy_now:null,
- picklist:null, //门店列表
- wuliuprice: null, //物流价格表
- wuliu: null, //物流公司
- baddr:null,
- mobile: null, //记录手机
- getu:null, //记录会员信息
- sessionKey: null,//记录会员信息
- openid: null, //记录会员信息
+ editTabBar: function () {
+ //使用getCurrentPages可以获取当前加载中所有的页面对象的一个数组,数组最后一个就是当前页面。
- to_group:null, //参团传递的数据
- wxapp_buy_obj:null, //微信小程序购买的Object
- pk_store:null, //选择的门店
+ var curPageArr = getCurrentPages(); //获取加载的页面
+ var curPage = curPageArr[curPageArr.length - 1]; //获取当前页面的对象
+ var pagePath = curPage.route; //当前页面url
+ if (pagePath.indexOf('/') != 0) {
+ pagePath = '/' + pagePath;
+ }
+ console.log("获取加载的页面:="+curPageArr)
+ console.log("获取当前页面的对象:="+curPage)
+ console.log("当前页面url:="+pagePath)
+ var tabBar = this.globalData.tabBar;
+ for (var i = 0; i < tabBar.list.length; i++) {
+ tabBar.list[i].active = false;
+ if (tabBar.list[i].weappurl == pagePath) {
+ tabBar.list[i].active = true; //根据页面地址设置当前页面状态
+ }
+ }
+ curPage.setData({
+ tabBar: tabBar
+ });
+ },
+ globalData: {
+ tabBar: {
+ "color": "#6e6d6b",//文字未选择color
+ "selectedColor": "#f23030",//文字被选择后color
+ "borderStyle": "white",//
+ "backgroundColor": "#ffffff",//背景color
+ "iscustom":'',
+ "url":"",
+ "list": [
+ {
+ "weappurl": "/pages/index/index/index",
+ "nav_name": "首页",
+ "src": "/miniapp/images/bar/index.png",
+ "src_sele": "/miniapp/images/bar/index_on.png"
+ },
+ {
+ "weappurl": "/pages/goods/categoryList/categoryList",
+ "nav_name": "分类",
+ "src": "/miniapp/images/bar/fl.png",
+ "src_sele": "/miniapp/images/bar/fl_on.png"
+ },
+ {
+ "weappurl": "/pages/cart/cart/cart",
+ "nav_name": "购物车",
+ "src": "/miniapp/images/bar/car.png",
+ "src_sele": "/miniapp/images/bar/car_on.png"
+ },
+ {
+ "weappurl": "/pages/user/index/index",
+ "nav_name": "我的",
+ "src": "/miniapp/images/bar/user.png",
+ "src_sele": "/miniapp/images/bar/user_on.png"
+ }
+ ]
},
+ isTabBar:false,
+ setting: t,
+ wechatUser: null,
+ userInfo: null,
+ config: null, //门店参数
+ config2: null, //门店配置
+ code: null,
+ heigth:0,
+ user_id:null,// 3674923,// 4379287,// null,// 5682068,
+ buy_now:null,
+ picklist:null, //门店列表
+ wuliuprice: null, //物流价格表
+ wuliu: null, //物流公司
+ baddr:null,
+ mobile: null, //记录手机
+ getu:null, //记录会员信息
+ sessionKey: null,//记录会员信息
+ openid: null, //记录会员信息
+
+ to_group:null, //参团传递的数据
+ wxapp_buy_obj:null, //微信小程序购买的Object
+ pk_store:null, //选择的门店
+ },
auth: o,
request: a,
onLaunch: function() {
@@ -368,6 +426,8 @@ App({
data: {
store_id: th.globalData.setting.stoid,
user_id: th.globalData.user_id,
+ state:0,
+ is_gift:0
},
success: function(e) {
var num = 0;
@@ -396,15 +456,14 @@ App({
},1000);
}
},
-
-
+
//------定时等待某个值,有值才进行运算--------
waitfor2:function(page,key,pop_value_key,func){
var n=0;
if(!page.data[key]){
page.data[key]=setInterval(function(){
console.log(page.data[key]);n++;
- if(page.data[pop_value_key]) {
+ if(page.data[pop_value_key] && Object.keys(page.data[pop_value_key]).length>0) {
clearInterval(page.data[key]);
func();
}
diff --git a/app.json b/app.json
index eb0793a..80c7662 100644
--- a/app.json
+++ b/app.json
@@ -1,5 +1,5 @@
{
- "pages": [
+ "pages": [
"pages/index/index/index",
"pages/goods/categoryList/categoryList",
"pages/cart/cart/cart",
@@ -85,11 +85,25 @@
"pages/video/index",
"pages/template/index",
"pages/store/index"
-
- ],
+
+ ],
+ "subPackages": [{
+ "root": "packageA/",
+ "name":"pack1",
+ "pages": [
+ "pages/prom_list/prom_list",
+ "pages/quan_list/quan_list",
+ "pages/quan_pro/quan_pro"
+ ],
+ "plugins": {
+ "live-player-plugin": {
+ "version": "1.0.13",
+ "provider": "wx2b03c6e691cd7370"
+ }
+ }
+ }],
-
"permission": {
"scope.userLocation": {
"desc": "获取你的位置信息"
@@ -112,26 +126,26 @@
{
"pagePath": "pages/index/index/index",
"text": "首页",
- "iconPath": "images/bar/index.png",
- "selectedIconPath": "images/bar/index_on.png"
+ "iconPath": "packageA/images/bar/index.png",
+ "selectedIconPath": "packageA/images/bar/index_on.png"
},
{
"pagePath": "pages/goods/categoryList/categoryList",
"text": "分类",
- "iconPath": "images/bar/fl.png",
- "selectedIconPath": "images/bar/fl_on.png"
+ "iconPath": "packageA/images/bar/fl.png",
+ "selectedIconPath": "packageA/images/bar/fl_on.png"
},
{
"pagePath": "pages/cart/cart/cart",
"text": "购物车",
- "iconPath": "images/bar/car.png",
- "selectedIconPath": "images/bar/car_on.png"
+ "iconPath": "packageA/images/bar/car.png",
+ "selectedIconPath": "packageA/images/bar/car_on.png"
},
{
"pagePath": "pages/user/index/index",
"text": "我的",
- "iconPath": "images/bar/user.png",
- "selectedIconPath": "images/bar/user_on.png"
+ "iconPath": "packageA/images/bar/user.png",
+ "selectedIconPath": "packageA/images/bar/user_on.png"
}
]
},
diff --git a/app.wxss b/app.wxss
index 1c9cadb..6f4643d 100644
--- a/app.wxss
+++ b/app.wxss
@@ -94,7 +94,7 @@ button {
text-align: center;
}
.no-data .no-data-title {
- color: #9b9b9b;
+ color: #444;
margin-bottom: 30rpx;
font-size: 35rpx;
}
diff --git a/components/goods_list/goods_list.js b/components/goods_list/goods_list.js
index 11b1296..3fe92f1 100644
--- a/components/goods_list/goods_list.js
+++ b/components/goods_list/goods_list.js
@@ -144,12 +144,21 @@ Component({
var arr = [1219, 2089, 3031];
var new_arr = new Array();
var card_name_map = new Map();
+
+ var user = getApp().globalData.userInfo;
+
for (var i = 0; i < plusCard.length; i++) {
- var name = "card" + plusCard[i].CorrPrice.toLowerCase();
- card_name_map.set(name, plusCard[i].CardName);
+ if ((user.card_field==null || user.card_field=="") && (plusCard[i].IsStopBuy==true)) {
+ continue;
+ }
+ var name = "card" + plusCard[i].CorrPrice.toLowerCase();
+ card_name_map.set(name, plusCard[i].CardName);
+ new_arr.push(plusCard[i]);
+
+
}
var ob = {
- "card_list": plusCard,
+ "card_list": new_arr,
"name_map": card_name_map
};
func(ob);
diff --git a/images/bar/car.png b/packageA/images/bar/car.png
index 7fd3ab0..7fd3ab0 100644
--- a/images/bar/car.png
+++ b/packageA/images/bar/car.png
diff --git a/images/bar/car_on.png b/packageA/images/bar/car_on.png
index 27a5d27..27a5d27 100644
--- a/images/bar/car_on.png
+++ b/packageA/images/bar/car_on.png
diff --git a/images/bar/fl.png b/packageA/images/bar/fl.png
index e05a532..e05a532 100644
--- a/images/bar/fl.png
+++ b/packageA/images/bar/fl.png
diff --git a/images/bar/fl_on.png b/packageA/images/bar/fl_on.png
index 8a8016d..8a8016d 100644
--- a/images/bar/fl_on.png
+++ b/packageA/images/bar/fl_on.png
diff --git a/images/bar/fx.png b/packageA/images/bar/fx.png
index bba9649..bba9649 100644
--- a/images/bar/fx.png
+++ b/packageA/images/bar/fx.png
diff --git a/images/bar/fx_on.png b/packageA/images/bar/fx_on.png
index f6adb92..f6adb92 100644
--- a/images/bar/fx_on.png
+++ b/packageA/images/bar/fx_on.png
diff --git a/images/bar/index.png b/packageA/images/bar/index.png
index d6b0303..d6b0303 100644
--- a/images/bar/index.png
+++ b/packageA/images/bar/index.png
diff --git a/images/bar/index_on.png b/packageA/images/bar/index_on.png
index 096cb84..096cb84 100644
--- a/images/bar/index_on.png
+++ b/packageA/images/bar/index_on.png
diff --git a/images/bar/user.png b/packageA/images/bar/user.png
index 86974d9..86974d9 100644
--- a/images/bar/user.png
+++ b/packageA/images/bar/user.png
diff --git a/images/bar/user_on.png b/packageA/images/bar/user_on.png
index 93629ad..93629ad 100644
--- a/images/bar/user_on.png
+++ b/packageA/images/bar/user_on.png
diff --git a/images/share/ct_num.png b/packageA/images/share/ct_num.png
index c6e1ac3..c6e1ac3 100644
--- a/images/share/ct_num.png
+++ b/packageA/images/share/ct_num.png
diff --git a/images/share/default_g_img.gif b/packageA/images/share/default_g_img.gif
index a5369e2..a5369e2 100644
--- a/images/share/default_g_img.gif
+++ b/packageA/images/share/default_g_img.gif
diff --git a/images/share/hui_hear_pic.png b/packageA/images/share/hui_hear_pic.png
index 91144c7..91144c7 100644
--- a/images/share/hui_hear_pic.png
+++ b/packageA/images/share/hui_hear_pic.png
diff --git a/images/share/mackground.png b/packageA/images/share/mackground.png
index 6bcf62e..6bcf62e 100644
--- a/images/share/mackground.png
+++ b/packageA/images/share/mackground.png
diff --git a/images/share/miao_share.png b/packageA/images/share/miao_share.png
index f788197..f788197 100644
--- a/images/share/miao_share.png
+++ b/packageA/images/share/miao_share.png
diff --git a/images/share/q_tj.png b/packageA/images/share/q_tj.png
index 56136e5..56136e5 100644
--- a/images/share/q_tj.png
+++ b/packageA/images/share/q_tj.png
diff --git a/images/share/s_gou.png b/packageA/images/share/s_gou.png
index 5e4e765..5e4e765 100644
--- a/images/share/s_gou.png
+++ b/packageA/images/share/s_gou.png
diff --git a/images/share/share_bg.png b/packageA/images/share/share_bg.png
index a3177c6..a3177c6 100644
--- a/images/share/share_bg.png
+++ b/packageA/images/share/share_bg.png
diff --git a/packageA/pages/prom_list/filter.wxs b/packageA/pages/prom_list/filter.wxs
new file mode 100644
index 0000000..fa5ed5a
--- /dev/null
+++ b/packageA/pages/prom_list/filter.wxs
@@ -0,0 +1,17 @@
+var is_has = function (text,val) {
+ if(text.indexOf(","+val+",")==-1) return false;
+ return true
+}
+
+function get_guige(color,spece){
+ if(color=="" && spece==""){return "规格1"}
+ if(spece!="" && color==""){return spece}
+ if(spece=="" && color!=""){return color}
+ if(spece!="" && color!=""){return spece+"/"+color}
+ return "";
+}
+
+module.exports = {
+ is_has: is_has,
+ get_guige:get_guige
+}
diff --git a/packageA/pages/prom_list/g_filter.wxs b/packageA/pages/prom_list/g_filter.wxs
new file mode 100644
index 0000000..e998151
--- /dev/null
+++ b/packageA/pages/prom_list/g_filter.wxs
@@ -0,0 +1,87 @@
+var g_filters = {
+ //-- 判断是不是有等级价 --
+ is_has_rank:function(rank_switch,item){
+ if(!rank_switch) return false;
+ if(item.cardprice1 || item.cardprice2 || item.cardprice3) {return true}
+ return false;
+ },
+
+ //-- 判断,不是等级会员时候,要显示的最低等级价和名称 --
+ get_card_price:function(goods,all_card,type){
+ var price1=parseFloat(goods['cardprice1']);
+ var price2=parseFloat(goods['cardprice2']);
+ var price3=parseFloat(goods['cardprice3']);
+ if(!all_card){
+ if(type==0) return 0;
+ return "";
+ }
+
+ var arr=[];
+ var min_price= 0;
+ var min_name="";
+
+ var min_price=null;
+ var min_name=null;
+ //---设置对应的价格名字----
+ for(var i=0;i<3;i++) {
+ var vl=all_card[i];
+ if(!vl) continue;
+ if(vl['CorrPrice']=="Price1" && price1>0)
+ {
+ if(min_price==null) {
+ min_price=price1;min_name=vl['CardName'];
+ }
+ else if(price10)
+ {
+ if(min_price==null) {
+ min_price=price2;min_name=vl['CardName'];
+ }
+ else if(price20)
+ {
+ if(min_price==null) {
+ min_price=price3;min_name=vl['CardName'];
+ }
+ else if(price34 ) min_name=min_name.substring(0, 4);
+ return min_name;
+ },
+}
+module.exports = {
+ is_has_rank:g_filters.is_has_rank,
+ get_card_price:g_filters.get_card_price,
+}
\ No newline at end of file
diff --git a/packageA/pages/prom_list/prom_list.js b/packageA/pages/prom_list/prom_list.js
new file mode 100644
index 0000000..2ff76e1
--- /dev/null
+++ b/packageA/pages/prom_list/prom_list.js
@@ -0,0 +1,1539 @@
+var t = require("../../../utils/util.js"),
+ ut = t,
+ e = require("../../../utils/common.js"),
+ a = require("../../../utils/wxParse/wxParse.js"),
+ s = getApp(),
+ i = s.request,
+ rq = i,
+ oo = s.globalData,
+ o = s.globalData.setting,
+ os = o;
+var utils = require('../../../utils/util.js'),ut=utils;
+var regeneratorRuntime = require('../../../utils/runtime.js');
+
+
+Page({
+ data: {
+ gid: "",
+ stoid: o.stoid,
+ url: o.url,
+ resourceUrl: o.resourceUrl,
+ iurl: o.imghost,
+ defaultAvatar: o.resourceUrl + "/static/images/user68.jpg",
+ data: null,
+ openSpecModal: !1,
+ openPromModal: !1,
+ supportPageScroll: !1,
+
+ //联系电话
+ mobile: '',
+ bconfig:null,
+ sales_rules:1,
+
+ t_time:null,
+ card_field:"",
+ dp_price:0,
+ cut_price:0,
+ open_ind_store:1,
+ goodsInputNum:1,
+ g_buy_num: null,
+ sele_collocation:null,
+ },
+
+ //------初始化加载----------
+ onLoad: function(t) {
+ var goods_id=t.goods_id;
+ this.setData({gid:goods_id});
+ var ee=this,th=ee,that=ee;
+ //----获取系统参数,并判断等级价格-----
+ getApp().getConfig2(function(e) {
+ var json_d = JSON.parse(e.switch_list);
+ ee.setData({
+ store_config: e,
+ bconfig: e,
+ sys_switch:json_d,
+ is_closecoupon: json_d.is_closecoupon,
+ is_newsales_rules:json_d.is_newsales_rules,
+ sales_rules:e.sales_rules
+ });
+ //------几人评价-------
+ //计算等级价相关
+ var swithc_list=e.switch_list;
+ var sw_arr=JSON.parse(swithc_list);
+ //---如果后台又开等级卡的开关---
+ if(sw_arr.rank_switch && sw_arr.rank_switch=="2"){
+ th.data.rank_switch=true;
+ }
+ });
+
+ //获取用户的默认门店
+ getApp().get_user_store(function(ee) {
+ if(!ee) {
+ th.data.fir_def_store={}; //赋值空对象
+ return false;
+ }
+ var appd=getApp().globalData;
+ var w_time = setInterval(function() {
+ if (that.data.is_get_local_ok == 0) return false;
+ clearInterval(w_time);
+ var distance = null;
+ var e=JSON.parse(JSON.stringify(ee));
+
+ //如果有开启近距离的话,同时距离优不一样了
+ if (that.data.lat != null) {
+ //如果经纬度有变化的话
+ if( appd.lat==that.data.lat && appd.lon==that.data.lon && e.distance>0 ){
+ that.data.fir_def_store=e;
+ that.setData({
+ def_pick_store: e,
+ sto_sele_name: e.pickup_name,
+ sto_sele_id: e.pickup_id,
+ sto_sele_distr: e.distr_type
+ })
+ }else{
+ //要用接口是获取距离,js的计算不准
+ getApp().request.promiseGet("/api/weshop/pickup/list",{
+ data:{store_id:os.stoid,pickup_id:e.pickup_id,lat:th.data.lat,lon: th.data.lon},
+ }).then(res=>{
+ if(res.data.code==0){
+ e=res.data.data.pageData[0];
+ if (e){
+ appd.pk_store=e;
+ that.data.fir_def_store=e;
+ that.setData({
+ def_pick_store: e,
+ sto_sele_name: e.pickup_name,
+ sto_sele_id: e.pickup_id,
+ sto_sele_distr: e.distr_type
+ })
+ }
+
+ }
+ })
+ }
+
+ //e.distance = distance;
+ appd.lat=that.data.lat;
+ appd.lon=that.data.lon;
+
+ }else{
+ if (e) {
+ e.distance = null;
+ that.data.fir_def_store=e;
+ that.setData({
+ def_pick_store: e,
+ sto_sele_name: e.pickup_name,
+ sto_sele_id: e.pickup_id,
+ sto_sele_distr: e.distr_type
+ })
+ }
+ }
+
+ }, 500)
+ });
+
+ },
+
+ //---展示---
+ onShow: function() {
+ var ee=this,th=ee,that=ee;
+ var gid = this.data.gid,i = getApp().request;
+ ee.data.g_buy_num = new Map();
+ this.wait_for_store_config();
+ setTimeout(function(){
+ i.get("/api/weshop/goods/get/" + o.stoid + "/" + ee.data.gid, {
+ failRollback: !0,
+ success: function(t) {
+ if (t.data.code == 0) {
+ if (t.data.data.is_on_sale != 1) {
+ wx.showModal({
+ title: '商品已经下架',
+ showCancel: !1,
+ complete: function() {
+ wx.navigateBack();
+ }
+ });
+ }
+
+ var timestamp = Date.parse(new Date());
+ timestamp = timestamp / 1000;
+ if (t.data.data.on_time > timestamp) {
+ wx.showModal({
+ title: '商品还未上架',
+ showCancel: !1,
+ complete: function() {
+ wx.navigateBack();
+ }
+ });
+ }
+
+ if (t.data.data.down_time > 0) {
+ if (t.data.data.down_time < timestamp) {
+ wx.showModal({
+ title: '商品已经到期下架',
+ showCancel: !1,
+ complete: function() {
+ wx.navigateBack();
+ }
+ });
+ }
+ }
+
+ t.data.data.on_time = ut.formatTime(t.data.data.on_time, 'yyyy-MM-dd hh:mm:ss');
+ var txt = (t.data.data.shop_price / t.data.data.market_price * 10).toFixed(2);
+ t.data.data['disc'] = txt;
+
+ if (t.data.data.original_img.indexOf(o.imghost) == -1)
+ t.data.data.original_img = o.imghost + t.data.data.original_img;
+ if (t.data.data.goods_content == null) t.data.data.goods_content = "";
+
+ //计算商品的规格
+ var gg = "";
+ if(t.data.data.goods_spec=="null" || t.data.data.goods_spec==null) t.data.data.goods_spec="";
+ if(t.data.data.goods_color=="null" || t.data.data.goods_color==null) t.data.data.goods_color="";
+
+ if (t.data.data.goods_spec != "" && t.data.data.goods_color != "") {
+ gg = t.data.data.goods_spec + "/" + t.data.data.goods_color;
+ } else if (t.data.data.goods_spec != "" || t.data.data.goods_color != "") {
+ gg = t.data.data.goods_spec + t.data.data.goods_color;
+ } else {
+ gg = "规格1";
+ }
+ t.data.data.gg = gg;
+
+
+ //--看一下有没有开启等级卡---
+ if(ee.data.rank_switch){
+ //---回调卡的列表---
+ th.getPlusCardType(function(ob){
+ var user = getApp().globalData.userInfo;
+ if(user){
+ if(user.card_field ){
+ var str = user['card_expiredate'].replace(/-/g, '/');
+ var end = new Date(str);
+ end = Date.parse(end) / 1000;
+ var now = ut.gettimestamp();
+ //--- 判断是等级会员,且在有效期范围内 ---
+ if(user.card_field && now5) card_name=card_name.substring(0,5);
+ th.setData({card_field:user.card_field,card_name:card_name});
+ if(t.data.data[user.card_field]>0) t.data.data.shop_price=t.data.data[user.card_field];
+ }
+ }
+ }
+ ee.setData({ data: t.data.data, });
+ })
+ }else{
+ ee.setData({ data: t.data.data, });
+ }
+
+ /*---获取活动的重表---*/
+ //调用接口判断订单优惠,
+ getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+ee.data.gid+"/2", {}).then(res => {
+ if(res.data.code==0){
+ var r_data=res.data.data;
+ th.loop_promise(0,r_data.collocationList,function(){
+ ee.setData({
+ collocationGoods:r_data.collocationPromList,
+ collocationList:r_data.collocationList,
+ })
+ })
+ }
+ })
+
+ //获取统一条形码,普通商品和优惠促销的商品
+ if ( t.data.data.prom_type == 5){
+ //默认门店要拿下门店库存
+ if(that.data.sales_rules==2 && that.data.is_newsales_rules){
+ //--等待某个值只运行---,这里有可能因为导航的时间太久,而不能计算门店库存
+ getApp().waitfor2(that,"wait_for_user_store","fir_def_store",function(){
+ if(th.data.fir_def_store && th.data.fir_def_store.pickup_id ){
+ var lock=0,plist=null;
+ //先读取门店的lock,采用链式写法,少用await
+ getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
+ data:{store_id:os.stoid,wareId:ee.data.data.goods_id,storageId:that.data.fir_def_store.pickup_id,pageSize:1000}
+ }).then(res=>{
+ if(res.data.code==0 && res.data.data.total>0){
+ for(var i in res.data.data.pageData)
+ lock+=res.data.data.pageData[i].outQty
+ }
+ //---通过接口获取门店的线下库存信息--
+ return getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
+ data:{storageNos:that.data.fir_def_store.pickup_no,wareIds:encodeURIComponent(th.data.data.erpwareid),storeId:os.stoid}
+ })
+ }).then(res=>{
+ if(res.data.code==0 && res.data.data.total>0){
+ plist=res.data.data.pageData[0];
+ }
+ if(plist && plist.CanOutQty-lock>0){
+ that.data.fir_def_store.CanOutQty=plist.CanOutQty-lock;
+ }else{
+ that.data.fir_def_store.CanOutQty=0;
+ }
+ //--给门店赋值线下库存--
+ th.setData({def_pick_store:that.data.fir_def_store});
+ //获取门店
+ ee.get_sto();
+ })
+ }else{
+ //--获取门店--
+ ee.get_sto();
+ }
+ })
+ }else{
+ //获取门店
+ ee.get_sto();
+ }
+
+ }
+ else {
+ return getApp().my_warnning("商品没有搭配购的活动",0,th)
+ }
+ }
+ }
+ });
+ },1000)
+ },
+
+ onUnload: function() {},
+ onHide: function() {
+ clearInterval(this.data.t_time);
+ },
+ //--滚动到顶部--
+ doScrollTop: function() {
+ wx.pageScrollTo({
+ scrollTop: 0
+ });
+ },
+ //------------加入购物车--------------
+ addCart: function(t) {
+ var th = this;
+ th.add_cart_func(t);
+
+ },
+ //加入购物的函数
+ add_cart_func: function(t) {
+ var i = getApp().request;
+ if (oo.user_id == null) {
+ return s.my_warnning("还未登录!", 0, this);
+ }
+ var e = this,
+ th = e,
+ a = 0,
+ o = this.data.data;
+ a = o.goods_id;
+
+ //----------添加到购物车时,要判断限购数量,--------
+ e.get_buy_num(o, function(ee) {
+ //---判断商品是否超出限购---
+ if (th.data.g_buy_num != null && th.data.data.viplimited > 0) {
+ if (th.data.goodsInputNum + th.data.g_buy_num.get(th.data.data.goods_id) > th.data.data.viplimited) {
+ wx.showModal({
+ title: '提示',
+ content: '超出商品限购'
+ });
+ return false;
+ }
+ }
+ //---判断商品是否超出活动限购---
+ if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) {
+ if (th.data.goodsInputNum + th.data.prom_buy_num > th.data.prom_buy_limit) {
+ wx.showModal({
+ title: '提示',
+ content: '超出商品活动限购'
+ });
+ return false;
+ }
+ }
+
+ if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th);
+ if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined)
+ this.setData({
+ sto_sele_name: ""
+ });
+ if (th.data.sto_sele_name == "") return s.my_warnning("请选择门店", 0, th);
+
+ //--------------此时操作的数据------------
+ var newd = {
+ goods_id: o.goods_id,
+ goods_num: th.data.goodsInputNum,
+ pick_id: th.data.sto_sele_id,
+ user_id: oo.user_id,
+ store_id: th.data.stoid,
+ goods_price: o.shop_price,
+ member_goods_price: o.shop_price,
+ goods_name: o.goods_name,
+ goods_sn: o.goods_sn,
+ sku: o.sku,
+ prom_type: 5,
+ prom_id:o.prom_id
+ };
+
+ //-----如果是秒杀,团购,积分购,拼团-----
+ if (th.data.data.prom_type != 5) {
+ return s.my_warnning("商品不是搭配活动!", 0, th);
+ }else{
+ //---如果是线下门店销售的时候---
+ if(th.data.sales_rules==2){
+ var pick=th.get_pick_from_list(th.data.sto_sele_id)
+ //---通过接口获取门店的线下库存信息--
+ getApp().request.get("/api/weshop/goods/getWareStorages",{
+ data:{storageNos:pick.pickup_no,wareIds:encodeURIComponent(th.data.data.erpwareid),storeId:os.stoid},
+ success:function(res){
+ if(res.data.code==0){
+ if(res.data.data.pageData.length>0){
+ var CanOutQty=res.data.data.pageData[0].CanOutQty;
+ if(CanOutQty0){
+ var lock=0;
+ for(var i in res_data.data.data.pageData){
+ lock+=res_data.data.data.pageData[i].outQty;
+ }
+
+ if(CanOutQty<=lock){
+ return s.my_warnning("库存不足!", 0, th);
+ }
+ th.add_cart_next(e,t,a,o,newd,CanOutQty-lock);
+ }else{
+ th.add_cart_next(e,t,a,o,newd,CanOutQty);
+ }
+ }
+ })
+ }else{
+ return s.my_warnning("库存不足!", 0, th);
+ }
+
+ }
+ }
+ })
+ }else{
+ if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
+ if (o.store_count now){
+ var card_price=o[getApp().globalData.userInfo['card_field']];
+ //如果会员有等级价
+ if(getApp().globalData.userInfo['card_field']!=undefined && getApp().globalData.userInfo['card_field']!=null
+ && getApp().globalData.userInfo['card_field']!="" && card_price>0){
+ newd.goods_price=card_price;
+ }
+ }
+ }
+ }
+
+ newd['pick_name'] = th.data.sto_sele_name;
+ newd['pick_dis'] = th.data.sto_sele_distr;
+ newd["collocation_goods"]=th.data.sele_collocation;
+
+ th.buyNow(newd);
+
+ },
+
+ //----------立即购买-----------
+ buyNow: function(e) {
+ s.set_b_now(e);
+ wx.redirectTo({
+ url: "/pages/cart/cart2/cart2?is_bnow=1&goods_id=" + e.goods_id,
+ });
+ },
+
+ //----------增加购买数量-----------
+ addCartNum: function(t) {
+ this.checkCartNum(this.data.goodsInputNum + 1);
+ },
+ //----------减少购买数量-----------
+ subCartNum: function(t) {
+ this.checkCartNum(this.data.goodsInputNum - 1);
+ },
+ //----------输入框输入购买数量-----------
+ inputCartNum: function(t) {
+ this.checkCartNum(Number(t.detail.value));
+ },
+
+ //------检查数量是不是超出限购------
+ checkCartNum: function(t) {
+ var th = this;
+ this.get_buy_num(this.data.data, async function() {
+
+ //--判断商品是否超出限购--
+ if (th.data.g_buy_num != null && th.data.data.viplimited > 0) {
+
+ var gd_buy_num=th.data.g_buy_num.get(th.data.data.goods_id);
+
+ if (t + gd_buy_num > th.data.data.viplimited) {
+ wx.showModal({
+ title: '超出商品限购',
+ });
+
+ var num= th.data.data.viplimited-gd_buy_num;
+ if(num<0) num=0;
+ th.setData({goodsInputNum:num})
+ return false;
+ }
+ }
+
+ //--判断商品是否超出活动限购--
+ if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0) {
+ if (t + th.data.prom_buy_num > th.data.prom_buy_limit) {
+ wx.showModal({
+ title: '超出商品活动限购',
+ });
+
+ var num=th.data.prom_buy_limit- th.data.prom_buy_num ;
+ if(num<0) num=0;
+ th.setData({goodsInputNum:num})
+ return false;
+ }
+ }
+
+ if (th.data.data.prom_type == 1 || th.data.data.prom_type == 6) {
+ var redis_num = 0;
+ //------判断活动是否抢光-----
+ await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" +
+ os.stoid + "/" + th.data.data.prom_type + "/" + th.data.data.prom_id, {
+ 1: 1
+ }).then(res => {
+ redis_num = res.data.data;
+ });
+
+ if (t > redis_num) {
+ wx.showModal({
+ title: '超出商品活动库存',
+ });
+ th.setData({goodsInputNum:redis_num})
+ return false;
+ }
+
+ }
+
+ var e = th.data.data.store_count;
+ if(th.data.sales_rules==2){
+ if(!th.data.def_pick_store){
+ wx.showModal({ title: '请选择门店', });
+ return false;
+ }else{
+ e=th.data.def_pick_store.CanOutQty;
+ }
+ }
+
+ //库存不足,不增加
+ if(e e || 0 == e ? t = e : t < 1 && (t = 1);
+ th.setData({ goodsInputNum: t });
+
+ })
+ },
+
+ closeSpecModal: function() {
+ var th=this;
+ this.setData({
+ openSpecModal: !1,
+ openSpecModal_pt: !1
+ });
+ },
+ openSpecModel: function(t) {
+ var th = this;
+ this.setData({
+ store: 0,
+ choice_sort_store: 0,
+ sort_store: 0,
+ })
+ //--先判断会员状态--
+ var user_info = getApp().globalData.userInfo;
+ if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
+ wx.navigateTo({
+ url: '/pages/getphone/getphone',
+ })
+ return false;
+ }
+
+ var collocationList=this.data.collocationList;
+ this.data.sele_collocation=null;
+ for(var i in collocationList){
+ if(collocationList[i].sele){
+ collocationList[i].goods_num=1;
+ collocationList[i].prom_type=5;
+ collocationList[i].prom_id=th.data.data.prom_id;
+ collocationList[i].goods_price=collocationList[i].price;
+ collocationList[i].is_collocation=1;
+ if(!th.data.sele_collocation) th.data.sele_collocation=new Array();
+ th.data.sele_collocation.push(collocationList[i]);
+ }
+ }
+ if(!th.data.sele_collocation){
+ return s.my_warnning("请选择搭配商品!", 0, th);
+ }
+
+
+ this.setData({
+ openSpecModal: !0,
+ });
+ },
+ closePromModal: function() {
+ this.setData({
+ openPromModal: !1
+ });
+ },
+
+ openPromModal: function() {
+ this.setData({
+ openPromModal: !0
+ });
+ },
+
+ //--点击分享事件---
+ onShareAppMessage: function(t) {
+ var th = this;
+ var price = th.data.data.shop_price;
+ if (th.data.prom_act) {
+ price = th.data.prom_act.price;
+ }
+ var title= th.data.data.goods_name;
+ var img=th.data.data.original_img;
+ if(th.data.prom_type==6){
+ title=th.data.prom_act.share_title;
+ img=th.data.iurl+th.data.prom_act.share_imgurl;
+ }
+
+ return {
+ title: price + "元 " +title,
+ path: "/pages/goods/goodsInfo/goodsInfo?goods_id=" + th.data.gid,
+ imageUrl: img,
+ }
+
+ },
+
+ //-----图片失败,默认图片-----
+ bind_bnerr: function(e) {
+ var _errImg = e.target.dataset.errorimg;
+ var _errObj = {};
+ _errObj[_errImg] = this.data.iurl + "/miniapp/images/default_g_img.gif";
+ this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
+ },
+
+ //-----图片失败,默认图片-----
+ bind_bnerr2: function(e) {
+
+ var _errImg = e.target.dataset.errorimg;
+ var _errObj = {};
+ _errObj[_errImg] = this.data.iurl + "/miniapp/images/hui_hear_pic.png"
+ this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
+ },
+
+ //---------拿出门店分类和门店------------
+ get_sto(e) {
+ var th = this,that=this;
+ var timer_get = setInterval(function() {
+ if (th.data.is_get_local_ok == 0) return false;
+ var dd = null,
+ i = getApp().request;
+ var g_distr_type = th.data.data.distr_type;
+ if (g_distr_type != 0) {
+ dd = {
+ store_id: o.stoid,
+ distr_type: g_distr_type,
+ isstop: 0,
+ pageSize: 2000
+ }
+ } else {
+ dd = {
+ store_id: o.stoid,
+ isstop: 0,
+ pageSize: 2000
+ }
+ }
+ //如果有距离的话
+ if (th.data.lat != null) {
+ dd.lat = th.data.lat;
+ dd.lon = th.data.lon;
+ }
+ clearInterval(timer_get);
+ //----------获取门店----------------
+ getApp().request.promiseGet("/api/weshop/pickup/list", {
+ data: dd,
+ }).then(res => {
+ var e = res;
+ if (e.data.code == 0) {
+
+ //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店
+ if(dd.lat && !th.data.def_pick_store && th.data.bconfig.is_sort_storage){
+ th.setData({
+ def_pick_store:e.data.data.pageData[0],
+ sto_sele_name: e.data.data.pageData[0].pickup_name,
+ sto_sele_id: e.data.data.pageData[0].pickup_id,
+ sto_sele_distr: e.data.data.pageData[0].distr_type
+ });
+ th.data.fir_def_store=e.data.data.pageData[0];
+ }
+
+ //-- 如果有默认选择门店的时候,要把默认门店放在第一位 --
+ if (th.data.def_pick_store) {
+ for (var k = 0; k < e.data.data.pageData.length; k++) {
+ if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) {
+ e.data.data.pageData.splice(k, 1); //删除
+ break;
+ }
+ }
+ e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加
+ }
+
+
+ th.setData({all_pick_list:e.data.data.pageData});
+
+ //--获取线下库存,而且不是新的门店规则,同时不能是活动--
+ if(th.data.sales_rules==2 && !th.data.is_newsales_rules && th.data.prom_type!=1 && th.data.prom_type!=6){
+ setTimeout(function(){
+ th.deal_pickup_dline(e);
+ },800)
+ }else{
+ setTimeout(function(){
+ th.deal_pickup(e); //--普通门店排版--
+ },800)
+ }
+ }
+ })
+ }, 200)
+ },
+
+ //------------处理门店---------------
+ deal_pickup(e){
+ var th=this;
+ //单总量超出5个的时候
+ if (e.data.data.total > 5) {
+ getApp().request.get("/api/weshop/storagecategory/page", {
+ data: {
+ store_id: o.stoid,
+ is_show: 1,
+ pageSize: 1000
+ },
+ success: function(ee) {
+ if (ee.data.code == 0) {
+ if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0) {
+ var def_arr = new Array();
+ var ishas = 0;
+ //-- 开始就看5个门店 --
+ for (var k = 0; k < 5; k++) {
+ if (k == e.data.data.pageData.length) break;
+ def_arr.push(e.data.data.pageData[k]);
+ }
+
+ th.setData({
+ def_pickpu_list: def_arr,
+ pickpu_list: ee.data.data.pageData
+ });
+ var sto_cate = ee.data.data.pageData;
+ var sto_arr = e.data.data.pageData;
+ var newarr = new Array();
+ var qita = new Array();
+
+ //----要进行门店分组--------
+ for (var i = 0; i < sto_arr.length; i++) {
+ //找一下这个门店有没有在分类数组内
+ var find2 = 0,
+ find2name = "";
+ for (var m = 0; m < sto_cate.length; m++) {
+ if (sto_arr[i].category_id == sto_cate[m].cat_id) {
+ find2 = sto_cate[m].cat_id;
+ find2name = sto_cate[m].cat_name;
+ break;
+ }
+ }
+
+ if (newarr.length > 0) {
+ var find = 0;
+ //如果有找到,那门店就在这个分组内,否则,分类就要排在其他
+ if (find2 != 0) {
+ for (var ii = 0; ii < newarr.length; ii++) {
+ if (sto_arr[i].category_id == newarr[ii].cat_id) {
+ newarr[ii].s_arr.push(sto_arr[i]);
+ find = 1;
+ break;
+ }
+ }
+ if (find == 0) {
+ var arr0 = new Array();
+ arr0.push(sto_arr[i]);
+ var item = {
+ cat_id: find2,
+ name: find2name,
+ s_arr: arr0
+ };
+ newarr.push(item);
+ }
+ } else {
+ qita.push(sto_arr[i]);
+ }
+ } else {
+ //如果有找到,那门店就在这个分组内,否则,分类就要排在其他
+ if (find2 != 0) {
+ var arr0 = new Array();
+ arr0.push(sto_arr[i]);
+ var item = {
+ cat_id: find2,
+ name: find2name,
+ s_arr: arr0
+ };
+ newarr.push(item);
+ } else {
+ qita.push(sto_arr[i]);
+ }
+ }
+ }
+
+ //----安排其他的分类-----
+ if (qita.length > 0) {
+ var item = {
+ cat_id: -1,
+ name: "其他",
+ s_arr: qita
+ };
+ newarr.push(item);
+ }
+ th.setData({
+ is_show_sto_cat: 1,
+ all_sto: newarr
+ });
+
+ } else {
+ th.setData({
+ is_show_sto_cat: -1,
+ only_pk: e.data.data.pageData
+ });
+ //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------
+ if (!th.data.def_pick_store) {
+ th.setData({def_pick_store:e.data.data.pageData[0]})
+ }
+ }
+ } else {
+ th.setData({
+ is_show_sto_cat: -1,
+ only_pk: e.data.data.pageData
+ });
+ //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------
+ if (!th.data.def_pick_store) {
+ th.setData({def_pick_store:e.data.data.pageData[0]})
+ }
+
+ }
+ }
+ });
+ } else {
+ th.setData({
+ is_show_sto_cat: 0,
+ only_pk: e.data.data.pageData
+ });
+ //-----如果没有默认门店,要取第一个门店作为默认店------
+ if (!th.data.def_pick_store && th.data.bconfig.is_sort_storage) {
+ th.setData({
+ def_pick_store:e.data.data.pageData[0],
+ sto_sele_name: e.data.data.pageData[0].pickup_name,
+ sto_sele_id: e.data.data.pageData[0].pickup_id,
+ sto_sele_distr: e.data.data.pageData[0].distr_type
+ })
+ }
+ }
+
+ },
+ //------------处理线下门店库存--------
+ deal_pickup_dline(e){
+ var pkno=[],th=this;
+ if(this.data.def_pick_store){
+ pkno.push(this.data.def_pick_store.pickup_no);
+ }
+ for(var i in e.data.data.pageData){
+ var item=e.data.data.pageData[i];
+ if(pkno.indexOf(item.pickup_no)<0)
+ pkno.push(item.pickup_no);
+ }
+ var pkno_str=pkno.join(",");
+ var o_plist=e.data.data.pageData;
+ var new_list=[];
+ var is_find_def_store=0;
+
+ var lock=[];
+ //先读取门店的lock,采用链式写法,少用await
+ getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
+ data:{store_id:os.stoid,wareId:th.data.data.goods_id,pageSize:1000}
+ }).then(res=>{
+ if(res.data.code==0 && res.data.data.total>0){
+ lock=res.data.data.pageData
+ }
+ //---通过接口获取门店的线下库存信息--
+ return getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
+ data:{storageNos:pkno_str,wareIds:encodeURIComponent(th.data.data.erpwareid),storeId:os.stoid}
+ })
+ }).then(res=>{
+ if(res.data.code==0){
+ if(res.data.data.pageData){
+ var plist=res.data.data.pageData;
+ var def_pick_store=th.data.def_pick_store;
+ //以原来的数组为外循环,保证距离的顺序
+ for(var kk in o_plist){
+ for(var ii in plist){
+ //线下的门店小心
+ var n_item=plist[ii];
+ if(n_item.StorageNo==o_plist[kk].pickup_no){
+
+ //拿到锁库的数量
+ var lock_num=th.find_lock_num(o_plist[kk].pickup_id,lock);
+ //可出库数大于预出库库存的数量,可以判断为有库存
+ if(n_item.CanOutQty>lock_num){
+ o_plist[kk].CanOutQty=n_item.CanOutQty-lock_num;
+ new_list.push(o_plist[kk]);
+ //如果找到默认门店
+ if(th.data.fir_def_store && n_item.StorageNo==th.data.fir_def_store.pickup_no){
+ th.data.fir_def_store.CanOutQty=n_item.CanOutQty-lock_num;
+ if(def_pick_store.pickup_id==th.data.fir_def_store.pickup_id)
+ th.setData({def_pick_store:th.data.fir_def_store})
+ is_find_def_store=1;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ //数据组装下
+ var em={};em.data={};em.data.data={};
+ em.data.data.total=new_list.length;
+ em.data.data.pageData=new_list;
+
+ if(th.data.fir_def_store && !is_find_def_store && th.data.fir_def_store.pickup_id){
+ th.data.fir_def_store.CanOutQty=0;
+ //--当选择的门店是客户默认的门店的时候--
+ if(th.data.def_pick_store && th.data.fir_def_store.pickup_id==th.data.def_pick_store.pickup_id) {
+ th.setData({def_pick_store:th.data.fir_def_store});
+ em.data.data.pageData.unshift(th.data.def_pick_store);
+ }else{
+ em.data.data.pageData.splice(1,0,th.data.fir_def_store);
+ }
+ }
+
+ //---把数组组装进去---
+ th.deal_pickup(em);
+ }else{
+ th.setData({def_pick_store:null,all_sto:null,only_pk:null})
+ }
+ }else{
+ th.setData({def_pick_store:null,all_sto:null,only_pk:null})
+ }
+ })
+ },
+
+ find_lock_num(pick_id,lock){
+ var lock_num=0;
+ if(!lock) return 0;
+ if(lock.length<0) return 0;
+ for(var i in lock){
+ if(pick_id==lock[i].pickupId){
+ lock_num+=lock[i].outQty;
+ }
+ }
+ return lock_num;
+ },
+
+ //----------取货门店被点击的效果------
+ getmendian: function(t) {
+ this.setData({
+ ismend: 1,
+ });
+ },
+ //----------隐藏取货门店,选取门店----------
+ hidemend: function(e) {
+ var pid = e.target.dataset.p_id;
+ var pname = e.target.dataset.p_name;
+ var p_distr_t = e.target.dataset.p_dis;
+ this.setData({
+ ismend: 0,
+ is_sec_mend: 0,
+ sto_sele_id: pid,
+ sto_sele_name: pname,
+ sto_sele_distr: p_distr_t
+ });
+ },
+ //------显示取货2级----------
+ show_sec: function(t) {
+ var index = t.target.dataset.index;
+ var item = this.data.all_sto[index];
+ this.setData({
+ is_sec_mend: 1,
+ sec_sto: item
+ });
+ },
+ //------隐藏取货门店2级----
+ hide_sec_mend: function() {
+ this.setData({
+ is_sec_mend: 0,
+ });
+ },
+
+ //加载更多是靠这个函数
+ onReachBottom: function() {
+
+ },
+ //--------检查是搭配促销活动是不是结束-------
+ async check_prom(gid, prom_type, prom_id) {
+
+ },
+
+ //-------------获取购买数量的总函数----------------
+ get_buy_num: function(gd, func) {
+ var map = this.data.g_buy_num,
+ th = this,
+ user_id = getApp().globalData.user_id;
+ if (user_id == null) {
+ map.set(gd.goods_id, 0);
+ th.setData({
+ g_buy_num: map,
+ prom_buy_num: 0,
+ });
+ "function" == typeof func && func();
+ return false;
+ }
+
+ if (map.has(gd.goods_id)) {
+ "function" == typeof func && func();
+ } else {
+ //----获取商品购买数----
+ getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", {
+ data: {
+ store_id: os.stoid,
+ user_id: user_id,
+ goods_id: gd.goods_id
+ },
+ success: function(t) {
+ if (t.data.code == 0) {
+ var g_buy_num = t.data.data.goodsbuynum;
+ if (gd.prom_type == 1 || gd.prom_type == 2 || gd.prom_type == 4 || gd.prom_type == 6) {
+ //----获取活动购买数----
+ getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", {
+ data: {
+ store_id: os.stoid,
+ user_id: user_id,
+ goods_id: gd.goods_id,
+ prom_type: gd.prom_type,
+ prom_id: gd.prom_id
+ },
+ //-----获取-----
+ success: function(tt) {
+ if (tt.data.code == 0) {
+ map.set(gd.goods_id, g_buy_num);
+ th.setData({
+ g_buy_num: map,
+ prom_buy_num: tt.data.data.goodsbuynum,
+ });
+ "function" == typeof func && func();
+ }
+ }
+ });
+ } else {
+ map.set(gd.goods_id, g_buy_num);
+ th.setData({
+ g_buy_num: map
+ });
+ "function" == typeof func && func();
+ }
+ }
+ }
+ });
+ }
+ },
+
+ //--跳转到商品详情页面--
+ go_goods: function(e) {
+ var gid = e.currentTarget.dataset.gid;
+ var url = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + gid;
+ getApp().goto(url);
+ },
+
+ // 选择门店
+ choice_store: function(ee) {
+ var th = this;
+ var ind=ee.currentTarget.dataset.ind;
+ var bconfig = th.data.bconfig;
+
+ if(!th.data.only_pk && !th.data.def_pickpu_list){
+ getApp().confirmBox("门店库存不足", null, 25000, !1);
+ return false;
+ }
+
+ if(th.data.only_pk && !th.data.only_pk.length){
+ getApp().confirmBox("门店库存不足", null, 25000, !1);
+ return false;
+ }
+ if(th.data.def_pickpu_list && !th.data.def_pickpu_list.length){
+ getApp().confirmBox("门店库存不足", null, 25000, !1);
+ return false;
+ }
+
+
+ if (bconfig.is_sort_storage) {
+ wx.getLocation({
+ type: 'wgs84',
+ success: function(res) {
+
+ th.data.lat = res.latitude;
+ th.data.lon = res.longitude;
+ th.data.is_get_local_ok = 1;
+ th.setData({
+ is_gps: 1
+ });
+ //th.onShow();
+ //th.get_sto();
+ },
+ fail: function(res) {
+ //th.onShow();
+ th.data.is_get_local_ok = 1;
+ th.get_sto();
+ if (res.errCode == 2) {
+ th.setData({
+ is_gps: 0
+ });
+ if (th.data.is_gps == 0) {
+ getApp().confirmBox("请开启GPS定位", null, 25000, !1);
+ }
+ } else {
+ th.setData({
+ is_gps: "3"
+ });
+ }
+
+ }
+ })
+ }else{
+ th.data.is_get_local_ok = 1;
+ }
+
+ if(ind!=undefined && ind!=null ){
+ this.setData({
+ open_ind_store: ind,
+ store: 1,
+ openSpecModal: !1,
+ openSpecModal_pt: !1
+ })
+ }else{
+ this.setData({
+ store: 1,
+ openSpecModal: !1,
+ openSpecModal_pt: !1
+ })
+ }
+ },
+ //关闭选择门店
+ close_popup: function(e) {
+ var th=this;
+ this.setData({
+ store: 0,
+ choice_sort_store: 0,
+ sort_store: 0,
+ fir_pick_index:0,
+ sec_pick_index:0
+ })
+
+ var openindstore=this.data.open_ind_store;
+ if (openindstore == 1) {
+ th.setData({
+ openSpecModal: !0,
+ openSpecModal_ind: openindstore,
+ });
+ } else if (openindstore == 2) {
+ th.setData({
+ openSpecModal: !0,
+ openSpecModal_ind: openindstore,
+ });
+ }
+ else if (openindstore == 4) { //4就是拼团
+ th.setData({
+ openSpecModal_pt: 1, //打开拼团购买界面
+ store: 0, //关闭门店
+ choice_sort_store: 0, //关闭门店2级
+ sort_store: 0, //关闭门店2级
+ });
+ }
+ else {
+ th.setData({
+ store: 0,
+ choice_sort_store: 0,
+ sort_store: 0
+ })
+ }
+
+ },
+
+ //选择更多门店
+ more_store: function() {
+ this.setData({
+ sort_store: 1
+ });
+ },
+
+ //---选择分类门店---
+ choice_sort_store: function(e) {
+ var index = e.currentTarget.dataset.index;
+ var region_name = e.currentTarget.dataset.region;
+ var item = this.data.all_sto[index];
+ this.setData({
+ region_name: region_name,
+ sort_store: 0,
+ choice_sort_store: 1,
+ sec_sto: item,
+ sec_pick_index: 0
+ });
+ },
+
+ choose_for_store_fir: function(e) {
+ var index_c = e.currentTarget.dataset.ind;
+ var th=this;
+ th.setData({
+ fir_pick_index: index_c
+ })
+
+ },
+
+ //如果开启线下库存,已经急速库存才会使用
+ async check_the_pick(item,func){
+ var th=this;
+ var goodsinfo=th.data.data;
+ var erpwareid=goodsinfo.erpwareid;
+ var plist=null;
+ var lock=0;
+
+ //---如果是活动的时候---
+ if(th.data.prom_type==1 || th.data.prom_type==6){
+ func(); return false;
+ }
+
+ if(this.data.sales_rules!=2){
+ func();
+ }else{
+
+ //先读取门店的lock
+ await getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
+ data:{store_id:os.stoid,wareId:goodsinfo.goods_id,storageId:item.pickup_id,pageSize:1000}
+ }).then(res=>{
+ if(res.data.code==0 && res.data.data.total>0){
+ for(var i in res.data.data.pageData )
+ lock+=res.data.data.pageData[i].outQty;
+ }
+ })
+ //读取线下的门店库存
+ await getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
+ data:{storageNos:item.pickup_no,wareIds:encodeURIComponent(erpwareid),storeId:os.stoid}
+ }).then(res=>{
+ if(res.data.code==0 && res.data.data.total>0){
+ plist=res.data.data.pageData[0];
+ }
+ })
+
+ if(plist && plist.CanOutQty-lock>0){
+ item.CanOutQty=plist.CanOutQty-lock;
+ func();
+ return false;
+ }
+ getApp().my_warnning(item.pickup_name+"库存不足!", 0, th);
+
+ }
+ },
+
+ //确定def_pick为选择的门店
+ sure_pick: function(e) {
+ var th = this;
+ var item = null;
+ var openindstore = th.data.open_ind_store;
+
+ if (th.data.choice_sort_store == 0) {
+ var index = th.data.fir_pick_index;
+ if (th.data.is_show_sto_cat == 1) {
+ item = th.data.def_pickpu_list[index];
+ } else {
+ item = th.data.only_pk[index]; //当没有门店分类的时候
+ }
+
+ } else {
+ var index = th.data.sec_pick_index;
+ item = th.data.sec_sto.s_arr[index];
+ }
+
+ //--回调函数的用法--
+ th.check_the_pick(item,function(){
+ th.setData({
+ def_pick_store: item,
+ sto_sele_name: item.pickup_name,
+ sto_sele_id: item.pickup_id,
+ sto_sele_distr: item.distr_type,
+ store: 0,
+ choice_sort_store: 0,
+ fir_pick_index: 0
+ });
+
+ if (openindstore == 1) {
+ th.setData({
+ openSpecModal: !0,
+ openSpecModal_ind: openindstore,
+ });
+ } else if (openindstore == 2) {
+ th.setData({
+ openSpecModal: !0,
+ openSpecModal_ind: openindstore,
+ });
+ }
+ else if (openindstore == 4) { //4就是拼团
+ th.setData({
+ openSpecModal_pt: 1, //打开拼团购买界面
+ store: 0, //关闭门店
+ choice_sort_store: 0, //关闭门店2级
+ sort_store: 0, //关闭门店2级
+ });
+ }
+ else {
+ th.setData({
+ store: 0,
+ choice_sort_store: 0,
+ sort_store: 0
+ })
+ }
+ })
+ },
+ //---点击二级之后的选择---
+ choose_for_store: function(e) {
+ var index_c = e.currentTarget.dataset.ind;
+ var th=this;
+ th.setData({
+ sec_pick_index: index_c,
+ fir_pick_index: index_c
+ })
+ },
+
+ //把选择的门店设置成默认的门店def_pick
+ set_def_pick: function(e) {
+ var th = this;
+ var item = null;
+ if (th.data.choice_sort_store == 0) {
+ var index = th.data.fir_pick_index;
+ if (th.data.is_show_sto_cat == 1) {
+ item = th.data.def_pickpu_list[index];
+ } else {
+ item = th.data.only_pk[index]; //当没有门店分类的时候
+ }
+ } else {
+ var index = th.data.sec_pick_index;
+ item = th.data.sec_sto.s_arr[index];
+ }
+
+ //先设置之前,要判断是不是有库存
+ th.check_the_pick(item,function(){
+ var store_id = o.stoid;
+ var user_id = getApp().globalData.user_id;
+ var def_pickup_id = item.pickup_id;
+
+ getApp().request.put('/api/weshop/users/update', {
+ data: {
+ user_id,
+ def_pickup_id
+ },
+ success: function(res) {
+ if (res.data.code == 0) {
+ if (th.data.choice_sort_store == 0) th.setData({
+ fir_pick_index: 0
+ });
+ getApp().globalData.pk_store = item;
+ } else {
+ //s.showWarning("设置默认门店地址失败", null, 500, !1);
+ getApp().my_warnning("设置默认门店地址失败",0,th)
+ }
+
+ }
+ });
+
+ th.setData({
+ def_pick_store: item,
+ sto_sele_name: item.pickup_name,
+ sto_sele_id: item.pickup_id,
+ sto_sele_distr: item.distr_type,
+ store: 0,
+ choice_sort_store: 0
+ });
+
+ var openindstore = th.data.open_ind_store;
+ if (openindstore == 1) {
+ th.setData({
+ openSpecModal: !0,
+ openSpecModal_ind: openindstore,
+ store: 0,
+ choice_sort_store: 0,
+ sort_store: 0,
+ });
+ } else if (openindstore == 2) {
+ th.setData({
+ openSpecModal: !0,
+ openSpecModal_ind: openindstore,
+ store: 0,
+ choice_sort_store: 0,
+ sort_store: 0,
+ });
+ }
+ else if (openindstore == 4) { //4就是拼团
+ th.setData({
+ openSpecModal_pt: 1, //打开拼团购买界面
+ store: 0, //关闭门店
+ choice_sort_store: 0, //关闭门店2级
+ sort_store: 0, //关闭门店2级
+ });
+ }
+
+ else {
+ th.setData({
+ store: 0,
+ choice_sort_store: 0,
+ sort_store: 0,
+ })
+ }
+ })
+ },
+
+ wait_for_store_config: function() {
+ var th = this;
+ th.data.t_time = setInterval(function() {
+ if (th.data.bconfig == null) false;
+ var e = th.data.bconfig;
+ if (e.is_sort_storage) {
+ wx.getLocation({
+ type: 'wgs84',
+ success: function(res) {
+ th.data.lat = res.latitude;
+ th.data.lon = res.longitude;
+ th.data.is_get_local_ok = 1;
+ },
+ fail: function(res) {
+ if (res.errCode == 2) {
+ th.setData({
+ is_gps: 0
+ });
+ if (th.data.is_gps == 0) {
+ getApp().confirmBox("请开启GPS定位", null, 10000, !1);
+ }
+
+ } else {
+ th.setData({
+ is_gps: "3"
+ });
+ }
+ th.data.is_get_local_ok = 1;
+ }
+ })
+ } else {
+ th.data.is_get_local_ok = 1;
+ }
+ clearInterval(th.data.t_time);
+ }, 500)
+ },
+
+ //-- 根据ID拿出门店 --
+ get_pick_from_list(pid){
+ var all_pick_list=this.data.all_pick_list;
+ for(var i in all_pick_list){
+ var item=all_pick_list[i];
+ if(item.pickup_id==pid){
+ return item;
+ }
+ }
+ },
+
+ //--- 获取卡类列表 ---
+ getPlusCardType: function (func) {
+ var storid = os.stoid;
+ var th = this;
+ getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => {
+ var plusCard = res.data.data;
+ var arr = [1219, 2089, 3031];
+ var new_arr = new Array();
+ var card_name_map=new Map();
+ for (var i = 0; i < plusCard.length; i++) {
+ var name="card"+plusCard[i].CorrPrice.toLowerCase();
+ card_name_map.set(name,plusCard[i].CardName);
+ }
+
+ var ob={"card_list":plusCard,"name_map":card_name_map};
+ func(ob);
+ })
+ },
+
+ //递归获取商品
+ loop_promise:function(x,arr,func){
+ var th=this;
+ getApp().request.promiseGet("/api/weshop/goods/get/" + o.stoid + "/" + arr[x].goods_id, {}).then(res => {
+ arr[x].goods_spec=res.data.data.goods_spec;
+ arr[x].goods_color=res.data.data.goods_color;
+ arr[x].original_img=res.data.data.original_img;
+ arr[x].shop_price=res.data.data.shop_price;
+ if(x==arr.length-1){
+ func(arr); //循环再最后
+ }else{
+ ++x;
+ th.loop_promise(x,arr,func);
+ }
+ })
+ },
+
+ //图片失败,默认图片
+ bind_bnerr3: function(e) {
+ var _errImg = e.target.dataset.errorimg;
+ var _errObj = {};
+ _errObj[_errImg] = "/public/images/default_goods_image_240.gif";
+ this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
+ },
+
+ set_sele:function (e) {
+ var index=e.currentTarget.dataset.ind;
+ var set=e.currentTarget.dataset.set;
+ var text="collocationList["+index+"].sele";
+ var ob={};
+ ob[text]= parseInt(set);
+ this.setData(ob);
+
+ var price=parseFloat(this.data.collocationList[index].price);
+ var cut_pirce=this.data.collocationList[index].shop_price-price;
+ if(set==1){
+ this.data.dp_price=parseFloat(this.data.dp_price)+price;
+ this.data.cut_price=this.data.cut_price+cut_pirce;
+ }else{
+ this.data.dp_price=parseFloat(this.data.dp_price)-price;
+ this.data.cut_price=this.data.cut_price-cut_pirce;
+ }
+ price=price.toFixed(2);
+ cut_pirce=cut_pirce.toFixed(2);
+ this.setData({dp_price: this.data.dp_price,cut_price:this.data.cut_price});
+ }
+
+
+
+});
diff --git a/packageA/pages/prom_list/prom_list.json b/packageA/pages/prom_list/prom_list.json
new file mode 100644
index 0000000..fdf470d
--- /dev/null
+++ b/packageA/pages/prom_list/prom_list.json
@@ -0,0 +1,8 @@
+{
+ "navigationBarTitleText": "搭配促销商品",
+ "enablePullDownRefresh": false,
+ "usingComponents": {
+ "nav_box": "/components/nav_box/nav_box",
+ "warn": "/components/long_warn/long_warn"
+ }
+}
\ No newline at end of file
diff --git a/packageA/pages/prom_list/prom_list.wxml b/packageA/pages/prom_list/prom_list.wxml
new file mode 100644
index 0000000..9a4e7cc
--- /dev/null
+++ b/packageA/pages/prom_list/prom_list.wxml
@@ -0,0 +1,345 @@
+
+
+
+
+搭配商品
+
+
+
+
+
+
+
+ {{data.goods_name}}
+ 规格:{{tool.get_guige(data.goods_spec,data.goods_color)}}
+ ¥{{data.shop_price}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.goods_name}}
+ 规格:{{tool.get_guige(item.goods_spec,item.goods_color)}}
+ ¥{{item.price}}
+
+
+
+
+
+
+
+
+
+
+
+
+ 搭配价¥{{filters.toFix(data.shop_price+dp_price,2)}}
+ 已省¥{{filters.toFix(cut_price,2)}}
+
+
+ 立即购买
+
+
+
+
+
+
+
+
+
+
+
+ {{data.goods_name}}
+
+
+ ¥
+
+
+ {{data[card_field]}}
+
+
+ {{data.shop_price}}
+
+
+
+
+
+
+ 已售:{{data.sales_sum}}
+
+ 可售:{{def_pick_store.CanOutQty}}
+ 可售:0
+
+
+ 可售:{{data.store_count}}
+
+
+
+
+
+
+
+
+
+ {{def_pick_store.pickup_name}}
+
+ 距离:{{def_pick_store.distance>1000?filters.toFix(def_pick_store.distance/1000,2)+"km":filters.toFix(def_pick_store.distance,0)+"m"}}
+
+
+
+
+
+
+
+ 选择门店
+
+
+
+ 更多门店
+
+
+
+ (库存不足)
+
+ (库存不足)
+
+ (库存不足)
+
+
+
+ 地址:{{def_pick_store.fulladdress}}
+
+
+
+
+ 商品属性
+
+
+ {{data.gg}}
+
+
+
+
+
+
+ 购买数量
+
+ -
+
+ +
+
+
+
+
+
+
+ 库存不足
+
+
+
+
+
+ 库存不足
+
+
+
+ 库存不足
+
+
+
+ 请先选择门店
+
+
+
+
+
+ 库存不足
+
+
+ 立即购买
+
+
+
+
+
+ 库存不足
+
+
+ 立即购买
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/packageA/pages/prom_list/prom_list.wxss b/packageA/pages/prom_list/prom_list.wxss
new file mode 100644
index 0000000..e1d5663
--- /dev/null
+++ b/packageA/pages/prom_list/prom_list.wxss
@@ -0,0 +1,360 @@
+.head{ height: 100rpx; line-height: 100rpx; border-bottom: 1rpx solid #dddddd; padding: 0 20px }
+.goods_list .item{ height:240rpx}
+.r_box{width:670rpx;border-bottom: 1rpx solid #dddddd;height: 100%}
+.r_box_img{ width:210rpx;height: 210rpx; margin: 17rpx 0 }
+
+
+.join-cart {
+ position: fixed;
+ left: 0;
+ bottom: 0;
+ display: flex;
+ width: 100%;
+ height: 100rpx;
+ background-color: #fff;
+ text-align: center;
+ z-index: 9;
+ border-top: 4rpx solid #eee;
+}
+
+.buy_btn{ width: 200rpx; height: 100%; background-color:#c4182e; line-height: 100rpx; color: #fff}
+.f_hei{color: #333; font-size: 28rpx}
+
+.spec-model {
+ position: fixed;
+ bottom: 0;
+ z-index: 20;
+ background: white;
+ width: 100%;
+ /* padding: 0 30rpx; */
+ font-size: 32rpx;
+ box-sizing: border-box;
+ border-radius: 20rpx;
+ height: 72%;
+}
+
+.spec-model .pding{padding: 0 30rpx;}
+
+.spec-goods {
+ padding: 30rpx 0 20rpx;
+ float: left;
+ width: 100%;
+ border-bottom:2rpx solid #eee;
+}
+
+.spec-img {
+ float: left;
+ height: 186rpx;
+ width: 186rpx;
+ border: 4rpx solid #eee
+}
+
+.spec-goods-info {
+ float: left;
+ padding: 0 25rpx;
+ width: 400rpx;
+}
+
+.spec-goods-name {
+ font-size: 30rpx;
+ line-height: 35rpx;
+ height: 35rpx;
+ margin: 15rpx 20rpx 25rpx 0;
+ overflow: hidden;
+ text-overflow: ellipsis;color: #333;
+}
+
+.spec-goods-price {
+ color: #d60021;
+ font-size: 33rpx;
+ font-weight: bold;
+}
+
+.spec-goods-stock {
+ margin-top: 3rpx;
+ font-size: 24rpx;
+ color: #999999;
+ margin-right: 15rpx;
+}
+
+.spec-name {
+ clear: both;
+ padding: 20rpx 0;
+ font-size: 30rpx;color: #333;
+}
+
+.quhuo{font-size: 30rpx; color: #000}
+.b_num{
+ display: flex;font-size: 30rpx; color: #333;
+}
+
+.count {
+ position: fixed;
+ display: flex;
+ height: 50rpx;
+ border: 1rpx solid #000;
+ font-size: 28rpx;
+ right: 30rpx;
+}
+
+
+.count>view,.count>input {
+ width: 60rpx;
+ height: 50rpx;
+ line-height: 50rpx;
+ text-align: center;
+}
+.spec_bt{
+ background: fff;color: #333; margin-left: 10rpx;padding: 4rpx 15rpx 4rpx; display: inline-block;
+ border-radius:30rpx;font-size: 24rpx;border: 1rpx solid #ccc; margin: 10rpx; height: 40rpx; line-height: 40rpx;
+}
+.spec_bt.act{background: #d60021;color: #fff;border: 1rpx solid #d60021;}
+.sub {
+ border-right: 1px solid #000;
+}
+
+.add {
+ border-left: 1px solid #000;
+}
+
+.spec-btn {
+ color: black;
+ background-color: white;
+ padding: 10rpx 10rpx;
+ font-size: 26rpx;
+ line-height: 28rpx;
+ float: left;
+ border: 1rpx solid #dedede;
+ margin: 4rpx 10rpx 4rpx 0;
+ border-radius: 4rpx;
+}
+
+.spec-btn-click {
+ color: white;
+ background-color: #f23030;
+ border: 1rpx solid #f23030;
+}
+
+.spec-cart-btns {
+ width: 92%;
+ line-height: 70rpx;
+ margin: 0rpx auto;
+ margin-top: 160rpx;
+ border-radius: 20rpx;
+ position: fixed;
+ bottom: 50rpx;
+ left: 4%;
+}
+
+.spec-cart-btn {
+
+ width:100%;
+ font-size: 30rpx;
+ text-align: center;
+ color: white;
+ border-radius: 40rpx;
+}
+
+.spec-add-cart {
+ background-color: #ffb03f;
+}
+.spec-buy {
+ background-color: #f23030;
+ /* margin-left: 34rpx; */
+}
+.spec-cart-disable {
+ background: #bbbbbb;
+}
+
+.spec-cart-btn-lg {
+ width: 614rpx;
+}
+.stores-img{
+ width: 40rpx;
+ height: 35rpx;
+ margin-right: 10rpx;
+}
+.shop_name{
+ margin-right: 10rpx;
+}
+.address{
+ width: 90%;
+ margin-top: 25rpx;
+ margin-bottom: 5rpx;
+}
+.distance{
+ padding-left: 15rpx;
+ padding-right: 15rpx;
+ background: #eee;
+ border-radius: 20rpx;
+ margin-right: 5rpx;
+ color: #999;
+ height: 38rpx;
+ line-height: 38rpx;
+}
+.sto_v .title,.sto_v .stitle{ border-top: 1rpx solid #dedede;border-bottom: 1rpx solid #dedede; height: 78rpx; line-height: 78rpx;}
+.sto_v .title .tubiao,.sto_v .stitle .tubiao{width: 32rpx; height: 32rpx; margin-top: 23rpx;}
+.itemlists .item{border-bottom: 1rpx solid #dedede; height: 72rpx; line-height: 72rpx;font-size: 28rpx; margin: 0 10rpx;}
+
+.store-list{
+ width: 95%;
+ height: 72%;
+ overflow-y: scroll;
+ margin: auto;
+}
+.store-list .store_choose{
+ width: 100%;
+ height: 120rpx;
+ line-height: 125rpx;
+ border-bottom: 1rpx solid #eee;
+
+}
+.store-list .store_choose .store{
+ width: 100%;
+ margin: auto;
+ line-height: 37rpx;
+ padding-left: 20rpx;
+
+}
+.xc-hook{
+ width: 35rpx;
+ height: 35rpx;
+ transform: rotate(-145deg);
+ line-height: 37rpx;
+ text-align: center;
+}
+.xc-hooks{
+ width: 30rpx;
+ height: 30rpx;
+ border: 1rpx solid #999;
+}
+.address-frame{
+ width: 93%;
+ margin-left: 7rpx;
+
+}
+.nearby_store{
+ margin-left: 17rpx;
+}
+.address_name{
+ margin-right: 10rpx;
+
+}
+.address-val{
+ height: 38rpx;
+ line-height: 38rpx;
+
+}
+.store-bottom{
+ width: 85%;
+ margin: auto;
+ height: 70rpx;
+}
+.determine{
+ width: 260rpx;
+ height: 55rpx;
+ border-radius: 50rpx;
+ line-height: 55rpx;
+}
+.default{
+ width: 260rpx;
+ height: 55rpx;
+ border:3rpx solid #c8c8c8;
+ border-radius: 50rpx;
+ line-height: 55rpx;
+}
+.store-bottom-frame{
+ width: 95%;
+ margin: auto;
+
+}
+/* 门店分类列表 */
+.sort_store_list{
+ height: 82%;
+ overflow: hidden;
+ overflow-y: scroll;
+ width: 95%;
+ margin: auto;
+}
+.sort_store_list .sort-store-frame{
+ width: 100%;
+ height: 100rpx;
+ line-height:100rpx;
+ border-bottom: 1rpx solid #eee;
+
+}
+.sort_store_list .sort-store-frame .sort-store{
+ width: 94.5%;
+ margin: auto;
+}
+.black_rights-frame{
+ width: 50%;
+}
+.black_rights-frame .black_rights{
+ border-top: 3rpx solid;
+ border-right: 3rpx solid;
+ transform: rotate(45deg);
+ display: inline-block;
+ width: 20rpx;
+ height: 20rpx;
+}
+
+/* 选择门店的弹窗 */
+.mongolia-layer{
+ position: fixed;
+ left: 0;
+ top: 0;
+ right: 0;
+ bottom: 0;
+ z-index: 11;
+ background: rgba(0,0,0,0.4);
+ width: 100%;
+ height: 91.9%;
+}
+
+.popup-frame{
+ position: fixed;
+ bottom:99rpx;
+ z-index: 20;
+ background: white;
+ width: 100%;
+ border-radius: 20rpx 20rpx 0 0;
+ height: 72%;
+}
+.popup-top{
+ border-bottom: 1rpx solid #eee;
+ height: 155rpx;
+ width: 95%;
+ margin: auto;
+ line-height: 155rpx;
+
+}
+.bg_rights{
+ border-top: 2rpx solid ;
+ border-right: 2rpx solid ;
+ transform: rotate(45deg);
+ display:inline-block;
+ width:15rpx;height:15rpx;
+ border-color:#da0b31;
+}
+.modal-closes {
+ position: absolute;
+ right: 30rpx;
+ top: -15rpx;
+ height: 25rpx;
+
+}
+.choose_more{
+ margin-top: 40rpx;
+ margin-right: 20rpx;
+
+}
+.choose_mores{
+ margin-top: 30rpx;
+ margin-right: 15rpx;
+}
+.xc-goods-attribute{
+ border-bottom: 1px solid #eee;
+ padding-bottom: 15px;
+ margin-bottom:40rpx;
+ }
\ No newline at end of file
diff --git a/packageA/pages/quan_list/filter.wxs b/packageA/pages/quan_list/filter.wxs
new file mode 100644
index 0000000..5051751
--- /dev/null
+++ b/packageA/pages/quan_list/filter.wxs
@@ -0,0 +1,27 @@
+var is_has = function (text,val) {
+ if(text.indexOf(","+val+",")==-1) return false;
+ return true
+}
+
+function get_guige(color,spece){
+ if(color=="" && spece==""){return "规格1"}
+ if(spece!="" && color==""){return spece}
+ if(spece=="" && color!=""){return color}
+ if(spece!="" && color!=""){return spece+"/"+color}
+ return "";
+}
+
+function get_color(index){
+ var i=index%3;
+ switch(i){
+ case 0: return "red";
+ case 1: return "blue";
+ case 2: return "purple";
+ }
+}
+
+module.exports = {
+ is_has: is_has,
+ get_guige:get_guige,
+ get_color:get_color
+}
diff --git a/packageA/pages/quan_list/g_filter.wxs b/packageA/pages/quan_list/g_filter.wxs
new file mode 100644
index 0000000..e998151
--- /dev/null
+++ b/packageA/pages/quan_list/g_filter.wxs
@@ -0,0 +1,87 @@
+var g_filters = {
+ //-- 判断是不是有等级价 --
+ is_has_rank:function(rank_switch,item){
+ if(!rank_switch) return false;
+ if(item.cardprice1 || item.cardprice2 || item.cardprice3) {return true}
+ return false;
+ },
+
+ //-- 判断,不是等级会员时候,要显示的最低等级价和名称 --
+ get_card_price:function(goods,all_card,type){
+ var price1=parseFloat(goods['cardprice1']);
+ var price2=parseFloat(goods['cardprice2']);
+ var price3=parseFloat(goods['cardprice3']);
+ if(!all_card){
+ if(type==0) return 0;
+ return "";
+ }
+
+ var arr=[];
+ var min_price= 0;
+ var min_name="";
+
+ var min_price=null;
+ var min_name=null;
+ //---设置对应的价格名字----
+ for(var i=0;i<3;i++) {
+ var vl=all_card[i];
+ if(!vl) continue;
+ if(vl['CorrPrice']=="Price1" && price1>0)
+ {
+ if(min_price==null) {
+ min_price=price1;min_name=vl['CardName'];
+ }
+ else if(price10)
+ {
+ if(min_price==null) {
+ min_price=price2;min_name=vl['CardName'];
+ }
+ else if(price20)
+ {
+ if(min_price==null) {
+ min_price=price3;min_name=vl['CardName'];
+ }
+ else if(price34 ) min_name=min_name.substring(0, 4);
+ return min_name;
+ },
+}
+module.exports = {
+ is_has_rank:g_filters.is_has_rank,
+ get_card_price:g_filters.get_card_price,
+}
\ No newline at end of file
diff --git a/packageA/pages/quan_list/quan_list.js b/packageA/pages/quan_list/quan_list.js
new file mode 100644
index 0000000..66bcb83
--- /dev/null
+++ b/packageA/pages/quan_list/quan_list.js
@@ -0,0 +1,140 @@
+var t = require("../../../utils/util.js"), ut = t,
+ e = require("../../../utils/common.js"),
+ oo = getApp().globalData,
+ os = getApp().globalData.setting;
+var utils = require('../../../utils/util.js'),ut=utils;
+
+
+
+Page({
+ data: {
+ stoid: os.stoid,
+ url: os.url,
+ resourceUrl: os.resourceUrl,
+ iurl: os.imghost,
+ defaultAvatar: os.resourceUrl + "/static/images/user68.jpg",
+ dataList: null,
+ config2:null,
+ curpage:1,
+ loading:0,
+ get_item:null,
+ show_success:0,
+ },
+ //------初始化加载----------
+ onLoad: function(t) {
+ var th=this;
+ getApp().getConfig2(function (conf) {
+ conf.couponset=conf.couponset.replace(/\
{
+ th.data.loading=0;
+ if(res.data.code==0){
+ if(!th.data.dataList) th.data.dataList=new Array();
+ th.data.dataList=th.data.dataList.concat(res.data.data.pageData);
+ th.data.curpage++;
+ th.setData({dataList:th.data.dataList});
+ }
+ });
+ },
+
+ //---加载更多是靠这个函数----
+ onReachBottom: function() {
+ this.get_quan_list();
+ },
+
+
+ //--滚动到顶部--
+ doScrollTop: function() {
+ wx.pageScrollTo({ scrollTop: 0 });
+ },
+
+ //-----领取券-----
+ get_quan: function(e) {
+ var cid = e.currentTarget.dataset.cid;
+ var index = e.currentTarget.dataset.ind;
+ var item = this.data.dataList[index];
+
+ //--先判断会员状态--
+ var user_info = getApp().globalData.userInfo;
+ if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
+ wx.navigateTo({
+ url: '/pages/getphone/getphone',
+ })
+ return false;
+ }
+
+ //如果券还在领取中,不能再点
+ if (item.linging == 1) {
+ getApp().my_warnning('领取中..', 0, this);
+ return false;
+ }
+
+ //如果领取的次数到了
+ if (item.everyone_num > 0 && item.lqnum >= item.everyone_num) {
+ getApp().my_warnning('领取失败,您已领完该券', 0, this);
+ return false;
+ }
+ var lq_num = item.lqnum;
+ var pdata = {
+ 'uid': oo.user_id,
+ 'cid': cid,
+ 'store_id': os.stoid,
+ 'type': 5
+ };
+ var app = getApp(),
+ th = this;
+ app.request.post("/api/weshop/couponList/saveCouponList", {
+ data: pdata,
+ success: function(res) {
+ if (res.data.code == 0) {
+ var text = "dataList[" + index + "].is_get";
+ var text2 = "dataList[" + index + "].linging";
+ var text3 = "get_item";
+ var obj = {};obj[text] = 1; obj[text2] = 0;obj[text3] = item;obj['show_success']=1;
+ th.setData(obj);
+ } else {
+ app.confirmBox(res.data.msg);
+ var text2 = "dataList[" + index + "].linging";
+ th.setData({[text2]:0});
+ }
+ }
+ })
+ },
+ close_show:function () {
+ this.setData({show_success:0,get_item:null})
+ },
+ go_quan:function () {
+ getApp().goto("/pages/user/coupons/coupons");
+ },
+ go_detail:function (e) {
+ var index=e.currentTarget.dataset.ind;
+ var item=this.data.dataList[index];
+ getApp().goto("/packageA/pages/quan_pro/quan_pro?id="+item.id);
+ }
+
+
+});
diff --git a/packageA/pages/quan_list/quan_list.json b/packageA/pages/quan_list/quan_list.json
new file mode 100644
index 0000000..04a1287
--- /dev/null
+++ b/packageA/pages/quan_list/quan_list.json
@@ -0,0 +1,8 @@
+{
+ "navigationBarTitleText": "优惠券",
+ "enablePullDownRefresh": false,
+ "usingComponents": {
+ "nav_box": "/components/nav_box/nav_box",
+ "warn": "/components/long_warn/long_warn"
+ }
+}
\ No newline at end of file
diff --git a/packageA/pages/quan_list/quan_list.wxml b/packageA/pages/quan_list/quan_list.wxml
new file mode 100644
index 0000000..b2fe076
--- /dev/null
+++ b/packageA/pages/quan_list/quan_list.wxml
@@ -0,0 +1,51 @@
+
+
+
+
+
+
+
+
+
+
+ ¥{{filters.toFix(item.money,2)}}
+ 满{{filters.toFix(item.condition,2)}}可用
+
+
+
+
+ {{item.name}}
+ 所有门店通用
+ 有效期
+ {{filters.format_time(item.use_start_time)}}至
+ {{filters.format_time(item.use_end_time)}}不限
+
+ 有效期{{item.days}}天不限
+ 每人限领:{{item.everyone_num}}不限
+
+
+ 已领取
+ 立即领取
+
+
+
+
+
+
+
+
+
+
+
+ 恭喜您获得【{{get_item.name}}】优惠券
+
+
+ 查看我的优惠券
+
+
+
+
+
+
diff --git a/packageA/pages/quan_list/quan_list.wxss b/packageA/pages/quan_list/quan_list.wxss
new file mode 100644
index 0000000..9f69ee1
--- /dev/null
+++ b/packageA/pages/quan_list/quan_list.wxss
@@ -0,0 +1,32 @@
+page{background-color: #f8f8f8;}
+.co-w{color: #ffffff;}
+.co_g{color:#b399b3}
+.co_b{color:#333;}
+
+.header{padding: 0 10rpx;}
+.r_txt{line-height: 45rpx; }
+.content{padding: 0 20rpx; margin-top: 20rpx}
+.quan_item{ height: 213rpx; margin-bottom: 20rpx }
+.quan_item .left{overflow: hidden;width: 35%; height: 213rpx;border-top-left-radius:10rpx;border-bottom-left-radius:10rpx;position: relative}
+.quan_item .right{width: 65%; height: 210rpx; border-top-right-radius:10rpx;border-bottom-right-radius:10rpx;position: relative;
+ background-position: center;background-size: 100% 100%; background-repeat: no-repeat}
+.quan_item .left.red {background: url(https://mshopimg.yolipai.net/miniapp/images/coupon_img/red.png) no-repeat;background-position: center;background-size: 100% 100%;}
+.quan_item .left.blue {background: url(https://mshopimg.yolipai.net/miniapp/images/coupon_img/blue.png) no-repeat;background-position: center;background-size: 100% 100%;}
+.quan_item .left.purple {background: url(https://mshopimg.yolipai.net/miniapp/images/coupon_img/purple.png) no-repeat;background-position: center;background-size: 100% 100%;}
+
+.quan_item .right.pding{padding-left: 40rpx}
+.btn{position: absolute;right: 20rpx; bottom: 20rpx; border-radius: 5px; border: 1rpx solid #c4182e; width: 132rpx; height: 40rpx; color: #c4182e }
+.btn.is_get{border: 0;background-color: #dcdcdc;color: #adb3be; width: 94rpx;}
+
+.suc_content{
+ height: 300rpx; width: 84%; margin-left:8%;position: fixed; border-radius:25rpx;
+ top:50%; margin-top: -150rpx;background-color: #fff; z-index: 999999;
+}
+
+.suc_content .up{ height:200rpx }
+.suc_content .up image{ width: 280rpx; height: 220rpx; margin-top: -130rpx}
+.suc_content .down{ background-color: #c4182e; height:106rpx; line-height: 106rpx;
+border-bottom-right-radius:25rpx;
+border-bottom-left-radius:25rpx;
+}
+
diff --git a/packageA/pages/quan_pro/filter.wxs b/packageA/pages/quan_pro/filter.wxs
new file mode 100644
index 0000000..fa5ed5a
--- /dev/null
+++ b/packageA/pages/quan_pro/filter.wxs
@@ -0,0 +1,17 @@
+var is_has = function (text,val) {
+ if(text.indexOf(","+val+",")==-1) return false;
+ return true
+}
+
+function get_guige(color,spece){
+ if(color=="" && spece==""){return "规格1"}
+ if(spece!="" && color==""){return spece}
+ if(spece=="" && color!=""){return color}
+ if(spece!="" && color!=""){return spece+"/"+color}
+ return "";
+}
+
+module.exports = {
+ is_has: is_has,
+ get_guige:get_guige
+}
diff --git a/packageA/pages/quan_pro/g_filter.wxs b/packageA/pages/quan_pro/g_filter.wxs
new file mode 100644
index 0000000..e998151
--- /dev/null
+++ b/packageA/pages/quan_pro/g_filter.wxs
@@ -0,0 +1,87 @@
+var g_filters = {
+ //-- 判断是不是有等级价 --
+ is_has_rank:function(rank_switch,item){
+ if(!rank_switch) return false;
+ if(item.cardprice1 || item.cardprice2 || item.cardprice3) {return true}
+ return false;
+ },
+
+ //-- 判断,不是等级会员时候,要显示的最低等级价和名称 --
+ get_card_price:function(goods,all_card,type){
+ var price1=parseFloat(goods['cardprice1']);
+ var price2=parseFloat(goods['cardprice2']);
+ var price3=parseFloat(goods['cardprice3']);
+ if(!all_card){
+ if(type==0) return 0;
+ return "";
+ }
+
+ var arr=[];
+ var min_price= 0;
+ var min_name="";
+
+ var min_price=null;
+ var min_name=null;
+ //---设置对应的价格名字----
+ for(var i=0;i<3;i++) {
+ var vl=all_card[i];
+ if(!vl) continue;
+ if(vl['CorrPrice']=="Price1" && price1>0)
+ {
+ if(min_price==null) {
+ min_price=price1;min_name=vl['CardName'];
+ }
+ else if(price10)
+ {
+ if(min_price==null) {
+ min_price=price2;min_name=vl['CardName'];
+ }
+ else if(price20)
+ {
+ if(min_price==null) {
+ min_price=price3;min_name=vl['CardName'];
+ }
+ else if(price34 ) min_name=min_name.substring(0, 4);
+ return min_name;
+ },
+}
+module.exports = {
+ is_has_rank:g_filters.is_has_rank,
+ get_card_price:g_filters.get_card_price,
+}
\ No newline at end of file
diff --git a/packageA/pages/quan_pro/quan_pro.js b/packageA/pages/quan_pro/quan_pro.js
new file mode 100644
index 0000000..a3e9906
--- /dev/null
+++ b/packageA/pages/quan_pro/quan_pro.js
@@ -0,0 +1,109 @@
+var t = require("../../../utils/util.js"), ut = t,
+ e = require("../../../utils/common.js"),
+ oo = getApp().globalData,
+ os = getApp().globalData.setting;
+ var utils = require('../../../utils/util.js'),ut=utils;
+
+Page({
+ data: {
+ stoid: os.stoid,
+ url: os.url,
+ resourceUrl: os.resourceUrl,
+ iurl: os.imghost,
+ defaultAvatar: os.resourceUrl + "/static/images/user68.jpg",
+ q_data: null,
+ id:null,
+ config2:null,
+
+ },
+ //------初始化加载----------
+ onLoad: function(t) {
+ var id=t.id;
+ this.data.id=id;
+ var goods_list = this.selectComponent("#goods_list"); //组件的id
+ goods_list.init();
+ setTimeout(function() {
+ goods_list.get_list();
+ }, 300)
+ },
+
+ //---展示,显示券的信息---
+ onShow: function() {
+ var th=this;
+ var user_id=getApp().globalData.user_id;
+ getApp().request.promiseGet("/api/weshop/prom/coupon/pageCouponList", {
+ data:{store_id:os.stoid,type:1,id:th.data.id,user_id:user_id}
+ }).then(res => {
+ if(res.data.code==0){
+ th.setData({q_data:res.data.data.pageData[0]});
+ }
+ });
+ },
+
+ onHide: function() {
+
+ },
+ //--滚动到顶部--
+ doScrollTop: function() {
+ wx.pageScrollTo({ scrollTop: 0 });
+ },
+
+ //---加载更多是靠这个函数----
+ onReachBottom: function() {
+ var goods_list = this.selectComponent("#goods_list"); //组件的id
+ if (goods_list) goods_list.get_list();
+ },
+
+ //-----领取券-----
+ get_quan: function() {
+ var item=this.data.q_data;
+ var cid = this.data.q_data.id;
+ var th=this;
+ //--先判断会员状态--
+ var user_info = getApp().globalData.userInfo;
+ if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
+ wx.navigateTo({
+ url: '/pages/getphone/getphone',
+ })
+ return false;
+ }
+ //如果券还在领取中,不能再点
+ if (th.data.linging == 1) {
+ getApp().my_warnning('领取中..', 0, this);
+ return false;
+ }
+ th.data.linging = 1;
+ //如果领取的次数到了
+ if (item.everyone_num > 0 && item.lqnum >= item.everyone_num) {
+ getApp().my_warnning('领取失败,您已领完该券', 0, this);
+ return false;
+ }
+ var lq_num = item.lqnum;
+ var pdata = {
+ 'uid': oo.user_id,
+ 'cid': cid,
+ 'store_id': os.stoid,
+ 'type': 5
+ };
+ var app = getApp(),
+ th = this;
+ app.request.post("/api/weshop/couponList/saveCouponList", {
+ data: pdata,
+ success: function(res) {
+ th.data.linging = 0;
+ if (res.data.code == 0) {
+ item.lqnum++;
+ var text = "dataList[" + index + "].is_get";
+ var text2 = "dataList[" + index + "].linging";
+ var text3="q_data";
+ var obj = {};obj[text] = 1; obj[text2] = 0;obj[text3] = item;obj['show_success']=1;
+ th.setData(obj);
+ } else {
+ app.confirmBox(res.data.msg);
+ }
+ }
+ })
+ },
+
+
+});
diff --git a/packageA/pages/quan_pro/quan_pro.json b/packageA/pages/quan_pro/quan_pro.json
new file mode 100644
index 0000000..06e6a38
--- /dev/null
+++ b/packageA/pages/quan_pro/quan_pro.json
@@ -0,0 +1,9 @@
+{
+ "navigationBarTitleText": "优惠券",
+ "enablePullDownRefresh": false,
+ "usingComponents": {
+ "nav_box": "/components/nav_box/nav_box",
+ "warn": "/components/long_warn/long_warn",
+ "goods_recommend":"/components/goods_list/goods_list"
+ }
+}
\ No newline at end of file
diff --git a/packageA/pages/quan_pro/quan_pro.wxml b/packageA/pages/quan_pro/quan_pro.wxml
new file mode 100644
index 0000000..3ff4c39
--- /dev/null
+++ b/packageA/pages/quan_pro/quan_pro.wxml
@@ -0,0 +1,67 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{q_data.name}}
+
+
+ 全场通用
+ 仅限{{q_data.useobjectname}}使用
+
+
+
+ ¥{{filters.toFix(q_data.money,2)}}
+ 满{{filters.toFix(q_data.condition,2)}}可用
+
+
+ 有效期
+ {{filters.format_time(q_data.use_start_time)}}至
+ {{filters.format_time(q_data.use_end_time)}}不限
+
+ 有效期{{q_data.days}}天不限
+
+
+
+
+
+ 已领取
+ 立即领取
+
+
+ 猜你喜欢
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 恭喜您获得【{{get_item.name}}】优惠券
+
+
+ 查看我的优惠券
+
+
+
+
+
+
+
+
diff --git a/packageA/pages/quan_pro/quan_pro.wxss b/packageA/pages/quan_pro/quan_pro.wxss
new file mode 100644
index 0000000..90cdbc8
--- /dev/null
+++ b/packageA/pages/quan_pro/quan_pro.wxss
@@ -0,0 +1,29 @@
+page{background-color: #f8f8f8;}
+.co-w{color: #ffffff;}
+.co_g{color:#b399b3}
+.co_b{color:#333;}
+
+.up_part{background-color: #fff;padding-bottom: 20rpx}
+.img_part{ padding: 0 20rpx; position: relative}
+.btn{ width: 90%; height: 72rpx; border-radius: 10rpx; background-color: #ff6c6c; color: #fff;}
+.love{ width: 60rpx; height: 50rpx}
+.q_content{ position: absolute;top: 0; left: 0; width: 100%; height: 450rpx;padding: 0 20rpx; }
+.upper{ height:330rpx;}
+.lower{ height: 120rpx; line-height: 170rpx;color:#7a668f}
+
+.upper .left{ margin-left:30rpx; margin-top: 30rpx }
+.t_circle{ width: 10rpx; height: 10rpx; border-radius: 50%; background-color: #fff; margin-right: 8rpx}
+
+.suc_content{
+ height: 300rpx; width: 84%; margin-left:8%;position: fixed; border-radius:25rpx;
+ top:50%; margin-top: -150rpx;background-color: #fff; z-index: 999999;
+}
+
+.suc_content .up{ height:200rpx;}
+.suc_content .up image{ width: 280rpx; height: 220rpx; margin-top: -130rpx}
+.suc_content .down{ background-color: #c4182e; height:106rpx; line-height: 106rpx;
+ border-bottom-right-radius:25rpx;
+ border-bottom-left-radius:25rpx;
+}
+
+.btn.gray{background-color: #dcdcdc; color: #adb3be;}
diff --git a/pages/cart/cart/cart.js b/pages/cart/cart/cart.js
index 7277b7e..81a9eea 100644
--- a/pages/cart/cart/cart.js
+++ b/pages/cart/cart/cart.js
@@ -49,9 +49,17 @@ Page({
t.auth.hadAuth() && t.getUserInfo(function() {
a.getCardList();
});
+
+
+
},
onShow: function() {
var th = this;
+ //th.setData({
+ // isTabBar: getApp().globalData.isTabBar,
+ //});
+
+ t.editTabBar(); //显示自定义的底部导航
this.getCardList();
if(getApp().globalData.user_id) getApp().requestCardNum();
//--获取是否又秒杀活动--
@@ -121,7 +129,8 @@ Page({
user_id: app.globalData.user_id,
rd: rd,
store_id: oo.stoid,
- pageSize: 600
+ pageSize: 600,
+ state:0
},
success:async function(su) {
//按门店分类的数组
@@ -136,18 +145,60 @@ Page({
good=res.data.data;
})
var tt=ut.gettimestamp();
- if((good.down_time>0 && good.down_time0 && good.down_time{
+ if(res.data.code==0) prom=res.data.data;
+ })
+ //---如果有活动,不算在一起---
+ if(!prom && prom.is_end==0 && prom.end_time>now && prom.start_time {
+ if(res.data.code==0){
+ var r_data=res.data.data;
+ if(!r_data.promGoodsLists){
+ var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
+ a.delete(url, {});
+ //商品已经下架
+ isok=0;
+ }
+ }
+ else{
+ var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
+ a.delete(url, { });
+ //商品已经下架
+ isok=0;
+ }
+ })
+ if(!isok) continue;
+ }
+
all_num += item.goods_num;
item.original_img = oo.imghost + item.original_img;
item.selected = 0;
+
var pcid = item.pick_id;
var find = 0;
//---------循环查找门店---
@@ -183,6 +234,14 @@ Page({
}
}
+ if(arr.length==0) {
+ setTimeout(function () {
+ var goods_list = th.selectComponent("#goods_list"); //组件的id
+ goods_list.init();
+ goods_list.get_list();
+ }, 800)
+ }
+
th.setData({
requestData: arr,
all_num: all_num,
@@ -292,6 +351,7 @@ Page({
}
var fir = 0;
for (var j = 0; j < item.length; j++) {
+ if(item[j].is_gift) continue;
if (fir == 0) {
fir = item[j].distr_type;
} else {
@@ -324,6 +384,11 @@ Page({
total_fee: tfeel.toFixed(2),
total_num: t_num,
});
+
+ for(var i in e.data.requestData){
+ e.check_prom_activity(i)
+ }
+
}
},
@@ -339,6 +404,7 @@ Page({
iarr = item;
if (!sele && item.length > 0) {
for (var i = 0; i < iarr.length; i++) {
+ if(iarr[i].is_gift==1) continue;
if (iarr[i].distr_type != 0) {
if (fir == 0) {
fir = iarr[i].distr_type;
@@ -370,6 +436,7 @@ Page({
e.setData({
[txt]: Number(!sele),
});
+ e.check_prom_activity(pitems);
this.doCheckAll();
},
@@ -379,14 +446,15 @@ Page({
item = t.currentTarget.dataset.item,
pitems = t.currentTarget.dataset.pitems;
a = this.data.requestData[pitems].goods[item];
- var isok = 1,
- fir = 0;
+ var isok = 1,fir = 0;
var iarr = e.data.requestData[pitems].goods;
//当数量大于1,且是选择的时候
if (iarr.length > 1 && !a.selected) {
for (var i = 0; i < iarr.length; i++) {
+ if(iarr[i].is_gift==1) continue;
+
//---当不是本身选择项目----
var sel = iarr[i].selected;
if (iarr[i].distr_type != 0 && (sel || iarr[i].id == a.id)) {
@@ -411,6 +479,12 @@ Page({
e.setData({
[txt]: Number(!a.selected),
});
+
+ if(a.prom_type==3){
+ //判断商品是不是优惠活动
+ e.check_prom_activity(pitems);
+ }
+
this.doCheckAll();
}
},
@@ -427,6 +501,7 @@ Page({
var item = car[a].goods,
is_s_sele = 1;
for (var c = 0; c < item.length; c++) {
+ if(item[c].is_gift) continue;
all_num += item[c].goods_num;
if (item[c].selected == 0) {
ischeck = 0;
@@ -680,8 +755,13 @@ Page({
plist=res.data.data.pageData[0];
}
})
- var ob={}; ob.code=1;
- if(t.goods_num>plist.CanOutQty-lock){
+ var ob={}; ob.code=1;
+
+ if(!plist){
+ ob.code=-1;ob.CanOutQty=0;func(ob); return false;
+ }
+
+ if( t.goods_num>plist.CanOutQty-lock){
ob.code=-1;
ob.CanOutQty=plist.CanOutQty-lock
if(ob.CanOutQty<0) ob.CanOutQty=0;
@@ -701,6 +781,9 @@ Page({
e.setData({
[txt]: t.goods_num,
});
+ for(var i in e.data.requestData){
+ e.check_prom_activity(i)
+ }
e.doCheckAll();
}
});
@@ -725,7 +808,7 @@ Page({
for (var i = 0; i < this.data.requestData.length; i++) {
var i_arr = this.data.requestData[i].goods;
for (var j = 0; j < i_arr.length; j++) {
- if (i_arr[j].selected) {
+ if (i_arr[j].selected && i_arr[j].is_gift!=1) {
//map 的key是不会重复,会覆盖,,
var ie = {
goods_id: i_arr[j].goods_id,
@@ -742,8 +825,8 @@ Page({
}
glist += i_arr[j].goods_id + ",";
ab = 1;
- //--普通商品,如果有开启线下库存的功能,要调用线下库存进行计算---
- if(i_arr[j].prom_type==0 && th.data.sales_rules==2){
+ //--普通商品,如果有开启线下库存的功能,要调用线下库存进行计算,赠品不要进行调用线下库存---
+ if((i_arr[j].prom_type==0 || i_arr[j].prom_type==3 || i_arr[j].prom_type==5) && th.data.sales_rules==2 && i_arr[j].is_gift!=1){
//--获取商品的线下商品ID--
var gd=null;
await getApp().request.promiseGet("/api/weshop/goods/get/" + oo.stoid + "/" + i_arr[j].goods_id,{}).then(res=>{
@@ -759,9 +842,26 @@ Page({
wx.hideLoading();
return false;
}
+
+ var is_ok=1;
+ //如果是优惠活动话,要看活动有没有过期
+ if(i_arr[j].prom_type==3){
+ //判断有没有活动
+ await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+i_arr[j].goods_id+"/1", {}).then(res => {
+ if(res.data.code==0){
+ if(!res.data.data.promGoodsLists){
+ t.my_warnning(i_arr[j].goods_name+"优惠活动已经过期", 0, th);
+ wx.hideLoading();
+ is_ok=0;
+ }
+ }
+ })
+ }
+ if(!is_ok){return false;}
}
} else {
+ if(i_arr[j].is_gift==1) continue;
rq.put("/api/weshop/cart/update", {
data: {
id: i_arr[j].id,
@@ -1006,7 +1106,188 @@ Page({
url: '/pages/index/index/index',
})
},
-
-
+
+ //---加载更多是靠这个函数----
+ onReachBottom: function() {
+ if(this.data.requestData.length==0) {
+ var goods_list = this.selectComponent("#goods_list"); //组件的id
+ if (goods_list) goods_list.get_list();
+ }
+ },
+
+ //检查莫个门店下的商品是不是优惠活动,有的话,看要不要送礼品,同时有没有倍增
+ check_prom_activity:async function (cindex) {
+ var make_up_arr=new Array();
+ var th=this;
+ var map=new Map();
+ var list=this.data.requestData[cindex];
+ //循环处理活动,看活动商品的数量,用map来出来存储,key为活动id,值是数量
+ for(var i in list.goods){
+ var item=list.goods[i];
+ if(item.prom_type==3 && item.selected && !item.is_gift){
+ if(map.has(item.prom_id+"")){
+ var ob=map.get(item.prom_id+"");
+ ob.num+=item.goods_num;
+ ob.price+=item.goods_num*item.goods_price;
+ map.set(item.prom_id+"",ob);
+ }else{
+ var ob={};
+ ob.num=item.goods_num;
+ ob.price=item.goods_num*item.goods_price;
+ map.set(item.prom_id+"",ob);
+ }
+ }
+ if(item.is_gift==1){
+ var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
+ //getApp().request.delete(url, {});
+ await getApp().request.promiseDelete(url, {}) // 要用同步让赠品删除
+ list.goods.splice(i,1);
+ }
+ }
+
+ var map2=new Map();
+ //请那些是赠品,但是优惠活动并没有被选中的商品要删除,同时满足条件的要放到map2,
+ for(var i in list.goods){
+ var item=list.goods[i];
+ if(item.is_gift){
+ if(map.has(item.prom_id+"")){
+ if(!map2.has(item.prom_id+"")){
+ map2.set(item.prom_id+"",i)
+ }
+ }else{
+ var url = '/api/weshop/cart/del/' + oo.stoid + '/' + item.id;
+ list.goods.splice(i,1);
+ getApp().request.delete(url, {});
+ }
+ }
+ }
+ for(let p_item of map.entries()){
+ var prom=null;
+ await getApp().request.promiseGet("/api/weshop/promgoods/get/"+os.stoid+"/"+p_item[0],{}).then(res=> {
+ if(res.data.code==0){
+ prom=res.data.data;
+ }
+ })
+ //如果活动已经结束
+ if(!prom || prom.is_end || prom.end_time{
+ if(res.data.code==0) discount=res.data.data;
+ })
+
+ //---如果有打折的信息,赠送的信息,赠送的时候要判断是不是限购数量---
+ if(discount && discount['goods_id'] && discount.limit_num>=discount.bs && discount.gift_storecount>=discount.bs){
+ var o=discount.goodsinfo;
+ var newd = {
+ goods_id: o.goods_id,
+ goods_num: discount.bs,
+ pick_id: list.pid,
+ user_id: app.globalData.user_id,
+ store_id: os.stoid,
+ goods_price: 0,
+ member_goods_price: 0,
+ goods_name: o.goods_name,
+ goods_sn: o.goods_sn,
+ sku: o.sku,
+ is_gift: 1,
+ prom_id:p_item[0],
+ prom_type:3,
+ selected:1,
+ gift_id:discount.gift_id
+ };
+
+ if(map2.has(p_item[0]+"")){
+ var index=map2.get(p_item[0]+"");
+ if( list.goods[index].goods_num!=discount.bs){
+ list.goods[index].goods_num=discount.bs;
+ getApp().request.put("/api/weshop/cart/update", {
+ data: {
+ id: list.goods[index].id,
+ selected: 1,
+ store_id: oo.stoid,
+ goods_num:discount.bs
+ },
+ success: function(ee) {
+ console.log(ee);
+ }
+ });
+ }
+
+ }else{
+ var add_data=null;
+ await getApp().request.promisePost("/api/weshop/cart/save", { data: newd }).then(res=>{
+ if(res.data.code==0){
+ add_data=res.data.data;
+ }
+ })
+ if(add_data){
+ newd.id=add_data.id;
+ list.goods.push(newd);
+ }
+ }
+ }
+
+
+
+ //-- 获取 --
+ await getApp().request.promiseGet("/api/weshop/promgoodslist/list",{
+ data:{prom_id:prom.id}
+ }).then(res=>{
+ if(res.data.code==0){
+ var list=res.data.data;
+ for(var i in list){
+ var item=list[i];
+ if(item.prom_type==0){
+ if(ob.price0){
+ this.setData({[diff_text]:make_up_arr});
+ }else{
+ this.setData({[diff_text]:null});
+ }
+ },
+
+ //去凑单
+ go_cou_dang:function (e) {
+ var prom_id=e.currentTarget.dataset.prom_id;
+ var url="/pages/goods/goodsList/goodsList?prom_type=3&prom_id="+prom_id;
+ getApp().goto(url);
+ }
});
\ No newline at end of file
diff --git a/pages/cart/cart/cart.json b/pages/cart/cart/cart.json
index c4d22ab..70ce71e 100644
--- a/pages/cart/cart/cart.json
+++ b/pages/cart/cart/cart.json
@@ -1,6 +1,7 @@
{
"navigationBarTitleText": "购物车",
"usingComponents": {
- "warn": "/components/long_warn/long_warn"
+ "warn": "/components/long_warn/long_warn",
+ "goods_recommend":"/components/goods_list/goods_list"
}
}
\ No newline at end of file
diff --git a/pages/cart/cart/cart.wxml b/pages/cart/cart/cart.wxml
index 695a6d2..725c2da 100644
--- a/pages/cart/cart/cart.wxml
+++ b/pages/cart/cart/cart.wxml
@@ -32,16 +32,25 @@
-
+
+
-
-
-
+
+
+
+
+
+
- 自选
- 自提
- 物流
+
+ 赠品
+
+
+ 自选
+ 自提
+ 物流
+
@@ -53,9 +62,14 @@
{{items.goods_color}}{{items.goods_color?"/":''}}{{items.goods_spec}}
规格1
+
+ {{items.goods_num}}件
+
-
+
+
+
¥
{{items.goods_price}}
@@ -66,9 +80,28 @@
+
+
+
+
+
+ 再买{{item.diff}}元
+ 件
+ ,
+ 免{{item.content.money}}元|
+ 打{{item.content.sale}}折|
+ 包邮|
+ 送优惠券|
+ 送积分|
+ 送赠品|
+ 送礼包|
+
+
+ 去凑单>
+
+
@@ -113,4 +146,44 @@
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+ 好物推荐
+
+
+
+
+
+
+
+
+
+
+
+ GOOD HOT THING
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/cart/cart/cart.wxss b/pages/cart/cart/cart.wxss
index 904cf00..4439f04 100644
--- a/pages/cart/cart/cart.wxss
+++ b/pages/cart/cart/cart.wxss
@@ -267,9 +267,9 @@ radio {
/* 购物车为空 */
.empty_order image {
- width: 329rpx;
- height: 229rpx;
- margin-top: 140rpx;
+ width: 129rpx;
+ height: 129rpx;
+ margin-top: 120rpx;
}
.empty_order .xc-ash {
@@ -278,7 +278,7 @@ radio {
}
.empty_order navigator {
- margin-top: 60rpx;
+ margin-top: 20rpx;
border-radius: 40rpx;
}
@@ -294,3 +294,55 @@ radio {
margin-left: 30rpx; margin-right: 25rpx}
.mlr{ margin-left: 25rpx; margin-right: 20rpx}
+
+/* 热门好物 */
+
+.title .China {
+ width: 100%;
+ margin-top: 10rpx;
+ margin-bottom: 10rpx;
+ line-height: 0rpx;
+}
+
+.title .China .line view {
+ width: 2rpx;
+}
+
+.title .China .line {
+ height: 40rpx;
+ color: rgb(51, 51, 51);
+}
+
+.title .China .line view {
+ border-left: 3rpx solid #000;
+ margin-left: 5rpx;
+}
+
+.title .China .line .one {
+ height: 23rpx;
+}
+
+.title .China .line .two {
+ height: 15rpx;
+}
+
+.title .China .line .three {
+ height: 18rpx;
+}
+
+.title .China .Recommend {
+ margin: 0rpx 20rpx;
+ font-size: 28rpx;
+ line-height: 39rpx;
+ font-weight: bold;
+}
+
+.title .english .silk {
+ width: 214rpx;
+ height: 2rpx;
+ background-color: #000;
+}
+
+.title .english .esh {
+ margin: 0rpx 15rpx;
+}
diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js
index 8d28a97..4f5b5f6 100644
--- a/pages/cart/cart2/cart2.js
+++ b/pages/cart/cart2/cart2.js
@@ -34,6 +34,7 @@ Page({
},
/*-----------当是购物车结算的时候-------------*/
cartlist:null,
+ old_cartlist:null,
cartlist_y:null, //购物车原始列表
js_use_money: 0, //是否使用余额
is_all_zt:1, //是否全部都是自提
@@ -95,6 +96,14 @@ Page({
is_no_by:{},
is_by:{},
is_quan_by:{},
+ //--购买赠送的商品--
+ buy_now_gift_goods:null,
+ //--订单优惠--
+ order_prom:{},
+ //-- 购物车优惠活动 --
+ prom_goods_map:{},
+ //-- order_prom_list --
+ order_prom_list_cart:null,
},
onLoad: function(t) {
@@ -143,10 +152,38 @@ Page({
console.log("getuser_addr")
console.log(ie)
- th.setData({user_addr: ie });
- var going=0;
+ //地址切换要把包邮券清空
+ if( !th.data.user_addr || th.data.user_addr.address_id!=ie.address_id){
+ var using_quan=th.data.using_quan;
+ for(var i in using_quan){
+ var item=using_quan[i];
+ if(item.isby==1){
+ var ob={},txt="using_quan["+i+"]";ob[txt]={};
+ th.setData(ob);
+ }
+ }
+ th.data.isget_by_quan={};
+ }
+
+ //更换地址回来要重新调用计算价钱的接口
+ if(!th.data.user_addr || th.data.user_addr.address_id!=ie.address_id){
+ if (th.data.is_b_now == 1) {
+ if(th.data.bn_goods) {
+ th.calculatePrice2();
+ }
+ }else{
+ if (th.data.cartlist){
+ th.calculatePrice();
+ }
+ }
+ }
+
+ th.setData({user_addr: ie });
+ var going=0;
+
//使用计时器,避免空现象
+ /*---
var jishi= setInterval(function () {
if (th.data.is_b_now == 1 && going==0) {
if(th.data.bn_goods) {
@@ -157,7 +194,7 @@ Page({
th.calculatePrice();going = 1; clearInterval(jishi);
}
}
- },500)
+ },500)--*/
});
//--更新默认地址--,看一下是不是跳到地址页面
@@ -171,7 +208,6 @@ Page({
//-------------------获取物流---------------
get_wuliu(func) {
-
var th = this;
to.getwuliu(function (e) {
th.setData({ wu_arr: e })
@@ -256,9 +292,9 @@ Page({
var th = this,app=getApp();
a.get("/api/weshop/cart/list", {
data: {
- user_id: to.globalData.user_id, selected:1,
+ user_id: to.globalData.user_id, selected:1,state:0,
store_id: oo.stoid, pageSize: 600 },
- success:function (su) {
+ success:async function (su) {
//按门店分类的数组
var arr = new Array();
var carr = su.data.data.pageData;
@@ -266,8 +302,11 @@ Page({
for (var i = 0; i < carr.length; i++) {
var item = carr[i];
+ //要把优惠活动加入,prom_goods_map中,赠品不要运算
+ if(item.prom_type==3 && item.is_gift!=1){
+ await th.add_prom_goods_map(item);
+ }
item.original_img = oo.imghost + item.original_img;
-
/*----接口要弄出来的,先顶着-----*/
var pcid = item.pick_id;
var find = 0;
@@ -320,13 +359,23 @@ Page({
arr.push(ie);
}
}
+ //深拷贝
+ th.data.old_cartlist= JSON.parse(JSON.stringify(arr));
th.setData({
cartlist: arr,
- }),
-
- th.calculatePrice();
+ });
//--- 获取一下看有没有优惠券 ----
- th.get_cart_quan();
+ setTimeout(function () {
+ var frozenQuan=null;
+ var url0="/api/weshop/users/frozenQuan/listFrozenQuan/"+app.globalData.user_id;
+ app.request.promiseGet(url0,{1:1}).then(res=>{
+ if(res.data.code==0){ frozenQuan=res.data.data; th.data.frozenQuan=frozenQuan; }
+ th.calculatePrice();
+ th.get_cart_quan();
+ })
+
+ },500)
+
}
});
},
@@ -360,7 +409,6 @@ Page({
var item=th.data.wu_arr[k]; if(def_exp_code==item.code){ m_wind=k; }
}
}
-
switch (gd.prom_type){
case 0:
case 2:
@@ -371,21 +419,99 @@ Page({
//--此时开始计算商品的使用券相关,如果有等级价还要计算和等级价相关的,
// 如果有优惠促销,还要把促销的部分计算在内,因为促销还有不能使用优惠券--
t.data.data.shop_price=gg.goods_price;
+ t.data.data.goods_price=gg.goods_price;
+ t.data.data.goods_num=gg.goods_num;
th.data.ckeck_quan_price=t.data.data.shop_price*gg.goods_num;
th.data.check_quan_price_list=t.data.data.shop_price*gg.goods_num+"";
th.data.check_quan_ware_list=t.data.data.erpwareid+"";
t.data.data.prom_id = 0;
t.data.data.prom_type = 0;
-
- th.setData({
- bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind,
- bn_pick: gg.pick_id, bn_t_exp_t: distr_t
- });
- //计算价格
- th.calculatePrice2();
- //获取优惠券
- th.get_buy_now_quan();
+
+ //如果立即购买那边过来,就要读取接口,查看活动的优惠内容
+ if(gg.prom_type==3){
+ t.data.data.prom_id = gg.prom_id ;
+ t.data.data.prom_type =3;
+ //如果是优惠活动,就要调用活动,计算价格
+ th.buy_now_prom_goods(gg.prom_id, t.data.data,function (data) {
+ //判断一下购买商品的数量是不是超过
+ if(data.gift_goods_id){
+ var num=1;
+ if(data.is_bz==1){
+ num=data.bs;
+ if (num > data.gift_limitnum) num = 0;
+ }
+ //如果赠品数量超出礼品库存,就取消
+ if(num>data['gift_storecount']) num=0;
+ if(num>0){
+ var ob={};
+ ob.is_gift=1;
+ ob.prom_id=data.prom_id;
+ ob.goods_id=data.gift_goods_id;
+ ob.goods_name=data.gift_goods_name;
+ ob.goods_color=data.gift_goods_color;
+ ob.goods_spec=data.gift_goods_spec;
+ ob.original_img=os.imghost+data.gift_original_img;
+ ob.market_price=data.gift_market_price;
+ ob.gift_id=data.gift_id;
+ ob.shop_price=0;
+ ob.buynum=num;
+ ob.weight=data.gift_weight; //商品的重量
+ ob.exp_sum_type=data.gift_exp_sum_type; //商品的物流计算方式
+ th.setData({buy_now_gift_goods:ob});
+ }
+ }
+
+ th.setData({
+ bn_goods: data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind,
+ bn_pick: gg.pick_id, bn_t_exp_t: distr_t
+ });
+
+ //计算价格
+ th.calculatePrice2();
+ //获取优惠券
+ th.get_buy_now_quan();
+
+ })
+
+ }else{
+ //--看是不是搭配促销--
+ if(gg.prom_type==5){
+ t.data.data.prom_id = gg.prom_id ;
+ t.data.data.prom_type =5;
+ th.setData({collocation_goods:gg.collocation_goods});
+
+ var cart_arr=new Array();
+ var narr=gg.collocation_goods;
+ narr.push(t.data.data);
+ var ie = {
+ pickup_id: gg.pick_id, pname: gg.pick_name, goods: narr, exp_type: et, wind: m_wind, distr_t: distr_t,
+ goods_price: 0, shipping_price: 0, user_money: 0, total_amount: 0, order_amount: 0, user_note:0};
+ cart_arr.push(ie);
+ th.data.old_cartlist=cart_arr;
+ }
+ th.setData({
+ bn_goods: t.data.data, bn_pickname: gg.pick_name, bn_exp_type: et,index:m_wind,
+ bn_pick: gg.pick_id, bn_t_exp_t: distr_t
+ });
+
+ //--搭配促销也是按照购物车的方式来计算优惠券--
+ if(gg.prom_type==5){
+ var frozenQuan=null;
+ var url0="/api/weshop/users/frozenQuan/listFrozenQuan/"+app.globalData.user_id;
+ app.request.promiseGet(url0,{1:1}).then(res=> {
+ if(res.data.code==0){ frozenQuan=res.data.data; th.data.frozenQuan=frozenQuan; }
+ //计算价格
+ th.calculatePrice2();
+ th.get_cart_quan();
+ });
+ }else{
+ //计算价格
+ th.calculatePrice2();
+ //获取优惠券,
+ th.get_buy_now_quan();
+ }
+ }
break;
case 1: //---秒杀-----
@@ -461,14 +587,16 @@ Page({
to.getConfig2(function(ee){
to.getwuliuprice( async function (rs) {
- var all_price=0; //所有的商品总价
- var all_shipping_m= 0; //所有的物流总价
- var all_total_m = 0; //所有的订单应付总价
- var all_order_m = 0; //所有的订单应付总价
- var all_user_m=0; //所有的订单用户使用金额
+ var all_price=0; //所有的商品总价
+ var all_shipping_m= 0; //所有的物流总价
+ var all_total_m = 0; //所有的订单应付总价
+ var all_order_m = 0; //所有的订单应付总价
+ var all_user_m=0; //所有的订单用户使用金额
var all_coupon_price_m=0; //所有的订单用户使用优惠券价格
- var umoney = th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money;
+ var all_cutprice=0; //所有的优惠减件
+ var all_order_prom=0; //所有的订单优惠
+ var umoney = th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money;
var freight_free = ee.freight_free; //全场满多少包邮
var no_ex_id=ee.no_ex_id;
var no_ex_good=null;
@@ -483,11 +611,25 @@ Page({
by_qc=res.data.data[0];
}
})
- }
-
- var c_arr=th.data.cartlist;
+ };
+ var c_arr=JSON.parse(JSON.stringify(th.data.old_cartlist));
//---循环购物车---
- for(var i=0;i {
+ if (res.data.code == 0 && res.data.data.condition) {
+ var get_data = res.data.data;
+ item_map.is_bz = get_data.is_bz; //是不是倍增
+ item_map.bs = get_data.bs; //是不是倍数
+ item_map.is_past = get_data.is_past; //是不是包邮
+ item_map.prom_price = get_data.price?get_data.price:item_map.price;
+ item_map.s_intValue = get_data.intValue;
+ item_map.s_coupon_id = get_data.coupon_id;
+ item_map.s_coupon_num = get_data.coupon_num;
+ if(get_data.gift_id && get_data.goodsinfo) {
+ item_map.gift_id = get_data.gift_id;
+ item_map.gift_goods_id = get_data.goods_id;
+ item_map.gift_goods_name = get_data.goods_name;
+ item_map.gift_goods_color = get_data.goodsinfo.goods_color ? get_data.goodsinfo.goods_color : '';
+ item_map.gift_goods_spec = get_data.goodsinfo.goods_spec ? get_data.goodsinfo.goods_spec : '';
+ item_map.gift_original_img = get_data.goodsinfo.original_img;
+ item_map.gift_limit_num = get_data.limit_num;
+ item_map.gift_storecount = get_data.gift_storecount;
+ item_map.gift_weight = get_data.goodsinfo.weight;
+ item_map.gift_exp_sum_type = get_data.goodsinfo.exp_sum_type;
+ }
+ item_map.s_libao = get_data.libao;
+ item_map.s_lb_num = get_data.lb_num;
+ }
+ })
+ }
+ //--------循环计算商品是不是包邮,是不是使用优惠券-----------
+ for(var j=0;j0 && o_price>freight_free && c_arr[i].exp_type == 0 && (by_qc.region_list || by_qc.goods_list) ){
+ if(no_ex_id && freight_free>0 && o_price>=freight_free && cart_item.exp_type == 0 && (by_qc.region_list || by_qc.goods_list) ){
//如果有设置不包邮区域的时候
if(by_qc.region_list!="" && by_qc.region_list!=null && by_qc.region_list!=undefined ){
if(th.check_by_area(by_qc.region_list)){
@@ -519,13 +761,13 @@ Page({
}
}
- //--如果是物流,且选择了地址,就要开始显示包邮券--
- if (c_arr[i].exp_type == 0 && th.data.user_addr != null) {
+ //--如果是物流,且选择了地址,就要开始显示包邮券,且包邮券也已经优惠了优惠活动的金额--
+ if (cart_item.exp_type == 0 && th.data.user_addr != null) {
//看是不是有调用过包邮券
if(!th.data.isget_by_quan[pickid]){
- //--判断要不要显示包邮券,链式调用接口---
- getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea",{
- data:{store_id:os.stoid,isuse:0,condition:o_price,user_id:getApp().globalData.user_id,pageSize:2000}
+ //--判断要不要显示包邮券,调用接口,因为有for循环---
+ await getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea",{
+ data:{store_id:os.stoid,isuse:0,condition:q_conditin,user_id:getApp().globalData.user_id,pageSize:2000}
}).then(res=>{
if(res.data.code==0 && res.data.data.total>0){
//此时要循环判断包邮的地区,不包邮商品是不是符合
@@ -538,7 +780,6 @@ Page({
for(var ii in goods){
g_arr.push(goods[ii].goods_id);
}
-
if(item.region_list && th.check_by_area(item.region_list)) continue; //如果是不包邮区域
if(item.goods_list){
var no_goods_arr=item.goods_list.split(",");
@@ -548,7 +789,10 @@ Page({
}
if(arr){
th.data.get_by_quan_list_cart[pickid]=arr;
- th.setData({get_by_quan_list_cart:th.data.get_by_quan_list_cart});
+ //th.setData({get_by_quan_list_cart:th.data.get_by_quan_list_cart});
+ if(th.data.is_b_now){
+ th.setData({get_by_quan_list:arr});
+ }
}
th.data.isget_by_quan[pickid]=1;
}
@@ -589,18 +833,25 @@ Page({
for(var j=0;j=freight_free && freight_free>0 && !is_good_no_by && th.data.is_no_by[pickid]!=1) continue;
+ if(o_price>=freight_free && freight_free>0 && !is_good_no_by && th.data.is_no_by[pickid]!=1){
+ continue;
+ }
//--如果是包邮券使用的情况下,如果商品是包邮的,那么就不进行计算--
- if(th.data.using_quan[pickid] && th.data.using_quan[pickid].isby==1 && !is_good_no_by) continue;
+ if(th.data.using_quan[pickid] && th.data.using_quan[pickid].isby==1 && !is_good_no_by){
+ continue;
+ }
+
//----------------如果是选择了物流---------------------
- if (c_arr[i].exp_type == 0 && item[j].is_free_shipping==0){
+ if(cart_item.exp_type == 0 && item[j].is_free_shipping==0){
//如果地址不为空
if (th.data.user_addr!=null){
switch (item[j]['exp_sum_type']) {
@@ -619,24 +870,24 @@ Page({
}
}
}
-
-
+
+
//计算物流价格
if (c_arr[i].exp_type == 0) {
freight_free=0; //后面不在进行判断
var code = th.data.wu_arr[c_arr[i].wind].code;
- th.data.cartlist[i].shipping_price =
+ cart_item.shipping_price =
th.calculatewuliu(code, o_shipping_price, goods_weight,
goods_piece,th.data.user_addr, freight_free, o_price, rs);
if(!th.data.using_quan[pickid] || th.data.using_quan[pickid].isby!=1){
- if( th.data.cartlist[i].shipping_price ==0) th.data.is_by[pickid]=0; //已经全场包邮,就不要选择券了
+ if( cart_item.shipping_price ==0) th.data.is_by[pickid]=1; //已经全场包邮,就不要选择券了
}
}else{
- th.data.cartlist[i].shipping_price=0;
+ cart_item.shipping_price=0;
}
- th.data.cartlist[i].shipping_price=th.data.cartlist[i].shipping_price.toFixed(2);
+ cart_item.shipping_price=cart_item.shipping_price.toFixed(2);
//---如果有选择优惠券的情况下---
var quan_price=0;
var coupon_price=0;
@@ -660,7 +911,7 @@ Page({
if (res.data.code == 0 && res.data.data.length > 0) {
var q_data = res.data.data;
//--存储商品优惠的内容--
- th.data.cartlist[i].quan_youhui_list = q_data;
+ cart_item.quan_youhui_list = q_data;
for (var k in q_data)
quan_price += q_data[k].WareCashSum;
}
@@ -669,52 +920,96 @@ Page({
}
//总价计算,总价不包含运费
- th.data.cartlist[i].order_amount= (o_price -quan_price).toFixed(2);
- th.data.cartlist[i].total_amount= o_price.toFixed(2);
+ cart_item.order_amount= (o_price -quan_price).toFixed(2);
+ cart_item.total_amount= f_o_price.toFixed(2);
+
+ var order_prom_amount=0; var order_prom_id=0; var o_condition=cart_item.order_amount;
+ var order_m=0;
+ //---判断是不是有订单优惠---
+ await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion",{
+ data:{store_id:os.stoid,orderAmount:cart_item.order_amount}
+ }).then(res=>{
+ if(res.data.code==0){
+ var ord_prom=res.data.data;
+ order_prom_id = ord_prom['id'];
+ switch (ord_prom['type']) {
+ case 0:
+ order_m = Math.round(o_condition * ord_prom['expression'])/100;//满额打折
+ order_prom_amount=(o_condition -order_m).toFixed(2);
+ break;
+ case 1:
+ //order_m = o_condition - ord_prom['expression'];//满额优惠金额
+ order_prom_amount= ord_prom['expression'];
+ break;
+ }
+ }
+ })
+ cart_item.order_prom_amount=0;
+ //--订单优惠的显示--
+ if(order_prom_id>0){
+ cart_item.order_amount= (o_price -quan_price-order_prom_amount).toFixed(2);
+ cart_item.order_prom_id=order_prom_id;
+ cart_item.order_prom_amount=order_prom_amount;
+ }
coupon_price=quan_price;
- if( th.data.cartlist[i].order_amount<0){
- th.data.cartlist[i].order_amount=0;
+ if( cart_item.order_amount<0){
+ cart_item.order_amount=0;
coupon_price=o_price;
}
- th.data.cartlist[i].total_amount= parseFloat(th.data.cartlist[i].total_amount)+parseFloat(th.data.cartlist[i].shipping_price); //总金额
- th.data.cartlist[i].order_amount=parseFloat(th.data.cartlist[i].order_amount)+parseFloat(th.data.cartlist[i].shipping_price); //总金额
+ cart_item.total_amount= parseFloat(cart_item.total_amount)+parseFloat(cart_item.shipping_price); //总金额
+ cart_item.order_amount=parseFloat(cart_item.order_amount)+parseFloat(cart_item.shipping_price); //总金额
+ cart_item.total_amount= cart_item.total_amount.toFixed(2);
+ cart_item.order_amount=cart_item.order_amount.toFixed(2);
- th.data.cartlist[i].total_amount= th.data.cartlist[i].total_amount.toFixed(2);
- th.data.cartlist[i].order_amount=th.data.cartlist[i].order_amount.toFixed(2);
+ //搭配购在使用余额
+ if(th.data.bn_use_money==1 && th.data.is_b_now==1){
+
+ if (umoney > cart_item.order_amount) {
+ cart_item.user_money = cart_item.order_amount;
+ umoney = umoney - cart_item.order_amount;
+ }else {
+ cart_item.user_money = umoney;
+ umoney=0;
+ }
- //--------------如果使用余额---------------------
- if (th.data.js_use_money == 1) {
- if (umoney > th.data.cartlist[i].order_amount) {
- th.data.cartlist[i].user_money = th.data.cartlist[i].order_amount;
- umoney = umoney - th.data.cartlist[i].order_amount;
- }else {
- th.data.cartlist[i].user_money = umoney;
- umoney=0;
- }
}else{
- th.data.cartlist[i].user_money=0;
- }
+ //--------------如果使用余额,购物车购买---------------------
+ if (th.data.js_use_money == 1) {
+ if (umoney > cart_item.order_amount) {
+ cart_item.user_money = cart_item.order_amount;
+ umoney = umoney - cart_item.order_amount;
+ }else {
+ cart_item.user_money = umoney;
+ umoney=0;
+ }
+ }else{
+ cart_item.user_money=0;
+ }
+ }
+
+
- th.data.cartlist[i].user_money = parseFloat(th.data.cartlist[i].user_money).toFixed(2);
+ cart_item.user_money = parseFloat(cart_item.user_money).toFixed(2);
- if (coupon_price>0) th.data.cartlist[i].coupon_price=coupon_price.toFixed(2);
- else th.data.cartlist[i].coupon_price = coupon_price
- if(quan_no) th.data.cartlist[i].quan_no = quan_no;
+ if (coupon_price>0) cart_item.coupon_price=coupon_price.toFixed(2);
+ else cart_item.coupon_price = coupon_price
+ if(quan_no) cart_item.quan_no = quan_no;
-
- th.data.cartlist[i].goods_price = o_price.toFixed(2);
- th.data.cartlist[i].order_amount= th.data.cartlist[i].order_amount- th.data.cartlist[i].user_money; //会员使用余额
+ //cart_item.goods_price = o_price.toFixed(2);
+ cart_item.order_amount= cart_item.order_amount- cart_item.user_money; //会员使用余额
- all_price += parseFloat(o_price);
- all_total_m += parseFloat(th.data.cartlist[i].total_amount);
- all_shipping_m += parseFloat(th.data.cartlist[i].shipping_price);
- all_order_m += parseFloat(th.data.cartlist[i].order_amount);
- all_user_m += parseFloat(th.data.cartlist[i].user_money);
- all_coupon_price_m+= parseFloat(th.data.cartlist[i].coupon_price);
+ all_price += parseFloat(f_o_price);
+ all_total_m += parseFloat(cart_item.total_amount);
+ all_shipping_m += parseFloat(cart_item.shipping_price);
+ all_order_m += parseFloat(cart_item.order_amount);
+ all_user_m += parseFloat(cart_item.user_money);
+ all_coupon_price_m+= parseFloat(cart_item.coupon_price);
+ all_cutprice+=parseFloat(cart_item.cut_price);
+ all_order_prom+=parseFloat(cart_item.order_prom_amount);
}
all_shipping_m=parseFloat(all_shipping_m).toFixed(2);
@@ -724,6 +1019,8 @@ Page({
all_user_m = parseFloat(all_user_m).toFixed(2);
all_total_m = parseFloat(all_total_m).toFixed(2);
all_coupon_price_m = parseFloat(all_coupon_price_m).toFixed(2);
+ all_cutprice=all_cutprice.toFixed(2);
+ all_order_prom=all_order_prom.toFixed(2);
var atxt = "formData.total_amount";
var atxt1 = "formData.order_amount";
@@ -731,37 +1028,54 @@ Page({
var atxt3 = "formData.user_money";
var atxt4 = "formData.shipping_price";
var atxt5 = "formData.coupon_price";
+ var atxt6 = "formData.cut_price";
+ var atxt7 = "formData.order_prom_amount";
th.setData({ [atxt]: all_total_m, [atxt1]: all_order_m,
- [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m, [atxt5]: all_coupon_price_m })
-
+ [atxt2]: all_price, [atxt3]: all_user_m, [atxt4]: all_shipping_m,
+ [atxt5]: all_coupon_price_m,[atxt6]: all_cutprice,
+ [atxt7]: all_order_prom,
+ })
+ th.data.order_prom_list_cart=c_arr;
});
});
},
//---------计算立即购买----------
calculatePrice2: function () {
-
var th = this, good = this.data.bn_goods;
+ //搭配的计算要用购物的车计算方法
+ if(good.prom_type==5){
+ th.calculatePrice();
+ return false;
+ }
//-----------计算商品总价--------------
var allpice = good.shop_price * good.buynum;
+ var cut_price=0;
+ if(good.prom_type==3 && good.prom_price){
+ cut_price=allpice-good.prom_price;
+ }
allpice=parseFloat(allpice).toFixed(2);
var txt = "formData.all_price";
th.setData({ [txt]: allpice, });
- console.log(th.data.formData);
+ if(cut_price){
+ var c_txt="formData.cut_price";
+ th.setData({ [c_txt]: cut_price, });
+
+ }
to.getConfig2(function (ee) {
to.getwuliuprice(async function (rs) {
var o_shipping_price = 0, goods_weight = -1, goods_piece = -1;
- //-----------当地址不为空,且是物流时,计算物流费用----------
- if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 ){
-
- //看是不是有调用过包邮券
- if(!th.data.isget_by_quan[th.data.bn_pick]){
- //--判断要不要显示包邮券,链式调用接口---
+ //-----------当地址不为空,且是物流时,计算物流费用,并同时商品不是优惠活动的包邮----------
+ if (th.data.user_addr != null && th.data.bn_exp_type == 0 && good.is_free_shipping == 0 && good.is_past!=1 ){
+ //看是不是有调用过包邮券
+ if(!th.data.isget_by_quan[th.data.bn_pick] && good.is_xz_yh!=1){
+ var condition=allpice-cut_price;
+ //--判断要不要显示包邮券,链式调用接口,调取包邮券,已经是减了优惠的金额---
getApp().request.promiseGet("/api/weshop/userfeemail/pageAndArea",{
- data:{store_id:os.stoid,isuse:0,condition:allpice,user_id:getApp().globalData.user_id,pageSize:2000}
+ data:{store_id:os.stoid,isuse:0,condition:condition,user_id:getApp().globalData.user_id,pageSize:2000}
}).then(res=>{
if(res.data.code==0 && res.data.data.total>0){
//此时要循环判断包邮的地区,不包邮商品是不是符合
@@ -776,7 +1090,7 @@ Page({
if(arr){
th.setData({get_by_quan_list:arr});
}
- th.data.isget_by_quan[th.data.bn_pick]=1;
+ th.data.isget_by_quan[th.data.bn_pick]=1;
}
})
}
@@ -799,14 +1113,18 @@ Page({
var freight_free = ee.freight_free; //全场满多少包邮
var no_ex_id=ee.no_ex_id;
th.data.is_no_by[th.data.bn_pick]=0;
-
+
+
+ var no_by_data=null;
+ var gift_freight_free=freight_free;
//有不包邮区域,且不免运费
- if(no_ex_id && freight_free>0 && freight_free<=allpice){
+ if(no_ex_id && freight_free>0 && freight_free<=allpice-cut_price){
//-----------获取不包邮区域,不包邮商品-------
await getApp().request.promiseGet("/api/weshop/areaFeemail/getAreaGoods",{
data:{store_id:os.stoid,id:no_ex_id}
}).then(res=>{
if(res.data.code==0){
+ no_by_data=res.data.data[0];
//如果有设置不包邮区域的时候
if(res.data.data[0].region_list){
if(th.check_by_area(res.data.data[0].region_list)){
@@ -829,7 +1147,13 @@ Page({
//--------------开始计算物流------------------
var shipping_price=
th.calculatewuliu(code, o_shipping_price, goods_weight,
- goods_piece, th.data.user_addr, freight_free, allpice, rs);
+ goods_piece, th.data.user_addr, freight_free, allpice-cut_price, rs);
+
+ //如果有赠品的时候,也要计算赠品的物流费用
+ if(th.data.buy_now_gift_goods){
+ shipping_price=th.get_now_gift_goods_wuliu(code, o_shipping_price, th.data.user_addr, gift_freight_free, allpice-cut_price, rs,shipping_price,no_by_data);
+ }
+
if(shipping_price<=0){
th.data.is_by[th.data.bn_pick]=1; //已经是包邮了,就不要选择包邮券
}
@@ -863,39 +1187,132 @@ Page({
}
})
}
-
}
//-----------------支付价,优惠券不减物流-----------------
var total_m = (parseFloat(allpice)).toFixed(2);
- var order_m = (parseFloat(allpice)-quan_price).toFixed(2);
-
+ var order_m = (parseFloat(allpice-cut_price)-quan_price).toFixed(2);
var coupon_price=quan_price; //优惠券优惠了多少钱
if(order_m<0) {
order_m=0;coupon_price=parseFloat(order_m).toFixed(2);
}
+ //--看一下有没有订单优惠--
+ var o_condition=parseFloat(order_m);
+ if(o_condition>0){
+ th.check_is_order_prom(o_condition,function () {
+ var order_prom_amount=0; var order_prom_id=0;
+ if(th.data.order_prom[th.data.bn_pick]){
+ var ord_prom=th.data.order_prom[th.data.bn_pick];
+ order_prom_id = ord_prom['id'];
+ switch (ord_prom['type']) {
+ case 0:
+ order_m = Math.round(o_condition * ord_prom['expression'])/100;//满额打折
+ order_prom_amount=(o_condition -order_m).toFixed(2);
+ break;
+ case 1:
+ order_m = o_condition - ord_prom['expression'];//满额优惠金额
+ order_prom_amount= ord_prom['expression'];
+ break;
+ }
+ }
+ //--订单优惠的显示--
+ if(order_prom_id>0){
+ var order_prom_txt1="formData.order_prom_id";
+ var order_prom_txt2="formData.order_prom_amount";
+ th.setData({ [order_prom_txt1]: order_prom_id,[order_prom_txt2]: order_prom_amount})
+ }
- total_m= parseFloat( total_m)+ parseFloat( th.data.formData.shipping_price);
- order_m = parseFloat(order_m)+ parseFloat( th.data.formData.shipping_price);
-
- var atxt= "formData.total_amount";
- th.setData({ [atxt]: total_m, })
-
- var txt = "formData.user_money";
- var txt2 = "formData.order_amount";
- var txt3="formData.coupon_price";
- var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
- //--------------如果使用余额---------------------
- if (th.data.bn_use_money == 1) {
- if (amoney> order_m) {
- order_m = order_m.toFixed(2);
- th.setData({ [txt]: order_m, [txt2]:0,[txt3]:coupon_price })
+ total_m= parseFloat( total_m)+ parseFloat( th.data.formData.shipping_price);
+ order_m = parseFloat(order_m)+ parseFloat( th.data.formData.shipping_price);
+ var atxt= "formData.total_amount";
+ th.setData({ [atxt]: total_m, })
+
+ var txt = "formData.user_money";
+ var txt2 = "formData.order_amount";
+ var txt3="formData.coupon_price";
+ var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
+ //--------------如果使用余额---------------------
+ if (th.data.bn_use_money == 1) {
+ if (amoney> order_m) {
+ order_m = order_m.toFixed(2);
+ th.setData({ [txt]: order_m, [txt2]:0,[txt3]:coupon_price })
+ }else{
+ order_m =parseFloat(order_m - amoney);
+ order_m = order_m.toFixed(2);
+ th.setData({ [txt]: amoney, [txt2]: order_m,[txt3]:coupon_price })
+ }
+ }else{
+ th.setData({ [txt]: 0, [txt2]: order_m,[txt3]:coupon_price })
+ }
+ //优惠活动送积分
+ if(good.s_intValue){
+ txt = "formData.give_integral";
+ th.setData({ [txt]:good.s_intValue });
+ }
+ //优惠送券
+ if(good.s_coupon_id){
+ var i_txt = "formData.give_coupon_id";
+ //这个是json格式的
+ var i_txt1 = "formData.g_coupon_num";
+ var ob=[{"num":good.s_coupon_num,"c_id":good.s_coupon_id}];
+ ob=JSON.stringify(ob);
+ th.setData({ [i_txt]:good.s_coupon_id,[i_txt1]:ob });
+ }
+ //优惠礼包
+ if(good.s_libao){
+ var l_txt = "formData.give_lb_id";
+ //这个是json格式的
+ var l_txt1 = "formData.g_lb_num";
+ var ob=[{"num":good.s_lb_num,"l_id":good.s_libao}];
+ ob=JSON.stringify(ob);
+ th.setData({ [l_txt]:good.s_libao,[l_txt1]:ob });
+ }
+ })
+ }else{
+ total_m= parseFloat( total_m)+ parseFloat( th.data.formData.shipping_price);
+ order_m = parseFloat(order_m)+ parseFloat( th.data.formData.shipping_price);
+ var atxt= "formData.total_amount";
+ th.setData({ [atxt]: total_m, })
+
+ var txt = "formData.user_money";
+ var txt2 = "formData.order_amount";
+ var txt3="formData.coupon_price";
+ var amoney = parseFloat(th.data.userinfo.user_money - th.data.txmon - th.data.userinfo.frozen_money);
+ //--------------如果使用余额---------------------
+ if (th.data.bn_use_money == 1) {
+ if (amoney> order_m) {
+ order_m = order_m.toFixed(2);
+ th.setData({ [txt]: order_m, [txt2]:0,[txt3]:coupon_price })
+ }else{
+ order_m =parseFloat(order_m - amoney);
+ order_m = order_m.toFixed(2);
+ th.setData({ [txt]: amoney, [txt2]: order_m,[txt3]:coupon_price })
+ }
}else{
- order_m =parseFloat(order_m - amoney);
- order_m = order_m.toFixed(2);
- th.setData({ [txt]: amoney, [txt2]: order_m,[txt3]:coupon_price })
+ th.setData({ [txt]: 0, [txt2]: order_m,[txt3]:coupon_price })
+ }
+ //优惠活动送积分
+ if(good.s_intValue){
+ txt = "formData.give_integral";
+ th.setData({ [txt]:good.s_intValue });
+ }
+ //优惠送券
+ if(good.s_coupon_id){
+ var i_txt = "formData.give_coupon_id";
+ //这个是json格式的
+ var i_txt1 = "formData.g_coupon_num";
+ var ob=[{"num":good.s_coupon_num,"c_id":good.s_coupon_id}];
+ ob=JSON.stringify(ob);
+ th.setData({ [i_txt]:good.s_coupon_id,[i_txt1]:ob });
+ }
+ //优惠礼包
+ if(good.s_libao){
+ var l_txt = "formData.give_lb_id";
+ //这个是json格式的
+ var l_txt1 = "formData.g_lb_num";
+ var ob=[{"num":good.s_lb_num,"l_id":good.s_libao}];
+ ob=JSON.stringify(ob);
+ th.setData({ [l_txt]:good.s_coupon_id,[l_txt1]:ob });
}
- }else{
- th.setData({ [txt]: 0, [txt2]: order_m,[txt3]:coupon_price })
}
});
@@ -904,13 +1321,14 @@ Page({
//--------------------提交订单-----------------------
async submitForm(t){
+ var sub_value=t;
+
if(this.data.is_summit_ing==1) return false; //--提交中退出--
this.data.is_summit_ing=1;
var th=this,pdata=new Array();
var ff=true;
//------------立即购买-------------
- if (th.data.is_b_now==1){
- console.log("buy_new");
+ if (th.data.is_b_now==1 && th.data.bn_goods.prom_type!=5){
if(th.data.bn_exp_type == 0 && th.data.user_addr==null ){
ff = false; getApp().my_warnning("请选择收货地址",0,th);
@@ -920,17 +1338,12 @@ Page({
var addr = th.data.user_addr;
if (th.data.bn_exp_type == 1) addr=null;
- console.log(th.data.formData);
- console.log(th.data.wu_arr);
- console.log(th.data.bn_exp_type);
-
if(th.data.bn_exp_type==0)
if(th.data.wu_arr==null || th.data.wu_arr.length<=0){
getApp().my_warnning("读取物流失败",0,th);
return false;
}
-
var item={
'user_id': to.globalData.user_id,
'consignee': addr == null ? "" : addr.consignee,
@@ -957,8 +1370,39 @@ Page({
'exp_type': th.data.bn_exp_type, //配送方式
'order_goods':new Array(),
};
+ //是不是重新提交
+ if(th.data.is_continue==1) item.is_continue=1;
+
+ var order_prom_list={};
+ //--判断有没有优惠活动--
+ if(th.data.order_prom[item.pickup_id]){
+ if(th.data.formData.order_prom_amount>0){
+ order_prom_list.order_prom_id=th.data.formData.order_prom_id;
+ order_prom_list.order_prom_amount=th.data.formData.order_prom_amount;
+ }
+ }
+
+ //--判断优惠活动的提交--
+ if(th.data.formData.cut_price>0){
+ order_prom_list.discount_amount=th.data.formData.cut_price.toFixed(2);
+ var ob=[{"prom_id":th.data.bn_goods.prom_id,"dis":th.data.formData.cut_price.toFixed(2),"ispt":0}]
+ order_prom_list.prom_pt_json=JSON.stringify(ob);
+ }
+ if(th.data.formData.give_integral>0){
+ order_prom_list.give_integral=th.data.formData.give_integral;
+ }
+ if(th.data.formData.give_coupon_id>0){
+ order_prom_list.give_coupon_id=th.data.formData.give_coupon_id;
+ order_prom_list.g_coupon_num=th.data.formData.g_coupon_num;
+ }
+ if(th.data.formData.give_lb_id>0){
+ order_prom_list.give_lb_id=th.data.formData.give_lb_id;
+ order_prom_list.g_lb_num=th.data.formData.g_lb_num;
+ }
+ item.order_prom_list=order_prom_list;
+
//组装优惠券的钱
- if(th.data.formData.coupon_price){
+ if(parseFloat(th.data.formData.coupon_price)>0){
item.coupon_price=th.data.formData.coupon_price;
item.coupon_no=th.data.using_quan[th.data.bn_pick].coupon_no;
}
@@ -992,7 +1436,6 @@ Page({
return false;
}
}
-
//--组装优惠券的钱--
if(th.data.formData.coupon_price){
item.coupon_price=th.data.formData.coupon_price;
@@ -1000,8 +1443,26 @@ Page({
goods.quan_num=th.data.formData.coupon_price;
goods.quan_no= item.coupon_no;
}
-
item.order_goods.push(goods);
+
+ //--如果有赠品的时候,赠品也要提交---
+ if(th.data.buy_now_gift_goods){
+ var gift_gg=th.data.buy_now_gift_goods;
+ var g_goods={
+ 'goods_id': gift_gg.goods_id,
+ 'goods_name': gift_gg.goods_name,
+ 'goods_sn': gift_gg.goods_sn,
+ 'goods_num': gift_gg.buynum,
+ 'market_price': gift_gg.market_price,
+ 'goods_price': 0,
+ 'member_goods_price': 0,
+ 'store_id': oo.stoid,
+ 'is_gift':1,
+ 'gift_id':gift_gg.gift_id,
+ 'prom_id':gift_gg.prom_id,
+ };
+ item.order_goods.push(g_goods);
+ }
pdata.push(item);
console.log(pdata);
@@ -1022,8 +1483,10 @@ Page({
return false;
}
- for (var i = 0; i < th.data.cartlist.length;i++){
- var t_item = th.data.cartlist[i];
+ var order_prom_list_cart=th.data.order_prom_list_cart;
+ //--组装推送数据--
+ for (var i = 0; i < order_prom_list_cart.length;i++){
+ var t_item = order_prom_list_cart[i];
var item = {
'user_id': to.globalData.user_id,
'consignee': addr == null ? th.data.userinfo.mobile : addr.consignee,
@@ -1049,17 +1512,42 @@ Page({
'exp_type': t_item.exp_type, //配送方式
'order_goods': new Array(),
};
+ //是不是重新提交
+ if(th.data.is_continue==1) item.is_continue=1;
//组装优惠券的钱
if(t_item.coupon_price) {
item.coupon_price = t_item.coupon_price;
item.coupon_no = th.data.using_quan[t_item.pickup_id].coupon_no;
- }
- if(t_item.quan_no) {
+ }else if(t_item.quan_no) {
item.coupon_no = t_item.quan_no;
item.coupon_price = 0;
}
+ var order_prom_list={};
+ //--判断有没有优惠活动--
+ if(t_item.order_prom_amount>0){
+ order_prom_list.order_prom_id=t_item.order_prom_id;
+ order_prom_list.order_prom_amount=t_item.order_prom_amount;
+ }
+ //--判断优惠活动的提交--
+ if(t_item.cut_price>0){
+ order_prom_list.discount_amount=t_item.cut_price.toFixed(2);
+ order_prom_list.prom_pt_json=JSON.stringify(t_item.prom_pt_json);
+ }
+ if(t_item.s_intValue>0){
+ order_prom_list.give_integral=t_item.s_intValue;
+ }
+ if(t_item.s_coupon_id>0){
+ order_prom_list.give_coupon_id=t_item.s_coupon_id;
+ order_prom_list.g_coupon_num= JSON.stringify(t_item.g_coupon_num);
+ }
+ if(t_item.s_libao>0){
+ order_prom_list.give_lb_id=t_item.s_libao;
+ order_prom_list.g_lb_num=JSON.stringify(t_item.g_lb_num);
+ }
+ if(Object.keys(order_prom_list).length>0)
+ item.order_prom_list=order_prom_list;
//-------------让商品添加到商品列表--------------------
for (var k = 0; k < t_item.goods.length;k++){
var g_item = t_item.goods[k];
@@ -1085,14 +1573,31 @@ Page({
}
}
- //如果是秒杀,团购,积分购,拼团
- if (g_item.prom_type==1){
- goods.prom_type = g_item.prom_type;
- goods.prom_id = g_item.prom_id;
- }else{
- goods.prom_type = 0;goods.prom_id =0;
+ //--判断活动的类型--
+ switch (g_item.prom_type) {
+ case 1:
+ goods.prom_type = g_item.prom_type;
+ goods.prom_id = g_item.prom_id;
+ break;
+ case 3:
+ goods.prom_type=3;
+ goods.prom_id=g_item.prom_id;
+ if(g_item.is_gift){
+ goods.is_gift=g_item.is_gift;
+ goods.gift_id=g_item.gift_id;
+ }
+ break;
+ case 5:
+ goods.prom_type=5;
+ goods.prom_id=g_item.prom_id;
+ if(g_item.is_collocation){
+ goods.is_collocation=g_item.is_collocation;
+ }
+ break
+ default:
+ goods.prom_type = 0;goods.prom_id =0;
}
-
+
//如果不立即购买或者秒杀,如果是线下库存购买的时候
if(goods.prom_type==0 && th.data.sales_rules==2){
var isok=1;
@@ -1115,6 +1620,7 @@ Page({
if (pdata.length==0) return;
var str = JSON.stringify(pdata);
+
wx.showLoading({title: "加载中"});
wx.request({
url: oo.url + '/api/weshop/order/createWxdOrder',
@@ -1195,6 +1701,25 @@ Page({
else{
//--内容换行--
var msg=data.msg;
+ //赠品活动已经取消,无法赠送,是否继续买单?
+ if(msg.indexOf("是否继续买单")>0){
+ wx.showModal({
+ title:"提示",
+ content: data.msg,
+ cancelText:'取消',
+ confirmText:'确定',
+ showCancel: true,
+ success(res){
+ if(res.cancel){
+ return;
+ }else if(res.confirm){
+ th.data.is_continue=1;
+ th.submitForm(sub_value);
+ }
+ }
+ })
+ return;
+ }
if(msg.length>13){
msg=msg.slice(0, 13) + "\r\n"+ msg.slice(13);
}
@@ -1458,14 +1983,12 @@ Page({
//对于在其他门店已经选择了的券 要判断是否显示到界面
for(var i in quanlist){
- var is_using= th.check_in_sele(quanlist[i].CashRepNo,pickid);
- if(is_using) quanlist[i].is_using=1;
+ quanlist[i].is_using= th.check_in_sele(quanlist[i].CashRepNo,pickid);
}
- if(get_by_quan_list_cart){
+ if(get_by_quan_list_cart){
for(var i in get_by_quan_list_cart){
- var is_using= th.check_in_sele(get_by_quan_list_cart[i].no,pickid);
- if(is_using) quanlist[i].is_using=1;
+ get_by_quan_list_cart[i].is_using= th.check_in_sele(get_by_quan_list_cart[i].no,pickid);
}
th.setData({by_quan_list_cart:get_by_quan_list_cart});
}
@@ -1604,31 +2127,23 @@ Page({
return;
}
+ var pickid=th.data.selected_quan_pick; //现在选择的是哪一个门店
var ind = e.currentTarget.dataset.ind;
//--如果是立即购买的部分--
var txt="";var txt1=""; var quan_item=null;
if(th.data.is_b_now){
quan_item = this.data.get_by_quan_list[ind];
txt = "get_by_quan_list[" + ind + "].show_red";
+ var obj = {}; obj[txt] = 1;
+ this.setData(obj);
}else{
- txt = "by_quan_list_cart[" + ind + "].show_red";
- quan_item = th.data.by_quan_list_cart[ind]
-
- }
- var obj = {}; obj[txt] = 1;
- if (quan_item.show_red) {
- obj[txt] = 0;
- }
-
- //购物车购买过来的商品
- if(txt1){
- obj[txt1] = 1;
- if (quan_item.show_red) {
- obj[txt1] = 0;
- }
+ txt= "by_quan_list_cart[" + ind + "].show_red";
+ quan_item = th.data.by_quan_list_cart[ind];
+ var obj = {}; obj[txt] = 1;
+ this.setData(obj);
+ th.data.get_by_quan_list_cart[pickid]=JSON.parse(JSON.stringify(th.data.by_quan_list_cart)); //要把选中的弄回数组
}
- this.setData(obj);
if(using_quan[th.data.selected_quan_pick]){
using_quan[th.data.selected_quan_pick].is_nouse_red=0;
}
@@ -1640,12 +2155,12 @@ Page({
//--确认使用券---
confirm_quan:function () {
- var using_quan=this.data.using_quan
- var pickid=this.data.selected_quan_pick;
+ var using_quan=this.data.using_quan; //正在使用中的券列表
+ var pickid=this.data.selected_quan_pick; //选中的门店ID
var th=this;
- var selected_quan_list=this.data.selected_quan_list;
- var get_by_quan_list=this.data.get_by_quan_list;
- var by_quan_list_cart=this.data.by_quan_list_cart;
+ var selected_quan_list=this.data.selected_quan_list; //选择了那个门店的券列表
+ var get_by_quan_list=this.data.get_by_quan_list; //立即购买的包邮券列表
+ var by_quan_list_cart=this.data.by_quan_list_cart; //购物车购买的包邮券列表
//选择了的券
var sele_quan=null;
@@ -1747,7 +2262,6 @@ Page({
}
}
if(!is_find) arr.push(item);
-
}
return arr;
},
@@ -1868,68 +2382,96 @@ Page({
},
//-----获取购物车进来的劵-------
get_cart_quan:function () {
- var arr=this.data.cartlist,th=this;
- //------------开始计算使用优惠券相关------------
- for(var ind in arr){
- var ep=arr[ind];
- var goodlist=ep.goods;
- //--更优惠券抵用有关,立即购买的,如果是购物车,如果有等级价还有考虑等级价的东西
- //就要把相应的值,写入cartlist数组中--
- var ckeck_quan_price=0,
- check_quan_price_list='',
- check_quan_ware_list='';
-
- for(var i in goodlist){
- var gd=goodlist[i];
- //--如果是秒杀就跳出--
- if(gd.prom_type==1){ continue; }
- var item_price=gd.goods_price*gd.goods_num;
- ckeck_quan_price+=item_price;
-
- //--组装价格list--
- if (check_quan_price_list) {
- check_quan_price_list += "," +item_price;
- } else {
- check_quan_price_list = item_price;
- }
- //--组装商品的线下erpwareid--
- if (check_quan_ware_list) {
- check_quan_ware_list += "," +gd['erpwareid'];
- } else {
- check_quan_ware_list = gd['erpwareid'];
- }
- }
+ var th=this;
+ var is_xz_yh=1;
+ //等待值的出现
+ getApp().waitfor2(this,"g_cart_q_time","order_prom_list_cart",async function () {
+ var arr=th.data.order_prom_list_cart;
+ //如果系统有限制使用优惠券
+ if(th.data.is_close_quan) return false;
+ //------------开始计算使用优惠券相关------------
+ for(var ind in arr){
+ var ep=arr[ind];
+ var goodlist=ep.goods;
+ var pickup_id=ep.pickup_id;
+ //--更优惠券抵用有关,立即购买的,如果是购物车,如果有等级价还有考虑等级价的东西
+ //就要把相应的值,写入cartlist数组中--
+ var ckeck_quan_price=0,
+ check_quan_price_list='',
+ check_quan_ware_list='';
+
+ for(var i in goodlist){
+ var gd=goodlist[i];
+ //--如果是秒杀就跳出,如果是赠品,如果是限制使用优惠券--
+ if(gd.prom_type==1 || gd.is_gift ){ continue; }
+ //如果有限制使用优惠券,就要返回
+ if(gd.prom_type==3){
+ if(th.data.prom_goods_map[pickup_id][gd.prom_id].is_xz_yh) continue;
+ th.data.prom_goods_map[pickup_id][gd.prom_id].coupon_sele=1;
+ }
+ is_xz_yh=0;
+ var item_price=gd.goods_price*gd.goods_num;
+ ckeck_quan_price+=item_price;
+ //--组装价格list--
+ if (check_quan_price_list) {
+ check_quan_price_list += "," +item_price;
+ } else {
+ check_quan_price_list = item_price;
+ }
+ //--组装商品的线下erpwareid--
+ if (check_quan_ware_list) {
+ check_quan_ware_list += "," + encodeURIComponent(gd['erpwareid']);
+ } else {
+ check_quan_ware_list = encodeURIComponent(gd['erpwareid']);
+ }
+ }
+ //优惠券优惠的金额要控制到优惠券的选择条件
+ var cut_price=0;
+ for(var i in th.data.prom_goods_map[pickup_id]){
+ var obj=th.data.prom_goods_map[pickup_id][i];
+ if(obj.coupon_sele){
+ cut_price+=obj.price-obj.prom_price;
+ }
+ }
+
+ arr[ind].ckeck_quan_price=ckeck_quan_price-cut_price;
+ arr[ind].check_quan_ware_list=check_quan_ware_list;
+ arr[ind].check_quan_price_list=check_quan_price_list;
+
+ //是否关闭使用优惠券
+ if (th.data.is_close_quan != 1 && !is_xz_yh) {
+ //--调用接口,获取优惠券的列表,3秒钟内控制接口请求--
+ var url="/api/weshop/couponList/getUseCouponList";
+ await app.request.promiseGet(url,{ data:{storeId:oo.stoid,userId:app.globalData.user_id,BuySum:ckeck_quan_price,WareIds:check_quan_ware_list,pageSize:100}}).then(res=>{
+ if (res.data.code == 0) {
+ var quan_list = res.data.data.pageData;
+ arr[ind].quan_list = th.check_is_frozenQuan(quan_list, th.data.frozenQuan);
+ }
+ })
+ }
+ }
+
+ //如果是搭配购的立即购买的时候
+ if(th.data.is_b_now){
+ var quanlist=arr[0].quan_list;
+ th.setData({selected_quan_list:quanlist,cartlist:arr})
+ }else{
+ th.setData({cartlist:arr })
+ }
+
+
+ })
+ },
- arr[ind].ckeck_quan_price=ckeck_quan_price;
- arr[ind].check_quan_ware_list=check_quan_ware_list;
- arr[ind].check_quan_price_list=check_quan_price_list;
-
- //是否关闭使用优惠券
- if (th.data.is_close_quan != 1) {
- var frozenQuan=null;
- var url0="/api/weshop/users/frozenQuan/listFrozenQuan/"+app.globalData.user_id;
- app.request.promiseGet(url0,{1:1}).then(res=>{
- if(res.data.code==0){ frozenQuan=res.data.data; th.data.frozenQuan=frozenQuan; }
- //--调用接口,获取优惠券的列表,3秒钟内控制接口请求--
- var url="/api/weshop/couponList/getUseCouponList";
- app.request.time_limit_get(6,url,{
- data:{storeId:oo.stoid,userId:app.globalData.user_id,BuySum:ckeck_quan_price,WareIds:check_quan_ware_list,pageSize:100},
- success:function (res) {
- if (res.data.code == 0) {
- arr[ind].quan_list = res.data.data.pageData;
- arr[ind].quan_list = th.check_is_frozenQuan(arr[ind].quan_list, frozenQuan);
- th.setData({cartlist:arr })
- }
- }
- })
- })
- }
- }
- },
//------ 获取立即购买的购物车的劵 --------
get_buy_now_quan:function () {
var quanlist=null,th=this,frozenQuan = null;
- if(th.data.is_close_quan != 1)
+ var good = this.data.bn_goods;
+ if(good.prom_price){
+ th.data.ckeck_quan_price=good.prom_price;
+ }
+ //--如果商家后台没有限制使用优惠券,同时商品的优惠活动没有限制使用优惠券--
+ if(th.data.is_close_quan != 1 && th.data.bn_goods.is_xz_yh!=1)
{
var url0 = "/api/weshop/users/frozenQuan/listFrozenQuan/" + app.globalData.user_id;
var url="/api/weshop/couponList/getUseCouponList";
@@ -1942,7 +2484,7 @@ Page({
storeId: oo.stoid,
userId: app.globalData.user_id,
BuySum: th.data.ckeck_quan_price,
- WareIds: th.data.check_quan_ware_list,
+ WareIds: encodeURIComponent(th.data.check_quan_ware_list),
pageSize: 100
},
success: function (res) {
@@ -1956,9 +2498,9 @@ Page({
}
})
})
-
}
},
+
//检查区域是不是包邮
check_area:function(arr){
var user_addr=this.data.user_addr;
@@ -1990,7 +2532,158 @@ Page({
var arr=goods_list.split(",");
var check=this.check_good(arr,goods_id);
return !check;
- }
+ },
+
+ //立即购买获取优惠活动的内容
+ buy_now_prom_goods:function (prom_id,arr,func) {
+ var price=arr.shop_price*arr.goods_num;
+ var prom=null;
+ getApp().request.promiseGet("/api/weshop/promgoods/get/"+os.stoid+"/"+prom_id,{}).then(res=>{
+ if(res.data.code==0){
+ prom=res.data.data;
+ return getApp().request.promiseGet("/api/weshop/goods/getDiscount", {
+ data: {
+ price: price,
+ prom_id: prom_id,
+ goods_num: arr.goods_num,
+ user_id: getApp().globalData.user_id,
+ is_bz: prom.is_bz
+ }
+ })
+ }else {
+ func(arr);
+ }
+ }).then(res=>{
+ if(res.data.code==0){
+ var get_data=res.data.data;
+ arr.is_bz=prom.is_bz; //是不是倍增
+ arr.is_xz_yh=prom.is_xz_yh; //是不是优惠
+ arr.bs=get_data.bs; //是不是倍数
+ arr.is_past=get_data.is_past; //是不是包邮
+ arr.prom_price=get_data.price?get_data.price:price;
+ arr.s_intValue=get_data.intValue;
+ arr.s_coupon_id=get_data.coupon_id;
+ arr.s_coupon_num=get_data.coupon_num;
+ //-- 看是不是有赠品 --
+ if(get_data.gift_id) {
+ arr.gift_id = get_data.gift_id;
+ arr.gift_goods_id = get_data.goods_id;
+ arr.gift_goods_name = get_data.goods_name;
+ arr.gift_goods_color = get_data.goodsinfo.goods_color;
+ arr.gift_goods_spec = get_data.goodsinfo.goods_spec;
+ arr.gift_original_img = get_data.goodsinfo.original_img;
+ arr.gift_weight = get_data.goodsinfo.weight;
+ arr.gift_exp_sum_type = get_data.goodsinfo.exp_sum_type;
+ arr.gift_limit_num = get_data.limit_num;
+ arr.gift_storecount = get_data.gift_storecount;
+ }
+ arr.s_libao=get_data.libao;
+ arr.s_lb_num=get_data.lb_num;
+ arr.prom_id=prom_id;
+ }
+ func(arr);
+ })
+ },
+ //--检查订单优惠--
+ check_is_order_prom:function (condition,func,pick) {
+ var th=this;
+ if(this.data.is_b_now==1) pick=this.data.bn_pick;
+ //---获取订单优惠---
+ getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion",{
+ data:{store_id:os.stoid,orderAmount:condition}
+ }).then(res=>{
+ if(res.data.code==0) {
+ var data = res.data.data;
+ th.data.order_prom[pick]=data;
+ }
+ func();
+ })
+ },
+
+ //--- 加入优惠活动的映射中 ---
+ add_prom_goods_map:async function (item) {
+ var th=this;
+ var pickid=item.pick_id;
+ var map=th.data.prom_goods_map;
+ var obj=map[pickid];
+
+ if(map[pickid]){
+ if(map[pickid][item.prom_id]){
+ var ob=map[pickid][item.prom_id];
+ ob.price+=item.goods_price*item.goods_num;
+ ob.goods_num+=item.goods_num;
+ }else{
+ var prom=null;
+ await getApp().request.promiseGet("/api/weshop/promgoods/get/"+os.stoid+"/"+item.prom_id,{}).then(res=>{
+ if(res.data.code==0){ prom=res.data.data; }
+ })
+ var ob={};
+ ob.prom_id=item.prom_id;
+ ob.price=item.goods_price*item.goods_num;
+ ob.goods_num=item.goods_num;
+ ob.is_bz=prom.is_bz;
+ ob.is_xz_yh=prom.is_xz_yh;
+ map[pickid][item.prom_id]=ob;
+ }
+ }else{
+ var ob={};
+ var prom=null;
+ await getApp().request.promiseGet("/api/weshop/promgoods/get/"+os.stoid+"/"+item.prom_id,{}).then(res=>{
+ if(res.data.code==0){ prom=res.data.data; }
+ })
+ ob.prom_id=item.prom_id;
+ ob.price=item.goods_price*item.goods_num;
+ ob.goods_num=item.goods_num;
+ ob.is_bz=prom.is_bz;
+ ob.is_xz_yh=prom.is_xz_yh;
+ var obj={};
+ obj[item.prom_id]=ob;
+ map[pickid]=obj;
+
+ }
+ },
+
+ //计算立即购买赠品的物流费用
+ get_now_gift_goods_wuliu:function (code, o_shipping_price, user_addr, gift_freight_free,allpice, rs,shipping_price,no_by_data) {
+ var good=this.data.buy_now_gift_goods;
+ var goods_weight=-1, goods_piece=-1;
+ var gift_shipping_price=0;
+ var th=this;
+ switch (good['exp_sum_type']) {
+ case 1:
+ //统一运费
+ gift_shipping_price += good['uniform_exp_sum']; break;
+ case 2:
+ if (goods_weight < 0) goods_weight = 0;
+ //累积商品重量 每种商品的重量 * 数量
+ goods_weight += good['weight'] * good['buynum'];break;
+ case 3:
+ if (goods_piece < 0) goods_piece = 0;
+ //累积商品数量
+ goods_piece += good['buynum']; break;
+ }
+
+ //如果有设置不包邮区域的时候
+ if(no_by_data && no_by_data.region_list){
+ if(th.check_by_area(no_by_data.region_list)){
+ gift_freight_free=0;
+ th.data.is_no_by[th.data.bn_pick]=1;
+ }
+ }
+ //如果有设置不包邮商品
+ if(no_by_data && no_by_data.goods_list && gift_freight_free){
+ if(th.check_by_goods(no_by_data.goods_list)){
+ gift_freight_free=0;
+ th.data.is_no_by[th.data.bn_pick]=1;
+ }
+ }
+ var t_shipping_price=
+ this.calculatewuliu(code, gift_shipping_price, goods_weight,
+ goods_piece, user_addr, gift_freight_free, allpice, rs);
+ return t_shipping_price+shipping_price;
+
+ }
+
});
diff --git a/pages/cart/cart2/cart2.wxml b/pages/cart/cart2/cart2.wxml
index 844c990..79a0ab8 100644
--- a/pages/cart/cart2/cart2.wxml
+++ b/pages/cart/cart2/cart2.wxml
@@ -41,7 +41,8 @@
门店:{{item.pname}}
-
+
+
@@ -69,10 +70,10 @@
-
+ !!!!---{{item.quan_list.length}}---!!!
+ wx:if="{{(item.quan_list && item.quan_list.length>0) || get_by_quan_list_cart[item.pickup_id]!=null}}" data-cind="{{pidx}}" data-pickid="{{item.pickup_id}}">
优惠券
@@ -190,14 +191,62 @@
x{{bn_goods.buynum}}
-
+
-
+
+
+
+
+
+
+
+
+ {{buy_now_gift_goods.goods_name}}
+
+
+
+ {{filters.show_gui_ge(buy_now_gift_goods.goods_spec,buy_now_gift_goods.goods_color)}}
+
+
+
+
+ ¥0
+ x{{buy_now_gift_goods.buynum}}
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.goods_name}}
+
+
+
+ {{filters.show_gui_ge(item.goods_spec,item.goods_color)}}
+
+
+
+
+ ¥{{item.price}}
+ x{{item.goods_num}}
+
+
+
+
+
+
+
{{order.store_prom}}
+ wx:if="{{(selected_quan_list && selected_quan_list.length>0) || get_by_quan_list!=null}}">
优惠券
@@ -224,11 +273,10 @@
物流
-
+
{{wu_arr[index].name}}
-
+
-
@@ -248,32 +296,32 @@
-
+
商品金额
¥ {{formData.all_price}}元
-
+
配送费用
¥ {{formData.shipping_price}}元
-
使用优惠券
- ¥ {{formData.coupon_price}}元
-
-
+
+
+ 优惠活动
+ - ¥ {{filters.toFix(formData.cut_price,2)}}元
+
+
+
+ 订单优惠
+ - ¥ {{filters.toFix(formData.order_prom_amount,2)}}元
+
+
使用余额
- ¥ {{formData.user_money}}元
-
@@ -426,7 +474,6 @@
确定
-
@@ -470,6 +517,4 @@
-
-
\ No newline at end of file
diff --git a/pages/cart/cart2/cart2.wxss b/pages/cart/cart2/cart2.wxss
index 4cfebae..c10b952 100644
--- a/pages/cart/cart2/cart2.wxss
+++ b/pages/cart/cart2/cart2.wxss
@@ -208,8 +208,8 @@ margin:auto;
height: 100rpx; width: 100%;
background-color: #fff;
position: fixed; bottom: 0;left: 0;
- border-top:1rpx solid #dee
-
+ border-top:1rpx solid #dee;
+ z-index:9999
}
.tips-btn {
@@ -346,7 +346,7 @@ margin:auto;
}
.xc-frame{
width: 100%;
- height:68.9%;
+ height:60%;
}
.xc-frame .list-frame{
@@ -480,11 +480,7 @@ padding-left: 40rpx;
margin-top: 30rpx;
}
-.cx-popup.radius{
-
-height: 650rpx;
-}
.xc-hook {
width: 33rpx;
height: 33rpx;
@@ -512,8 +508,9 @@ border-bottom: 1rpx solid #eee;
.express_list{
width: 100%;
height: 65%;
- overflow-y: scroll;
- overflow: hidden;
+ overflow-y: auto;
+ margin-bottom: 10rpx;
+
}
.xc-confirms {
width: 40%;
@@ -821,5 +818,5 @@ margin-left: 20rpx;
.color-gray{
color: #808080;
}
-
-.n_guige{ display: inline-block; background:rgb(236, 236, 236); color: rgb(63,63,63); padding: 3rpx 10rpx; border-radius: 3rpx }
\ No newline at end of file
+.n_guige{ display: inline-block; background:rgb(236, 236, 236); color: rgb(63,63,63); padding: 3rpx 10rpx; border-radius: 3rpx }
+.gift_image{ width: 60rpx; height: 60rpx; position: absolute; top: 0; left: 0}
\ No newline at end of file
diff --git a/pages/cart/cart2_pt/cart2_pt.wxml b/pages/cart/cart2_pt/cart2_pt.wxml
index feba63e..4de1c84 100644
--- a/pages/cart/cart2_pt/cart2_pt.wxml
+++ b/pages/cart/cart2_pt/cart2_pt.wxml
@@ -129,11 +129,11 @@
¥ {{formData.all_price}}元
-
+
配送费用
¥ {{formData.shipping_price}}元
-
+
使用余额
- ¥ {{formData.user_money}}元
diff --git a/pages/cart/cart_wk/cart_wk.js b/pages/cart/cart_wk/cart_wk.js
index c4302ed..31e5b8a 100644
--- a/pages/cart/cart_wk/cart_wk.js
+++ b/pages/cart/cart_wk/cart_wk.js
@@ -384,14 +384,18 @@ Page({
getApp().my_warnning("支付失败",0,th);
})
}else {
- //---用余额支付---
- getApp().my_warnning("支付成功",1,th);
- setTimeout(function () {
- th.setData({ isclose: 0 });
- wx.navigateTo({
- url: "/pages/user/order_list/order_list"
- })
- }, 1000)
+ if(t.data.code==0){
+ //---用余额支付---
+ getApp().my_warnning("支付成功",1,th);
+ setTimeout(function () {
+ th.setData({ isclose: 0 });
+ wx.navigateTo({
+ url: "/pages/user/order_list/order_list"
+ })
+ }, 1000)
+ }else{
+ getApp().my_warnning(t.data.msg,1,th);
+ }
}
}
});
diff --git a/pages/cart/cart_wk/cart_wk.wxml b/pages/cart/cart_wk/cart_wk.wxml
index a4aa7a6..b083181 100644
--- a/pages/cart/cart_wk/cart_wk.wxml
+++ b/pages/cart/cart_wk/cart_wk.wxml
@@ -96,7 +96,7 @@
-
+
配送费用
¥{{exp_price}}
diff --git a/pages/goods/categoryList/categoryList.js b/pages/goods/categoryList/categoryList.js
index 301ed31..997e781 100644
--- a/pages/goods/categoryList/categoryList.js
+++ b/pages/goods/categoryList/categoryList.js
@@ -1,11 +1,17 @@
var t = getApp(), e = t.request, oo = t.globalData.setting;
+var i = function (i) {
+ return i && i.__esModule ? i : {
+ default: i
+ };
+}(require("../../../utils/LoadMore.js")), a = new i.default(), ut = require("../../../utils/util.js");
+//t = i,e = t
Page({
data: {
- is_date:true,
- scrollHeight: 0,
- currentTab:-1,
- abc:0,
+ is_date:true,
+ scrollHeight: 0,
+ currentTab:-1,
+ abc:0,
windowHeight:0,
windowWidth: 0,
eachLetterHeight:0,
@@ -39,14 +45,35 @@ Page({
cat_id:0,
pl_timer: null,//只有品类的定时器
is_pl_time:0,
-
+ requestData:null, //风格三的商品数据列表 分页
+ stylePage:1, //商品列表分页标识
+ //风格三使用
+ url: t.globalData.setting.imghost,
+ currentPage: 1,
+ requestData: null,
+ allData: null,
+ openFilterModal: !1,
+ baseUrl: "api/weshop/goods/page?1=1&orderField=goods_id&orderType=desc&is_mainshow=1&isonsale=1&store_id="+oo.stoid+"&is_recommend=1",
+ requestUrl: "",
+ tabname: "goods_id", //排序的字段
+ adname: "desc", //升降的字段
+ is_new: 0,
+ is_hot: 0,
+ msgStatus:false, //页面显示暂无数据状态
+ countDownNum: 3,
+ timer: '', //定时器
+ lastMsg:false,
+ toView:"",
},
onLoad: function(tt) {
+ var that = this;
+ that.get_brand();
+
+ clearInterval(that.data.timer);
+ that.setData({ countDownNum: 3, stylePage: 1 });
+
const res = wx.getSystemInfoSync(),
letters = this.data.letters;
-
- var that = this;
-
this.setData({
abc: t.globalData.heigth-88-88-16,
windowHeight: res.windowHeight,
@@ -77,11 +104,58 @@ Page({
if (this.data.is_used_share==0){
this.get_nation();
}
-
+
+ //风格三
+ //t = i,e = t
+ var th = this;
+ a.init(this, "", "requestData");
+ var url = this.data.baseUrl;
+ this.data.is_new = i.is_new;
+ this.data.is_hot = i.is_hot;
+ if (0 != this.data.cat_id) {
+ url += "&cat_id=" + this.data.cat_id;
+ }
+
+ // this.requestGoodsList(url);
+ getApp().getConfig2(function (rs) {
+ //计算等级价相关
+ var swithc_list = rs.switch_list;
+ var sw_arr = JSON.parse(swithc_list);
+ //---如果后台又开等级卡的开关---
+ if (sw_arr.rank_switch && sw_arr.rank_switch == "2") {
+ th.setData({ rank_switch: true });
+ var user = getApp().globalData.userInfo;
+ var ti = setInterval(function () {
+ if (!user) return false;
+ clearInterval(ti);
+ //---回调卡的列表---
+ th.getPlusCardType(function (ob) {
+ th.setData({ card_list: ob.card_list });
+ if (user.card_field) {
+ var str = user['card_expiredate'].replace(/-/g, '/');
+ var end = new Date(str);
+ end = Date.parse(end) / 1000;
+ var now = ut.gettimestamp();
+
+ //--- 判断是等级会员,且在有效期范围内 ---
+ if (user.card_field && now < end) {
+ var card_name = ob.name_map.get(user.card_field);
+ if (card_name.length > 4) card_name = card_name.substring(0, 4);
+ th.setData({ card_field: user.card_field, card_name: card_name, card_list: ob.card_list });
+ }
+ }
+ })
+ }, 500)
+ }
+ });
},
onShow:function(){
var that=this;
+ that.setData({
+ isTabBar: getApp().globalData.isTabBar,
+ });
+ t.editTabBar(); //显示自定义的底部导航
//this.requestFirstCategoris();
if(getApp().globalData.user_id) getApp().requestCardNum();
getApp().getConfig2(function (e) {
@@ -150,6 +224,7 @@ Page({
that.setData({ currentTab: 0 });
}
})
+
},
//---------------分类请求接口,数据进行拼装------------------
@@ -180,7 +255,7 @@ Page({
}
}
t.setData({ catelist: arr});
- }else{
+ } else if (t.data.is_used_share == 1 || t.data.is_used_share == 2){
//---------新的版本----------------
for (var i = 0; i < dda.length; i++) {
@@ -221,11 +296,11 @@ Page({
}
t.setData({one_level_classify:arr});
- }
+ }
}
});
},
-
+
requestCategories: function(t) {
var s = this;
e.get("/api/goods/goodsSecAndThirdCategoryList", {
@@ -300,6 +375,7 @@ Page({
//------------手指滑动------------------
touchmove(e) {
+ console.log("手指滑动")
const x = e.touches[0].clientX,
y = e.touches[0].clientY,
lettersPosition = this.data.lettersPosition,
@@ -458,38 +534,57 @@ Page({
this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
},
+
+
+ //---图片失败,默认图片---
+ bind_Goodsbnerr: function (e) {
+ var _errImg = e.target.dataset.errorimg;
+ var _errObj = {};
+ _errObj[_errImg] ="/miniapp/images/default_g_img.gif";
+ this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
+ },
// 新的版本分类点击一级分类
click_classify:function(e){
- this.data.ishaf_three=0;
- var indexs=e.currentTarget.dataset.index;
+ clearInterval(this.data.timer);
+ this.setData({ countDownNum: 3, stylePage: 1, scrollTop: 0});
+ this.data.ishaf_three = 0;
+ var indexs = e.currentTarget.dataset.index;
var name = e.currentTarget.dataset.name;
var cid = e.currentTarget.dataset.cid;
var pid = e.currentTarget.dataset.pid;
var arr = e.currentTarget.dataset.arr;
-
- if (indexs==220){ this.get_brand();}
- if (arr!="undefined" && arr!=undefined){
- if (arr.length==0){
- this.setData({ select_classify_on: indexs, index: indexs, classify_name: name,cat_id:cid,
- goodslist: null,is_level_three: 0 });
- return false;
- }
- if (arr.length != 0){
- var is_lev_thr=0
- for(var i=0;i0) {is_lev_thr=1;break; }
- }
- this.setData({ is_level_three: is_lev_thr });
-
- if (this.data.is_level_three!=1) {
- this.setData({ select_classify_on: indexs, index: indexs, classify_name: name, goodslist: arr });
- } else {
- this.setData({ select_classify_on: indexs, index: indexs, goodslist: arr });
- }
+ console.log("cid:=" + cid)
+ if (indexs == 220) { this.get_brand(); }
+ //==2的时候 请求数据为商品,不为分类
+ if (this.data.is_used_share == 2) {
+ this.style(this.data.stylePage, cid)
+ this.setData({ select_classify_on: indexs, index: indexs, classify_name: name, cat_id: cid,lastMsg: false, });
+ }else{
+ if (arr != "undefined" && arr != undefined) {
+ if (arr.length == 0) {
+ this.setData({
+ select_classify_on: indexs, index: indexs, classify_name: name, cat_id: cid,
+ goodslist: null, is_level_three: 0
+ });
+ return false;
+ }
+ if (arr.length != 0) {
+ var is_lev_thr = 0
+ for (var i = 0; i < arr.length; i++) {
+ if (arr[i].arrays.length > 0) { is_lev_thr = 1; break; }
+ }
+ this.setData({ is_level_three: is_lev_thr });
+
+ if (this.data.is_level_three != 1) {
+ this.setData({ select_classify_on: indexs, index: indexs, classify_name: name, goodslist: arr });
+ } else {
+ this.setData({ select_classify_on: indexs, index: indexs, goodslist: arr });
+ }
+ }
}
+ this.setData({ select_classify_on: indexs, index: indexs, classify_name: name, cat_id: cid, stylePage: 1,lastMsg: false,});
}
- this.setData({ select_classify_on: indexs, index: indexs, classify_name: name, cat_id: cid});
-
+
},
@@ -527,4 +622,244 @@ Page({
this.destroyActivityTimer();
},
+
+ //风格三使用
+ changeTab: function (t) {
+ var ord = t.currentTarget.dataset.href;
+ var ad = t.currentTarget.dataset.ad;
+ var url = this.data.requestUrl;
+
+ if (this.data.tabname != ord) {
+ this.setData({ tabname: ord, adname: "desc" });
+ } else {
+ ad = ad == "desc" ? "asc" : "desc";
+ this.setData({ adname: ad });
+ }
+ this.resetData(), this.requestGoodsList(url);
+ },
+
+ requestGoodsList: function (t) {
+ var that = this;
+ that.data.requestUrl = t;
+ e.get("/api/weshop/goods/page?1=1", {
+ data: { page: that.data.stylePage, cat_id: that.data.cat_id, parent_id: 0, orderField: 'goods_id', orderType: 'desc', is_mainshow: 1, isonsale: 1, store_id: oo.stoid, is_recommend: 1 },
+ success: function (data) {
+ console.log(data.data.data.pageData)
+ that.setData({
+ requestData: data.data.data.pageData,
+ is_go: 1
+ });
+ that.setData({ is_go: 1 });
+ that.data.stylePage++ , null == that.data.allData && (that.data.allData = Object.assign({}, data.data.data.pageData)),
+ wx.stopPullDownRefresh();
+ }
+ });
+ // //不是商品分组的,不是默认排序的
+ // if (t.indexOf("group_id") == -1 || e.data.tabname != "goods_id") {
+ // t += "&orderField=" + e.data.tabname;
+ // t += "&orderType=" + e.data.adname;
+ // }
+ // + "&parent_id=0&orderField=goods_id&orderType=desc&page="+this.data.page+"&is_mainshow=1&isonsale=1&store_id=1&is_recommend=1"
+ // t += "&page=" + e.data.page;
+ // a.request(t,
+ // function (t) {
+ // e.setData({ is_go: 1 });
+ // e.data.page++ , null == e.data.allData && (e.data.allData = Object.assign({}, t.data.result)),
+ // wx.stopPullDownRefresh();
+ // },
+ // null, { is_mainshow: 1, isonsale: 1, store_id: oo.stoid }
+ // );
+ },
+
+ // onReachBottom: function () {
+ // console.log('监听上拉:=')
+ // var that = this;
+ // clearInterval(that.data.timer);
+ // that.setData({
+ // stylePage: that.data.stylePage + 1,
+ // countDownNum: 3,
+ // lastMsg: false,
+ // });
+ // that.style(that.data.stylePage, that.data.cat_id);
+ // },
+ // onPullDownRefresh: function () {
+ // console.log('监听下拉:=' + this.data.requestUrl)
+ // this.resetData(), this.requestGoodsList(this.data.requestUrl);
+ // },
+ // 左侧更新
+ scrollLower: function (data) {
+ console.log("上拉加载更多", JSON.stringify(data))
+ var that = this;
+ clearInterval(that.data.timer);
+ that.setData({
+ stylePage: that.data.stylePage + 1,
+ countDownNum: 3,
+ lastMsg: false,
+ });
+ that.style(that.data.stylePage, that.data.cat_id);
+ },
+
+ //页面版面风格三的时候请求推荐商品 返回
+ style: function (page, cid) {
+ console.log("page:=" + page)
+ var s = this
+ e.get("/api/weshop/goods/page?1=1", {
+ data: { page: page, cat_id: cid, parent_id: 0, orderField: 'goods_id', orderType: 'desc', is_mainshow: 1, isonsale: 1, store_id: oo.stoid, is_recommend: 1 },
+ success: function (e) {
+ console.log(e.data.data.pageData)
+ s.setData({
+ dataLength: e.data.data.pageData.length,
+ });
+ if (e.data.data.pageData.length > 0) {
+ s.setData({
+ msgStatus: false,
+ });
+ //如果有数据 怕断分页为第一页的时候直接渲染数据
+ if (page > 1) {
+ //如果分页不是在第一页 那么就把返回的数据追加到原有数据后面
+ var arr = s.data.requestData
+ console.log("arr:=" + JSON.stringify(arr))
+
+ for (var i = 0; i < e.data.data.pageData.length;i++){
+ arr.push(e.data.data.pageData[i]);
+ }
+ console.log(arr)
+ s.setData({
+ requestData: arr
+ });
+
+ }else{
+ s.setData({
+ requestData: e.data.data.pageData
+ });
+ if (wx.pageScrollTo) {
+ wx.pageScrollTo({
+ scrollTop: 0
+ })
+ }
+ }
+
+ } else {
+ //没有数据页面显示暂无数据
+ if (page != 1) {
+ var dataArray = s.data.one_level_classify
+ var index = s.data.index
+ console.log(dataArray[index + 1]['items'])
+ s.setData({
+ msgStatus: true,
+ stylePage: 1,
+ index: index + 1,
+ select_classify_on: index + 1,
+ cat_id: dataArray[index + 1]['items']['id'],
+ classify_name: dataArray[index + 1]['items']['name']
+ });
+ s.style(s.data.stylePage, dataArray[index + 1]['items']['id'])
+ }else{
+ //没有数据而且是第一页的时候
+ s.setData({
+ stylePage: 1,
+ });
+ let countDownNum = 3; //获取倒计时初始值
+ s.setData({
+ msgStatus: true,
+ countDownNum: countDownNum,
+ requestData: []
+ });
+ s.setData({
+ timer:setInterval(function () {
+ if (countDownNum == 0) {
+ clearInterval(s.data.timer);
+ //关闭定时器之后,可作其他处理
+ s.setData({
+ msgStatus: false,
+ })
+
+ //如果没有数据就把分页初始化成第一页
+ //没有数据根据当前分类id去找到下一个分类id再次传递给服务端请求数据
+ var dataArray = s.data.one_level_classify
+ var index = s.data.index
+ console.log(dataArray[index + 1])
+ if (dataArray[index + 1] == undefined || dataArray[index + 1] == "undefined"){
+ console.log("dataArray[index + 1] = undefined")
+ s.setData({
+ stylePage: 1,
+ msgStatus: true,
+ lastMsg: true
+ });
+ }else{
+ s.setData({
+ stylePage: 1,
+ index: index + 1,
+ select_classify_on: index + 1,
+ cat_id: dataArray[index + 1]['items']['id'],
+ classify_name: dataArray[index + 1]['items']['name']
+ });
+ s.style(s.data.stylePage, dataArray[index + 1]['items']['id']);
+ }
+
+ }
+ countDownNum--;
+ s.setData({
+ countDownNum: countDownNum
+ })
+ }, 1000)
+
+ })
+ }
+
+
+ }
+ }
+ });
+ },
+
+
+ openFilterModal: function () {
+ this.setData({
+ openFilterModal: !0
+ });
+ },
+ closeFilterModal: function () {
+ this.setData({
+ openFilterModal: !1
+ });
+ },
+ filterGoods: function (t) {
+ this.resetData(), this.requestGoodsList(t.currentTarget.dataset.href), this.closeFilterModal();
+ },
+ resetData: function () {
+ a.resetConfig(), this.data.requestData = null, this.data.currentPage = 1;
+ },
+
+ //---回复最初的设置---
+ restoreData: function () {
+ this.setData({
+ requestData: null,
+ });
+ this.data.page = 1;
+ },
+
+ //--- 获取卡类列表 ---
+ getPlusCardType: function (func) {
+ var storid = oo.stoid;
+ var th = this;
+ getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => {
+ var plusCard = res.data.data;
+ var arr = [1219, 2089, 3031];
+ var new_arr = new Array();
+ var card_name_map = new Map();
+ var user = getApp().globalData.userInfo;
+ for (var i = 0; i < plusCard.length; i++) {
+ if ((user.card_field == null || user.card_field == "") && (plusCard[i].IsStopBuy == true)) {
+ continue;
+ }
+ var name = "card" + plusCard[i].CorrPrice.toLowerCase();
+ card_name_map.set(name, plusCard[i].CardName);
+ new_arr.push(plusCard[i]);
+ }
+
+ var ob = { "card_list": new_arr, "name_map": card_name_map };
+ func(ob);
+ })
+ },
});
\ No newline at end of file
diff --git a/pages/goods/categoryList/categoryList.wxml b/pages/goods/categoryList/categoryList.wxml
index f5c8974..f2997a4 100644
--- a/pages/goods/categoryList/categoryList.wxml
+++ b/pages/goods/categoryList/categoryList.wxml
@@ -1,14 +1,15 @@
+
-
- 分类
- 国家
- 品牌
-
-
+
+ 分类
+ 国家
+ 品牌
+
+
@@ -16,7 +17,7 @@
-
+
@@ -84,16 +85,17 @@
暂无分类
去逛逛
-
+
商家暂未设置分类
去逛逛
+
-
-
+
+
@@ -262,4 +264,230 @@
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+ 扫一扫
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 国家
+
+
+
+
+ 品牌
+
+
+
+
+
+
+
+
+ {{name}}
+
+
+
+ {{ittms.items.name}}
+
+
+
+
+
+
+
+
+
+
+ {{ishaf_three==1?good_list.name:classify_name}}
+
+
+
+
+
+
+
+ {{bitem.name}}
+
+
+ {{bitem.enname}}
+
+
+
+
+
+
+
+
+
+
+
+ {{classify_name}}
+
+
+
+
+
+
+
+
+
+ {{user.name}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{item.goods_name}}
+
+
+
+ ¥{{item.prom_price}}
+
+
+
+
+
+
+
+
+
+
+ ¥{{item[card_field]}}
+
+
+ {{card_name}}
+
+
+
+
+
+ ¥{{item.shop_price}}
+
+
+
+
+
+
+ ¥{{item.shop_price}}
+ ¥{{item.market_price}}
+
+
+
+
+ ¥{{item.shop_price}}
+
+
+
+
+
+ ¥{{item.shop_price}}
+
+
+
+
+
+
+
+
+
+
+ 该类别暂无推荐商品 {{countDownNum}} 秒后自动跳到下一个类别
+ 该类别暂无推荐商品
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 商家暂未设置分类
+ 去逛逛
+
+
+
+
+
\ No newline at end of file
diff --git a/pages/goods/categoryList/categoryList.wxss b/pages/goods/categoryList/categoryList.wxss
index 3eb60ef..2a79d0e 100644
--- a/pages/goods/categoryList/categoryList.wxss
+++ b/pages/goods/categoryList/categoryList.wxss
@@ -1,6 +1,8 @@
/*---nyf 2018-9-7---*/
+
page{height: 100%; background: #fff;}
.top_view{ width: 100%;background: #fff;}
+
.swiper-tab{
width: 70%;
text-align: center;
@@ -262,7 +264,7 @@ width: 60%;
width: 90%;
margin: auto;
height: 70rpx;
- border-bottom: 1rpx solid #eee;
+ border-bottom: 1rpx solid #f5f6f6;
line-height: 85rpx;
font-weight: 600;
@@ -400,4 +402,7 @@ margin: auto;
width: 80%;
}
-.brand_img_name {color: #666;}
\ No newline at end of file
+.brand_img_name {color: #666;}
+
+/* 风格三商品列表样式引入 */
+@import "../goodsList/goodsList.wxss";
\ No newline at end of file
diff --git a/pages/goods/goodsInfo/filter.wxs b/pages/goods/goodsInfo/filter.wxs
index 21c243f..5c5f0a2 100644
--- a/pages/goods/goodsInfo/filter.wxs
+++ b/pages/goods/goodsInfo/filter.wxs
@@ -2,7 +2,13 @@ var is_has = function (text,val) {
if(text.indexOf(","+val+",")==-1) return false;
return true
}
-
+function format_tt(ts) {
+ if(ts==null || ts==undefined || ts=='') return "";
+ var d = getDate(ts*1000)
+ var fm=(d.getMonth()+1)+"月"+ d.getDate()+"日";
+ return fm;
+}
module.exports = {
- is_has: is_has
+ is_has: is_has,
+ format_tt:format_tt
}
diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js
index 2c45730..7a5c8b6 100644
--- a/pages/goods/goodsInfo/goodsInfo.js
+++ b/pages/goods/goodsInfo/goodsInfo.js
@@ -236,6 +236,10 @@ Page({
sales_rules:1, //默认是线上销售
wait_for_user_store:null,
+
+ prom_goods:null, //商品优惠列表
+ order_prom:null, //订单优惠
+ collocationGoods:null, //搭配购
},
@@ -547,11 +551,11 @@ Page({
mapurl: mapurl,
});
-
},
//---展示---
onShow: function() {
+
var goods_list = null,th = this,that=this;
var ui = setInterval(function () {
goods_list = th.selectComponent("#goods_list");
@@ -608,6 +612,8 @@ Page({
}
}
+ ee.check_is_youhui(ee.data.gid);
+
t.data.data.on_time = ut.formatTime(t.data.data.on_time, 'yyyy-MM-dd hh:mm:ss');
var txt = (t.data.data.shop_price / t.data.data.market_price * 10).toFixed(2);
t.data.data['disc'] = txt;
@@ -631,43 +637,40 @@ Page({
//获取统一条形码,普通商品和优惠促销的商品
if (ee.data.data.prom_type == 0 || ee.data.data.prom_type == 2 || ee.data.data.prom_type == 3 || ee.data.data.prom_type == 4 || ee.data.data.prom_type == 5){
//默认门店要拿下门店库存
- if(that.data.sales_rules==2 && that.data.is_newsales_rules){
- //--等待某个值只运行---,这里有可能因为导航的时间太久,而不能计算门店库存
- getApp().waitfor2(that,"wait_for_user_store","fir_def_store",function(){
- if(th.data.fir_def_store && th.data.fir_def_store.pickup_id ){
- var lock=0,plist=null;
- //先读取门店的lock,采用链式写法,少用await
- getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
- data:{store_id:os.stoid,wareId:ee.data.data.goods_id,storageId:that.data.fir_def_store.pickup_id,pageSize:1000}
- }).then(res=>{
- if(res.data.code==0 && res.data.data.total>0){
- for(var i in res.data.data.pageData)
- lock+=res.data.data.pageData[i].outQty
- }
- //---通过接口获取门店的线下库存信息--
- return getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
- data:{storageNos:that.data.fir_def_store.pickup_no,wareIds:encodeURIComponent(th.data.data.erpwareid),storeId:os.stoid}
- })
- }).then(res=>{
- if(res.data.code==0 && res.data.data.total>0){
- plist=res.data.data.pageData[0];
- }
- if(plist && plist.CanOutQty-lock>0){
- that.data.fir_def_store.CanOutQty=plist.CanOutQty-lock;
- }else{
- that.data.fir_def_store.CanOutQty=0;
- }
- //--给门店赋值线下库存--
- th.setData({def_pick_store:that.data.fir_def_store});
- //获取门店
- ee.get_sto();
- })
- }else{
- //--获取门店--
- ee.get_sto();
- }
- })
- }else{
+ if(that.data.sales_rules==2 && that.data.is_newsales_rules){
+ //获取门店
+ ee.get_sto();
+ //--等待某个值只运行---,这里有可能因为导航的时间太久,而不能计算门店库存
+ getApp().waitfor2(that,"wait_for_user_store","fir_def_store",function(){
+ if(th.data.fir_def_store && th.data.fir_def_store.pickup_id ){
+ var lock=0,plist=null;
+ //先读取门店的lock,采用链式写法,少用await
+ getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{
+ data:{store_id:os.stoid,wareId:ee.data.data.goods_id,storageId:that.data.fir_def_store.pickup_id,pageSize:1000}
+ }).then(res=>{
+ if(res.data.code==0 && res.data.data.total>0){
+ for(var i in res.data.data.pageData)
+ lock+=res.data.data.pageData[i].outQty
+ }
+ //---通过接口获取门店的线下库存信息--
+ return getApp().request.promiseGet("/api/weshop/goods/getWareStorages",{
+ data:{storageNos:that.data.fir_def_store.pickup_no,wareIds:encodeURIComponent(th.data.data.erpwareid),storeId:os.stoid}
+ })
+ }).then(res=>{
+ if(res.data.code==0 && res.data.data.total>0){
+ plist=res.data.data.pageData[0];
+ }
+ if(plist && plist.CanOutQty-lock>0){
+ that.data.fir_def_store.CanOutQty=plist.CanOutQty-lock;
+ }else{
+ that.data.fir_def_store.CanOutQty=0;
+ }
+ //--给门店赋值线下库存--
+ th.setData({def_pick_store:that.data.fir_def_store});
+ })
+ }
+ })
+ }else{
//获取门店
ee.get_sto();
}
@@ -926,6 +929,11 @@ Page({
sku: o.sku,
};
+ //如果是积分够,is_integral_normal就要有积分购普通购买字段
+ if(o.prom_type==4){
+ newd.is_integral_normal=1;
+ }
+
//-----如果是秒杀,团购,积分购,拼团-----
if (th.data.prom_type == 1) {
newd.goods_price = th.data.prom_price;
@@ -938,9 +946,11 @@ Page({
th.add_cart_next(e,t,a,o,newd); //加入购物车下一步
- } else if ( th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 2 || th.data.prom_type == 4 || th.data.prom_type == 5) {
+ }
+ else if ( th.data.prom_type == 0 || th.data.prom_type == 3 || th.data.prom_type == 2 || th.data.prom_type == 4 || th.data.prom_type == 5) {
newd.prom_type = 0;
newd.prom_id = 0;
+
//---如果是线下门店销售的时候---
if(th.data.sales_rules==2){
var pick=th.get_pick_from_list(th.data.sto_sele_id)
@@ -992,7 +1002,7 @@ Page({
//---加入购物车的最后一步---
add_cart_next(e,t,a,o,newd,CanOutQty){
- var th=this;
+ var th=this,i=getApp().request;
//---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------
if(o.prom_type!=1 && o.prom_type!=6){
var conf=th.data.bconfig;
@@ -1010,13 +1020,22 @@ Page({
if(getApp().globalData.userInfo['card_field']!=undefined && getApp().globalData.userInfo['card_field']!=null
&& getApp().globalData.userInfo['card_field']!="" && card_price>0){
newd.goods_price=card_price;
+ newd.member_goods_price=card_price;
}
}
}
}
-
+
+
+
//if (this.data.data.goods.is_virtual) return this.buyVirtualGoods(d);
if ("add" == t.currentTarget.dataset.action) {
+
+ if(th.data.prom_goods){
+ newd.prom_type = 3;
+ newd.prom_id = th.data.prom_goods[0].prom_id;
+ }
+
//----先看会员在购物车中是否加入了该商品-----
i.get("/api/weshop/cart/page", {
data: {
@@ -1043,12 +1062,12 @@ Page({
}
}
-
-
+
var updata = {
id: item.id,
goods_num: e.data.goodsInputNum + item.goods_num,
goods_price: newd.goods_price,
+ member_goods_price:newd.goods_price,
store_id: th.data.stoid,
};
@@ -1081,6 +1100,30 @@ Page({
}
//else "exchange" == t.currentTarget.dataset.action ? this.exchange(d) : this.buyNow(d);
else {
+
+ if(th.data.prom_goods){
+ var prom_d=th.data.prom_goods;
+ for(var i in prom_d){
+ //判断活动有俩种条件,0元 1件
+ var condition_t=prom_d[i].prom_type;
+ switch(condition_t) {
+ case 0: //按钱
+ if(newd.goods_price>=condition_t){
+ newd.prom_type = 3;
+ newd.prom_id = prom_d[i].prom_id;
+ }
+ break
+ case 1://按购买数量
+ if(newd.goods_num>=condition_t){
+ newd.prom_type = 3;
+ newd.prom_id = prom_d[i].prom_id;
+ }
+ break;
+ }
+ }
+
+ }
+
newd['pick_name'] = th.data.sto_sele_name;
newd['pick_dis'] = th.data.sto_sele_distr;
th.buyNow(newd);
@@ -1317,6 +1360,8 @@ Page({
data: {
store_id: o.stoid,
user_id: s.globalData.user_id,
+ state:0,
+ is_gift:0
},
success: function(e) {
var num = 0;
@@ -1515,8 +1560,11 @@ Page({
if (item) this.setData({
sele_g: item,
gid: gid
- });
-
+ });
+
+ that.check_is_youhui(gid)
+
+
this.get_sto();
//默认门店要拿下门店库存
if(that.data.sales_rules==2 && that.data.def_pick_store){
@@ -3921,12 +3969,14 @@ Page({
getPlusCardType: function (func) {
var storid = os.stoid;
var th = this;
+ var user=getApp().globalData.userInfo;
getApp().request.promiseGet("/api/weshop/plus/vip/mem/bership/list?" + "storeId=" + storid, {}).then(res => {
var plusCard = res.data.data;
var arr = [1219, 2089, 3031];
var new_arr = new Array();
var card_name_map=new Map();
for (var i = 0; i < plusCard.length; i++) {
+ if((user.card_field==null || user.card_field=="") && plusCard[i].IsStopBuy==true) continue;
var name="card"+plusCard[i].CorrPrice.toLowerCase();
card_name_map.set(name,plusCard[i].CardName);
}
@@ -3951,9 +4001,51 @@ Page({
return item;
}
}
- }
-
+ },
+ //-----显示优惠券的时候情况-----
+ show_more_cx:function () {
+ if(this.data.is_more_cx){
+ this.setData({is_more_cx:0});
+ }else{
+ this.setData({is_more_cx:1});
+ }
+ },
+
+ //----跳转到搭配购买----
+ go_prom_list:function () {
+ wx.navigateTo({ url: "../../../packageA/pages/prom_list/prom_list?goods_id="+this.data.gid, })
+ },
+
+ //---检查有没有优惠活动---
+ check_is_youhui:function(gid){
+ var th=this;
+ //调用接口判断订单优惠,
+ getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+gid+"/0", {}).then(res => {
+ if(res.data.code==0){
+ var r_data=res.data.data;
+ var max=0,min=0;
+ if(r_data.collocationList){
+ for(var i in r_data.collocationList){
+ if(max==0) max=r_data.collocationList[i].price;
+ if(min==0) min=r_data.collocationList[i].price;
+
+ if(maxparseFloat(r_data.collocationList[i].price)) min=r_data.collocationList[i].price;
+ }
+ r_data.collocationPromList.max=(max+th.data.data.shop_price).toFixed(2);
+ r_data.collocationPromList.min=(min+th.data.data.shop_price).toFixed(2);
+ }
+ th.setData({
+ order_prom:r_data.promOrder,
+ collocationGoods:r_data.collocationPromList,
+ prom_goods:r_data.promGoodsLists,
+ })
+ }
+ })
+ }
+
+
});
diff --git a/pages/goods/goodsInfo/goodsInfo.wxml b/pages/goods/goodsInfo/goodsInfo.wxml
index 7f8512a..095eded 100644
--- a/pages/goods/goodsInfo/goodsInfo.wxml
+++ b/pages/goods/goodsInfo/goodsInfo.wxml
@@ -1,7 +1,8 @@
-
+
+
@@ -434,11 +435,77 @@
+
+
+
+
+ 促销
+
+
+
+ 消费满{{item.condition}}件元
+
+ 减价{{item.money}}元;
+ 打{{item.sale}}折;
+ 包邮;
+ 送{{tem.intValue}}积分;
+ 送{{item.couponMoney}}元优惠券;
+ 送商品{{item.goods_name}};
+ 送{{item.lbtitle}};
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 订单优惠
+
+
+
+
+ {{order_prom.name}}
+ (活动时间:{{tool.format_tt(order_prom.start_time)}} - {{tool.format_tt(order_prom.end_time)}})
+
+
+
+
+
+
{{bconfig.service_bz}}
+
+
+
+
+ 优惠热配
+ 查看全部
+
+
+
+
+
+
+
+
+ {{collocationGoods.title}}
+ 搭配价¥{{collocationGoods.min}}-{{collocationGoods.max}}
+ 搭配价¥{{collocationGoods.min}}
+ 活动至{{filters.format_time(collocationGoods.end_time,1)}}
+
+
+
+
+
@@ -1029,6 +1096,8 @@
+
+
diff --git a/pages/goods/goodsInfo/goodsInfo.wxss b/pages/goods/goodsInfo/goodsInfo.wxss
index 6a66f57..6448c7d 100644
--- a/pages/goods/goodsInfo/goodsInfo.wxss
+++ b/pages/goods/goodsInfo/goodsInfo.wxss
@@ -333,8 +333,11 @@ image {
width: 29%;
}
-.join-cart>view.new_split {
- width: 14%;
+.join-cart>.new_split {
+ width: 13%;
+ text-align: center;
+ padding: 0;
+ margin: 0;
}
.cart-ico {
@@ -957,6 +960,8 @@ left:31rpx;}
transform: rotate(45deg);display:inline-block;
margin-bottom:3rpx;
}
+.bg_jj.down1{transform: rotate(135deg);}
+
/* 顶部边框 */
.topframe{
width: 100%;
@@ -2302,6 +2307,7 @@ width: 100%;
height: 91.9%;
}
+
.popup-frame{
position: fixed;
bottom:99rpx;
@@ -2567,4 +2573,29 @@ button.custom-service { line-height: normal; border: 0;}
button.custom-service::after{
border: 0;
}
-.no_store{color:#d60021; font-size: 26rpx;}
\ No newline at end of file
+.no_store{color:#d60021; font-size: 26rpx;}
+.cx_show_view{ width: 580rpx; line-height: 30rpx; margin-bottom: 6rpx; }
+.cx_show_view .word{ width: 400rpx}
+.prom_condition {
+ color: #d60021;
+ width: 180rpx;
+ height: 30rpx;
+ font-size: 20rpx;
+ padding-top: 0.01rpx;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ border: #d60021 solid 1rpx;
+ border-radius: 10rpx;
+ margin-right:10rpx ;
+ margin-left: 10rpx;
+
+}
+.hui_img{ width: 44rpx; height: 44rpx; margin-right: 8rpx}
+.order_hui{color: #444; width: 420rpx}
+.order_hui view{ height: 34rpx; line-height: 34rpx;}
+.dp_img{width: 240rpx; height: 240rpx; margin: 0 40rpx}
+.dp_cx_view{border-bottom: 0.02rpx solid #eee; padding-bottom: 40rpx}
+.act_content{ margin-top: 40rpx}
+.act_content view{ margin-bottom: 12rpx}
+.color_b{color: #ff9c00}
\ No newline at end of file
diff --git a/pages/goods/goodsList/goodsList.js b/pages/goods/goodsList/goodsList.js
index 76d79d8..ee77df3 100644
--- a/pages/goods/goodsList/goodsList.js
+++ b/pages/goods/goodsList/goodsList.js
@@ -3,6 +3,7 @@
default: t
};
}(require("../../../utils/LoadMore.js")), e = getApp(), a = new t.default(), oo = e.globalData.setting, ut = require("../../../utils/util.js");
+var regeneratorRuntime = require('../../../utils/runtime.js');
Page({
data: {
@@ -19,7 +20,9 @@ Page({
adname:"desc", //升降的字段
is_new:0,
is_hot:0,
+ prom_goods_list:null,
},
+
onLoad: function(t) {
var th=this;
a.init(this, "", "requestData");
@@ -47,8 +50,22 @@ Page({
if (0 != t.is_new && t.is_new != undefined) { url += "&is_new=" + t.is_new; }
if (0 != t.is_hot && t.is_hot != undefined) { url += "&is_hot=" + t.is_hot; }
+
+ //优惠活动的凑单
+ if(t.prom_type==3){
+ if (0 != t.prom_id && t.prom_id != undefined) { url += "&prom_id=" + t.prom_id; }
+ if (0 != t.prom_type && t.prom_type != undefined) { url += "&prom_type=" + t.prom_type; }
+ //-- 获取 --
+ getApp().request.promiseGet("/api/weshop/promgoodslist/list",{
+ data:{prom_id:t.prom_id }
+ }).then(res=>{
+ if(res.data.code==0){
+ var arr= res.data.data;
+ th.set_prom_list(arr);
+ }
+ })
+ }
this.requestGoodsList(url);
-
getApp().getConfig2(function(rs){
//计算等级价相关
var swithc_list=rs.switch_list;
@@ -80,8 +97,38 @@ Page({
},500)
}
});
-
},
+
+ //设置优惠券的
+ set_prom_list:async function(arr){
+ var th=this;
+ for(var i in arr){
+ //优惠的实际内容
+ var content=JSON.parse(arr[i].preferential_type);
+ arr[i].content=content;
+
+ //--送礼包--
+ if(content.is_libao) {
+ //-- 获取 --
+ await getApp().request.promiseGet("/api/weshop/libao/libaoForm/page?id="+content.libao+"&store_id="+oo.stoid, {
+ }).then(res => {
+ if(res.data.code==0)
+ arr[i].content.lb_name=res.data.data.pageData[0].lbtitle;
+ })
+ }
+ //--送赠品--
+ if(content.is_gift) {
+ //-- 获取 --
+ await getApp().request.promiseGet("/api/weshop/prom/gift/page?id="+content.gift+"&store_id="+oo.stoid, {
+ }).then(res => {
+ if(res.data.code==0)
+ arr[i].content.gift_name=res.data.data.pageData[0].goods_name;
+ })
+ }
+ }
+ th.setData({prom_goods_list:arr});
+ },
+
changeTab: function(t) {
var ord = t.currentTarget.dataset.href;
var ad = t.currentTarget.dataset.ad;
@@ -171,13 +218,18 @@ Page({
var plusCard = res.data.data;
var arr = [1219, 2089, 3031];
var new_arr = new Array();
- var card_name_map=new Map();
- for (var i = 0; i < plusCard.length; i++) {
+ var card_name_map=new Map();
+ var user = getApp().globalData.userInfo;
+ for (var i = 0; i < plusCard.length; i++) {
+ if ((user.card_field==null || user.card_field=="") && (plusCard[i].IsStopBuy==true)) {
+ continue;
+ }
var name="card"+plusCard[i].CorrPrice.toLowerCase();
- card_name_map.set(name,plusCard[i].CardName);
+ card_name_map.set(name,plusCard[i].CardName);
+ new_arr.push(plusCard[i]);
}
- var ob={"card_list":plusCard,"name_map":card_name_map};
+ var ob={"card_list":new_arr,"name_map":card_name_map};
func(ob);
})
},
diff --git a/pages/goods/goodsList/goodsList.wxml b/pages/goods/goodsList/goodsList.wxml
index c918332..ef97e90 100644
--- a/pages/goods/goodsList/goodsList.wxml
+++ b/pages/goods/goodsList/goodsList.wxml
@@ -1,5 +1,19 @@
+
+
+
+ 满{{item.condition}}元 件
+ 减{{item.content.money}}元
+ 打{{item.content.sale}}折
+ 送{{item.content.int}}积分
+ 送{{item.content.coupon}}元优惠券
+ 送{{item.content.gift_name}}
+ 送{{item.content.lb_name}}
+
+
+
+
综合
diff --git a/pages/goods/goodsList/goodsList.wxss b/pages/goods/goodsList/goodsList.wxss
index 1defb76..fa28dd1 100644
--- a/pages/goods/goodsList/goodsList.wxss
+++ b/pages/goods/goodsList/goodsList.wxss
@@ -64,7 +64,7 @@
width: 100%;
min-height: 200rpx;
padding: 10rpx 0;
- border-bottom: 1px solid #dfefef;
+ border-bottom: 1px solid #f5f6f6;
font-size: 30rpx;
}
diff --git a/pages/goods/search/search.js b/pages/goods/search/search.js
index f062bca..fb31a6a 100644
--- a/pages/goods/search/search.js
+++ b/pages/goods/search/search.js
@@ -197,13 +197,20 @@ Page({
var plusCard = res.data.data;
var arr = [1219, 2089, 3031];
var new_arr = new Array();
- var card_name_map=new Map();
- for (var i = 0; i < plusCard.length; i++) {
- var name="card"+plusCard[i].CorrPrice.toLowerCase();
- card_name_map.set(name,plusCard[i].CardName);
+ var card_name_map=new Map();
+ var user = getApp().globalData.userInfo;
+
+ for (var i = 0; i < plusCard.length; i++) {
+ if ((user.card_field==null || user.card_field=="") && (plusCard[i].IsStopBuy==true)) {
+ continue;
+ }
+ var name="card"+plusCard[i].CorrPrice.toLowerCase();
+ card_name_map.set(name,plusCard[i].CardName);
+ new_arr.push(plusCard[i]);
+
}
- var ob={"card_list":plusCard,"name_map":card_name_map};
+ var ob={"card_list":new_arr,"name_map":card_name_map};
func(ob);
})
},
diff --git a/pages/index/index/index.js b/pages/index/index/index.js
index a708ce8..d25120c 100644
--- a/pages/index/index/index.js
+++ b/pages/index/index/index.js
@@ -77,7 +77,7 @@ Page({
onLoad: function() {
var th = this;
-
+
//看一下商家是否开通了权益
//--初始化是否有打勾--
getApp().request.promiseGet("/api/weshop/users/grade/vip/init/get", {
@@ -102,9 +102,44 @@ Page({
is_disgraceful: 0
})
},
+
async onShow() {
var th = this;
-
+ //获取底部导航
+ // await getApp().request.promiseGet("/api/weshop/storeFooter/get/"+o.stoid, {
+
+ // }).then(res => {
+ // var e = res;
+ // console.log(e)
+ // if(e.data.code != -1){
+ // getApp().globalData.isTabBar = true
+ // //console.log(JSON.parse(e))
+ // var itemList = e.data.data.data;
+
+ // itemList = JSON.parse(itemList)
+ // for(var i=0; i
-
+
@@ -359,7 +359,9 @@
-
-
+
+
+
diff --git a/pages/tabbar/tabbar.js b/pages/tabbar/tabbar.js
new file mode 100644
index 0000000..2371de0
--- /dev/null
+++ b/pages/tabbar/tabbar.js
@@ -0,0 +1,67 @@
+// pages/tabbar.js
+var d = getApp().globalData;
+Page({
+
+ /**
+ * 页面的初始数据
+ */
+ data: {
+ isTabBar:d.isTabBar
+ },
+
+ /**
+ * 生命周期函数--监听页面加载
+ */
+ onLoad: function (options) {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面初次渲染完成
+ */
+ onReady: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面显示
+ */
+ onShow: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面隐藏
+ */
+ onHide: function () {
+
+ },
+
+ /**
+ * 生命周期函数--监听页面卸载
+ */
+ onUnload: function () {
+
+ },
+
+ /**
+ * 页面相关事件处理函数--监听用户下拉动作
+ */
+ onPullDownRefresh: function () {
+
+ },
+
+ /**
+ * 页面上拉触底事件的处理函数
+ */
+ onReachBottom: function () {
+
+ },
+
+ /**
+ * 用户点击右上角分享
+ */
+ onShareAppMessage: function () {
+
+ }
+})
\ No newline at end of file
diff --git a/pages/tabbar/tabbar.json b/pages/tabbar/tabbar.json
new file mode 100644
index 0000000..8835af0
--- /dev/null
+++ b/pages/tabbar/tabbar.json
@@ -0,0 +1,3 @@
+{
+ "usingComponents": {}
+}
\ No newline at end of file
diff --git a/pages/tabbar/tabbar.wxml b/pages/tabbar/tabbar.wxml
new file mode 100644
index 0000000..b5e6a70
--- /dev/null
+++ b/pages/tabbar/tabbar.wxml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+ {{item.nav_name}}
+
+
+
+
diff --git a/pages/tabbar/tabbar.wxss b/pages/tabbar/tabbar.wxss
new file mode 100644
index 0000000..979f504
--- /dev/null
+++ b/pages/tabbar/tabbar.wxss
@@ -0,0 +1 @@
+/* pages/tabbar.wxss */
\ No newline at end of file
diff --git a/pages/user/cardinfo/cardinfo.js b/pages/user/cardinfo/cardinfo.js
index 9e403e0..dbb9a0f 100644
--- a/pages/user/cardinfo/cardinfo.js
+++ b/pages/user/cardinfo/cardinfo.js
@@ -41,7 +41,7 @@ Page({
free:null,//分佣的数据
expiryDate:"",//卡到期时间
is_guoqi:0, //卡是不是过期
-
+ IsStopBuy:0, //卡是否停用
yu_e_show:0,//装入余额的弹窗
},
@@ -166,6 +166,10 @@ Page({
user_card.CardImg = th.data.url + "/miniapp/images/plus/bg" + index + ".jpg?v=1";
}
+ if (user_card.IsStopBuy==true){
+ this.setData({IsStopBuy:1})
+ }
+
console.log(user_card,"会员的卡类");
ee.setData({user_card: user_card});
@@ -718,12 +722,20 @@ Page({
if (res.data.code == 0) {
end_time=res.data.data.pageData[0].end_time;
}
- })
+ })
+
var now=ut.gettimestamp();
if(end_time {
+ if(res.data.code==0){
+ for(var i in res.data.data){
+ var item=res.data.data[i];
+ //IsStopBuy 如果是真的话,代表这个卡没有停用
+ if(item.IsStopBuy!=true){ isshow_vip=1;break; }
+ }
+ th.setData({isshow_vip:isshow_vip})
+ }
+ })
+ }
})
diff --git a/pages/user/index/index.wxml b/pages/user/index/index.wxml
index ed38417..f0225b2 100644
--- a/pages/user/index/index.wxml
+++ b/pages/user/index/index.wxml
@@ -1,4 +1,4 @@
-
+
@@ -63,6 +63,9 @@
+
+
+
@@ -86,6 +89,7 @@
+
@@ -297,3 +301,7 @@
+
\ No newline at end of file
diff --git a/pages/user/order_detail/order_detail.js b/pages/user/order_detail/order_detail.js
index 01c93a3..2193860 100644
--- a/pages/user/order_detail/order_detail.js
+++ b/pages/user/order_detail/order_detail.js
@@ -70,6 +70,16 @@ Page({
success:async function (eb) {
r.order_goods=eb.data.data.pageData;
+ var glist = r.order_goods;
+ for(var i in glist){
+ if(glist[i].is_gift){
+ r.is_prom=1;
+ }
+ }
+
+
+
+
//------------对比一下有没有退款记录------------
await getApp().request.promiseGet("/api/weshop/order/returngoods/page",{
data: { order_id: r.order_id, store_id: os.stoid,
@@ -225,15 +235,13 @@ Page({
if(!e.confirm) return false;
//如果是秒杀和拼单的商品,取消订单要返回redis,并取消订单
//if(is_skill==1 || is_zsorder>=2){
-
- getApp().request.delete("/api/weshop/order/cancelTeamOrder/"+os.stoid+"/"+o,{
+ getApp().request.post("/api/weshop/order/cancelOrder/"+os.stoid+"/"+o+"/"+getApp().globalData.user_id,{
data:{},
success: function(t) {
if(t.data.code==0)
th.requestOrderDetail(o), wx.setStorageSync("order:order_list:update", !0);
},
})
-
/*----
}else{
getApp().request.put("/api/weshop/order/updatebyId", {
@@ -249,24 +257,19 @@ Page({
//--------确认收货---------
confirmOrder: function(e) {
+ var th=this;
var t = this, o = this.data.order.order_id,order=this.data.order;
var is_zsorder=order.is_zsorder;
wx.showModal({
title: "是否确认收货?",
- success: function(e) {
- e.confirm && r.put("/api/weshop/order/updatebyId", {
- data: {
- order_id: o, order_status: 2
- },
- success: function(e) {
- t.requestOrderDetail(o), wx.setStorageSync("order:order_list:update", !0);
- //如果是会员团订单
- if(is_zsorder==3){
- getApp().request.post("/api/weshop/order/vipTuanTebate/"+os.stoid+"/"+o,{
- data:{}, success:function () { }})
- }
+ success: function(t) {
+ t.confirm && rq.post("/api/weshop/order/confirmOrder/"+os.stoid+"/"+o+"/"+getApp().globalData.user_id,{
+ success:function (e) {
+ if(e.data.code==0){
+ th.requestOrderDetail(o)
+ }
}
- });
+ })
}
});
},
@@ -284,7 +287,7 @@ Page({
for(var i in order_goods){
var good=order_goods[i];
//如果不是小程序有的功能,直接提示要去3.0处理
- if(good.prom_type==2 || good.prom_type==3 || good.prom_type==4 || good.prom_type==5){
+ if(good.prom_type==2 || good.prom_type==4){
wx.showModal({
title: '提示',
content: '小程序还未有该活动,请到3.0公众号支付'
@@ -325,8 +328,8 @@ Page({
});
return false;
}
-
- if(good.prom_type==1 || good.prom_type==6){
+
+ if((good.prom_type==1 || good.prom_type==6 || good.prom_type==5 ) && !good.is_gift && !good.is_collocation){
if(gg.prom_type!=good.prom_type) {
wx.showModal({
title: '提示',
@@ -334,6 +337,32 @@ Page({
});
return false;
}
+ if(good.prom_type==3 || good.prom_type==5){
+ await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => {
+ }).then(res=>{
+ if(res.data.code==0){
+ var r_data=res.data.data;
+ if(!r_data.collocationPromList && good.prom_type==5){
+ wx.showModal({
+ title: '提示',
+ content: good.goods_name+'未找到活动'
+ });
+ }
+ if(!r_data.promGoodsLists && good.prom_type==3){
+ wx.showModal({
+ title: '提示',
+ content: good.goods_name+'未找到活动'
+ });
+ }
+ }else{
+ wx.showModal({
+ title: '提示',
+ content: good.goods_name+'未找到活动'
+ });
+ return false;
+ }
+ })
+ }
}else{
@@ -369,24 +398,25 @@ Page({
}
}
}
-
-
- var isok=1;
- var card_field=th.data.card_field;
- //如果会员是等级会员,商品有等级价,且不是活动商品
- if(card_field && gg[card_field]>0){
- if (good.goods_price != gg[card_field]) isok = 0;
- }else{
- if (good.goods_price != gg.shop_price) isok = 0;
-
- }
- if(!isok){
- wx.showModal({
- title: '提示',
- content: gg.goods_name+'商品的价格发生了变化'
- });
- return false;
- }
+
+ if(!good.is_gift && !good.is_collocation) {
+ var isok = 1;
+ var card_field = th.data.card_field;
+ //如果会员是等级会员,商品有等级价,且不是活动商品
+ if (card_field && gg[card_field] > 0) {
+ if (good.goods_price != gg[card_field]) isok = 0;
+ } else {
+ if (good.goods_price != gg.shop_price) isok = 0;
+
+ }
+ if (!isok) {
+ wx.showModal({
+ title: '提示',
+ content: gg.goods_name + '商品的价格发生了变化'
+ });
+ return false;
+ }
+ }
//--如果是线下库存的时候--
if(th.data.conf.sales_rules==2){
diff --git a/pages/user/order_detail/order_detail.wxml b/pages/user/order_detail/order_detail.wxml
index 292b975..51db5fc 100644
--- a/pages/user/order_detail/order_detail.wxml
+++ b/pages/user/order_detail/order_detail.wxml
@@ -35,7 +35,7 @@
×{{item.goods_num}}
-
+
申请退款
¥ {{order.integral_money}}元
+
+ 优惠活动
+ ¥ {{order.discount_amount}}元
+
+
订单优惠
¥ {{order.order_prom_amount}}元
@@ -150,7 +155,7 @@
删除订单
- 重新退款
+ 重新退款
退款详情
diff --git a/pages/user/order_list/order_list.js b/pages/user/order_list/order_list.js
index 63f0b68..bf1d6dd 100644
--- a/pages/user/order_list/order_list.js
+++ b/pages/user/order_list/order_list.js
@@ -112,6 +112,14 @@ Page({
tt = res;
})
+ var glist = tt.data.data.pageData;
+ for(var i in glist){
+ if(glist[i].is_gift){
+ data[ind].is_prom=1;
+ }
+ }
+
+
//------------对比一下有没有退款记录------------
await getApp().request.promiseGet("/api/weshop/order/returngoods/page", {
data: {
@@ -253,7 +261,7 @@ Page({
//如果是秒杀和拼单的商品,取消订单要返回redis,并取消订单
if (t.confirm) {
//if(is_skill==1 || is_zsorder>=2){
- getApp().request.delete("/api/weshop/order/cancelTeamOrder/" + os.stoid + "/" + a, {
+ getApp().request.post("/api/weshop/order/cancelOrder/"+os.stoid+"/"+a+"/"+getApp().globalData.user_id, {
data: {},
success: function(t) {
if (t.data.code == 0) {
@@ -278,22 +286,14 @@ Page({
wx.showModal({
title: "是否确认收货?",
success: function(t) {
- t.confirm && rq.put("/api/weshop/order/updatebyId", {
- data: {
- order_id: a,
- order_status: 2
- },
- success: function(t) {
- e.deleteOrderData2(a);
- //如果是会员团订单
- if (is_zsorder == 3) {
- getApp().request.post("/api/weshop/order/vipTuanTebate/" + os.stoid + "/" + a, {
- data: {},
- success: function() {}
- })
+ t.confirm && rq.post("/api/weshop/order/confirmOrder/"+os.stoid+"/"+a+"/"+getApp().globalData.user_id,{
+ success:function (e) {
+ if(e.data.code==0){
+ th.deleteOrderData2(a);
+ getApp().confirmBox( "确认收货成功!");
+ }
}
- }
- });
+ })
}
});
},
@@ -307,7 +307,7 @@ Page({
var order=th.data.orderList[index];
if(order.order_status!=6){
up_data.order_status=5;
- }
+ }
wx.showModal({
title: "是否删除订单?",
success: function(tt) {
@@ -380,7 +380,7 @@ Page({
for(var i in order_goods){
var good=order_goods[i];
//如果不是小程序有的功能,直接提示要去3.0处理
- if(good.prom_type==2 || good.prom_type==3 || good.prom_type==4 || good.prom_type==5){
+ if(good.prom_type==2 || good.prom_type==4 ){
wx.showModal({
title: '提示',
content: '小程序还未有该活动,请到3.0公众号支付'
@@ -422,10 +422,7 @@ Page({
return false;
}
-
- console.log("-----------------111-------------------");
-
- if(good.prom_type==1 || good.prom_type==6){
+ if((good.prom_type==1 || good.prom_type==6 || good.prom_type==5 ) && !good.is_gift && !good.is_collocation){
if(gg.prom_type!=good.prom_type) {
wx.showModal({
title: '提示',
@@ -433,9 +430,34 @@ Page({
});
return false;
}
-
+ if(good.prom_type==3 || good.prom_type==5){
+ await getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid+"/"+good.goods_id+"/0", {}).then(res => {
+ }).then(res=>{
+ if(res.data.code==0){
+ var r_data=res.data.data;
+ if(!r_data.collocationPromList && good.prom_type==5){
+ wx.showModal({
+ title: '提示',
+ content: good.goods_name+'未找到活动'
+ });
+ }
+ if(!r_data.promGoodsLists && good.prom_type==3){
+ wx.showModal({
+ title: '提示',
+ content: good.goods_name+'未找到活动'
+ });
+ }
+ }else{
+ wx.showModal({
+ title: '提示',
+ content: good.goods_name+'未找到活动'
+ });
+ return false;
+ }
+ })
+ }
+
}else{
-
if(gg.prom_type==1 || gg.prom_type==6){
var prom=null;
//---如果是活动的时候---
@@ -468,24 +490,25 @@ Page({
}
}
}
-
-
+ //赠品和搭配购不判断商品金额
var isok=1;
var card_field=th.data.card_field;
//如果会员是等级会员,商品有等级价,且不是活动商品
- if(card_field && gg[card_field]>0){
- if (good.goods_price != gg[card_field]) isok = 0;
- }else{
- if (good.goods_price != gg.shop_price) isok = 0;
-
- }
- if(!isok){
- wx.showModal({
- title: '提示',
- content: gg.goods_name+'商品的价格发生了变化'
- });
- return false;
- }
+ if(!good.is_gift && !good.is_collocation) {
+ if (card_field && gg[card_field] > 0) {
+ if (good.goods_price != gg[card_field]) isok = 0;
+ } else {
+ if (good.goods_price != gg.shop_price) isok = 0;
+
+ }
+ if (!isok) {
+ wx.showModal({
+ title: '提示',
+ content: gg.goods_name + '商品的价格发生了变化'
+ });
+ return false;
+ }
+ }
//--如果是线下库存的时候--
if(th.data.conf.sales_rules==2){
@@ -577,6 +600,7 @@ Page({
pay_next(e){
+ var th=this;
if (e.order_amount == 0) {
var dd = {
parent_sn: e.order_sn,
diff --git a/pages/user/order_list/order_list.wxml b/pages/user/order_list/order_list.wxml
index 335bf1a..eb16b95 100644
--- a/pages/user/order_list/order_list.wxml
+++ b/pages/user/order_list/order_list.wxml
@@ -67,7 +67,7 @@
-
+
申请退款
退款中
重新退款
@@ -115,7 +115,8 @@
合计:
¥
- {{filters.toFix(item.order_amount+item.user_money,2)}}
+ {{filters.toFix(item.order_amount+item.user_money,2)}}
+ +{{item.coupon_price}}元优惠券
@@ -124,6 +125,8 @@
{{filters.toFix(item.pt_tail_money-item.shipping_price,2)}}
+
+
@@ -139,7 +142,7 @@
删除订单
- 重新退款
+ 重新退款
退款详情
查看物流
diff --git a/pages/user/plus/plus.js b/pages/user/plus/plus.js
index f448955..c428acd 100644
--- a/pages/user/plus/plus.js
+++ b/pages/user/plus/plus.js
@@ -173,9 +173,12 @@ Page({
var new_arr = new Array();
for (var i = 0; i < plusCard.length; i++) {
//plusCard[i].free=arr[i];
- if (plusCard[i].CardImg == "") plusCard[i].CardImg = th.data.url + "/miniapp/images/plus/bg"+(i + 1)+ ".jpg?v=1";
- var item = {"fee": plusCard[i].CardFee, 'index': i}
- new_arr.push(item);
+
+
+ if (plusCard[i].CardImg == "") plusCard[i].CardImg = th.data.url + "/miniapp/images/plus/bg"+(i + 1)+ ".jpg?v=1";
+ var item = {"fee": plusCard[i].CardFee, 'index': i}
+ new_arr.push(item);
+
}
//根據距離遠近排序,越近在前面,升序
new_arr.sort(function (a, b) {
@@ -189,11 +192,15 @@ Page({
});
//---给数组添加立省多少钱---
for (i = 0; i < plusCard.length; i++) {
- for (var j = 0; j < new_arr.length; j++) {
- if (i == new_arr[j].index) {
- plusCard[i].free = arr[j];
- break;
- }
+ //判断是否停用
+
+ for (var j = 0; j < new_arr.length; j++) {
+ if (i == new_arr[j].index) {
+ plusCard[i].free = arr[j];
+ break;
+ }
+
+
}
}
th.setData({
diff --git a/pages/user/plus/plus.wxml b/pages/user/plus/plus.wxml
index 26a54c5..efb2313 100644
--- a/pages/user/plus/plus.wxml
+++ b/pages/user/plus/plus.wxml
@@ -14,7 +14,8 @@
-
+
+
{{item.CardName}}
@@ -35,6 +36,8 @@
+
+
diff --git a/utils/filter.wxs b/utils/filter.wxs
index b71c82d..aa3ba54 100644
--- a/utils/filter.wxs
+++ b/utils/filter.wxs
@@ -1,5 +1,6 @@
var filters = {
toFix:function(val,count){
+ val=parseFloat(val);
return val.toFixed(count)
},
replace_time:function(val){
diff --git a/utils/pay.js b/utils/pay.js
index 0eb75a6..eca068a 100644
--- a/utils/pay.js
+++ b/utils/pay.js
@@ -34,10 +34,12 @@ module.exports = {
if(t.data.code==0){
i.weixinPay(t.data.data, e, a);
}else{
- t.showSuccess(t.data.msg);
- wx.redirectTo({
- url: "/pages/user/order_list/order_list",
- });
+ getApp().showWarning(t.data.msg);
+ setTimeout(function(){
+ wx.redirectTo({
+ url: "/pages/user/order_list/order_list",
+ });
+ },1000)
}
return false;
},
diff --git a/utils/request.js b/utils/request.js
index c87ca77..c7bd5b6 100644
--- a/utils/request.js
+++ b/utils/request.js
@@ -206,6 +206,27 @@ module.exports = {
})
})
},
+
+ //---promise的使用delete----
+ promiseDelete:function(url,data){
+ var th=this;
+ if(url.indexOf("http")==-1) url=getApp().globalData.setting.url +url;
+ return new Promise((resolve, reject) => {
+ data.isShowLoading && th.showLoading();
+ wx.request({
+ url,
+ method: 'DELETE',
+ header: {"content-type": "application/x-www-form-urlencoded" },
+ data:data.data,
+ success(res) {
+ data.isShowLoading && th.hideLoading();
+ resolve(res);
+ },
+ fail(err) { data.isShowLoading && th.hideLoading(); reject(err); }
+ })
+ })
+ },
+
//--------具有时间限制的读取接口----------
time_limit_get(time,url,data){
var req=this.get(url,data);