Commit 41acc5bc authored by June's avatar June

评论中心

parent 7b7a6020
...@@ -3,20 +3,22 @@ import { request } from "@/lib/service" ...@@ -3,20 +3,22 @@ import { request } from "@/lib/service"
/** /**
* @desc 查询用户待评价sku商品评论列表接口 * @desc 查询用户待评价sku商品评论列表接口
*/ */
export function unCommentList() { export function unCommentList(params) {
return request({ return request({
url: 'zsxcx/getDpjComments.htm', url: 'zsxcx/getDpjComments.htm',
method: 'post' method: 'post',
data: params
}) })
} }
/** /**
* @desc 查询用户已评价sku商品评论列表接口 * @desc 查询用户已评价sku商品评论列表接口
*/ */
export function hadCommentList() { export function hadCommentList(params) {
return request({ return request({
url: 'zsxcx/getYpjComments.htm', url: 'zsxcx/getYpjComments.htm',
method: 'post' method: 'post',
data: params
}) })
} }
...@@ -29,4 +31,27 @@ export function commentList(params) { ...@@ -29,4 +31,27 @@ export function commentList(params) {
method: 'post', method: 'post',
data: params data: params
}) })
}
/**
* @desc 获取商品评论详情接口
*/
export function commentDetail(id) {
return request({
url: 'zsxcx/getGoodsCommentsDetail.htm',
method: 'post',
data: {
id
}
})
}
/**
* @desc 获取用户待评价商品数量接口
*/
export function uncommentNum(id) {
return request({
url: 'zsxcx/getDpjCommentsCount.htm',
method: 'post'
})
} }
\ No newline at end of file
...@@ -3,50 +3,55 @@ ...@@ -3,50 +3,55 @@
class="wrap-scroll w-100" class="wrap-scroll w-100"
scroll-x scroll-x
> >
<video <template
class="r-8" v-for="(e, i) in media"
:class="className" >
:style="itemSize" <video
src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4" v-if="e.type === 'video'"
:controls="controls" class="item r-8"
:autoplay="false" :key="i"
:show-play-btn="false" :style="itemSize"
@click="handlePreview(0)" :src="e.url"
/> :controls="controls"
<image :autoplay="false"
v-for="(item, idx) in 4" :show-play-btn="false"
:key="item" @click.stop="handlePreview(i)"
class="item r-8" />
:class="className" <image
:style="itemSize" v-else
src="https://www.gelifood.com/upload/goods/20210301/7432e042823c1ea4dc08eb1614575307goods_thumb.png" :key="i"
mode="aspectFit" class="item r-8"
@click="handlePreview(idx+1)" :style="itemSize"
/> :src="e.url"
mode="aspectFit"
lazy-load
@click.stop="handlePreview(i)"
/>
</template>
</scroll-view> </scroll-view>
</template> </template>
<script module="utils" lang="wxs"> // <script module="utils" lang="wxs">
function itemSize(arr) { // function itemSize(arr) {
var len = arr.length; // var len = arr.length;
var size = 150; // 当大于三张时的宽度 // var size = 150; // 当大于三张时的宽度
switch(len) { // switch(len) {
case 1: // case 1:
size = 410; // size = 410;
breck; // breck;
case 2: // case 2:
size = 330; // size = 330;
break; // break;
default: // default:
break; // break;
} // }
return 'width:' + size + 'rpx;height:' + size + 'rpx;'; // return 'width:' + size + 'rpx;height:' + size + 'rpx;';
} // }
module.exports = { // module.exports = {
itemSize: itemSize // itemSize: itemSize
} // }
</script> // </script>
<script> <script>
export default { export default {
...@@ -55,9 +60,9 @@ ...@@ -55,9 +60,9 @@
type: [String , Number], type: [String , Number],
default: '150' default: '150'
}, },
className: { media: {
type: String, type: Array,
default: 'mr-2' default: () => []
} }
}, },
...@@ -67,24 +72,12 @@ ...@@ -67,24 +72,12 @@
return `width: ${size}rpx; height:${size}rpx;` return `width: ${size}rpx; height:${size}rpx;`
} }
}, },
methods: { methods: {
handlePreview(idx) { handlePreview(idx) {
wx.previewMedia({ console.log(idx)
sources: [ uni.previewMedia({
{ sources: this.media,
type: 'video',
url: 'http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4'
},
{
type: 'image',
url: 'https://www.gelifood.com/upload/goods/20210301/7432e042823c1ea4dc08eb1614575307goods_thumb.png'
},
{
type: 'image',
url: 'https://www.gelifood.com/upload/goods/20210301/7432e042823c1ea4dc08eb1614575307goods_thumb.png'
},
],
current: idx, current: idx,
fail: err => console.log(err) fail: err => console.log(err)
}) })
...@@ -98,5 +91,8 @@ ...@@ -98,5 +91,8 @@
white-space: nowrap; white-space: nowrap;
overflow-y: hidden; overflow-y: hidden;
font-size: 28rpx; font-size: 28rpx;
.item {
margin-right: 30rpx;
}
} }
</style> </style>
...@@ -4,13 +4,13 @@ ...@@ -4,13 +4,13 @@
<image <image
class="avatar mr-2 r-8" class="avatar mr-2 r-8"
:src="baseUrl + '/' + user.avatar" :src="baseUrl + '/' + user.avatar"
mode="aspectFit" mode="scaleToFill"
/> />
<view class="flex-1"> <view class="flex-1">
<view class="font-24 mb-2">{{user.nickname}}</view> <view class="font-24 mb-2">{{user.nickname}}</view>
<rate <rate
readonly readonly
value="user.grade" :value="~~user.grade"
size="12" size="12"
margin="2" margin="2"
/> />
......
...@@ -39,7 +39,6 @@ async function successRes(res, options, resolve, reject) { ...@@ -39,7 +39,6 @@ async function successRes(res, options, resolve, reject) {
resolve({ resolve({
status: true, status: true,
data: data.data, data: data.data,
test: data,
msg: data.rep_msg msg: data.rep_msg
}) })
break; break;
......
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
"path": "pages/mine/index", "path": "pages/mine/index",
"style": { "style": {
"navigationStyle": "custom", "navigationStyle": "custom",
"navigationBarTextStyle":"white" "navigationBarTextStyle":"white",
"enablePullDownRefresh": true
} }
}, },
{ {
...@@ -167,7 +168,8 @@ ...@@ -167,7 +168,8 @@
{ {
"path": "comments/detail", "path": "comments/detail",
"style": { "style": {
"navigationBarTitleText": "评论详情" "navigationBarTitleText": "评论详情",
"enablePullDownRefresh": true
} }
} }
] ]
......
...@@ -5,10 +5,11 @@ ...@@ -5,10 +5,11 @@
@tolower="tolower" @tolower="tolower"
@refresh="refresh" @refresh="refresh"
> >
<view <navigator
class="comment-item" class="comment-item"
hover-class="none"
v-for="(item, index) in list" v-for="(item, index) in list"
:data-index="index" :url="'/subPages/comments/detail?id=' + item.id"
:key="index" :key="index"
> >
<view class="mb-2"> <view class="mb-2">
...@@ -22,7 +23,7 @@ ...@@ -22,7 +23,7 @@
<media-view :media="item.media" /> <media-view :media="item.media" />
<view class="descColor font-24 mt-2">{{item.goods_attr}}</view> <view class="descColor font-24 mt-2">{{item.goods_attr}}</view>
</view> </navigator>
</pull-list> </pull-list>
</view> </view>
...@@ -82,12 +83,16 @@ ...@@ -82,12 +83,16 @@
if(status) { if(status) {
const resetData = data.map(item => { const resetData = data.map(item => {
let media = [] let media = []
const baseUrl = this.baseUrl
if(item.img_url) { if(item.img_url) {
media = [...item.img_url.split(',')] media = [...item.img_url.split(',').map(item => ({
url: `${baseUrl}/${item}`,
tpye: 'image'
}))]
} }
if(item.video_url) { if(item.video_url) {
media.unshift({ media.unshift({
url: item.video_rul, url: `${baseUrl}/${item.video_url}`,
type: 'video' type: 'video'
}) })
} }
...@@ -100,6 +105,7 @@ ...@@ -100,6 +105,7 @@
}, },
content: item.content, content: item.content,
media, media,
id: item.id,
reply: [], reply: [],
goods_attr: item.goods_attr goods_attr: item.goods_attr
} }
...@@ -118,6 +124,10 @@ ...@@ -118,6 +124,10 @@
refresh() { refresh() {
console.log("shuaxin") console.log("shuaxin")
},
handleNav(e) {
console.log(e)
} }
} }
} }
......
...@@ -4,7 +4,7 @@ import { collectGoods } from '@/apis/goods.js' ...@@ -4,7 +4,7 @@ import { collectGoods } from '@/apis/goods.js'
function handlePopup() { function handlePopup() {
const skuData = this.skuData const skuData = this.skuData
const detail = this.detail const detail = this.detail
if(!skuData & skuData.length) return this.$toast({title: '该商品暂无库存'}) if(!skuData || !skuData.length) return this.$toast({title: '该商品暂无库存'})
const params = { const params = {
goodsInfo: { goodsInfo: {
cover: `${this.baseUrl}/${detail.goods_thumb}`, cover: `${this.baseUrl}/${detail.goods_thumb}`,
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
> >
<image class="icon mb-2" src="/static/images/mine/comment.png" mode="aspectFit"></image> <image class="icon mb-2" src="/static/images/mine/comment.png" mode="aspectFit"></image>
<view>待评价</view> <view>待评价</view>
<view v-if="commentCounts > 0" class="badge">{{commentCounts > 99 ? '99+' : commentCounts}}</view>
</view> </view>
<view <view
class="order-menu_item flex flex-column j-center a-center" class="order-menu_item flex flex-column j-center a-center"
...@@ -115,6 +115,7 @@ import { checkLogin } from '@/utils/modules/login.js' ...@@ -115,6 +115,7 @@ import { checkLogin } from '@/utils/modules/login.js'
import { baseUrl } from '@/config/index.js' import { baseUrl } from '@/config/index.js'
import { makePhoneCall } from '@/utils/common.js' import { makePhoneCall } from '@/utils/common.js'
import { orderNum } from '@/apis/order.js' import { orderNum } from '@/apis/order.js'
import { uncommentNum } from '@/apis/comment.js'
export default { export default {
data() { data() {
return { return {
...@@ -123,7 +124,8 @@ export default { ...@@ -123,7 +124,8 @@ export default {
wait_pay: 0, wait_pay: 0,
wait_receive: 0, wait_receive: 0,
wait_send: 0 wait_send: 0
} },
commentCounts: 0
} }
}, },
computed: { computed: {
...@@ -132,16 +134,37 @@ export default { ...@@ -132,16 +134,37 @@ export default {
userInfo: state => state.user.userInfo, userInfo: state => state.user.userInfo,
}) })
}, },
onShow() { // 获取更新用户信息 onShow() { // 获取更新用户信息
if(this.token) { this.init()
this.setUserInfo()
this.getOrderNum()
}
}, },
onPullDownRefresh() {
uni.showLoading({
title: '加载中...',
mask: true
})
this.init()
let timer = setTimeout(() => {
uni.stopPullDownRefresh()
clearTimeout(timer)
timer = null
uni.hideLoading()
}, 800)
},
methods: { methods: {
makePhoneCall, makePhoneCall,
...mapActions('user', ['setUserInfo']), ...mapActions('user', ['setUserInfo']),
init() {
if(this.token) {
this.setUserInfo()
this.getOrderNum()
this.getCommentNum()
}
},
nav(type, arg) { nav(type, arg) {
checkLogin(() => { checkLogin(() => {
switch (type) { switch (type) {
...@@ -193,6 +216,19 @@ export default { ...@@ -193,6 +216,19 @@ export default {
if(status) { if(status) {
this.orderNum = data this.orderNum = data
} }
},
// 获取待评论数量
async getCommentNum() {
try{
const { status, data } = await uncommentNum()
if(status) {
this.commentCounts = data.count
}
}catch(e){
console.log(e)
//TODO handle the exception
}
} }
} }
} }
...@@ -258,8 +294,9 @@ export default { ...@@ -258,8 +294,9 @@ export default {
top: -16rpx; top: -16rpx;
width: 32rpx; width: 32rpx;
height: 32rpx; height: 32rpx;
line-height: 32rpx; display: flex;
text-align: center; justify-content: center;
align-items: center;
color: #fff; color: #fff;
background-color: $primary; background-color: $primary;
border: 1rpx solid $primary; border: 1rpx solid $primary;
......
...@@ -17,7 +17,10 @@ ...@@ -17,7 +17,10 @@
<!-- list --> <!-- list -->
<swiper class="list-wrap" :current="cur_tab" @change="swiperChange"> <swiper class="list-wrap" :current="cur_tab" @change="swiperChange">
<swiper-item> <swiper-item>
<pull-list> <pull-list
@tolower="tolower"
@refresh="refresh"
>
<view class="list-item w-100 p-2 r-8"> <view class="list-item w-100 p-2 r-8">
<view class="font-32 font-bold mb-2">这是一个店铺名称</view> <view class="font-32 font-bold mb-2">这是一个店铺名称</view>
<view class="w-100 flex j-start a-center"> <view class="w-100 flex j-start a-center">
...@@ -44,7 +47,10 @@ ...@@ -44,7 +47,10 @@
</pull-list> </pull-list>
</swiper-item> </swiper-item>
<swiper-item> <swiper-item>
<pull-list> <pull-list
@tolower="tolower"
@refresh="refresh"
>
<view class="list-item w-100 p-2 r-8"> <view class="list-item w-100 p-2 r-8">
<view class="font-32 font-bold mb-2">这是一个店铺名称</view> <view class="font-32 font-bold mb-2">这是一个店铺名称</view>
<view class="w-100 flex j-start a-center"> <view class="w-100 flex j-start a-center">
...@@ -102,8 +108,16 @@ ...@@ -102,8 +108,16 @@
methods: { methods: {
async getList() { async getList() {
try{ try{
const { status, data, test } = await commentList() const { cur_tab } = this
console.log(status, test) console.log(cur_tab)
if(cur_tab === 0) {
const { status, data, test } = await unCommentList()
console.log(status, test)
} else {
const { status, data, test } = await hadCommentList()
console.log(status, test)
}
}catch(e){ }catch(e){
this.$toast({title: '程序错误,获取失败'}) this.$toast({title: '程序错误,获取失败'})
} }
...@@ -117,6 +131,14 @@ ...@@ -117,6 +131,14 @@
swiperChange(e) { swiperChange(e) {
this.cur_tab = e.detail.current this.cur_tab = e.detail.current
},
tolower() {
console.log(2)
},
refresh() {
console.log(1)
} }
} }
} }
......
...@@ -66,15 +66,44 @@ ...@@ -66,15 +66,44 @@
<script> <script>
import user from '@/components/comments/user.vue' import user from '@/components/comments/user.vue'
import { commentDetail } from '@/apis/comment.js'
export default { export default {
components: { components: {
user user
}, },
mounted() { onLoad(ops) {
uni.showShareMenu({ this.id = ops.id
menus: ['shareAppMessage', 'shareTimeline'] if(!this.id) return
this.getCommentDeatil()
},
onPullDownRefresh() {
uni.showLoading({
title: '加载中...',
mask: true
}) })
this.getCommentDeatil()
let timer = setTimeout(() => {
uni.stopPullDownRefresh()
clearTimeout(timer)
timer = null
uni.hideLoading()
}, 800)
},
methods: {
async getCommentDeatil() {
try{
if(!this.id) return
const { status, data } = await commentDetail(this.id)
if(status) {
console.log(data)
}
}catch(e){
console.log(e)
}
}
} }
} }
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment