editCertificate.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. uni.showModal({
  70. title: '提示',
  71. content: '确定提交证件图片?',
  72. success (res) {
  73. if (res.confirm) {
  74. that.$u.debounce(confirmSubmit, 500)
  75. } else if (res.cancel) {
  76. console.log('用户点击取消')
  77. }
  78. }
  79. })
  80. },
  81. confirmSubmit() {
  82. uni.showLoading({
  83. title: '加载中',
  84. mask: true
  85. })
  86. this.$request.baseRequest('admin.tourism.foodInfo', 'update', {
  87. foodInfo: JSON.stringify(this.currectData)
  88. }, failres => {
  89. uni.showToast({
  90. icon: "none",
  91. title: failres.errmsg,
  92. duration: 3000
  93. });
  94. uni.hideLoading()
  95. }).then(res => {
  96. this.isSubmit = false
  97. uni.showToast({
  98. icon: "success",
  99. title: '编辑证件图片成功',
  100. duration: 2000
  101. });
  102. uni.setStorageSync('myCateringdustry',JSON.stringify(this.currectData))
  103. uni.navigateBack()
  104. })
  105. },
  106. openjyxkz(){
  107. this.$refs.calendar.open();
  108. },
  109. // 删除图片
  110. deletePic(event,status) {
  111. this[`fileList${event.name}`].splice(event.index, 1)
  112. that.indoorImageArray.splice(event.index, 1)
  113. that.currectData.indoorImage =that.indoorImageArray.toString()
  114. },
  115. // 新增图片
  116. async afterRead(event,status) {
  117. // 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
  118. let lists = [].concat(event.file)
  119. let fileListLen = this[`fileList${event.name}`].length
  120. lists.map((item) => {
  121. this[`fileList${event.name}`].push({
  122. ...item,
  123. status: 'uploading',
  124. message: '上传中'
  125. })
  126. })
  127. for (let i = 0; i < lists.length; i++) {
  128. const result = await this.uploadFilePromise(lists[i].url,status)
  129. let item = this[`fileList${event.name}`][fileListLen]
  130. this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
  131. status: 'success',
  132. message: '',
  133. url: result
  134. }))
  135. fileListLen++
  136. console.log(that.currectData, this[`fileList${event.name}`])
  137. }
  138. },
  139. uploadFilePromise(res,status) {
  140. return new Promise((resolve, reject) => {
  141. uploadImage(res, 'cardImages/',
  142. result => {
  143. if(status==1){
  144. that.currectData.businessLicense = result
  145. }else if(status==2){
  146. that.currectData.operateCertificate = result
  147. }
  148. resolve(res)
  149. }
  150. )
  151. })
  152. },
  153. }
  154. }
  155. </script>
  156. <style>
  157. </style>