signature.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view class="sign">
  3. <ujp-navbar title="签字"></ujp-navbar>
  4. <p>请在下方空白区域使用正楷字体进行电子签名</p>
  5. <view class="signature">
  6. <l-signature disableScroll ref="signatureRef" :penColor="penColor" :penSize="penSize"
  7. :openSmooth="openSmooth"></l-signature>
  8. </view>
  9. <view class="clean-save">
  10. <view class="clean" @click="onClick('clear')">
  11. <img src="../../../assets/img/riLine-eraser-line.svg" alt="">
  12. <view class="">
  13. 清除
  14. </view>
  15. </view>
  16. <view class="save" @click="onClick('save')">
  17. <img src="../../../assets/img/riLine-eraser-line.svg" alt="">
  18. <view class="">
  19. 保存
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. import LSignature from '@/components/l-signature/l-signature.vue'
  27. import * as API from '@/apis/finance.js'
  28. import * as API_Common from '@/apis/common.js'
  29. export default {
  30. data() {
  31. return {
  32. info: null,
  33. detailList:null,
  34. penColor: '',
  35. penSize: 5,
  36. url: '',
  37. suburl: '',
  38. openSmooth: true,
  39. nowTime:"",
  40. serverUrl: "",
  41. token: "",
  42. }
  43. },onLoad(op){
  44. //this.userInfo=this.carhelp.getPersonInfo("merchantUser")
  45. this.id=op.id
  46. this.getInfo()
  47. },
  48. methods: {
  49. //上传图片
  50. uploadpic() {
  51. uni.showLoading({
  52. title: "图片上传中",
  53. mask: true,
  54. })
  55. var formData = {
  56. "photoName":"signature.png",
  57. "photoBase64Data": this.url
  58. }
  59. // formData.append('photoName', '1.jpg');
  60. // formData.append('photoBase64Data', this.url);
  61. API_Common.uploadBase64Json(formData).then(response => {
  62. //this.suburl=response.data;
  63. this.info.status=0;
  64. this.info.signUrl=response.data;
  65. //this.$emit("signsubmit",0,this.suburl)
  66. this.submitFrom()
  67. }).catch(error => {
  68. uni.hideLoading()
  69. uni.showModal({
  70. title:"提示",
  71. content:error,
  72. showCancel:false
  73. })
  74. })
  75. },
  76. submitFrom(){
  77. uni.showLoading({
  78. title: "提交中...",
  79. mask: true,
  80. })
  81. //this.info.status=0;
  82. //var str=JSON.stringify();
  83. API.applyWithdrawByAccounting({
  84. record:this.info,
  85. detailList:this.detailList
  86. }).then((res) => {
  87. this.carhelp.set("withdrawRecord",{
  88. uuid:this.uuid,
  89. })
  90. this.id=res.data;
  91. uni.hideLoading()
  92. uni.redirectTo({
  93. url:"/pagesFinance/user/applyResult?value="+this.info.applicationAmount
  94. })
  95. }).catch(error => {
  96. uni.hideLoading()
  97. uni.showModal({
  98. title:"提示",
  99. content:error,
  100. showCancel:false
  101. })
  102. })
  103. },
  104. getInfo(){
  105. uni.showLoading({
  106. title: "加载中",
  107. mask: true,
  108. })
  109. API.getWithdrawInfoByAccounting(this.id).then((res) => {
  110. this.info=res.data.record
  111. this.detailList=res.data.detailList
  112. uni.hideLoading()
  113. }).catch(error => {
  114. uni.showToast({
  115. title: error
  116. })
  117. })
  118. },
  119. onClick(type) {
  120. this.url =""
  121. if(type == 'openSmooth') {
  122. this.openSmooth = !this.openSmooth
  123. return
  124. }
  125. if (type == 'save') {
  126. this.$refs.signatureRef.canvasToTempFilePath({
  127. success: (res) => {
  128. // 是否为空画板 无签名
  129. if(res.isEmpty){
  130. this.url ="";
  131. }else{
  132. this.url = res.tempFilePath
  133. console.log(this.url)
  134. // 生成图片的临时路径
  135. // app | H5 | 微信小程序 生成的是base64
  136. //this.uploadpic()
  137. uni.showLoading({
  138. title: '上传中'
  139. });
  140. this.token=this.carhelp.getToken();
  141. this.serverUrl=process.car.BASE_URL;
  142. uni.request({
  143. url: this.serverUrl + "/uploadBase64Json",
  144. method: "POST",
  145. header: {
  146. Authorization: this.token
  147. },
  148. data: {
  149. "photoName":"signature.png",
  150. "photoBase64Data": this.url
  151. },
  152. success: (res) => {
  153. uni.hideLoading();
  154. console.log(res)
  155. if(res.data.result){
  156. uni.showToast({
  157. title: '签名保存成功!',
  158. duration: 2000
  159. });
  160. this.info.status=0;
  161. this.info.signUrl=response.data;
  162. //this.$emit("signsubmit",0,this.suburl)
  163. this.submitFrom()
  164. }
  165. else{
  166. uni.showToast({
  167. title: '签名保存失败!',
  168. duration: 2000
  169. });
  170. }
  171. }
  172. })
  173. }
  174. }
  175. })
  176. return
  177. }
  178. if (this.$refs.signatureRef)
  179. this.$refs.signatureRef[type]()
  180. }
  181. }
  182. }
  183. </script>
  184. <style lang="scss" scoped>
  185. .sign{
  186. margin: 32rpx 16rpx ;
  187. font-weight: bold;
  188. line-height: 20px;
  189. p{
  190. color: rgba(16, 16, 16, 1);
  191. }
  192. .signature{
  193. background-color: #fff;
  194. margin-top: 8px;
  195. height: 160px;
  196. border: #c2c2c2 1px solid;
  197. }
  198. .clean-save{
  199. background-color: #fff;
  200. display: flex;
  201. .clean,.save{
  202. width: 50%;
  203. text-align: center;
  204. color: #252525;
  205. line-height: 40px;
  206. }
  207. .clean,.save{
  208. border:#c2c2c2 1px solid;
  209. display: flex;
  210. justify-content: center;
  211. img{
  212. margin-right: 4px;
  213. }
  214. }
  215. }
  216. }
  217. </style>