shopTourOver.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class="shopTourOver-wrap">
  3. <!-- 店长签名 -->
  4. <view class="autograph-con">
  5. <text class="autograph-tit">店长签名:</text>
  6. <view class="autograph-main">
  7. <autograph-to-pic ref="dz" canvasId="handWriting-dz" @generatePictures="autographDz"/>
  8. </view>
  9. </view>
  10. <!-- 巡店人签名 -->
  11. <view class="autograph-con">
  12. <text class="autograph-tit">巡店人签名:</text>
  13. <view class="autograph-main">
  14. <autograph-to-pic ref="xdr" canvasId="handWriting-xd" @generatePictures="autographXdr" />
  15. </view>
  16. </view>
  17. <u-button type="primary" shape="circle" class="submit-btn" @click="submitFun">提交</u-button>
  18. </view>
  19. </template>
  20. <script>
  21. import AutographToPic from '@/components/autograph-to-pic/autograph-to-pic.vue'
  22. import {submitTask} from '@/api/task'
  23. import { clzConfirm,saveBase64ToAliOss } from '@/libs/tools'
  24. export default{
  25. components: {
  26. AutographToPic
  27. },
  28. data(){
  29. return{
  30. taskId: '',
  31. storeManagerSign:'', // 店长签名
  32. inspectorSign:'', // 巡店人签名
  33. sign: 0 // 标记 是否两张签名都已生成
  34. }
  35. },
  36. onLoad(opts) {
  37. this.taskId = opts.taskId
  38. },
  39. methods: {
  40. // 店长签名 生成图片
  41. autographDz(res){
  42. console.log(res,'店长签名+++')
  43. if(res.status == 200){
  44. this.storeManagerSign = res.data
  45. this.sign++
  46. this.$refs.xdr.subCanvas()
  47. }else{
  48. this.storeManagerSign = ''
  49. uni.showToast({ icon: 'none', title: '店长签名生成失败,请重新提交' })
  50. }
  51. },
  52. // 巡店人签名 生成图片
  53. autographXdr(res){
  54. console.log(res,'巡店人签名+++')
  55. if(res.status == 200){
  56. this.inspectorSign = res.data
  57. this.sign++
  58. this.isSubmit()
  59. }else{
  60. this.inspectorSign = ''
  61. uni.showToast({ icon: 'none', title: '巡店人签名生成失败,请重新提交' })
  62. }
  63. },
  64. // 是否提交
  65. isSubmit(){
  66. let _this = this
  67. if(this.sign == 2&&this.storeManagerSign && this.inspectorSign){
  68. console.log('正常提交')
  69. clzConfirm({
  70. title: '提示',
  71. content: '确定提交本次巡店?',
  72. success: function(res) {
  73. if (res.confirm || res.index == 0) {
  74. // 上传图片后提交代码
  75. _this.submitTask()
  76. }
  77. }
  78. })
  79. }else{
  80. uni.showToast({ icon: 'none', title: '签名生成失败,请重新提交' })
  81. }
  82. },
  83. // 提交本次任务
  84. submitFun(){
  85. const dzIsEmpty = this.$refs.dz.isEmpty
  86. const xdrIsEmpty = this.$refs.xdr.isEmpty
  87. if(dzIsEmpty){
  88. uni.showToast({
  89. icon:'none',
  90. title:'店长未签名'
  91. })
  92. return
  93. }
  94. if(xdrIsEmpty){
  95. uni.showToast({
  96. icon:'none',
  97. title:'巡店人未签名'
  98. })
  99. return
  100. }
  101. this.$refs.dz.subCanvas()
  102. },
  103. // 提交
  104. submitTask(){
  105. const _this = this
  106. const data = {
  107. id: _this.taskId,
  108. storeManagerSignPath: _this.storeManagerSign,
  109. inspectorSignPath:_this.inspectorSign
  110. }
  111. console.log(data,'submit data')
  112. submitTask(data).then(ret=>{
  113. console.log(ret)
  114. if(ret.status == 200){
  115. // 关闭上页
  116. uni.$emit("closeTour",1)
  117. // 打开完成页面
  118. uni.redirectTo({
  119. url:"/pages/shopTourCompleted/shopTourCompleted?taskId="+_this.taskId
  120. })
  121. }
  122. uni.showToast({
  123. icon:'none',
  124. title: ret.message
  125. })
  126. })
  127. }
  128. }
  129. }
  130. </script>
  131. <style lang="scss">
  132. page{
  133. background-color: #f8f8f8;
  134. height: calc(100vh - 44px);
  135. }
  136. .shopTourOver-wrap{
  137. height: 100%;
  138. .autograph-con{
  139. margin: 30upx 30upx 0;
  140. border-radius: 12upx;
  141. background-color: #fff;
  142. .autograph-tit{
  143. display: block;
  144. padding: 20upx 30upx;
  145. }
  146. }
  147. .submit-btn{
  148. width: 80%;
  149. margin: 60upx auto 40upx;
  150. }
  151. }
  152. </style>