publish.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template name="publish">
  2. <view class="cu-modal show">
  3. <view class="cu-dialog">
  4. <view class="cu-bar bg-white justify-end">
  5. <view class="content">{{title}}</view>
  6. <view class="action" @tap="hideModal">
  7. <text class="cuIcon-close text-red"></text>
  8. </view>
  9. </view>
  10. <view class="padding-xls">
  11. <view class="publish-wrap bg-white">
  12. <view class="input-box padding-sm">
  13. <textarea class="area-top" placeholder="写点啥..." maxlength="10000" v-model="content"></textarea>
  14. </view>
  15. <view class="cu-form-group img-box" v-if="is_upload">
  16. <view class="next-title">上传图片(最多{{total}}张)</view>
  17. <view class="margin-none margin-left">
  18. <view class="grid col-5 grid-square flex-sub padding-top-lg">
  19. <view class="bg-img" v-for="(item,index) in pic" :key="index">
  20. <image :src="item" mode="aspectFill" @tap="Dever.viewPic(pic, item)" class="img-item"></image>
  21. <image src="@/static/img/publish/img_close.png" @tap.stop="del" :data-index="index" mode="widthFix" class="close-img"></image>
  22. </view>
  23. <view class="add-img" @tap="choose" v-if="pic.length<total">
  24. <text class='cuIcon-add link-color'></text>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="cu-bar bg-white">
  32. <view class="action margin-0 flex-sub text-green" @tap="hideModal" v-if="is_upload" style="display: none;">
  33. <text class="cuIcon-moneybag"></text>藏点钱
  34. </view>
  35. <view class="action margin-0 flex-sub text-green solid-left" @tap="save">发布</view>
  36. <view class="action margin-0 flex-sub solid-left" @tap="hideModal">取消</view>
  37. </view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. export default {
  43. name : 'publish',
  44. props: {
  45. title : '',
  46. cate_id : null,
  47. type : null,
  48. type_id : 0,
  49. to_id : 0,
  50. to_uid : 0,
  51. index : 0,
  52. is_upload : true,
  53. seconds : 0,
  54. api : {
  55. type : String,
  56. default : 'app/community/?l=api.add'
  57. },
  58. },
  59. data() {
  60. return {
  61. pic : [],
  62. content : '',
  63. upload : 'img',
  64. total : 9,
  65. };
  66. },
  67. mounted() {
  68. // 初始化上传数据
  69. this.Dever.getUpload().data = {};
  70. this.Dever.getUpload().data[this.upload] = [];
  71. this.pic = [];
  72. },
  73. methods: {
  74. // 保存数据
  75. save : function() {
  76. var self = this;
  77. var data = {};
  78. data.content = this.content;
  79. if (this.pic.length > 0) {
  80. data.pic = this.pic.join(',');
  81. }
  82. if (this.cate_id) {
  83. data.cate_id = this.cate_id;
  84. }
  85. if (this.seconds) {
  86. data.seconds = this.seconds;
  87. }
  88. data.type = this.type;
  89. data.type_id = this.type_id;
  90. data.to_id = this.to_id;
  91. data.to_uid = this.to_uid;
  92. if (this.Dever.config.code) {
  93. data.code = this.Dever.config.code;
  94. }
  95. this.Dever.post(this.api, data, function(t) {
  96. self.getRefresh(data.content);
  97. });
  98. },
  99. // 选择图片
  100. choose: function() {
  101. var self = this;
  102. var upload = this.Dever.upload(this.upload, this.total, function(type, img) {
  103. self.pic = img;
  104. });
  105. },
  106. // 删除图片
  107. del : function(e) {
  108. var self = this;
  109. self.pic.splice(e.currentTarget.dataset.index, 1)
  110. },
  111. hideModal : function() {
  112. this.$emit('hideModal');
  113. },
  114. getRefresh : function(content) {
  115. this.$emit('getRefresh', this.cate_id, this.type, this.type_id, content);
  116. }
  117. }
  118. }
  119. </script>
  120. <style lang="less" scoped>
  121. .textarea-placeholder {
  122. text-align: left;;
  123. }
  124. .grid.grid-square {
  125. overflow: visible;
  126. }
  127. .margin-left {
  128. width: 100%;
  129. font-size: 13px;
  130. line-height: 21px;
  131. margin-left: -60rpx;
  132. }
  133. .publish-wrap {
  134. .input-box {
  135. .area-top {
  136. width: 100%;
  137. box-shadow: inset 0 -1px 0 0 #ECECEC;
  138. min-height: 280rpx;
  139. text-align: left;
  140. }
  141. }
  142. .img-box {
  143. padding: 30rpx;
  144. display: flex;
  145. flex-direction: column;
  146. margin-top: 20rpx;
  147. margin-bottom: 160rpx;
  148. .next-title {
  149. width: 100%;
  150. font-size: 36rpx;
  151. color: var(--mainColor);
  152. }
  153. .font-red {
  154. color: #ff0000;
  155. }
  156. .img-wrap {
  157. width: 100%;
  158. font-size: 28rpx;
  159. line-height: 44rpx;
  160. color: #999999;
  161. margin: 20rpx 0;
  162. }
  163. .add-img {
  164. left: 60rpx;
  165. border: 4rpx dashed #999;
  166. font-size: 40rpx;
  167. }
  168. }
  169. .bottom-btn {
  170. position: fixed;
  171. bottom: 0;
  172. width: 100%;
  173. padding: 20rpx 0;
  174. .btn {
  175. border-radius: 40rpx;
  176. display: flex;
  177. align-items: center;
  178. justify-content: center;
  179. color: #FFFFFF;
  180. border: 1rpx solid var(--activeColor);
  181. background-color: var(--activeColor);
  182. box-shadow: 0 1px 10px 0px var(--activeColor);
  183. width: 400rpx;
  184. height: 80rpx;
  185. }
  186. }
  187. }
  188. .bg-img {
  189. overflow: visible !important;
  190. .img-item {
  191. border-radius: 20rpx;
  192. }
  193. .close-img {
  194. position: absolute;
  195. width: 36rpx !important;
  196. top: -18rpx;
  197. right: -18rpx;
  198. }
  199. }
  200. </style>