detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. <template>
  2. <view style="background-color: #fff;padding-bottom: 80px;padding-top: 10px;">
  3. <view class="main">
  4. <view class="changeby-box">
  5. <view class="changeby">
  6. <image class="headpic"
  7. :src="detail.headpic || 'https://yossys06593.obs.cn-east-3.myhuaweicloud.com:443/202406011717209838416B6150695f.webp'"
  8. mode="aspectFill" />
  9. <view class="name u-line-1">
  10. {{ detail.changeby || '--' }}
  11. </view>
  12. </view>
  13. <navigator class="iconfont icon-a-720quanjing-bai" v-if="detail.ispanorama"
  14. style="color: #C30D23;font-size: 24px;" :url="'/packageA/webView/webView?url=' + detail.panoramaurl" />
  15. </view>
  16. <view class="title" v-if="detail.title_c || detail.title">
  17. {{ detail.title_c || detail.title }}
  18. </view>
  19. <block v-for="item in files" :key="item.attachmentid">
  20. <image class="image" v-if="item.fileType == 'image'" :src="item.cover" mode="widthFix" lazy-load="true"
  21. @click="previewImg(item)" />
  22. <video v-else-if="item.fileType == 'video'" class="video" :poster="item.subfiles[0].url" :src="item.url" />
  23. </block>
  24. </view>
  25. <view class="comment-box">
  26. <view class="head">
  27. <view class="label">
  28. 评论
  29. </view>
  30. <view class="total">
  31. 共{{ detail.commentcount || 0 }}条
  32. </view>
  33. </view>
  34. <view class="comment" v-for="item in comments" :key="item.sys_datacommentid">
  35. <view class="user">
  36. <image class="headpic"
  37. :src="item.headpic || 'https://yossys06593.obs.cn-east-3.myhuaweicloud.com:443/202406011717209838416B6150695f.webp'"
  38. mode="aspectFill" />
  39. <view class="name">
  40. {{ item.name }}
  41. </view>
  42. </view>
  43. <view class="content">
  44. {{ item.content }}
  45. </view>
  46. <view class="time">
  47. <text class="createdate">{{ item.createdate }}</text>
  48. <view v-if="userid == item.userid" class="iconfont icon-shanchu" hover-class="navigator-hover"
  49. @click="delectComment(item)" />
  50. </view>
  51. </view>
  52. <view v-if="!comments.length" style="padding:50px 0 100px 0;">
  53. <u-empty mode="data" text="暂无评论" />
  54. </view>
  55. <view v-else style="padding-bottom: 10px;">
  56. <u-divider text="已经到底部" :dashed="true" />
  57. </view>
  58. </view>
  59. <view class="footer">
  60. <view class="but" @click="loadings.like ? '' : handleCollect(2, detail.islike)">
  61. <u-loading-icon v-if="loadings.like" />
  62. <block v-else>
  63. <view v-if="detail.islike" style="color: #E3041F;" class="iconfont icon-yidianzan" />
  64. <view v-else style="color: #646566;" class="iconfont icon-weidianzan" />
  65. <view class="text">
  66. 点赞
  67. </view>
  68. </block>
  69. </view>
  70. <view class="but" @click="loadings.collect ? '' : handleCollect(1, detail.iscollect)">
  71. <u-loading-icon v-if="loadings.collect" />
  72. <block v-else>
  73. <view v-if="detail.iscollect" style="color: #FFC300;" class="iconfont icon-yishoucang" />
  74. <view v-else style="color: #646566;" class="iconfont icon-weishoucang" />
  75. <view class="text">
  76. 收藏
  77. </view>
  78. </block>
  79. </view>
  80. <view class="input-box" hover-class="navigator-hover">
  81. <input class="input" type="text" placeholder="评论" :value="commentText" maxlength="499"
  82. @input="changeComment" confirm-type="send" @confirm="onSend">
  83. <icon v-if="commentText" class="icon" type="clear" size="3.733vw" @click="onClear" />
  84. </view>
  85. </view>
  86. </view>
  87. </template>
  88. <script>
  89. import { viewImage, formattedFiles } from "../../utils/settleFiles"
  90. export default {
  91. data() {
  92. return {
  93. sat_sharematerialid: 0,
  94. detail: {},
  95. files: [],
  96. comments: [],
  97. "content": {
  98. "ownertable": "sat_sharematerial"
  99. },
  100. commentText: "",
  101. userid: uni.getStorageSync('userMsg').userid,
  102. loadings: {
  103. collect: false,
  104. like: false
  105. },
  106. loadingGetList: false
  107. }
  108. },
  109. onLoad(options) {
  110. this.sat_sharematerialid = options.id;
  111. this.getDetail(true);
  112. },
  113. onUnload() {
  114. this.$Http.setCount && delete this.$Http.setCount
  115. },
  116. onReachBottom() {
  117. if (!this.loadingGetList) this.getList();
  118. },
  119. methods: {
  120. previewImg(item) {
  121. viewImage(item.url)
  122. },
  123. getDetail(init = false) {
  124. this.getList(init)
  125. if (!init) return;
  126. this.$Http.basic({
  127. "id": 20240417104702,
  128. "content": {
  129. "sat_sharematerialid": this.sat_sharematerialid
  130. },
  131. }).then(res => {
  132. console.log("设计实景详情", res)
  133. if (this.cutoff(res.msg)) return;
  134. this.files = formattedFiles(res.data.attinfos_pic.map(v => v.attinfos[0])).map(v => {
  135. if (v.fileType == 'image') v.cover = this.getSpecifiedImage(v, 'compressed')
  136. return v
  137. })
  138. this.detail = res.data;
  139. this.setCount()
  140. uni.setNavigationBarTitle({
  141. title: res.data.title_c || res.data.title || '详情'
  142. });
  143. })
  144. },
  145. getList(init = false) {
  146. this.loadingGetList = true;
  147. if (this.paging(this.content, init)) return this.loadingGetList = false;
  148. this.content.ownerid = this.sat_sharematerialid;
  149. this.$Http.basic({
  150. "id": 20240417161702,
  151. content: this.content
  152. }).then(res => {
  153. this.loadingGetList = false;
  154. console.log("获取评论列表", res)
  155. if (this.cutoff(res.msg)) return;
  156. this.comments = res.pageNumber == 1 ? res.data : this.list.concat(res.data);
  157. this.content.pageNumber = res.pageNumber - 0 + 1;
  158. this.content.pageTotal = res.pageTotal;
  159. this.content.pageSize = res.pageSize;
  160. })
  161. },
  162. changeComment(e) {
  163. this.commentText = e.detail.value;
  164. },
  165. onClear() {
  166. let that = this;
  167. uni.showModal({
  168. title: '提示',
  169. content: '是否确定清空评论?',
  170. success: ({ confirm }) => {
  171. if (confirm) that.commentText = ""
  172. },
  173. })
  174. },
  175. onSend() {
  176. if (this.commentText == '') return uni.showToast({
  177. title: '还未输入评论内容!',
  178. duration: 2000,
  179. icon: "none"
  180. });
  181. this.$Http.basic({
  182. "id": 20240417161502,
  183. "content": {
  184. "ownertable": "sat_sharematerial",
  185. "ownerid": this.sat_sharematerialid,
  186. "contentstr": this.commentText
  187. },
  188. }).then(res => {
  189. console.log("发送评论", res)
  190. if (this.cutoff(res.msg, '评论成功')) return;
  191. this.commentText = '';
  192. this.getDetail(true)
  193. })
  194. },
  195. delectComment(item) {
  196. let that = this;
  197. uni.showModal({
  198. title: '提示',
  199. content: "是否确定删除该评论?",
  200. success: ({ confirm }) => {
  201. if (confirm) that.$Http.basic({
  202. "id": 20240417161602,
  203. "content": {
  204. "sys_datacommentid": item.sys_datacommentid,
  205. "ownertable": "sat_sharematerial",
  206. "ownerid": item.ownerid
  207. },
  208. }).then(res => {
  209. console.log("删除评论", res)
  210. if (this.cutoff(res.msg, '删除成功')) return;
  211. that.detail.commentcount -= 1;
  212. that.comments = that.comments.filter(v => v.sys_datacommentid != item.sys_datacommentid);
  213. this.setCount()
  214. })
  215. },
  216. })
  217. },
  218. setCount() {
  219. this.$Http.setCount && this.$Http.setCount(this.detail)
  220. },
  221. handleCollect(type, value) {
  222. if (type == 1) {
  223. this.loadings.collect = true;
  224. } else {
  225. this.loadings.like = true;
  226. }
  227. this.$Http.basic({
  228. "id": 20240416133702,
  229. "content": {
  230. "ownertable": "sat_sharematerial",
  231. "ownerid": this.detail.sat_sharematerialid,
  232. type
  233. },
  234. }).then(res => {
  235. console.log(value ? '取消' : '添加', type == 1 ? "收藏" : "喜欢", res)
  236. if (type == 1) {
  237. this.loadings.collect = false;
  238. } else {
  239. this.loadings.like = false;
  240. }
  241. if (this.cutoff(res.msg)) return;
  242. if (type == 1) {
  243. this.detail.iscollect = value ? 0 : 1
  244. this.detail.collectcount = value ? this.detail.collectcount - 1 : this.detail.collectcount - 0 + 1
  245. } else {
  246. this.detail.islike = value ? 0 : 1
  247. this.detail.likecount = value ? this.detail.likecount - 1 : this.detail.likecount - 0 + 1
  248. }
  249. this.setCount();
  250. })
  251. },
  252. },
  253. }
  254. </script>
  255. <style lang="scss" scoped>
  256. .main {
  257. width: 355px;
  258. margin: 0 auto;
  259. .changeby-box {
  260. display: flex;
  261. align-items: center;
  262. justify-content: space-between;
  263. .changeby {
  264. display: flex;
  265. align-items: center;
  266. .headpic {
  267. width: 24px;
  268. height: 24px;
  269. border-radius: 50%;
  270. margin-right: 5px;
  271. }
  272. .name {
  273. font-family: Source Han Sans SC, Source Han Sans SC;
  274. font-size: 12px;
  275. color: #333333;
  276. width: 200px;
  277. }
  278. }
  279. }
  280. .title {
  281. font-family: Source Han Sans SC, Source Han Sans SC;
  282. font-size: 12px;
  283. color: #333333;
  284. line-height: 20px;
  285. margin-top: 10px;
  286. }
  287. .image {
  288. width: 100%;
  289. border-radius: 5px;
  290. margin-top: 10px;
  291. }
  292. .video {
  293. width: 355px;
  294. height: 240px;
  295. border-radius: 5px;
  296. margin-top: 10px;
  297. }
  298. }
  299. .comment-box {
  300. background: #fff;
  301. margin-top: 10px;
  302. .head {
  303. display: flex;
  304. justify-content: space-between;
  305. align-items: center;
  306. width: 100vw;
  307. height: 45px;
  308. .label {
  309. font-family: PingFang SC, PingFang SC;
  310. font-weight: bold;
  311. font-size: 16px;
  312. color: #333333;
  313. margin-left: 10px;
  314. }
  315. .total {
  316. font-family: PingFang SC, PingFang SC;
  317. font-size: 14px;
  318. color: #333333;
  319. margin-right: 10px;
  320. }
  321. }
  322. .comment {
  323. padding: 10px;
  324. .user {
  325. display: flex;
  326. align-items: center;
  327. height: 32px;
  328. .headpic {
  329. width: 32px;
  330. height: 32px;
  331. border-radius: 50%;
  332. }
  333. .name {
  334. margin-left: 10px;
  335. font-family: Source Han Sans SC,
  336. Source Han Sans SC;
  337. font-weight: 500;
  338. font-size: 14px;
  339. color: #666666;
  340. }
  341. }
  342. .content {
  343. width: 313px;
  344. margin-top: 4px;
  345. margin-left: 42px;
  346. line-height: 20px;
  347. font-family: Source Han Sans SC, Source Han Sans SC;
  348. font-size: 14px;
  349. color: #333333;
  350. }
  351. .time {
  352. display: flex;
  353. justify-content: space-between;
  354. width: 313px;
  355. margin-top: 10px;
  356. margin-left: 42px;
  357. .iconfont,
  358. .createdate {
  359. font-family: Source Han Sans SC, Source Han Sans SC;
  360. font-size: 12px;
  361. color: #999999;
  362. line-height: 17px;
  363. }
  364. .iconfont {
  365. padding: 0 5px;
  366. border-radius: 4px;
  367. }
  368. }
  369. }
  370. }
  371. .footer {
  372. display: flex;
  373. position: fixed;
  374. bottom: 0;
  375. left: 0;
  376. width: 375px;
  377. height: 70px;
  378. background: #FFFFFF;
  379. box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
  380. .but {
  381. width: 50px;
  382. text-align: center;
  383. padding-top: 13px;
  384. .iconfont {
  385. font-size: 16px;
  386. margin-bottom: 4px;
  387. }
  388. .text {
  389. font-family: PingFang SC, PingFang SC;
  390. font-size: 10px;
  391. color: #333333;
  392. height: 100%;
  393. box-sizing: border-box;
  394. }
  395. }
  396. .input-box {
  397. display: flex;
  398. align-items: center;
  399. width: 245px;
  400. height: 45px;
  401. background: #F7F7F7;
  402. border-radius: 50px;
  403. border: 1px solid #CCCCCC;
  404. margin-left: 20px;
  405. margin-top: 6px;
  406. padding: 0 10px 0 20px;
  407. box-sizing: border-box;
  408. .input {
  409. flex: 1;
  410. height: 45px;
  411. line-height: 45px;
  412. }
  413. .icon {
  414. margin-left: 5px;
  415. }
  416. }
  417. }
  418. </style>