123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649 |
- <template>
- <view>
- <Loading
- :type="3"
- :loadStatus="loadStatus"
- :showText="errorText"
- />
- <zj-page-layout
- v-if="detail"
- :hasFooter="true"
- :isScroll="true"
- :refresherTriggered="refresherTriggered"
- @refresherrefresh="refresherrefresh">
- <view class="top-container">
- <view class="user">
- <image :src="detail.userPic ? (imageUrl + detail.userPic) : require('@/static/common/logo.png')"></image>
- <view class="info">
- <view class="name">{{detail.userName}}</view>
- <view class="phone">联系电话:{{detail.phone}}</view>
- </view>
- </view>
- <view class="btns">
- <u-button type="warning" text="分享好友" class="share" open-type="share"></u-button>
- <u-button type="error" text="立即联系" class="contact" @click="toContact" v-if="!isMine"></u-button>
- <u-button type="primary" text="立即购买" class="buy" @click="toBuy" v-if="!isMine && detail.amount" :disabled="detail.status === 4"></u-button>
- </view>
- </view>
- <view class="info-container">
- <view class="soldout" v-if="detail.status === 4">
- <image src="@/static/common/soldout.png" mode="widthFix"></image>
- </view>
- <view class="title">
- <view class="tit">{{detail.title}}</view>
- <view class="price">{{detail.amount | priceFilter2}}</view>
- </view>
- <view class="des">{{detail.content}}</view>
- <view class="tags">
- <view class="it" v-if="detail.brand">{{detail.brand}}</view>
- <view class="it" v-if="detail.power">{{detail.power}}</view>
- <view class="it" v-if="detail.energy">{{detail.energy}}</view>
- </view>
- <view class="info">
- <text>{{detail.createTime | timeFilter}}发布</text>
- </view>
- <view class="bottom">
- <view class="left-location"><text class="iconfont icon-dingwei"></text>{{detail.city}} {{detail.area}}</view>
- <view class="right-stats">
- <view class="it">
- <text class="iconfont icon-liulan"></text>
- <text class="text">{{detail.visit || 0}}</text>
- </view>
- <view class="it" :class="detail.isLike ? 'active':''" @tap="handelLickCollect(1)">
- <text class="iconfont icon-dianzan"></text>
- <text class="text">{{detail.up || 0}}</text>
- </view>
- <view class="it" :class="detail.isCollect ? 'active':''" @tap="handelLickCollect(2)">
- <text class="iconfont icon-shoucang"></text>
- <text class="text">{{detail.collectNum || 0}}</text>
- </view>
- </view>
- </view>
- </view>
- <view class="imgs-container">
- <image :src="imageUrl + item.imgUrl" v-for="(item, index) in detail.goodsFiles" :key="index" mode="widthFix"></image>
- </view>
- <view class="remark-container">
- <view class="title">
- <view class="tit">全部留言</view>
- <view class="right" v-if="!isMine" @tap="isShowReportDialog = true;">内容违规,我要举报</view>
- </view>
- <view class="item" v-for="(item, index) in remarkList" :key="index">
- <view class="top">
- <image :src="item.userPic ? (imageUrl + item.userPic) : require('@/static/common/logo.png')"></image>
- <view class="user">
- <view class="name">{{item.userName}}</view>
- <view class="time">{{item.createTime}}</view>
- </view>
- </view>
- <view class="content">
- <view class="left">{{item.message}}</view>
- <view class="right" @tap="handelReply(item)"><text class="iconfont icon-bianji"></text><text>回复</text></view>
- </view>
- <view class="reply" v-if="item.goodsMessageList && item.goodsMessageList.length > 0">
- <view class="it" v-for="(it, idx) in item.goodsMessageList" :key="idx" @tap="handelReply(it)">
- <text class="name">{{it.userName}}</text>
- <text class="text">回复</text>
- <text class="name">{{it.replyNickName}}</text>:{{it.message}}
- </view>
- </view>
- </view>
- </view>
- <template slot="footer">
- <view class="bottom-container">
- <u-button text="留言" type="primary" shape="circle" @click="openRemark()"></u-button>
- <u-button text="操作" type="primary" shape="circle" @click="isShowActionDialog = true" v-if="isMine"></u-button>
- </view>
- </template>
- </zj-page-layout>
- <zj-dialog-remark
- ref="remarkDialog"
- :isShow="isShowRemarkDialog"
- @close="isShowRemarkDialog = false"
- @confirm="confirmRemark">
- </zj-dialog-remark>
- <u-action-sheet
- :actions="actionList"
- :title="'操作'"
- :show="isShowActionDialog"
- @close="isShowActionDialog = false"
- @select="selectAction">
- </u-action-sheet>
- <zj-dialog-box
- :title="'违规举报'"
- :minHeight="'50vh'"
- :isShow="isShowReportDialog"
- @cancel="cancelReportDialog"
- @confirm="confirmReportDialog">
- <view class="report-container">
- <view class="title"><text>*</text>举报原因</view>
- <u--textarea
- fixed
- v-model="reportForm.reason"
- placeholder="请输入"
- height="100">
- </u--textarea>
- <view class="title">上传凭证</view>
- <zj-upload key="cp" @getFiles="getFiles" :fileList="reportForm.fileList" :count="9" />
- </view>
- </zj-dialog-box>
- </view>
- </template>
- <script>
- import zjDialogBox from "@/components/zj-dialog/zj-dialog-box.vue";
- import zjDialogRemark from '@/components/zj-dialog/zj-dialog-remark.vue';
- import zjUpload from '@/components/zj-upload/index.vue'
- export default {
- components: {
- zjDialogBox,
- zjDialogRemark,
- zjUpload
- },
- data() {
- return {
- id: null,
- detail: null,
- remarkList: [],
- imageUrl: this.$imageUrl,
- loadStatus: 0,
- errorText: '',
- refresherTriggered: false,
- isShowRemarkDialog: false,
- actionList: [
- {name: '已卖出', value: 1},
- {name: '下架', value: 2},
- {name: '重新上架', value: 3},
- {name: '编辑', value: 4},
- ],
- isShowActionDialog: false,
- replyId: '',
- isShowReportDialog: false,
- reportForm: {
- reason: '',
- fileList: [],
- }
- }
- },
- computed: {
- isMine() {
- if(this.detail) {
- return this.$store.state.user.userId === this.detail.userId;
- }
- else {
- return false;
- }
- }
- },
- onShareAppMessage(options) {
- if (options && options.from == 'button') {
- // 来自页面内的转发按钮
- } else {
- // 点击微信右上角的分享按钮
- }
- return {
- title: '分享商品「' + this.detail.title + '」',
- imageUrl: this.imageUrl + this.detail.goodsFiles[0].imgUrl,
- path: '/pages/goods/detail?id=' + this.id,
- query: {
- // id: this.goodsId,
- },
- success: function(res) {
- if(res.errMsg == 'shareAppMessage:ok'){
- this.$successToast('分享完成');
- }
- }
- }
- },
- onLoad({id}) {
- this.id = id;
- this.getDetail();
- this.getRemarkList();
- },
- methods: {
- getDetail() {
- this.$api.postJson('/goods/detail', {
- id: this.id
- }).then(res => {
- this.detail = res.data;
- this.loadStatus = 0;
- }).catch(res => {
- this.errorText = res.message;
- this.loadStatus = 2;
- }).finally(res => {
- this.refresherTriggered = false;
- })
- },
- refresherrefresh() {
- this.refresherTriggered = true;
- this.getDetail();
- this.getRemarkList();
- },
- // 处理点赞留言
- handelLickCollect(type) {
- let status = false;
- if(type === 1) {
- status = this.detail.isLike || false;
- }else {
- status = this.detail.isCollect || false;
- }
- this.$api.postJson('/likeOrCollect/likeOrCollect', {
- userId: this.$store.state.user.userId,
- goodsId: this.id,
- type,
- operate: status ? 'NO' : 'YES'
- }).then(res => {
- this.detail.up = res.data.up;
- this.detail.collectNum = res.data.collectNum;
- this.detail.isLike = res.data.isLike;
- this.detail.isCollect = res.data.isCollect;
- })
- },
- // 去联系
- toContact() {
- this.$navToPage({
- url: `/pages/message/msgView?goodsId=${this.id}`
- })
- },
- // 去购买
- toBuy() {
- this.$navToPage({
- url: `/pages/goods/order?goodsId=${this.id}`
- })
- },
- // 获取留言列表
- getRemarkList() {
- this.$api.postJson('/message/list2', {
- userId: this.$store.state.user.userId,
- goodsId: this.id,
- pageNum: 1,
- pageSize: -1,
- }).then(res => {
- this.remarkList = res.data.records;
- })
- },
- openRemark(replyItem) {
- this.$refs.remarkDialog.setValue(replyItem);
- this.isShowRemarkDialog = true;
- },
- // 提交留言
- confirmRemark(val) {
- this.$api.postJson('/message/add', {
- userId: this.$store.state.user.userId,
- goodsId: this.id,
- message: val,
- replyId: this.replyId,
- }).then(res => {
- this.replyId = '';
- this.isShowRemarkDialog = false;
- this.getRemarkList();
- })
- },
- // 回复留言
- handelReply(item) {
- this.replyId = item.id;
- this.openRemark(item);
- },
- getFiles(value) {
- this.reportForm.fileList = value[0]
- },
- cancelReportDialog() {
- this.reportForm.reason = '';
- this.reportForm.fileList = [];
- this.isShowReportDialog = false;
- },
- confirmReportDialog() {
- if(!this.reportForm.reason) return this.$toast('请输入举报原因');
- this.$api.postJson('/reportGoods/report', {
- goodsId: this.id,
- reportNote: this.reportForm.reason,
- url: this.reportForm.fileList,
- }).then(res => {
- this.cancelReportDialog();
- this.isShowRemarkDialog = false;
- })
- },
- selectAction(e) {
- // 已卖出/下架
- if(e.value === 1 || e.value === 2) {
- this.$modal({
- content: `确定要${e.name}吗?`
- }).then(() => {
- this.$api.post('/goods/upOrDel', {
- id: this.id,
- status: e.value === 1 ? 4 : 0,
- }).then(res => {
- this.$successToast();
- this.getDetail();
- })
- }).catch(() => {})
- }
- // 重新上架
- else if(e.value === 3) {
- uni.setStorageSync('issuePageParam', {
- goodsId: this.id,
- type: 1,
- isLoad:true
- });
- this.$navToPage({
- url: `/pages/issue/index`
- }, 'switchTab')
- }
- // 编辑
- else if(e.value === 4) {
- uni.setStorageSync('issuePageParam', {
- goodsId: this.id,
- type: 2
- });
- this.$navToPage({
- url: `/pages/issue/index`
- }, 'switchTab')
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .top-container {
- background: #ffffff;
- margin-top: 30rpx;
- padding: 30rpx;
- .user {
- display: flex;
- align-items: center;
- image {
- width: 88rpx;
- height: 88rpx;
- border-radius: 50%;
- }
- .info {
- margin-left: 12rpx;
- .name {
- font-size: 28rpx;
- }
- .phone {
- font-size: 24rpx;
- margin-top: 12rpx;
- }
- }
- }
- .btns {
- display: flex;
- margin-top: 30rpx;
- ::v-deep .u-button {
- width: calc((100% - 60rpx) / 3);
- height: 68rpx;
- line-height: 68rpx;
- font-size: 28rpx;
- color: #ffffff;
- margin: 0;
- margin-right: 30rpx;
- &:last-child {
- margin-right: 0;
- }
- }
- }
- }
- .info-container {
- background: #ffffff;
- padding: 30rpx;
- margin-top: 30rpx;
- position: relative;
- .soldout {
- position: absolute;
- right: 150rpx;
- top: 20rpx;
- image {
- width: 120rpx;
- }
- }
- .title {
- display: flex;
- justify-content: space-between;
- .tit {
- font-size: 32rpx;
- }
- .price {
- font-size: 32rpx;
- color: $assist-color;
- font-weight: 500;
- }
- }
- .des {
- margin-top: 12rpx;
- font-size: 28rpx;
- color: $reg-font;
- }
- .tags {
- margin-top: 12rpx;
- display: flex;
- .it {
- background: #f1f1f1;
- font-size: 20rpx;
- margin-right: 20rpx;
- padding: 8rpx 12rpx;
- border-radius: 8rpx;
- }
- }
- .info {
- display: flex;
- margin-top: 20rpx;
- text {
- font-size: 24rpx;
- color: $sec-font;
- }
- }
- .bottom {
- border-top: 1px solid #eaeaea;
- margin-top: 20rpx;
- padding-top: 20rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .left-location {
- font-size: 28rpx;
- color: $sec-font;
- display: flex;
- align-items: center;
- .iconfont {
- margin-right: 4rpx;
- }
- }
- .right-stats {
- flex-shrink: 0;
- display: flex;
- align-items: center;
- .it {
- flex-shrink: 0;
- display: flex;
- align-items: center;
- margin-left: 20rpx;
- .iconfont {
- font-size: 30rpx;
- color: $sec-font;
- }
- .text {
- font-size: 26rpx;
- margin-left: 4rpx;
- color: $sec-font;
- }
- &.active {
- .iconfont {
- color: $theme-color;
- }
- .text {
- color: $theme-color;
- }
- }
- }
- }
- }
- }
- .imgs-container {
- margin-top: 30rpx;
- image {
- width: 100%;
- display: block;
- }
- }
- .remark-container {
- background: #ffffff;
- margin-top: 30rpx;
- padding: 30rpx;
- .title {
- display: flex;
- align-items: center;
- justify-content: space-between;
- .tit {
- font-weight: 500;
- }
- .right {
- font-size: 24rpx;
- color: $sec-font;
- border-radius: 40rpx;
- border: 1px solid #eaeaea;
- padding: 0 16rpx;
- height: 40rpx;
- line-height: 40rpx;
- }
- }
- .item {
- padding: 30rpx 0;
- border-bottom: 1px solid #eaeaea;
- &:last-child {
- border: none;
- }
- .top {
- display: flex;
- image {
- width: 88rpx;
- height: 88rpx;
- border-radius: 50%;
- flex-shrink: 0;
- }
- .user {
- margin-left: 20rpx;
- flex: 1;
- display: flex;
- flex-direction: column;
- justify-content: center;
- .name {
- }
- .time {
- color: $sec-font;
- font-size: 24rpx;
- margin-top: 8rpx;
- }
- }
- .status {
- color: $assist-color;
- }
- }
- .content {
- margin-top: 20rpx;
- display: flex;
- justify-content: space-between;
- align-items: center;
- .left {
- font-size: 28rpx;
- word-break: break-all;
- line-height: 36rpx;
- }
- .right {
- flex-shrink: 0;
- font-size: 24rpx;
- background: #eaeaea;
- display: flex;
- align-items: center;
- padding: 8rpx 12rpx;
- margin-left: 40rpx;
- border-radius: 8rpx;
- .iconfont {
- font-size: 24rpx;
- margin-right: 4rpx;
- }
- }
- }
- .reply {
- background: #f5f5f5;
- border-radius: 8rpx;
- padding: 16rpx 20rpx;
- margin-top: 20rpx;
- .it {
- margin-top: 16rpx;
- font-size: 26rpx;
- line-height: 32rpx;
- word-break: break-all;
- &:first-child {
- margin-top: 0;
- }
- .name {
- color: $theme-color;
- }
- .text {
- color: $sec-font;
- }
- }
- }
- }
- }
- .report-container {
- padding: 0 30rpx 60rpx;
- .title {
- margin-top: 30rpx;
- margin-bottom: 20rpx;
- text {
- color: $assist-color;
- }
- }
- }
- .bottom-container {
- padding: 20rpx 30rpx;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- ::v-deep .u-button {
- width: auto;
- height: 60rpx;
- margin: 0;
- margin-left: 20rpx;
- padding: 0 30rpx;
- }
- }
- </style>
|