message-system.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view v-for="(item, index) in messageList" :key="index">
  3. <view v-if="item.payload.operationType === 1" class="card handle">
  4. <view>
  5. <view class="time">{{ caculateTimeago(item.time * 1000) }}</view>
  6. {{ translateGroupSystemNotice(item) }}
  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">{{ caculateTimeago(item.time * 1000) }}</view>
  12. {{translateGroupSystemNotice(item)}}
  13. </view>
  14. </view>
  15. </template>
  16. <script lang="ts">
  17. import { defineComponent, watchEffect, reactive, toRefs } from 'vue';
  18. import { translateGroupSystemNotice } from "../../../../utils/untis";
  19. import { caculateTimeago } from '../../../../utils/date';
  20. const MessageSystem = defineComponent({
  21. props: {
  22. data: {
  23. type: Array,
  24. default: () => {
  25. return [];
  26. }
  27. },
  28. types: {
  29. type: Object,
  30. default: () => {
  31. return {};
  32. }
  33. },
  34. },
  35. setup(props:any, ctx:any) {
  36. const data = reactive({
  37. messageList: [],
  38. types: {}
  39. });
  40. watchEffect(()=>{
  41. data.messageList = props.data;
  42. data.types = props.types;
  43. });
  44. const handleApplication = () => {
  45. uni.showActionSheet({
  46. itemList: ['同意', '拒绝'],
  47. success: res => {
  48. const option = {
  49. handleAction: 'Agree',
  50. handleMessage: '欢迎进群',
  51. message: this.message
  52. };
  53. if (res.tapIndex === 1) {
  54. option.handleAction = 'Reject';
  55. option.handleMessage = '拒绝申请';
  56. }
  57. uni.$TUIKit.handleGroupApplication(option)
  58. .then(() => {
  59. uni.showToast({
  60. title: option.handleAction === 'Agree' ? '已同意申请' : '已拒绝申请'
  61. });
  62. })
  63. .catch(error => {
  64. uni.showToast({
  65. title: error.message || '处理失败',
  66. icon: 'none'
  67. });
  68. });
  69. }
  70. });
  71. }
  72. // const handleApplication = (handleAction:string, message:any) => {
  73. // const options:any = {
  74. // handleAction,
  75. // message,
  76. // };
  77. // ctx.emit('application', options);
  78. // };
  79. return {
  80. ...toRefs(data),
  81. translateGroupSystemNotice,
  82. handleApplication,
  83. caculateTimeago,
  84. };
  85. }
  86. });
  87. export default MessageSystem
  88. </script>
  89. <style lang="scss" scoped>
  90. .container {
  91. width: 100%;
  92. height: 200rpx;
  93. }
  94. .handle {
  95. display: flex;
  96. justify-content: space-between;
  97. }
  98. .card {
  99. font-size: 14px;
  100. margin: 20px;
  101. padding: 20px;
  102. box-sizing: border-box;
  103. border: 1px solid #abdcff;
  104. background-color: #f0faff;
  105. border-radius: 12px;
  106. }
  107. .time {}
  108. .button {
  109. color: blue;
  110. border-radius: 8px;
  111. line-height: 30px;
  112. font-size: 16px;
  113. width: 70px;
  114. }
  115. </style>