|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- // pages/finance/index.js
- import * as UTIL from '../../utils/util.js';
- import * as API from '../../utils/API.js';
- const app = getApp();
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- isIPX: app.globalData.isIPX,
- list:[]
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
-
- },
- back:function(){
- wx.navigateBack({
- delta: 1
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- var that = this;
- that.setData({
- imgUrl:wx.getStorageSync('dressCode')
- })
- UTIL.httpRequest(API.URL_GET_GETOPENLIST, {method:'GET'},{
- success: (res) => {
- if(res.code == 200){
- for (let i = 0; i < res.rows.length; i++) {
- const element = res.rows[i];
- element.openPic = element.openPic.split(',');
- element.openFile = element.openFile.split(',');
- }
- // wx.getStorageSync('dressCode')+
- if (res.rows.length>0) {
- that.setData({
- bookId:res.rows[0].bookId,
- deptId:res.rows[0].deptId,
- })
- }
-
- console.log(res.rows);
- that.setData({
- list:res.rows
- })
- }else{
- UTIL.showToastNoneIcon(res.msg);
- }
- }
- })
- },
- openPreview(e){
- let array = [];
- array.push(e.currentTarget.dataset.url)
- wx.previewImage({
- urls: array,
- showmenu:true,
- })
- },
- // 预览文件
- previewFile(e) {
- if(!e.currentTarget.dataset.url) {
- return false
- }
- UTIL.showLoading()
-
- // 单次下载允许的最大文件为 200MB
- wx.downloadFile({
- url: e.currentTarget.dataset.url,
- success: function (res) {
- console.log(res, "wx.downloadFile success res")
- if(res.statusCode != 200) {
- UTIL.hideLoadingWithErrorTips()
- return false
- }
- var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用
- wx.openDocument({
- filePath: Path,
- showMenu: true,
- success: function (res) {
- console.log('打开成功');
- UTIL.hideLoadings()
- }
- })
- },
- fail: function (err) {
- console.log(err, "wx.downloadFile fail err");
- UTIL.hideLoadingWithErrorTips()
- }
- })
-
- },
- goSearch(e){
- var that = this;
- let query = {
- openName:e.detail,
- bookId:that.data.bookId,
- deptId:that.data.deptId,
- method:'GET'
- }
- UTIL.httpRequest(API.URL_GET_GETOPENLIST,query,{
- success: (res) => {
- if(res.code == 200){
- for (let i = 0; i < res.rows.length; i++) {
- const element = res.rows[i];
- element.openPic = wx.getStorageSync('dressCode')+element.openPic;
- element.openFile = wx.getStorageSync('dressCode')+element.openFile;
- }
- that.setData({
- list:res.rows
- })
- }else{
- UTIL.showToastNoneIcon(res.msg);
- }
- }
- })
- },
- goFinace(e){
- let date = e.currentTarget.dataset.date;
- let bookId = e.currentTarget.dataset.bookid;
- let deptId = e.currentTarget.dataset.deptid;
- wx.navigateTo({
- url: 'finance?date='+date+'&bookId='+bookId+'&deptId='+deptId,
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
-
- }
- })
|