UserInfoCard.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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-header">
  27. <text>描述</text>
  28. <text>操作人</text>
  29. <text>时间</text>
  30. </view>
  31. <view class="log-item" v-for="(log, index) in detail.logVoList" :key="index">
  32. <text class="log-item-content">{{ log.statusName }}</text>
  33. <text class="log-item-name">{{ log.createName }}</text>
  34. <text class="log-item-time">{{ log.createTime }}</text>
  35. </view>
  36. </view>
  37. </u-modal>
  38. <u-modal v-model:show="showBlacklistModal" title="拉黑用户" :showCancelButton="true" confirmText="提交"
  39. cancelText="取消" @confirm="confirmBlacklist" @cancel="showBlacklistModal = false">
  40. <textarea class="reason-textarea" placeholder="请输入拉黑原因..." autoHeight bg-color="#f8f8f8"
  41. border-radius="10rpx" v-model="reason" height="100px"></textarea>
  42. </u-modal>
  43. </view>
  44. </template>
  45. <script setup>
  46. import { ref, computed } from 'vue';
  47. const props = defineProps({
  48. detail: {
  49. type: Object,
  50. default: () => ({})
  51. }
  52. });
  53. const formattedName = computed(() => {
  54. return props.detail?.userNick?.charAt(0) + '**';
  55. });
  56. const statusClass = computed(() => {
  57. return props.detail.userStatus == 1 ? 'color-green' : 'color-red';
  58. });
  59. const blacklistAction = computed(() => {
  60. return props.detail.userStatus == 1 ? '加入黑名单' : '移除黑名单';
  61. });
  62. const showModal = ref(false);
  63. const showBlacklistModal = ref(false);
  64. const reason = ref('');
  65. const toggleBlacklist = () => {
  66. showBlacklistModal.value = true;
  67. };
  68. const confirmBlacklist = () => {
  69. let apiStr = props.detail.userStatus == 1 ? '/app/appUser/setUserBlack' : 'app/appUser/removeUserBlack';
  70. uni.$u.http.post(apiStr, {
  71. userId: props.detail.userId,
  72. reason: reason.value
  73. }).then(res => {
  74. if (res.code == 200) {
  75. uni.$u.toast('操作成功');
  76. showBlacklistModal.value = false;
  77. props.detail.userStatus = props.detail.userStatus == 1 ? 2 : 1;
  78. } else {
  79. uni.$u.toast(res.msg);
  80. }
  81. });
  82. };
  83. </script>
  84. <style lang="scss" scoped>
  85. .user-info-card {
  86. .header {
  87. display: flex;
  88. justify-content: space-between;
  89. padding: 24rpx 30rpx;
  90. border-bottom: 1rpx solid #e6e6e6;
  91. }
  92. .content {
  93. padding: 15px;
  94. border-bottom: 1rpx solid #e6e6e6;
  95. .user-image {
  96. width: 50px;
  97. height: 50px;
  98. border-radius: 50%;
  99. }
  100. }
  101. .log-container {
  102. max-height: 60vh;
  103. overflow-y: auto;
  104. background: #fff;
  105. width: 100%;
  106. }
  107. .log-header {
  108. display: flex;
  109. padding: 20rpx;
  110. background: #f2f2f2;
  111. font-size: 28rpx;
  112. color: #333;
  113. text-align: center;
  114. text:nth-child(1) {
  115. flex: 1.2;
  116. flex-shrink: 0;
  117. }
  118. text:nth-child(2),
  119. text:nth-child(3) {
  120. flex: 1;
  121. flex-shrink: 0;
  122. }
  123. }
  124. .log-item {
  125. display: flex;
  126. padding: 20rpx;
  127. border-bottom: 1px solid #f2f2f2;
  128. font-size: 28rpx;
  129. color: #666;
  130. .log-item-content {
  131. flex: 1.2;
  132. text-align: center;
  133. flex-shrink: 0;
  134. }
  135. .log-item-name,
  136. .log-item-time {
  137. flex: 1;
  138. text-align: center;
  139. flex-shrink: 0;
  140. }
  141. &:last-child {
  142. border-bottom: none;
  143. }
  144. }
  145. :deep(.u-modal__content) {
  146. padding: 20rpx !important;
  147. }
  148. :deep(.reason-textarea .uni-textarea-wrapper) {
  149. background-color: #f8f8f8;
  150. border-radius: 10rpx;
  151. padding: 20rpx;
  152. box-sizing: border-box;
  153. min-height: 100px;
  154. .uni-textarea-textarea,
  155. .uni-textarea-placeholder {
  156. padding: 10rpx 20rpx;
  157. }
  158. }
  159. }
  160. </style>