upload.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view class="content">
  3. <view class="upload-title">
  4. 请提供相关截图及描述,以便上级审核(最多两张)
  5. </view>
  6. <view class="upload-box">
  7. <view class="upload-img flex">
  8. <image src="../../static/img/upload.png" mode="" v-if="!imgone" @click="upimg('imgone')"></image>
  9. <image :src="imgone" mode="" v-if="imgone" @click="upimg('imgone')"></image>
  10. <image src="../../static/img/upload.png" mode="" v-if="!imgtow" @click="upimg('imgtow')"></image>
  11. <image :src="imgtow" mode="" v-if="imgtow" @click="upimg('imgtow')"></image>
  12. </view>
  13. <view class="fenge"></view>
  14. <view class="upload-content">
  15. <view class="describe">
  16. <view class="title">
  17. 补充描述
  18. </view>
  19. <textarea class="title1" value="" placeholder="填写描述" maxlength="140" focus="focus" />
  20. </view>
  21. </view>
  22. </view>
  23. <view class="submit" @click="sub">
  24. 提交
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import {
  30. uploadApply
  31. } from '../../api/apply.js'
  32. import { uploads } from '@/api/user.js';
  33. export default {
  34. data() {
  35. return {
  36. imgone: '',
  37. imgtow: '',
  38. apply_id: '',
  39. }
  40. },
  41. onLoad(opt) {
  42. this.apply_id = opt.id
  43. },
  44. methods: {
  45. upimg(name) {
  46. uploads({
  47. filename: ''
  48. }).then(res => {
  49. console.log(res,'++++++++++++++++')
  50. this.$set(this,name,res[0].fullurl)
  51. })
  52. },
  53. sub() {
  54. let obj = this
  55. if(obj.imgone == '' && obj.imgtow == '') {
  56. return obj.$api.msg('请上传凭证')
  57. }
  58. uni.showLoading({
  59. title: '提交中...',
  60. mask: true
  61. })
  62. let arr = []
  63. if(obj.imgone) {
  64. arr.push(obj.imgone)
  65. }
  66. if(obj.imgtow) {
  67. arr.push(obj.imgtow)
  68. }
  69. console.log(arr,'arr')
  70. uploadApply({
  71. images:arr
  72. },obj.apply_id).then( res => {
  73. uni.hideLoading()
  74. uni.showToast({
  75. title:'提交成功',
  76. duration:2000
  77. });
  78. setTimeout(function() {
  79. uni.navigateBack();
  80. }, 800);
  81. console.log(res,'+++++++++++++++++')
  82. }).catch( err => {
  83. uni.hideLoading()
  84. console.log(err)
  85. })
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss">
  91. page {
  92. width: 100%;
  93. padding: 0;
  94. margin: 0;
  95. }
  96. .content {
  97. .upload-title {
  98. padding: 30rpx 30rpx;
  99. font-size: 28rpx;
  100. font-family: PingFang SC;
  101. font-weight: 500;
  102. color: #FFFFFF;
  103. line-height: 28rpx;
  104. }
  105. .upload-box {
  106. width: 100%;
  107. height: 450rpx;
  108. background-color: #15130F;
  109. .upload-img {
  110. justify-content: flex-start;
  111. margin: 30rpx;
  112. padding-top: 30rpx;
  113. height: 190rpx;
  114. image {
  115. width: 160rpx;
  116. height: 100%;
  117. margin-right: 15rpx;
  118. }
  119. }
  120. .fenge {
  121. width: 100%;
  122. border: 1rpx solid #F0F0F0;
  123. }
  124. .describe {
  125. display: flex;
  126. padding: 20rpx 30rpx;
  127. .title {
  128. width: 150rpx;
  129. font-size: 28rpx;
  130. font-family: PingFang SC;
  131. font-weight: 500;
  132. color: #FFFFFF;
  133. }
  134. .title1 {
  135. margin-left: 40rpx;
  136. font-size: 26rpx;
  137. font-family: PingFang SC;
  138. font-weight: 500;
  139. color: #999999;
  140. }
  141. }
  142. }
  143. .submit{
  144. margin: 120rpx auto;
  145. text-align: center;
  146. line-height: 80rpx;
  147. width: 560rpx;
  148. height: 80rpx;
  149. background: linear-gradient(-74deg, #CE9C6D, #FFECD6);
  150. border-image: linear-gradient(115deg, #FEEBD5, #FFFFFF, #E1AD7D) 1 1;
  151. box-shadow: 3rpx 4rpx 5rpx 0rpx rgba(151, 118, 74, 0.5);
  152. border-radius: 40rpx;
  153. }
  154. }
  155. </style>