微信小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

index.js 3.8 KiB

2 anos atrás
2 anos atrás
2 anos atrás
2 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. that.setData({
  34. imgUrl:wx.getStorageSync('dressCode')
  35. })
  36. UTIL.httpRequest(API.URL_GET_GETOPENLIST, {method:'GET'},{
  37. success: (res) => {
  38. if(res.code == 200){
  39. for (let i = 0; i < res.rows.length; i++) {
  40. const element = res.rows[i];
  41. element.openPic = element.openPic.split(',');
  42. element.openFile = element.openFile.split(',');
  43. }
  44. // wx.getStorageSync('dressCode')+
  45. if (res.rows.length>0) {
  46. that.setData({
  47. bookId:res.rows[0].bookId,
  48. deptId:res.rows[0].deptId,
  49. })
  50. }
  51. console.log(res.rows);
  52. that.setData({
  53. list:res.rows
  54. })
  55. }else{
  56. UTIL.showToastNoneIcon(res.msg);
  57. }
  58. }
  59. })
  60. },
  61. openPreview(e){
  62. let array = [];
  63. array.push(e.currentTarget.dataset.url)
  64. wx.previewImage({
  65. urls: array,
  66. showmenu:true,
  67. })
  68. },
  69. // 预览文件
  70. previewFile(e) {
  71. if(!e.currentTarget.dataset.url) {
  72. return false
  73. }
  74. UTIL.showLoading()
  75. // 单次下载允许的最大文件为 200MB
  76. wx.downloadFile({
  77. url: e.currentTarget.dataset.url,
  78. success: function (res) {
  79. console.log(res, "wx.downloadFile success res")
  80. if(res.statusCode != 200) {
  81. UTIL.hideLoadingWithErrorTips()
  82. return false
  83. }
  84. var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用
  85. wx.openDocument({
  86. filePath: Path,
  87. showMenu: true,
  88. success: function (res) {
  89. console.log('打开成功');
  90. UTIL.hideLoadings()
  91. }
  92. })
  93. },
  94. fail: function (err) {
  95. console.log(err, "wx.downloadFile fail err");
  96. UTIL.hideLoadingWithErrorTips()
  97. }
  98. })
  99. },
  100. goSearch(e){
  101. var that = this;
  102. let query = {
  103. openName:e.detail,
  104. bookId:that.data.bookId,
  105. deptId:that.data.deptId,
  106. method:'GET'
  107. }
  108. UTIL.httpRequest(API.URL_GET_GETOPENLIST,query,{
  109. success: (res) => {
  110. if(res.code == 200){
  111. for (let i = 0; i < res.rows.length; i++) {
  112. const element = res.rows[i];
  113. element.openPic = wx.getStorageSync('dressCode')+element.openPic;
  114. element.openFile = wx.getStorageSync('dressCode')+element.openFile;
  115. }
  116. that.setData({
  117. list:res.rows
  118. })
  119. }else{
  120. UTIL.showToastNoneIcon(res.msg);
  121. }
  122. }
  123. })
  124. },
  125. goFinace(e){
  126. let date = e.currentTarget.dataset.date;
  127. let bookId = e.currentTarget.dataset.bookid;
  128. let deptId = e.currentTarget.dataset.deptid;
  129. wx.navigateTo({
  130. url: 'finance?date='+date+'&bookId='+bookId+'&deptId='+deptId,
  131. })
  132. },
  133. /**
  134. * 生命周期函数--监听页面隐藏
  135. */
  136. onHide() {
  137. },
  138. /**
  139. * 生命周期函数--监听页面卸载
  140. */
  141. onUnload() {
  142. },
  143. /**
  144. * 页面相关事件处理函数--监听用户下拉动作
  145. */
  146. onPullDownRefresh() {
  147. },
  148. /**
  149. * 页面上拉触底事件的处理函数
  150. */
  151. onReachBottom() {
  152. },
  153. /**
  154. * 用户点击右上角分享
  155. */
  156. onShareAppMessage() {
  157. }
  158. })