UserInfoCard.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view class="user-info-card bg-white mt-16">
  3. <view class="header">
  4. <text style="color: #666;">{{ detail.orderTime }}</text>
  5. <text @click="showModal = true" class="color-green">[查看订单日志]</text>
  6. </view>
  7. <view class="content flex flex-j-b">
  8. <image :src="detail.imgPath" class="user-image" />
  9. <view class="flex flex-a-e flex-1 ml-12">
  10. <view class="flex flex-d flex-1">
  11. <text class="color-green">{{ formattedName }}<text style="color: #e99d42;">(所有单)</text></text>
  12. <text class="common-text" style="margin-top: 10rpx;">共卖出{{ detail.totalNum }}本书</text>
  13. <text class="common-text">来自{{ detail.sendSsq }}</text>
  14. <text class="common-text" style="margin-top: 10rpx;">用户状态: <text :class="statusClass">{{
  15. detail.userStatus == 1 ? '正常' :
  16. detail.userStatus == 2 ? '黑名单' : '-'
  17. }}</text></text>
  18. </view>
  19. <text style="min-width: 160rpx;" @click="toggleBlacklist" class="color-red">[{{ blacklistAction
  20. }}]</text>
  21. </view>
  22. </view>
  23. <u-modal v-model:show="showModal" title="订单日志" :showCancelButton="false" confirmText="关闭"
  24. @confirm="showModal = false" class="log-modal">
  25. <view class="log-container">
  26. <view class="log-item" v-for="(log, index) in detail.logVoList" :key="index">
  27. <view class="log-item-content">{{ log.content }}</view>
  28. <view class="log-item-name common-text">操作人:{{ log.createName }}</view>
  29. <view class="log-item-time common-text">操作时间:{{ log.createTime }}</view>
  30. </view>
  31. </view>
  32. </u-modal>
  33. <u-modal v-model:show="showBlacklistModal" title="拉黑用户" :showCancelButton="true" confirmText="提交"
  34. cancelText="取消" @confirm="confirmBlacklist" @cancel="showBlacklistModal = false">
  35. <textarea class="reason-textarea" placeholder="请输入拉黑原因..." autoHeight bg-color="#f8f8f8"
  36. border-radius="10rpx" v-model="reason" height="100px"></textarea>
  37. </u-modal>
  38. </view>
  39. </template>
  40. <script setup>
  41. import { ref, computed } from 'vue';
  42. const props = defineProps({
  43. detail: {
  44. type: Object,
  45. default: () => ({})
  46. }
  47. });
  48. const formattedName = computed(() => {
  49. return props.detail?.userNick?.charAt(0) + '**';
  50. });
  51. const statusClass = computed(() => {
  52. return props.detail.userStatus == 1 ? 'color-green' : 'color-red';
  53. });
  54. const blacklistAction = computed(() => {
  55. return props.detail.userStatus == 1 ? '加入黑名单' : '移除黑名单';
  56. });
  57. const showModal = ref(false);
  58. const showBlacklistModal = ref(false);
  59. const reason = ref('');
  60. const toggleBlacklist = () => {
  61. showBlacklistModal.value = true;
  62. };
  63. const confirmBlacklist = () => {
  64. let apiStr = props.detail.userStatus == 1 ? '/app/appUser/setUserBlack' : 'app/appUser/removeUserBlack';
  65. uni.$u.http.post(apiStr, {
  66. userId: props.detail.userId,
  67. reason: reason.value
  68. }).then(res => {
  69. if (res.code == 200) {
  70. uni.$u.toast('操作成功');
  71. showBlacklistModal.value = false;
  72. props.detail.userStatus = props.detail.userStatus == 1 ? 2 : 1;
  73. } else {
  74. uni.$u.toast(res.msg);
  75. }
  76. });
  77. };
  78. </script>
  79. <style lang="scss" scoped>
  80. .user-info-card {
  81. .header {
  82. display: flex;
  83. justify-content: space-between;
  84. padding: 24rpx 30rpx;
  85. border-bottom: 1rpx solid #e6e6e6;
  86. }
  87. .content {
  88. padding: 15px;
  89. border-bottom: 1rpx solid #e6e6e6;
  90. .user-image {
  91. width: 50px;
  92. height: 50px;
  93. border-radius: 50%;
  94. }
  95. }
  96. .log-item {
  97. background-color: #f8f8f8;
  98. padding: 14rpx 20rpx;
  99. margin-bottom: 10rpx;
  100. border-radius: 10rpx;
  101. }
  102. :deep(.u-modal__content) {
  103. padding: 20rpx !important;
  104. }
  105. .log-container {
  106. max-height: 60vh;
  107. overflow-y: auto;
  108. }
  109. :deep(.reason-textarea .uni-textarea-wrapper) {
  110. background-color: #f8f8f8;
  111. border-radius: 10rpx;
  112. padding: 20rpx;
  113. box-sizing: border-box;
  114. min-height: 100px;
  115. .uni-textarea-textarea,
  116. .uni-textarea-placeholder {
  117. padding: 10rpx 20rpx;
  118. }
  119. }
  120. }
  121. </style>