wxml
<!--優(yōu)惠券——開(kāi)始-->
<view class='MK_youhui'>
? <view class='MK_youhuibt'>領(lǐng)券再購(gòu) 千券放送</view>
? <scroll-view style=" white-space: nowrap; display: flex" class='MK_youhui_jue' scroll-left="{{scrollLeft}}" scroll-x="true">
? ? ? <view wx:for="{{MK_youhui}}" wx:key="unique" data-Aid="{{item.Aid}}" bindtap='lingjue' class='a1'>
? ? ? ? <image src='../../images/MK_youhui01.jpg'></image>
? ? ? ? <view class='MK_youhui_juenr'>
? ? ? ? ? <view>{{item.Qmoney}}</view>
? ? ? ? ? <view>元</view>
? ? ? ? ? <view>滿{{item.QxzMoney}}使用</view>
? ? ? ? </view>
? ? ? </view>
? ? ? <view class='zwsj' style="display:{{MK_youhui==0?'block':'none'}}">暫無(wú)優(yōu)惠券</view>
? </scroll-view>
</view>
<!--優(yōu)惠券——結(jié)束-->
js
//優(yōu)惠券
? yhj:function(){
? ? var that=this;
? ? wx.request({
? ? ? url: '' + app.information.host + '/api/json/vouchers/vouchers.ashx?action=coupon&companyid=' + app.information.companyid,
? ? ? header: {
? ? ? ? 'content-type': 'application/json'
? ? ? },
? ? ? //請(qǐng)求后臺(tái)數(shù)據(jù)成功
? ? ? success: function (res) {
? ? ? ? if(res.data.status==1){
? ? ? ? ? that.setData({
? ? ? ? ? ? MK_youhui: res.data.list
? ? ? ? ? })
? ? ? ? }else{
? ? ? ? ? that.setData({
? ? ? ? ? ? MK_youhui: 0
? ? ? ? ? })
? ? ? ? }
? ? ? }
? ? });
? },
//領(lǐng)取優(yōu)惠券
? lingjue: function (e) {
? ? var utilMd5 = require('../../utils/util.js');
? ? var that = this;
? ? var timestamp = Date.parse(new Date());
? ? timestamp = timestamp / 1000;
? ? var password = utilMd5.hexMD5(app.information.code + timestamp);
? ? wx.request({
? ? ? url: '' + app.information.host + '/api/json/vouchers/vouchers.ashx?action=couponobtain&companyid=' + app.information.companyid + '&code=' + password + '×tamp=' + timestamp + '&aid=' + e.currentTarget.dataset.aid,
? ? ? header: {
? ? ? ? 'content-type': 'application/json',
? ? ? ? "cookie": app.information.cookie.replace(/path=\/,/g, "").replace(/path=\/;/g, "").replace(/path=\//g, "").replace(/HttpOnly,/g, "")
? ? ? },
? ? ? //請(qǐng)求后臺(tái)數(shù)據(jù)成功
? ? ? success: function (res) {
? ? ? ? wx.showToast({
? ? ? ? ? // 提示內(nèi)容
? ? ? ? ? title: res.data.returnMsg,
? ? ? ? ? icon: "none",
? ? ? ? ? duration: 2000,
? ? ? ? ? mask: false,
? ? ? ? })
? ? ? }
? ? });
? },
wxss
/*優(yōu)惠券*/
.MK_youhui{width: 92%;padding: 2.67vw 4% 0; background: #fff;overflow: hidden;}
.MK_youhuibt{font-size: 5.3vw;color: #333333;text-align: center;font-weight: 600;margin-bottom: 5.33vw;}
.MK_youhuixbt{margin: 1.8vw 0 5.6vw;text-align: center;color: #e60033;font-size: 3.2vw;}
.MK_youhui_jue{width: 92vw;height:40vw; margin: 0 0 10vw;display: flex;justify-content: space-between;}
.MK_youhui_jue .a1{display:inline-block;margin-right: 2vw}
.MK_youhui_jue .a1:last-child{margin-right: 0;}
.MK_youhui_jue image{width: 29.33vw;height: 40vw;display: block;float:left; position: relative;z-index: 1;left: 0;top: 0;}
.MK_youhui_juenr{width: 29.33vw;height: 40vw;position: relative;z-index: 2;left: 0;top: 0vw;}
.MK_youhui_juetop{font-weight: 600}
.MK_youhui_juenr>view:nth-child(1){position:absolute;color:#fff;font-size:11.67vw;left:5vw;top:6.1vw;width:15vw;text-align:center;}
.MK_youhui_juenr>view:nth-child(2){position:absolute;color:#fff;font-size:4.27vw;left:19vw;top:13vw;}
.MK_youhui_juenr>view:nth-child(3){position:absolute;color:#fff;font-size:4vw;left:6vw;top:21vw;font-weight:600;}
.MK_youhui_juebottom{position: absolute;color: #FAC253;font-size:3vw;left:7vw;top:15vw;font-weight: 600;width: 30vw;height: 3.5vw;text-align: center;line-height:3.5vw;background: #fff}
.MK_youhui_jue>view:nth-child(2n) .MK_youhui_juebottom{color: #F9754F;}