list.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. gotoDetail: function (e) {
  48. var questionTypeID = e.currentTarget.dataset.id;
  49. wx.navigateTo({
  50. url: './detail?id=' + questionTypeID
  51. });
  52. },
  53. gotoPrint: function (e) {
  54. var that=this;
  55. var id = e.currentTarget.dataset.id;
  56. server.getData('GetQuestionTypesPrint?ID='+id, function (data) {
  57. that.downImage(data);
  58. });
  59. },
  60. downImage:function(filename){
  61. var that = this;
  62. wx.showLoading({
  63. title: '下载中',
  64. });
  65. setTimeout(function(){
  66. wx.downloadFile({
  67. url: "https://print-1253256735.file.myqcloud.com/" + filename + ".png",
  68. success: function (res) {
  69. wx.hideLoading();
  70. wx.previewImage({
  71. current: res.tempFilePath, // 当前显示图片的http链接
  72. urls: [res.tempFilePath] // 需要预览的图片http链接列表
  73. })
  74. },
  75. fail: function () {
  76. wx.hideLoading();
  77. that.downImage(filename);
  78. }
  79. });
  80. },2000);
  81. },
  82. onShareAppMessage: function () {
  83. var that = this;
  84. return {
  85. title: '',
  86. path: 'pages/index/start?UserID=' + app.globalData.userInfo.UserID,
  87. imageUrl: app.globalData.fileUrl + 'images3/Extend/02.png',
  88. success: function (res) {
  89. },
  90. fail: function (err) {
  91. console.log(err);
  92. },
  93. complete: function (res) {
  94. console.log("shareComplete:" + res);
  95. },
  96. }
  97. },
  98. })