send.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. <template>
  2. <view>
  3. <view style="background-color: #fff;">
  4. <editor id="editor" class="ql-container" placeholder="请文明发言,不可涉及黄、赌、毒、捐赠相关动态!"
  5. :show-img-size="true"
  6. @ready="onEditorReady"
  7. @blur="setInputLength"
  8. @input="calculateWordCount"></editor>
  9. <u-upload :action="action" upload-text="" :show-progress="true" :max-count="type=='video'?1:9" :show-tips="false"></u-upload>
  10. </view>
  11. <view class="operate-content">
  12. <span class="content">同时分享到微信朋友圈:</span>
  13. <div class="not-share not-share-margin" v-if="!ifShare" @click="switchShareContent"></div>
  14. <image v-else src="../../static/dynamic/gx_add_gou2.png" class="add-gou-img not-share-margin"
  15. @click="switchShareContent"></image>
  16. <span class="content">关闭评论</span>
  17. <div class="open-comment" v-if="!ifCloseComment" @click="switchComment"></div>
  18. <image v-else src="../../static/dynamic/gx_add_gou2.png" class="add-gou-img" @click="switchComment"></image>
  19. </view>
  20. <view class="input-contorl-box">
  21. <view class="contorl-btn-box">
  22. <view class="control-btn">
  23. <image
  24. src="../../static/dynamic/talk_image_icon.png"
  25. class="choose-img"
  26. @click="chooseImg"></image>
  27. <image v-if="!ifShowKeyboard" src="../../static/dynamic/gongxiu_emoji.png" class="choose-emoji"
  28. @click="switchEmojiStatus"></image>
  29. <image v-else src="../../static/dynamic/gongxiu_keyboard.png" class="choose-emoji"
  30. @click="switchEmojiStatus"></image>
  31. </view>
  32. <view style="width: 510rpx">
  33. <text class="input-word">{{wordCount}}/1500</text>
  34. </view>
  35. </view>
  36. <view class="emoji-list-box" v-show="ifShowEmoji">
  37. <swiper :indicator-dots="true" indicator-active-color="#FF713F">
  38. <swiper-item v-for="(parentItem, parentIndex) in emojiList" :key="parentIndex">
  39. <view class="emoji-list-item">
  40. <image v-for="(item,index) in parentItem" :src="getImgUrl(item)" :key="index"
  41. @click="clickEmoji(item)" class="emoji-img"></image>
  42. </view>
  43. </swiper-item>
  44. </swiper>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. import emojiData from "../../static/emoji/emojiData.js"
  51. export default {
  52. data() {
  53. return {
  54. content: '', //发表内容:
  55. action: '', //图片上传路径
  56. type: 'image',
  57. ifShare: false, //是否把发布的内容分享到朋友圈,
  58. ifCloseComment: false, //是否关闭评论
  59. ifShowEmoji: false, //是否显示表情面板
  60. emojiList: [], //表情列表
  61. imgUrl: '../../static/dynamic/',
  62. ifShowKeyboard: false,
  63. wordCount: 0, //输入的字符数
  64. }
  65. },
  66. onLoad() {
  67. this.emojiList = emojiData;
  68. },
  69. methods: {
  70. switchShareContent() {
  71. this.ifShare = !this.ifShare;
  72. if (this.ifShare) {
  73. //分享到朋友圈
  74. }
  75. },
  76. switchComment() {
  77. this.ifCloseComment = !this.ifCloseComment;
  78. if (this.ifCloseComment) {
  79. //关闭评论
  80. }
  81. },
  82. //获取图片路径
  83. getImgUrl(item) {
  84. return this.imgUrl + item.url;
  85. },
  86. onEditorReady() {
  87. uni.createSelectorQuery().select('#editor').context((res) => {
  88. this.editorCtx = res.context
  89. }).exec()
  90. },
  91. setInputLength(){},
  92. calculateWordCount(e){
  93. let count = (e.detail.html.split('img')).length-1;
  94. this.wordCount = e.detail.text.length-1+count*4;
  95. },
  96. //点击每个表情
  97. clickEmoji(item) {
  98. var that = this;
  99. //往富文本编辑器里插入图片
  100. this.editorCtx.insertImage({
  101. src: this.imgUrl + item.url,
  102. width: 20,
  103. height: 20,
  104. extClass: 'emojiIamge',
  105. success: function() {
  106. // console.log("insert success!")
  107. }
  108. });
  109. },
  110. switchEmojiStatus() {
  111. this.ifShowKeyboard = !this.ifShowKeyboard;
  112. this.ifShowEmoji = !this.ifShowEmoji;
  113. },
  114. //选择图片
  115. chooseImg(){
  116. uni.chooseImage({
  117. sourceType:['album','camera'],
  118. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  119. success: (res)=>{
  120. console.log(JSON.stringify(res.tempFilePaths));
  121. }
  122. });
  123. }
  124. }
  125. }
  126. </script>
  127. <style>
  128. page {
  129. background-color: rgb(247, 246, 242);
  130. }
  131. </style>
  132. <style lang="less" scoped>
  133. /deep/.u-input__textarea {
  134. font-size: 40rpx !important;
  135. padding: 25rpx 20rpx;
  136. }
  137. /deep/uni-textarea {
  138. caret-color: #FF713F;
  139. }
  140. /deep/.uicon-plus {
  141. font-size: 40px !important;
  142. }
  143. /deep/.u-add-wrap {
  144. color: rgb(190, 190, 190);
  145. background-color: #fff;
  146. border: 2px solid rgb(190, 190, 190);
  147. }
  148. /deep/.u-upload {
  149. padding: 0 0 15rpx 15rpx;
  150. }
  151. /deep/.ql-editor.ql-blank:before {
  152. color: rgba(0, 0, 0, 0.5);
  153. font-style: normal!important;
  154. font-size: 40rpx ;
  155. }
  156. /deep/.ql-container{
  157. font-size: 40rpx !important;
  158. padding: 15rpx 25rpx;
  159. }
  160. .operate-content {
  161. display: flex;
  162. align-items: center;
  163. padding: 15rpx;
  164. .content {
  165. color: rgb(113, 113, 111);
  166. padding-right: 25rpx;
  167. font-size: 32rpx;
  168. }
  169. .not-share,
  170. .open-comment {
  171. width: 22rpx;
  172. height: 22rpx;
  173. border-radius: 50%;
  174. border: 6rpx solid rgb(201, 201, 201);
  175. display: inline-block;
  176. }
  177. .not-share-margin {
  178. margin-right: 95rpx;
  179. }
  180. .add-gou-img {
  181. width: 45rpx;
  182. height: 45rpx;
  183. }
  184. }
  185. .input-contorl-box {
  186. position: fixed;
  187. // bottom: 0;
  188. bottom: 100rpx;
  189. margin-top: 10rpx;
  190. background-color: rgb(252, 251, 247);
  191. .contorl-btn-box {
  192. display: flex;
  193. flex-direction: row;
  194. align-items: center;
  195. border-top: 1rpx solid #000;
  196. .control-btn {
  197. background-color: #fff;
  198. .choose-img {
  199. width: 55rpx;
  200. height: 55rpx;
  201. padding: 15rpx 35rpx;
  202. }
  203. .choose-emoji {
  204. width: 55rpx;
  205. height: 55rpx;
  206. padding: 15rpx 35rpx;
  207. }
  208. }
  209. .input-word {
  210. font-size: 40rpx;
  211. display: block;
  212. text-align: right;
  213. padding-right: 15rpx;
  214. }
  215. }
  216. .emoji-list-box {
  217. width: 100%;
  218. height: 292rpx;
  219. background-color: #fff;
  220. .emoji-list-item {
  221. .emoji-img {
  222. width: 60rpx;
  223. height: 60rpx;
  224. padding: 15rpx 24rpx;
  225. }
  226. }
  227. }
  228. }
  229. </style>