微信小程序***实现字符串转二维码
***是客户发布订单,订单管理等平台,下图就是啥都收客服端个人页面。啥都收客服端有信息管理页面,我的钱包,我要接单,我的优惠券,服务保障等页面。
当用户需要查看本账号有多少优惠券是,可以点击我的优惠卷查看,而我本账户只有两张优惠券,一张是20元的,一张是30元的,当我需要用20元的优惠券,那点击使用,会打开新页面。
点击使用会出现二维码和要求。当师傅扫一下二维码即可生效,抵消相应金额。
特别提醒:由于需要生成二维码,需要导入外部js文件(weapp-qrcode.js)。
WXML代码如下:
![](/image/user/lpj.png)
<!--金额-->
<view class='CouponMoneyLeft'>
<label class='label'>¥</label>
<label class='labelMoney'>{{item.ParValue}}</label>
</view>
<!--金额 end-->
<!--优惠券 -->
<view class='CouponMoneyViewTop2'>
<view class='CouponMoneyViewTop2Top'></view>
<view class='CouponMoneyViewTop2bottom'>
<text> \t 元 \n</text>
<text> \t 优惠券</text>
</view>
</view>
<!--优惠券 end-->
</view>
<!--点击使用-->
<view class='CouponMoneyViewbottom'>
<view class='ClickUse' bindtap='ErWeiMa' data-index='{{item.UserCouponID}}' data-tty='{{item.UserRule}}'>点击使用</view>
</view>
<!--点击使用 end-->
JS:
onLoad: function (options) {
var that=this;
var UserID = app.globalData.login_sj[1];
wx.setNavigationBarTitle({
title: ‘优惠券’,
})
wx.request({
url: ShaDouShou +‘LbsApi/GetUserCouponsInforByUserID’,
data:{
UserID: UserID
},
method:‘post’,
success:function(e){
console.log(‘优惠券’,e);
that.setData({
Coupon: e.data.data
})
}
})
},
modalCandel: function () {
// do something
this.setData({
modalHidden: true
})
this.onLoad();
},
/**
- 点击确认
*/
modalConfirm: function () {
// do something
this.setData({
modalHidden: true
})
this.onLoad();
}