// pages/testpromotion/testresult/testresult.js const app = getApp() Page({ /** * 页面的初始数据 */ data: { imgpath: null, prx_id: null, pd_title: null, pd_imgurl: null, loaddisplay: true, score: null, imgqrcode: null, loadPath: null, qrcode: null, testImg: null, resultShow: [] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this this.setData({ prx_id: options.prx_id, score: options.score }) wx.request({ url: app.globalData.url + '/getPromotionTestResultShowByPrxID', method: 'get', data: { prx_id: options.prx_id }, success: function (res) { that.setData({ resultShow: res.data }) for (var i = 0; i < that.data.resultShow.length; i++) { if (options.score <= that.data.resultShow[i].ptrs_greater && options.score >= that.data.resultShow[i].ptrs_less) { that.setData({ imgpath: that.data.resultShow[i].ptrs_img, testImg: that.data.resultShow[i].ptrs_img_name }) break } } if (that.data.imgpath == null || that.data.testImg == null){ that.setData({ imgpath: that.data.resultShow[0].ptrs_img, testImg: that.data.resultShow[0].ptrs_img_name }) } } }) // if (options.score == 100) { // this.setData({ // imgpath: 'https://yuesuo.yueguanjia.com/MiniProgram/promotion/test/scoretall.jpg', // testImg:'scoretall.jpg' // }) // } else if (options.score < 100 && options.score >=60 ) { // this.setData({ // imgpath: 'https://yuesuo.yueguanjia.com/MiniProgram/promotion/test/scoremiddle.jpg', // testImg: 'scoremiddle.jpg' // }) // } else { // this.setData({ // imgpath: 'https://yuesuo.yueguanjia.com/MiniProgram/promotion/test/scorelow.jpg', // testImg: 'scorelow.jpg' // }) // } wx.request({ url: app.globalData.url + '/getPromotionDC', method: 'get', success: function (res) { that.setData({ pd_title: res.data.pd_title, pd_imgurl: res.data.pd_imgurl }) } }) wx.request({ url: app.globalData.url + '/checkDcIntroducers', method: 'get', data: { wv_phone: app.globalData.userphone }, success: function (res) { if (res.data != "") { that.setData({ imgqrcode: res.data.wv_qrcode, qrcode: app.globalData.userphone +'.png', loaddisplay: 'none' }) } else { that.setData({ imgqrcode: 'http://yuesuo.yueguanjia.com/MiniProgram/mgm/P_PMTEST.png', qrcode: 'P_PMTEST.png', loaddisplay: 'none' }) } } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { wx.setNavigationBarTitle({ title: '测试结果', success: function (res) { // success } }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { return { title: this.data.pd_title, path: '/pages/index/index?share=promotion&url=/pages/testpromotion/testpromotion&id=' + this.data.prx_id + '', // path: '/pages/testpromotion/testpromotion?id=' + this.data.prx_id, imageUrl: this.data.pd_imgurl } }, longTap: function (e) { var that = this wx.showLoading({ title: '保存中......', icon: 'loading', duration: 5500 }) wx.request({ url: app.globalData.url + '/CreateTestShare', method: 'get', data: { qrcode: this.data.qrcode, testImg: this.data.testImg, score: this.data.score, openid: app.globalData.openid }, success: function (res) { wx.downloadFile({ url: res.data, success: function (res) { wx.saveImageToPhotosAlbum({ filePath: res.tempFilePath, success: function (res) { wx.hideLoading() wx.showToast({ title: "保存成功", icon: "success", }) } }) }, fail: function () { wx.hideLoading() wx.showToast({ title: "保存失败,请点击按钮授权", icon: "none", }) that.setData({ sqshow: true }) } }) } }) }, again: function () { wx.navigateBack({ delta: 1 }) }, surprised: function() { wx.navigateTo({ url: '/pages/testpromotion/testsurprised/testsurprised?prx_id=' + this.data.prx_id }) } })