Commit 64128ee33546daacf0fafd16c6c05475d8501167

Authored by antploy
1 parent eef50d4a

会员权益免费领取

components/qr_code/qr_code.js
@@ -24,6 +24,7 @@ Component({ @@ -24,6 +24,7 @@ Component({
24 //关闭 24 //关闭
25 close: function (e) { 25 close: function (e) {
26 this.setData({q_show: 0,barcode_canvas:null,qrcode_canvas:null }); 26 this.setData({q_show: 0,barcode_canvas:null,qrcode_canvas:null });
  27 + this.triggerEvent('close',{},{bubbles: true});
27 }, 28 },
28 29
29 //打开 30 //打开
pages/user/index/index.js
@@ -652,7 +652,8 @@ Page({ @@ -652,7 +652,8 @@ Page({
652 getApp().goto("/pages/user/user_fw/user_fw?gradeId=" + th.data.gradeId + "&FormId=" + item.Id); 652 getApp().goto("/pages/user/user_fw/user_fw?gradeId=" + th.data.gradeId + "&FormId=" + item.Id);
653 break; 653 break;
654 case "03": 654 case "03":
655 - getApp().goto("/pages/user/user_spsy/user_spsy"); 655 + getApp().goto("/pages/user/user_spsy/user_spsy?img=" +
  656 + url + "&gradeId=" + th.data.gradeId + "&FormId=" + item.Id);
656 break; 657 break;
657 case "10": 658 case "10":
658 getApp().request.get("/api/weshop/users/grade/vipprivilegelist/other/get", { 659 getApp().request.get("/api/weshop/users/grade/vipprivilegelist/other/get", {
pages/user/user_spsy/user_spsy.js
1 // pages/user/usersy/usersy.js 1 // pages/user/usersy/usersy.js
2 -var e = getApp(),os = e.globalData.setting;  
3 -var utils = require('../../../utils/util.js'); 2 +var e = getApp(),
  3 + os = e.globalData.setting;
  4 +var ut = require('../../../utils/util');
4 var regeneratorRuntime = require('../../../utils/runtime.js'); 5 var regeneratorRuntime = require('../../../utils/runtime.js');
5 6
6 Page({ 7 Page({
@@ -8,27 +9,100 @@ Page({ @@ -8,27 +9,100 @@ Page({
8 * 页面的初始数据 9 * 页面的初始数据
9 */ 10 */
10 data: { 11 data: {
11 - qr_code_object:{val:"12121",content:"请将二维码展示给核销员,取货更快捷!"},  
12 - xp_list:null,  
13 - iurl:os.imghost, 12 + qr_code_object: {},
  13 + xp_list: null,
  14 + iurl: os.imghost,
  15 + page: 1,
  16 + isLoading: 0,
  17 + no_more: 0,
  18 + is_use:0 //领取状态
14 }, 19 },
15 /** 20 /**
16 * 生命周期函数--监听页面加载 21 * 生命周期函数--监听页面加载
17 */ 22 */
18 - onLoad: function (options) { }, 23 + onLoad: function (options) {
  24 + var h_pic = options.img;
  25 + if (h_pic.indexOf("http") == -1) {
  26 + h_pic = os.imghost + h_pic;
  27 + }
  28 + var FormId = options.FormId;
  29 + var GradeId = options.gradeId;
  30 + var now = ut.gettimestamp();
  31 + this.setData({
  32 + h_pic,
  33 + GradeId,
  34 + FormId,
  35 + now,
  36 + });
  37 + this.requestData()
  38 + this.getQrCode(FormId)
  39 + },
19 /** 40 /**
20 * 生命周期函数--监听页面显示 41 * 生命周期函数--监听页面显示
21 */ 42 */
22 - onShow:async function () {  
23 - var th = this;  
24 - var xp_list=null;  
25 - //--获取列表--  
26 - await getApp().request.promiseGet("http://172.20.3.102:8080/api/user_qy/xp_list", {  
27 - 1: 1  
28 - }).then(res => {  
29 - xp_list = res.data;  
30 - })  
31 - th.setData({xp_list:xp_list}); 43 + onShow: function () {
  44 +
  45 +
  46 + },
  47 + async getQrCode(id) {
  48 + const res = await getApp().request.promiseGet("/api/weshop/users/grade/wares/code/get", {
  49 + data: {
  50 + privilegeId: id,
  51 + storeId: os.stoid,
  52 + userId: getApp().globalData.user_id,
  53 + },
  54 + });
  55 + if (res.data.code == 0 && res.data.data) {
  56 + if(res.data.data.VerifyDate || res.data.data.VerifyNo){
  57 + this.setData({
  58 + is_use:1
  59 + })
  60 + }else{
  61 + this.setData({
  62 + qr_code_object: res.data.data,
  63 + })
  64 + }
  65 + }
  66 + },
  67 + async requestData() {
  68 + if (this.data.no_more) return false;
  69 + if (this.data.isLoading) return false;
  70 + this.data.isLoading = 1;
  71 + let {
  72 + GradeId,
  73 + FormId,
  74 + page,
  75 + xp_list
  76 + } = this.data;
  77 + let req_data = {
  78 + page,
  79 + GradeId,
  80 + FormId,
  81 + storeId: os.stoid,
  82 + userId: getApp().globalData.user_id,
  83 + }
  84 + const res = await getApp().request.promiseGet("/api/weshop/users/grade/wechat/wares/page", {
  85 + data: req_data
  86 + });
  87 +
  88 + if (ut.ajax_ok(res)) {
  89 + if (res.data.data.page > 1) {
  90 + xp_list = xp_list.concat(res.data.data.pageData);
  91 + } else {
  92 + xp_list = res.data.data.pageData;
  93 + }
  94 + this.setData({
  95 + xp_list,
  96 + isLoading: 0,
  97 + no_more: 0,
  98 + })
  99 + } else {
  100 + this.setData({
  101 + xp_list: [],
  102 + isLoading: 0,
  103 + no_more: 0,
  104 + })
  105 + }
32 }, 106 },
33 /** 107 /**
34 * 页面上拉触底事件的处理函数 108 * 页面上拉触底事件的处理函数
@@ -46,26 +120,36 @@ Page({ @@ -46,26 +120,36 @@ Page({
46 120
47 121
48 /*-- 打开服务项目 --*/ 122 /*-- 打开服务项目 --*/
49 - open_xp:function (e) {  
50 - var th=this; 123 + open_xp: function (e) {
  124 + var th = this;
51 var qc_com = this.selectComponent("#qc_com"); //组件的id 125 var qc_com = this.selectComponent("#qc_com"); //组件的id
52 qc_com.open(th.data.qr_code_object) 126 qc_com.open(th.data.qr_code_object)
53 }, 127 },
54 128
55 //--领取商品-- 129 //--领取商品--
56 - get_xp:function (e) {  
57 - var th=this,index=e.currentTarget.dataset.ind;  
58 - getApp().request.post("http://172.20.3.102:8080/api/user_qy/get_gd",{  
59 - data:{},  
60 - success:function (e) {  
61 - if(e.data.code==0){  
62 - var txt="xp_list["+index+"].is_get"  
63 - var obj={};obj[txt]=1;  
64 - th.setData(obj);  
65 - }  
66 - } 130 + async show_hxm(e) {
  131 + let qr_code_object = this.data.qr_code_object;
  132 + if (qr_code_object !== {}) {
  133 + let { Number: val, BeginDate, EndDate} = qr_code_object;
  134 + let qr_code = this.selectComponent("#qc_com");
  135 + let obj = {
  136 + val,
  137 + content: "请将二维码展示给核销员,抵券更快捷",
  138 + now: BeginDate,
  139 + validay: EndDate,
  140 + is_quan: 1,
  141 + };
  142 + qr_code.open(obj)
  143 + }else{
  144 + wx.showToast({
  145 + title: "获取失败",
  146 + icon: 'none',
  147 + duration: 1000
67 }) 148 })
68 - }  
69 - 149 + }
  150 + },
70 151
  152 + close:function (){
  153 + this.getQrCode(this.data.FormId)
  154 + }
71 }) 155 })
72 \ No newline at end of file 156 \ No newline at end of file
pages/user/user_spsy/user_spsy.json
1 { 1 {
2 - "navigationBarTitleText": "新品试用", 2 + "navigationBarTitleText": "免费领取",
3 "usingComponents": { 3 "usingComponents": {
4 "qr_code": "/components/qr_code/qr_code" 4 "qr_code": "/components/qr_code/qr_code"
5 } 5 }
pages/user/user_spsy/user_spsy.wxml
1 -<view class="xc-page" >  
2 - <view class="items" wx:for="{{xp_list}}">  
3 - <view class="rel">  
4 - <image class="new-product" src="{{iurl+item.img}}"></image>  
5 - <image wx:if="{{item.is_get}}" class="abs zimg" src="{{iurl}}/miniapp//images/userqy/isgeted.png"></image>  
6 - </view>  
7 -  
8 - <view class="product-explain three-level-word">{{item.goods_name}}</view>  
9 - <view class="xc-bottom flex">  
10 - <view class="xc-goods-money three-level-word ">¥  
11 - </view>  
12 - <view class="xc-money">  
13 - {{item.goods_price}}  
14 - </view>  
15 - <view class="xc-clike-get t-c white" data-ind="{{index}}" bindtap="open_xp" wx:if="{{item.is_get}}">立即使用</view>  
16 - <view class="xc-clike-get t-c white" data-ind="{{index}}" bindtap="get_xp" wx:else>免费领取</view>  
17 - </view>  
18 -</view> 1 +<view>
  2 + <image class="xc-coupon-img" src="{{h_pic}}"></image>
  3 + <view class="flex pd20 jc_sb fs28">
  4 + <view>单品名称</view>
  5 + <view>数量</view>
  6 + </view>
  7 + <view class="flex pd20 jc_sb fs26" wx:for="{{xp_list}}" wx:key="id">
  8 + <view>{{item.PrivilegeName}}</view>
  9 + <view class="c-a4">x{{item.SecondNo}}</view>
  10 + </view>
  11 + <view class="btn-container">
  12 + <!-- <view wx:if="{{details.isget}}" data-type="1" class="btn" style="background-color:#aaa;color: #fff">
  13 + 已使用{{list[0].freebh}}
  14 + </view> -->
  15 + <view wx:if="{{is_use}}" class="btn">已使用</view>
  16 + <view wx:else bindtap="show_hxm" data-type="1" class="btn">立即使用</view>
  17 + <!-- <view bindtap="right_use" class="btn">立即使用</view></view> -->
  18 + </view>
19 </view> 19 </view>
20 20
21 <!-- 弹出框扫描 --> 21 <!-- 弹出框扫描 -->
22 -<qr_code id="qc_com"></qr_code>  
23 -  
24 -  
25 -  
26 -  
27 -  
28 - 22 +<qr_code id="qc_com" bindclose="close"></qr_code>
29 \ No newline at end of file 23 \ No newline at end of file
pages/user/user_spsy/user_spsy.wxss
@@ -3,66 +3,28 @@ page{ @@ -3,66 +3,28 @@ page{
3 height: 100%; 3 height: 100%;
4 background:#f4f5fa; 4 background:#f4f5fa;
5 } 5 }
6 -.xc-page{  
7 - width: 100%;  
8 - height: 100%;  
9 - background: #f4f5fa;  
10 -}  
11 -.xc-page .items{  
12 - display: inline-block;  
13 - width: 345rpx;  
14 - height:450rpx;  
15 - margin-left:20rpx;  
16 - margin-top: 25rpx;  
17 - border-radius: 15rpx;  
18 - background:#fff;  
19 -}  
20 -  
21 -.xc-page .items .zimg{  
22 - width: 120rpx;  
23 - height: 120rpx;  
24 - left:50%; top:50%;  
25 - margin-left: -60rpx; margin-top: -60rpx;  
26 -}  
27 -  
28 6
29 -.new-product{  
30 - width:345rpx;  
31 - height:325rpx;  
32 - border-radius:15rpx 15rpx 0 0;  
33 -}  
34 -.product-explain{  
35 - width: 90%;  
36 - word-break:break-all;  
37 - height: 40rpx;  
38 - margin-left:15rpx;  
39 -  
40 -}  
41 -.xc-bottom{  
42 - margin-top: 13rpx; 7 +.xc-coupon-img{
43 width: 100%; 8 width: 100%;
44 - margin-left: 15rpx;  
45 -}  
46 -  
47 -.xc-bottom .xc-goods-money{  
48 -color: #ca4e59;  
49 - padding-top: 12rpx;  
50 -}  
51 -.xc-bottom .xc-money{  
52 - color: #ca4e59;  
53 - font-size: 40rpx;  
54 - height: 100%;  
55 - line-height:50rpx 9 + height: 330rpx;
  10 +}
  11 +.btn-container {
  12 + position: fixed;
  13 + left: 0;
  14 + bottom: 0;
  15 + width: 100%;
  16 + /* padding: 20rpx 30rpx; */
  17 + box-sizing: border-box;
  18 + background-color: white;
  19 + border-top: 2rpx solid #f2f2f2;
  20 + z-index: 1;
56 } 21 }
57 22
58 -.xc-clike-get{  
59 - width: 120rpx;  
60 - height: 36rpx;  
61 - border-radius: 20rpx;  
62 - background: #ca4e59;  
63 - line-height:28rpx;  
64 - font-size:27rpx;  
65 - margin-left: 120rpx;  
66 -padding-top: 10rpx 23 +.btn {
  24 + background-color: #FF6768;
  25 + color: white;
  26 + padding: 26rpx;
  27 + text-align: center;
  28 + /* border-radius: 8rpx; */
67 } 29 }
68 30
pages/user/userqy/userqy.js
@@ -197,7 +197,7 @@ Page({ @@ -197,7 +197,7 @@ Page({
197 getApp().goto("/pages/user/user_fw/user_fw?gradeId="+th.data.gradeId+"&FormId="+item.Id); 197 getApp().goto("/pages/user/user_fw/user_fw?gradeId="+th.data.gradeId+"&FormId="+item.Id);
198 break; 198 break;
199 case "03": 199 case "03":
200 - getApp().goto("/pages/user/user_spsy/user_spsy"); 200 + getApp().goto("/pages/user/user_spsy/user_spsy?img="+url+"&gradeId="+th.data.gradeId+"&FormId="+item.Id);
201 break; 201 break;
202 case "10": 202 case "10":
203 getApp().request.get("/api/weshop/users/grade/vipprivilegelist/other/get",{ 203 getApp().request.get("/api/weshop/users/grade/vipprivilegelist/other/get",{