diff --git a/app.js b/app.js index 16afc9e..cc2b2b6 100644 --- a/app.js +++ b/app.js @@ -165,8 +165,9 @@ App({ } } }) - - + + //获取一下门店的基本信息 + this.getConfig(); }, //---初始化第三方---- @@ -216,7 +217,7 @@ App({ return false; } if(this.globalData.config==undefined) this.globalData.config=null; - this.globalData.config ? "function" == typeof t && t(this.globalData.config) : e.request.get("/api/weshop/store/get/" + e.globalData.setting.stoid, { + this.globalData.config ? "function" == typeof t && t(this.globalData.config) : e.requestGet("/api/weshop/store/get/" + e.globalData.setting.stoid, { success: function(o) { console.log('getConfig'); if(o.data.code==0){ @@ -677,6 +678,27 @@ App({ }) }) }, + + + //---promise的使用get---- + requestGet:function(url,data){ + if(url.indexOf("http")==-1) url=this.globalData.setting.url +url; + data.isShowLoading && wx.showLoading(); + wx.request({ + url, + method: 'GET', + header: {"content-type": "application/x-www-form-urlencoded" }, + data:data.data, + success(res) { + data.isShowLoading && wx.hideLoading(); + data.success(res); + }, + fail(err) { + data.isShowLoading && wx.hideLoading(); + if(data.fail) data.fail(err); + } + }) + }, // 判断是否登录 diff --git a/components/qr_code/qr_code.wxss b/components/qr_code/qr_code.wxss index 50d62ba..084783b 100644 --- a/components/qr_code/qr_code.wxss +++ b/components/qr_code/qr_code.wxss @@ -57,10 +57,11 @@ left: 0rpx; .barcode { height:150rpx; width: 620rpx; - text-align:center; position:absolute; - left: 30rpx + left: 30rpx; + top: -6rpx; + } canvas{ width:100%; @@ -83,6 +84,7 @@ display:flex; flex-direction:column; position: absolute; left: 75rpx; +top: 5rpx; } .qrcode{ diff --git a/packageA/pages/hongBao/hongBao.js b/packageA/pages/hongBao/hongBao.js index b02e4b0..32bd064 100644 --- a/packageA/pages/hongBao/hongBao.js +++ b/packageA/pages/hongBao/hongBao.js @@ -34,9 +34,15 @@ Page({ .then(function(data) { self.data.hongBaoData = data.data.data; self.countDown(); - self.setData({ - storeName: app.globalData.config.store_name - }); + setTimeout(function (){ + if(app.globalData.config && app.globalData.config.store_name){ + self.setData({ + storeName: app.globalData.config.store_name + }); + } + + },1000) + }); }); diff --git a/packageA/pages/myGift/myGift.js b/packageA/pages/myGift/myGift.js index 2f77488..593a01c 100644 --- a/packageA/pages/myGift/myGift.js +++ b/packageA/pages/myGift/myGift.js @@ -47,6 +47,9 @@ Page({ */ onLoad: function (options) { self = this; + if(options.index){ + this.setData({currentIndex:1}); //查看我的礼包 + } app.isLogin().then(function(data) {//进入页面前已经授权登录成功 self.setData({ userInfo: data, @@ -57,9 +60,7 @@ Page({ /** * 生命周期函数--监听页面初次渲染完成 */ - onReady: function () { - - }, + onReady: function () {}, /** * 生命周期函数--监听页面显示 @@ -72,11 +73,26 @@ Page({ imghost: app.globalData.setting.imghost, isLogin: true, }); - - this.getData(true, '/api/weshop/libao/libaoForm/page', { + + var index=this.data.currentIndex; + let url = ''; + let data = { store_id: app.globalData.setting.stoid, user_id: app.globalData.user_id, - }); + }; + this.setData({ + list: null, + pageNum: 1, + noMore: false, + }); + + if(index == 0) { + url = '/api/weshop/libao/libaoForm/page'; + } else if(index == 1) { + url = '/api/weshop/libao/libaoFormvip/page'; + }; + + this.getData(true, url, data); }; }; }, diff --git a/packageA/pages/myGiftDetails/myGiftDetails.js b/packageA/pages/myGiftDetails/myGiftDetails.js index 344ea64..f0f4798 100644 --- a/packageA/pages/myGiftDetails/myGiftDetails.js +++ b/packageA/pages/myGiftDetails/myGiftDetails.js @@ -1,6 +1,7 @@ // packageA//pages/myGiftDetails/myGiftDetails.js const app = getApp(); let self = null; +var os = app.globalData.setting; Page({ @@ -8,7 +9,10 @@ Page({ * 页面的初始数据 */ data: { - + qr_code_object: { + val: "12121", + content: "请将二维码展示给核销员,服务更快捷!" + }, }, /** @@ -90,9 +94,11 @@ Page({ isShowLoading: true, }).then(function(res) { // console.log('res3-->', res); - self.setData({ - details: res.data.data.pageData[0], - }); + if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0){ + self.setData({ + details: res.data.data.pageData[0], + }); + } }); app.request.promiseGet('/api/weshop/libao/libaoListvip/page', { @@ -103,9 +109,15 @@ Page({ isShowLoading: true, }).then(function(res) { // console.log('res4-->', res); - self.setData({ - list: res.data.data.pageData, - }); + if(res.data.code==0 && res.data.data && res.data.data.pageData && res.data.data.pageData.length>0) { + var list_arr=res.data.data.pageData; + for(var i in list_arr){ + list_arr[i].alsonum= list_arr[i]['goods_num'] - list_arr[i]['usenum'];//剩余次数 + } + self.setData({ + list: res.data.data.pageData, + }); + } }); }; @@ -114,38 +126,148 @@ Page({ }; }, - /** - * 生命周期函数--监听页面隐藏 + /** + * 用户点击右上角分享 */ - onHide: function () { + onShareAppMessage: function () { }, - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { + //-- 礼包购买 -- + GetBuyPrice: function(e) { + var th = this,that=th; + var item=th.data.details; + var id = item.id; //活动id + var my_confirm = th.selectComponent("#my_confirm"); //组件的id + var user=getApp().globalData.userInfo; - }, + my_confirm.open( + "是否确定购买该礼包", + "取消", + "确定", + function() { + my_confirm.open_cancel(0); + }, + function() { + my_confirm.open_cancel(0); + var json = { + "lbid": id, //活动Id + "paytype": 2, //1=积分兑换 2=购买 + "store_id": os.stoid, //商家Id + "user_id": user.user_id, //用户ID + }; + var url = "/api/weshop/libao/libaoFormvip/libaoOrder"; + getApp().request.post(url, + { + data:json, + success:function(res) { + if (res.data.code == 0 && res.data.data) { + res = res.data.data; + wx.requestPayment({ + timeStamp: String(res.timeStamp), + nonceStr: res.nonceStr, + package: res.packageValue, + signType: res.signType, + paySign: res.paySign, + success: function(res) { + getApp().my_warnning("支付成功", 1, th); + setTimeout(function (){ + getApp().goto("/packageA/pages/libao_payment/payment?type=2"); + },1000) + }, + fail: function(res) { + getApp().my_warnning("取消支付", 0, th); + } + }); + } else { + getApp().my_warnning(res.data.msg, 0, th); + } + } + }) + }) + }, - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { + //-- 积分兑换 -- + GetBuyIntegral: function(e) { + var th = this,that=th; + var item=th.data.details; - }, + var id = item.id; //活动id + var my_confirm = th.selectComponent("#my_confirm"); //组件的id + var user=getApp().globalData.userInfo; + my_confirm.open( + "是否确定兑换该礼包", + "取消", + "确定", + function() { + my_confirm.open_cancel(0); + }, + function() { + my_confirm.open_cancel(0); + var json = { + "lbid": id, //活动Id + "paytype": 1, //1=积分兑换 2=购买 + "store_id": os.stoid, //商家Id + "user_id": user.user_id, //用户ID + }; + var url = "/api/weshop/libao/libaoFormvip/libaoOrder"; + getApp().request.post(url,{ + data:json, + success:function(res) { + if (res.data.code == 0) { + getApp().my_warnning("兑换成功!", 1, th); + setTimeout(function (){ + getApp().goto("/packageA/pages/libao_payment/payment?type=1"); + },1000) + } else { + getApp().my_warnning(res.data.msg, 0, th); + } + }, + }) - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { + }) + }, - }, + //显示二维码,进行核销 + show_hxm:function (e){ + var th=this; + var type=e.currentTarget.dataset.type; + var data={}; + data.store_id=os.stoid; + data.user_id=getApp().globalData.user_id; + + if(type && parseInt(type)==1){ + data.id=this.data.id; + data.type=1; + }else{ + var index=e.currentTarget.dataset.index; + var item=this.data.list[index]; + data.id=item.id; + data.type=2; + } + + //获取二维码 + getApp().request.get("/api/weshop/libao/libaoListvip/getLibaoCode",{ + data:data, + success:function (res){ + if(res.data.code==0){ + th.data.qr_code_object.val=res.data.data; + var qc_com = th.selectComponent("#qrcode"); //组件的id + qc_com.open(th.data.qr_code_object) + }else{ + wx.showToast({ + title: res.data.msg, + icon: 'none', + duration: 2000 + }) + + + + } + } + }) + + } - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - } }) \ No newline at end of file diff --git a/packageA/pages/myGiftDetails/myGiftDetails.json b/packageA/pages/myGiftDetails/myGiftDetails.json index c41d9ba..454ab13 100644 --- a/packageA/pages/myGiftDetails/myGiftDetails.json +++ b/packageA/pages/myGiftDetails/myGiftDetails.json @@ -3,6 +3,8 @@ "enablePullDownRefresh": false, "usingComponents": { "warn": "/components/long_warn/long_warn", - "nav_b": "/components/nav_b/nav_b" + "nav_b": "/components/nav_b/nav_b", + "my_confirm": "/components/my_confirm/my_confirm", + "qrcode":"/components/qr_code/qr_code" } } \ No newline at end of file diff --git a/packageA/pages/myGiftDetails/myGiftDetails.wxml b/packageA/pages/myGiftDetails/myGiftDetails.wxml index fb7d720..1dfade2 100644 --- a/packageA/pages/myGiftDetails/myGiftDetails.wxml +++ b/packageA/pages/myGiftDetails/myGiftDetails.wxml @@ -20,7 +20,28 @@ 可到线下门店兑换以下单品 - + + + 单品名称 + 总数量 + 剩余数量 + + + + {{item.goods_name}} + x{{item.goods_num}} + x{{item.alsonum}} + + 使用 + + + 已领 + + + + + + 单品名称 数量 @@ -35,9 +56,15 @@ - 立即兑换 - 立即购买 + 立即兑换 + 立即购买 - 立即使用 + 立即使用 + + + + + + diff --git a/packageA/pages/myGiftDetails/myGiftDetails.wxss b/packageA/pages/myGiftDetails/myGiftDetails.wxss index 23bdcaf..2431c64 100644 --- a/packageA/pages/myGiftDetails/myGiftDetails.wxss +++ b/packageA/pages/myGiftDetails/myGiftDetails.wxss @@ -76,4 +76,9 @@ page { .btn.pink { background-color: #FACAD6; color: #FF6768; -} \ No newline at end of file +} + +.ling_btn{ background: #c0283a; color: #fff; width: 100rpx; height: 50rpx; + display: inline-block; line-height: 50rpx; border-radius: 10rpx} + +.ling_btn.c_a{ background: darkgrey} \ No newline at end of file