123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523 |
- const util = require('../../utils/util.js');
- const app = getApp()
- Page({
- data: {
- userInfo: wx.getStorageSync("userInfo"),
- cloudCardOrder: {},
- validTime: 0,
- imageList: [],
- fileList: [],
- sec: 1,
- countdown: "",
- name: "",//姓名
- phone: "",//手机号
- code: '',//验证码
- iscode: null,//用于存放验证码接口里获取到的code
- codename: '获取验证码',
- disabled: false, //按钮是否禁用
- click: true,
- canShow: false
- },
- onLoad: function (option) {
- var that = this;
- wx.login({
- success: res => {
- wx.request({
- url: app.globalData.serverUrl + '/user/weiXinLogin',
- data: {
- code: res.code
- },
- header: {
- 'content-type': 'application/json'
- },
- success: function (res) {
- if(res.data.statusCode != null){
- wx.showToast({
- title: '获取用户信息失败',
- icon: 'none',
- duration: 2000
- })
- } else {
- app.globalData.userInfo = res.data.data;
- wx.setStorageSync('userInfo', res.data.data);
- wx.setStorageSync('openId', res.data.data.openid);
- that.getDetail(option.id);
- }
-
- },
- fail: function (res) {
- wx.showToast({
- title: '获取用户信息失败',
- icon: 'none',
- duration: 2000
- })
- }
- })
- }
- })
- wx.showShareMenu({
- withShareTicket: true
- })
- },
- //获取详情
- getDetail: function(id){
- var that = this;
-
- wx.request({
- url: app.globalData.serverUrl + '/cloudcard/detail',
- data: {
- openId : wx.getStorageSync("openId"),
- id : id,
- type: 1
- },
- success(res) {
- if (res.data.data != null) {
- var cloudCardOrder = res.data.data.cloudCardOrder, imageList = [], fileList = [];
- var strId = cloudCardOrder.initiatorId + "," + cloudCardOrder.receiverId + ",";
- var lawyeIds = "";
- for (var i in cloudCardOrder.lawyes) {
- strId += cloudCardOrder.lawyes[i].id + ",";
- lawyeIds += cloudCardOrder.lawyes[i].id + ",";
- }
- for (var i in cloudCardOrder.uploadFileModels) {
- var str = app.globalData.fileUrl + cloudCardOrder.uploadFileModels[i].fileUrl;
- imageList.push(str);
- }
- if (cloudCardOrder.receiverId != null) {
- if(strId.indexOf(wx.getStorageSync("userInfo").id) == -1) {
- wx.showToast({
- title: '您没有权限预览!',
- icon: 'none',
- duration: 2000
- })
- setTimeout(function () {
- wx.reLaunch({
- url: '../index/index'
- })
- }, 100)
- return false
- }
- }
- if(res.data.data.cloudCardOrder.isOpen == 1
- && res.data.data.cloudCardOrder.initiatorId != that.data.userInfo.id){
- wx.request({
- url: app.globalData.serverUrl + '/cloudcard/orderChecking',
- data: {
- id : res.data.data.cloudCardOrder.id
- },
- method:"GET",
- success(res) {
- setTimeout(function() {
- wx.reLaunch({
- url: '../detail/detail?id=' + res.data.data.cloudCardOrder.id + '&fromReceiver=1'
- })
- }, 200)
- },
- fail: function (res) {
- setTimeout(function() {
- wx.reLaunch({
- url: '../detail/detail?id=' + res.data.data.cloudCardOrder.id + '&fromReceiver=1'
- })
- }, 200)
- }
- })
- setTimeout(function() {
- wx.reLaunch({
- url: '../detail/detail?id=' + res.data.data.cloudCardOrder.id + '&fromReceiver=1'
- })
- }, 200)
- }
- if(res.data.data.cloudCardOrder.orderStatus != "NOT_SIGN"){
- setTimeout(function() {
- wx.reLaunch({
- url: '../detail/detail?id=' + res.data.data.cloudCardOrder.id + '&fromReceiver=1'
- })
- }, 200)
- }
- for (var i in cloudCardOrder.textFile) {
- var str = app.globalData.fileUrl + cloudCardOrder.textFile[i].fileUrl;
- fileList.push({
- url: str,
- name: cloudCardOrder.textFile[i].fileName
- });
- }
- for (var i in cloudCardOrder.lawyes) {
- var str = app.globalData.fileUrl + cloudCardOrder.lawyes[i].headPortrait;
- cloudCardOrder.lawyes[i].headPortrait = str;
- }
- that.setData({
- cloudCardOrder: cloudCardOrder,
- validTime: res.data.data.minute,
- sec: res.data.data.second,
- imageList: imageList,
- fileList: fileList
- })
- that.countTime();
- if (cloudCardOrder.initiatorId == that.data.userInfo.id) {
- that.setData({
- // countdown: cloudCardOrder.validTime + "分 00 秒",
- canShow: false
- })
- } else {
- that.setData({
- canShow: true
- })
- wx.request({
- url: app.globalData.serverUrl + "/cloudcard/checkIsOpen",
- method: "GET",
- data: {
- id: that.data.cloudCardOrder.id,
- isOpen: 1
- },
- success(res) {
- },
- fail: function (res) {
- }
- })
- }
- } else {
- wx.showToast({
- title: '获取失败!',
- icon: 'none',
- duration: 2000
- })
- }
- },
- fail: function (res) {
- wx.showToast({
- title: '获取失败!',
- icon: 'none',
- duration: 2000
- })
- }
- })
- },
- //倒计时
- countTime: function(){
- var m = this.data.validTime , s = this.data.sec;
- if (m >= 0) {
- m = m < 10 ? "0" + m : m;
- s = s < 10 ? "0" + s : s;
-
- this.setData({
- countdown: m + "分 " + s + " 秒",
- })
- this.data.sec--;
- if(this.data.sec < 0){
- this.data.sec = 59;
- this.data.validTime--;
- }
- this.setData({
- validTime: this.data.validTime,
- sec: this.data.sec
- })
- //递归每秒调用countTime方法,显示动态时间效果
- setTimeout(this.countTime, 1000);
- } else {
- this.setData({
- countdown: '已过期'
- })
- setTimeout(function() {
- wx.reLaunch({
- url: '../detail/detail?id=' + that.data.cloudCardOrder.id + '&fromReceiver=1'
- })
- }, 200)
- }
- },
- //图片预览
- 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 = this.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
- })
- }
- })
- // }
- // }
- // })
- },
- getNameValue: function (e) {
- this.setData({
- name: e.detail.value
- })
- },
- getPhoneValue: function (e) {
- this.setData({
- phone: e.detail.value
- })
- },
- getCodeValue: function (e) {
- this.setData({
- code: e.detail.value
- })
- },
- //判断手机号
- getCode: function () {
- var phoneNum = this.data.phone;
- var that = this;
- var myreg = /^1[0-9]{10,11}$/;
- if (this.data.phone == "") {
- wx.showToast({
- title: '手机号不能为空',
- icon: 'none',
- duration: 1000
- })
- return false;
- } else if (!myreg.test(this.data.phone)) {
- wx.showToast({
- title: '请输入正确的手机号',
- icon: 'none',
- duration: 1000
- })
- return false;
- } else {
- wx.showLoading({
- title: '请稍候...',
- mask: true
- })
- wx.request({
- url: app.globalData.serverUrl + "/cloudcard/getVcode",
- data: {
- mobile: phoneNum
- },
- success(res) {
- wx.hideLoading();
- // that.setData({
- // iscode: res.data.data
- // })
- var num = 61;
- var timer = setInterval(function () {
- num--;
- if (num <= 0) {
- clearInterval(timer);
- that.setData({
- codename: '重新发送',
- disabled: false
- })
- } else {
- that.setData({
- codename: num + "s"
- })
- }
- }, 1000)
- },
- fail: function (res) {
- wx.hideLoading();
- }
- })
- }
- },
- //获取验证码
- getVerificationCode() {
- this.getCode();
- var that = this
- that.setData({
- disabled: true
- })
- },
- //查看确认书
- book: function(){
- wx.navigateTo({
- url: '../book/book'
- })
- },
- //同意
- agree: function(e){
- var myreg = /^1[0-9]{10,11}$/;
- if (this.data.name == "") {
- wx.showToast({
- title: '姓名不能为空',
- icon: 'none',
- duration: 1000
- })
- return false;
- } else if (this.data.phone == "") {
- wx.showToast({
- title: '手机号不能为空',
- icon: 'none',
- duration: 1000
- })
- return false;
- } else if (!myreg.test(this.data.phone)) {
- wx.showToast({
- title: '请输入正确的手机号',
- icon: 'none',
- duration: 1000
- })
- return false;
- } else if (this.data.code == "") {
- 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/orderAgree",
- method: "GET",
- data: {
- orderId: that.data.cloudCardOrder.id,
- openid: wx.getStorageSync("openId"),
- userName: that.data.name,
- mobile: that.data.phone,
- VCode: that.data.code,
- formId: e.detail.formId
- },
- success(res) {
- wx.request({
- url: app.globalData.fileUrl + "/index/copy",
- method: "GET",
- data: {
- id: that.data.cloudCardOrder.id
- },
- success(res) {
- },
- fail: function (res) {
- }
- })
- that.setData({
- click: true
- })
- if(res.data.code == "ok"){
- wx.showToast({
- title: "操作成功",
- icon: 'success',
- duration: 2000
- })
- } else {
- wx.showToast({
- title: res.data.msg,
- icon: 'none',
- duration: 2000
- })
- }
-
- setTimeout(function() {
- wx.reLaunch({
- url: '../detail/detail?id=' + that.data.cloudCardOrder.id + '&fromReceiver=1'
- })
- }, 200)
- },
- fail: function (res) {
- that.setData({
- click: true
- })
- wx.showToast({
- title: "操作失败",
- icon: 'none',
- duration: 2000
- })
- }
- })
- } else {
- wx.showToast({
- title: '保存中,请勿重复提交',
- icon: 'none',
- duration: 1000
- })
- }
- }
- },
- //拒绝
- refuse: function(e){
- if(this.data.click){
- var that = this;
- that.setData({
- click: false
- })
- wx.request({
- url: app.globalData.serverUrl + "/cloudcard/orderReject",
- method: "GET",
- data: {
- orderId: that.data.cloudCardOrder.id,
- openid: wx.getStorageSync("openId"),
- formId: e.detail.formId
- },
- success(res) {
- if(res.data.code == "ok"){
- wx.showToast({
- title: "操作成功",
- icon: 'success',
- duration: 2000
- })
- } else {
- wx.showToast({
- title: "操作失败",
- icon: 'none',
- duration: 2000
- })
- }
- setTimeout(function() {
- wx.reLaunch({
- url: '../detail/detail?id=' + that.data.cloudCardOrder.id + '&fromReceiver=1'
- })
- }, 200)
- },
- fail: function (res) {
- wx.showToast({
- title: "操作失败",
- icon: 'none',
- duration: 2000
- })
- }
- })
- } else {
- wx.showToast({
- title: '保存中,请勿重复提交',
- icon: 'none',
- duration: 1000
- })
- }
- }
- })
|