testresult.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. // pages/testpromotion/testresult/testresult.js
  2. const app = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. imgpath: null,
  9. prx_id: null,
  10. pd_title: null,
  11. pd_imgurl: null,
  12. loaddisplay: true,
  13. score: null,
  14. imgqrcode: null,
  15. loadPath: null,
  16. qrcode: null,
  17. testImg: null,
  18. resultShow: []
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. var that = this
  25. this.setData({
  26. prx_id: options.prx_id,
  27. score: options.score
  28. })
  29. wx.request({
  30. url: app.globalData.url + '/getPromotionTestResultShowByPrxID',
  31. method: 'get',
  32. data: {
  33. prx_id: options.prx_id
  34. },
  35. success: function (res) {
  36. that.setData({
  37. resultShow: res.data
  38. })
  39. for (var i = 0; i < that.data.resultShow.length; i++) {
  40. if (options.score <= that.data.resultShow[i].ptrs_greater && options.score >= that.data.resultShow[i].ptrs_less) {
  41. that.setData({
  42. imgpath: that.data.resultShow[i].ptrs_img,
  43. testImg: that.data.resultShow[i].ptrs_img_name
  44. })
  45. break
  46. }
  47. }
  48. if (that.data.imgpath == null || that.data.testImg == null){
  49. that.setData({
  50. imgpath: that.data.resultShow[0].ptrs_img,
  51. testImg: that.data.resultShow[0].ptrs_img_name
  52. })
  53. }
  54. }
  55. })
  56. // if (options.score == 100) {
  57. // this.setData({
  58. // imgpath: 'https://yuesuo.yueguanjia.com/MiniProgram/promotion/test/scoretall.jpg',
  59. // testImg:'scoretall.jpg'
  60. // })
  61. // } else if (options.score < 100 && options.score >=60 ) {
  62. // this.setData({
  63. // imgpath: 'https://yuesuo.yueguanjia.com/MiniProgram/promotion/test/scoremiddle.jpg',
  64. // testImg: 'scoremiddle.jpg'
  65. // })
  66. // } else {
  67. // this.setData({
  68. // imgpath: 'https://yuesuo.yueguanjia.com/MiniProgram/promotion/test/scorelow.jpg',
  69. // testImg: 'scorelow.jpg'
  70. // })
  71. // }
  72. wx.request({
  73. url: app.globalData.url + '/getPromotionDC',
  74. method: 'get',
  75. success: function (res) {
  76. that.setData({
  77. pd_title: res.data.pd_title,
  78. pd_imgurl: res.data.pd_imgurl
  79. })
  80. }
  81. })
  82. wx.request({
  83. url: app.globalData.url + '/checkDcIntroducers',
  84. method: 'get',
  85. data: {
  86. wv_phone: app.globalData.userphone
  87. },
  88. success: function (res) {
  89. if (res.data != "") {
  90. that.setData({
  91. imgqrcode: res.data.wv_qrcode,
  92. qrcode: app.globalData.userphone +'.png',
  93. loaddisplay: 'none'
  94. })
  95. } else {
  96. that.setData({
  97. imgqrcode: 'http://yuesuo.yueguanjia.com/MiniProgram/mgm/P_PMTEST.png',
  98. qrcode: 'P_PMTEST.png',
  99. loaddisplay: 'none'
  100. })
  101. }
  102. }
  103. })
  104. },
  105. /**
  106. * 生命周期函数--监听页面初次渲染完成
  107. */
  108. onReady: function () {
  109. },
  110. /**
  111. * 生命周期函数--监听页面显示
  112. */
  113. onShow: function () {
  114. wx.setNavigationBarTitle({
  115. title: '测试结果',
  116. success: function (res) {
  117. // success
  118. }
  119. })
  120. },
  121. /**
  122. * 生命周期函数--监听页面隐藏
  123. */
  124. onHide: function () {
  125. },
  126. /**
  127. * 生命周期函数--监听页面卸载
  128. */
  129. onUnload: function () {
  130. },
  131. /**
  132. * 页面相关事件处理函数--监听用户下拉动作
  133. */
  134. onPullDownRefresh: function () {
  135. },
  136. /**
  137. * 页面上拉触底事件的处理函数
  138. */
  139. onReachBottom: function () {
  140. },
  141. /**
  142. * 用户点击右上角分享
  143. */
  144. onShareAppMessage: function () {
  145. return {
  146. title: this.data.pd_title,
  147. path: '/pages/index/index?share=promotion&url=/pages/testpromotion/testpromotion&id=' + this.data.prx_id + '',
  148. // path: '/pages/testpromotion/testpromotion?id=' + this.data.prx_id,
  149. imageUrl: this.data.pd_imgurl
  150. }
  151. },
  152. longTap: function (e) {
  153. var that = this
  154. wx.showLoading({
  155. title: '保存中......',
  156. icon: 'loading',
  157. duration: 5500
  158. })
  159. wx.request({
  160. url: app.globalData.url + '/CreateTestShare',
  161. method: 'get',
  162. data: {
  163. qrcode: this.data.qrcode,
  164. testImg: this.data.testImg,
  165. score: this.data.score,
  166. openid: app.globalData.openid
  167. },
  168. success: function (res) {
  169. wx.downloadFile({
  170. url: res.data,
  171. success: function (res) {
  172. wx.saveImageToPhotosAlbum({
  173. filePath: res.tempFilePath,
  174. success: function (res) {
  175. wx.hideLoading()
  176. wx.showToast({
  177. title: "保存成功",
  178. icon: "success",
  179. })
  180. }
  181. })
  182. },
  183. fail: function () {
  184. wx.hideLoading()
  185. wx.showToast({
  186. title: "保存失败,请点击按钮授权",
  187. icon: "none",
  188. })
  189. that.setData({
  190. sqshow: true
  191. })
  192. }
  193. })
  194. }
  195. })
  196. },
  197. again: function () {
  198. wx.navigateBack({
  199. delta: 1
  200. })
  201. },
  202. surprised: function() {
  203. wx.navigateTo({
  204. url: '/pages/testpromotion/testsurprised/testsurprised?prx_id=' + this.data.prx_id
  205. })
  206. }
  207. })