shopTourOver.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. }else{
  46. this.storeManagerSign = ''
  47. // uni.showToast({ icon: 'none', title: res.message })
  48. // return
  49. }
  50. this.sign++
  51. this.isSubmit()
  52. },
  53. // 巡店人签名 生成图片
  54. autographXdr(res){
  55. console.log(res,'巡店人签名+++')
  56. if(res.status == 200){
  57. this.inspectorSign = res.data
  58. }else{
  59. this.inspectorSign = ''
  60. // uni.showToast({ icon: 'none', title: res.message })
  61. // return
  62. }
  63. this.sign++
  64. this.isSubmit()
  65. },
  66. // 是否提交
  67. isSubmit(){
  68. if(this.sign == 2){
  69. if(this.storeManagerSign && this.inspectorSign){
  70. console.log('正常提交')
  71. clzConfirm({
  72. title: '提示',
  73. content: '确定提交本次巡店?',
  74. success: function(res) {
  75. if (res.confirm || res.index == 0) {
  76. // 上传图片后提交代码
  77. _this.submitTask()
  78. }
  79. }
  80. })
  81. }else{
  82. if(!this.storeManagerSign){
  83. uni.showToast({ icon: 'none', title: '店长签名生成失败,请重新提交' })
  84. return
  85. }
  86. if(!this.inspectorSign){
  87. uni.showToast({ icon: 'none', title: '巡店人签名生成失败,请重新提交' })
  88. return
  89. }
  90. }
  91. }
  92. },
  93. // 提交本次任务
  94. submitFun(){
  95. const dzIsEmpty = this.$refs.dz.isEmpty
  96. const xdrIsEmpty = this.$refs.xdr.isEmpty
  97. if(dzIsEmpty){
  98. uni.showToast({
  99. icon:'none',
  100. title:'店长未签名'
  101. })
  102. return
  103. }
  104. if(xdrIsEmpty){
  105. uni.showToast({
  106. icon:'none',
  107. title:'巡店人未签名'
  108. })
  109. return
  110. }
  111. this.$refs.dz.subCanvas()
  112. this.$refs.xdr.subCanvas()
  113. },
  114. // 提交
  115. submitTask(){
  116. const _this = this
  117. submitTask({
  118. id: _this.taskId,
  119. inspectorSign: _this.inspectorSign,
  120. storeManagerSign: _this.storeManagerSign
  121. }).then(ret=>{
  122. console.log(ret)
  123. if(ret.status == 200){
  124. // 关闭上页
  125. uni.$emit("closeTour",1)
  126. // 打开完成页面
  127. uni.redirectTo({
  128. url:"/pages/shopTourCompleted/shopTourCompleted?taskId="+_this.taskId
  129. })
  130. }
  131. uni.showToast({
  132. icon:'none',
  133. title: ret.message
  134. })
  135. })
  136. }
  137. }
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. page{
  142. background-color: #f8f8f8;
  143. height: calc(100vh - 44px);
  144. }
  145. .shopTourOver-wrap{
  146. height: 100%;
  147. .autograph-con{
  148. margin: 30upx 30upx 0;
  149. border-radius: 12upx;
  150. background-color: #fff;
  151. .autograph-tit{
  152. display: block;
  153. padding: 20upx 30upx;
  154. }
  155. }
  156. .submit-btn{
  157. width: 80%;
  158. margin: 60upx auto 40upx;
  159. }
  160. }
  161. </style>