detail.vue 16 KB

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