post_group_chat_notice.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. <template>
  2. <view>
  3. <u-toast ref="uToast" />
  4. <common :tips='commonTips'></common>
  5. <u-form class="post-form">
  6. <view class="form-item">
  7. <u-input maxlength="-1" v-model="form.content" name="content" class="post-textarea" placeholder="请输入公告内容" type="textarea" />
  8. <view>
  9. <u-upload @on-change="imagesOnChange" :form-data="uploadFormData" :file-list="filesArr" :action="action" ref="uUpload" :size-type="['compressed']" :max-count="10" name="file" width="160" height="160"></u-upload>
  10. </view>
  11. <view class="checkbox-group">
  12. <u-checkbox-group name="checkboxs">
  13. <u-checkbox v-model="item.checked" v-for="(item, cindex) in checkboxs" :key="cindex" :name="item.title">
  14. {{ item.title }}
  15. </u-checkbox>
  16. </u-checkbox-group>
  17. </view>
  18. </view>
  19. <u-button :loading="submitButtonStatus" :disabled="submitButtonStatus" class="submit-button" type="primary" @click="submit">发布</u-button>
  20. </u-form>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. data() {
  26. return {
  27. id: 0,
  28. group_id: 0,
  29. form: {
  30. content: ''
  31. },
  32. action: '',
  33. filesArr: [],
  34. checkboxs: [{
  35. name: 'popup',
  36. title: '使用弹窗展示公告',
  37. checked: true
  38. },
  39. {
  40. name: 'receipt',
  41. title: '需群成员确认收到',
  42. checked: false
  43. },
  44. {
  45. name: 'top',
  46. title: '置顶公告',
  47. checked: false
  48. }],
  49. submitButtonStatus: false,
  50. uploadFormData: new Object(),
  51. commonTips: ''
  52. }
  53. },
  54. onLoad(query) {
  55. var that = this
  56. that.id = query.id
  57. that.group_id = query.group_id
  58. let userinfo = uni.getStorageSync('userinfo');
  59. that.action = that.ws.buildUrl('upload', userinfo.token)
  60. that.ws.pageFun(that.pageDataLoad, that);
  61. },
  62. onShow() {
  63. this.ws.checkNetwork(this)
  64. },
  65. methods: {
  66. pageDataLoad: function() {
  67. var that = this
  68. that.ws.send({
  69. c: 'ImBase',
  70. a: 'getUploadMultipart'
  71. });
  72. if (that.id) {
  73. that.ws.send({
  74. c: 'Message',
  75. a: 'groupChatNoticeOpt',
  76. data: {
  77. id: that.id,
  78. type: "edit"
  79. }
  80. });
  81. uni.setNavigationBarTitle({
  82. title: '编辑公告'
  83. });
  84. }
  85. },
  86. imagesOnChange: function (res) {
  87. res = JSON.parse(res.data);
  88. if (res.code != 1) {
  89. this.ws.pageFun(() => {
  90. this.ws.send({
  91. c: 'ImBase',
  92. a: 'getUploadMultipart'
  93. })
  94. }, this)
  95. this.$refs.uUpload.remove(index);
  96. uni.showModal({
  97. title: '温馨提示',
  98. content: res.msg,
  99. showCancel: false
  100. })
  101. }
  102. },
  103. submit: function () {
  104. var that = this
  105. that.submitButtonStatus = true
  106. var values = that.form, noticeimages = '', message = '';
  107. for (var i = 0; i < that.$refs.uUpload.lists.length; i++) {
  108. if (that.$refs.uUpload.lists[i].progress == 100) {
  109. if (that.$refs.uUpload.lists[i].response) {
  110. noticeimages += that.$refs.uUpload.lists[i].response.data.fullurl + ','
  111. } else if (that.$refs.uUpload.lists[i].url) {
  112. noticeimages += that.$refs.uUpload.lists[i].url + ','
  113. }
  114. }
  115. }
  116. for (var i = 0; i < that.checkboxs.length; i++) {
  117. values[that.checkboxs[i].name] = that.checkboxs[i].checked ? 1:0
  118. }
  119. values.group_id = that.group_id
  120. values.images = noticeimages
  121. values.method = 'post'
  122. if (that.id) {
  123. values.id = that.id
  124. values.type = 'post-edit'
  125. values.source = 'uni-app'
  126. message = {c: 'Message', a: 'groupChatNoticeOpt', data: values}
  127. } else {
  128. message = {c: 'Message', a: 'groupChatNotice', data: values}
  129. }
  130. that.ws.pageFun(function() {
  131. that.ws.send(message);
  132. that.ws.showMsgCallback = function() {
  133. setTimeout(function() {
  134. that.ws.pageRefresh.chatSetting = true
  135. that.submitButtonStatus = false
  136. uni.navigateBack({
  137. delta: 1
  138. })
  139. }, 2000)
  140. }
  141. }, that);
  142. }
  143. }
  144. }
  145. </script>
  146. <style>
  147. page {
  148. background: #F8F8F8;
  149. }
  150. .post-form {
  151. display: block;
  152. width: 96vw;
  153. margin: 20rpx auto;
  154. }
  155. .form-item {
  156. display: block;
  157. padding: 20rpx;
  158. border-radius: 12rpx;
  159. background: #FFFFFF;
  160. }
  161. .post-textarea,.checkbox-group {
  162. display: block;
  163. width: 96%;
  164. margin: 0 auto;
  165. padding-top: 20rpx;
  166. }
  167. .submit-button {
  168. width: 60vw;
  169. display: block;
  170. margin: 60rpx auto;
  171. }
  172. </style>