communityPush.vue 4.6 KB

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