blob: 12ce7925008733a52740044c7efbe0694a7229f7 [file] [log] [blame]
binquan.qiu7f2665f2020-03-27 17:19:57 +08001// pages/qrcode/qrcode.js
2const QR = require('../../utils/weapp-qrcode.js')
3const app = getApp()
4Page({
5
6 /**
7 * 页面的初始数据
8 */
9 data: {
10 qrcodeURL: "",
11 },
12
13 /**
14 * 生命周期函数--监听页面加载
15 */
16 onLoad: function(options) {
17 var that = this;
18
19 wx.getScreenBrightness({
20 success:function(e){
21 wx.setStorageSync("brightness", e.value);
22 }
23 })
24 wx.setNavigationBarTitle({
25 title: '付款码',
26 })
27 wx.setScreenBrightness({
28 value: 1,
29 })
30
31 wx.$doPost('/v1/qrcode', {}, function(ok, ret) {
32 console.log(ret);
33 if (ok) {
34 var imgData = QR.drawImg(ret.data.qrcode, {
35 typeNumber: 4,
36 errorCorrectLevel: 'M',
37 size: 500
38 })
39 that.setData({
40 qrcodeURL: imgData
41 })
42 }else{
43 wx.showModal({
44 title: '错误',
45 content: '获取二维码失败,请稍后再试',
46 showCancel: false,
47 success(res) {
48 wx.navigateBack({
49
50 })
51 }
52 })
53 }
54
55 })
56 },
57
58 /**
59 * 生命周期函数--监听页面初次渲染完成
60 */
61 onReady: function() {
62
63 },
64
65 /**
66 * 生命周期函数--监听页面显示
67 */
68 onShow: function() {
69
70 },
71
72 /**
73 * 生命周期函数--监听页面隐藏
74 */
75 onHide: function() {
76
77 },
78
79 /**
80 * 生命周期函数--监听页面卸载
81 */
82 onUnload: function() {
83
84 },
85
86 /**
87 * 页面相关事件处理函数--监听用户下拉动作
88 */
89 onPullDownRefresh: function() {
90
91 },
92
93 /**
94 * 页面上拉触底事件的处理函数
95 */
96 onReachBottom: function() {
97
98 },
99
100 /**
101 * 用户点击右上角分享
102 */
103 onShareAppMessage: function() {
104
105 }
106})