diff --git a/components/qr_code/qr_code.js b/components/qr_code/qr_code.js index c46b356..812d7c8 100644 --- a/components/qr_code/qr_code.js +++ b/components/qr_code/qr_code.js @@ -24,6 +24,7 @@ Component({ //关闭 close: function (e) { this.setData({q_show: 0,barcode_canvas:null,qrcode_canvas:null }); + this.triggerEvent('close',{},{bubbles: true}); }, //打开 diff --git a/pages/user/index/index.js b/pages/user/index/index.js index 7b79d40..f16b45b 100644 --- a/pages/user/index/index.js +++ b/pages/user/index/index.js @@ -652,7 +652,8 @@ Page({ getApp().goto("/pages/user/user_fw/user_fw?gradeId=" + th.data.gradeId + "&FormId=" + item.Id); break; case "03": - getApp().goto("/pages/user/user_spsy/user_spsy"); + getApp().goto("/pages/user/user_spsy/user_spsy?img=" + + url + "&gradeId=" + th.data.gradeId + "&FormId=" + item.Id); break; case "10": getApp().request.get("/api/weshop/users/grade/vipprivilegelist/other/get", { diff --git a/pages/user/user_spsy/user_spsy.js b/pages/user/user_spsy/user_spsy.js index e43903d..b94b66f 100644 --- a/pages/user/user_spsy/user_spsy.js +++ b/pages/user/user_spsy/user_spsy.js @@ -1,6 +1,7 @@ // pages/user/usersy/usersy.js -var e = getApp(),os = e.globalData.setting; -var utils = require('../../../utils/util.js'); +var e = getApp(), + os = e.globalData.setting; +var ut = require('../../../utils/util'); var regeneratorRuntime = require('../../../utils/runtime.js'); Page({ @@ -8,27 +9,100 @@ Page({ * 页面的初始数据 */ data: { - qr_code_object:{val:"12121",content:"请将二维码展示给核销员,取货更快捷!"}, - xp_list:null, - iurl:os.imghost, + qr_code_object: {}, + xp_list: null, + iurl: os.imghost, + page: 1, + isLoading: 0, + no_more: 0, + is_use:0 //领取状态 }, /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) { }, + onLoad: function (options) { + var h_pic = options.img; + if (h_pic.indexOf("http") == -1) { + h_pic = os.imghost + h_pic; + } + var FormId = options.FormId; + var GradeId = options.gradeId; + var now = ut.gettimestamp(); + this.setData({ + h_pic, + GradeId, + FormId, + now, + }); + this.requestData() + this.getQrCode(FormId) + }, /** * 生命周期函数--监听页面显示 */ - onShow:async function () { - var th = this; - var xp_list=null; - //--获取列表-- - await getApp().request.promiseGet("http://172.20.3.102:8080/api/user_qy/xp_list", { - 1: 1 - }).then(res => { - xp_list = res.data; - }) - th.setData({xp_list:xp_list}); + onShow: function () { + + + }, + async getQrCode(id) { + const res = await getApp().request.promiseGet("/api/weshop/users/grade/wares/code/get", { + data: { + privilegeId: id, + storeId: os.stoid, + userId: getApp().globalData.user_id, + }, + }); + if (res.data.code == 0 && res.data.data) { + if(res.data.data.VerifyDate || res.data.data.VerifyNo){ + this.setData({ + is_use:1 + }) + }else{ + this.setData({ + qr_code_object: res.data.data, + }) + } + } + }, + async requestData() { + if (this.data.no_more) return false; + if (this.data.isLoading) return false; + this.data.isLoading = 1; + let { + GradeId, + FormId, + page, + xp_list + } = this.data; + let req_data = { + page, + GradeId, + FormId, + storeId: os.stoid, + userId: getApp().globalData.user_id, + } + const res = await getApp().request.promiseGet("/api/weshop/users/grade/wechat/wares/page", { + data: req_data + }); + + if (ut.ajax_ok(res)) { + if (res.data.data.page > 1) { + xp_list = xp_list.concat(res.data.data.pageData); + } else { + xp_list = res.data.data.pageData; + } + this.setData({ + xp_list, + isLoading: 0, + no_more: 0, + }) + } else { + this.setData({ + xp_list: [], + isLoading: 0, + no_more: 0, + }) + } }, /** * 页面上拉触底事件的处理函数 @@ -46,26 +120,36 @@ Page({ /*-- 打开服务项目 --*/ - open_xp:function (e) { - var th=this; + open_xp: function (e) { + var th = this; var qc_com = this.selectComponent("#qc_com"); //组件的id qc_com.open(th.data.qr_code_object) }, //--领取商品-- - get_xp:function (e) { - var th=this,index=e.currentTarget.dataset.ind; - getApp().request.post("http://172.20.3.102:8080/api/user_qy/get_gd",{ - data:{}, - success:function (e) { - if(e.data.code==0){ - var txt="xp_list["+index+"].is_get" - var obj={};obj[txt]=1; - th.setData(obj); - } - } + async show_hxm(e) { + let qr_code_object = this.data.qr_code_object; + if (qr_code_object !== {}) { + let { Number: val, BeginDate, EndDate} = qr_code_object; + let qr_code = this.selectComponent("#qc_com"); + let obj = { + val, + content: "请将二维码展示给核销员,抵券更快捷", + now: BeginDate, + validay: EndDate, + is_quan: 1, + }; + qr_code.open(obj) + }else{ + wx.showToast({ + title: "获取失败", + icon: 'none', + duration: 1000 }) - } - + } + }, + close:function (){ + this.getQrCode(this.data.FormId) + } }) \ No newline at end of file diff --git a/pages/user/user_spsy/user_spsy.json b/pages/user/user_spsy/user_spsy.json index 468dc50..678c7b1 100644 --- a/pages/user/user_spsy/user_spsy.json +++ b/pages/user/user_spsy/user_spsy.json @@ -1,5 +1,5 @@ { - "navigationBarTitleText": "新品试用", + "navigationBarTitleText": "免费领取", "usingComponents": { "qr_code": "/components/qr_code/qr_code" } diff --git a/pages/user/user_spsy/user_spsy.wxml b/pages/user/user_spsy/user_spsy.wxml index 1fb85c4..a785fb0 100644 --- a/pages/user/user_spsy/user_spsy.wxml +++ b/pages/user/user_spsy/user_spsy.wxml @@ -1,28 +1,22 @@ - - - - - - - - {{item.goods_name}} - - ¥ - - - {{item.goods_price}} - - 立即使用 - 免费领取 - - + + + + 单品名称 + 数量 + + + {{item.PrivilegeName}} + x{{item.SecondNo}} + + + + 已使用 + 立即使用 + + - - - - - - - + \ No newline at end of file diff --git a/pages/user/user_spsy/user_spsy.wxss b/pages/user/user_spsy/user_spsy.wxss index ec604ef..c53c4af 100644 --- a/pages/user/user_spsy/user_spsy.wxss +++ b/pages/user/user_spsy/user_spsy.wxss @@ -3,66 +3,28 @@ page{ height: 100%; background:#f4f5fa; } -.xc-page{ - width: 100%; - height: 100%; - background: #f4f5fa; -} -.xc-page .items{ - display: inline-block; - width: 345rpx; - height:450rpx; - margin-left:20rpx; - margin-top: 25rpx; - border-radius: 15rpx; - background:#fff; -} - -.xc-page .items .zimg{ - width: 120rpx; - height: 120rpx; - left:50%; top:50%; - margin-left: -60rpx; margin-top: -60rpx; -} - -.new-product{ - width:345rpx; - height:325rpx; - border-radius:15rpx 15rpx 0 0; -} -.product-explain{ - width: 90%; - word-break:break-all; - height: 40rpx; - margin-left:15rpx; - -} -.xc-bottom{ - margin-top: 13rpx; +.xc-coupon-img{ width: 100%; - margin-left: 15rpx; -} - -.xc-bottom .xc-goods-money{ -color: #ca4e59; - padding-top: 12rpx; -} -.xc-bottom .xc-money{ - color: #ca4e59; - font-size: 40rpx; - height: 100%; - line-height:50rpx + height: 330rpx; +} +.btn-container { + position: fixed; + left: 0; + bottom: 0; + width: 100%; + /* padding: 20rpx 30rpx; */ + box-sizing: border-box; + background-color: white; + border-top: 2rpx solid #f2f2f2; + z-index: 1; } -.xc-clike-get{ - width: 120rpx; - height: 36rpx; - border-radius: 20rpx; - background: #ca4e59; - line-height:28rpx; - font-size:27rpx; - margin-left: 120rpx; -padding-top: 10rpx +.btn { + background-color: #FF6768; + color: white; + padding: 26rpx; + text-align: center; + /* border-radius: 8rpx; */ } diff --git a/pages/user/userqy/userqy.js b/pages/user/userqy/userqy.js index 9a244d0..f1654ab 100644 --- a/pages/user/userqy/userqy.js +++ b/pages/user/userqy/userqy.js @@ -197,7 +197,7 @@ Page({ getApp().goto("/pages/user/user_fw/user_fw?gradeId="+th.data.gradeId+"&FormId="+item.Id); break; case "03": - getApp().goto("/pages/user/user_spsy/user_spsy"); + getApp().goto("/pages/user/user_spsy/user_spsy?img="+url+"&gradeId="+th.data.gradeId+"&FormId="+item.Id); break; case "10": getApp().request.get("/api/weshop/users/grade/vipprivilegelist/other/get",{