123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204 |
- var sysT = require('../../../../tool/sys-tool.js')
- var businessT = require('../../../../tool/business-tool.js')
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- adapter: {
- suffix: ''
- },
- img: [],
- type: 'display',
- upload: {
- maxC: 0,
- addC: 0
- },
- status: 0,//0正常展示1删除
- },
- deleteAction: businessT.action(function (sender) {
- if (this.data.type == 'display') {
- return
- }
- var that = this
- wx.showModal({
- title: '提示',
- content: '确定删除该图片',
- confirmColor: '#3296FB',
- cancelColor: '#3296FB',
- confirmText: '确定',
- cancelText: '取消',
- success: function (res) {
- if (res.confirm) {
- that.data.img.splice(Number(sender.currentTarget.id), 1)
- if (that.data.img.length == 0) {
- wx.navigateBack({
-
- })
- } else {
- that.data.upload.addC = that.data.upload.maxC - that.data.img.length
- that.setData({
- img: that.data.img,
- upload: that.data.upload
- })
- }
-
- }
- }
- })
- }),
- finishDeleteAction: businessT.action(function (sender) {
- if (this.data.type == 'display') {
- return
- }
- this.data.status = 0
- this.setData({
- status: this.data.status
- })
- businessT.debugLog('finishDeleteAction')
- }),
- changeDelete: businessT.action(function (sender) {
- if (this.data.type == 'display') {
- return
- }
- this.data.status = 1
- this.setData({
- status: this.data.status
- })
- businessT.debugLog('changeDelete')
- }),
- detailsAction: businessT.action(function (sender) {
- if (this.data.status == 1) {
- return
- }
- businessT.debugLog('detailsAction')
- wx.previewImage({
- current: this.data.img[sender.currentTarget.id],
- urls: this.data.img,
- })
- }),
- addImg: businessT.action(function (sender) {
- if (this.data.type == 'display') {
- return
- }
- var that = this
- wx.chooseImage({
- sizeType: ['compressed'],
- count: this.data.upload.addC,
- success: function (res) {
- that.data.img = that.data.img.concat(res.tempFilePaths)
- that.data.upload.addC = that.data.upload.maxC - that.data.img.length
- that.setData({
- img: that.data.img,
- upload: that.data.upload
- })
- },
- })
- }),
- submitAction: businessT.action(function (sender) {
- if (this.data.img.length == 0) {
- wx.showToast({
- title: '请选择图片',
- })
- return
- }
- wx.navigateBack({
- })
- var pages = getCurrentPages()
- pages[pages.length - 2].finishUploadPhoto(this.data.img)
- }),
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- this.data.type = options.type
- wx.setNavigationBarTitle({
- title: this.data.type == 'upload' ? '上传资料' : '详情',
- })
-
- var pages = getCurrentPages()
- this.data.img = pages[pages.length - 2].data.img
- businessT.debugLog(this.data.img)
- if (this.data.type == 'upload') {
- this.data.upload.maxC = options.max
- this.data.upload.addC = this.data.upload.maxC - this.data.img.length
- }
- this.data.adapter = {
- suffix: sysT.suffixOfClass()
- }
- businessT.debugLog(this.data.upload)
-
- this.setData({
- type: this.data.type,
- adapter: this.data.adapter,
- img: this.data.img,
- upload: this.data.upload
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- return {
- path: '/page/home/index',
- imageUrl: '../../../../icon/public/share_img.png',
- title: '自助缴社保公积金,覆盖200多个城市,专业团队操作'
- }
- }
- })
|