signature.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <template>
  2. <view>
  3. <u--form :model="inputForm" labelWidth="100px" class="u-form" labelPosition="left"
  4. ref="inputForm">
  5. <u-form-item label="旧签名" borderBottom prop="signPic">
  6. <u--image :showLoading="true" :src="BASE_URL + inputForm.signPic " width="100px" height="40px"></u--image>
  7. </u-form-item>
  8. <u-form-item label="签字" borderBottom prop="signPic">
  9. <signInput ref="sign" canvasId="twoDrowCanvas" canvasIds="twoRotateCanvas" :header="header"
  10. :action="action" @signToUrl="signToUrl">
  11. </signInput>
  12. </u-form-item>
  13. <view class="padding-xl">
  14. <u-button type="primary" @click="formSubmit" text="提交"></u-button>
  15. </view>
  16. </u--form>
  17. </view>
  18. </template>
  19. <script>
  20. import userService from "@/api/sys/userService"
  21. import * as $auth from "@/common/auth.js"
  22. import BASE_URL from '@/config.js'
  23. import signInput from "@/components/am-sign-input/am-sign-input.vue"
  24. export default {
  25. components:{
  26. signInput
  27. },
  28. data() {
  29. return {
  30. action: this.BASE_URL + '/gwfile/upload?uploadPath=sign', //上传服务器的地址
  31. header: {"token": $auth.getUserToken()}, //图片上传携带头部信息
  32. loading: false,
  33. inputForm: this.$auth.getUserInfo()
  34. }
  35. },
  36. methods: {
  37. /**
  38. * @param {Object} e
  39. * 签名完成回调
  40. */
  41. signToUrl(e) {
  42. console.log("签字=====", e);
  43. this.inputForm.signPic = e.data
  44. if (e.error_code && e.error_code === '201') {
  45. uni.showToast({
  46. title: e.msg,
  47. icon: 'none'
  48. })
  49. return
  50. }
  51. },
  52. formSubmit: function(e) {
  53. //定义表单规则
  54. // this.$refs.inputForm.validate().then(res => {
  55. uni.showLoading()
  56. userService.saveInfo(this.inputForm).then((data) => {
  57. uni.showToast({
  58. title: data,
  59. icon: "success"
  60. });
  61. uni.clearStorage();
  62. uni.reLaunch({
  63. url: '/pages/login/login'
  64. })
  65. // }).catch((e) => {
  66. // console.log(e)
  67. // })
  68. })
  69. }
  70. }
  71. }
  72. </script>
  73. <style>
  74. .btn-logout {
  75. margin-top: 100upx;
  76. width: 80%;
  77. border-radius: 50upx;
  78. font-size: 16px;
  79. color: #fff;
  80. background: linear-gradient(to right, #365fff, #36bbff);
  81. }
  82. .btn-logout-hover {
  83. background: linear-gradient(to right, #365fdd, #36bbfa);
  84. }
  85. .cu-form-group .title {
  86. min-width: calc(4em + 40px);
  87. }
  88. </style>