bottom-tool-bar.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view class="bottom-tool-bar">
  3. <tm-translate :auto="true" animation-name="fadeUp">
  4. <view class="content flex">
  5. <view class="input" @click="fnToComment()">
  6. <text class="icon iconfont icon-edit"></text>
  7. <text class="text">(*^▽^*)说点啥吧~</text>
  8. </view>
  9. <view class="right flex">
  10. <!-- 点赞 -->
  11. <view class="item likes" @click="fnDoLikes()">
  12. <view class="iconfont icon-like"></view>
  13. <view class="text">{{ tempPost.likes }}</view>
  14. </view>
  15. <!-- 评论 -->
  16. <view class="item comment">
  17. <view class="iconfont icon-comment-dots"></view>
  18. <view class="text">{{ tempPost.commentCount }}</view>
  19. </view>
  20. <!-- 分享 -->
  21. <view class="item share" @click="fnOnShare()"><text class="iconfont icon-share1"></text></view>
  22. </view>
  23. </view>
  24. </tm-translate>
  25. <tm-shareSheet @change="fnOnShareChange" :actions="share.list" title="分享文章" v-model="share.show"></tm-shareSheet>
  26. </view>
  27. </template>
  28. <script>
  29. import tmTranslate from '@/tm-vuetify/components/tm-translate/tm-translate.vue';
  30. import tmShareSheet from '@/tm-vuetify/components/tm-shareSheet/tm-shareSheet.vue';
  31. export default {
  32. name: 'bottom-tool-bar',
  33. components: {
  34. tmTranslate,
  35. tmShareSheet
  36. },
  37. props: {
  38. // 文章数据
  39. post: {
  40. type: Object,
  41. default: () => {}
  42. },
  43. // 其他参数
  44. params: {
  45. type: Object,
  46. default: () => {}
  47. }
  48. },
  49. data() {
  50. return {
  51. share: {
  52. show: false,
  53. list: [
  54. [
  55. { name: '微信好友', bgcolor: '#07c160', icon: 'icon-weixin', color: 'white' },
  56. { name: '朋友圈', bgcolor: '#04c887', icon: 'icon-pengyouquan', color: 'white' },
  57. { name: '生成海报', bgcolor: '#1dc0fd', icon: 'icon-QQ', color: 'white' }
  58. ]
  59. ]
  60. },
  61. tempPost: {}
  62. };
  63. },
  64. watch: {
  65. post: {
  66. deep: true,
  67. handler(val) {
  68. console.log('watch', val);
  69. this.tempPost = this.$utils.deepClone(val);
  70. }
  71. }
  72. },
  73. created() {
  74. console.log(this.post);
  75. this.tempPost = this.$utils.deepClone(this.post);
  76. console.log(this.tempPost);
  77. },
  78. methods: {
  79. fnToComment() {
  80. this.$Router.push({
  81. path: '/pagesA/comment/comment',
  82. query: {
  83. postId: this.post.id,
  84. parentId: 0,
  85. title: this.post.title,
  86. formPage: 'comment_list',
  87. type: 'post'
  88. }
  89. });
  90. },
  91. fnDoLikes() {
  92. this.$httpApi
  93. .postLikePost(this.post.id)
  94. .then(res => {
  95. if (res.status == 200) {
  96. uni.showToast({
  97. icon: 'none',
  98. title: '点赞成功'
  99. });
  100. this.tempPost.likes += 1;
  101. } else {
  102. uni.showToast({
  103. icon: 'none',
  104. title: res.message
  105. });
  106. }
  107. })
  108. .catch(err => {
  109. console.log(err);
  110. uni.showToast({
  111. icon: 'none',
  112. title: err.message
  113. });
  114. });
  115. },
  116. fnOnShare() {
  117. // this.$emit('on-share');
  118. this.share.show = true;
  119. },
  120. fnOnShareChange(e) {
  121. console.log(e);
  122. }
  123. }
  124. };
  125. </script>
  126. <style scoped lang="scss">
  127. .bottom-tool-bar {
  128. width: 100vw;
  129. position: fixed;
  130. left: 0;
  131. bottom: 0;
  132. z-index: 401;
  133. ::v-deep {
  134. .tm-shareSheet-wk .uni-scroll-view-content {
  135. display: flex;
  136. align-items: center;
  137. justify-content: center;
  138. }
  139. }
  140. .content {
  141. width: 100%;
  142. justify-content: space-between;
  143. box-sizing: border-box;
  144. padding: 24rpx;
  145. background-color: #ffffff;
  146. box-shadow: 0rpx -4rpx 24rpx rgba(0, 0, 0, 0.07);
  147. border-radius: 24rpx 24rpx 0 0;
  148. .input {
  149. width: 280rpx;
  150. padding: 12rpx 24rpx;
  151. background-color: #f5f5f5;
  152. border-radius: 60rpx;
  153. font-size: 24rpx;
  154. color: #666;
  155. .icon {
  156. }
  157. .text {
  158. padding-left: 8rpx;
  159. }
  160. }
  161. .right {
  162. width: 0;
  163. flex-grow: 1;
  164. align-items: center;
  165. justify-content: space-between;
  166. padding-left: 24rpx;
  167. .item {
  168. margin-left: 24rpx;
  169. text-align: center;
  170. display: flex;
  171. align-items: center;
  172. &.share {
  173. .iconfont {
  174. font-size: 36rpx;
  175. }
  176. }
  177. .iconfont {
  178. font-size: 36rpx;
  179. color: #333;
  180. }
  181. .text {
  182. padding-left: 6rpx;
  183. font-size: 32rpx;
  184. }
  185. }
  186. }
  187. }
  188. }
  189. </style>