message-custom.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <div class="custom" style="font-size: 14px">
  3. <!-- 发送房源 -->
  4. <template v-if="isCustom.businessID === 'house_message'">
  5. <view>
  6. <view
  7. class="qzy-center item-main"
  8. @click="
  9. toDetail(
  10. isCustom.shopUserId,
  11. isCustom.publishType,
  12. isCustom.houseId
  13. )
  14. "
  15. >
  16. <image class="item-l" :src="isCustom.indoorImg" mode="scaleToFill" />
  17. <view class="item-r">
  18. <view class="text-14 text-bold item-title ellipsis-nowrap">
  19. {{ isCustom.publishType }}丨{{ isCustom.communityName }}
  20. </view>
  21. <view class="qzy-center text-12 text-500 item-row">
  22. <text>{{ isCustom.houseType }}</text>
  23. <text>丨</text>
  24. <text>{{ isCustom.acreage }}㎡</text>
  25. <text>丨</text>
  26. <text>{{ isCustom.orientation }}</text>
  27. </view>
  28. <view class="qzy-center text-500">
  29. <text class="text-18">{{ isCustom.price }}</text>
  30. <i class="text-12">{{ isCustom.unitName }}</i>
  31. </view>
  32. <view class="item-address text-10 text-500 ellipsis-nowrap">
  33. <text
  34. >{{ isCustom.cityName }}{{ isCustom.areaName
  35. }}{{ isCustom.address }}</text
  36. >
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <!-- 发送邀请 -->
  43. <template v-else-if="isCustom.businessID === 'appointment_message'">
  44. <view class="invite-box">
  45. <view class="text-18 text-bold">{{
  46. formatterTitle(isCustom.status)
  47. }}</view>
  48. <view class="item-row text-16 text-500">{{ isCustom.houseName }}</view>
  49. <view class="item-row">
  50. <text>预约时间:</text>
  51. <view>{{ isCustom.time }}</view>
  52. </view>
  53. <view class="item-row">
  54. <text>小区地址:</text>
  55. <view>{{ isCustom.address }}</view>
  56. </view>
  57. <view class="item-row">
  58. <text>联系方式:</text>
  59. <view>{{ isCustom.contact }}</view>
  60. </view>
  61. <view class="item-row qzy-center"
  62. >信息费:<text class="text-bold">0</text>元</view
  63. >
  64. <view
  65. v-if="isCustom.status == 0 && isCustom.inviteeId == ownId"
  66. class="operate-box"
  67. @click="acceptHandle(isCustom.appointmentId)"
  68. >接受预约</view
  69. >
  70. </view>
  71. </template>
  72. </div>
  73. </template>
  74. <script lang="ts" setup>
  75. import { watchEffect, ref } from "../../../../adapter-vue";
  76. import {
  77. TUITranslateService,
  78. IMessageModel,
  79. } from "@tencentcloud/chat-uikit-engine";
  80. import { isUrl, JSONToObject } from "../../../../utils/index";
  81. import { CHAT_MSG_CUSTOM_TYPE } from "../../../../constant";
  82. import { ICustomMessagePayload } from "../../../../interface";
  83. import Icon from "../../../common/Icon.vue";
  84. import star from "../../../../assets/icon/star-light.png";
  85. import api from "@/api/home/home.js";
  86. const ownId = uni.getStorageSync("userId");
  87. interface IEmits {
  88. (key: "scrollToLatestMessage"): void;
  89. }
  90. const emits = defineEmits<IEmits>();
  91. interface Props {
  92. messageItem: IMessageModel;
  93. content: any;
  94. }
  95. const props = withDefaults(defineProps<Props>(), {
  96. messageItem: undefined,
  97. content: undefined,
  98. });
  99. const custom = ref();
  100. const message = ref<IMessageModel>();
  101. const extension = ref();
  102. const isCustom = ref<ICustomMessagePayload>({
  103. businessID: "",
  104. });
  105. watchEffect(() => {
  106. custom.value = props.content;
  107. message.value = props.messageItem;
  108. const { payload } = props.messageItem;
  109. isCustom.value = payload.data || "";
  110. isCustom.value = JSON.parse(payload.data);
  111. if (payload.data === CHAT_MSG_CUSTOM_TYPE.SERVICE) {
  112. extension.value = JSONToObject(payload.extension);
  113. }
  114. });
  115. const acceptHandle = async (id) => {
  116. const { code, data } = await api.changeUserSubscribe({ id: id, status: 1 });
  117. if (code === 200) {
  118. uni.$u.toast("已接受预约~");
  119. emits("scrollToLatestMessage");
  120. }
  121. };
  122. // 发送邀请标题文字格式化
  123. const formatterTitle = (status) => {
  124. if (status == 0) {
  125. return "待确认预约看房邀请";
  126. } else if (status == 1) {
  127. return "已接受预约看房邀请";
  128. } else if (status == 2) {
  129. return "已看房";
  130. } else if (status == 3) {
  131. return "已成交";
  132. } else if (status == 4) {
  133. return "未按时看房";
  134. } else {
  135. return "已取消预约看房邀请";
  136. }
  137. };
  138. const toDetail = (shopUserId, publishType, houseId) => {
  139. // 自己发布的房源不跳转详情
  140. if (shopUserId == uni.getStorageSync("userId")) {
  141. return false;
  142. }
  143. let path = "";
  144. if (publishType == "新房") {
  145. path = "/packageHouse/home/house/new-house-detail";
  146. } else if (publishType == "二手房") {
  147. path = "/packageHouse/home/house/used-house-detail";
  148. } else {
  149. path = "/packageHouse/home/house/renting-house-detail";
  150. }
  151. webUni.webView.navigateTo({ url: path + "?id=" + houseId });
  152. };
  153. </script>
  154. <style lang="scss" scoped>
  155. @import "../../../../assets/styles/common";
  156. .phone {
  157. min-width: 180px;
  158. height: 65px;
  159. border-radius: 10px;
  160. display: flex;
  161. flex-direction: row;
  162. align-items: center;
  163. justify-content: center;
  164. padding: 2px;
  165. }
  166. .xian {
  167. width: 408rpx;
  168. height: 1rpx;
  169. background: #000000;
  170. opacity: 0.1;
  171. }
  172. .phone_footer {
  173. display: flex;
  174. flex-direction: row;
  175. justify-content: space-around;
  176. position: relative;
  177. top: 8px;
  178. height: 25px;
  179. align-items: center;
  180. }
  181. a {
  182. color: #00b693;
  183. }
  184. .custom {
  185. font-size: 14px;
  186. h1 {
  187. font-size: 14px;
  188. color: #000;
  189. }
  190. h1,
  191. a,
  192. p {
  193. font-size: 14px;
  194. }
  195. .evaluate {
  196. ul {
  197. display: flex;
  198. padding: 10px 0;
  199. }
  200. &-list {
  201. display: flex;
  202. flex-direction: row;
  203. &-item {
  204. padding: 0 2px;
  205. }
  206. }
  207. }
  208. .order {
  209. display: flex;
  210. min-height: 250px;
  211. min-width: 215px;
  212. flex-direction: column;
  213. padding: 5px;
  214. .header {
  215. width: 100%;
  216. height: 55px;
  217. display: flex;
  218. flex-direction: row;
  219. justify-content: space-between;
  220. }
  221. .contont {
  222. display: flex;
  223. flex-direction: column;
  224. justify-content: space-around;
  225. align-items: flex-start;
  226. height: 190px;
  227. .title {
  228. font-family: PingFang SC;
  229. font-weight: 500;
  230. font-size: 26rpx;
  231. color: #a1a1a1;
  232. line-height: 44rpx;
  233. }
  234. .value {
  235. font-family: PingFang SC;
  236. font-weight: 500;
  237. font-size: 30rpx;
  238. color: #666666;
  239. line-height: 44rpx;
  240. }
  241. }
  242. .main {
  243. padding-left: 5px;
  244. width: 90%;
  245. line-height: 25px;
  246. }
  247. img {
  248. width: 45px;
  249. height: 45px;
  250. }
  251. }
  252. .data-time {
  253. background: #f4f4f4;
  254. padding: 10upx 24upx;
  255. }
  256. .item-l {
  257. width: 60px;
  258. height: 60px;
  259. border-radius: 6upx;
  260. margin-right: 22upx;
  261. }
  262. .item-r {
  263. width: calc(100% - 70px);
  264. padding: 10upx 0;
  265. }
  266. .item-row {
  267. text {
  268. display: block;
  269. }
  270. }
  271. i {
  272. font-style: normal;
  273. }
  274. .invite-box {
  275. .item-row {
  276. padding: 10upx 0;
  277. }
  278. }
  279. }
  280. .operate-box {
  281. margin-top: 10px;
  282. padding-top: 10px;
  283. text-align: center;
  284. font-weight: bold;
  285. font-size: 32upx;
  286. }
  287. .in {
  288. .operate-box {
  289. color: #009f82;
  290. border-top: 1px solid #f4f4f4;
  291. }
  292. .item-main {
  293. background: #f4f4f4;
  294. padding: 0 14upx;
  295. border-radius: 16rpx;
  296. }
  297. }
  298. .out {
  299. .operate-box {
  300. border-top: 1px solid rgba(255, 255, 255, 0.5);
  301. color: #fff;
  302. }
  303. .item-main {
  304. background: #009f82;
  305. padding: 0 14upx;
  306. border-radius: 16rpx;
  307. }
  308. }
  309. </style>