const util = require('../../utils/util.js'); const app = getApp() Page({ data: { userInfo: wx.getStorageSync("userInfo"), cloudCardOrder: {}, pdfUrl: "", imageList: [], pay: {}, totalFee: "", isCheck: false, modal: true, detailId: "", click: true, fromReceiver: null, lawyeIds: "", }, onLoad: function (option) { var that = this; that.setData({ detailId : option.id, fromReceiver: option.fromReceiver }) wx.request({ url: app.globalData.serverUrl + '/cloudcard/detail', data: { openId : wx.getStorageSync("openId"), id : option.id }, success(res) { if (res.data.data != null) { var list = res.data.data , cloudCardOrder = list.cloudCardOrder , imageList = [] , fileList = []; wx.login({ success: res => { wx.request({ url: app.globalData.serverUrl + '/user/weiXinLogin', data: { code: res.code }, header: { 'content-type': 'application/json' }, success: function (res) { wx.setStorageSync('userInfo', res.data.data); wx.setStorageSync('openId', res.data.data.openid); var str = cloudCardOrder.initiatorId + "," + cloudCardOrder.receiverId + ","; for(var i in cloudCardOrder.lawyes) { str += cloudCardOrder.lawyes[i].id + ","; } if(str.indexOf(wx.getStorageSync("userInfo").id) == -1 && cloudCardOrder.isOpen == 1){ wx.showToast({ title: '您没有权限预览!', icon: 'none', duration: 2000 }) setTimeout(function() { wx.reLaunch({ url: '../index/index' }) }, 100) return false } else { if (cloudCardOrder.orderStatus == 'NOT_PAY') { cloudCardOrder.statusName = '未支付'; } else if (cloudCardOrder.orderStatus == 'NOT_SIGN') { cloudCardOrder.statusName = '未签署'; } else if (cloudCardOrder.orderStatus == 'ALREADY_SIGN') { cloudCardOrder.statusName = '已签署'; } else if (cloudCardOrder.orderStatus == 'ALREADY_REJECT') { cloudCardOrder.statusName = '已拒绝'; } else if (cloudCardOrder.orderStatus == 'ALREADY_FAILURE') { cloudCardOrder.statusName = '已失效'; } else if (cloudCardOrder.orderStatus == 'ALREADY_REFUND') { if (cloudCardOrder.initiatorId != that.data.userInfo.id) { cloudCardOrder.statusName = '已失效'; } else { cloudCardOrder.statusName = '已退款'; } } else { cloudCardOrder.statusName = '未知'; } if (cloudCardOrder.orderStatus == 'NOT_SIGN') { wx.showShareMenu({ withShareTicket: true, success: function (res) { } }) } for (var i in cloudCardOrder.uploadFileModels) { var str = app.globalData.fileUrl + cloudCardOrder.uploadFileModels[i].fileUrl; imageList.push(str); } for (var i in cloudCardOrder.textFile) { var str = app.globalData.fileUrl + cloudCardOrder.textFile[i].fileUrl; fileList.push({ url: str, name: cloudCardOrder.textFile[i].fileName, }); } var lawyeIds = ""; for (var i in cloudCardOrder.lawyes) { var str = app.globalData.fileUrl + cloudCardOrder.lawyes[i].headPortrait; lawyeIds += cloudCardOrder.lawyes[i].id + ","; cloudCardOrder.lawyes[i].headPortrait = str; } var pay = { appId: list.appId, nonceStr: list.nonceStr, package: list.package, paySign: list.paySign, signType: list.signType, timeStamp: list.timeStamp, } that.setData({ userInfo: wx.getStorageSync("userInfo"), cloudCardOrder: cloudCardOrder, totalFee: list.totalFee, imageList: imageList, fileList: fileList, pdfUrl: list.pdfFile, pay: pay, lawyeIds: lawyeIds.indexOf(wx.getStorageSync("userInfo").id)==-1?true:false }) } } }) } }) } else { wx.showToast({ title: '获取失败!', icon: 'none', duration: 2000 }) } }, fail: function (res) { wx.showToast({ title: '获取失败!', icon: 'none', duration: 2000 }) } }) }, onUnload: function () { // wx.reLaunch({ // url: '../cloud/cloud' // }) }, //返回首页 back: function (){ if(this.data.userInfo == "" && this.data.userInfo.mobile == null) { setTimeout(function() { wx.reLaunch({ url: '../index/index' }) }, 200) } else { setTimeout(function() { wx.reLaunch({ url: '../cloud/cloud' }) }, 200) } }, //接收 agree: function(e){ wx.navigateTo({ url: '../detail/receiver?id=' + this.data.cloudCardOrder.id }) }, //图片预览 handleImagePreview: function(e){ const i = e.target.dataset.index; const images = this.data.imageList; wx.previewImage({ current: images[i], urls: images, }) }, //文件预览 showFile: function(e){ const i = e.target.dataset.index; var that = this , url = that.data.fileList[i].url; // wx.getSystemInfo({ // success: function (res) { // if(res.system.indexOf("iOS") > -1){ // wx.navigateTo({ // url: '../book/pdf?url=' + url + '&type=1' // }) // } else { wx.showLoading({ title: '正在打开请稍候...', }) wx.downloadFile({ url: url, success: function (res) { wx.hideLoading() var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用 wx.openDocument({ filePath: Path, success: function (res) { console.log('打开成功'); } }) }, fail: function (res) { wx.hideLoading() wx.showToast({ title: '文件打开失败!', icon: 'none', duration: 1000 }) } }) // } // } // }) }, //查看pdf preview: function(){ var that = this; // wx.getSystemInfo({ // success: function (res) { // if(res.system.indexOf("iOS") > -1){ // wx.navigateTo({ // url: '../book/pdf?url=' + that.data.pdfUrl // }) // } else { wx.showLoading({ title: '正在打开请稍候...', }) wx.downloadFile({ url: app.globalData.fileUrl + that.data.pdfUrl, success: function (res) { wx.hideLoading() var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用 wx.openDocument({ filePath: Path, success: function (res) { console.log('打开成功'); } }) }, fail: function (res) { wx.hideLoading() wx.showToast({ title: '文件打开失败!', icon: 'none', duration: 1000 }) } }) // } // } // }) }, //申请证明书 prove: function(){ wx.navigateTo({ url: '../detail/order?id='+this.data.cloudCardOrder.id+'&ccNo=' + this.data.cloudCardOrder.ccNo+'&alreadyAppFlag='+this.data.cloudCardOrder.alreadyAppFlag }) }, //查看确认书 book: function(){ wx.navigateTo({ url: '../book/book' }) }, //阅读确认书 checkboxChange: function(e){ var ischeck; if(e.detail.value.length == 0){ ischeck = false; } else { ischeck = true; } this.setData({ isCheck: ischeck }) }, //保存并支付 toPay: function(){ if(!this.data.isCheck){ wx.showToast({ title: '请阅读《网律云证用户确认书》', icon: 'none', duration: 1000 }) return false; } else { if(this.data.click) { var that = this; that.setData({ click: false }) wx.request({ url: app.globalData.serverUrl + '/cloudcard/payAgain', data: { id : that.data.detailId }, success(res) { if (res.data.data != null) { wx.requestPayment({ timeStamp: res.data.data.timeStamp, nonceStr: res.data.data.nonceStr, package: res.data.data.package, signType: 'MD5', paySign: res.data.data.paySign, success (res) { that.setData({ click: true }) setTimeout(function() { wx.reLaunch({ url: '../share/share?id=' + that.data.cloudCardOrder.id }) }, 200) }, fail (res) { that.setData({ click: true }) wx.showToast({ title: "支付失败", icon: 'none', duration: 2000 }) } }) } else { that.setData({ click: true }) wx.showToast({ title: '获取失败!', icon: 'none', duration: 2000 }) } }, fail: function (res) { that.setData({ click: true }) wx.showToast({ title: '获取失败!', icon: 'none', duration: 2000 }) } }) } else { wx.showToast({ title: '支付中,请勿重复点击', icon: 'none', duration: 1000 }) } } } })