// pages/learningReport/learningReport.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { showewm: false, showzs: false, "spxxArr": [{ "isfinish": "/images/unfinish.png", "spfm": "/images/spfm.jpg", "iszburl": "/images/zb.png", "name": "一期素质教育培训", "startdate": "6月9日", "starttime": "19:30", "isstartstudy": "/images/startstudy.png", "isdtxs": "/images/dtxs.png", "ispjkc": "/images/pjkc.png" }, { "isfinish": "/images/finish.png", "spfm": "/images/spfm.jpg", "iszburl": "/images/db.png", "name": "一期素质教育培训", "startdate": "6月9日", "starttime": "19:30", "isstartstudy": "/images/startstudy.png", "isdtxs": "/images/dtxs.png", "ispjkc": "/images/pjkc.png" }, { "isfinish": "/images/unstart.png", "spfm": "/images/spfm.jpg", "iszburl": "/images/db.png", "name": "一期素质教育培训", "startdate": "6月9日", "starttime": "19:30", "isstartstudy": "/images/startstudy.png", "isdtxs": "/images/dtxs.png", "ispjkc": "/images/pjkc.png" }, { "isfinish": "/images/unstart.png", "spfm": "/images/spfm.jpg", "iszburl": "/images/db.png", "name": "一期素质教育培训", "startdate": "6月9日", "starttime": "19:30", "isstartstudy": "/images/startstudy.png", "isdtxs": "/images/dtxs.png", "ispjkc": "/images/pjkc.png" }], }, selectBtn0() { this.setData({ select: 0 }); }, selectBtn1() { this.setData({ select: 1 }); }, gokhAnswer() { wx.navigateTo({ url: '../answerAfterclass/answerAfterclass' }) }, gopjClass() { wx.navigateTo({ url: '../evaluationCourse/evaluationCourse' }) }, startAnswer() { wx.navigateTo({ url: '/pages/answerAfterclass/answerAfterclass', }) }, goWrite() { wx.navigateTo({ url: '../studentRegistration/studentRegistration' }) }, goWrite2() { wx.navigateTo({ url: '../feedBack/feedBack' }) }, lq() { this.setData({ showzs: true }); // wx.showToast({ // title: '领取成功' // }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, showEwm() { var sessionKey = ""; var _this = this; wx.checkSession({ success: () => { console.log("我有缓存") sessionKey = wx.getStorageSync('sessionKey'); console.log(sessionKey) wx.request({ url: app.globalData.publicUrl2 + '/education/student/wx/selClas?sessionKey=' + sessionKey + '&isActive=1', method: "post", success: function (res) { if (res.data.data.isAgree == 0) { _this.setData({ show: true }); } else { _this.setData({ show: false }); } } }) }, fail() { console.log("我没有缓存并去登录请求") wx.login({ success(res) { console.log(res); var code = res.code wx.request({ url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login', method: "get", data: { code }, success: function (res) { sessionKey = res.data.sessionKey; wx.setStorageSync('sessionKey', res.data.sessionKey); } }) } }) } }) // this.setData({ // showewm: true // }); }, // showzs(){ // }, onClose() { wx.hideLoading() this.setData({ showewm: false }); }, onClose1() { this.setData({ showzs: false }); }, /** * 生命周期函数--监听页面初次渲染完成 */ saveImg() { wx.getSetting({ success(res) { if (!res.authSetting['scope.writePhotosAlbum']) { wx.authorize({ scope: 'scope.writePhotosAlbum', success() { console.log(res, "我点击同意啦") wx.showLoading({ title: '保存中...' }) var imgSrc = "http://yijiao.oss-cn-qingdao.aliyuncs.com/images/http://tmp/wx1b4e5e756cd48af1.o6zAJsws4grEQvYrWTjBigy-6QaU.0llhudiKSF2V955a1c48350d9328ef064b4d36d12746.jpg" wx.downloadFile({ url: imgSrc, success: function (res) { console.log(res, '我下载完成啦'); //图片保存到本地 wx.saveImageToPhotosAlbum({ filePath: res.tempFilePath, success: function (data) { console.log(data, '我保存成功啦') wx.hideLoading(); wx.showToast({ title: '保存成功', icon: 'success', duration: 2000 }) }, fail: function (err) { console.log(err, '我保存失败啦') wx.hideLoading(); if (err.errMsg === "saveImageToPhotosAlbum:fail auth deny") { console.log("当初用户拒绝,再次发起授权") wx.openSetting({ success(settingdata) { console.log(settingdata) if (settingdata.authSetting['scope.writePhotosAlbum']) { console.log('获取权限成功,给出再次点击图片保存到相册的提示。') } else { console.log('获取权限失败,给出不给权限就无法正常使用的提示') } } }) } }, complete(res) { console.log(res); } }) } }) console.log('授权成功') } }) } else { var imgSrc = "http://yijiao.oss-cn-qingdao.aliyuncs.com/images/http://tmp/wx1b4e5e756cd48af1.o6zAJsws4grEQvYrWTjBigy-6QaU.0llhudiKSF2V955a1c48350d9328ef064b4d36d12746.jpg" wx.downloadFile({ url: imgSrc, success: function (res) { console.log(res, '我下载完成啦'); wx.hideLoading(); //图片保存到本地 wx.saveImageToPhotosAlbum({ filePath: res.tempFilePath, success: function (data) { console.log(data, '我保存成功啦') wx.hideLoading(); wx.showToast({ title: '保存成功', icon: 'success', duration: 2000 }) }, fail: function (err) { console.log(err, '我保存失败啦') wx.hideLoading(); if (err.errMsg === "saveImageToPhotosAlbum:fail auth deny") { console.log("当初用户拒绝,再次发起授权") wx.openSetting({ success(settingdata) { console.log(settingdata) if (settingdata.authSetting['scope.writePhotosAlbum']) { console.log('获取权限成功,给出再次点击图片保存到相册的提示。') } else { console.log('获取权限失败,给出不给权限就无法正常使用的提示') } } }) } }, complete(res) { console.log(res); } }) } }) } } }) // wx.showLoading({ // title: '保存中...' // }) // wx.getSetting({ // success(res) { // console.log(res) // if (res.authSetting['scope.writePhotosAlbum']) { // wx.authorize({ // scope: 'scope.writePhotosAlbum', // success() { // var imgSrc = "http://sqdx.windd.cn/files/21.png" // wx.downloadFile({ // url: imgSrc, // success: function (res) { // console.log(res); // //图片保存到本地 // wx.saveImageToPhotosAlbum({ // filePath: res.tempFilePath, // success: function (data) { // wx.hideLoading(); // wx.showToast({ // title: '保存成功', // icon: 'success', // duration: 2000 // }) // }, // fail: function (err) { // console.log(err); // if (err.errMsg === "saveImageToPhotosAlbum:fail auth deny") { // console.log("当初用户拒绝,再次发起授权") // wx.openSetting({ // success(settingdata) { // console.log(settingdata) // if (settingdata.authSetting['scope.writePhotosAlbum']) { // console.log('获取权限成功,给出再次点击图片保存到相册的提示。') // } else { // console.log('获取权限失败,给出不给权限就无法正常使用的提示') // } // } // }) // } // }, // complete(res) { // console.log(res); // } // }) // } // }) // } // }) // } // } // }) }, onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })