工行这里学车报名流程h5
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.

137 lines
3.0 KiB

2 years ago
  1. <template>
  2. <view class="box">
  3. <view class="main">
  4. <signature :showCanvas="showCanvas" @closeCanvas="closeCanvas" @getCanvasImg="getCanvasImg"></signature>
  5. </view>
  6. </view>
  7. </template>
  8. <script>
  9. import signature from './signature.vue';
  10. import carLearn from '@/api/carLearn.js'
  11. import { APP_API, APP_HOST } from '@/site.config.js';
  12. export default {
  13. components: {
  14. signature
  15. },
  16. data() {
  17. return {
  18. //打开canvas绘制签名
  19. showCanvas: true,
  20. //是否展示操作菜单
  21. completionSignPath: '' ,//签名路径
  22. completionSignImg:'', //签名图片base64
  23. signImg:"", //原有签名图片
  24. params: {
  25. studentId: uni.getStorageSync('studentId')||'',
  26. part: '',
  27. signUrl: ''
  28. }
  29. }
  30. },
  31. onLoad(option) {
  32. this.params.part = option.part
  33. },
  34. methods: {
  35. //隐藏canvas签名组件
  36. closeCanvas(e) {
  37. // this.showCanvas = false;
  38. if (e) {
  39. this.completionSignPath = e
  40. this.ossUpload();
  41. }
  42. },
  43. //获取图片内容
  44. getCanvasImg(e) {
  45. if (e) {
  46. this.completionSignImg = e
  47. // this.ossUpload()
  48. }
  49. },
  50. sign() {
  51. this.showCanvas = true;
  52. },
  53. //上传签名
  54. ossUpload() {
  55. let _this = this
  56. if(!this.completionSignPath){
  57. uni.showToast({
  58. title: '签名为空不能上传',
  59. icon: 'none',
  60. duration: 2000
  61. })
  62. return;
  63. }
  64. const _url = APP_HOST + APP_API + '/util/manage/uploadFile.do';
  65. console.log('来到这里了吗?')
  66. console.log(this.completionSignPath)
  67. uni.uploadFile({
  68. url: _url,
  69. filePath: this.completionSignPath,
  70. name: 'file',
  71. formData: {
  72. fileType: 1,
  73. fileSuffix: "png",
  74. },
  75. header: {
  76. 'token' : uni.getStorageSync("Authorization") || '',
  77. },
  78. success: res => {
  79. // 判断是否json字符串,将其转为json格式
  80. let data = typeof(res.data) == 'string' ? JSON.parse(res.data) : res.data;
  81. if (data.code==0) {
  82. console.log(data.data)
  83. _this.params.signUrl = data.data
  84. _this.saveStudentPeriodSign()
  85. }
  86. console.log(res)
  87. },
  88. fail: err =>{
  89. console.log('err',err);
  90. uni.$u.toast(err.errMsg);
  91. }
  92. });
  93. },
  94. // 确认认签名
  95. async saveStudentPeriodSign() {
  96. const [err, res] = await carLearn.saveStudentPeriodSign(this.params)
  97. console.log('签名成功')
  98. console.log(res)
  99. if(res.data.code!=0) return this.$u.toast(res.message)
  100. // 锁定竖屏
  101. // #ifdef APP-PLUS
  102. plus.screen.lockOrientation("portrait-primary");
  103. // #endif
  104. this.$refs.uToast.show({
  105. title: '上传成功',
  106. type: 'success',
  107. url: '/pages/learnDriveStep/confirmClassHour/back'
  108. })
  109. },
  110. }
  111. }
  112. </script>
  113. <style scoped lang="scss">
  114. .box {
  115. overflow: hidden;
  116. height: 100vh;
  117. }
  118. .main {
  119. width: 100%;
  120. height: 100%;
  121. background: #fff;
  122. overflow-y: scroll;
  123. /* 使用滚动区域代替Webview滚动 */
  124. -webkit-overflow-scrolling: touch;
  125. /* IOS弹性 */
  126. position: relative;
  127. /* 相对位置 */
  128. overflow-x: hidden;
  129. /* X轴滚动 */
  130. -webkit-transform: translateZ(0);
  131. /* 3D加速 */
  132. -webkit-overflow-scrolling: touch;
  133. }
  134. </style>