detail.vue 17 KB

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