task-add.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. <template>
  2. <view class="container taskations">
  3. <view class="taskations-content">
  4. <view class="list-view-title">
  5. <text class="none">*</text>推广截图:
  6. <text class="small">(分享朋友圈及其他推广截图)</text></view>
  7. <view class="list-view-upload clearfix">
  8. <view class="photo-item" v-for="(item, imageIndex) in imageList" :key="imageIndex">
  9. <image :src="item" mode="aspectFill" @click.stop="previewImg(item)"></image>
  10. <text class="iconfont icon-iconfontguanbi" @click.stop="deletePhotoFn(imageIndex)"></text>
  11. </view>
  12. <view
  13. class="photo-item add"
  14. @click.stop="uploadPhotoFn"
  15. v-if="imageList.length < 10 || imageList.length == 0"
  16. >
  17. <text class="iconfont icon-jiahao"></text>
  18. </view>
  19. </view>
  20. <view class="list-view-title">备注:</view>
  21. <view class="list-view-text">
  22. <textarea
  23. class="textarea"
  24. v-model="params.taskDesc"
  25. placeholder="请输入备注信息"
  26. maxlength="200"
  27. @input="conInput"
  28. />
  29. <text class="limit-text">{{ min }}/{{ max }}</text>
  30. </view>
  31. </view>
  32. <view class="card-mains-btn">
  33. <button
  34. class="add-btn"
  35. :disabled="disabled"
  36. :class="[disabled ? 'disabled' : '']"
  37. @click="handeleAddtask"
  38. >
  39. 提交审核
  40. </button>
  41. </view>
  42. </view>
  43. </template>
  44. <script>
  45. import { mapState, mapMutations } from 'vuex'
  46. import { uploadFileImage } from '@/services/public.js'
  47. export default {
  48. data() {
  49. return {
  50. isPreviewImg: false,
  51. imageList: [],
  52. params: {
  53. taskId: 0,
  54. taskDesc: '',
  55. images: '',
  56. serviceProviderId: 0
  57. },
  58. min: 0,
  59. max: 200
  60. }
  61. },
  62. onLoad(option) {
  63. console.log(option)
  64. this.params.taskId = option.taskId
  65. this.params.serviceProviderId = option.serviceProviderId
  66. if(option.type === 'edit'){
  67. this.getProviderTaskDetail(option)
  68. }
  69. },
  70. computed: {
  71. disabled() {
  72. return !(this.imageList.length > 0)
  73. }
  74. },
  75. methods: {
  76. // 获取截图详情
  77. async getProviderTaskDetail(option){
  78. try {
  79. const params = { taskId: option.taskId, serviceProviderId: option.serviceProviderId }
  80. const res = await this.SellerService.getProviderTaskDetail(params)
  81. const data = res.data
  82. this.imageList = data.images
  83. this.params.taskDesc = data.taskDesc
  84. } catch (error) {
  85. console.log('error', error)
  86. }
  87. },
  88. // 提交上传
  89. async handeleAddtask() {
  90. try {
  91. this.params.images = this.imageList
  92. console.log('params', this.params)
  93. const res = await this.SellerService.taskpushTask(this.params)
  94. this.$util.msg('提交成功', 2000, true, 'success')
  95. setTimeout(() => {
  96. this.$api.navigateBack(1)
  97. }, 2000)
  98. } catch (error) {
  99. console.log('error', error)
  100. }
  101. },
  102. async uploadPhotoFn() {
  103. //添加图片
  104. try {
  105. const res = await uploadFileImage()
  106. const data = JSON.parse(res.data).data
  107. this.imageList.push(data)
  108. console.log('imageList', this.imageList)
  109. } catch (e) {
  110. console.log('上传图片失败')
  111. }
  112. },
  113. conInput(e) {
  114. //备注文字字数限制
  115. let value = e.detail.value
  116. let len = parseInt(value.length)
  117. if (len > this.max) return
  118. this.min = len
  119. if (this.min == 200) {
  120. return
  121. }
  122. },
  123. deletePhotoFn(index) {
  124. //删除图片
  125. this.imageList.splice(index, 1)
  126. },
  127. previewImg(image) {
  128. //顶部商品图片预览
  129. this.isPreviewImage = true
  130. let urls = []
  131. urls.push(image)
  132. uni.previewImage({
  133. urls: urls,
  134. current: 0
  135. })
  136. }
  137. },
  138. onShow() {}
  139. }
  140. </script>
  141. <style lang="scss">
  142. page {
  143. height: auto;
  144. background: #ffffff;
  145. }
  146. .taskations-content {
  147. width: 100%;
  148. height: auto;
  149. box-sizing: border-box;
  150. padding: 0 24rpx;
  151. .list-view-title {
  152. width: 100%;
  153. height: 92rpx;
  154. line-height: 92rpx;
  155. font-size: $font-size-30;
  156. color: #333333;
  157. text-align: left;
  158. .none {
  159. color: #f85050;
  160. }
  161. .small{
  162. font-size: 22rpx;
  163. color: #f85050;
  164. }
  165. }
  166. .list-view-text {
  167. width: 100%;
  168. height: 216rpx;
  169. box-sizing: border-box;
  170. border: 1px solid #e1e1e1;
  171. padding: 20rpx;
  172. border-radius: 6rpx;
  173. position: relative;
  174. .textarea {
  175. width: 100%;
  176. height: 100%;
  177. font-size: $font-size-26;
  178. color: #666666;
  179. }
  180. .limit-text {
  181. position: absolute;
  182. right: 20rpx;
  183. bottom: 16rpx;
  184. line-height: 44rpx;
  185. font-size: $font-size-24;
  186. color: #b2b2b2;
  187. }
  188. }
  189. .list-view-upload {
  190. width: 100%;
  191. height: auto;
  192. padding: 10rpx 0;
  193. .photo-item {
  194. display: inline-block;
  195. width: 150rpx;
  196. height: 150rpx;
  197. margin: 10rpx 0;
  198. margin-right: 25rpx;
  199. border-radius: 10rpx;
  200. border: 1px dashed #b8bfca;
  201. position: relative;
  202. float: left;
  203. &.add {
  204. width: 150rpx;
  205. height: 150rpx;
  206. border-color: #b2b2b2;
  207. text-align: center;
  208. line-height: 150rpx;
  209. margin-right: 0rpx;
  210. .icon-jiahao {
  211. font-size: $font-size-44;
  212. color: #b2b2b2;
  213. font-weight: bold;
  214. }
  215. }
  216. .icon-iconfontguanbi {
  217. width: 30rpx;
  218. height: 30rpx;
  219. border-radius: 50%;
  220. display: block;
  221. position: absolute;
  222. right: -10rpx;
  223. top: -10rpx;
  224. background: #f94b4b;
  225. text-align: center;
  226. line-height: 30rpx;
  227. color: #ffffff;
  228. font-size: $font-size-22;
  229. }
  230. image {
  231. width: 100%;
  232. height: 100%;
  233. border-radius: 10rpx;
  234. display: block;
  235. }
  236. }
  237. .photo-list {
  238. width: 100%;
  239. height: 116rpx;
  240. overflow: hidden;
  241. white-space: nowrap;
  242. display: flex;
  243. align-items: flex-start;
  244. }
  245. .scoll-wrapper {
  246. display: flex;
  247. align-items: flex-start;
  248. }
  249. }
  250. }
  251. .card-mains-btn {
  252. width: 100%;
  253. height: auto;
  254. box-sizing: border-box;
  255. padding: 0 75rpx;
  256. margin-top: 180rpx;
  257. .add-btn {
  258. width: 100%;
  259. height: 90rpx;
  260. font-size: $font-size-30;
  261. line-height: 90rpx;
  262. color: #ffffff;
  263. text-align: center;
  264. background: $btn-confirm;
  265. border-radius: 45rpx;
  266. border-radius: 44rpx;
  267. margin-top: 80rpx;
  268. &.disabled {
  269. background: #e1e1e1;
  270. border-radius: 44rpx;
  271. }
  272. }
  273. }
  274. </style>