index.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <view>
  3. <view v-if="message.payload.operationType === 1" class="card handle">
  4. <view>
  5. <view class="time">{{ messageTime }}</view>
  6. {{ renderDom }}
  7. </view>
  8. <view class="choose"><view class="button" @tap="handleClick">处理</view></view>
  9. </view>
  10. <view class="card" v-else>
  11. <view class="time">{{ messageTime }}</view>
  12. {{ renderDom }}
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import { parseGroupSystemNotice } from '../../../base/message-facade';
  18. import { caculateTimeago } from '../../../base/common';
  19. export default {
  20. data() {
  21. return {
  22. // message: {},
  23. messageTime: '',
  24. renderDom: ''
  25. };
  26. },
  27. components: {},
  28. props: {
  29. message: {
  30. type: Object
  31. }
  32. },
  33. watch: {
  34. message: {
  35. handler: function(newVal) {
  36. this.messageTime=caculateTimeago(newVal.time * 1000);
  37. this.renderDom=parseGroupSystemNotice(newVal);
  38. // this.setData({
  39. // messageTime: caculateTimeago(newVal.time * 1000),
  40. // renderDom: parseGroupSystemNotice(newVal)
  41. // });
  42. },
  43. immediate: true,
  44. deep: true
  45. }
  46. },
  47. methods: {
  48. handleClick() {
  49. uni.showActionSheet({
  50. itemList: ['同意', '拒绝'],
  51. success: res => {
  52. const option = {
  53. handleAction: 'Agree',
  54. handleMessage: '欢迎进群',
  55. message: this.message
  56. };
  57. if (res.tapIndex === 1) {
  58. option.handleAction = 'Reject';
  59. option.handleMessage = '拒绝申请';
  60. }
  61. uni.$TUIKit
  62. .handleGroupApplication(option)
  63. .then(() => {
  64. uni.showToast({
  65. title: option.handleAction === 'Agree' ? '已同意申请' : '已拒绝申请'
  66. });
  67. })
  68. .catch(error => {
  69. uni.showToast({
  70. title: error.message || '处理失败',
  71. icon: 'none'
  72. });
  73. });
  74. }
  75. });
  76. }
  77. }
  78. };
  79. </script>
  80. <style scoped>
  81. @import './index.css';
  82. </style>