houseDetail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. <template>
  2. <view class="content">
  3. <image class="topImg" :src="dataInfo.image" mode="aspectFill"></image>
  4. <view class="sectionA">
  5. <view class="topSection">
  6. <view class="title">{{dataInfo.name}}</view>
  7. <view class="tags">
  8. <view class="item" v-for="(item, idx) in dataInfo.categoryList" :key="idx"
  9. :style="`color: ${color2}; background-color: ${color6};`">{{item.categoryName}}</view>
  10. </view>
  11. <view class="shareBtn" :style="`background-color: ${color1};`" @click="toShareCard(2)">
  12. <image class="icon" src="https://dm.static.elab-plus.com/yezhu/h5/icon_share.png" mode="aspectFit">
  13. </image>
  14. <text>分享项目</text>
  15. </view>
  16. </view>
  17. <view class="bottomSection">
  18. <image class="icon" src="https://dm.static.elab-plus.com/yezhu/h5/icon_dingweiY.png" mode=""></image>
  19. <view class="name">{{dataInfo.province + dataInfo.city + dataInfo.district + dataInfo.address}}</view>
  20. </view>
  21. </view>
  22. <view class="sectionB">
  23. <view class="item" v-for="(item, idx) in categoryList" :key="idx">
  24. <view class="name">{{item.categoryName}}收益</view>
  25. <view class="value">{{item.value}}</view>
  26. </view>
  27. </view>
  28. <view class="sectionC">
  29. <view class="title">基本信息</view>
  30. <view class="line"></view>
  31. <view class="infos">
  32. <view class="item" v-for="(item, idx) in infos" :key="idx">
  33. <view class="name">{{item.title}}</view>
  34. <view class="value">{{item.value}}</view>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="sectionD" v-if="registAmount">
  39. <image class="icon" src="https://dm.static.elab-plus.com/yezhu/icon_hongbao.png" mode="aspectFit"></image>
  40. <view class="midSection">
  41. <view class="name">邀请好友注册</view>
  42. <view class="value">完成邀请,可获得¥{{registAmount}}/人</view>
  43. </view>
  44. <view class="invitationBtn" @click="toShareCard(1)">邀请好友</view>
  45. </view>
  46. <backHome></backHome>
  47. <login-notice></login-notice>
  48. <login></login>
  49. </view>
  50. </template>
  51. <script>
  52. import moment from '../../static/moment.min.js'
  53. import {
  54. displayDateFormatChi
  55. } from '../../static/format.js'
  56. let app = getApp();
  57. const config = require('@/static/config.js');
  58. import backHome from "@/components/backHome/backHome.vue";
  59. const wx = require('weixin-js-sdk');
  60. export default {
  61. data() {
  62. return {
  63. color1: '',
  64. color2: '',
  65. color3: '',
  66. color6: '',
  67. infos: [{
  68. title: '开盘时间',
  69. value: ''
  70. },
  71. {
  72. title: '项目业态',
  73. value: ''
  74. },
  75. {
  76. title: '均价',
  77. value: ''
  78. },
  79. {
  80. title: '总价',
  81. value: ''
  82. },
  83. {
  84. title: '主力户型',
  85. value: ''
  86. }
  87. // {
  88. // title: '目标人群',
  89. // value: ''
  90. // }
  91. ],
  92. projectId: '',
  93. dataInfo: {
  94. "address": "",
  95. "availableIncome": "",
  96. "bizFormat": "",
  97. "categoryList": [],
  98. "city": "",
  99. "cusGroup": "",
  100. "district": "",
  101. "id": 0,
  102. "image": "",
  103. "mainHouseType": "",
  104. "maxPrice": 0,
  105. "maxTotalPrice": 0,
  106. "minPrice": 0,
  107. "minTotalPrice": 0,
  108. "name": "",
  109. "onlineStatus": 0,
  110. "openTime": 0,
  111. "otherPage": "",
  112. "projectFocusImage": "",
  113. "projectId": "",
  114. "province": "",
  115. "registAmount": "",
  116. "revision": "",
  117. "shareImg": "",
  118. "shareRemark": "",
  119. "xcxPage": ""
  120. },
  121. categoryList: [],
  122. registAmount: null,
  123. shareToken:"",
  124. }
  125. },
  126. onLoad(param) {
  127. this.projectId = param.projectId;
  128. },
  129. onShow() {
  130. },
  131. components: {
  132. backHome
  133. },
  134. mounted() {
  135. this.color1 = app.globalData.color1;
  136. this.color2 = app.globalData.color2;
  137. this.color3 = app.globalData.color3;
  138. this.color6 = app.globalData.color6;
  139. this.detailDatahandle()
  140. uni.$on("request", () => {
  141. this.detailDatahandle()
  142. })
  143. },
  144. methods: {
  145. async getSingle(){
  146. let params = {
  147. "projectId": this.projectId,
  148. "userId": getApp().globalData.userId
  149. }
  150. let res = await this.$myRequest({
  151. url: '/share_token/generate',
  152. data: parmas
  153. });
  154. if(res.data.success){
  155. this.shareToken = res.data.single;
  156. }
  157. },
  158. async signJsapiTicket(){
  159. let url = location.href.split('#')[0]
  160. let parmas = {
  161. url: url,
  162. }
  163. let self = this;
  164. let res = await this.$myRequest({
  165. url: '/wechat/signJsapiTicket',
  166. data: parmas,
  167. method:"GET",
  168. });
  169. if(res.data.success){
  170. let single = res.data.single;
  171. wx.config({
  172. debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
  173. appId: config.appid, // 必填,公众号的唯一标识
  174. timestamp: single.timestamp, // 必填,生成签名的时间戳
  175. nonceStr: single.nonceStr, // 必填,生成签名的随机串
  176. signature: single.signature, // 必填,签名
  177. jsApiList: ["updateAppMessageShareData","updateTimelineShareData",'showMenuItems'] // 必填,需要使用的JS接口列表
  178. });
  179. wx.ready(function() {
  180. // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行。对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中。
  181. wx.updateAppMessageShareData({ //分享给朋友
  182. title: self.dataInfo.name, // 分享标题
  183. desc: self.dataInfo.shareRemark, // 分享描述
  184. link: location.origin+location.pathname + "?projectId="+self.projectId+"&shareToken="+self.shareToken, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  185. imgUrl: self.dataInfo.shareImg, // 分享图标
  186. success: function() {
  187. // 设置成功
  188. }
  189. });
  190. wx.updateTimelineShareData({ //分享到朋友圈
  191. title: self.dataInfo.name, // 分享标题
  192. link: location.origin+location.pathname + "?projectId="+self.projectId+"&shareToken="+self.shareToken, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
  193. imgUrl: self.dataInfo.shareImg, // 分享图标
  194. success: function() {
  195. // 设置成功
  196. }
  197. });
  198. wx.showMenuItems({
  199. menuList: [ "menuItem:share:appMessage","menuItem:share:timeline"] // 要显示的菜单项,所有menu项见附录3
  200. });
  201. });
  202. wx.error(function(res) {
  203. // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名。
  204. });
  205. }
  206. },
  207. async detailDatahandle() {
  208. if (getApp().globalData.userId) {
  209. var parmas = {
  210. projectId: this.projectId,
  211. userId: getApp().globalData.userId
  212. }
  213. this.getSingle();
  214. this.createUserProjectRlat();
  215. this.getRegistTask();
  216. let res = await this.$myRequest({
  217. url: '/project/queryProjectByH5',
  218. data: parmas
  219. })
  220. if (res && res.data.success) {
  221. console.log('详情res:', res)
  222. this.dataInfo = res.data.single
  223. this.reloadCategoryList()
  224. this.reloadInfos();
  225. this.signJsapiTicket();
  226. }
  227. }
  228. },
  229. async getRegistTask() {
  230. if (app.globalData.userId) {
  231. let res = await this.$myRequest({
  232. url: "/task/registTask",
  233. method: "GET",
  234. data: {
  235. userId: getApp().globalData.userId
  236. }
  237. })
  238. if (res.data.success) {
  239. this.registAmount = res.data.single.amount || null
  240. } else {
  241. this.registAmount = null;
  242. }
  243. }
  244. },
  245. async createUserProjectRlat() {
  246. if (getApp().globalData.userId) {
  247. var parmas = {
  248. projectId: this.projectId,
  249. shareToken: getApp().globalData.shareToken
  250. }
  251. let res = await this.$myRequest({
  252. url: '/user/createUserProjectRlat',
  253. data: parmas
  254. })
  255. if (res && res.data.success) {
  256. }
  257. }
  258. },
  259. reloadCategoryList() {
  260. var tempList = JSON.parse(JSON.stringify(this.dataInfo.categoryList || []))
  261. tempList.forEach((item, idx) => {
  262. item.value = '¥' + (parseFloat(item.amount || 0.00).toFixed(2)) + '/个'
  263. })
  264. this.categoryList = tempList
  265. this.categoryList.push({
  266. categoryName: '可获收益',
  267. value: this.dataInfo.availableIncome + '元'
  268. })
  269. },
  270. reloadInfos() {
  271. this.infos[0].value = this.timeFilterAction(this.dataInfo.openTime)
  272. this.infos[1].value = this.dataInfo.bizFormat
  273. if (this.dataInfo.maxPrice > 0) {
  274. this.infos[2].value = this.priceReload(this.dataInfo.minPrice) + '~' + this.priceReload(this.dataInfo
  275. .maxPrice) + '/m²'
  276. } else {
  277. this.infos[2].value = this.priceReload(this.dataInfo.minPrice) + '/m²'
  278. }
  279. if (this.dataInfo.maxTotalPrice > 0) {
  280. this.infos[3].value = this.priceReload(this.dataInfo.minTotalPrice) + '~' + this.priceReload(this
  281. .dataInfo.maxTotalPrice) + '/套'
  282. } else {
  283. this.infos[3].value = this.priceReload(this.dataInfo.minTotalPrice) + '/套'
  284. }
  285. this.infos[4].value = this.dataInfo.mainHouseType
  286. // this.infos[5].value = this.dataInfo.cusGroup
  287. this.infos.forEach((item, idx) => {
  288. if (!item.value) {
  289. item.value = '暂无'
  290. }
  291. })
  292. },
  293. timeFilterAction(val) {
  294. if (val) {
  295. return displayDateFormatChi(val * 1000)
  296. } else {
  297. return ''
  298. }
  299. },
  300. priceReload(val) {
  301. return parseFloat(val / 10000).toFixed(2) + '万'
  302. },
  303. toShareCard(type) {
  304. if (getApp().globalData.userId) {
  305. let href = location.origin + location.pathname;
  306. uni.navigateTo({
  307. url: '../shareCardPage/shareCardPage?page=' + href + "&projectId=" + this.projectId +
  308. "&type=" + type
  309. })
  310. } else {
  311. uni.$emit('unLogin')
  312. }
  313. },
  314. backAction() {
  315. uni.navigateBack({
  316. delta: 1
  317. })
  318. }
  319. },
  320. watch: {
  321. },
  322. onPullDownRefresh() {
  323. this.detailDatahandle();
  324. }
  325. }
  326. </script>
  327. <style lang="scss" scoped>
  328. page {
  329. width: 100vw;
  330. height: 100vh;
  331. background-color: #FFFFFF;
  332. }
  333. .content {
  334. width: 100%;
  335. height: 100%;
  336. overflow-y: scroll;
  337. position: relative;
  338. padding-bottom: 60rpx;
  339. box-sizing: border-box;
  340. .topImg {
  341. width: 100%;
  342. height: 480rpx;
  343. background-color: rgba($color: #000000, $alpha: 0.5);
  344. // 滤镜效果
  345. // -webkit-filter: grayscale(30%); /* Chrome, Safari, Opera */
  346. // filter: grayscale(30%);
  347. }
  348. .sectionA {
  349. padding: 0 30rpx;
  350. box-sizing: border-box;
  351. width: 100%;
  352. margin-top: 50rpx;
  353. .topSection {
  354. display: flex;
  355. justify-content: space-between;
  356. align-items: center;
  357. padding-left: 6rpx;
  358. box-sizing: border-box;
  359. .title {
  360. font-size: 44rpx;
  361. font-family: Verdana, Verdana-Bold;
  362. font-weight: 700;
  363. text-align: left;
  364. color: #262626;
  365. white-space: pre-wrap;
  366. max-width: 50%;
  367. }
  368. .tags {
  369. margin-left: 8rpx;
  370. display: flex;
  371. justify-content: flex-start;
  372. align-items: center;
  373. flex-wrap: wrap;
  374. flex-grow: 1;
  375. .item {
  376. padding: 0 18rpx;
  377. box-sizing: border-box;
  378. line-height: 40rpx;
  379. height: 40rpx;
  380. text-align: center;
  381. font-size: 20rpx;
  382. font-family: Verdana, Verdana-Regular;
  383. font-weight: 400;
  384. margin-left: 12rpx;
  385. }
  386. }
  387. .shareBtn {
  388. width: 140rpx;
  389. height: 52rpx;
  390. border-radius: 8px;
  391. box-shadow: 0px 2px 10px 0px rgba(0, 0, 0, 0.10);
  392. display: flex;
  393. align-items: center;
  394. font-size: 22rpx;
  395. font-family: Verdana, Verdana-Regular;
  396. font-weight: 400;
  397. text-align: left;
  398. color: #ffffff;
  399. .icon {
  400. width: 32rpx;
  401. height: 32rpx;
  402. margin-left: 10rpx;
  403. }
  404. }
  405. }
  406. .bottomSection {
  407. margin-top: 16rpx;
  408. display: flex;
  409. justify-content: flex-start;
  410. align-items: center;
  411. height: 80rpx;
  412. background: #f8f8f8;
  413. border-radius: 8rpx;
  414. .icon {
  415. width: 20rpx;
  416. height: 28rpx;
  417. margin-right: 14rpx;
  418. margin-left: 25rpx;
  419. }
  420. .name {
  421. font-size: 24rpx;
  422. font-family: Verdana, Verdana-Regular;
  423. font-weight: 400;
  424. text-align: left;
  425. color: #b1b1b1;
  426. }
  427. }
  428. }
  429. .sectionB {
  430. width: 100%;
  431. display: flex;
  432. align-items: center;
  433. padding: 40rpx 36rpx;
  434. box-sizing: border-box;
  435. flex-wrap: wrap;
  436. .item {
  437. width: calc((100% - 12rpx) / 3);
  438. min-width: calc((100% - 12rpx) / 3);
  439. max-width: calc((100% - 12rpx) / 3);
  440. .name {
  441. font-size: 24rpx;
  442. font-family: Verdana, Verdana-Regular;
  443. font-weight: 400;
  444. text-align: left;
  445. color: #b1b1b1;
  446. }
  447. .value {
  448. font-size: 32rpx;
  449. font-family: DIN Alternate, DIN Alternate-Bold;
  450. font-weight: 700;
  451. text-align: left;
  452. white-space: nowrap;
  453. color: #fd8f3c;
  454. }
  455. }
  456. }
  457. .sectionC {
  458. width: 100%;
  459. padding: 0 36rpx 76rpx 36rpx;
  460. box-sizing: border-box;
  461. display: flex;
  462. flex-wrap: wrap;
  463. .title {
  464. font-size: 28rpx;
  465. font-family: Verdana, Verdana-Bold;
  466. font-weight: 700;
  467. text-align: left;
  468. color: #171717;
  469. width: 100%;
  470. margin-bottom: 26rpx;
  471. }
  472. .line {
  473. width: 6rpx;
  474. height: 268rpx;
  475. background: linear-gradient(180deg, #ffd7b9, rgba(255, 215, 185, 0.00));
  476. border-radius: 4rpx;
  477. }
  478. .infos {
  479. margin-left: 30rpx;
  480. width: calc(100% - 36rpx);
  481. margin-top: -20rpx;
  482. display: flex;
  483. flex-wrap: wrap;
  484. align-items: center;
  485. justify-content: space-between;
  486. .item {
  487. width: 50%;
  488. .name {
  489. font-size: 24rpx;
  490. font-family: Verdana, Verdana-Regular;
  491. font-weight: 400;
  492. text-align: left;
  493. color: #b1b1b1;
  494. }
  495. .value {
  496. font-size: 24rpx;
  497. font-family: Verdana, Verdana-Regular;
  498. font-weight: 400;
  499. text-align: left;
  500. color: #262626;
  501. }
  502. }
  503. }
  504. }
  505. .sectionD {
  506. display: flex;
  507. justify-content: space-between;
  508. align-items: center;
  509. margin-left: 30rpx;
  510. width: calc(100% - 60rpx);
  511. height: 140rpx;
  512. background: linear-gradient(108deg, #ffb55f 9%, #f87523 96%);
  513. border-radius: 16rpx;
  514. padding: 0 20rpx 0 26rpx;
  515. box-sizing: border-box;
  516. .icon {
  517. width: 60rpx;
  518. height: 80rpx;
  519. margin-right: 20rpx;
  520. }
  521. .midSection {
  522. flex-grow: 1;
  523. .name {
  524. font-size: 30rpx;
  525. font-family: Verdana, Verdana-Bold;
  526. font-weight: 700;
  527. text-align: left;
  528. color: #ffffff;
  529. }
  530. .value {
  531. font-size: 24rpx;
  532. font-family: Verdana, Verdana-Regular;
  533. font-weight: 400;
  534. text-align: left;
  535. color: #ffead8;
  536. }
  537. }
  538. .invitationBtn {
  539. width: 140rpx;
  540. height: 56rpx;
  541. border-radius: 12rpx;
  542. background-color: #FFFFFF;
  543. font-size: 24rpx;
  544. font-family: Verdana, Verdana-Bold;
  545. font-weight: 700;
  546. text-align: center;
  547. color: #f07423;
  548. line-height: 56rpx;
  549. }
  550. }
  551. }
  552. </style>