123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- import { documentList, createQRcode } from "../../api/document";
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- qrcodeDialog: false,
- currentPage: 1,
- hasNext: false,
- fileList: [],
- baseStr: 'data:image/jpg;base64,',
- QRCodeBase64: '',
- qrUserName: ''
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- this.getDocumentList()
- },
- // 获取档案列表
- getDocumentList () {
- var data = {
- currentPage: this.data.currentPage
- }
- wx.showLoading({
- title: '加载中...',
- mask: true
- })
- documentList(data).then(res => {
- wx.hideLoading()
- var response = res.data.vos
- response.map(item => {
- item.birthDay = item.birthday.split(' ')[0]
- })
- this.setData({
- hasNext: res.data.hasNext,
- fileList: response
- })
- }).catch(e => {
- wx.hideLoading()
- wx.showModal({
- content: e,
- confirmColor: '#333',
- showCancel: false
- })
- })
- },
- onReachBottom () {
- if (this.data.hasNext) {
- var _currentPag = this.data.currentPage + 1
- this.setData({
- currentPage: _currentPag
- })
- this.getDocumentList()
- }
- },
- handleReportDetail (e) {
- var reportid = e.currentTarget.dataset.reportid
- wx.navigateTo({
- url: '/pages/reportDetail/reportDetail?reportid=' + reportid
- })
- },
- /**
- * 新建档案
- */
- handleAddFile() {
- wx.navigateTo({
- url: '/pages/createFile/createFile?from=myFile'
- })
- },
- /**
- * 管理档案
- */
- handleFile() {
- if (this.data.fileList.length !== 0) {
- wx.navigateTo({
- url: '/pages/handleFile/handleFile',
- })
- } else {
- wx.showToast({
- title: '暂无档案',
- icon: 'error'
- })
- }
- },
- handleShowQRCode (e) {
- var that = this
- var id = e.currentTarget.dataset.id
- var realname = e.currentTarget.dataset.realname
- this.setData({
- qrUserName: realname
- })
- wx.showLoading({
- title: '生成中...'
- })
- createQRcode({ documentId: id }).then(res => {
- wx.hideLoading()
- that.setData({
- QRCodeBase64: that.data.baseStr + res.data,
- qrcodeDialog: true
- })
- }).catch(e => {
- wx.hideLoading()
- wx.showModal({
- content: e,
- confirmColor: '#333',
- showCancel: false
- })
- })
- },
- handleCloseQRCode () {
- this.setData({
- qrcodeDialog: false,
- QRCodeBase64: ''
- })
- }
- })
|