upload.vue 3.6 KB

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