s_code.js
1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var util = require('../../utils/util.js')
var uri=require('../../utils/uri.js')
Page({
onLoad:function(){
wx.setNavigationBarTitle({
title:'快餐二维码'
})
this.setData({
sellerid:util.cache('sellerid')
})
this.getcode();
},
onShow:function(){
var that=this;
util.postSuccessFun=function(json,uri_code){
switch(uri_code){
case uri.CGI_USER_CREATFASTQRCODE__CODE:
if(json.ret==200){
that.setData({
imgurl:json.data
})
}
break;
}
}
},
downloadcode:function(){
wx.downloadFile({
url: this.data.imgurl,
success:function(res){
wx.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: function (res) {
wx.showToast({
title:'图片保存成功',
duration:2000
})
},
fail: function (res) {
util.setting();
}
})
},
fail:function(){
console.log('fail')
}
})
},
getcode:function(){
util.post(uri.CGI_USER_CREATFASTQRCODE,{sellerid:this.data.sellerid},uri.CGI_USER_CREATFASTQRCODE__CODE)
},
netchange:function () {
this.onShow()
}
})