s_addmany.js 1.61 KB
var util = require('../../utils/util.js')
import App from '../../utils/api.js'
Page({
    data:{
        
    },
    onLoad:function(){
        this.sellerid=util.cache('sellerid');
		this.getcode();
    },
    onShow:function(){
        
    },
    getcode:function(){
        App.Seller.CreatebatchQrcode({sellerid:this.sellerid}).then((json)=>{
			if(json.ret==200){
				console.log(json)
				this.setData({
					code:json.data
				})
			}
		})
    },
    download:function(){
        var that=this;
        wx.downloadFile({
            url: this.data.code,
            success:function(res){
                console.log('ggg',res)
                wx.saveImageToPhotosAlbum({
                    filePath: res.tempFilePath,
                    success:function(result) {
                        console.log(result)
                        wx.showToast({
                            title:'图片保存成功',
                            duration:2000
                        })
                    },
                    fail: function (res) {
                        console.log(res)
                        wx.showModal({
                            content:'下载图片必须授权',
                            confirmColor:'#199095',
                            success:function(res){
                                if (res.confirm) {
                                    util.setting();
                                }
                            }
                        })
                    }
                })
            },
            fail:function(){
                console.log('fail')
            }
        })


    },
})