123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- // 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
- })
- }
- })
|