messageDetail.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view class="message-detail-index">
  3. <view class="message-detail-content">
  4. <text v-if="detail.id">{{detail.sendUserName}}{{detail.message}}</text>
  5. </view>
  6. <view class="message-btn-box" v-if="dataDetail.status === 1">
  7. <view class="message-btn red" @click="btnClick('拒绝',3)">拒绝</view>
  8. <view class="line"></view>
  9. <view class="message-btn primary" @click="btnClick('同意',2)">同意</view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. import {
  15. getMessageDetailById,
  16. bindProject,
  17. getCustomerDetailById,
  18. updateCustomer,
  19. getAgentDetailById,
  20. updateAgent
  21. } from '@/request/api/message.js'
  22. export default {
  23. data() {
  24. return {
  25. messageId: '',
  26. detail: {},
  27. dataDetail: {}
  28. }
  29. },
  30. onLoad(body) {
  31. this.messageId = body.id;
  32. this.init();
  33. },
  34. methods: {
  35. init() {
  36. getMessageDetailById(this.messageId).then(res => {
  37. if (res.code == 200) {
  38. this.detail = res.data;
  39. this.detail = Object.assign(this.detail, JSON.parse(this.detail.json));
  40. this.initDetail();
  41. }
  42. })
  43. },
  44. initDetail() {
  45. if (this.detail.identityId === 1) { //客户
  46. getCustomerDetailById(this.detail.dataId).then(res => {
  47. if (res.code == 200) {
  48. this.dataDetail = res.data;
  49. }
  50. })
  51. } else if (this.detail.identityId === 2) { //经纪人
  52. getAgentDetailById(this.detail.dataId).then(res => {
  53. if (res.code == 200) {
  54. this.dataDetail = res.data;
  55. }
  56. })
  57. }
  58. },
  59. btnClick(msg, type) {
  60. uni.showModal({
  61. title: '有极提示',
  62. content: '是否' + msg + '加入该项目',
  63. success: (res) => {
  64. if (res.confirm) {
  65. if (this.detail.identityId === 1) { //客户
  66. updateCustomer({
  67. id: this.dataDetail.id,
  68. status: type
  69. }).then(res => {
  70. if (res.code == 200) {
  71. if (type === 2) return this.operationProject();
  72. this.initDetail();
  73. this.$toast('操作成功');
  74. }
  75. })
  76. } else if (this.detail.identityId === 2) { //经纪人
  77. updateAgent({
  78. id: this.dataDetail.id,
  79. status: type
  80. }).then(res => {
  81. if (res.code == 200) {
  82. if (type === 2) return this.operationProject();
  83. this.initDetail();
  84. this.$toast('操作成功');
  85. }
  86. })
  87. }
  88. }
  89. }
  90. });
  91. },
  92. operationProject() {
  93. let postData = {
  94. organizationId: this.detail.organizationId,
  95. projectId: this.detail.projectId,
  96. userId: this.$store.getters.user.userId,
  97. identityId: this.detail.identityId
  98. }
  99. if (this.detail.identityId === 1) { //客户
  100. postData['clientId'] = this.detail.dataId
  101. } else if (this.detail.identityId === 2) { //经纪人
  102. postData['agentId'] = this.detail.dataId
  103. }
  104. bindProject(postData).then(res => {
  105. if (res.code === 200) {
  106. this.$toast('操作成功');
  107. this.initDetail();
  108. }
  109. })
  110. }
  111. }
  112. }
  113. </script>
  114. <style lang="scss">
  115. .message-detail-index {
  116. background: $uni-white;
  117. padding: 20rpx;
  118. padding-bottom: 0;
  119. margin: 20rpx 30rpx;
  120. border-radius: 10rpx;
  121. .message-detail-content {
  122. min-height: 200rpx;
  123. padding-bottom: 40rpx;
  124. }
  125. .message-btn-box {
  126. width: 100%;
  127. display: flex;
  128. height: 80rpx;
  129. align-items: center;
  130. border-top: 1px solid $uni-border-3;
  131. .line {
  132. width: 1px;
  133. height: 40rpx;
  134. background: $uni-border-3;
  135. }
  136. .message-btn {
  137. text-align: center;
  138. flex: 1;
  139. }
  140. .red {
  141. color: $uni-error;
  142. }
  143. .primary {
  144. color: $uni-primary;
  145. }
  146. }
  147. }
  148. </style>