微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
пре 3 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. import SignaturePad from '../../../../utils/signature_pad';
  2. import * as UTIL from '../../../../utils/util.js';
  3. import * as API from '../../../../utils/API.js';
  4. let signaturePad = {};
  5. let pix = 7;
  6. let penColor = 'black';
  7. let lineWidth = 0.6;
  8. Page({
  9. data: {
  10. penColor: 'black',
  11. lineWidth: 0.6,
  12. isEmpty: true,
  13. baseItem:"",
  14. item:{},
  15. url:"",
  16. isShow:false
  17. },
  18. onLoad: function(options) {
  19. this.getUserInfo();
  20. this.getBaseUrl()
  21. },
  22. /* 获取用户信息*/
  23. getUserInfo(){
  24. UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
  25. success: (res) => {
  26. if (res.code == API.SUCCESS_CODE) {
  27. this.setData({item:res.user})
  28. if(this.data.item.electronicSignature==null||this.data.item.electronicSignature==""){
  29. this.setData({isShow:false})
  30. var ctx = wx.createCanvasContext('handWriting');
  31. const data = {
  32. devicePixelRatio: pix,
  33. };
  34. signaturePad = new SignaturePad(ctx, data);
  35. }else{
  36. this.setData({isShow:true,url:wx.getStorageSync('dressCode')+this.data.item.electronicSignature})
  37. }
  38. }
  39. }
  40. })
  41. },
  42. getBaseUrl:function(){
  43. let params={
  44. configKey: "system.attachment.url"}
  45. UTIL.httpRequest(API.URL_GET_SYSCONFIG,params,{
  46. success: (res) => {
  47. if (res.code == API.SUCCESS_CODE) {
  48. console.log(res.rows[0].configValue+this.data.item.electronicSignature)
  49. this.setData({url:res.rows[0].configValue+this.data.item.electronicSignature})
  50. }
  51. }
  52. })
  53. },
  54. uploadScaleStart(e) {
  55. const item = {
  56. penColor: penColor,
  57. lineWidth: lineWidth
  58. };
  59. signaturePad._handleTouchStart(e, item);
  60. },
  61. back:function(){
  62. wx.navigateBack({
  63. delta: 1
  64. })
  65. },
  66. uploadScaleMove(e) {
  67. signaturePad._handleTouchMove(e);
  68. },
  69. uploadScaleEnd: function(e) {
  70. signaturePad._handleTouchEnd(e);
  71. const isEmpty = signaturePad.isEmpty();
  72. this.setData({
  73. isEmpty: isEmpty
  74. })
  75. },
  76. retDraw: function() {
  77. this.setData({isShow:false})
  78. var ctx = wx.createCanvasContext('handWriting');
  79. const data = {
  80. devicePixelRatio: pix,
  81. };
  82. signaturePad = new SignaturePad(ctx, data);
  83. signaturePad.clear();
  84. const isEmpty = signaturePad.isEmpty();
  85. this.setData({
  86. isEmpty: isEmpty
  87. })
  88. },
  89. getSysInfo: function() {
  90. var that = this
  91. wx.getSystemInfo({
  92. success: function(res) {
  93. pix = res.pixelRatio
  94. that.setData({
  95. width: res.windowWidth * pix,
  96. height: res.windowHeight * pix
  97. })
  98. }
  99. })
  100. },
  101. //保存canvas图像
  102. subCanvas: function() {
  103. let _this = this
  104. if (this.data.isEmpty) {
  105. return false
  106. }
  107. wx.canvasToTempFilePath({
  108. canvasId: 'handWriting',
  109. success: function(res) {
  110. wx.uploadFile({
  111.       url: wx.getStorageSync('dressCode')+API.URL_POST_UPLOADFILE, //服务器地址
  112.       filePath:res.tempFilePath,//本地照片地址
  113.       name: 'file',
  114. header: {
  115. 'Content-Type': 'multipart/form-data',
  116. 'Authorization':'Bearer '+getApp().globalData.userInfo.token, //如果需要token的话要传
  117. },
  118.       success (res){
  119. let dd = JSON.parse(res.data)
  120. if(dd.code==200){
  121. wx.showToast({
  122. title: dd.msg,
  123. duration: 2000,
  124. icon:"success"
  125. })
  126. setTimeout(() => {
  127. _this.back()
  128. }, 2000);
  129. }else{
  130. wx.showToast({
  131. title: dd.msg,
  132. duration: 2000,
  133. icon:"none"
  134. })
  135. }
  136.       }
  137.     })
  138. },
  139. fail: function(res) {
  140. console.log(res)
  141. }
  142. })
  143. },
  144. // 保存电子签名
  145. saveESign : function(item){
  146. UTIL.httpRequest(API.URL_POST_USEREDIT,item,{
  147. success: (res) => {
  148. if (res.code == API.SUCCESS_CODE) {
  149. wx.showToast({
  150. title: "保存成功!",
  151. duration: 2000,
  152. icon:"success"
  153. })
  154. }
  155. }
  156. })
  157. }
  158. })