detail.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680
  1. <template>
  2. <view>
  3. <Loading
  4. :type="3"
  5. :loadStatus="loadStatus"
  6. :showText="errorText"
  7. />
  8. <zj-page-layout
  9. v-if="detail"
  10. :hasFooter="true"
  11. :isScroll="true"
  12. :refresherTriggered="refresherTriggered"
  13. @refresherrefresh="refresherrefresh">
  14. <view class="top-container">
  15. <view class="user">
  16. <image :src="detail.userPic ? (imageUrl + detail.userPic) : require('@/static/common/logo.png')"></image>
  17. <view class="info">
  18. <view class="name">{{detail.userName}}</view>
  19. <view class="phone">{{detail.phone}}</view>
  20. </view>
  21. </view>
  22. <view class="btns">
  23. <u-button type="warning" text="分享好友" class="share" open-type="share"></u-button>
  24. <u-button type="error" text="立即联系" class="contact" @click="toContact" v-if="!isMine"></u-button>
  25. <u-button type="primary" text="立即购买" class="buy" @click="toBuy" v-if="!isMine && detail.amount && detail.status === 1"></u-button>
  26. </view>
  27. </view>
  28. <view class="info-container">
  29. <view class="soldout" v-if="detail.status === 4">
  30. <image src="@/static/common/soldout.png" mode="widthFix"></image>
  31. </view>
  32. <view class="title">
  33. <view class="tit">{{detail.title}}</view>
  34. <view class="price">{{detail.amount | priceFilter2}}</view>
  35. </view>
  36. <view class="des">{{detail.content}}</view>
  37. <view class="tags">
  38. <view class="it" v-if="detail.brand">{{detail.brand}}</view>
  39. <view class="it" v-if="detail.power">{{detail.power}}</view>
  40. <view class="it" v-if="detail.energy">{{detail.energy}}</view>
  41. </view>
  42. <view class="info">
  43. <text>{{detail.createTime | timeFilter}}发布</text>
  44. </view>
  45. <view class="bottom">
  46. <view class="left-location"><text class="iconfont icon-dingwei"></text>{{detail.city}} {{detail.area}}</view>
  47. <view class="right-stats">
  48. <view class="it">
  49. <text class="iconfont icon-liulan"></text>
  50. <text class="text">{{detail.visit || 0}}</text>
  51. </view>
  52. <view class="it" :class="detail.isLike ? 'active':''" @tap="handelLickCollect(1)">
  53. <text class="iconfont icon-dianzan"></text>
  54. <text class="text">{{detail.up || 0}}</text>
  55. </view>
  56. <view class="it" :class="detail.isCollect ? 'active':''" @tap="handelLickCollect(2)">
  57. <text class="iconfont icon-shoucang"></text>
  58. <text class="text">{{detail.collectNum || 0}}</text>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <view class="imgs-container">
  64. <image :src="imageUrl + item.imgUrl" v-for="(item, index) in detail.goodsFiles" :key="index" mode="widthFix"></image>
  65. </view>
  66. <view class="remark-container">
  67. <view class="title">
  68. <view class="tit">全部留言</view>
  69. <view class="right" v-if="!isMine" @tap="isShowReportDialog = true;">内容违规,我要举报</view>
  70. </view>
  71. <view class="list">
  72. <view class="item" v-for="(item, index) in remarkList" :key="index">
  73. <view class="top">
  74. <image :src="item.userPic ? (imageUrl + item.userPic) : require('@/static/common/logo.png')"></image>
  75. <view class="user">
  76. <view class="name">{{item.userName}}</view>
  77. <view class="time">{{item.createTime}}</view>
  78. </view>
  79. </view>
  80. <view class="content">
  81. <view class="left">{{item.message}}</view>
  82. <view class="right" @tap="handelReply(item)"><text class="iconfont icon-bianji"></text><text>回复</text></view>
  83. </view>
  84. <view class="reply" v-if="item.goodsMessageList && item.goodsMessageList.length > 0">
  85. <view class="it" v-for="(it, idx) in item.goodsMessageList" :key="idx" @tap="handelReply(it)">
  86. <text class="name">{{it.userName}}</text>
  87. <text class="text">回复</text>
  88. <text class="name">{{it.replyNickName}}</text>:{{it.message}}
  89. </view>
  90. </view>
  91. </view>
  92. </view>
  93. <Loading :type="2" :loadStatus="remarkLoadStatus" :dataList="remarkList" />
  94. </view>
  95. <template slot="footer">
  96. <view class="bottom-container">
  97. <u-button text="留言" type="primary" shape="circle" @click="openRemark()"></u-button>
  98. <u-button text="操作" type="primary" shape="circle" @click="isShowActionDialog = true" v-if="isMine && detail.status !== 4"></u-button>
  99. </view>
  100. </template>
  101. </zj-page-layout>
  102. <zj-dialog-remark
  103. ref="remarkDialog"
  104. :isShow="isShowRemarkDialog"
  105. @close="isShowRemarkDialog = false"
  106. @confirm="confirmRemark">
  107. </zj-dialog-remark>
  108. <u-action-sheet
  109. :actions="actionList"
  110. :title="'操作'"
  111. :show="isShowActionDialog"
  112. @close="isShowActionDialog = false"
  113. @select="selectAction">
  114. </u-action-sheet>
  115. <zj-dialog-box
  116. :title="'违规举报'"
  117. :minHeight="'50vh'"
  118. :isShow="isShowReportDialog"
  119. @cancel="cancelReportDialog"
  120. @confirm="confirmReportDialog">
  121. <view class="report-container">
  122. <view class="title"><text>*</text>举报原因</view>
  123. <u--textarea
  124. fixed
  125. v-model="reportForm.reason"
  126. placeholder="请输入"
  127. height="100">
  128. </u--textarea>
  129. <view class="title">上传凭证</view>
  130. <zj-upload key="cp" @getFiles="getFiles" :fileList="reportForm.fileList" :count="9" />
  131. </view>
  132. </zj-dialog-box>
  133. </view>
  134. </template>
  135. <script>
  136. import zjDialogBox from "@/components/zj-dialog/zj-dialog-box.vue";
  137. import zjDialogRemark from '@/components/zj-dialog/zj-dialog-remark.vue';
  138. import zjUpload from '@/components/zj-upload/index.vue'
  139. export default {
  140. components: {
  141. zjDialogBox,
  142. zjDialogRemark,
  143. zjUpload
  144. },
  145. data() {
  146. return {
  147. id: null,
  148. detail: null,
  149. remarkList: [],
  150. imageUrl: this.$imageUrl,
  151. loadStatus: 0,
  152. errorText: '',
  153. refresherTriggered: false,
  154. isShowRemarkDialog: false,
  155. actionList: [],
  156. isShowActionDialog: false,
  157. replyId: '',
  158. remarkLoadStatus: 0,
  159. isShowReportDialog: false,
  160. reportForm: {
  161. reason: '',
  162. fileList: [],
  163. }
  164. }
  165. },
  166. computed: {
  167. isMine() {
  168. if(this.detail) {
  169. return this.$store.state.user.userId === this.detail.userId;
  170. }
  171. else {
  172. return false;
  173. }
  174. }
  175. },
  176. onShareAppMessage(options) {
  177. if (options && options.from == 'button') {
  178. // 来自页面内的转发按钮
  179. } else {
  180. // 点击微信右上角的分享按钮
  181. }
  182. return {
  183. title: '分享商品「' + this.detail.title + '」',
  184. imageUrl: this.imageUrl + this.detail.goodsFiles[0].imgUrl,
  185. path: '/pages/goods/detail?id=' + this.id,
  186. query: {
  187. // id: this.goodsId,
  188. },
  189. success: function(res) {
  190. if(res.errMsg == 'shareAppMessage:ok'){
  191. this.$successToast('分享完成');
  192. }
  193. }
  194. }
  195. },
  196. onLoad({id}) {
  197. this.id = id;
  198. this.getDetail();
  199. this.getRemarkList();
  200. },
  201. methods: {
  202. getDetail() {
  203. this.$api.postJson('/goods/detail', {
  204. id: this.id
  205. }).then(res => {
  206. this.detail = res.data;
  207. this.loadStatus = 0;
  208. let actionList = [
  209. // {name: '已转让', value: 1},
  210. {name: '上架', value: 2},
  211. {name: '下架', value: 3},
  212. {name: '重新上架', value: 4},
  213. {name: '编辑', value: 5},
  214. ]
  215. if(this.detail.status === 1) {
  216. actionList.splice(0, 1);
  217. }else if(this.detail.status === 0) {
  218. actionList.splice(1, 1);
  219. }
  220. this.actionList = actionList;
  221. }).catch(res => {
  222. this.errorText = res.message;
  223. this.loadStatus = 2;
  224. }).finally(res => {
  225. this.refresherTriggered = false;
  226. })
  227. },
  228. refresherrefresh() {
  229. this.refresherTriggered = true;
  230. this.getDetail();
  231. this.getRemarkList();
  232. },
  233. // 处理点赞留言
  234. handelLickCollect(type) {
  235. let status = false;
  236. if(type === 1) {
  237. status = this.detail.isLike || false;
  238. }else {
  239. status = this.detail.isCollect || false;
  240. }
  241. this.$api.postJson('/likeOrCollect/likeOrCollect', {
  242. userId: this.$store.state.user.userId,
  243. goodsId: this.id,
  244. type,
  245. operate: status ? 'NO' : 'YES'
  246. }).then(res => {
  247. this.detail.up = res.data.up;
  248. this.detail.collectNum = res.data.collectNum;
  249. this.detail.isLike = res.data.isLike;
  250. this.detail.isCollect = res.data.isCollect;
  251. this.crossPage.$emit('reloadHomePage');
  252. this.crossPage.$emit('reloadGoodsListPage');
  253. this.crossPage.$emit('reloadMyIssueListPage');
  254. })
  255. },
  256. // 去联系
  257. toContact() {
  258. this.$navToPage({
  259. url: `/pages/message/msgView?goodsId=${this.id}`
  260. })
  261. },
  262. // 去购买
  263. toBuy() {
  264. this.$navToPage({
  265. url: `/pages/goods/order?goodsId=${this.id}`
  266. })
  267. },
  268. // 获取留言列表
  269. getRemarkList() {
  270. this.$api.postJson('/message/list2', {
  271. userId: this.$store.state.user.userId,
  272. goodsId: this.id,
  273. pageNum: 1,
  274. pageSize: -1,
  275. }).then(res => {
  276. this.remarkList = res.data.records;
  277. this.remarkLoadStatus = 0;
  278. }).catch(res => {
  279. this.remarkLoadStatus = 2;
  280. })
  281. },
  282. openRemark(replyItem) {
  283. this.$refs.remarkDialog.setValue(replyItem);
  284. this.isShowRemarkDialog = true;
  285. },
  286. // 提交留言
  287. confirmRemark(val) {
  288. this.$api.postJson('/message/add', {
  289. userId: this.$store.state.user.userId,
  290. goodsId: this.id,
  291. message: val,
  292. replyId: this.replyId,
  293. }).then(res => {
  294. this.replyId = '';
  295. this.isShowRemarkDialog = false;
  296. this.getRemarkList();
  297. })
  298. },
  299. // 回复留言
  300. handelReply(item) {
  301. this.replyId = item.id;
  302. this.openRemark(item);
  303. },
  304. getFiles(value) {
  305. this.reportForm.fileList = value[0]
  306. },
  307. cancelReportDialog() {
  308. this.reportForm.reason = '';
  309. this.reportForm.fileList = [];
  310. this.isShowReportDialog = false;
  311. },
  312. confirmReportDialog() {
  313. if(!this.reportForm.reason) return this.$toast('请输入举报原因');
  314. this.$api.postJson('/reportGoods/report', {
  315. goodsId: this.id,
  316. reportNote: this.reportForm.reason,
  317. url: this.reportForm.fileList,
  318. }).then(res => {
  319. this.$successToast();
  320. this.cancelReportDialog();
  321. this.isShowRemarkDialog = false;
  322. })
  323. },
  324. selectAction(e) {
  325. // 已转让/下架
  326. if(~[1,2,3].indexOf(e.value)) {
  327. const statusMap = {
  328. 1: 2, // 已转让
  329. 2: 1, // 上架
  330. 3: 0, // 下架
  331. }
  332. this.$modal({
  333. content: `确定要${e.name}吗?`
  334. }).then(() => {
  335. this.$api.post('/goods/upOrDel', {
  336. id: this.id,
  337. status: statusMap[e.value],
  338. }).then(res => {
  339. this.$successToast();
  340. this.getDetail();
  341. this.crossPage.$emit('reloadHomePage');
  342. this.crossPage.$emit('reloadGoodsListPage');
  343. this.crossPage.$emit('reloadMyIssueListPage');
  344. })
  345. }).catch(() => {})
  346. }
  347. // 重新上架
  348. else if(e.value === 4) {
  349. uni.setStorageSync('issuePageParam', {
  350. goodsId: this.id,
  351. type: 1,
  352. isLoad:true
  353. });
  354. this.$navToPage({
  355. url: `/pages/issue/index`
  356. }, 'switchTab')
  357. }
  358. // 编辑
  359. else if(e.value === 5) {
  360. uni.setStorageSync('issuePageParam', {
  361. goodsId: this.id,
  362. type: 2
  363. });
  364. this.$navToPage({
  365. url: `/pages/issue/index`
  366. }, 'switchTab')
  367. }
  368. }
  369. }
  370. }
  371. </script>
  372. <style lang="scss" scoped>
  373. .top-container {
  374. background: #ffffff;
  375. margin-top: 30rpx;
  376. padding: 30rpx;
  377. .user {
  378. display: flex;
  379. align-items: center;
  380. image {
  381. width: 88rpx;
  382. height: 88rpx;
  383. border-radius: 50%;
  384. }
  385. .info {
  386. margin-left: 20rpx;
  387. .name {
  388. font-size: 28rpx;
  389. }
  390. .phone {
  391. font-size: 24rpx;
  392. margin-top: 12rpx;
  393. }
  394. }
  395. }
  396. .btns {
  397. display: flex;
  398. margin-top: 30rpx;
  399. ::v-deep .u-button {
  400. width: calc((100% - 60rpx) / 3);
  401. height: 68rpx;
  402. line-height: 68rpx;
  403. font-size: 28rpx;
  404. color: #ffffff;
  405. margin: 0;
  406. margin-right: 30rpx;
  407. &:last-child {
  408. margin-right: 0;
  409. }
  410. }
  411. }
  412. }
  413. .info-container {
  414. background: #ffffff;
  415. padding: 30rpx;
  416. margin-top: 30rpx;
  417. position: relative;
  418. .soldout {
  419. position: absolute;
  420. right: 150rpx;
  421. top: 20rpx;
  422. image {
  423. width: 120rpx;
  424. }
  425. }
  426. .title {
  427. display: flex;
  428. justify-content: space-between;
  429. .tit {
  430. font-size: 32rpx;
  431. }
  432. .price {
  433. font-size: 32rpx;
  434. color: $assist-color;
  435. font-weight: 500;
  436. }
  437. }
  438. .des {
  439. margin-top: 12rpx;
  440. font-size: 28rpx;
  441. color: $reg-font;
  442. }
  443. .tags {
  444. margin-top: 12rpx;
  445. display: flex;
  446. .it {
  447. background: #f1f1f1;
  448. font-size: 20rpx;
  449. margin-right: 20rpx;
  450. padding: 8rpx 12rpx;
  451. border-radius: 8rpx;
  452. }
  453. }
  454. .info {
  455. display: flex;
  456. margin-top: 20rpx;
  457. text {
  458. font-size: 24rpx;
  459. color: $sec-font;
  460. }
  461. }
  462. .bottom {
  463. border-top: 1px solid #eaeaea;
  464. margin-top: 20rpx;
  465. padding-top: 20rpx;
  466. display: flex;
  467. align-items: center;
  468. justify-content: space-between;
  469. .left-location {
  470. font-size: 28rpx;
  471. color: $sec-font;
  472. display: flex;
  473. align-items: center;
  474. .iconfont {
  475. margin-right: 4rpx;
  476. }
  477. }
  478. .right-stats {
  479. flex-shrink: 0;
  480. display: flex;
  481. align-items: center;
  482. .it {
  483. flex-shrink: 0;
  484. display: flex;
  485. align-items: center;
  486. margin-left: 30rpx;
  487. .iconfont {
  488. font-size: 32rpx;
  489. color: $sec-font;
  490. }
  491. .text {
  492. font-size: 28rpx;
  493. margin-left: 6rpx;
  494. color: $sec-font;
  495. }
  496. &.active {
  497. .iconfont {
  498. color: $theme-color;
  499. }
  500. .text {
  501. color: $theme-color;
  502. }
  503. }
  504. }
  505. }
  506. }
  507. }
  508. .imgs-container {
  509. margin-top: 30rpx;
  510. image {
  511. width: 100%;
  512. display: block;
  513. }
  514. }
  515. .remark-container {
  516. background: #ffffff;
  517. margin-top: 30rpx;
  518. padding: 30rpx;
  519. .title {
  520. display: flex;
  521. align-items: center;
  522. justify-content: space-between;
  523. .tit {
  524. font-weight: 500;
  525. }
  526. .right {
  527. font-size: 24rpx;
  528. color: $sec-font;
  529. border-radius: 40rpx;
  530. border: 1px solid #eaeaea;
  531. padding: 0 16rpx;
  532. height: 40rpx;
  533. line-height: 40rpx;
  534. }
  535. }
  536. .item {
  537. padding: 30rpx 0;
  538. border-bottom: 1px solid #eaeaea;
  539. &:last-of-type {
  540. border: none;
  541. }
  542. .top {
  543. display: flex;
  544. image {
  545. width: 88rpx;
  546. height: 88rpx;
  547. border-radius: 50%;
  548. flex-shrink: 0;
  549. }
  550. .user {
  551. margin-left: 20rpx;
  552. flex: 1;
  553. display: flex;
  554. flex-direction: column;
  555. justify-content: center;
  556. .name {
  557. }
  558. .time {
  559. color: $sec-font;
  560. font-size: 24rpx;
  561. margin-top: 8rpx;
  562. }
  563. }
  564. .status {
  565. color: $assist-color;
  566. }
  567. }
  568. .content {
  569. margin-top: 20rpx;
  570. display: flex;
  571. justify-content: space-between;
  572. align-items: center;
  573. .left {
  574. font-size: 28rpx;
  575. word-break: break-all;
  576. line-height: 40rpx;
  577. }
  578. .right {
  579. flex-shrink: 0;
  580. font-size: 24rpx;
  581. background: #eaeaea;
  582. display: flex;
  583. align-items: center;
  584. padding: 8rpx 12rpx;
  585. margin-left: 30rpx;
  586. border-radius: 8rpx;
  587. .iconfont {
  588. font-size: 28rpx;
  589. margin-right: 8rpx;
  590. }
  591. }
  592. }
  593. .reply {
  594. background: #f5f5f5;
  595. border-radius: 8rpx;
  596. padding: 16rpx 20rpx;
  597. margin-top: 20rpx;
  598. .it {
  599. margin-top: 16rpx;
  600. font-size: 28rpx;
  601. line-height: 40rpx;
  602. word-break: break-all;
  603. &:hover {
  604. background: #eaeaea;
  605. }
  606. &:first-child {
  607. margin-top: 0;
  608. }
  609. .name {
  610. color: $theme-color;
  611. }
  612. .text {
  613. color: $sec-font;
  614. }
  615. }
  616. }
  617. }
  618. }
  619. .report-container {
  620. padding: 0 30rpx 60rpx;
  621. .title {
  622. margin-top: 30rpx;
  623. margin-bottom: 20rpx;
  624. text {
  625. color: $assist-color;
  626. }
  627. }
  628. }
  629. .bottom-container {
  630. padding: 20rpx 30rpx;
  631. display: flex;
  632. align-items: center;
  633. justify-content: flex-end;
  634. ::v-deep .u-button {
  635. width: auto;
  636. height: 60rpx;
  637. margin: 0;
  638. margin-left: 20rpx;
  639. padding: 0 30rpx;
  640. }
  641. }
  642. </style>