123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- var util = require('../../../utils/util.js');
- var api = require('../../../config/api.js');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl:'',
- ads:'',
- goodsId:''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- wx.showLoading({
- title: '生成中',
- })
- this.setData({
- goodsId:options.goodsId
- });
-
- util.request(api.QrGoodsCodeCreate, {goodsId:this.data.goodsId
- }).then(res=>{
- wx.hideLoading();
- this.setData({
- imgUrl:res.data.imgUrl,
- ads:res.data.ads
- })
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
- copyText(){
- wx.setClipboardData({
- data: this.data.ads,
- success: function (res) {
- wx.showToast({
- title: '文案复制成功',
- icon: 'success',
- duration: 2000
- });
- }
- })
- },
-
- goSaveQrcode:function(){//保存二维码图片
- let that=this;
- wx.showLoading({
- title: '保存中',
- });
- wx.downloadFile({
- url: that.data.imgUrl,
- success:function(res){
- wx.hideLoading();
- if(res.statusCode===200){
- let img=res.tempFilePath;
- wx.saveImageToPhotosAlbum({
- filePath: img,
- success(res){
- wx.showToast({
- title: '保存成功'
- })
- },
-
- })
- }
- },
- fail(res){
- wx.hideLoading();
- util.showErrorToast('图片保存失败 请重试');
- }
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|