messageDetail.vue 3.6 KB

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