UserInfoCard.vue 6.0 KB

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