task-msg.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template>
  2. <view class="task-set">
  3. <!-- <headNav :isBackShow="false" :textContents="'任务反馈'" :navBackgroundColor="'#fff'"></headNav> -->
  4. <view class="nav">
  5. 任务反馈
  6. </view>
  7. <!-- <view class="content">-->
  8. <!-- <view class="leave-message-box">-->
  9. <!-- <view class="">-->
  10. <!-- <textarea placeholder="留个言吧" v-model="msgData.msg" :maxlength="999" auto-height />-->
  11. <!-- </view>-->
  12. <!-- <view class="img-box">-->
  13. <!-- <view class="credentials-img" @click="showImg(msgData.msg_img,pIndex)"-->
  14. <!-- v-for="(msg_img,pIndex) in msgData.msg_img">-->
  15. <!-- <image class="credentials-imgs" :src="msg_img" mode="aspectFit"></image>-->
  16. <!-- <image @click="shutImg(pIndex)" class="gb-img" src="@/static/login/gb.png" mode=""></image>-->
  17. <!-- </view>-->
  18. <!-- <image class="img-box-img" @click="showUploadingImg(true)" src="@/static/add-client/scmb.png" mode=""></image>-->
  19. <!-- </view>-->
  20. <!-- </view>-->
  21. <!-- </view>-->
  22. <add-msg v-model="msgData"></add-msg>
  23. <view class="submit-box" @click="setMsg">
  24. <view class="submit">
  25. 提交
  26. </view>
  27. </view>
  28. <uni-popup ref="popup" type="bottom">
  29. <view class="popup-block">
  30. <view class="popup-row" @click="uploadingImg(1)">拍照</view>
  31. <view class="popup-row" @click="uploadingImg(2)">从手机里面选择</view>
  32. <view class="popup-row" @click="showUploadingImg(false)">取消</view>
  33. </view>
  34. </uni-popup>
  35. <PreviewImage ref="previewImage" :imgs="previewList" :current="current"></PreviewImage>
  36. </view>
  37. </template>
  38. <script>
  39. import txUploadFile from "@/common/js/txOssSts";
  40. import tools from "@/common/js/tools";
  41. import {
  42. setMsg
  43. } from "@/api/task";
  44. import PreviewImage from "@/components/PreviewImage/index";
  45. import AddMsg from "@/pages-task/task-info/module/add-msg";
  46. export default {
  47. props: {
  48. businessId: {
  49. default: 0
  50. },
  51. replyId:{
  52. default: 0
  53. }
  54. },
  55. components: {
  56. AddMsg,
  57. PreviewImage
  58. },
  59. data() {
  60. return {
  61. title: "",
  62. msgData: {
  63. business_id: '',
  64. msg: '',
  65. reply_id: 0,
  66. msg_img: [],
  67. file_list: [],
  68. },
  69. isAjax: false,
  70. previewList: [],
  71. current: 0
  72. }
  73. },
  74. onLoad() {
  75. },
  76. watch:{
  77. 'replyId':function (){
  78. if (this.replyId) {
  79. this.msgData.reply_id = this.replyId;
  80. }else {
  81. this.msgData.reply_id =''
  82. }
  83. }
  84. },
  85. mounted() {
  86. console.log('-----------businessId:'+this.businessId,'--------------replyId:'+this.replyId)
  87. this.msgData.business_id = this.businessId
  88. if (this.replyId) {
  89. this.msgData.reply_id = this.replyId;
  90. }
  91. },
  92. methods: {
  93. showImg(item, index) {
  94. if (typeof item === 'string') {
  95. item = [item];
  96. }
  97. this.previewList = item
  98. this.current = index
  99. this.$refs.previewImage.open(index);
  100. },
  101. setMsg() {
  102. if (this.isAjax) {
  103. return;
  104. }
  105. // this.isAjax=true;
  106. this.msgData.business_id = this.businessId
  107. if (this.replyId) {
  108. this.msgData.reply_id = this.replyId;
  109. }
  110. setMsg(this.msgData).then((res) => {
  111. if (res.code === 1) {
  112. tools.success(res.msg)
  113. uni.$emit('newMsg')
  114. this.msgData.reply_id=''
  115. this.msgData.msg=''
  116. this.msgData.msg_img=[]
  117. } else {
  118. tools.error(res.msg)
  119. this.isAjax = false;
  120. }
  121. })
  122. },
  123. shutImg(indexT) {
  124. this.msgData.msg_img.splice(indexT, 1)
  125. },
  126. showUploadingImg(showImg) {
  127. if (showImg) {
  128. this.$refs.popup.open("bottom");
  129. // this.uploadingImg(2)
  130. } else {
  131. this.$refs.popup.close();
  132. }
  133. },
  134. uploadingImg(sourceType) {
  135. uni.chooseMedia({
  136. mediaType: 'image',
  137. count: sourceType === 1 ? 1 : 9, //默认9
  138. sizeType: "compressed",
  139. sourceType: [sourceType === 1 ? 'camera' : 'album'],
  140. success: (res) => {
  141. console.log(res)
  142. if (res.tempFiles.length > 0) {
  143. res.tempFiles.forEach((tempFile) => {
  144. txUploadFile(tempFile.tempFilePath).then((data) => {
  145. if (!data) {
  146. tools.error('图片上传失败')
  147. } else {
  148. this.msgData.msg_img.push(data.Location)
  149. }
  150. })
  151. })
  152. this.showUploadingImg(false);
  153. } else {
  154. tools.error("请选择上传的图片")
  155. }
  156. },
  157. });
  158. },
  159. leftClick() {
  160. uni.navigateBack({
  161. delta: 1
  162. })
  163. },
  164. },
  165. }
  166. </script>
  167. <style lang="scss" scoped>
  168. .popup-block {
  169. border-radius: 20rpx 20rpx 0rpx 0rpx;
  170. background-color: #f5f5f5;
  171. .popup-row {
  172. height: 100rpx;
  173. background-color: #fff;
  174. text-align: center;
  175. line-height: 100rpx;
  176. border-bottom: 2rpx solid #f5f5f5;
  177. &:nth-child(2) {
  178. margin-bottom: 20rpx;
  179. }
  180. &:last-child {
  181. height: 112rpx;
  182. border: none;
  183. line-height: 112rpx;
  184. }
  185. &:active {
  186. background-color: rgb(244, 244, 244);
  187. }
  188. }
  189. }
  190. .task-set {
  191. width: 100%;
  192. min-height: 50vh;
  193. max-height: 70vh;
  194. background: #F6F7FB;
  195. overflow: auto;
  196. border-radius: 20rpx 20rpx 0rpx 0rpx;
  197. .nav {
  198. font-size: 18px;
  199. font-weight: bold;
  200. text-align: center;
  201. padding: 30rpx 0 15rpx;
  202. background: #fff;
  203. }
  204. .content {
  205. width: 100%;
  206. height: auto;
  207. padding: 22rpx 0 0 0;
  208. .choose-box {
  209. width: 100%;
  210. height: auto;
  211. padding: 34rpx 35rpx;
  212. box-sizing: border-box;
  213. background: #fff;
  214. border-top: 1px solid #F0F0F0;
  215. display: flex;
  216. align-items: center;
  217. justify-content: space-between;
  218. .choose-box-left {
  219. font-size: 16px;
  220. color: #666666;
  221. }
  222. .choose-box-right {
  223. display: flex;
  224. align-items: center;
  225. .choose-box-right-content {
  226. font-size: 16px;
  227. font-weight: 400;
  228. color: #232A35;
  229. margin: 0 18rpx 0 0;
  230. }
  231. .choose-box-right-img {
  232. width: 12rpx;
  233. height: 20rpx;
  234. }
  235. }
  236. }
  237. .choose-box-two {
  238. margin: 0 0 22rpx 0;
  239. }
  240. .leave-message-box {
  241. width: 100%;
  242. height: auto;
  243. padding: 36rpx 30rpx 106rpx;
  244. box-sizing: border-box;
  245. background: #fff;
  246. .img-box {
  247. width: 100%;
  248. height: auto;
  249. display: flex;
  250. align-items: center;
  251. padding: 40rpx 0 0 0;
  252. .credentials-img {
  253. width: 160rpx;
  254. height: 160rpx;
  255. margin: 0 16rpx 30rpx 0;
  256. position: relative;
  257. .credentials-imgs {
  258. width: 100%;
  259. height: 100%;
  260. display: block;
  261. }
  262. .gb-img {
  263. width: 32rpx;
  264. height: 32rpx;
  265. position: absolute;
  266. right: 0;
  267. top: 0;
  268. z-index: 2;
  269. }
  270. }
  271. .img-box-img {
  272. width: 216rpx;
  273. height: 216rpx;
  274. }
  275. }
  276. }
  277. }
  278. .submit-box {
  279. width: 100%;
  280. height: auto;
  281. border-top: 1px solid #F0F0F0;
  282. background: #fff;
  283. position: fixed;
  284. left: 0;
  285. bottom: 0;
  286. padding: 12rpx 32rpx;
  287. box-sizing: border-box;
  288. .submit {
  289. width: 100%;
  290. height: auto;
  291. background: #3169FA;
  292. border-radius: 4px;
  293. font-size: 16px;
  294. color: #FFFFFF;
  295. padding: 20rpx 0;
  296. text-align: center;
  297. }
  298. }
  299. }
  300. </style>