index.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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.setData({
  37. messageTime: caculateTimeago(newVal.time * 1000),
  38. renderDom: parseGroupSystemNotice(newVal)
  39. });
  40. },
  41. immediate: true,
  42. deep: true
  43. }
  44. },
  45. methods: {
  46. handleClick() {
  47. uni.showActionSheet({
  48. itemList: ['同意', '拒绝'],
  49. success: res => {
  50. const option = {
  51. handleAction: 'Agree',
  52. handleMessage: '欢迎进群',
  53. message: this.message
  54. };
  55. if (res.tapIndex === 1) {
  56. option.handleAction = 'Reject';
  57. option.handleMessage = '拒绝申请';
  58. }
  59. uni.$TUIKit
  60. .handleGroupApplication(option)
  61. .then(() => {
  62. uni.showToast({
  63. title: option.handleAction === 'Agree' ? '已同意申请' : '已拒绝申请'
  64. });
  65. })
  66. .catch(error => {
  67. uni.showToast({
  68. title: error.message || '处理失败',
  69. icon: 'none'
  70. });
  71. });
  72. }
  73. });
  74. }
  75. }
  76. };
  77. </script>
  78. <style scoped>
  79. @import './index.css';
  80. </style>