mycertificate.js 2.7 KB
const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        list: '',
        active: ''
    },


    onLoad: function (options) {

    },


    onReady: function () {

    },


    onShow: function () {

        let that = this
        that.getList()

    },

    getList() {
        let that = this;
        let url = '/index/second/zhengJianInfo ';
        let head = {
            'XX-Token': wx.getStorageSync('token')
        }

        app.post(url, '', head).then((res) => {

            console.log(res)

            this.setData({

                list: res
            })
        })
    },


    // 生成图片
    getPic(e) {
        console.log(e)
        var type = e.currentTarget.dataset.type
        let that = this;
        let url = '/index/second/zhengJianPic ';
        let head = {
            'XX-Token': wx.getStorageSync('token')
        }
        let params = {
            type: type
        }

        app.post(url, params, head).then((res) => {
            console.log(res)
            // this.setData({
            //     active: res.url
            // })
            wx.downloadFile({
                url: res.url,
                success: (res) => {
                    wx.saveImageToPhotosAlbum({
                        filePath: res.tempFilePath,
                        success: (r) => {
                            wx.showToast({
                                title: '保存成功',
                                mask: true,
                                duration: 1000
                            })
                        }
                    })
                }
            })




        })
    },

    //保存海报到本地
    // save_poster() {
    //     wx.downloadFile({
    //         url: this.data.active,
    //         success: (res) => {
    //             wx.saveImageToPhotosAlbum({
    //                 filePath: res.tempFilePath,
    //                 success: (r) => {
    //                     wx.showToast({
    //                         title: '保存成功',
    //                         mask: true,
    //                         duration: 1000
    //                     })
    //                 }
    //             })
    //         }
    //     })

    // },




    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})