From 6a9bb26ed057a90447e7fc714e2711a7190ea0c0 Mon Sep 17 00:00:00 2001 From: yvan.ni Date: Wed, 10 Nov 2021 10:29:28 +0800 Subject: [PATCH] 团购 --- components/diy_groupbuy/diy_groupbuy.js | 242 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------- components/diy_groupbuy/diy_groupbuy.wxml | 291 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- components/diy_groupbuy/diy_groupbuy.wxss | 593 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- pages/cart/cart2/cart2.js | 42 ++++++++++++++++++++++++++++++++++++++---- pages/goods/goodsInfo/goodsInfo.js | 161 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------- pages/goods/goodsInfo/goodsInfo.wxml | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------ pages/index/index/index.wxml | 21 +++++++++++++++++---- pages/template/index.wxml | 6 ++++-- pages/user/order_detail/order_detail.js | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------- pages/user/order_list/order_list.js | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------- 10 files changed, 919 insertions(+), 683 deletions(-) diff --git a/components/diy_groupbuy/diy_groupbuy.js b/components/diy_groupbuy/diy_groupbuy.js index 36f7de1..71cef18 100644 --- a/components/diy_groupbuy/diy_groupbuy.js +++ b/components/diy_groupbuy/diy_groupbuy.js @@ -1,25 +1,221 @@ +var regeneratorRuntime = require('../../utils/runtime.js'); +var ut = require("../../utils/util.js"); +var os= getApp().globalData.setting; Component({ - properties: { - // 这里定义了innerText属性,属性值可以在组件使用时指定 - - style_b: { - type: Number, - value: 3, - }, - - - - - - }, - data: { - // 这里是一些组件内部数据 - bulk:false, - someData: {} - }, - methods: { - // 这里是一个自定义方法 - - customMethod: function () { } - } + properties: { + // 这里定义了innerText属性,属性值可以在组件使用时指定 + object: { + type: Object, + value: null, + }, + goods_array: { + type: Array, + value: [] + }, + newTime: { + type: Number, + value: 0 + }, + }, + data: { + // 这里是一些组件内部数据 + yc: false, + someData: null, + ylp_img: "https://mshopimg.yolipai.net/", + imghost: os.imghost, + timer: null, + }, + + pageLifetimes: { + //要处理一下,游客登录后的界面的变化,主要还该是改变会员 + show: function () { + //会员身份变化 + var th = this; + var g_id = this.data.object; + this.init(g_id); + setTimeout(function () { + if (th.data.goods_array && th.data.goods_array.length > 0) { + th.data.timer = setInterval(function () { + th.countDown2(th); + }, 1000); + } + },600) + } + }, + + ready: function () { + var g_id = this.data.object; + this.init(g_id); + }, + detached() { + // 页面被被销毁的时候,清除定时器 + clearInterval(this.data.timer); + }, + + + methods: { + // 这里是一个自定义方法 + customMethod: function () { }, + + + init: function (g_id) { + var th = this, app = getApp(), goodsidlist = ""; + if (g_id.data && g_id.data.length > 0) { + //--先把商品ID串起来-- + g_id.data.forEach(function (val, ind) { + var item = {}; + goodsidlist += val.goodsid + ","; + }) + goodsidlist = ut.sub_last(goodsidlist); + + var user_id=getApp().globalData.user_id; + if(!user_id){ user_id=0;} + + //--调用接口,读取秒杀-- + app.request.promiseGet("/api/weshop/goods/groupBuy/getGoodsList?store_id=" + + os.stoid + "&aidlist=" + goodsidlist+"&user_id="+user_id, {}).then(res => { + console.log(res); + //如果秒杀的数组为空的时候 + var goodslist = res.data.data; + //就算是添加的活动已经过期,就要用最新的进行中活动 + if (goodslist && goodslist.length > 0) { + th.set_goods_list(g_id.data, goodslist); + } + }); + } + else { + th.no_gid_set(); + } + }, + + //-- 当是默认的情况 -- + no_gid_set() { + var user_id=getApp().globalData.user_id; + if(!user_id){ user_id=0;} + var req={ store_id: os.stoid, is_end: 0, is_show: 1, timetype: 2,user_id:user_id}; + + getApp().request.promiseGet("/api/weshop/goods/groupBuy/page?page=1&pageSize=9", + { isShowLoading: 1, data:req } + ).then(res => { + if (res.data.code == 0 && res.data.data.pageData && res.data.data.pageData.length > 0) { + var goodsidlist = res.data.data.pageData; + this.set_goods_list(null, goodsidlist); + } + }); + }, + + //就算是添加的活动已经过期,就要用最新的活动 + set_goods_list(g_id, goodslist) { + // 判断火热,预热 + var newTime = ut.gettimestamp(), all_array = [], th = this; + th.setData({ newTime: newTime }); + if (g_id) { + /*--商品队列按照添加的顺序排列--*/ + g_id.forEach(function (val, ind) { + goodslist.forEach(function (vy, indy) { + if (val.goodsid == vy.goods_id) { + if(!vy.id) vy.id=vy.prom_id; + all_array.push(vy); + } + }) + }) + } else { + all_array = goodslist; + } + + + if (all_array.length == 0) { + all_array = goodslist; + } + + for(let i in all_array){ + let item=all_array[i]; + if(item.user_price) item.price=item.user_price; + } + + var arr = new Array(); + //--三个三个一组--- + for (var i = 0; i < all_array.length; i += 3) { + arr.push(all_array.slice(i, i + 3)); + } + /*--熏染到前台--*/ + + th.setData({ goods_array: arr }); + + th.data.timer = setInterval(function () { + th.countDown2(th); + }, 1000); + }, + + //---小于10的格式化函数---- + timeFormat: function (param) { + return param < 10 ? '0' + param : param; + }, + //----秒杀倒计时函数----- + countDown2: function (ob) { + if (ob == undefined) return false; + var ee = ob; + // 获取当前时间,同时得到活动结束时间数组 + var newTime = ut.gettimestamp(); + this.setData({ newTime: newTime }); + + var List = ee.data.goods_array; + if (List.length == 0) return false; + for (var j = 0; j < List.length; j++) { + // 对结束时间进行处理渲染到页面 + var endTimeList = List[j]; + for (var i = 0; i < endTimeList.length; i++) { + var o = endTimeList[i]; + var endTime = o.end_time; + if (newTime < o.start_time) endTime = o.start_time; + let obj = null; + // 如果活动未结束,对时间进行处理 + if (endTime - newTime > 0) { + let time = (endTime - newTime); + // 获取天、时、分、秒 + let day = parseInt(time / (60 * 60 * 24)); + let hou = parseInt(time % (60 * 60 * 24) / 3600); + let min = parseInt(time % (60 * 60 * 24) % 3600 / 60); + let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60); + obj = { + day: this.timeFormat(day), + hou: this.timeFormat(hou), + min: this.timeFormat(min), + sec: this.timeFormat(sec) + } + } else { + //活动已结束,全部设置为'00' + obj = { + day: '00', + hou: '00', + min: '00', + sec: '00' + } + } + var txt = "goods_array[" + j + "][" + i + "].djs"; + ee.setData({ + [txt]: obj + }); + } + } + }, + //图片失败,默认图片 + bind_bnerr3: function (e) { + var _errImg = e.target.dataset.errorimg; + var _errObj = {}; + _errObj[_errImg] = "/public/images/default_goods_image_240.gif"; + this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ; + }, + + //跳转到秒杀列表 + go_to_group: function () { + + var url="/packageC/pages/group_list/group_list"; + getApp().goto(url); + + } + + + + } }) \ No newline at end of file diff --git a/components/diy_groupbuy/diy_groupbuy.wxml b/components/diy_groupbuy/diy_groupbuy.wxml index c95c04c..249862c 100644 --- a/components/diy_groupbuy/diy_groupbuy.wxml +++ b/components/diy_groupbuy/diy_groupbuy.wxml @@ -1,185 +1,106 @@ - - - - - - - -团购 - - - - - - - - - - - -11天22小时33分44秒 - - - -ddddd -¥1111111111111 -¥1111111111111111 - - - - 已抢50件 - 50% - - - - - - - -11天22小时33分44秒 - - - -ddddd -1111 -1111 - - - - 已抢50件 - 50% - - - - - - - -11天22小时33分44秒 - - - -ddddd -1111 -1111 - - - 已抢50件 - 50% - - - - - - - - - - - - 距结束时间 - 1122:22:22 - - - - - - - - - - - ddddd - - - 已抢50件 - 50% - - - 1111 - 1111 - - - - - - - - - - - 距结束时间 - 1122:22:22 - - - - - - - - ddddd - - - 已抢50件 - 50% - - - 1111 - 1111 - - - - - - - - - - - 距结束时间 - 1122:22:22 - - - - - - - - ddddd - - - 已抢50件 - 50% - - - 1111 - 1111 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + 团购 + + + + + + + + + + + + + + + + + + + + + {{aitem.djs.day}}天 + {{aitem.djs.hou}}时 + {{aitem.djs.min}}分 + {{aitem.djs.sec}}秒 + + + + + + + {{aitem.goods_name}} + ¥{{aitem.price}} + ¥{{aitem.market_price}} + + + 已抢0件 + 0% + + + + + + + + + + + + + + + + + + 距结束时间 + + + {{aitem.djs.day}} 天 + {{aitem.djs.hou}} : + {{aitem.djs.min}} : + {{aitem.djs.sec}} + + + + + + + + + + + + {{aitem.title}} + + + + + + ¥{{aitem.price}} + ¥{{aitem.market_price}} + + + + + + + + + + + + + diff --git a/components/diy_groupbuy/diy_groupbuy.wxss b/components/diy_groupbuy/diy_groupbuy.wxss index 0665ff4..ec03a93 100644 --- a/components/diy_groupbuy/diy_groupbuy.wxss +++ b/components/diy_groupbuy/diy_groupbuy.wxss @@ -1,487 +1,326 @@ -/* pages/team_guo/team_guo.wxss */ - -/* pages/wp/wp.wxss */ -.kbstyle{ - background-color: red; - width: 100%; - height: 60rpx; +.flex{ + display: flex; + align-items: center; +} +.top { + background-color: white; + height: 70rpx; + line-height: 70rpx; + color: #000; + border-bottom: 2rpx solid #eee; + padding:0rpx 20rpx; + display: flex; + justify-content: space-between; + font-size: 32rpx; } -.right_b{ - width: 30rpx; - height: 100%; - background: url(https://mshopimg.yolipai.net/miniapp/images/user/leftTip.png) no-repeat center center; - background-size: 22rpx 40rpx; - margin-left: 600rpx; +.s_it { + width: 100%; + display: flex; + background-color: white; } -.top_b{ +.s_prom { width: 100%; background-color: white; - height: 70rpx; - line-height: 70rpx; - color: #000; - text-align: left; - border-bottom: 2rpx solid #eee; - display: flex; + min-height: 200rpx; } -.top_b .t_left_b{ - width: 6rpx; - height: 38rpx; - background: #C4182E; - margin-top:18rpx; -margin-right:12rpx; +swiper { + display: block; + height: 460rpx; +} +.right_k { + width: 30rpx; +} +.right_k image{ + width: 30rpx; + height: 30rpx; +} + .t_left { + width: 10rpx; + height: 38rpx; + background: #c4182e; + margin-right: 10rpx; } -.sp_b{ +.sp { min-height: 300rpx; width: 100%; background-color: white; - padding:18rpx; -display: flex; + padding: 18rpx; + display: flex; } -.sp_b .sp_top_b{ - height: 220rpx; +.sp .sp_top { + height: 190rpx; min-width: 30%; - background-color: bisque; - } -.sp_b .sp_top_b .s_img_b{ +.sp .sp_top .s_img { width: 210rpx; height: 100%; } -.sp_b .sp_top_b .s_img_b image{ +.sp .sp_top .s_img image { width: 210rpx; height: 100%; - background-color: blueviolet; - position:relative; -top:-24rpx; -left:-64rpx; +} +.sp .sp_top .s_top_kill { + background-color: #c4182e; + font-size: 24rpx; + height: 38rpx; + line-height: 38rpx; + padding: 4rpx 10rpx; + border-radius: 10rpx; + z-index: 999; + position: relative; + top: 1rpx; + width: 110rpx; + color: #fff; + text-align: center; } -.sp_b .sp_top_b .s_top_b{ +.po { position: absolute; -background-color:#C4182E; -font-size:24rpx; -height:38rpx; -line-height:38rpx; -left:40rpx; -top:160rpx; -padding:0 10rpx; -color:white; -border-radius:10rpx; - } -.sp_b .sp_top_b .s_foot_bulk{ +.sp .sp_top .s_foot_kill { font-size: 20rpx; - position: relative; - top:-40rpx; - width: 210rpx; - height: 38rpx; - line-height: 38rpx; - color: #fff; - text-align: center; - background-color: rgba(0, 0, 0, 0.5); + position: absolute; + width: 210rpx; + height: 38rpx; + line-height: 38rpx; + color: #fff; + text-align: center; + background-color: rgba(0, 0, 0, 0.5); } +.sp_wz { + width: 210rpx; + min-height: 100rpx; + margin-top: 50rpx; +} +.sp_wz .sp_wzi { + font-size: 30rpx; + border-bottom: 2rpx solid #dcdcdc; + width: 100%; + text-align: left; + padding: 4rpx 0; + overflow: hidden; + height: 48rpx; + text-overflow: ellipsis; + white-space: nowrap; + line-height: 48rpx; +} -.sp_wz_b{ -width: 210rpx; - min-height:100rpx; - +.sp_wz .sp_jg { + color: #c4182e; + font-size: 30rpx; + overflow: hidden; + display: inline-block; + text-overflow: ellipsis; + white-space: nowrap; + margin-right: 10rpx; } -.sp_wz_b .sp_wzi_b{ - font-size: 28rpx; - border-bottom: 2rpx solid #dcdcdc; - width: 100%; - text-align: left; - padding: 4rpx 0; - overflow: hidden; - height: 48rpx; - text-overflow: ellipsis; - display: inline-block; - white-space: nowrap; -} - -.sp_wz_b .sp_jg_b{ - color: #C4182E; - font-size: 20rpx; - width: 50%; - overflow: hidden; - display: inline-block; - - text-overflow: ellipsis; - white-space: nowrap; -} - -.sp_wz_b .sp_jgx_b{ - color: #dcdcdc; - text-decoration: line-through; - font-size: 20rpx; - width: 50%; - overflow: hidden; - display: inline-block; - - text-overflow: ellipsis; - white-space: nowrap; +.sp_wz .sp_jgx { + color: #adadad; + text-decoration: line-through; + font-size: 24rpx; + overflow: hidden; + display: inline-block; + text-overflow: ellipsis; + white-space: nowrap; } -.one_b{ +.one { margin-left: 14rpx; - } - -.sp_b .sp_top_b .s_top1_b{ +.sp .sp_top .s_top1_kill { position: absolute; -background-color:#C4182E; -font-size:24rpx; -height:38rpx; -line-height:38rpx; -left:265rpx; -top:160rpx; -padding:0 10rpx; -color:white; -border-radius:10rpx; - + background-color: #c4182e; + font-size: 24rpx; + height: 38rpx; + line-height: 38rpx; + left: 265rpx; + top: 100rpx; + padding: 0 10rpx; + color: white; + border-radius: 10rpx; } -.sp_b .sp_top_b .s_top2_b{ +.sp .sp_top .s_top2_kill { position: absolute; -background-color:#C4182E; -font-size:24rpx; -height:38rpx; -line-height:38rpx; -right:146rpx; -top:160rpx; -padding:0 10rpx; -color:white; -border-radius:10rpx; - + background-color: #c4182e; + font-size: 24rpx; + height: 38rpx; + line-height: 38rpx; + right: 146rpx; + top: 100rpx; + padding: 0 10rpx; + color: white; + border-radius: 10rpx; } - - -.sp_b .sp_top_b .s_foot1_bulk{ +.sp .sp_top .s_foot1_kill { font-size: 20rpx; - position: relative; - top:-40rpx; - width: 210rpx; - height: 38rpx; - line-height: 38rpx; - color: #fff; - text-align: center; - background-color: rgba(0, 0, 0, 0.5); + position: absolute; + top: 270rpx; + width: 210rpx; + height: 38rpx; + line-height: 38rpx; + color: #fff; + text-align: center; + background-color: rgba(0, 0, 0, 0.5); } +.po1 { + position: absolute; +} - -.sp_b .sp_top_b .s_foot2_bulk{ +.sp .sp_top .s_foot2_kill { font-size: 20rpx; - position: relative; - top:-40rpx; - width: 210rpx; - height: 38rpx; - line-height: 38rpx; - color: #fff; - text-align: center; - background-color: rgba(0, 0, 0, 0.5); + position: absolute; + top: 270rpx; + width: 210rpx; + height: 38rpx; + line-height: 38rpx; + color: #fff; + text-align: center; + background-color: rgba(0, 0, 0, 0.5); } - - - - - - -.sp2_b{ +.sp2 { width: 100%; min-height: 240rpx; - } -.sp2_b .one1_b{ - width: 100%; +.sp2 .one1 { background-color: white; - height: 252rpx; + height: 285rpx; display: flex; - padding: 20rpx; - border-bottom:2rpx#eee solid; - + padding:0rpx 20rpx; + border-bottom: 6rpx#eee solid; + align-items: center; } -.sp2_b .one1_b .o1_img_b{ - width: 200rpx; - height: 240rpx; - background-color: bisque; - margin-right: 24rpx; +.sp2 .one1 .o1_img { + width: 220rpx; + height: 220rpx; + margin-right: 25rpx; } -.o1_right_b .sp_wzi_b{ - font-size: 36rpx; - margin-bottom:6rpx; - - width: 100%; +.o1_right .sp_wzi { + font-size: 30rpx; + margin-bottom: 6rpx; text-align: left; padding: 4rpx 0; - overflow: hidden; height: 48rpx; + overflow: hidden; + white-space: nowrap; text-overflow: ellipsis; } -.o1_right_b .o1_sj_b{ +.o1_right .o1_sj_kill { height: 60rpx; - margin-bottom: 10rpx; + font-size: 28rpx; } -.o1_right_b .o1_sj_b text{ +.o1_sj_kill text { background-color: #fdcb08; text-align: center; border-radius: 10rpx; - padding:4rpx; -margin-left:6rpx; - + padding: 4rpx; + margin-left: 6rpx; + color: #777; + font-size: 28rpx; } - - -.o1_right_b .sp_jg_b{ - color: #C4182E; - font-size: 36rpx; - width: 28%; +.o1_right .sp_jg { + color: #c4182e; + font-size: 30rpx; overflow: hidden; - margin-top: 10rpx; + margin-right: 10rpx; } -.o1_right_b .sp_jgx_b{ +.o1_right .sp_jgx { color: #dcdcdc; text-decoration: line-through; font-size: 26rpx; - width: 50%; overflow: hidden; - display: inline-block; - margin-top: 10rpx; -} - - -.o1_img_b image{ - width: 100%; - height: 100%; - background-color: blueviolet; - position: relative; - top:-24rpx; -left:-64rpx; - } -.o1_right_b .wo_b{ - background-color: #C4182E; - width: 160rpx; - height: 60rpx; - line-height: 60rpx; - color: white; - text-align: center; - font-size: 38rpx; - margin-left:298rpx; -border-radius:14rpx; - -} - -.guo_b{ - width: 100%; - border: 1px solid #C4182E; - text-align: left; - background-color: #fff; - border-radius:24rpx; -height:44rpx; -font-size:26rpx; -display: flex; -} - -.g_one_b{ - width: 50%; - height: 44rpx; - line-height: 44rpx; - text-align: left; - background-color: #C4182E; -color: white; -border-radius:24rpx; -padding-right: 2rpx; - text-overflow: ellipsis; - white-space: nowrap; - overflow: hidden; -} - -.g_one_b text{ - margin-left: 10rpx; - text-overflow: ellipsis; -} - -.g_two_b{ - height: 44rpx; - line-height: 44rpx; - text-align: right; - width: 50%; - color: #C4182E; -} - -.g_two_b text{ - margin-right: 10rpx; -} - -.g_top_b{ - display: flex; - background-color: #fbfaff; - color: #333; - font-size: 28rpx; - height: 60rpx; - line-height: 60rpx; - width: 94%; -} - -.g_top_b text{ - margin-left: 20rpx; -} - -.o1_sj_b text{ - background-color: #fdcb08; - text-align: center; - border-radius: 10rpx; - padding:4rpx; - margin-left:6rpx; - -} - -.o1_sj_b{ - margin-left: 370rpx; +.o1_img image { + width: 220rpx; + height: 220rpx; } - -.sp2_guo_b{ - width: 100%; - border: 1px solid #C4182E; - text-align: left; - background-color: #fff; - border-radius:24rpx; - height:44rpx; - font-size:26rpx; - display: flex; +.o1_right{ + width: 465rpx; } - -.g_one2_b{ - width: 50%; - height: 44rpx; - line-height: 44rpx; - text-align: left; - background-color: #C4182E; +.o1_right .wo { + background-color: #c4182e; + width: 150rpx; + height: 50rpx; + line-height: 50rpx; color: white; - border-radius:24rpx; - padding-right: 2rpx; -} - -.g_one2_b text{ - margin-left: 10rpx; -} - -.g_two2_b{ - height: 44rpx; - line-height: 44rpx; - text-align: right; - width: 50%; - color: #C4182E; -} - -.g_two2_b text{ - margin-right: 10rpx; -} - -.o1_sj1_bulk text{ - background-color: #fdcb08; text-align: center; - border-radius: 10rpx; - padding:4rpx; - margin-left:6rpx; + font-size: 30rpx; + border-radius: 14rpx; } - - - - -.o1_sj1_bulk { - margin-left:306rpx; +.rob{ + display: flex; + justify-content: flex-end; + font-size: 30rpx; } - -.o1_right_b{ - width: 456rpx; +.money{ + display: flex; + align-items: center; } +.sp .sp_top .s_top_kill.gray{background-color:#bdbdc1;color: #fff;font-weight: normal} -.down-arrow { - display :inline-block; - position: relative; - width: 40rpx; - height: 30rpx; - margin-right: 20rpx; -} +.gorup_count { + position: relative; + font-size: 0; + border: 1px solid #C4182E; + width: 100%; + text-align: left; + background-color: #fff; + border-radius: 32rpx; -.down-arrow::after { - display: inline-block; - content: " "; - height: 18rpx; - width: 18rpx; - border-width: 0 2rpx 2rpx 0; - border-color: #999999; - border-style: solid; - transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0); - transform-origin: center; - transition: transform .3s; - position: absolute; - top: 50%; - right: 10rpx; - margin-top: -10rpx; } +.gorup_count .leftred,.gorup_count .rightwhite { + font-size: 20rpx; + vertical-align: middle; + display: inline-block; - -.pt_center{ - background: #fff; - position: fixed; - padding: 15px; } -.pt_center .pt_zi span{ - color: #333; -} +.gorup_count .leftred { + width: 50%; + background-color: #C4182E; + color: #FFF; + border: 1px solid #C4182E; + text-align: center; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + border-radius: 32rpx; -.pt_c_img image{ - background-color: red; - width: 48rpx; - height: 48rpx; - position: relative; - top: 0rpx; - right: 0rpx; - display: inline-block; } -.pt_c_img{ - display: inline-block; +.gorup_count .rightwhite { + color: #C4182E; + position: absolute; + right: 10rpx; + top: 2rpx; } - -.pt_zi{ - width: 100%; - font-size: 36rpx; -} - -.g_g{ - background-color: #fff; - width: 100%; -} \ No newline at end of file +.jc_sb{ justify-content: space-between;} \ No newline at end of file diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js index 6be2361..ce12ef7 100644 --- a/pages/cart/cart2/cart2.js +++ b/pages/cart/cart2/cart2.js @@ -779,13 +779,12 @@ Page({ } } - + gd.prom_type=gg.prom_type; gd.prom_id=gg.prom_id; - + switch (gd.prom_type) { case 0: - case 2: case 3: case 4: case 5: @@ -984,6 +983,41 @@ Page({ }); break; + + case 2: //--- 团购 --- + var quanlist = null; + getApp().request.get("/api/weshop/goods/groupBuy/getActInfo/" +os.stoid + "/" +gd.goods_id+"/"+ gd.prom_id, { + success: async function (tt) { + if (tt.data.code == 0) { + //t.data.data.shop_price = tt.data.data.prom_price; + t.data.data.shop_price = tt.data.data.price; + } else { + t.data.data.prom_id = 0; + t.data.data.prom_type = 0; + } + + 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 + ""; + + th.setData({ + bn_goods: gd, + bn_pickname: gg.pick_name, + bn_exp_type: et, + index: m_wind, + bn_pick: gg.pick_id, + bn_t_exp_t: distr_t, + bn_exp_type: et + }); + + //-- 计算价格 -- + th.calculatePrice2(); + //获取优惠券,如果有券的钱,就调用 + if(th.data.ckeck_quan_price>0) th.get_buy_now_quan(); + } + }); + + break; } }, }); @@ -2394,6 +2428,7 @@ Page({ //--判断活动的类型-- switch (g_item.prom_type) { case 1: + case 2: goods.prom_type = g_item.prom_type; goods.prom_id = g_item.prom_id; break; @@ -3769,7 +3804,6 @@ Page({ } }, - //取消使用线下取价 cancle_offline: function () { //判断是不是立即购买 diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index 00b80f4..c348bdf 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -840,7 +840,7 @@ 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 == 5 || ee.data.data.prom_type == 7) { + if (ee.data.data.prom_type == 0 || ee.data.data.prom_type == 3 || ee.data.data.prom_type == 5 || ee.data.data.prom_type == 7) { //默认门店要拿下门店库存 if (that.data.sales_rules == 2 && that.data.is_newsales_rules) { //获取门店 @@ -1053,7 +1053,7 @@ Page({ open_ind_store: ind }); //如果是秒杀的话,要看redis够不够 - if (this.data.prom_type == 1) { + if (this.data.prom_type == 1 || this.data.prom_type == 2) { this.getactLen(function (num) { if (num < th.data.goodsInputNum) { getApp().my_warnning("秒杀库存不足!", 0, th); @@ -1268,10 +1268,10 @@ Page({ } //-----如果是秒杀,团购,积分购,拼团----- - if (th.data.prom_type == 1) { + if (th.data.prom_type == 1 || th.data.prom_type == 2) { newd.goods_price = th.data.prom_price; newd.member_goods_price = th.data.prom_price, - newd.prom_type = th.data.prom_type; + newd.prom_type = th.data.prom_type; newd.prom_id = th.data.prom_id; if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); @@ -1342,7 +1342,7 @@ Page({ }) } - 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 == 4 || th.data.prom_type == 5) { newd.prom_type = 0; newd.prom_id = 0; @@ -1399,7 +1399,7 @@ Page({ add_cart_next(e, t, a, o, newd, CanOutQty) { var th = this, i = getApp().request; //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ - if ((o.prom_type != 1 || o.prom_id<=0) && ((o.prom_type != 6 && o.prom_type != 4) || th.data.is_normal)) { + if ((o.prom_type != 1 || o.prom_id<=0) && ((o.prom_type != 6 && o.prom_type != 4 && o.prom_type !=2 ) || th.data.is_normal)) { var conf = th.data.bconfig; if (conf.switch_list && getApp().globalData.userInfo['card_field'] && getApp().globalData.userInfo['card_expiredate']) { var s_list = JSON.parse(conf.switch_list); @@ -2969,13 +2969,108 @@ Page({ var user_id=getApp().globalData.user_id; if(!user_id) user_id=0; - if (prom_type == 3 || prom_type == 0 || prom_type == 2 || prom_type == 5 || prom_type == 7) { + if (prom_type == 3 || prom_type == 0 || prom_type == 5 || prom_type == 7) { this.setData({ prom_type: 0,isshow: 1, }); return false; } + if(prom_type==2){ + //-------判断团购活动是否抢光--------- + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { + 1: 1 + }).then(res => { + var em = res; + if (em.data.code == 0) { + if (em.data.data <= 0) ee.setData({ + prom_r_null: 1 + }); + //拿取价格并且判断时间-- + getApp().request.get("/api/weshop/goods/groupBuy/getActInfo/" +os.stoid + "/" +gid+"/"+ prom_id, { + success: function (t) { + if (t.data.code != 0) { + ee.setData({ + prom_type: 0, + isshow: 1, + }); + ee.get_sku(os.stoid, ee.data.data, gid); + return false; + } + //----已经结束----- + if (t.data.data.is_end == 1) { + ee.setData({ + prom_type: 0, + isshow: 1, + }); + ee.get_sku(os.stoid, ee.data.data, gid); + ee.get_sto(); + return false; + } + //----已经过期----- + var now = ut.gettimestamp(); + if (t.data.data.end_time < now) { + ee.setData({ + prom_type: 0, + isshow: 1, + }); + ee.get_sku(os.stoid, ee.data.data, gid); + return false; + } + + /*-- 还没有开始预热的也不显示 --*/ + if (t.data.data.show_time > now) { + ee.setData({ + prom_type: 0, + isshow: 1, + }); + ee.get_sku(os.stoid, ee.data.data, gid); + ee.get_sto(); + return false; + } + + var t_gd = ee.data.data; + var prom_end_time = ut.formatTime(t.data.data.end_time, "yyyy-MM-dd hh:mm:ss"); + var prom_start_time = ut.formatTime(t.data.data.start_time, "yyyy-MM-dd hh:mm:ss"); + + ee.setData({ + prom_price: t.data.data.price, + prom_type: 2, + prom_id: prom_id, + prom_buy_limit: t.data.data.buy_limit, + prom_act: t.data.data, + prom_end_time: prom_end_time, + prom_start_time: prom_start_time, + isshow: 1, + prom_act:t.data.data + }); + + ee.get_sto(); + var newTime = ut.gettimestamp(); + var endTime2 = t.data.data.end_time; + var endTime1 = t.data.data.start_time; + if (endTime1 > newTime) { + ee.setData({ + prom_time_text: '距团购开始还有' + }) + ee.countDown(endTime1, 0); + } else { + if (endTime2 > newTime) { + ee.setData({ + prom_time_text: '距团购结束还有', + prom_st: 1 + }) + ee.countDown(endTime2); + } + } + + } + }); + } + }) + + + } if (prom_type == 1 && prom_id==0){ this.setData({ prom_type: 0,isshow: 1, @@ -3529,6 +3624,7 @@ Page({ 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", { @@ -4294,7 +4390,11 @@ Page({ //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团 var type = this.data.prom_type; + if (type==2) type=-1; if (type == 6) type = 2; + + + if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; wx.showLoading({ title: '生成中...',}) @@ -4338,15 +4438,7 @@ Page({ // 先画背景 var pg_path = "../../../images/share/share_bg.png"; - // context.fillStyle="#FFFFFF"; - // context.fillRect(0,0,554 * unit, 899 * unit); - - // if(type == 0) { - // this.drawPoster(context); - // return false; - // }; - - + //-- 如果有自定义海报的时候,判断背景的图片 -- if (th.data.share_b_img) { pg_path = th.data.share_b_img; @@ -4354,7 +4446,7 @@ Page({ // context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); - if(type == 0) { // 如果是普通商品,绘制新海报 + if(type == 0 ) { // 如果是普通商品,绘制新海报 th.drawPoster(context, unit, th.data.share_goods_img, vpath); } else { context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit); @@ -4411,7 +4503,7 @@ Page({ var share_title = th.data.data.goods_name; - if (th.data.prom_type == 1 || th.data.prom_type == 6 || th.data.prom_type == 4) { + if (th.data.prom_type == 1 || th.data.prom_type == 2 || th.data.prom_type == 6 || th.data.prom_type == 4) { share_title = th.data.prom_act.share_title; if (!share_title) share_title = th.data.prom_act.title; if (th.data.prom_type == 4) share_title = th.data.prom_act.name; @@ -4531,7 +4623,7 @@ Page({ context.setFillStyle("black") context.setFontSize(22 * unit) - if (type == 0) { + if (type == 0 || type == -1) { // 原来start ---> context.setFontSize(24 * unit) context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit); @@ -4690,6 +4782,37 @@ Page({ context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit); } break + + + case -1: //秒杀商品的展示 + //---画线--- + context.setLineWidth(1 * unit) + context.moveTo(32 * unit, 670 * unit) + context.lineTo(520 * unit, 670 * unit) + context.stroke(); + + + context.setFillStyle("black") + context.setFontSize(24 * unit) + context.fillText(th.data.sto_sele_name_1, 40 * unit, 744 * unit); + //---文字--- + context.setFontSize(22 * unit) + context.setFillStyle("black") + context.fillText("长按识别二维码", 40 * unit, 800 * unit); + context.fillText("立即开始抢购", 40 * unit, 846 * unit); + + + //---二维吗图--- + //-- 自定义海报 -- + if (th.data.poster) { + var erm_x = parseFloat(th.data.poster.ewm_x) * 2; + var erm_y = parseFloat(th.data.poster.ewm_y) * 2; + context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit); + } else { + //---二维吗图--- + context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit); + } + break; } diff --git a/pages/goods/goodsInfo/goodsInfo.wxml b/pages/goods/goodsInfo/goodsInfo.wxml index 7bbc713..e79e5e2 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxml +++ b/pages/goods/goodsInfo/goodsInfo.wxml @@ -46,7 +46,8 @@ - + + @@ -73,6 +74,21 @@ + + + + ¥{{prom_price}} + 零售价¥{{filters.toFix(data.market_price,2)}} + + + + + 结束时间 + + {{djs.day}}天{{djs.hou}}小时{{djs.min}}分{{djs.sec}}秒 + + + @@ -247,8 +263,10 @@ + + @@ -261,7 +279,9 @@ 零售价:¥{{filters.toFix(data.market_price,2)}} - + + + {{filters.toFix(data.shop_price,2)}} @@ -271,17 +291,15 @@ - - - + @@ -295,7 +313,7 @@ - + - + - + {{data.goods_name}} - + + + 销量:{{data.sales_sum}}件 折扣:{{data.disc}}折 {{categories3[0].num}}人评价 + @@ -379,13 +400,24 @@ --> - + + + {{sele_g.goods_name}} - + + + {{sele_g.goods_name}} + + + + - + 总数量:{{prom_act.goods_num+prom_act.virtual}}件 限购:{{prom_act.buy_limit}}件 @@ -406,6 +438,29 @@ + + + + + 总数量:{{prom_act.goods_num+prom_act.virtualNum}}件 + 限购:{{prom_act.buy_limit}}件 + 限购:不限 + + + 已购:0件 + + + 已购:{{prom_act.buy_num+prom_act.virtualNum}}件 + + + + 总数量:{{prom_act.goods_num}}件 + 限购:{{prom_act.buy_limit}}件 + 限购:不限 + 已购:{{prom_act.buy_num}}件 + + + @@ -446,7 +501,7 @@ - + 领券 @@ -1059,15 +1114,13 @@ {{sele_g[card_field]}} {{sele_g.shop_price}} - - - {{prom_price}} - + {{prom_price}} 券后¥ {{sele_g.offline_price}} + diff --git a/pages/index/index/index.wxml b/pages/index/index/index.wxml index b78889d..e19dbb0 100644 --- a/pages/index/index/index.wxml +++ b/pages/index/index/index.wxml @@ -83,6 +83,15 @@ + + + + + + 团购 + + + @@ -485,10 +494,14 @@ - - - - + + + + + + + + diff --git a/pages/template/index.wxml b/pages/template/index.wxml index 82f373f..405353f 100644 --- a/pages/template/index.wxml +++ b/pages/template/index.wxml @@ -66,8 +66,10 @@ - - + + + + diff --git a/pages/user/order_detail/order_detail.js b/pages/user/order_detail/order_detail.js index 277b338..b96bf5c 100644 --- a/pages/user/order_detail/order_detail.js +++ b/pages/user/order_detail/order_detail.js @@ -336,15 +336,7 @@ Page({ }); return false; } - //如果不是小程序有的功能,直接提示要去3.0处理 - if(good.prom_type==2 ){ - wx.showModal({ - title: '提示', - content: '小程序还未有该活动,请到3.0公众号支付' - }); - return false; - } - + //要每件每件的商品进行检查,看有么有超出库存,超出限购 var good= order_goods[i],goodsbuynum=0,promgoodsbuynum=0,gg=null; //获取单品的现在的活动状态 @@ -474,7 +466,7 @@ Page({ } //商品的普通购买 ,不要进行判断 - if((good.prom_type==1 || good.prom_type==6 || good.prom_type==4) && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal){ + if((good.prom_type==1 || good.prom_type==2 || good.prom_type==6 || good.prom_type==4) && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal){ if(gg.prom_type!=good.prom_type && gg.prom_type>0) { var content=gg.goods_name+'商品的活动发生了变化,请取消订单重新购买'; th.toast(content); @@ -495,6 +487,17 @@ Page({ } }) } + + if (gg.prom_type == 2) { + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/"+ gg.goods_id + "/" + gg.prom_id, {}).then(res => { + if (res.data.code == 0) { + prom = res.data.data; + prom.price=prom.price; + } + }) + } + + if(gg.prom_type==6){ await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+gg.prom_id,{ }).then(res=>{ @@ -603,7 +606,18 @@ Page({ prom.price=prom.user_price; } }) - } + } + + if (goodsinfo.prom_type == 2) { + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/"+ good.goods_id + "/" + goodsinfo.prom_id, {}).then(res => { + if (res.data.code == 0) { + prom = res.data.data; + prom.price=prom.price; + } + }) + } + + if(goodsinfo.prom_type==6 && !good.is_pd_normal){ await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+goodsinfo.prom_id,{ }).then(res=>{ @@ -646,6 +660,13 @@ Page({ th.toast(content); return false; } + + //看一下会员的团购价格是不是发生了变化 + if(goodsinfo.prom_type==2 && goodsinfo.goods_price!=prom.price){ + var content=goodsinfo.goods_name+'秒杀活动的价格发生了变化'; + th.toast(content); + return false; + } if(goodsinfo.prom_type==4){ if (good.goods_num > prom.limitqty-prom.buy_num) { @@ -654,23 +675,14 @@ Page({ th.toast(content); return false; } - }else{ - var redis_num = 0; - //------判断活动是否抢光----- - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + - os.stoid + "/" + goodsinfo.prom_type + "/" + goodsinfo.prom_id, { - }).then(res => { - redis_num = res.data.data; - }); - - if (good.goods_num > redis_num) { - - var content=gg.goods_name+'超出商品活动库存,请取消订单'; - th.toast(content); - return false; - } - } - + }else if(goodsinfo.prom_type == 1 || goodsinfo.prom_type == 2 || goodsinfo.prom_type == 6 ) { + if(order.add_time+5*60 { + if (res.data.code == 0) { + group = res.data.data; + } + }) + //----已经结束----- + if (group && group.is_end == 0 && group.end_time > timestamp && group.start_time < timestamp) { + prom = group; + prom.price = prom.price; + b_item.price = prom.price; + } + break; case 6: b_item.is_pd_normal = 1; break; diff --git a/pages/user/order_list/order_list.js b/pages/user/order_list/order_list.js index 19ec610..4b8c5c1 100644 --- a/pages/user/order_list/order_list.js +++ b/pages/user/order_list/order_list.js @@ -481,14 +481,7 @@ Page({ }); return false; } - //如果不是小程序有的功能,直接提示要去3.0处理 - if (good.prom_type == 2) { - wx.showModal({ - title: '提示', - content: '小程序还未有该活动,请到3.0公众号支付' - }); - return false; - } + //要每件每件的商品进行检查,看有么有超出库存,超出限购 var good = order_goods[i], goodsbuynum = 0, promgoodsbuynum = 0, gg = null,presellList=null; @@ -660,7 +653,7 @@ Page({ } //商品的普通购买 ,不要进行判断 - if ((good.prom_type == 1 || good.prom_type == 6 || good.prom_type == 4 || good.prom_type == 8) + if ((good.prom_type == 1 || good.prom_type == 2 || good.prom_type == 6 || good.prom_type == 4 || good.prom_type == 8) && !good.is_gift && !good.is_collocation && !good.is_integral_normal && !good.is_pd_normal) { if (gg.prom_type != good.prom_type && gg.prom_type>0) { var content = gg.goods_name + '商品的活动发生了变化,请取消订单重新购买'; @@ -669,7 +662,7 @@ Page({ } } else { - if ((gg.prom_type == 1 || gg.prom_type == 3 || gg.prom_type == 5 || gg.prom_type == 6 || gg.prom_type == 4) + if ((gg.prom_type == 1 || good.prom_type == 2 || gg.prom_type == 3 || gg.prom_type == 5 || gg.prom_type == 6 || gg.prom_type == 4) && !good.is_collocation && !good.is_gift && !good.is_integral_normal && !good.is_pd_normal) { var prom = null; //---如果是活动的时候--- @@ -682,6 +675,17 @@ Page({ } }) } + + if (gg.prom_type == 2) { + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/"+ gg.goods_id + "/" + gg.prom_id, {}).then(res => { + if (res.data.code == 0) { + prom = res.data.data; + prom.price=prom.price; + } + }) + } + + if (gg.prom_type == 6) { await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + gg.prom_id, {}).then(res => { if (res.data.code == 0) { @@ -786,6 +790,17 @@ Page({ } }) } + + if (goodsinfo.prom_type == 2) { + await getApp().request.promiseGet("/api/weshop/goods/groupBuy/getActInfo/" + os.stoid + "/"+ good.goods_id + "/" + goodsinfo.prom_id, {}).then(res => { + if (res.data.code == 0) { + prom = res.data.data; + prom.price=prom.price; + } + }) + } + + if (goodsinfo.prom_type == 6 && !good.is_pd_normal) { await getApp().request.promiseGet("/api/weshop/teamlist/get/" + os.stoid + "/" + goodsinfo.prom_id, {}).then(res => { if (res.data.code == 0) { @@ -827,6 +842,13 @@ Page({ th.toast(content); return false; } + + // --看一下会员的团购价格是不是发生了变化 + if(goodsinfo.prom_type==2 && goodsinfo.goods_price!=prom.price){ + var content=goodsinfo.goods_name+'秒杀活动的价格发生了变化'; + th.toast(content); + return false; + } if (goodsinfo.prom_type == 4) { if (good.goods_num > prom.limitqty - prom.buy_num) { @@ -835,20 +857,12 @@ Page({ th.toast(content); return false; } - } else { - var redis_num = 0; - //------判断活动是否抢光----- - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + - os.stoid + "/" + goodsinfo.prom_type + "/" + goodsinfo.prom_id, {}).then(res => { - redis_num = res.data.data; - }); - - if (good.goods_num > redis_num) { - - var content = gg.goods_name + '超出商品活动库存,请取消订单'; + } else if(goodsinfo.prom_type == 1 || goodsinfo.prom_type == 2 || goodsinfo.prom_type == 6 ) { + if(order.add_time+5*60 { + if (res.data.code == 0) { + group = res.data.data; + } + }) + //----已经结束----- + if (group && group.is_end == 0 && group.end_time > timestamp && group.start_time < timestamp) { + prom = group; + prom.price = prom.price; + b_item.price = prom.price; + } + break; + case 6: b_item.is_pd_normal = 1; break; -- libgit2 0.21.4