communityPush.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <template name="communityPush">
  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="写点啥..." 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 : 'communityPush',
  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. },
  54. data() {
  55. return {
  56. pic : [],
  57. content : '',
  58. upload : 'img',
  59. total : 9,
  60. };
  61. },
  62. mounted() {
  63. // 初始化上传数据
  64. this.Dever.getUpload().data = {};
  65. this.Dever.getUpload().data[this.upload] = [];
  66. this.pic = [];
  67. },
  68. methods: {
  69. // 保存数据
  70. save : function() {
  71. var self = this;
  72. var data = {};
  73. data.content = this.content;
  74. if (this.pic.length > 0) {
  75. data.pic = this.pic.join(',');
  76. }
  77. data.cate_id = this.cate_id;
  78. data.type = this.type;
  79. data.type_id = this.type_id;
  80. data.to_id = this.to_id;
  81. data.to_uid = this.to_uid;
  82. this.Dever.post('app/community/?l=api.add', data, function(t) {
  83. self.getRefresh();
  84. });
  85. },
  86. // 选择图片
  87. choose: function() {
  88. var self = this;
  89. var upload = this.Dever.upload(this.upload, this.total, function(type, img) {
  90. self.pic = img;
  91. });
  92. },
  93. // 删除图片
  94. del : function(e) {
  95. var self = this;
  96. self.pic.splice(e.currentTarget.dataset.index, 1)
  97. },
  98. hideModal : function() {
  99. this.$emit('hideModal');
  100. },
  101. getRefresh : function() {
  102. this.$emit('getRefresh', this.cate_id, this.type, this.type_id);
  103. }
  104. }
  105. }
  106. </script>
  107. <style lang="less" scoped>
  108. .textarea-placeholder {
  109. text-align: left;;
  110. }
  111. .grid.grid-square {
  112. overflow: visible;
  113. }
  114. .margin-left {
  115. width: 100%;
  116. font-size: 13px;
  117. line-height: 21px;
  118. margin-left: -60rpx;
  119. }
  120. .publish-wrap {
  121. .input-box {
  122. .area-top {
  123. width: 100%;
  124. box-shadow: inset 0 -1px 0 0 #ECECEC;
  125. min-height: 280rpx;
  126. text-align: left;
  127. }
  128. }
  129. .img-box {
  130. padding: 30rpx;
  131. display: flex;
  132. flex-direction: column;
  133. margin-top: 20rpx;
  134. margin-bottom: 160rpx;
  135. .next-title {
  136. width: 100%;
  137. font-size: 36rpx;
  138. color: var(--mainColor);
  139. }
  140. .font-red {
  141. color: #ff0000;
  142. }
  143. .img-wrap {
  144. width: 100%;
  145. font-size: 28rpx;
  146. line-height: 44rpx;
  147. color: #999999;
  148. margin: 20rpx 0;
  149. }
  150. .add-img {
  151. left: 60rpx;
  152. border: 4rpx dashed #999;
  153. font-size: 40rpx;
  154. }
  155. }
  156. .bottom-btn {
  157. position: fixed;
  158. bottom: 0;
  159. width: 100%;
  160. padding: 20rpx 0;
  161. .btn {
  162. border-radius: 40rpx;
  163. display: flex;
  164. align-items: center;
  165. justify-content: center;
  166. color: #FFFFFF;
  167. border: 1rpx solid var(--activeColor);
  168. background-color: var(--activeColor);
  169. box-shadow: 0 1px 10px 0px var(--activeColor);
  170. width: 400rpx;
  171. height: 80rpx;
  172. }
  173. }
  174. }
  175. .bg-img {
  176. overflow: visible !important;
  177. .img-item {
  178. border-radius: 20rpx;
  179. }
  180. .close-img {
  181. position: absolute;
  182. width: 36rpx !important;
  183. top: -18rpx;
  184. right: -18rpx;
  185. }
  186. }
  187. </style>