detail.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. const util = require('../../utils/util.js');
  2. const app = getApp()
  3. Page({
  4. data: {
  5. userInfo: wx.getStorageSync("userInfo"),
  6. cloudCardOrder: {},
  7. pdfUrl: "",
  8. imageList: [],
  9. pay: {},
  10. totalFee: "",
  11. isCheck: false,
  12. modal: true,
  13. detailId: "",
  14. click: true,
  15. fromReceiver: null,
  16. lawyeIds: "",
  17. },
  18. onLoad: function (option) {
  19. var that = this;
  20. that.setData({
  21. detailId : option.id,
  22. fromReceiver: option.fromReceiver
  23. })
  24. wx.request({
  25. url: app.globalData.serverUrl + '/cloudcard/detail',
  26. data: {
  27. openId : wx.getStorageSync("openId"),
  28. id : option.id
  29. },
  30. success(res) {
  31. if (res.data.data != null) {
  32. var list = res.data.data , cloudCardOrder = list.cloudCardOrder , imageList = [] , fileList = [];
  33. wx.login({
  34. success: res => {
  35. wx.request({
  36. url: app.globalData.serverUrl + '/user/weiXinLogin',
  37. data: {
  38. code: res.code
  39. },
  40. header: {
  41. 'content-type': 'application/json'
  42. },
  43. success: function (res) {
  44. wx.setStorageSync('userInfo', res.data.data);
  45. wx.setStorageSync('openId', res.data.data.openid);
  46. var str = cloudCardOrder.initiatorId + "," + cloudCardOrder.receiverId + ",";
  47. for(var i in cloudCardOrder.lawyes) {
  48. str += cloudCardOrder.lawyes[i].id + ",";
  49. }
  50. if(str.indexOf(wx.getStorageSync("userInfo").id) == -1 && cloudCardOrder.isOpen == 1){
  51. wx.showToast({
  52. title: '您没有权限预览!',
  53. icon: 'none',
  54. duration: 2000
  55. })
  56. setTimeout(function() {
  57. wx.reLaunch({
  58. url: '../index/index'
  59. })
  60. }, 100)
  61. return false
  62. } else {
  63. if (cloudCardOrder.orderStatus == 'NOT_PAY') {
  64. cloudCardOrder.statusName = '未支付';
  65. } else if (cloudCardOrder.orderStatus == 'NOT_SIGN') {
  66. cloudCardOrder.statusName = '未签署';
  67. } else if (cloudCardOrder.orderStatus == 'ALREADY_SIGN') {
  68. cloudCardOrder.statusName = '已签署';
  69. } else if (cloudCardOrder.orderStatus == 'ALREADY_REJECT') {
  70. cloudCardOrder.statusName = '已拒绝';
  71. } else if (cloudCardOrder.orderStatus == 'ALREADY_FAILURE') {
  72. cloudCardOrder.statusName = '已失效';
  73. } else if (cloudCardOrder.orderStatus == 'ALREADY_REFUND') {
  74. if (cloudCardOrder.initiatorId != that.data.userInfo.id) {
  75. cloudCardOrder.statusName = '已失效';
  76. } else {
  77. cloudCardOrder.statusName = '已退款';
  78. }
  79. } else {
  80. cloudCardOrder.statusName = '未知';
  81. }
  82. if (cloudCardOrder.orderStatus == 'NOT_SIGN') {
  83. wx.showShareMenu({
  84. withShareTicket: true,
  85. success: function (res) {
  86. }
  87. })
  88. }
  89. for (var i in cloudCardOrder.uploadFileModels) {
  90. var str = app.globalData.fileUrl + cloudCardOrder.uploadFileModels[i].fileUrl;
  91. imageList.push(str);
  92. }
  93. for (var i in cloudCardOrder.textFile) {
  94. var str = app.globalData.fileUrl + cloudCardOrder.textFile[i].fileUrl;
  95. fileList.push({
  96. url: str,
  97. name: cloudCardOrder.textFile[i].fileName,
  98. });
  99. }
  100. var lawyeIds = "";
  101. for (var i in cloudCardOrder.lawyes) {
  102. var str = app.globalData.fileUrl + cloudCardOrder.lawyes[i].headPortrait;
  103. lawyeIds += cloudCardOrder.lawyes[i].id + ",";
  104. cloudCardOrder.lawyes[i].headPortrait = str;
  105. }
  106. var pay = {
  107. appId: list.appId,
  108. nonceStr: list.nonceStr,
  109. package: list.package,
  110. paySign: list.paySign,
  111. signType: list.signType,
  112. timeStamp: list.timeStamp,
  113. }
  114. that.setData({
  115. userInfo: wx.getStorageSync("userInfo"),
  116. cloudCardOrder: cloudCardOrder,
  117. totalFee: list.totalFee,
  118. imageList: imageList,
  119. fileList: fileList,
  120. pdfUrl: list.pdfFile,
  121. pay: pay,
  122. lawyeIds: lawyeIds.indexOf(wx.getStorageSync("userInfo").id)==-1?true:false
  123. })
  124. }
  125. }
  126. })
  127. }
  128. })
  129. } else {
  130. wx.showToast({
  131. title: '获取失败!',
  132. icon: 'none',
  133. duration: 2000
  134. })
  135. }
  136. },
  137. fail: function (res) {
  138. wx.showToast({
  139. title: '获取失败!',
  140. icon: 'none',
  141. duration: 2000
  142. })
  143. }
  144. })
  145. },
  146. onUnload: function () {
  147. // wx.reLaunch({
  148. // url: '../cloud/cloud'
  149. // })
  150. },
  151. //返回首页
  152. back: function (){
  153. if(this.data.userInfo == "" && this.data.userInfo.mobile == null) {
  154. setTimeout(function() {
  155. wx.reLaunch({
  156. url: '../index/index'
  157. })
  158. }, 200)
  159. } else {
  160. setTimeout(function() {
  161. wx.reLaunch({
  162. url: '../cloud/cloud'
  163. })
  164. }, 200)
  165. }
  166. },
  167. //接收
  168. agree: function(e){
  169. wx.navigateTo({
  170. url: '../detail/receiver?id=' + this.data.cloudCardOrder.id
  171. })
  172. },
  173. //图片预览
  174. handleImagePreview: function(e){
  175. const i = e.target.dataset.index;
  176. const images = this.data.imageList;
  177. wx.previewImage({
  178. current: images[i],
  179. urls: images,
  180. })
  181. },
  182. //文件预览
  183. showFile: function(e){
  184. const i = e.target.dataset.index;
  185. var that = this , url = that.data.fileList[i].url;
  186. // wx.getSystemInfo({
  187. // success: function (res) {
  188. // if(res.system.indexOf("iOS") > -1){
  189. // wx.navigateTo({
  190. // url: '../book/pdf?url=' + url + '&type=1'
  191. // })
  192. // } else {
  193. wx.showLoading({
  194. title: '正在打开请稍候...',
  195. })
  196. wx.downloadFile({
  197. url: url,
  198. success: function (res) {
  199. wx.hideLoading()
  200. var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用
  201. wx.openDocument({
  202. filePath: Path,
  203. success: function (res) {
  204. console.log('打开成功');
  205. }
  206. })
  207. },
  208. fail: function (res) {
  209. wx.hideLoading()
  210. wx.showToast({
  211. title: '文件打开失败!',
  212. icon: 'none',
  213. duration: 1000
  214. })
  215. }
  216. })
  217. // }
  218. // }
  219. // })
  220. },
  221. //查看pdf
  222. preview: function(){
  223. var that = this;
  224. // wx.getSystemInfo({
  225. // success: function (res) {
  226. // if(res.system.indexOf("iOS") > -1){
  227. // wx.navigateTo({
  228. // url: '../book/pdf?url=' + that.data.pdfUrl
  229. // })
  230. // } else {
  231. wx.showLoading({
  232. title: '正在打开请稍候...',
  233. })
  234. wx.downloadFile({
  235. url: app.globalData.fileUrl + that.data.pdfUrl,
  236. success: function (res) {
  237. wx.hideLoading()
  238. var Path = res.tempFilePath //返回的文件临时地址,用于后面打开本地预览所用
  239. wx.openDocument({
  240. filePath: Path,
  241. success: function (res) {
  242. console.log('打开成功');
  243. }
  244. })
  245. },
  246. fail: function (res) {
  247. wx.hideLoading()
  248. wx.showToast({
  249. title: '文件打开失败!',
  250. icon: 'none',
  251. duration: 1000
  252. })
  253. }
  254. })
  255. // }
  256. // }
  257. // })
  258. },
  259. //申请证明书
  260. prove: function(){
  261. wx.navigateTo({
  262. url: '../detail/order?id='+this.data.cloudCardOrder.id+'&ccNo=' + this.data.cloudCardOrder.ccNo+'&alreadyAppFlag='+this.data.cloudCardOrder.alreadyAppFlag
  263. })
  264. },
  265. //查看确认书
  266. book: function(){
  267. wx.navigateTo({
  268. url: '../book/book'
  269. })
  270. },
  271. //阅读确认书
  272. checkboxChange: function(e){
  273. var ischeck;
  274. if(e.detail.value.length == 0){
  275. ischeck = false;
  276. } else {
  277. ischeck = true;
  278. }
  279. this.setData({
  280. isCheck: ischeck
  281. })
  282. },
  283. //保存并支付
  284. toPay: function(){
  285. if(!this.data.isCheck){
  286. wx.showToast({
  287. title: '请阅读《网律云证用户确认书》',
  288. icon: 'none',
  289. duration: 1000
  290. })
  291. return false;
  292. } else {
  293. if(this.data.click) {
  294. var that = this;
  295. that.setData({
  296. click: false
  297. })
  298. wx.request({
  299. url: app.globalData.serverUrl + '/cloudcard/payAgain',
  300. data: {
  301. id : that.data.detailId
  302. },
  303. success(res) {
  304. if (res.data.data != null) {
  305. wx.requestPayment({
  306. timeStamp: res.data.data.timeStamp,
  307. nonceStr: res.data.data.nonceStr,
  308. package: res.data.data.package,
  309. signType: 'MD5',
  310. paySign: res.data.data.paySign,
  311. success (res) {
  312. that.setData({
  313. click: true
  314. })
  315. setTimeout(function() {
  316. wx.reLaunch({
  317. url: '../share/share?id=' + that.data.cloudCardOrder.id
  318. })
  319. }, 200)
  320. },
  321. fail (res) {
  322. that.setData({
  323. click: true
  324. })
  325. wx.showToast({
  326. title: "支付失败",
  327. icon: 'none',
  328. duration: 2000
  329. })
  330. }
  331. })
  332. } else {
  333. that.setData({
  334. click: true
  335. })
  336. wx.showToast({
  337. title: '获取失败!',
  338. icon: 'none',
  339. duration: 2000
  340. })
  341. }
  342. },
  343. fail: function (res) {
  344. that.setData({
  345. click: true
  346. })
  347. wx.showToast({
  348. title: '获取失败!',
  349. icon: 'none',
  350. duration: 2000
  351. })
  352. }
  353. })
  354. } else {
  355. wx.showToast({
  356. title: '支付中,请勿重复点击',
  357. icon: 'none',
  358. duration: 1000
  359. })
  360. }
  361. }
  362. }
  363. })