import { getUserCard } from '../../api/index' // import { downloadImg } from '../../utils/common' Page({ /** * 页面的初始数据 */ data: { bottomLift: 0, isShow: false, userCard: '', isShow2: false, userInfo: {} }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { var app = getApp().globalData var userType = options.userType || 1 if (userType == 1) { //如果查询自己的信息 this.setData({ userInfo: wx.getStorageSync('member') }) console.log(this.data) } this.setData({ bottomLift: app.bottomLift }) }, showQrcode() { this.setData({ isShow: true }) }, closeCard() { this.setData({ isShow2: false }) }, saveCard() { wx.downloadFile({ url: this.data.userCard, success: function (res) { console.log('下载成功', res); wx.saveImageToPhotosAlbum({ filePath: res.tempFilePath, success(result) { console.log(result) wx.showToast({ title: '保存成功', icon: 'success', duration: 2000 }) } }) } }) }, openModal() { if (this.data.userCard != null && this.data.userCard != '') { this.setData({ isShow2: true }) return; } getUserCard().then(res => { this.setData({ userCard: res.data }) this.setData({ isShow2: true }) }) }, onClose() { this.setData({ isShow: false }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })