editCertificate.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <template>
  2. <view class='content'>
  3. <view class='wrap'>
  4. <u--form ref="uForm">
  5. <u-form-item labelWidth='80' labelPosition='top' label="营业执照">
  6. <u-upload height='208' width='320' :fileList="fileList2" @afterRead="afterRead($event,1)" @delete="deletePic" name="2" multiple
  7. :maxCount="1">
  8. <image style='width:680rpx;height:417rpx;' src="@/static/image/enter/yingyezhizhao.png" mode=""></image>
  9. </u-upload>
  10. </u-form-item>
  11. <u-form-item labelWidth='80' labelPosition='top' label="经营许可证">
  12. <u-upload height='208' width='320' :fileList="fileList3" @afterRead="afterRead($event,2)" @delete="deletePic" name="3" multiple
  13. :maxCount="1">
  14. <image style='width:680rpx;height:417rpx;' src="@/static/image/enter/jingyingxukezheng.png" mode=""></image>
  15. </u-upload>
  16. </u-form-item>
  17. <u-form-item labelWidth='150' labelPosition='left' label="经营许可证有效期">
  18. <view style='text-align:right;' @click='openjyxkz'>{{currectData.operateCertificateDate?currectData.operateCertificateDate:'选择日期'}}<image src="@/static/image/yjt.png" mode=""
  19. style="margin-left:10rpx;width:12rpx;height: 21rpx;"></image></view>
  20. </u-form-item>
  21. <uni-calendar
  22. :insert="false"
  23. :lunar="true"
  24. ref="calendar"
  25. :start-date="startDate"
  26. @confirm="confirm"
  27. />
  28. </u--form>
  29. <view class="footer">
  30. <button @click='submit' class="submit">提交</button>
  31. </view>
  32. </view>
  33. <u-modal :show="isSubmit" content='确定提交证件图片' @confirm="$u.debounce(confirmSubmit, 500)" showCancelButton
  34. @cancel="isSubmit=false" @close="isSubmit=false" closeOnClickOverlay></u-modal>
  35. </view>
  36. </template>
  37. <script>
  38. var that
  39. import uploadImage from '@/components/ossutil/uploadFile.js';
  40. export default {
  41. data() {
  42. return {
  43. isSubmit:false,
  44. currectData:{},
  45. fileList2:[],
  46. fileList3:[],
  47. startDate:'',
  48. }
  49. },
  50. onLoad() {
  51. that = this
  52. },
  53. onShow(){
  54. var date = new Date().toISOString().slice(0, 10)
  55. this.startDate=date
  56. if(uni.getStorageSync('myCateringdustry')){
  57. this.currectData=JSON.parse(uni.getStorageSync('myCateringdustry'))
  58. if(this.currectData.businessLicense){
  59. this.fileList2=[{url:this.currectData.businessLicense}]
  60. }
  61. if(this.currectData.operateCertificate){
  62. this.fileList3=[{url:this.currectData.operateCertificate}]
  63. }
  64. this.currectData.operateCertificateDate=this.parseTime(this.currectData.operateCertificateDate,'{y}-{m}-{d}')
  65. }
  66. },
  67. methods: {
  68. submit(){
  69. this.isSubmit = true
  70. },
  71. confirmSubmit() {
  72. uni.showLoading({
  73. title: '加载中',
  74. mask: true
  75. })
  76. this.$request.baseRequest('admin.tourism.foodInfo', 'update', {
  77. foodInfo: JSON.stringify(this.currectData)
  78. }, failres => {
  79. uni.showToast({
  80. icon: "none",
  81. title: failres.errmsg,
  82. duration: 3000
  83. });
  84. uni.hideLoading()
  85. }).then(res => {
  86. this.isSubmit = false
  87. uni.showToast({
  88. icon: "success",
  89. title: '编辑证件图片成功',
  90. duration: 2000
  91. });
  92. uni.setStorageSync('myCateringdustry',JSON.stringify(this.currectData))
  93. uni.navigateBack()
  94. })
  95. },
  96. openjyxkz(){
  97. this.$refs.calendar.open();
  98. },
  99. // 删除图片
  100. deletePic(event,status) {
  101. this[`fileList${event.name}`].splice(event.index, 1)
  102. that.indoorImageArray.splice(event.index, 1)
  103. that.currectData.indoorImage =that.indoorImageArray.toString()
  104. },
  105. // 新增图片
  106. async afterRead(event,status) {
  107. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  108. let lists = [].concat(event.file)
  109. let fileListLen = this[`fileList${event.name}`].length
  110. lists.map((item) => {
  111. this[`fileList${event.name}`].push({
  112. ...item,
  113. status: 'uploading',
  114. message: '上传中'
  115. })
  116. })
  117. for (let i = 0; i < lists.length; i++) {
  118. const result = await this.uploadFilePromise(lists[i].url,status)
  119. let item = this[`fileList${event.name}`][fileListLen]
  120. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  121. status: 'success',
  122. message: '',
  123. url: result
  124. }))
  125. fileListLen++
  126. console.log(that.currectData, this[`fileList${event.name}`])
  127. }
  128. },
  129. uploadFilePromise(res,status) {
  130. return new Promise((resolve, reject) => {
  131. uploadImage(res, 'cardImages/',
  132. result => {
  133. if(status==1){
  134. that.currectData.businessLicense = result
  135. }else if(status==2){
  136. that.currectData.operateCertificate = result
  137. }
  138. resolve(res)
  139. }
  140. )
  141. })
  142. },
  143. }
  144. }
  145. </script>
  146. <style>
  147. </style>