微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 line
3.7 KiB

  1. // pages/finance/index.js
  2. import * as UTIL from '../../utils/util.js';
  3. import * as API from '../../utils/API.js';
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. isIPX: app.globalData.isIPX,
  11. list:[]
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad(options) {
  17. },
  18. back:function(){
  19. wx.navigateBack({
  20. delta: 1
  21. })
  22. },
  23. /**
  24. * 生命周期函数--监听页面初次渲染完成
  25. */
  26. onReady() {
  27. },
  28. /**
  29. * 生命周期函数--监听页面显示
  30. */
  31. onShow() {
  32. var that = this;
  33. UTIL.httpRequest(API.URL_GET_GETOPENLIST, {method:'GET'},{
  34. success: (res) => {
  35. if(res.code == 200){
  36. for (let i = 0; i < res.rows.length; i++) {
  37. const element = res.rows[i];
  38. element.openPic = wx.getStorageSync('dressCode')+element.openPic;
  39. element.openFile = wx.getStorageSync('dressCode')+element.openFile;
  40. }
  41. if (res.rows.length>0) {
  42. that.setData({
  43. bookId:res.rows[0].bookId,
  44. deptId:res.rows[0].deptId,
  45. })
  46. }
  47. that.setData({
  48. list:res.rows
  49. })
  50. }else{
  51. UTIL.showToastNoneIcon(res.msg);
  52. }
  53. }
  54. })
  55. },
  56. openPreview(e){
  57. let array = [];
  58. array.push(e.currentTarget.dataset.url)
  59. wx.previewImage({
  60. urls: array,
  61. showmenu:true,
  62. })
  63. },
  64. // 预览文件
  65. previewFile(e) {
  66. if(!e.currentTarget.dataset.url) {
  67. return false
  68. }
  69. UTIL.showLoading()
  70. // 单次下载允许的最大文件为 200MB
  71. wx.downloadFile({
  72. url: e.currentTarget.dataset.url,
  73. success: function (res) {
  74. console.log(res, "wx.downloadFile success res")
  75. if(res.statusCode != 200) {
  76. UTIL.hideLoadingWithErrorTips()
  77. return false
  78. }
  79. var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用
  80. wx.openDocument({
  81. filePath: Path,
  82. showMenu: true,
  83. success: function (res) {
  84. console.log('打开成功');
  85. UTIL.hideLoadings()
  86. }
  87. })
  88. },
  89. fail: function (err) {
  90. console.log(err, "wx.downloadFile fail err");
  91. UTIL.hideLoadingWithErrorTips()
  92. }
  93. })
  94. },
  95. goSearch(e){
  96. var that = this;
  97. let query = {
  98. openName:e.detail,
  99. bookId:that.data.bookId,
  100. deptId:that.data.deptId,
  101. method:'GET'
  102. }
  103. UTIL.httpRequest(API.URL_GET_GETOPENLIST,query,{
  104. success: (res) => {
  105. if(res.code == 200){
  106. for (let i = 0; i < res.rows.length; i++) {
  107. const element = res.rows[i];
  108. element.openPic = wx.getStorageSync('dressCode')+element.openPic;
  109. element.openFile = wx.getStorageSync('dressCode')+element.openFile;
  110. }
  111. that.setData({
  112. list:res.rows
  113. })
  114. }else{
  115. UTIL.showToastNoneIcon(res.msg);
  116. }
  117. }
  118. })
  119. },
  120. goFinace(e){
  121. let date = e.currentTarget.dataset.date;
  122. let bookId = e.currentTarget.dataset.bookid;
  123. let deptId = e.currentTarget.dataset.deptid;
  124. wx.navigateTo({
  125. url: 'finance?date='+date+'&bookId='+bookId+'&deptId='+deptId,
  126. })
  127. },
  128. /**
  129. * 生命周期函数--监听页面隐藏
  130. */
  131. onHide() {
  132. },
  133. /**
  134. * 生命周期函数--监听页面卸载
  135. */
  136. onUnload() {
  137. },
  138. /**
  139. * 页面相关事件处理函数--监听用户下拉动作
  140. */
  141. onPullDownRefresh() {
  142. },
  143. /**
  144. * 页面上拉触底事件的处理函数
  145. */
  146. onReachBottom() {
  147. },
  148. /**
  149. * 用户点击右上角分享
  150. */
  151. onShareAppMessage() {
  152. }
  153. })