upLoadInfo.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="container">
  3. <view class="up-tit">请提供相关图片描述 以便我们后续跟进</view>
  4. <view class="add-img-box flex_item">
  5. <view class="add-img-item" v-for="(item, index) in imgList" :key="index">
  6. <image class="add-img" @click.stop="imgInfo(index)" :src="item" mode="aspectFill"></image>
  7. <image class="add-img-del" @click.stop="delImg(index)" src="/static/img/delete.png"></image>
  8. </view>
  9. <view v-if='imgCount > 0' class="add-img-item" @click.stop="scImg()">
  10. <image class="add-img" src="../../static/images/sctp.png"></image>
  11. </view>
  12. </view>
  13. <view class="mark-box">
  14. <view class="mark-tit">补充描述</view>
  15. <textarea class="mark-text" v-model="mark" placeholder="填写描述"></textarea>
  16. </view>
  17. <view class="up-btn" v-if="type == 0" @click="submit">提交</view>
  18. <view class="up-btn" v-if="type == 1" @click="submit">修改</view>
  19. </view>
  20. </template>
  21. <script>
  22. import { upload,add_four_help } from '@/api/index.js';
  23. import { means, get_means } from '@/api/applyHelp.js';
  24. export default {
  25. data() {
  26. return {
  27. imgList: [], // 图片
  28. cloudimgList: [],
  29. mark: '', // 描述
  30. imgCount: 6, // 最多传6张
  31. id: '',
  32. type: 0,
  33. }
  34. },
  35. onLoad(option) {
  36. this.id = option.id;
  37. if ( option.type ) {
  38. this.type = 1;
  39. get_means({
  40. id: this.id
  41. }).then(({data}) => {
  42. this.imgList = data.img;
  43. this.mark = data.remark;
  44. })
  45. }
  46. },
  47. methods: {
  48. //多张上传图片
  49. scImg() {
  50. let obj = this;
  51. upload({
  52. file: ''
  53. })
  54. .then(e => {
  55. let list = []
  56. obj.imgList = [...obj.imgList, e[0].url];
  57. console.log(obj.imgList);
  58. obj.imgCount = 6 - obj.imgList.length;
  59. })
  60. .catch(e => {});
  61. },
  62. //点击图片显示大图
  63. imgInfo(i) {
  64. let tempList = [];
  65. this.imgList.forEach(e => {
  66. tempList.push(e);
  67. });
  68. //显示图片
  69. uni.previewImage({
  70. current: i,
  71. loop: false,
  72. urls: this.imgList,
  73. indicator: 'default'
  74. });
  75. },
  76. //删除图片
  77. delImg(i) {
  78. uni.showModal({
  79. content: '确定删除这张吗',
  80. success: res => {
  81. if (res.confirm) {
  82. this.imgList.splice(i, 1);
  83. this.imgCount++;
  84. } else if (res.cancel) {
  85. }
  86. }
  87. });
  88. },
  89. // 提交
  90. submit() {
  91. let obj = this;
  92. let arr = obj.imgList.join(';');
  93. console.log(arr,'arr')
  94. console.log(this.mark);
  95. if (!obj.imgList) {
  96. obj.$api.msg('请上传图片');
  97. return;
  98. }
  99. if (!obj.mark) {
  100. obj.$api.msg('请填写描述');
  101. return;
  102. }
  103. means({
  104. id: obj.id,
  105. img: arr,
  106. remark: obj.mark,
  107. }).then(({data}) => {
  108. obj.$api.msg('上传成功');
  109. uni.navigateBack();
  110. }).catch(e => {
  111. console.log(e);
  112. })
  113. },
  114. }
  115. }
  116. </script>
  117. <style lang="scss">
  118. .container {
  119. .up-tit {
  120. padding: 24rpx 30rpx;
  121. font-size: $font-base;
  122. font-family: PingFang SC;
  123. font-weight: 500;
  124. color: #333333;
  125. }
  126. .add-img-box {
  127. width: 100%;
  128. flex-wrap: wrap;
  129. // justify-content: center;
  130. padding: 30rpx 30rpx 0 30rpx;
  131. background: #FFFFFF;
  132. border-bottom: 1px solid #F0F0F0;
  133. }
  134. .add-img-item {
  135. margin-bottom: 25rpx;
  136. width: 33.33%;
  137. position: relative;
  138. .add-img {
  139. padding: 0rpx 10rpx;
  140. width: 100%;
  141. height: 214rpx;
  142. display: block;
  143. }
  144. }
  145. .add-img-del {
  146. position: absolute;
  147. width: 40rpx;
  148. height: 40rpx;
  149. right: 10rpx;
  150. top: 0;
  151. // bottom: 155rpx;
  152. //background-color: rgba(238, 0, 0, 1);
  153. border-radius: 20rpx;
  154. }
  155. .mark-box {
  156. display: flex;
  157. align-items: flex-start;
  158. background: #FFFFFF;
  159. padding: 40rpx 30rpx 0 30rpx;
  160. .mark-tit {
  161. margin-right: 40rpx;
  162. font-size: $font-base;
  163. font-family: PingFang SC;
  164. font-weight: 500;
  165. color: #333333;
  166. flex-shrink: 0;
  167. }
  168. .mark-text {
  169. font-size: $font-base - 2rpx;
  170. font-family: PingFang SC;
  171. font-weight: 500;
  172. color: #999999;
  173. }
  174. }
  175. .up-btn {
  176. margin: auto;
  177. margin-top: 120rpx;
  178. width: 560rpx;
  179. height: 80rpx;
  180. background: #FF727E;
  181. border-radius: 40rpx;
  182. font-size: 30rpx;
  183. font-family: PingFang SC;
  184. font-weight: 500;
  185. color: #FFFFFF;
  186. display: flex;
  187. align-items: center;
  188. justify-content: center;
  189. }
  190. }
  191. </style>