list.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import common from '../../utils/util';
  2. import server from '../../utils/main';
  3. var app = getApp();
  4. var category = 0;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. FileUrl: app.globalData.fileUrl,
  11. },
  12. /**
  13. * 生命周期函数--监听页面加载
  14. */
  15. onLoad: function (options) {
  16. this.setData({
  17. Containnerheight: server.getWindowHeight(),
  18. });
  19. category = options.id;
  20. console.log(category);
  21. this.getList();
  22. },
  23. onPullDownRefresh: function () {
  24. this.getList();
  25. },
  26. onShow: function () {
  27. var that = this;
  28. that.getList();
  29. },
  30. getList: function () {
  31. this.setData({
  32. Level: category,
  33. });
  34. var data = wx.getStorageSync('QuestionTypeList');
  35. for (var i = 0; i < data.length; i++) {
  36. if (data[i].ID == category) {
  37. this.setData({
  38. QuestionTypeList: data[i].List,
  39. });
  40. wx.setNavigationBarTitle({
  41. title: data[i].Name,
  42. });
  43. break;
  44. }
  45. }
  46. },
  47. gotoPrint: function (e) {
  48. var that=this;
  49. var id = e.currentTarget.dataset.id;
  50. server.getData('GetQuestionTypesPrint?ID='+id, function (data) {
  51. that.downImage(data);
  52. });
  53. },
  54. downImage:function(filename){
  55. var that = this;
  56. wx.showLoading({
  57. title: '下载中',
  58. });
  59. setTimeout(function(){
  60. wx.downloadFile({
  61. url: "https://print-1253256735.file.myqcloud.com/" + filename + ".png",
  62. success: function (res) {
  63. wx.hideLoading();
  64. wx.previewImage({
  65. current: res.tempFilePath, // 当前显示图片的http链接
  66. urls: [res.tempFilePath] // 需要预览的图片http链接列表
  67. })
  68. },
  69. fail: function () {
  70. wx.hideLoading();
  71. that.downImage(filename);
  72. }
  73. });
  74. },2000);
  75. },
  76. onShareAppMessage: function () {
  77. var that = this;
  78. return {
  79. title: '',
  80. path: 'pages/index/start?UserID=' + app.globalData.userInfo.UserID,
  81. imageUrl: app.globalData.fileUrl + 'images3/Extend/02.png',
  82. success: function (res) {
  83. },
  84. fail: function (err) {
  85. console.log(err);
  86. },
  87. complete: function (res) {
  88. console.log("shareComplete:" + res);
  89. },
  90. }
  91. },
  92. })