diff --git a/app.js b/app.js index def8269..32f6e1b 100644 --- a/app.js +++ b/app.js @@ -129,7 +129,7 @@ App({ cartGoodsNum:this.globalData.cartGoodsNum }) }, - + globalData: { cartGoodsNum:0, //购物车总数量 isTabBar :false, @@ -186,7 +186,6 @@ App({ app.globalData.user_id= app.globalData.userInfo.user_id; } } - wx.getSystemInfo({ success: (res) => { // console.log(res) @@ -594,6 +593,8 @@ App({ this.globalData.wuliu=null; //关闭要把物流清空 this.globalData.room_id=null; //关闭要把房间号关闭 this.globalData.room_goods_id=null; //关闭要把物流清空 + this.globalData.config2=null; //清除config2的缓存 + this.globalData.config=null; //清除config的缓存 } diff --git a/app.json b/app.json index 06d4421..87bf49e 100644 --- a/app.json +++ b/app.json @@ -87,12 +87,6 @@ "pages/template/index", "pages/store/index" ], - "plugins": { - "live-player-plugin": { - "version": "1.1.1", - "provider": "wx2b03c6e691cd7370" - } - }, "subPackages": [{ "root": "packageA/", "name":"pack1", diff --git a/packageA/pages/liveStream/liveStream.js b/packageA/pages/liveStream/liveStream.js index 471f96b..4b167e1 100644 --- a/packageA/pages/liveStream/liveStream.js +++ b/packageA/pages/liveStream/liveStream.js @@ -1,5 +1,4 @@ // pages/liveStream/liveStream.js - var t = require("../../../utils/util"), ut = t, e = require("../../../utils/common.js"), @@ -10,20 +9,26 @@ var t = require("../../../utils/util"), 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: { - goodsList: [], - imghost: '', - liveList: {} + curPage: 1, + pageNum: 1, + liveing: [], + livetoBegin: [], + liveOver: [] }, - + // list: [], + // live: { + // ing:[], + // toBegin:[], + // over:[] + // }, + // 点击直播列表项 clickItem: function (e) { // id:列表项id @@ -32,66 +37,191 @@ Page({ url: '/packageA/pages/liveStreamDetails/liveStreamDetails?id=' + e.currentTarget.dataset.id + '&live=' + e.currentTarget.dataset.live }) console.log('options-->'); - }, + }, // 点击 订阅/观看直播/观看回放 按钮,跳转直播组件 clickLive: function (e) { - console.log('当前房间号roomid:',e.currentTarget.dataset.roomid); + console.log('当前房间号roomid:', e.currentTarget.dataset.roomid); let roomId = e.currentTarget.dataset.roomid; - let customParams = encodeURIComponent(JSON.stringify({ path: 'pages/index/index', pid: 1 })); + let customParams = encodeURIComponent(JSON.stringify({ + path: 'pages/index/index', + pid: 1 + })); wx.navigateTo({ url: `plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${roomId}&custom_params=${customParams}` }) }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - var live = {}; - live.toBegin = []; // 即将开始 - live.ing = []; // 直播中 - live.over = []; // 已结束 + updateLiveList: function () { + return new Promise((resolve, reject) => { + let self = this; + getApp().request.put("/api/weshop/wx/livelist/updatelivelist", { + data: { + storeId: 1 + }, + success: function (res) { + console.log('我发起了PUT请求,请求结果:', res.data); + resolve(); + } + }); + }); + }, - // 请求数据 + loadLiveList: function (curPage) { + // console.log('---->curPage', curPage); + // var live = {}; + // live.toBegin = []; // 即将开始 + // live.ing = []; // 直播中 + // var liveOver = []; // 已结束 var that = this; - getApp().request.promiseGet("/api/weshop/wx/livelist/page", {}).then(res=>{ - console.log('ressss--->',res); - if(res.data.code==0){ - that.setData({ - goodsList: res.data.data.pageData - }) - } - // console.log(goodsList); - - var result = res.data.data.pageData; - var liveStatus; - if(res.data.code == 0) { - for(var i in result) { - console.log(i + '当前直播状态:', result[i].live_status); - liveStatus = result[i].live_status; - // 这里只显示101/102/103状态 - if (liveStatus == '101') { - live.ing.push(result[i]); - } else if (liveStatus == '102') { - live.toBegin.push(result[i]); - } else if (liveStatus == '103') { - live.over.push(result[i]); - } - } - // console.log('live--->', live); + var storeId = o.stoid; + + // 请求数据 + getApp().request.promiseGet("/api/weshop/wx/livelist/page", { + data: { + storedId: o.stoid, + page: curPage, + live_status: 103 + } + }).then(res => { + if (res.data.code == 0) { + console.log('res------------>', res); + // 计算总页数 + // var total = res.data.data.total; + // console.log("total", total); + // var pageSize = res.data.data.pageSize; + // console.log("pageSize", pageSize); + // var pageNum = that.pageTotal(total, pageSize); + // that.setData({ + // pageNum: that.pageTotal(total, pageSize) + // }); + + // 如果当前请求的是第一页数据,则执行赋值,否则执行合并再赋值 + if (curPage == 1) { + that.setData({ + liveOver: that.data.liveOver.concat(res.data.data.pageData) + }) + } else { + that.setData({ + liveOver: that.data.liveOver.concat(res.data.data.pageData) + }) + }; + + // var list = that.data.list; + // for(var i in list) { + // var liveStatus = list[i].live_status; + // if (liveStatus == '101') { + // live.ing.push(list[i]); + // } else if (liveStatus == '102') { + // live.toBegin.push(list[i]); + // } else if (liveStatus == '103') { + // live.over.push(list[i]); + // } + // } + + // that.setData({ + // liveOver: list + // }); + + curPage++; that.setData({ - live + curPage }); + + console.log('上拉已经触发,当前page------------------------->',that.data.curPage); + + } else { + console.error('请求失败!!!!!'); } }) }, + pageTotal: function (rowCount, pageSize) { + if (rowCount == null || rowCount == "") { + return 0; + } else { + if (pageSize != 0 && rowCount % pageSize == 0) { + return parseInt(rowCount / pageSize) + }; + if (pageSize != 0 && rowCount % pageSize != 0) { + return parseInt(rowCount / pageSize) + 1; + }; + } + }, + + getData: function (liveStatus) { + var that = this; + var curPage = this.data.curPage + getApp().request.promiseGet("/api/weshop/wx/livelist/page", { + data: { + storedId: o.stoid, + page: curPage, + live_status: liveStatus + } + }).then(res => { + if (res.data.code == 0) { + if (liveStatus == 101) { + that.setData({ + liveing: res.data.data.pageData + }); + } else if (liveStatus == 102) { + that.setData({ + livetoBegin: res.data.data.pageData + }); + } else if (liveStatus == 103) { + that.setData({ + liveOver: res.data.data.pageData + }); + + var total = res.data.data.total; + console.log("total", total); + var pageSize = res.data.data.pageSize; + console.log("pageSize", pageSize); + var pageNum = that.pageTotal(total, pageSize); + console.log("pageNum", pageNum); + that.setData({ + pageNum + }); + + } + } + + curPage++; + that.setData({ + curPage + }); + + }); + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + console.log('ppppp',this.pageTotal(4, 10)); + // var self = this; + // this.updateLiveList().then(() => { + // self.getData(101); + // self.getData(102); + // self.getData(103); + // }); + }, + /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { + // var self = this; + // this.updateLiveList().then(() => { + // self.loadLiveList(1); + // }); + var self = this; + this.updateLiveList().then(() => { + self.getData(101); + self.getData(102); + self.getData(103); + }); }, /** @@ -119,20 +249,64 @@ Page({ * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { - + // var self = this; + // wx.showNavigationBarLoading(); //在标题栏中显示加载 + // setTimeout(function() { + // self.loadLiveList(1); + // wx.hideNavigationBarLoading(); //完成停止加载 + // wx.stopPullDownRefresh(); //停止下拉刷新 + // }, 500); }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { + var self = this; + var curPage = this.data.curPage; + console.log('now curPage',curPage); + var pageNum = this.data.pageNum; + console.log('now pageNum',pageNum); + if (curPage <= pageNum) { + wx.showLoading({ + title: '加载中...', + }) + setTimeout(function () { + self.loadLiveList(curPage); + wx.hideLoading(); + }, 500); + } else { + wx.showToast({ + title: '已经到底啦~', + duration: 1000 + }) + } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { + if (res.from === 'button') { + // 来自页面内转发按钮 + console.log(res.target) + } + return { + title: '直播列表' + // path: '/page/user?id=123' + } + }, + + onShareTimeline: function (res) { + if (res.from === 'button') { + // 来自页面内转发按钮 + console.log(res.target) + } + return { + title: '直播列表' + // path: '/page/user?id=123' + } + }, - } }) \ No newline at end of file diff --git a/packageA/pages/liveStream/liveStream.json b/packageA/pages/liveStream/liveStream.json index e54bca5..4c7ef05 100644 --- a/packageA/pages/liveStream/liveStream.json +++ b/packageA/pages/liveStream/liveStream.json @@ -2,5 +2,8 @@ "usingComponents": { "subscribe": "plugin-private://wx2b03c6e691cd7370/components/subscribe/subscribe" }, - "navigationBarTitleText": "直播" -} \ No newline at end of file + "navigationBarTitleText": "直播", + "onReachBottomDistance": 300 +} + + \ No newline at end of file diff --git a/packageA/pages/liveStream/liveStream.wxml b/packageA/pages/liveStream/liveStream.wxml index ee02d20..76d269b 100644 --- a/packageA/pages/liveStream/liveStream.wxml +++ b/packageA/pages/liveStream/liveStream.wxml @@ -3,41 +3,44 @@ 当前暂无直播 - + 即将开始 - + - - + - {{item.name}} + + {{item.name}} + {{filter.format_time(item.start_time, 2)}} 开始 + 主播:{{item['anchor_name']}} + - - + - + 直播中 - + - + - {{item.name}} + + {{item.name}} + {{filter.format_time(item.start_time, 2)}} 开始 + 主播:{{item['anchor_name']}} + 观看直播 @@ -47,16 +50,20 @@ - + 精彩回放 - + - + - {{item.name}} + + {{item.name}} + {{filter.format_time(item.end_time, 2)}} 结束 + 主播:{{item['anchor_name']}} + 观看回放 diff --git a/packageA/pages/liveStream/liveStream.wxss b/packageA/pages/liveStream/liveStream.wxss index af00582..42777db 100644 --- a/packageA/pages/liveStream/liveStream.wxss +++ b/packageA/pages/liveStream/liveStream.wxss @@ -9,8 +9,8 @@ } .list-item-left { position: relative; - width: 300rpx; - height: 300rpx; + width: 340rpx; + height: 220rpx; flex-shrink: 0; } .list-item-right { @@ -55,9 +55,18 @@ display: -webkit-box; -webkit-box-orient: vertical; - -webkit-line-clamp: 4; + -webkit-line-clamp: 2; overflow: hidden; } +.item-time { + color: #999; + font-size: 22rpx; + padding-top: 10rpx; +} +.item-anchor { + color: #999; + font-size: 22rpx; +} .item-btn { width: 172rpx; diff --git a/packageA/pages/liveStreamDetails/liveStreamDetails.js b/packageA/pages/liveStreamDetails/liveStreamDetails.js index cfc2011..ffa1f30 100644 --- a/packageA/pages/liveStreamDetails/liveStreamDetails.js +++ b/packageA/pages/liveStreamDetails/liveStreamDetails.js @@ -29,7 +29,11 @@ Page({ nickName: '', avatarUrl: '', coverImg: '', - canvasToImgPath: '' + canvasToImgPath: '', + screenWidth: 0, + canvasHidden: 1, + gid: '', + shareImgPath: '' }, // 点击商品 @@ -59,21 +63,31 @@ Page({ this.setData({ showActionSheet: 'false' }) + if(!this.data.showPlaybill) { + this.setData({ + showPlaybill: 'true' + }); + } + }, + + closeWin: function () { + this.setData({ + showPlaybill: 'true' + }); }, //生成海报 createPlaybill: function () { // 1.提示 “正在生成海报...” - wx.showLoading({ - title: '正在生成海报...' - }); + // 2.生成海报,如果生成完毕,关闭提示 this.drawPlaybill(); // 3.展示生成的海报 this.setData({ - showPlaybill: !this.data.showPlaybill, - showActionSheet: 'false' + showActionSheet: 'false', + showPlaybill: !this.data.showPlaybill }); + }, // 获取设备信息 @@ -84,150 +98,153 @@ Page({ that.setData({ windowWidth: res.windowWidth, windowHeight: res.windowHeight, + screenWidth: res.screenWidth, dpr: res.pixelRatio }) } }); + console.log('宽度',this.data.windowWidth); + console.log('高度',this.data.windowHeight); }, - //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 - drawText: function(ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) { - var lineWidth = 0; - var lastSubStrIndex = 0; //每次开始截取的字符串的索引 - var han = 0; - for (let i = 0; i < str.length; i++) { - if (han == 2) return; - //lineWidth += ctx.measureText(str[i]).width; - lineWidth += ut.measureText(str[i], 21.3 * unit); - if (lineWidth > canvasWidth) { - han++; - - if (han == 2) { - ctx.textAlign = 'justify'; - ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 - } else { - ctx.textAlign = 'justify'; - ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); - } - initHeight += 22; //22为字体的高度 - lineWidth = 0; - lastSubStrIndex = i; - titleHeight += 20; - } - if (i == str.length - 1) { //绘制剩余部分 - ctx.textAlign = 'justify'; - ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); - } +//文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 +drawText: function(ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) { + var lineWidth = 0; + var lastSubStrIndex = 0; //每次开始截取的字符串的索引 + var han = 0; + for (let i = 0; i < str.length; i++) { + if (han == 2) return; + //lineWidth += ctx.measureText(str[i]).width; + lineWidth += ut.measureText(str[i], 21.3 * unit); + if (lineWidth > canvasWidth) { + han++; + + if (han == 2) { + ctx.textAlign = 'justify'; + ctx.fillText(str.substring(lastSubStrIndex, i) + '...', leftWidth, initHeight); //绘制截取部分 + } else { + ctx.textAlign = 'justify'; + ctx.fillText(str.substring(lastSubStrIndex, i), leftWidth, initHeight); } - }, + initHeight += 35; //22为字体的高度 + lineWidth = 0; + lastSubStrIndex = i; + titleHeight += 20; + } + if (i == str.length - 1) { //绘制剩余部分 + ctx.textAlign = 'justify'; + ctx.fillText(str.substring(lastSubStrIndex, i + 1), leftWidth, initHeight); + } + } +}, // 生成海报 drawPlaybill: function () { - var that = this + wx.showLoading({ + title: '正在生成海报...' + }); + + // 数据准备 + const title = this.data.details.name; + // const headImg = app.globalData.userInfo['head_pic']; + const that = this; + + // console.log('----------------v', headImg); + + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + + os.stoid + "?sceneValue=1012" + "&pageValue=packageA/pages/liveStreamDetails/liveStreamDetails"; + + // 以iPhone6为例,375/750 = 0.5 + // let scale = this.data.windowWidth / 375; + let scale = this.data.screenWidth / 750 * 1.35 + + // 适配屏get幕 - let scale = this.data.windowWidth / 375.0 - - this.setData({ totalHeight: 667*scale}) + // let scale = this.data.windowWidth / 375.0; + // this.setData({totalHeight: 667 * scale}); + // 获取Canvas - let ctx = wx.createCanvasContext('myCanvas') + let ctx = wx.createCanvasContext('myCanvas'); // 放大 因为不放大的话,生成的分享图会模糊。暂时先注释 - ctx.scale(this.data.canvasScale, this.data.canvasScale) + // ctx.scale(this.data.canvasScale, this.data.canvasScale) + - // var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + - // os.stoid; - var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + - os.stoid + "?sceneValue=1012" + "&pageValue=pages/goods/goodsInfo/goodsInfo"; - + "?sceneValue=1012" + "&pageValue=packageA/pages/liveStreamDetails/liveStreamDetails" + // var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + + // os.stoid + "?sceneValue=1012" + "&pageValue=pages/goods/goodsInfo/goodsInfo"; + // + "?sceneValue=1012" + "&pageValue=packageA/pages/liveStreamDetails/liveStreamDetails" // console.log('path3---->', path3); // 绘制主背景白色 - ctx.setFillStyle('#ffffff') - ctx.fillRect(0, 0, this.data.windowWidth, this.data.totalHeight) - ctx.draw(true); - - - const coverImag = this.data.details['cover_img']; - const title = this.data.details.name; - console.log('detail--->', this.data.details); - - - //绘制头像 - wx.getImageInfo({ - src: that.data.avatarUrl, - success: function(res) { - ctx.save(); - ctx.beginPath(); - ctx.arc(29*scale, 27*scale, 14*scale, 0, 2*Math.PI); - ctx.clip(); - ctx.drawImage(res.path, 15*scale, 13*scale, 28*scale, 28*scale); - ctx.restore() - ctx.draw(true); - } - }) + ctx.setFillStyle('#ffffff'); + ctx.fillRect(0, 0, 480, 738); + + // 绘制头像 + ctx.save(); + ctx.beginPath(); + ctx.arc(58, 52, 28, 0, 2*Math.PI); + ctx.clip(); + // console.log('1__________________>',app.globalData.userInfo['head_pic']); + ctx.drawImage(this.data.avatarUrl, 30, 24, 56, 56); + ctx.restore(); // 绘制昵称 - ctx.setFontSize(12*scale); + ctx.setFontSize(22); ctx.setFillStyle('#ADADAD'); - ctx.fillText(this.data.nickName, 54*scale, 32*scale); + ctx.fillText(this.data.nickName, 106, 60); - //绘制主图 - wx.getImageInfo({ - src: coverImag, - success: function(res) { - ctx.drawImage(res.path, 0, 52*scale, 240*scale, 191*scale); - ctx.draw(true); - } - }) + // 绘制主图 + ctx.drawImage(this.data.coverImg, 0, 104, 480, 382); + // ctx.draw(true); - //绘制文字 - ctx.setFontSize(14*scale); + // 绘制文字 + ctx.setFontSize(24); ctx.setFillStyle('#1E1E1E'); - // ctx.fillText(title, 10*scale, 281*scale, 97*scale); - this.drawText(ctx, title, 10*scale, 281*scale, 130*scale, 130*scale, scale); - // ctx.draw(true); + this.drawText(ctx, title, 51, 563, 300, 360, 2); - //绘制小程序码 - wx.getImageInfo({ - src: path3, - success: function(res) { - ctx.drawImage(res.path, 152*scale, 262*scale, 66*scale, 66*scale); - ctx.draw(true); - } - }) + // 绘制小程序码 + ctx.drawImage(this.data.ewm, 310, 525, 132, 132); + // ctx.draw(true); - //绘制文字:常按识别 - ctx.setFontSize(14*scale); + //绘制文字:长按识别 + ctx.setFontSize(20); ctx.setFillStyle('#1E1E1E'); - ctx.fillText('长按识别小程序', 135*scale, 350*scale); + ctx.fillText('长按识别小程序', 309, 675); - - //把画板内容绘制成图片,并回调 画板图片路径 ctx.draw(true, function() { setTimeout(function() { + console.log("我进来了~~~~~"); wx.canvasToTempFilePath({ x: 0, y: 0, - destWidth: that.data.windowWidth*2, - destHeight: that.data.windowHeight*2, - fileType: 'jpg', - quality: 1, + width: 750, + height: 1217, + destWidth: 750, + destHeight: 1217, canvasId: 'myCanvas', + fileType: 'jpg', success: function(res) { wx.hideLoading(); that.setData({ - canvasToImgPath: res.tempFilePath, + canvasToImgPath: res.tempFilePath }); - console.log(res.tempFilePath); + // that.saveImageToPhotosAlbum(res.tempFilePath); + console.log('截图陈宫:', that.data.canvasToImgPath); + // wx.previewImage({ + // //将图片预览出来 + // urls: [that.data.canvasToImgPath] + // }); } }) - }, 3000) + }, 1000) }); - }, - + + + }, + //点击观看直播 clickBtn: function () { @@ -240,17 +257,18 @@ Page({ // 保存图片到手机 onSaveToPhone() { + var self = this; // 获取用户的当前设置,返回值中有小程序已经向用户请求过的权限 this.getSetting().then((res) => { // 判断用户是否授权了保存到相册的权限,如果没有发起授权 if (!res.authSetting['scope.writePhotosAlbum']) { this.authorize().then(() => { // 同意授权后保存下载文件 - this.savedownloadFile(this.data.canvasToImgPath) + this.saveImageToPhotosAlbum(self.data.canvasToImgPath) }) } else { // 如果已经授权,保存下载文件 - this.savedownloadFile(this.data.canvasToImgPath) + this.saveImageToPhotosAlbum(self.data.canvasToImgPath) } }) }, @@ -259,7 +277,7 @@ Page({ onOpenSetting() { wx.openSetting({ success:(res) => { - console.log(res.authSetting) + // console.log(res.authSetting) } }) }, @@ -269,7 +287,6 @@ Page({ return new Promise((resolve, reject) => { wx.getSetting({ success: res => { - console.log('getting---->', res); resolve(res) } }) @@ -286,7 +303,7 @@ Page({ scope: 'scope.writePhotosAlbum', // 同意授权 success: () => { - resolve() + resolve(); }, // 拒绝授权,这里是用户拒绝授权后的回调 fail: res => { @@ -298,10 +315,10 @@ Page({ duration: 1000 }) } else { - this.showModal() + this.showModal(); } console.log('拒绝授权'); - reject() + reject(); } }) }) @@ -311,12 +328,14 @@ Page({ savedownloadFile(img) { this.downLoadFile(img).then((res) => { return this.saveImageToPhotosAlbum(res.tempFilePath) - }).then(() => { + }).then(() => { + // resolve() }) }, //单文件下载(下载文件资源到本地),客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径。 downLoadFile(img) { + var self = this; return new Promise((resolve, reject) => { wx.showLoading({ title: '保存中...', @@ -325,8 +344,7 @@ Page({ wx.downloadFile({ url: img, success: (res) => { - console.log('downloadfile', res) - resolve(res) + resolve(res); } }) }) @@ -346,7 +364,13 @@ Page({ self.setData({ showPlaybill: 'true' }); - resolve() + resolve(); + }, + fail: () => { + wx.showToast({ + title: '保存失败', + duration: 1000, + }); } }) }) @@ -384,6 +408,34 @@ Page({ that.setData({ details: obj }) + + + // 请求主图 + that.getImageInfo(that.data.details['share_img']).then(res => { + that.setData({ + coverImg: res.path + }); + console.log('主图加载成功~') + }); + + // 请求头像 + that.getImageInfo(app.globalData.userInfo['head_pic']).then(res => { + that.setData({ + avatarUrl: res.path + }); + console.log('头像加载成功~') + }); + + // 请求二维码 + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + + os.stoid + "?sceneValue=1012" + "&pageValue=pages/goods/goodsInfo/goodsInfo"; + that.getImageInfo(path3).then(res => { + that.setData({ + ewm: res.path + }); + console.log('二维码加载成功~') + }); + } }) @@ -409,22 +461,21 @@ Page({ } this.setData({ - nickName: app.globalData.userInfo.nickname, - avatarUrl: app.globalData.userInfo.head_pic + nickName: app.globalData.userInfo.nickname }) - var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + - os.stoid + "?sceneValue=1012" + "&pageValue=pages/goods/goodsInfo/goodsInfo"; - wx.getImageInfo({ - src: path3, - success: function(res) { + // var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + + // os.stoid + "?sceneValue=1012" + "&pageValue=pages/goods/goodsInfo/goodsInfo"; + // wx.getImageInfo({ + // src: path3, + // success: function(res) { // ctx.drawImage(res.path, 152*scale, 262*scale, 66*scale, 66*scale); // ctx.draw(true); - that.setData({ - ewm: res.path - }) - } - }) + // that.setData({ + // ewm: res.path + // }) + // } + // }) }, // 获取图片信息 @@ -489,6 +540,10 @@ Page({ showActionSheet: 'false' }) var self = this; + if (res.from === 'button') { + // 来自页面内转发按钮 + console.log(res.target) + } return { title: this.data.details.name, success: function(res) { @@ -498,5 +553,17 @@ Page({ console.log('comple', res) } } + }, + + onShareTimeline: function (res) { + if (res.from === 'button') { + // 来自页面内转发按钮 + console.log(res.target) + } + return { + title: this.data.details.name + // path: '/page/user?id=123' + } } + }) diff --git a/packageA/pages/liveStreamDetails/liveStreamDetails.skeleton.wxml b/packageA/pages/liveStreamDetails/liveStreamDetails.skeleton.wxml deleted file mode 100644 index 71c485e..0000000 --- a/packageA/pages/liveStreamDetails/liveStreamDetails.skeleton.wxml +++ /dev/null @@ -1,10 +0,0 @@ - - \ No newline at end of file diff --git a/packageA/pages/liveStreamDetails/liveStreamDetails.skeleton.wxss b/packageA/pages/liveStreamDetails/liveStreamDetails.skeleton.wxss deleted file mode 100644 index 2b915c5..0000000 --- a/packageA/pages/liveStreamDetails/liveStreamDetails.skeleton.wxss +++ /dev/null @@ -1,17 +0,0 @@ -/* -此文件为开发者工具生成,生成时间: 2020/7/4 下午3:58:01 -使用方法:参考 "packageA\pages\liveStreamDetails\liveStreamDetails.skeleton.wxml" -*/ -.sk-transparent { - color: transparent !important; - } -.sk-container { - position: absolute; - overflow: hidden; - top: 0; - left: 0; - right: 0; - bottom: 0; - z-index: 1000000; - background-color: transparent; - } diff --git a/packageA/pages/liveStreamDetails/liveStreamDetails.wxml b/packageA/pages/liveStreamDetails/liveStreamDetails.wxml index 59a390f..5239f74 100644 --- a/packageA/pages/liveStreamDetails/liveStreamDetails.wxml +++ b/packageA/pages/liveStreamDetails/liveStreamDetails.wxml @@ -5,22 +5,22 @@ - + {{details.name}} + + {{filter.format_time(details.start_time, 2)}} 锁定直播 + + {{myUtils.liveStatus(details.live_status)}} - @@ -29,13 +29,13 @@ - + {{item.name}} - {{item.price}} + {{filter.toFix(item.price, 2)}} @@ -74,15 +74,19 @@ + + - + + + + diff --git a/packageA/pages/liveStreamDetails/liveStreamDetails.wxss b/packageA/pages/liveStreamDetails/liveStreamDetails.wxss index 55f26ca..f413e0f 100644 --- a/packageA/pages/liveStreamDetails/liveStreamDetails.wxss +++ b/packageA/pages/liveStreamDetails/liveStreamDetails.wxss @@ -6,9 +6,10 @@ .content { background-color: white; padding-bottom: 168rpx; + position: relative; } .cover-container { - height: 646rpx; + /* height: 646rpx; */ position: relative; } .cover-img { @@ -53,11 +54,13 @@ line-height: 50rpx; padding: 0 30rpx; background-color: #eee; - margin-top: 22rpx; - margin-bottom: 44rpx; + /* margin-top: 22rpx; + margin-bottom: 44rpx; */ } .desc-content { font-size: 29rpx; + padding-top: 22rpx; + padding-bottom: 22rpx; } .list { padding: 0 36rpx; @@ -103,8 +106,8 @@ } .share-container image { display: block; - width: 60rpx; - height: 60rpx; + width: 50rpx; + height: 50rpx; padding-top: 14rpx; padding-bottom: 11rpx; } @@ -220,12 +223,11 @@ } .playbill-pic { display: block; - width: 478rpx; - height: 737rpx; - border-width: 31rpx 20rpx 51rpx; - border-color: #f23030; - border-style: solid; + width: 560rpx; + height: auto; margin: 0 auto 26rpx; + border-radius: 10rpx; + overflow: hidden; } .playbill-save { diff --git a/pages/cart/cart/cart.wxml b/pages/cart/cart/cart.wxml index 76f395c..1a68131 100644 --- a/pages/cart/cart/cart.wxml +++ b/pages/cart/cart/cart.wxml @@ -107,7 +107,7 @@ - + diff --git a/pages/cart/cart/cart.wxss b/pages/cart/cart/cart.wxss index 9817577..71c30e3 100644 --- a/pages/cart/cart/cart.wxss +++ b/pages/cart/cart/cart.wxss @@ -143,7 +143,7 @@ radio { height: 100rpx; position: fixed; left: 0; - bottom: 45px; + bottom: 90rpx; font-size: 28rpx; color: #666; background-color: rgb(255, 255, 255); diff --git a/pages/cart/cart2/cart2.js b/pages/cart/cart2/cart2.js index beeae0f..75d8729 100644 --- a/pages/cart/cart2/cart2.js +++ b/pages/cart/cart2/cart2.js @@ -105,6 +105,8 @@ Page({ //-- order_prom_list -- order_prom_list_cart:null, + ispt_goods:0, //是否平摊至单品,0要平摊 1不平摊 + }, onLoad: function(t) { @@ -122,7 +124,8 @@ Page({ //先获取是否有关闭使用优惠券 getApp().getConfig2(function (ee) { var json_d = JSON.parse(ee.switch_list); - th.setData({ is_close_quan: json_d.is_close_quan,sales_rules:ee.sales_rules }); + th.data.ispt_goods=json_d.ispt_goods; //是不是平摊到单品的控制参数赋值 + th.setData({ is_close_quan: json_d.is_close_quan,sales_rules:ee.sales_rules}); //-----先获取物流,再获取用户信息,再展示页面----- th.get_wuliu(th.get_info(th.show_page)); }) @@ -638,19 +641,17 @@ Page({ if(th.data.cartlist) c_arr[i].check_quan_ware_list= th.data.cartlist[i].check_quan_ware_list; //优惠券优惠什么商品 } - var cart_item=c_arr[i]; + var cart_item=c_arr[i]; //就是每一单的意思 var pickid=cart_item.pickup_id; var o_price=0; var o_shipping_price=0,goods_weight=-1, goods_piece=-1; - var item=c_arr[i].goods; - //--获取物流code-- + var item=c_arr[i].goods; //就是每一单的从表的意思 //--------循环计算总价----------- for(var j=0;j=0?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; @@ -695,17 +696,10 @@ Page({ } }) } - //--------循环计算商品是不是包邮,是不是使用优惠券----------- - for(var j=0;j=0 && item_map.price-item_map.prom_price){ if(cart_item.prom_pt_json){ cart_item.prom_pt_json.push({"prom_id":item_map.prom_id,"dis":(item_map.price-item_map.prom_price).toFixed(2),"ispt":0}) }else{ @@ -717,6 +711,18 @@ Page({ if(!item_map.is_xz_yh) q_conditin=o_price; } + + //--------循环计算商品是不是包邮,是不是使用优惠券,此时循环是商品从表----------- + for(var j=0;j=0?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; @@ -2657,7 +2664,7 @@ Page({ }) }, - //--- 加入优惠活动的映射中 --- + //--- 加入优惠活动的映射中,同时要有一个good列表 --- add_prom_goods_map:async function (item) { var th=this; var pickid=item.pick_id; @@ -2669,6 +2676,8 @@ Page({ var ob=map[pickid][item.prom_id]; ob.price+=item.goods_price*item.goods_num; ob.goods_num+=item.goods_num; + ob.goods.push({goods_id:item.goods_id,goods_price:item.goods_price,goods_num:item.goods_num}); + }else{ var prom=null; await getApp().request.promiseGet("/api/weshop/promgoods/get/"+os.stoid+"/"+item.prom_id,{}).then(res=>{ @@ -2680,6 +2689,8 @@ Page({ ob.goods_num=item.goods_num; ob.is_bz=prom.is_bz; ob.is_xz_yh=prom.is_xz_yh; + ob.goods=new Array(); + ob.goods.push({goods_id:item.goods_id,goods_price:item.goods_price,goods_num:item.goods_num}); map[pickid][item.prom_id]=ob; } }else{ @@ -2693,6 +2704,9 @@ Page({ ob.goods_num=item.goods_num; ob.is_bz=prom.is_bz; ob.is_xz_yh=prom.is_xz_yh; + ob.goods=new Array(); + ob.goods.push({goods_id:item.goods_id,goods_price:item.goods_price,goods_num:item.goods_num}); + var obj={}; obj[item.prom_id]=ob; map[pickid]=obj; @@ -2700,8 +2714,8 @@ Page({ } }, - //计算立即购买赠品的物流费用 - get_now_gift_goods_wuliu:function (code, o_shipping_price, user_addr, gift_freight_free,allpice, rs,shipping_price,no_by_data) { + //计算立即购买赠品的物流费用 + 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; @@ -2739,8 +2753,14 @@ Page({ goods_piece, user_addr, gift_freight_free, allpice, rs); return t_shipping_price+shipping_price; - } + }, + //从优惠的映射中拿出商品从表的item + item_map_get_goods:function(goods_id,map){ + for(var i in map.goods){ + if(map.goods[i].goods_id==goods_id) return map.goods[i]; + } + } }); diff --git a/pages/goods/goodsInfo/goodsInfo.js b/pages/goods/goodsInfo/goodsInfo.js index c7418bf..b413b8f 100644 --- a/pages/goods/goodsInfo/goodsInfo.js +++ b/pages/goods/goodsInfo/goodsInfo.js @@ -1,20 +1,20 @@ 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; + 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 more = function(e) { - return e && e.__esModule ? e : { - default: e - }; - }(require("../../../utils/LoadMore.js")), - n = new more.default(); + return e && e.__esModule ? e : { + default: e + }; + }(require("../../../utils/LoadMore.js")), + n = new more.default(); var utils = require('../../../utils/util.js'); var regeneratorRuntime = require('../../../utils/runtime.js'); @@ -76,10 +76,10 @@ Page({ }], activeCategoryId3: 1, categories3: [{ - name: "全部", - id: 1, - num: 0 - }, + name: "全部", + id: 1, + num: 0 + }, { name: "有图", id: 5, @@ -125,8 +125,8 @@ Page({ pickpu_list: null, //读出的所有门店list def_pickpu_list: null, //一开始5个门店list sec_pick_index: 0, //第二级门店选择ID - fir_pick_index: 0, //第一级门店选择ID - all_pick_list:null,//所有的门店先记录起来 + fir_pick_index: 0, //第一级门店选择ID + all_pick_list:null,//所有的门店先记录起来 //同一条形码的所有商品 sku_g: null, sku_g_pt: null, //---拼单的普通购买--- @@ -219,7 +219,7 @@ Page({ new_user: 0, //新用户 def_pick_store: null, // 默认的门店 - fir_def_store:null, //客户默认的门店的 + fir_def_store:null, //客户默认的门店的 lat: null, //维度 lon: null, //经度 @@ -232,14 +232,14 @@ Page({ comments_no_more:0, get_c:0, //获取评价是不是成 is_collect_load:0, //是不是处理 - is_newsales_rules:0, //是否开启最新的门店规则,此时会新读门店,当点击选择门店时会触发读取线下库存 - sales_rules:1, //默认是线上销售 - - wait_for_user_store:null, - - prom_goods:null, //商品优惠列表 - order_prom:null, //订单优惠 - collocationGoods:null, //搭配购 + is_newsales_rules:0, //是否开启最新的门店规则,此时会新读门店,当点击选择门店时会触发读取线下库存 + sales_rules:1, //默认是线上销售 + + wait_for_user_store:null, + + prom_goods:null, //商品优惠列表 + order_prom:null, //订单优惠 + collocationGoods:null, //搭配购 }, @@ -249,11 +249,11 @@ Page({ title: "商品详情", }) var ee = this, - that = ee, - th = ee, - gid = t.goods_id, - first_leader=t.first_leader, - room_id=t.room_id; + that = ee, + th = ee, + gid = t.goods_id, + first_leader=t.first_leader, + room_id=t.room_id; //---获取手机地址坐标-- //--如果tg_id是空的话,分享回来-- @@ -267,18 +267,18 @@ Page({ } ee.setData({ gid: gid}); if(first_leader){ - getApp().globalData.first_leader=first_leader; - //调用接口判断是不是会员 - getApp().request.promiseGet("/api/weshop/shoppingGuide/get/"+os.stoid+"/"+first_leader,{}).then(res=>{ - if(res.data.code==0){ - getApp().globalData.guide_id=res.data.data.id; - } - }) + getApp().globalData.first_leader=first_leader; + //调用接口判断是不是会员 + getApp().request.promiseGet("/api/weshop/shoppingGuide/get/"+os.stoid+"/"+first_leader,{}).then(res=>{ + if(res.data.code==0){ + getApp().globalData.guide_id=res.data.data.id; + } + }) } if(room_id){ - getApp().globalData.room_id=room_id; - getApp().globalData.room_goods_id=gid; + getApp().globalData.room_id=room_id; + getApp().globalData.room_goods_id=gid; } @@ -291,7 +291,7 @@ Page({ getApp().getConfig2(function(e) { ee.setData({ bconfig: e, - sales_rules:e.sales_rules + sales_rules:e.sales_rules }); if (e.categoryset.indexOf("," + 1 + ",") != -1) { @@ -313,9 +313,9 @@ Page({ var json_d = JSON.parse(e.switch_list); ee.setData({ store_config: e, - sys_switch:json_d, + sys_switch:json_d, is_closecoupon: json_d.is_closecoupon, - is_newsales_rules:json_d.is_newsales_rules + is_newsales_rules:json_d.is_newsales_rules }); ee.init(gid); //------几人评价------- @@ -325,39 +325,39 @@ Page({ supportPageScroll: !0 }); - //计算等级价相关 - var swithc_list=e.switch_list; - var sw_arr=JSON.parse(swithc_list); - //---如果后台又开等级卡的开关--- - if(sw_arr.rank_switch && sw_arr.rank_switch=="2"){ - th.setData({rank_switch:true}); - //---回调卡的列表--- - th.getPlusCardType(function(ob){ - th.setData({card_list:ob.card_list}); - var ti = setInterval(function () { - var user = getApp().globalData.userInfo; - if (!user) return false; - clearInterval(ti); - - 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); - - var is_near_date=0; - if(end-now<60*60*30*24) is_near_date=1; //如果小于30天 - th.setData({card_field:user.card_field,card_name:card_name,card_list:ob.card_list,is_near_date:is_near_date}); - } - } - }, 500) - }) - - } + //计算等级价相关 + var swithc_list=e.switch_list; + var sw_arr=JSON.parse(swithc_list); + //---如果后台又开等级卡的开关--- + if(sw_arr.rank_switch && sw_arr.rank_switch=="2"){ + th.setData({rank_switch:true}); + //---回调卡的列表--- + th.getPlusCardType(function(ob){ + th.setData({card_list:ob.card_list}); + var ti = setInterval(function () { + var user = getApp().globalData.userInfo; + if (!user) return false; + clearInterval(ti); + + 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); + + var is_near_date=0; + if(end-now<60*60*30*24) is_near_date=1; //如果小于30天 + th.setData({card_field:user.card_field,card_name:card_name,card_list:ob.card_list,is_near_date:is_near_date}); + } + } + }, 500) + }) + + } }); @@ -372,7 +372,7 @@ Page({ //获取用户的默认门店 getApp().get_user_store(function(ee) { - + if(!ee) { th.data.fir_def_store={}; //赋值空对象 return false; @@ -454,15 +454,15 @@ Page({ //------------程序初始化入口------------- async init(gid) { var ee = this, - th = ee, - gallery = null, - is_collect = 0, - collect_id = 0, - categories3 = ee.data.categories3, - fir_com = null, - fir_quan = null, - mapurl = null, - mapurl_f_img = null; + th = ee, + gallery = null, + is_collect = 0, + collect_id = 0, + categories3 = ee.data.categories3, + fir_com = null, + fir_quan = null, + mapurl = null, + mapurl_f_img = null; //------图片滚动---------- @@ -609,8 +609,8 @@ Page({ this.data.is_timer = 1; var ee = this, - gid = this.data.gid, - i = getApp().request; + gid = this.data.gid, + i = getApp().request; this.wait_for_store_config(); @@ -659,7 +659,7 @@ Page({ 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; + t.data.data.original_img = o.imghost + t.data.data.original_img; if (t.data.data.goods_content == null) t.data.data.goods_content = ""; @@ -671,56 +671,56 @@ Page({ ee.setData({ data: t.data.data, sele_g: t.data.data, - userInfo:getApp().globalData.userInfo + userInfo:getApp().globalData.userInfo }); - + //获取统一条形码,普通商品和优惠促销的商品 - 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){ - //获取门店 - 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}); + 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){ + //获取门店 + 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} }) - } - }) - }else{ - //获取门店 - ee.get_sto(); - } - - ee.get_sku(o.stoid, t.data.data.sku, gid); - } + }).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(); + } + + ee.get_sku(o.stoid, t.data.data.sku, gid); + } else { var gg = "", - item = t.data.data; + item = t.data.data; if(item.goods_spec=="null" || item.goods_spec==null ) item.goods_spec=""; if(item.goods_color=="null" || item.goods_color==null) item.goods_color=""; @@ -837,7 +837,7 @@ Page({ //商品详情的时候调用 tabGoodsContent: function() { var th = this, - i = getApp().request; + i = getApp().request; this.setData({ activeCategoryId: 1 }); @@ -882,8 +882,8 @@ Page({ //获取redis中的数量 async getactLen(func) { var r_num = 0, - prom_type = this.data.prom_type, - prom_id = this.data.prom_id; + prom_type = this.data.prom_type, + prom_id = this.data.prom_id; await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { 1: 1 }).then(res => { @@ -924,10 +924,10 @@ Page({ return s.my_warnning("还未登录!", 0, this); } var e = this, - th = e, - a = 0, - o = this.data.sele_g; - a = o.goods_id; + th = e, + a = 0, + o = this.data.sele_g; + a = o.goods_id; //----------添加到购物车时,要判断限购数量,-------- e.get_buy_num(o, function(ee) { @@ -1005,208 +1005,208 @@ Page({ if (th.data.prom_type == 1) { 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); - if (o.store_count 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 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.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; + var s_list=JSON.parse(conf.switch_list); + var now=ut.gettimestamp(); + var str = getApp().globalData.userInfo['card_expiredate'].replace(/-/g, '/'); + var end = new Date(str); + end = Date.parse(end) / 1000; + + //--如果后台有开启等级价的功能,而且会员的等级没有过期的情况下-- + if(parseInt(s_list.rank_switch)==2 && end>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.member_goods_price=card_price; + } } + } + } - //----先看会员在购物车中是否加入了该商品----- - i.get("/api/weshop/cart/page", { - data: { - store_id: e.data.stoid, - user_id: oo.user_id, - goods_id: a, - pick_id: e.data.sto_sele_id, - }, - success: function(re) { - - //-------如果购物车中有相关的数据--------- - if (re.data.data.total > 0) { - - var item = re.data.data.pageData[0]; - - //判断数量,要看下购物车中有没有该商品 - if(CanOutQty){ - if(item.goods_num+ th.data.goodsInputNum>CanOutQty){ - return s.my_warnning("库存不足!", 0, th); - } - }else{ - if(item.goods_num+ th.data.goodsInputNum>o.store_count){ - return s.my_warnning("库存不足!", 0, th); - } - } - - 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, - }; - - //---是不是从收藏夹出来的--- - if(th.data.c_guide_id){ - updata['guide_id'] = th.data.c_guide_id; - updata['guide_type']=3; //加入购物车之后就变成了3 - }else { - if (getApp().globalData.guide_id) { - updata['guide_id'] = getApp().globalData.guide_id; - updata['guide_type'] = 0; - } + //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: { + store_id: e.data.stoid, + user_id: oo.user_id, + goods_id: a, + pick_id: e.data.sto_sele_id, + }, + success: function(re) { + + //-------如果购物车中有相关的数据--------- + if (re.data.data.total > 0) { + + var item = re.data.data.pageData[0]; + + //判断数量,要看下购物车中有没有该商品 + if(CanOutQty){ + if(item.goods_num+ th.data.goodsInputNum>CanOutQty){ + return s.my_warnning("库存不足!", 0, th); + } + }else{ + if(item.goods_num+ th.data.goodsInputNum>o.store_count){ + return s.my_warnning("库存不足!", 0, th); + } + } + + 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, + }; + + //---是不是从收藏夹出来的--- + if(th.data.c_guide_id){ + updata['guide_id'] = th.data.c_guide_id; + updata['guide_type']=3; //加入购物车之后就变成了3 + }else { + if (getApp().globalData.guide_id) { + updata['guide_id'] = getApp().globalData.guide_id; + updata['guide_type'] = 0; + } + } + + i.put("/api/weshop/cart/update", { + data: updata, + success: function(t) { + getApp().my_warnning('加入购物车成功', 1, th, 450); + var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; + th.setData({ + cartGoodsNum: c_num + }); + th.closeSpecModal(); } + }); + } else { + + + i.post("/api/weshop/cart/save", { + data: newd, + success: function(t) { + getApp().my_warnning('加入购物车成功', 1, th, 450); + var c_num = th.data.cartGoodsNum + e.data.goodsInputNum; + th.setData({ + cartGoodsNum: c_num + }); + th.closeSpecModal(); + } + }); + } + } + }); + } + //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; + } + } - i.put("/api/weshop/cart/update", { - data: updata, - success: function(t) { - getApp().my_warnning('加入购物车成功', 1, th, 450); - var c_num = th.data.cartGoodsNum + th.data.goodsInputNum; - th.setData({ - cartGoodsNum: c_num - }); - th.closeSpecModal(); - } - }); - } else { - - - i.post("/api/weshop/cart/save", { - data: newd, - success: function(t) { - getApp().my_warnning('加入购物车成功', 1, th, 450); - var c_num = th.data.cartGoodsNum + e.data.goodsInputNum; - th.setData({ - cartGoodsNum: c_num - }); - th.closeSpecModal(); - } - }); - } - } - }); - } - //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); - } + } + + newd['pick_name'] = th.data.sto_sele_name; + newd['pick_dis'] = th.data.sto_sele_distr; + th.buyNow(newd); + } }, - + //----------购买虚拟商品------ buyVirtualGoods: function(e) { @@ -1256,17 +1256,17 @@ Page({ //--判断商品是否超出限购-- if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { - - var gd_buy_num=th.data.g_buy_num.get(th.data.sele_g.goods_id); - + + var gd_buy_num=th.data.g_buy_num.get(th.data.sele_g.goods_id); + if (t + gd_buy_num > th.data.sele_g.viplimited) { wx.showModal({ title: '超出商品限购', }); - - var num= th.data.sele_g.viplimited-gd_buy_num; - if(num<0) num=0; - th.setData({goodsInputNum:num}) + + var num= th.data.sele_g.viplimited-gd_buy_num; + if(num<0) num=0; + th.setData({goodsInputNum:num}) return false; } } @@ -1277,10 +1277,10 @@ Page({ wx.showModal({ title: '超出商品活动限购', }); - - var num=th.data.prom_buy_limit- th.data.prom_buy_num ; - if(num<0) num=0; - th.setData({goodsInputNum:num}) + + var num=th.data.prom_buy_limit- th.data.prom_buy_num ; + if(num<0) num=0; + th.setData({goodsInputNum:num}) return false; } } @@ -1289,40 +1289,40 @@ Page({ var redis_num = 0; //------判断活动是否抢光----- await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + - os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { - 1: 1 - }).then(res => { + os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { + 1: 1 + }).then(res => { redis_num = res.data.data; }); if (t > redis_num) { wx.showModal({ title: '超出商品活动库存', - }); - th.setData({goodsInputNum:redis_num}) + }); + th.setData({goodsInputNum:redis_num}) + return false; + } + + } + + var e = th.data.sele_g.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 }); - var e = th.data.sele_g.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 }); - }) }, @@ -1359,7 +1359,7 @@ Page({ //---------点击收藏和不收藏------------ collectGoods: function() { var t = this, - i = getApp().request; + i = getApp().request; var user_id = s.globalData.user_id; if (user_id == '') { getApp().getUserFir(function() {}); @@ -1483,7 +1483,7 @@ Page({ previewGoodsCommentImgs: function(t) { var e = this, - a = this.data.data.comment[t.currentTarget.dataset.cidx].img; + a = this.data.data.comment[t.currentTarget.dataset.cidx].img; a = a.map(function(t) { return e.data.url + t; }), wx.previewImage({ @@ -1518,7 +1518,7 @@ Page({ } var url="/pages/goods/goodsInfo/goodsInfo?goods_id=" + th.data.gid; if(getApp().globalData.user_id){ - url+="&first_leader="+getApp().globalData.user_id; + url+="&first_leader="+getApp().globalData.user_id; } return { @@ -1549,6 +1549,8 @@ Page({ //----------装载同一条形码的商品---------- async get_sku(stoid, sku, g_id, is_normal, func) { var tt = this,arrdata=null; + var now=ut.gettimestamp(); + await getApp().request.promiseGet("/api/weshop/goods/page", { data: { store_id: o.stoid, @@ -1557,82 +1559,82 @@ Page({ is_on_sale: 1 } }).then(res => { - var e = res; - if (e.data.code == 0) arrdata = e.data.data.pageData; + var e = res; + if (e.data.code == 0) arrdata = e.data.data.pageData; }) - if(!arrdata) return fasle; - - var arrsku = new Array(); + if(!arrdata) return fasle; + + var arrsku = new Array(); var gitem = null; - var gb = 1,gg = ""; - for (var i = 0; i < arrdata.length; i++) { - var goodsinfo=arrdata[i],prom=null; - if (goodsinfo.goods_id != g_id) { - if(goodsinfo.prom_type==1){ - await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+goodsinfo.prom_id,{ - }).then(res=>{ - if(res.data.code==0) prom=res.data.data; - }) - } - if(goodsinfo.prom_type==6){ - await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+goodsinfo.prom_id,{ - }).then(res=>{ - if(res.data.code==0) prom=res.data.data; - }) - } - } - //---如果有活动,不算在一起--- - if(prom){ - if(prom.is_end==0 && prom.end_time>now && prom.start_time{ + if(res.data.code==0) prom=res.data.data; + }) + } + if(goodsinfo.prom_type==6){ + await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+goodsinfo.prom_id,{ + }).then(res=>{ + if(res.data.code==0) prom=res.data.data; + }) + } + } + //---如果有活动,不算在一起--- + if(prom){ + if(prom.is_end==0 && prom.end_time>now && prom.start_time{ - 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.def_pick_store.pickup_no,wareIds:encodeURIComponent(th.data.sele_g.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.def_pick_store.CanOutQty=plist.CanOutQty-lock; - }else{ - that.data.def_pick_store.CanOutQty=0; - } - //--给门店赋值线下库存-- - th.setData({def_pick_store:that.data.def_pick_store}); - }) - } - - - this.sele_spec_chech_activity(); + this.get_sto(); + //默认门店要拿下门店库存 + if(that.data.sales_rules==2 && that.data.def_pick_store){ + var lock=0,plist=null; + //先读取门店的lock,采用链式写法,少用await + getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{ + data:{store_id:os.stoid,wareId:ee.data.sele_g.goods_id,storageId:that.data.def_pick_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.def_pick_store.pickup_no,wareIds:encodeURIComponent(th.data.sele_g.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.def_pick_store.CanOutQty=plist.CanOutQty-lock; + }else{ + that.data.def_pick_store.CanOutQty=0; + } + //--给门店赋值线下库存-- + th.setData({def_pick_store:that.data.def_pick_store}); + }) + } + + + this.sele_spec_chech_activity(); }, - + //选择了不同的规格的时候要判断是不是有活动正在进行中 async sele_spec_chech_activity(){ - //---如果是活动的时候--- - var prom=null,goodsinfo=this.data.sele_g,th=this; - if(goodsinfo.prom_type==1){ - await getApp().request.promiseGet("/api/ms/flash_sale/get/"+os.stoid+"/"+goodsinfo.prom_id,{ - }).then(res=>{ - if(res.data.code==0){ - prom=res.data.data; - } - }) - } - if(goodsinfo.prom_type==6){ - await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+goodsinfo.prom_id,{ - }).then(res=>{ - if(res.data.code==0){ - prom=res.data.data; - } - }) - } - //----------如果有活动,并且在进行中,就不计算线下库存--------------- - var now=ut.gettimestamp(); - if(prom){ - if(prom.is_end==0 && prom.end_time>now && prom.start_time{ + if(res.data.code==0){ + prom=res.data.data; + } + }) + } + if(goodsinfo.prom_type==6){ + await getApp().request.promiseGet("/api/weshop/teamlist/get/"+os.stoid+"/"+goodsinfo.prom_id,{ + }).then(res=>{ + if(res.data.code==0){ + prom=res.data.data; + } + }) + } + //----------如果有活动,并且在进行中,就不计算线下库存--------------- + var now=ut.gettimestamp(); + if(prom){ + if(prom.is_end==0 && prom.end_time>now && prom.start_time { var e = res; if (e.data.code == 0) { - + //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店 if(dd.lat && !th.data.def_pick_store && th.data.bconfig.is_sort_storage){ th.setData({ @@ -1781,7 +1783,7 @@ Page({ 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]; + th.data.fir_def_store=e.data.data.pageData[0]; } //-- 如果有默认选择门店的时候,要把默认门店放在第一位 -- @@ -1794,266 +1796,266 @@ Page({ } 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) - } - } + + + 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; - - var g_distr_type=th.data.sele_g.distr_type; - - //单总量超出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 - }) - } - } + var th=this; + + var g_distr_type=th.data.sele_g.distr_type; + + //单总量超出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 g_distr_type=th.data.sele_g.distr_type; - var lock=[]; - //先读取门店的lock,采用链式写法,少用await - getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{ - data:{store_id:os.stoid,wareId:th.data.sele_g.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.sele_g.erpwareid),storeId:os.stoid,pageSize:2000} - }) - }).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 && (g_distr_type==0 || th.data.fir_def_store.distr_type==0 || th.data.def_pick_store.distr_type==g_distr_type ) ){ - 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 && (g_distr_type==0 || th.data.fir_def_store.distr_type==0 || th.data.def_pick_store.distr_type==g_distr_type ) ){ - 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}) - } - }) + 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 g_distr_type=th.data.sele_g.distr_type; + var lock=[]; + //先读取门店的lock,采用链式写法,少用await + getApp().request.promiseGet("/api/weshop/order/ware/lock/page",{ + data:{store_id:os.stoid,wareId:th.data.sele_g.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.sele_g.erpwareid),storeId:os.stoid,pageSize:2000} + }) + }).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 && (g_distr_type==0 || th.data.fir_def_store.distr_type==0 || th.data.def_pick_store.distr_type==g_distr_type ) ){ + 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 && (g_distr_type==0 || th.data.fir_def_store.distr_type==0 || th.data.def_pick_store.distr_type==g_distr_type ) ){ + 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; + 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; }, //----------取货门店被点击的效果------ @@ -2113,12 +2115,12 @@ Page({ var tot = res.data.data.total; e.data.c_curr_p++; e.setData({ - com_num: tot, //已经有加载 + com_num: tot, //已经有加载 }); if (res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){ - rs_data=res.data.data.pageData; + rs_data=res.data.data.pageData; }else{ - th.setData({comments_no_more:1,auto:1}); + th.setData({comments_no_more:1,auto:1}); } }) @@ -2126,30 +2128,30 @@ Page({ //var cda = th.data.comments; var cda = rs_data,com_data=th.data.comments; for (var ind in cda) { - var ep = cda[ind]; - if (cda[ind].head_pic == '') { - cda[ind].head_pic = th.data.iurl + "/miniapp/images/hui_hear_pic.png"; - } - if (ep.weapp_img != "" && ut.isString(ep.weapp_img)) { - cda[ind].weapp_img = JSON.parse(ep.weapp_img); - } - if (ep.img != "" && ut.isString(ep.img)) { - cda[ind].img = ut.unserialize(ep.img); - } + var ep = cda[ind]; + if (cda[ind].head_pic == '') { + cda[ind].head_pic = th.data.iurl + "/miniapp/images/hui_hear_pic.png"; + } + if (ep.weapp_img != "" && ut.isString(ep.weapp_img)) { + cda[ind].weapp_img = JSON.parse(ep.weapp_img); + } + if (ep.img != "" && ut.isString(ep.img)) { + cda[ind].img = ut.unserialize(ep.img); + } - //--测量多有字的宽带,计算有多少行-- - var widh=ut.measureText(ep.content,30); - var lines=widh/712; - cda[ind].seeMore=false; - if(lines>3) cda[ind].seeMore=true; - - await getApp().request.promiseGet("/api/weshop/comment/pageComment", { - data: {store_id: o.stoid, parent_id: ep.comment_id } - }).then(res => { - if (res.data.data.pageData && res.data.data.pageData.length > 0) { - cda[ind].replay_list = res.data.data.pageData; - } - }) + //--测量多有字的宽带,计算有多少行-- + var widh=ut.measureText(ep.content,30); + var lines=widh/712; + cda[ind].seeMore=false; + if(lines>3) cda[ind].seeMore=true; + + await getApp().request.promiseGet("/api/weshop/comment/pageComment", { + data: {store_id: o.stoid, parent_id: ep.comment_id } + }).then(res => { + if (res.data.data.pageData && res.data.data.pageData.length > 0) { + cda[ind].replay_list = res.data.data.pageData; + } + }) } if (!com_data) com_data = cda; @@ -2174,7 +2176,7 @@ Page({ //--------检查是否活动,活动是否开始,或者是否结束------- async check_prom(gid, prom_type, prom_id) { var ee = this, - th = ee; + th = ee; if (prom_type == 3 || prom_type == 0 || prom_type == 2 || prom_type == 4 || prom_type == 5) { this.setData({ prom_type: 0, @@ -2197,91 +2199,91 @@ Page({ }); //拿取价格并且判断时间-- getApp().request.get("/api/ms/flash_sale/get/" + - os.stoid + "/" + 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.sku, 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.sku, 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.sku, 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.sku, 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"); + os.stoid + "/" + 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.sku, 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.sku, 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.sku, gid); + return false; + } + /*-- 还没有开始预热的也不显示 --*/ + if (t.data.data.show_time > now) { ee.setData({ - prom_price: t.data.data.price, - prom_type: 1, - 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, + prom_type: 0, isshow: 1, }); - - ee.get_sto(); + ee.get_sku(os.stoid, ee.data.data.sku, 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: 1, + 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, + }); + + ee.get_sto(); - var newTime = ut.gettimestamp(); - var endTime2 = t.data.data.end_time; - var endTime1 = t.data.data.start_time; - //---苹果机不兼容--- - /*---- - var endTime2 = new Date(prom_end_time).getTime(); - var endTime1 = new Date(prom_start_time).getTime();----*/ + var newTime = ut.gettimestamp(); + var endTime2 = t.data.data.end_time; + var endTime1 = t.data.data.start_time; - if (endTime1 > newTime) { + //---苹果机不兼容--- + /*---- + var endTime2 = new Date(prom_end_time).getTime(); + var endTime1 = new Date(prom_start_time).getTime();----*/ + + if (endTime1 > newTime) { + ee.setData({ + prom_time_text: '距秒杀开始还有' + }) + ee.countDown(endTime1, 0); + } else { + if (endTime2 > newTime) { ee.setData({ - prom_time_text: '距秒杀开始还有' + prom_time_text: '距秒杀结束还有', + prom_st: 1 }) - ee.countDown(endTime1, 0); - } else { - if (endTime2 > newTime) { - ee.setData({ - prom_time_text: '距秒杀结束还有', - prom_st: 1 - }) - ee.countDown(endTime2); - } + ee.countDown(endTime2); } } - }); + } + }); } }) } @@ -2301,152 +2303,152 @@ Page({ }); //拿取价格并且判断时间-- getApp().request.get("/api/weshop/teamlist/get/" + - os.stoid + "/" + 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.sku, gid); - ee.get_sto(); - return false; - } - //----已经结束----- - if (t.data.data.is_end == 1) { - ee.setData({ - prom_type: 0, - isshow: 1, - }); - ee.get_sku(os.stoid, ee.data.data.sku, gid); - 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.sku, gid); - ee.get_sto(); - return false; - } + os.stoid + "/" + 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.sku, gid); + ee.get_sto(); + return false; + } + //----已经结束----- + if (t.data.data.is_end == 1) { + ee.setData({ + prom_type: 0, + isshow: 1, + }); + ee.get_sku(os.stoid, ee.data.data.sku, gid); + 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.sku, gid); + ee.get_sto(); + return false; + } - /*-- 还没有开始预热的也不显示 --*/ - if (t.data.data.show_time > now) { - ee.setData({ - prom_type: 0, - isshow: 1, - }); - ee.get_sku(os.stoid, ee.data.data.sku, gid); - ee.get_sto(); - return false; - } + /*-- 还没有开始预热的也不显示 --*/ + if (t.data.data.show_time > now) { + ee.setData({ + prom_type: 0, + isshow: 1, + }); + ee.get_sku(os.stoid, ee.data.data.sku, gid); + ee.get_sto(); + return false; + } - //-------查看自己是不是有买过该团的商品,并还为支付,或者在进行中------- - getApp().request.get("/api/weshop/order/page", { - data: { - pt_prom_id: prom_id, - user_id: oo.user_id, - store_id: os.stoid, - pageSize: 1, - page: 1 - }, - success: function(e) { - if (e.data.code == 0 && e.data.data.pageData.length > 0) { - var odr = e.data.data.pageData[0]; - th.data.buy_order = odr; - if (odr.pt_status == 0 && odr.order_status == 1) { + //-------查看自己是不是有买过该团的商品,并还为支付,或者在进行中------- + getApp().request.get("/api/weshop/order/page", { + data: { + pt_prom_id: prom_id, + user_id: oo.user_id, + store_id: os.stoid, + pageSize: 1, + page: 1 + }, + success: function(e) { + if (e.data.code == 0 && e.data.data.pageData.length > 0) { + var odr = e.data.data.pageData[0]; + th.data.buy_order = odr; + if (odr.pt_status == 0 && odr.order_status == 1) { + th.setData({ + user_order_pt_state: 1 + }); + } + if (odr.pt_status == 1 && odr.order_status == 1) { + if (odr.is_zsorder == 4) { + getApp().request.promiseGet("/api/weshop/teamgroup/page/", { + data: { + store_id: os.stoid, + team_id: odr.pt_prom_id, + listno: odr.pt_listno + } + }).then(res => { + var now = ut.gettimestamp(); + var tgr = res.data.data.pageData[0]; + //如果团的时间已经到了 + if (now >= tgr.kt_end_time) { + th.update_jiti(tgr.id); + } else { + th.setData({ + user_order_pt_state: 2 + }); + } + }) + + } else { th.setData({ - user_order_pt_state: 1 + user_order_pt_state: 2 }); } - if (odr.pt_status == 1 && odr.order_status == 1) { - if (odr.is_zsorder == 4) { - getApp().request.promiseGet("/api/weshop/teamgroup/page/", { - data: { - store_id: os.stoid, - team_id: odr.pt_prom_id, - listno: odr.pt_listno - } - }).then(res => { - var now = ut.gettimestamp(); - var tgr = res.data.data.pageData[0]; - //如果团的时间已经到了 - if (now >= tgr.kt_end_time) { - th.update_jiti(tgr.id); - } else { - th.setData({ - user_order_pt_state: 2 - }); - } - }) - - } else { - th.setData({ - user_order_pt_state: 2 - }); - } - } + } - if (odr.pt_status == 2 && odr.is_zsorder == 4) { - th.setData({ - user_order_pt_state: 3, - }); - th.data.wk_order_id = odr.order_id; - } + if (odr.pt_status == 2 && odr.is_zsorder == 4) { + th.setData({ + user_order_pt_state: 3, + }); + th.data.wk_order_id = odr.order_id; } - }, - }); + } + }, + }); - //----------查看阶梯团------------ - if (t.data.data.ct_rylist != "" && t.data.data.ct_rylist != null && t.data.data.ct_rylist != undefined) { - t.data.data.ct_rylist = JSON.parse(t.data.data.ct_rylist); - var max_num = 0; - t.data.data.ct_rylist.forEach(function(val, ind) { - if (parseInt(val.rynum) > max_num) max_num = parseInt(val.rynum); - }) - t.data.data.max_ct_num = max_num; - } + //----------查看阶梯团------------ + if (t.data.data.ct_rylist != "" && t.data.data.ct_rylist != null && t.data.data.ct_rylist != undefined) { + t.data.data.ct_rylist = JSON.parse(t.data.data.ct_rylist); + var max_num = 0; + t.data.data.ct_rylist.forEach(function(val, ind) { + if (parseInt(val.rynum) > max_num) max_num = parseInt(val.rynum); + }) + t.data.data.max_ct_num = max_num; + } - 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: 6, - 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, - }); - - ee.get_sto(); + 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: 6, + 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, + }); + + ee.get_sto(); - var newTime = now; - var endTime2 = t.data.data.end_time; - var endTime1 = t.data.data.start_time; + var newTime = now; + var endTime2 = t.data.data.end_time; + var endTime1 = t.data.data.start_time; - if (endTime1 > newTime) { + if (endTime1 > newTime) { + ee.setData({ + prom_time_text: '距拼单开始还剩:' + }) + ee.countDown(endTime1, 0); + } else { + if (endTime2 > newTime) { ee.setData({ - prom_time_text: '距拼单开始还剩:' + prom_time_text: '距拼单结束还剩:', + prom_st: 1 }) - ee.countDown(endTime1, 0); - } else { - if (endTime2 > newTime) { - ee.setData({ - prom_time_text: '距拼单结束还剩:', - prom_st: 1 - }) - ee.countDown(endTime2); - } + ee.countDown(endTime2); } - //-------查看有多少人在开这个团------- - th.get_team_group(prom_id); } - }); + //-------查看有多少人在开这个团------- + th.get_team_group(prom_id); + } + }); } }) } @@ -2456,8 +2458,8 @@ Page({ //--获取有多少人在开团-- async get_team_group(prom_id) { var teamgroup = [], - th = this, - grounp_tatal = 0; + th = this, + grounp_tatal = 0; //如果活动是开团不是商家团 if (this.data.prom_act.kttype > 1) { //获取活动从表信息team_id @@ -2573,8 +2575,8 @@ Page({ //-------------获取购买数量的总函数---------------- get_buy_num: function(gd, func) { var map = this.data.g_buy_num, - th = this, - user_id = getApp().globalData.user_id; + th = this, + user_id = getApp().globalData.user_id; if (user_id == null) { map.set(gd.goods_id, 0); th.setData({ @@ -2759,8 +2761,8 @@ Page({ return; } var e = this, - th = e, - o = this.data.sele_g; + th = e, + o = this.data.sele_g; if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th); //----------添加到购物车时,要判断限购数量,-------- @@ -2773,10 +2775,10 @@ Page({ title: '提示', content: '超出商品限购' }); - - var num=th.data.prom_buy_limit-th.data.prom_buy_num; - if(num<0) num=0; - th.setData({goodsInputNum:num}) + + var num=th.data.prom_buy_limit-th.data.prom_buy_num; + if(num<0) num=0; + th.setData({goodsInputNum:num}) return false; } } @@ -2787,42 +2789,42 @@ Page({ title: '提示', content: '超出商品活动限购' }); - - var num=th.data.prom_buy_limit-th.data.prom_buy_num; - if(num<0) num=0; - th.setData({goodsInputNum:num}) + + var num=th.data.prom_buy_limit-th.data.prom_buy_num; + if(num<0) num=0; + th.setData({goodsInputNum:num}) return false; } } var redis_num = 0 - //不是普通购买的时候 - if(th.data.is_normal!=1){ - //-------判断活动是否抢光--------- - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/6/" + th.data.sele_g.prom_id, { - 1: 1 - }).then(res => { - redis_num = res.data.data; - }) - - if (th.data.goodsInputNum > redis_num) { - wx.showModal({ - title: '提示', - content: '超出商品活动库存' - }); - - th.setData({goodsInputNum:redis_num}) - - return false; - } - } + //不是普通购买的时候 + if(th.data.is_normal!=1){ + //-------判断活动是否抢光--------- + await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/6/" + th.data.sele_g.prom_id, { + 1: 1 + }).then(res => { + redis_num = res.data.data; + }) + + if (th.data.goodsInputNum > redis_num) { + wx.showModal({ + title: '提示', + content: '超出商品活动库存' + }); + + th.setData({goodsInputNum:redis_num}) + + return false; + } + } if (th.data.goodsInputNum <= 0) return s.my_warnning("商品数量不能为0", 0, th); - if (th.data.goodsInputNum > o.store_count) { - th.setData({goodsInputNum:o.store_count}) - return s.my_warnning("超出商品库存", 0, th); - } - + if (th.data.goodsInputNum > o.store_count) { + th.setData({goodsInputNum:o.store_count}) + return s.my_warnning("超出商品库存", 0, th); + } + if (th.data.sto_sele_name == null || th.data.sto_sele_name == undefined) this.setData({ sto_sele_name: "" @@ -2860,30 +2862,30 @@ Page({ newd.room_id=getApp().globalData.room_id; } }else{ - if(newd.goods_id==getApp().globalData.room_goods_id){ - newd.room_id=getApp().globalData.room_id; - } + if(newd.goods_id==getApp().globalData.room_goods_id){ + newd.room_id=getApp().globalData.room_id; + } } - //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ + //---如果商品不是积分购和拼团,要判断一个是否要进行等级价的判断------ - if(th.data.is_normal == 1){ - var conf=th.data.bconfig; - if(conf.switch_list){ - var s_list=JSON.parse(conf.switch_list); - //如果后台有开启等级价的功能 - if(parseInt(s_list.rank_switch)==2){ - 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; - } - } - } - } + if(th.data.is_normal == 1){ + var conf=th.data.bconfig; + if(conf.switch_list){ + var s_list=JSON.parse(conf.switch_list); + //如果后台有开启等级价的功能 + if(parseInt(s_list.rank_switch)==2){ + 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; + } + } + } + } //-----如果是秒杀,团购,积分购,拼团,且不是普通购买----- @@ -3046,7 +3048,7 @@ Page({ var com_id = e.currentTarget.dataset.com_id; var item_id = e.currentTarget.dataset.item_id; var app = getApp(), - th = this; + th = this; if (app.globalData.userInfo == null || app.globalData.userInfo == undefined) { app.confirmBox("您还未登录"); @@ -3162,14 +3164,14 @@ Page({ var item = this.data.quan_list[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; - } + //--先判断会员状态-- + 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; + } //如果券还在领取中,不能再点 @@ -3193,7 +3195,7 @@ Page({ 'type': 5 }; var app = getApp(), - th = this; + th = this; app.request.post("/api/weshop/couponList/saveCouponList", { data: pdata, success: function(res) { @@ -3220,23 +3222,23 @@ Page({ //--定义的保存图片方法,分享团--- saveImageToPhotosAlbum: function() { //--先判断会员状态-- - // var user_info = getApp().globalData.userInfo; - // if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { - // //getApp().my_warnning("请先登录",0,this); - // wx.navigateTo({ url: '/pages/getphone/getphone', }) - // return false; - // } + var user_info = getApp().globalData.userInfo; + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) { + //getApp().my_warnning("请先登录",0,this); + wx.navigateTo({ url: '/pages/getphone/getphone', }) + return false; + } //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 - // var type = this.data.prom_type; - // if (type == 6) type = 2; - // if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; + var type = this.data.prom_type; + if (type == 6) type = 2; + if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3; wx.showLoading({ title: '生成中...', }) var that = this, - th = that; + th = that; //设置画板显示,才能开始绘图 that.setData({ canvasHidden: false @@ -3253,9 +3255,9 @@ Page({ ///二微码 var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" + - os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo"; + os.stoid + "?sceneValue=" + scene + "&pageValue=pages/goods/goodsInfo/goodsInfo"; - console.log('xiaochengxu----->',path3); + console.log(path3); //读取文件成功则OK-- wx.getImageInfo({ @@ -3285,164 +3287,155 @@ Page({ //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度 context.setFillStyle("black"); context.setFontSize(21.3 * unit) - th.draw_Text(context, th.data.data.goods_name, 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit); + th.draw_Text(context, th.data.data.goods_name, + 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit); //------产品的价格------- - // context.setFontSize(23 * unit) - // context.setFillStyle("red") - // context.fillText("¥", 416 * unit, 185 * unit); - // context.setFontSize(31 * unit) - // var pri0 = th.data.data.shop_price; - // if (th.data.prom_act) - // pri0 = th.data.prom_act.price; - - // pri0 = parseFloat(pri0).toFixed(2); - // context.fillText(pri0, 438 * unit, 185 * unit); + context.setFontSize(23 * unit) + context.setFillStyle("red") + context.fillText("¥", 416 * unit, 185 * unit); + context.setFontSize(31 * unit) + var pri0 = th.data.data.shop_price; + if (th.data.prom_act) + pri0 = th.data.prom_act.price; + + pri0 = parseFloat(pri0).toFixed(2); + context.fillText(pri0, 438 * unit, 185 * unit); //---市场价划掉--- - // context.setFillStyle("gray") - // context.setFontSize(22 * unit) - // context.fillText("¥" + th.data.data.market_price, 426 * unit, 213 * unit); - // context.setStrokeStyle('gray') - // context.setLineWidth(1 * unit) - // context.moveTo(426 * unit, 206 * unit) - // context.lineTo(510 * unit, 206 * unit) - // context.stroke(); + context.setFillStyle("gray") + context.setFontSize(22 * unit) + context.fillText("¥" + th.data.data.market_price, 426 * unit, 213 * unit); + context.setStrokeStyle('gray') + context.setLineWidth(1 * unit) + context.moveTo(426 * unit, 206 * unit) + context.lineTo(510 * unit, 206 * unit) + context.stroke(); //---中间大图--- context.drawImage(th.data.share_goods_img, 68 * unit, 242 * unit, 410 * unit, 410 * unit); - - //---文字--- - context.setFontSize(22 * unit) - context.setFillStyle("black") - context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 776 * unit); - context.fillText("长按识别小程序码", 40 * unit, 826 * unit); - //---二维吗图--- - context.drawImage(vpath, 380 * unit, 736 * unit, 120 * unit, 120 * unit); - - //-------大图后面就不一样了----------- - // switch (type) { - // case 0: //普通商品的展示 + switch (type) { + case 0: //普通商品的展示 //中间的几个字 - // var g_path = "../../../images/share/s_gou.png"; - // context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); - // context.setFillStyle("red") - // context.setFontSize(18 * unit) - // context.fillText("正品保证", 84 * unit, 690 * unit); - - // context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); - // context.setFillStyle("red") - // context.setFontSize(18 * unit) - // context.fillText("纯实体店", 246 * unit, 690 * unit); - - // context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); - // context.setFillStyle("red") - // context.setFontSize(18 * unit) - // context.fillText("官方验证", 420 * unit, 690 * unit); + var g_path = "../../../images/share/s_gou.png"; + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit); + context.setFillStyle("red") + context.setFontSize(18 * unit) + context.fillText("正品保证", 84 * unit, 690 * unit); + + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit); + context.setFillStyle("red") + context.setFontSize(18 * unit) + context.fillText("纯实体店", 246 * unit, 690 * unit); + + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit); + context.setFillStyle("red") + context.setFontSize(18 * unit) + context.fillText("官方验证", 420 * unit, 690 * unit); //---画线--- - // context.setLineWidth(1 * unit) - // context.moveTo(32 * unit, 710 * unit) - // context.lineTo(520 * unit, 710 * unit) - // context.stroke(); + context.setLineWidth(1 * unit) + context.moveTo(32 * unit, 710 * unit) + context.lineTo(520 * unit, 710 * unit) + context.stroke(); //---文字--- - // context.setFontSize(22 * unit) - // context.setFillStyle("black") - // context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 776 * unit); - // context.fillText("长按识别小程序码", 40 * unit, 826 * unit); - // //---二维吗图--- - // context.drawImage(vpath, 380 * unit, 736 * unit, 120 * unit, 120 * unit); - // break; - // case 1: //秒杀商品的展示 - // //---画线--- - // context.setLineWidth(1 * unit) - // context.moveTo(32 * unit, 670 * unit) - // context.lineTo(520 * unit, 670 * unit) - // context.stroke(); - - // //画秒杀的图片 - // var miaos_path = '../../../images/share/miao_share.png'; - // context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit); - - // //---文字--- - // context.setFontSize(22 * unit) - // context.setFillStyle("black") - // context.fillText("特惠好物,限时秒杀", 40 * unit, 806 * unit); - // context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit); - // //---二维吗图--- - // context.drawImage(vpath, 380 * unit, 736 * unit, 120 * unit, 120 * unit); - // break; - - // case 2: //会员团和商家团的展示 - // //---画线--- - // context.setLineWidth(1 * unit) - // context.moveTo(32 * unit, 670 * unit) - // context.lineTo(520 * unit, 670 * unit) - // context.stroke(); - // //---文字--- - // context.setFontSize(22 * unit) - // context.font = 'normal bold'; - // context.setFillStyle("black") - // context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit); - - // //绘制成团图片 - // var ct_img = "../../../images/share/ct_num.png"; - // context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit); - // var ct_num = th.data.prom_act.ct_num; - // context.setFontSize(14 * unit) - // context.font = 'normal'; - // context.setFillStyle("red") - // if (ct_num < 10) { - // context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit); - // } else { - // context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit); - // } - // context.setFontSize(22 * unit) - // context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit); - // context.setFillStyle("gray") - // context.fillText("快来和我一起拼团吧!", 40 * unit, 826 * unit); - // context.setFillStyle("black") - // context.font = 'normal bold 18px sans-serif'; - // context.setFontSize(21.3 * unit) - // context.fillText("长按识别二维码,立即参团", 40 * unit, 856 * unit); - // //---二维吗图--- - // context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); - // break - // case 3: //阶梯团的展示 - // //---画线--- - // context.setLineWidth(1 * unit) - // context.moveTo(32 * unit, 670 * unit) - // context.lineTo(520 * unit, 670 * unit) - // context.stroke(); - // //---文字--- - // context.setFontSize(22 * unit) - // context.font = 'normal bold'; - // context.setFillStyle("black") - // context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit); - // //---绘制中间阶梯的价格--- - // var list = th.data.prom_act.ct_rylist; - // for (var i = 0; i < list.length; i++) { - // var item = list[i]; - // var wi = i * 90 * unit; - // context.font = 'normal'; - // context.setFontSize(16 * unit) - // context.setFillStyle("red") - // context.fillText("¥", 40 * unit + wi, 756 * unit); - // context.setFontSize(22 * unit) - // var pri = parseFloat(item.price).toFixed(2); - // context.fillText(pri, 56 * unit + wi, 756 * unit); - // context.setFillStyle("gray") - // context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit); - // } - // //----------------下面部分---------------- - // context.setFillStyle("gray") - // context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit); - // context.setFillStyle("black") - // context.font = 'normal bold 18px sans-serif'; - // context.setFontSize(22 * unit) - // context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit); - // //---二维吗图--- - // context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); - - // break - // } + context.setFontSize(22 * unit) + context.setFillStyle("black") + context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 776 * unit); + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 826 * unit); + //---二维吗图--- + context.drawImage(vpath, 380 * unit, 736 * unit, 120 * unit, 120 * unit); + break; + case 1: //秒杀商品的展示 + //---画线--- + context.setLineWidth(1 * unit) + context.moveTo(32 * unit, 670 * unit) + context.lineTo(520 * unit, 670 * unit) + context.stroke(); + + //画秒杀的图片 + var miaos_path = '../../../images/share/miao_share.png'; + context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit); + + //---文字--- + context.setFontSize(22 * unit) + context.setFillStyle("black") + context.fillText("特惠好物,限时秒杀", 40 * unit, 806 * unit); + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit); + //---二维吗图--- + context.drawImage(vpath, 380 * unit, 736 * unit, 120 * unit, 120 * unit); + break; + + case 2: //会员团和商家团的展示 + //---画线--- + context.setLineWidth(1 * unit) + context.moveTo(32 * unit, 670 * unit) + context.lineTo(520 * unit, 670 * unit) + context.stroke(); + //---文字--- + context.setFontSize(22 * unit) + context.font = 'normal bold'; + context.setFillStyle("black") + context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit); + + //绘制成团图片 + var ct_img = "../../../images/share/ct_num.png"; + context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit); + var ct_num = th.data.prom_act.ct_num; + context.setFontSize(14 * unit) + context.font = 'normal'; + context.setFillStyle("red") + if (ct_num < 10) { + context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit); + } else { + context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit); + } + context.setFontSize(22 * unit) + context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit); + context.setFillStyle("gray") + context.fillText("快来和我一起拼团吧!", 40 * unit, 826 * unit); + context.setFillStyle("black") + context.font = 'normal bold 18px sans-serif'; + context.setFontSize(21.3 * unit) + context.fillText("长按识别二维码,立即参团", 40 * unit, 856 * unit); + //---二维吗图--- + context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); + break + case 3: //阶梯团的展示 + //---画线--- + context.setLineWidth(1 * unit) + context.moveTo(32 * unit, 670 * unit) + context.lineTo(520 * unit, 670 * unit) + context.stroke(); + //---文字--- + context.setFontSize(22 * unit) + context.font = 'normal bold'; + context.setFillStyle("black") + context.fillText("好物拼起来,拼拼更划算", 40 * unit, 726 * unit); + //---绘制中间阶梯的价格--- + var list = th.data.prom_act.ct_rylist; + for (var i = 0; i < list.length; i++) { + var item = list[i]; + var wi = i * 90 * unit; + context.font = 'normal'; + context.setFontSize(16 * unit) + context.setFillStyle("red") + context.fillText("¥", 40 * unit + wi, 756 * unit); + context.setFontSize(22 * unit) + var pri = parseFloat(item.price).toFixed(2); + context.fillText(pri, 56 * unit + wi, 756 * unit); + context.setFillStyle("gray") + context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit); + } + //----------------下面部分---------------- + context.setFillStyle("gray") + context.fillText("快来和我一起拼团吧!", 40 * unit, 830 * unit); + context.setFillStyle("black") + context.font = 'normal bold 18px sans-serif'; + context.setFontSize(22 * unit) + context.fillText("长按识别二维码,立即参团", 40 * unit, 860 * unit); + //---二维吗图--- + context.drawImage(vpath, 420 * unit, 726 * unit, 120 * unit, 120 * unit); + + break + } //---绘制圆形要放在最后---- context.save(); @@ -3682,22 +3675,22 @@ Page({ 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(!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', @@ -3714,7 +3707,7 @@ Page({ }, fail: function(res) { //th.onShow(); - th.data.is_get_local_ok = 1; + th.data.is_get_local_ok = 1; th.get_sto(); if (res.errCode == 2) { th.setData({ @@ -3735,64 +3728,64 @@ Page({ th.data.is_get_local_ok = 1; th.get_sto(); } - - 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 - }) - } + + 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; + var th=this; this.setData({ store: 0, choice_sort_store: 0, sort_store: 0, - fir_pick_index:0, - sec_pick_index: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 - }) - } - - + + 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({ @@ -3822,61 +3815,61 @@ Page({ sec_pick_index: 0 }); }, - + choose_for_store_fir: function(e) { var index_c = e.currentTarget.dataset.ind; - var th=this; + var th=this; th.setData({ - fir_pick_index: index_c + fir_pick_index: index_c }) }, - + //如果开启线下库存,已经急速库存才会使用 async check_the_pick(item,func){ - var th=this; - var goodsinfo=th.data.sele_g; - 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); - - } + var th=this; + var goodsinfo=th.data.sele_g; + 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) { @@ -3896,56 +3889,56 @@ Page({ 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 - }) - } - }) + + //--回调函数的用法-- + 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 - }) - + var th=this; + th.setData({ + sec_pick_index: index_c, + fir_pick_index: index_c + }) + }, //把选择的门店设置成默认的门店def_pick set_def_pick: function(e) { @@ -3962,76 +3955,76 @@ Page({ 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, - }) - } - }) + + //先设置之前,要判断是不是有库存 + 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() { @@ -4074,7 +4067,7 @@ Page({ //显示全部 toggleHandler: function(e) { var that = this, - index = e.currentTarget.dataset.index; + index = e.currentTarget.dataset.index; for (var i = 0; i < that.data.comments.length; i++) { if (index == i) { for (var i = 0; i < that.data.comments.length; i++) { @@ -4091,7 +4084,7 @@ Page({ //收起更多 toggleContent: function(e) { var that = this, - index = e.currentTarget.dataset.index; + index = e.currentTarget.dataset.index; for (var i = 0; i < that.data.comments.length; i++) { if (index == i) { that.data.comments[index].auto = true; @@ -4105,84 +4098,82 @@ 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); - } - - var ob={"card_list":plusCard,"name_map":card_name_map}; - func(ob); - }) - }, - - go_plus:function(){ - getApp().goto("/pages/user/plus/plus"); - }, - go_card_info:function(){ - getApp().goto("/pages/user/cardinfo/cardinfo"); - }, - //-- 根据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; - } - } - }, - //-----显示优惠券的时候情况----- - show_more_cx:function () { - if(this.data.is_more_cx){ - this.setData({is_more_cx:0}); - }else{ - this.setData({is_more_cx:1}); + 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); + } + + var ob={"card_list":plusCard,"name_map":card_name_map}; + func(ob); + }) + }, + + go_plus:function(){ + getApp().goto("/pages/user/plus/plus"); + }, + go_card_info:function(){ + getApp().goto("/pages/user/cardinfo/cardinfo"); + }, + //-- 根据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; } + } + }, + //-----显示优惠券的时候情况----- + 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, - }) - } - }) + 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 51cdbff..fcd8e8e 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxml +++ b/pages/goods/goodsInfo/goodsInfo.wxml @@ -924,7 +924,7 @@ - {{sele_g.goods_name}} + {{sele_g.goods_name}} diff --git a/pages/goods/goodsInfo/goodsInfo.wxss b/pages/goods/goodsInfo/goodsInfo.wxss index a2a6bd2..65c49f1 100644 --- a/pages/goods/goodsInfo/goodsInfo.wxss +++ b/pages/goods/goodsInfo/goodsInfo.wxss @@ -555,7 +555,7 @@ border-radius: 0 56rpx 55rpx 0; .spec-goods-name { font-size: 30rpx; line-height: 35rpx; - height: 35rpx; + height: 70rpx; margin: 15rpx 20rpx 25rpx 0; overflow: hidden; text-overflow: ellipsis;color: #333; @@ -2454,7 +2454,7 @@ width: 20rpx; height: 20rpx; } .xc-val-money{ - height:80rpx; + height:55rpx; } .xc-distance-bottom{ diff --git a/pages/tabbar/tabbar.wxml b/pages/tabbar/tabbar.wxml index 4e29db7..53a2613 100644 --- a/pages/tabbar/tabbar.wxml +++ b/pages/tabbar/tabbar.wxml @@ -76,7 +76,7 @@ - + {{tabBar.cartGoodsNum}} @@ -86,7 +86,7 @@ - + {{tabBar.cartGoodsNum}} diff --git a/setting.js b/setting.js index d577309..80acfc8 100644 --- a/setting.js +++ b/setting.js @@ -1,4 +1,5 @@ module.exports = { +<<<<<<< HEAD appName: "美得得商户中心", versionCode: "1.3.1", appLogo: "../../../images/logo.png", @@ -7,4 +8,20 @@ module.exports = { imghost: "https://mshopimg.yolipai.net/", share: {}, stoid: 197, -}; \ No newline at end of file +}; +======= + appName: "派派通", + versionCode: "1.0.0", + appLogo: "../../../images/logo.png", + // url: "https://test-weshop.yolipai.net", + url: "https://test-weshop.xinda100.cn", + //url:"https://weshop.yolipai.net", //外网的网址 + //url:"http://172.20.3.121:8085", //明海的网址 + //url:"http://172.20.3.102:8085", //自己的网址 + banner_err:"../../../images/del/logo.png", + imghost: "https://mshopimg.yolipai.net/", + share: {}, + stoid:1, + +}; +>>>>>>> 8cacb258d4c661260d724d7c9869476049e432e2 diff --git a/utils/filter.wxs b/utils/filter.wxs index aa3ba54..93eddaf 100644 --- a/utils/filter.wxs +++ b/utils/filter.wxs @@ -1,49 +1,68 @@ var filters = { - toFix:function(val,count){ - val=parseFloat(val); - return val.toFixed(count) - }, - replace_time:function(val){ - if(!val) return "不限"; - return val.replace("00:00:00",""); - }, - - replace_time2: function (val) { - if(val==null || val==undefined || val=='') return ""; - var a = val.split(" "); - return a[0]; - }, + toFix: function (val, count) { + val = parseFloat(val); + return val.toFixed(count) + }, + replace_time: function (val) { + if (!val) return "不限"; + return val.replace("00:00:00", ""); + }, - format_time:function(ts,isFull) { - if(ts==null || ts==undefined || ts=='') return ""; - var d = getDate(ts*1000) - var fm=[d.getFullYear(), d.getMonth()+1, d.getDate()].join('-'); - if(isFull==1) - fm=fm + ' '+ [d.getHours(), d.getMinutes(), d.getSeconds()].join(':') - return fm; - }, + replace_time2: function (val) { + if (val == null || val == undefined || val == '') return ""; + var a = val.split(" "); + return a[0]; + }, - pInt:function(t) { - var d = parseInt(t); return d; - }, + format_time: function (ts, isFull) { + // 如果数值位数为1,则补0 + function appendZero(obj) { + if (obj < 10) { + return "0" + "" + obj; + } else { + return obj; + } + }; + + if (ts == null || ts == undefined || ts == '') return ""; + var d = getDate(ts * 1000) + var fm = [d.getFullYear(), d.getMonth() + 1, d.getDate()].join('-'); + var md = (d.getMonth() + 1) + '月' + d.getDate() + '日'; + if (isFull == 1) + fm = fm + ' ' + [d.getHours(), d.getMinutes(), d.getSeconds()].join(':'); + if (isFull == 2) { + fm = md + ' ' + [appendZero(d.getHours()), appendZero(d.getMinutes())].join(':'); + } + return fm; + }, + + pInt: function (t) { + var d = parseInt(t); + return d; + }, + + show_gui_ge: function (spec, color) { + if ((spec == "" || spec == null || spec == "null")) { + if ((color == "" || color == null || color == "null")) { + return "规格1"; + } else { + return color; + } + } else { + if ((color == "" || color == null || color == "null")) { + return spec; + } else { + return spec + "/" + color; + } + } + } +}; - show_gui_ge:function(spec,color){ - if((spec=="" || spec==null || spec=="null")){ - if((color=="" || color==null || color=="null")){ return "规格1"; - }else{return color; } - }else{ - if((color=="" || color==null || color=="null")){ return spec; - }else{ return spec+"/"+color; } - } - }, - - -} module.exports = { - toFix: filters.toFix, - replace_time:filters.replace_time, - replace_time2: filters.replace_time2, - format_time:filters.format_time, - pInt:filters.pInt, - show_gui_ge:filters.show_gui_ge, + toFix: filters.toFix, + replace_time: filters.replace_time, + replace_time2: filters.replace_time2, + format_time: filters.format_time, + pInt: filters.pInt, + show_gui_ge: filters.show_gui_ge, } \ No newline at end of file diff --git a/utils/myUtils.wxs b/utils/myUtils.wxs index bf9f277..8983b98 100644 --- a/utils/myUtils.wxs +++ b/utils/myUtils.wxs @@ -8,7 +8,7 @@ var myUtils = { break; } case '102': { - statusText = '未开始'; + statusText = '即将开始'; break; } case '103': {