publish.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template name="dever-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. props: {
  44. title : '',
  45. cate_id : null,
  46. type : null,
  47. type_id : 0,
  48. to_id : 0,
  49. to_uid : 0,
  50. index : 0,
  51. is_upload : true,
  52. seconds : 0,
  53. api : {
  54. type : String,
  55. default : 'app/community/?l=api.add'
  56. },
  57. playtime : 0,
  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.playtime = this.playtime;
  89. data.type = this.type;
  90. data.type_id = this.type_id;
  91. data.to_id = this.to_id;
  92. data.to_uid = this.to_uid;
  93. if (this.Dever.config.code) {
  94. data.code = this.Dever.config.code;
  95. }
  96. this.Dever.post(this.api, data, function(t) {
  97. self.getRefresh(data.content);
  98. });
  99. },
  100. // 选择图片
  101. choose: function() {
  102. var self = this;
  103. var upload = this.Dever.upload(this.upload, this.total, function(type, img) {
  104. self.pic = img;
  105. });
  106. },
  107. // 删除图片
  108. del : function(e) {
  109. var self = this;
  110. self.pic.splice(e.currentTarget.dataset.index, 1)
  111. },
  112. hideModal : function() {
  113. this.$emit('hideModal');
  114. },
  115. getRefresh : function(content) {
  116. this.$emit('getRefresh', this.cate_id, this.type, this.type_id, content);
  117. }
  118. }
  119. }
  120. </script>
  121. <style lang="less" scoped>
  122. .textarea-placeholder {
  123. text-align: left;;
  124. }
  125. .grid.grid-square {
  126. overflow: visible;
  127. }
  128. .margin-left {
  129. width: 100%;
  130. font-size: 13px;
  131. line-height: 21px;
  132. margin-left: -60rpx;
  133. }
  134. .publish-wrap {
  135. .input-box {
  136. .area-top {
  137. width: 100%;
  138. box-shadow: inset 0 -1px 0 0 #ECECEC;
  139. min-height: 280rpx;
  140. text-align: left;
  141. }
  142. }
  143. .img-box {
  144. padding: 30rpx;
  145. display: flex;
  146. flex-direction: column;
  147. margin-top: 20rpx;
  148. margin-bottom: 160rpx;
  149. .next-title {
  150. width: 100%;
  151. /*font-size: 36rpx;*/
  152. color: var(--mainColor);
  153. text-align: left;
  154. margin-left: 60rpx;
  155. }
  156. .font-red {
  157. color: #ff0000;
  158. }
  159. .img-wrap {
  160. width: 100%;
  161. font-size: 28rpx;
  162. line-height: 44rpx;
  163. color: #999999;
  164. margin: 20rpx 0;
  165. }
  166. .add-img {
  167. left: 60rpx;
  168. border: 4rpx dashed #999;
  169. font-size: 40rpx;
  170. }
  171. }
  172. .bottom-btn {
  173. position: fixed;
  174. bottom: 0;
  175. width: 100%;
  176. padding: 20rpx 0;
  177. .btn {
  178. border-radius: 40rpx;
  179. display: flex;
  180. align-items: center;
  181. justify-content: center;
  182. color: #FFFFFF;
  183. border: 1rpx solid var(--activeColor);
  184. background-color: var(--activeColor);
  185. box-shadow: 0 1px 10px 0px var(--activeColor);
  186. width: 400rpx;
  187. height: 80rpx;
  188. }
  189. }
  190. }
  191. .bg-img {
  192. overflow: visible !important;
  193. .img-item {
  194. border-radius: 20rpx;
  195. }
  196. .close-img {
  197. position: absolute;
  198. width: 36rpx !important;
  199. top: -18rpx;
  200. right: -18rpx;
  201. }
  202. }
  203. </style>