Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
singleStore
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Max
singleStore
Commits
3f3dae48
Commit
3f3dae48
authored
Aug 25, 2021
by
June
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试
parent
c8777985
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
355 additions
and
126 deletions
+355
-126
apis/comment.js
apis/comment.js
+32
-4
apis/common.js
apis/common.js
+9
-3
components/comments/user.vue
components/comments/user.vue
+1
-1
lib/service/index.js
lib/service/index.js
+2
-2
pages/goods/comment-list.vue
pages/goods/comment-list.vue
+4
-0
pages/goods/detail.vue
pages/goods/detail.vue
+0
-8
subPages/comments/center.vue
subPages/comments/center.vue
+53
-33
subPages/comments/comment.vue
subPages/comments/comment.vue
+167
-61
subPages/comments/detail.vue
subPages/comments/detail.vue
+1
-1
subPages/comments/success.vue
subPages/comments/success.vue
+76
-9
utils/common.js
utils/common.js
+10
-4
No files found.
apis/comment.js
View file @
3f3dae48
...
...
@@ -7,7 +7,8 @@ export function unCommentList(params) {
return
request
({
url
:
'
zsxcx/getDpjComments.htm
'
,
method
:
'
post
'
,
data
:
params
data
:
params
,
needMask
:
true
})
}
...
...
@@ -18,7 +19,8 @@ export function hadCommentList(params) {
return
request
({
url
:
'
zsxcx/getYpjComments.htm
'
,
method
:
'
post
'
,
data
:
params
data
:
params
,
needMask
:
true
})
}
...
...
@@ -29,7 +31,8 @@ export function commentList(params) {
return
request
({
url
:
'
zsxcx/getGoodsComments.htm
'
,
method
:
'
post
'
,
data
:
params
data
:
params
,
needMask
:
true
})
}
...
...
@@ -42,7 +45,8 @@ export function commentDetail(id) {
method
:
'
post
'
,
data
:
{
id
}
},
needMask
:
true
})
}
...
...
@@ -54,4 +58,28 @@ export function uncommentNum(id) {
url
:
'
zsxcx/getDpjCommentsCount.htm
'
,
method
:
'
post
'
})
}
/**
* @desc 商品评论接口
*/
export
function
saveComment
(
formData
)
{
return
request
({
url
:
'
zsxcx/saveGoodsComments.htm
'
,
method
:
'
post
'
,
data
:
formData
,
needMask
:
true
})
}
/**
* @desc 追加商品评论接口
*/
export
function
addComment
(
formData
)
{
return
request
({
url
:
'
zsxcx/saveGoodsCommentsAdd.htm
'
,
method
:
'
post
'
,
data
:
formData
,
needMask
:
true
})
}
\ No newline at end of file
apis/common.js
View file @
3f3dae48
...
...
@@ -79,9 +79,15 @@ export function pay({order_sn, openid}) {
}
// 上传文件
export
function
upLoadFile
()
{
/**
* @param {Object} formData
* @param { file } tempFile
* formData.type 上传文件类型:1图片 2视频
*/
export
function
upLoadFile
(
tempFile
,
formData
)
{
return
upload
({
url
:
'
zsxcx/uploadCommentsFiles.htm
'
,
tempFile
,
formData
})
}
\ No newline at end of file
components/comments/user.vue
View file @
3f3dae48
...
...
@@ -10,7 +10,7 @@
<view
class=
"font-24 mb-2"
>
{{
user
.
nickname
}}
</view>
<rate
readonly
:value=
"~~user.grade"
:value=
"~~user.
com_
grade"
size=
"12"
margin=
"2"
/>
...
...
lib/service/index.js
View file @
3f3dae48
...
...
@@ -147,7 +147,6 @@ export function request (options) {
export
function
upload
(
options
)
{
const
valite_err
=
validateOps
(
options
)
if
(
valite_err
)
return
Toast
({
title
:
valite_err
})
options
.
url
=
`
${
baseUrl
}
/
${
options
.
url
}
`
uni
.
showLoading
({
title
:
'
上传中...
'
,
mask
:
true
})
return
new
Promise
((
resolve
,
reject
)
=>
{
// const isOverdue = store.state.user.isOverdue
...
...
@@ -162,13 +161,14 @@ export function upload(options) {
const
token
=
store
.
state
.
user
.
token
||
''
const
appid
=
store
.
state
.
user
.
appid
||
''
uni
.
uploadFile
({
url
:
options
.
url
,
url
:
`
${
baseUrl
}
/
${
options
.
url
}
`
,
filePath
:
options
.
tempFile
,
header
:
{
// "Content-Type": "multipart/form-data",
'
token
'
:
token
,
'
appid
'
:
appid
},
formData
:
options
.
formData
||
{},
name
:
'
file
'
,
success
:
res
=>
{
successRes
(
res
,
options
,
resolve
,
reject
)
...
...
pages/goods/comment-list.vue
View file @
3f3dae48
...
...
@@ -85,6 +85,10 @@
this
.
getData
()
},
beforeCreate
()
{
this
.
eventChannel
.
off
(
'
acceptDataFromOpenerPage
'
)
},
methods
:
{
...
commonModules
,
...
...
pages/goods/detail.vue
View file @
3f3dae48
...
...
@@ -315,14 +315,6 @@ export default {
handleComment
()
{
wx
.
navigateTo
({
url
:
"
/pages/goods/comment-list
"
,
events
:
{
acceptDataFromOpenedPage
:
function
(
data
)
{
console
.
log
(
data
)
},
someEvent
:
function
(
data
)
{
console
.
log
(
data
)
}
},
success
:
res
=>
{
res
.
eventChannel
.
emit
(
'
acceptDataFromOpenerPage
'
,
{
detail
:
this
.
detail
,
skuData
:
this
.
skuData
})
}
...
...
subPages/comments/center.vue
View file @
3f3dae48
...
...
@@ -56,7 +56,12 @@
/>
<view
class=
"w-100 flex j-between a-center"
>
<view
class=
"descColor font-24"
>
{{
goods
.
goods_attr
}}
</view>
<view
class=
"btn-comment r-8"
:data-order_id=
"unComment.order_id"
>
评价
</view>
<view
class=
"btn-comment r-8"
:data-listidx=
"tidx"
:data-commentdix=
"i"
:data-goodsidx=
"goods_idx"
>
评价
</view>
</view>
</view>
</view>
...
...
@@ -120,29 +125,34 @@
<view
class=
"mb-2"
>
<media-view
:media=
"replyItem.media"
/>
</view>
<view
class=
"font-24 descColor mb-2"
v-if=
"goods.comment_type === '2'"
>
已追评
</view>
<view
class=
"mb-2"
v-for=
"(b_reply, b_idx) in replyItem.reply"
:key=
"b_idx"
>
<view
class=
"reply-content"
>
<view
class=
"font-32 font-bold"
>
商家回复:
</view>
<words
:content=
"b_reply.content"
/>
<words
:content=
"'商家回复:' + b_reply.content"
/>
</view>
<view
class=
"mt-2"
v-if=
"b_reply.img_url.length > 0"
>
<media-view
:media=
"() =>
{
const media = [...b_reply.img_url]
b_reply.video_url
&&
media.unshift(b_reply.video_url)
return media
}" />
<media-view
:media=
"b_reply.media"
/>
</view>
</view>
<view
class=
"w-100 flex j-between a-center"
v-if=
"goods.comment_type === '1'"
>
<view
class=
"descColor font-24"
>
您还可以进行追评
</view>
<view
class=
"btn-comment r-8"
:data-listidx=
"tidx"
:data-commentdix=
"i"
:data-goodsidx=
"goods_idx"
>
追评
</view>
</view>
<view
class=
"font-24 descColor"
v-if=
"goods.comment_type === '3'"
>
感谢您的用心评价!
</view>
</view>
</
template
>
</view>
<view
class=
"w-100 flex j-between a-center"
>
<view
class=
"descColor font-24"
>
qqqq
</view>
<view
class=
"btn-comment r-8"
:data-order_id=
"hadComment.order_id"
>
评价
</view>
</view>
</view>
</view>
</template>
...
...
@@ -159,12 +169,8 @@
import
words
from
'
@/components/comments/words.vue
'
import
{
unCommentList
,
hadCommentList
}
from
'
@/apis/comment.js
'
import
LoadMore
from
'
@/utils/load-more.js
'
import
{
resetCommentData
}
from
'
@/utils/common.js
'
import
{
resetCommentData
,
debounce
}
from
'
@/utils/common.js
'
// 1可追评 2已评论已追评 3已超时
const
commentStatus
=
{
"
1
"
:
'
1
'
}
export
default
{
data
()
{
return
{
...
...
@@ -188,6 +194,14 @@
},
onShow
()
{
const
cur_tab
=
this
.
cur_tab
if
(
cur_tab
===
0
)
{
this
.
unCommendLoad
.
resetParams
()
this
.
unCommentList
=
[]
}
else
if
(
cur_tab
===
1
){
this
.
hadCommendLoad
.
resetParams
()
this
.
hadCommentList
=
[]
}
this
.
getList
()
},
...
...
@@ -195,7 +209,6 @@
async
getList
()
{
try
{
const
{
cur_tab
}
=
this
console
.
log
(
cur_tab
)
if
(
cur_tab
===
0
)
{
const
{
status
,
data
}
=
await
this
.
unCommendLoad
.
getList
({},
unCommentList
)
if
(
status
&&
data
&&
data
.
length
>
0
)
{
...
...
@@ -206,7 +219,7 @@
const
{
status
,
data
}
=
await
this
.
hadCommendLoad
.
getList
({},
hadCommentList
)
if
(
status
&&
data
&&
data
.
length
>
0
)
{
data
.
forEach
(
r
=>
r
.
goods
&&
r
.
goods
.
forEach
(
n
=>
{
n
.
grade
=
n
.
goods_comment
.
com_grade
n
.
com_
grade
=
n
.
goods_comment
.
com_grade
n
.
goods_comment
=
resetCommentData
(
n
.
goods_comment
)
}))
this
.
$set
(
this
.
hadCommentList
,
this
.
hadCommentList
.
length
,
data
)
...
...
@@ -222,11 +235,6 @@
const
index
=
+
e
.
target
.
dataset
.
tabid
if
(
index
===
this
.
cur_tab
)
return
this
.
cur_tab
=
index
if
(
index
===
0
&&
!
this
.
unCommentList
.
length
)
{
this
.
getList
()
}
else
if
(
index
===
1
&&
!
this
.
hadCommentList
.
length
)
{
this
.
getList
()
}
},
swiperChange
(
e
)
{
...
...
@@ -244,10 +252,11 @@
},
refresh
()
{
if
(
this
.
cur_tab
===
0
)
{
const
cur_tab
=
this
.
cur_tab
if
(
cur_tab
===
0
)
{
this
.
unCommendLoad
.
resetParams
()
this
.
unCommentList
=
[]
}
else
{
}
else
if
(
cur_tab
===
1
)
{
this
.
hadCommendLoad
.
resetParams
()
this
.
hadCommentList
=
[]
}
...
...
@@ -255,17 +264,28 @@
},
// 评价
handleComment
(
e
)
{
const
{
order_id
}
=
e
.
target
.
dataset
console
.
log
(
order_id
)
if
(
!
order_id
)
return
handleComment
:
debounce
(
function
(
e
)
{
const
{
listidx
,
commentdix
,
goodsidx
}
=
e
.
target
.
dataset
const
item
=
this
.
unCommentList
[
listidx
][
commentdix
].
goods
[
goodsidx
]
uni
.
navigateTo
({
url
:
'
/subPages/comments/comment?order_id=
'
+
order_id
url
:
'
/subPages/comments/comment
'
,
success
:
res
=>
{
res
.
eventChannel
.
emit
(
'
comment_event
'
,
{
item
,
type
:
'
comment
'
})
}
})
},
},
1000
),
// 追评
handleAddComment
(
e
)
{}
handleAddComment
:
debounce
(
function
(
e
)
{
const
{
listidx
,
commentdix
,
goodsidx
}
=
e
.
target
.
dataset
const
item
=
this
.
hadCommentList
[
listidx
][
commentdix
].
goods
[
goodsidx
]
uni
.
navigateTo
({
url
:
'
/subPages/comments/comment
'
,
success
:
res
=>
{
res
.
eventChannel
.
emit
(
'
comment_event
'
,
{
item
,
type
:
'
add
'
})
}
})
},
1000
)
}
}
</
script
>
...
...
subPages/comments/comment.vue
View file @
3f3dae48
<
template
>
<view
class=
"isIphoneX"
>
<view
class=
"isIphoneX"
:style=
"
{paddingBottom: !isIphoneX ? '34rpx' : null}"
>
<view
class=
"comment-wrap"
>
<view
class=
"goods-info flex j-star a-center"
>
<view
class=
"goods-info flex j-star a-center"
v-if=
"commentData"
>
<image
class=
"cover mr-2"
src=
"https://www.gelifood.com/upload/goods/20210301/7432e042823c1ea4dc08eb1614575307goods_thumb.png
"
:src=
"baseUrl + '/' + commentData.goods_thumb
"
mode=
"aspectFit"
/>
<view
class=
"goods flex-1 flex flex-column j-around"
>
<view
class=
"title"
>
设计方案就是积分卡
</view>
<view
class=
"title descColor font-24"
>
spu
</view>
<view
class=
"title"
>
{{
commentData
.
goods_name
}}
</view>
<view
class=
"title descColor font-24"
>
{{
commentData
.
goods_attr
}}
</view>
</view>
</view>
<view
class=
"w-100 my-4 flex j-star a-center"
>
<view
class=
"font-32 font-bold mr-2"
>
商品评分
</view>
<rate
:value.sync=
"form.v1"
:readonly=
"type === 'add'"
:value.sync=
"form.com_grade || 1"
size=
"17"
margin=
"15"
/>
</view>
<view
class=
"font-bold mb-4"
>
追加一下您的使用体验吧~
</view>
<view
class=
"font-bold mb-4"
v-if=
"type === 'add'"
>
追加一下您的使用体验吧~
</view>
<view
class=
"input-wrap mb-4"
>
<textarea
...
...
@@ -30,7 +31,7 @@
style=
"font-size: 28rpx;"
:placeholder=
"`\ue612 说说您的使用感受,为更多小伙伴购买提供参考~`"
maxlength=
"300"
v-model=
"form.
val
"
v-model=
"form.
content
"
/>
<text
class=
"font-24 descColor words-calc"
>
{{
words
}}
/300
</text>
...
...
@@ -53,7 +54,7 @@
<view
class=
"flex flex-column btn-item j-center a-center r-8 mb-2"
>
<image
class=
"icon"
src=
"/static/images/common/icon-img.png"
mode=
"aspectFit"
/>
</view>
<text>
添加图片
{{
imgTemp
.
length
}}
</text>
<text>
添加图片
</text>
</view>
<view
@
click=
"handleVideo"
v-show=
"!videoTemp"
>
<view
class=
"flex flex-column btn-item j-center a-center r-8 mb-2"
>
...
...
@@ -67,41 +68,43 @@
<view
class=
"w-100 mb-4"
>
<view
class=
"w-100 flex j-between a-center"
>
<view
class=
"font-32 font-bold"
>
服务评价
</view>
<view
class=
"flex a-center"
>
<view
class=
"icon-unSelect
"
></view>
<view
class=
"flex a-center"
@
click=
"form.anonymity = ~~!form.anonymity"
>
<view
:class=
"form.anonymity ? 'icon-unSelect' : 'icon-select'
"
></view>
<text
class=
"ml-2 font-24 descColor"
>
匿名评价
</text>
</view>
</view>
</view>
<view
class=
"w-100 my-4 flex j-star a-center"
>
<view
class=
"font-28 mr-2"
>
商品评分
</view>
<rate
:value.sync=
"form.v2"
size=
"17"
margin=
"15"
/>
</view>
<view
class=
"w-100 my-4 flex j-star a-center"
>
<view
class=
"font-28 mr-2"
>
商品评分
</view>
<rate
:value.sync=
"form.v3"
size=
"17"
margin=
"15"
/>
</view>
<view
class=
"w-100 my-4 flex j-star a-center"
>
<view
class=
"font-28 mr-2"
>
商品评分
</view>
<rate
:value.sync=
"form.v4"
size=
"17"
margin=
"15"
/>
</view>
<view
class=
"descColor font-24"
>
满意请给5星哦~
</view>
<template
v-if=
"type === 'comment'"
>
<view
class=
"w-100 my-4 flex j-star a-center"
>
<view
class=
"font-28 mr-2"
>
店铺服务
</view>
<rate
:value.sync=
"form.serve_grade"
size=
"17"
margin=
"15"
/>
</view>
<view
class=
"w-100 my-4 flex j-star a-center"
>
<view
class=
"font-28 mr-2"
>
商品描述
</view>
<rate
:value.sync=
"form.goods_grade"
size=
"17"
margin=
"15"
/>
</view>
<view
class=
"w-100 my-4 flex j-star a-center"
>
<view
class=
"font-28 mr-2"
>
物流服务
</view>
<rate
:value.sync=
"form.logistics_grade"
size=
"17"
margin=
"15"
/>
</view>
<view
class=
"descColor font-24"
>
满意请给5星哦~
</view>
</
template
>
</view>
<view
class=
"submit font-32 text-center"
@
click=
"handleSubmit"
>
提交
</view>
...
...
@@ -111,63 +114,128 @@
<
script
>
import
rate
from
'
@/components/rate/index.vue
'
import
{
M2B
}
from
'
@/config/global.js
'
import
Validator
from
'
@/utils/validate.js
'
import
{
saveComment
,
addComment
}
from
'
@/apis/comment.js
'
import
{
upLoadFile
}
from
'
@/apis/common.js
'
import
{
debounce
}
from
'
@/utils/common.js
'
export
default
{
components
:
{
rate
},
data
()
{
return
{
commentData
:
null
,
videoTemp
:
''
,
imgTemp
:
[],
type
:
'
add
'
,
form
:
{
og_id
:
''
,
v1
:
0
,
v2
:
0
,
v3
:
0
,
v4
:
0
,
val
:
''
content
:
''
,
img_url
:
[],
video_url
:
''
,
com_grade
:
1
,
serve_grade
:
1
,
logistics_grade
:
1
,
goods_grade
:
1
,
from
:
1
,
anonymity
:
0
// 1 不匿名 0匿名
}
}
},
onLoad
(
ops
)
{
const
{
order_id
}
=
ops
this
.
form
.
og_id
=
order_id
onLoad
()
{
this
.
eventChannel
=
this
.
getOpenerEventChannel
()
this
.
eventChannel
.
on
&&
this
.
eventChannel
.
on
(
'
comment_event
'
,
this
.
dealData
)
uni
.
$on
(
'
backPage
'
,
this
.
dealData
)
uni
.
$once
(
'
hook:beforeDestroy
'
,
()
=>
{
this
.
eventChannel
.
off
(
'
comment_event
'
)
uni
.
$off
(
'
backPage
'
)
})
},
computed
:
{
words
()
{
return
this
.
form
.
val
.
length
return
this
.
form
.
content
.
length
}
},
methods
:
{
dealData
(
data
)
{
const
{
item
,
type
}
=
data
console
.
log
(
item
,
type
)
this
.
type
=
type
this
.
form
=
{
// 先初始化一次,评论成功页面为了控制页面栈用了navBack
og_id
:
''
,
content
:
''
,
img_url
:
[],
video_url
:
''
,
com_grade
:
1
,
serve_grade
:
1
,
logistics_grade
:
1
,
goods_grade
:
1
,
from
:
1
,
anonymity
:
0
// 1 不匿名 0匿名
}
const
form
=
this
.
form
this
.
commentData
=
{...
item
}
form
.
og_id
=
item
.
og_id
if
(
type
===
'
add
'
)
{
this
.
type
=
'
add
'
form
.
com_grade
=
item
.
com_grade
}
this
.
form
=
form
},
async
handlePhoto
()
{
try
{
const
{
status
,
data
}
=
await
this
.
$cWx
(
'
chooseImage
'
,
{
count
:
5
-
this
.
imgTemp
.
length
})
if
(
status
)
{
const
MAX_SIZE
=
M2B
*
5
data
.
tempFiles
.
forEach
((
item
,
index
)
=>
{
const
MAX_SIZE
=
M2B
*
2
uni
.
showLoading
({
title
:
'
上传中...
'
})
const
uploadList
=
[]
// 将符合得图片丢到一个数组
data
.
tempFiles
.
forEach
(
async
(
item
,
index
)
=>
{
if
(
MAX_SIZE
<
item
.
size
)
{
this
.
$toast
({
title
:
`图片
${
index
}
大于
5
M, 请重新选择`
})
this
.
$toast
({
title
:
`图片
${
index
}
大于
2
M, 请重新选择`
})
}
else
{
this
.
imgTemp
.
push
(
item
.
path
)
uploadList
.
push
(
item
.
path
)
}
})
const
task
=
[]
uploadList
.
forEach
(
item
=>
{
task
.
push
(
upLoadFile
(
item
,
{
type
:
1
}))
})
Promise
.
all
(
task
)
.
then
(
res
=>
{
const
result
=
res
.
map
(
item
=>
item
.
data
.
path
)
const
fullPathResult
=
result
.
map
(
item
=>
(
`
${
this
.
baseUrl
}
/
${
item
}
`
))
this
.
imgTemp
=
[...
this
.
imgTemp
,
...
fullPathResult
]
this
.
form
.
img_url
=
[...
this
.
imgTemp
,
...
result
]
})
.
catch
((
err
)
=>
console
.
log
(
err
)
&&
this
.
$toast
({
title
:
'
上传失败
'
}))
.
finally
(()
=>
{
uni
.
hideLoading
()
})
}
}
catch
(
e
){
uni
.
hideLoading
()
console
.
log
(
e
)
}
},
async
handleVideo
()
{
try
{
const
{
status
,
data
}
=
await
this
.
$cWx
(
'
chooseVideo
'
,
{
count
:
5
}
)
const
{
status
,
data
}
=
await
this
.
$cWx
(
'
chooseVideo
'
)
if
(
status
)
{
console
.
log
(
data
)
if
((
M2B
*
10
)
<
data
.
size
)
return
this
.
$toast
({
title
:
'
视频不能大于5M
'
})
this
.
videoTemp
=
data
.
tempFilePath
if
((
M2B
*
2
)
<
data
.
size
)
return
this
.
$toast
({
title
:
'
视频不能大于2M
'
})
uni
.
showLoading
({
title
:
'
上传中...
'
})
const
{
status
:
uploadStatus
,
data
:
uploadRes
}
=
await
upLoadFile
(
data
.
tempFilePath
,
{
type
:
2
})
if
(
!
uploadStatus
)
return
uni
.
hideLoading
()
&&
this
.
$toast
({
title
:
'
上传失败
'
})
this
.
videoTemp
=
data
.
tempFilePath
this
.
form
.
video_url
=
uploadRes
.
path
uni
.
hideLoading
()
}
}
catch
(
e
){
console
.
log
(
e
)
...
...
@@ -187,9 +255,47 @@
}
},
handleSubmit
()
{
console
.
log
(
this
.
form
)
}
validateForm
()
{
const
formValidator
=
new
Validator
()
const
form
=
this
.
form
formValidator
.
add
(
form
.
og_id
,
[{
strategy
:
'
notEmpty
'
,
errorMsg
:
'
商品id不能为空
'
}])
formValidator
.
add
(
form
.
content
,
[{
strategy
:
'
notEmpty
'
,
errorMsg
:
'
评论内容不能为空
'
}])
return
formValidator
.
validate
()
},
handleSubmit
:
debounce
(
function
()
{
const
validateErr
=
this
.
validateForm
()
if
(
validateErr
)
return
this
.
$toast
({
title
:
validateErr
})
this
.
$modal
({
content
:
'
提交后无法修改,请确认不含隐私信息再提交噢~
'
,
cb
:
async
()
=>
{
try
{
this
.
form
.
img_url
.
join
(
'
,
'
)
// 将图片的数组转为字符串,注意这里的地址不拼接域名
switch
(
this
.
type
)
{
case
'
comment
'
:
const
{
status
:
savaStatus
,
data
:
saveData
}
=
await
saveComment
(
this
.
form
)
if
(
!
savaStatus
)
return
this
.
$toast
({
title
:
'
评论失败
'
})
uni
.
navigateTo
({
url
:
'
/subPages/comments/success?id=
'
+
saveData
.
id
})
break
;
case
'
add
'
:
const
{
status
:
addStatus
,
data
:
addData
}
=
await
addComment
(
this
.
form
)
if
(
!
addStatus
)
return
this
.
$toast
({
title
:
'
评论失败
'
})
// uni.navigateTo({
// url: '/subPages/comments/success?id=' + addData.id
// })
this
.
$toast
({
title
:
'
追评成功
'
,
cb
:
()
=>
uni
.
navigateBack
()})
break
;
default
:
break
;
}
}
catch
(
e
){
console
.
log
(
e
)
}
}
})
},
1000
)
}
}
</
script
>
...
...
subPages/comments/detail.vue
View file @
3f3dae48
...
...
@@ -38,7 +38,7 @@
/>
</
template
>
<
template
v-if=
"detail[0].add_data"
>
<
template
v-if=
"detail[0].add_data
.past_day > 0
"
>
<view
class=
"primaryColor font-32 font-bold"
>
{{
detail
[
0
].
add_data
.
past_day
}}
天后追
</view>
<view
class=
"comment-add my-2"
>
{{
detail
[
0
].
add_data
.
content
}}
</view>
<!-- video -->
...
...
subPages/comments/success.vue
View file @
3f3dae48
...
...
@@ -3,7 +3,7 @@
<!-- top -->
<view
class=
"wrap-top w-100 flex flex-column a-center j-center"
>
<view
class=
"font-bold flex a-center"
><i
class=
"icon mr-2"
></i>
评论成功,感谢您!
</view>
<view
class=
"btn-look my-2"
>
查看评价
</view>
<view
class=
"btn-look my-2"
@
click=
"handleDeital"
>
查看评价
</view>
<view
class=
"font-24"
>
审核通过后将对所有人可见
</view>
</view>
...
...
@@ -11,20 +11,32 @@
<view
class=
"my-2 ml-3"
>
心情不错,继续评价
</view>
<!-- list -->
<view
class=
"wrap-list"
>
<view
class=
"w-100 mb-2 wrap-comment"
>
<view
class=
"font-32 font-bold"
>
这是一个店铺名称
</view>
<view
class=
"flex j-star a-center mt-2"
>
<view
class=
"wrap-list"
@
click=
"handleComment"
>
<view
class=
"w-100 mb-2 wrap-comment"
v-for=
"(item, idx) in list"
:key=
"idx"
>
<view
class=
"font-32 font-bold"
>
{{
item
.
shop_name
}}
</view>
<view
class=
"flex j-star a-center mt-2"
v-for=
"(goods, goodsidx) in item.goods"
:key=
"goodsidx"
>
<image
class=
"cover mr-2 r-8"
src=
"https://www.gelifood.com/upload/goods/20210301/7432e042823c1ea4dc08eb1614575307goods_thumb.png
"
:src=
"baseUrl + '/' + goods.goods_thumb
"
mode=
"aspectFit"
/>
<view
class=
"info flex-1 flex j-between a-center flex-column"
>
<view
class=
"title font-bold"
>
这是一堆蔬菜和水果有黄瓜番茄 什么的
</view>
<view
class=
"title font-bold"
>
{{
goods
.
goods_name
}}
</view>
<view
class=
"w-100 flex j-between a-center"
>
<view
class=
"descColor font-24"
>
规格: 200g/包
</view>
<view
class=
"btn-comment r-8"
>
评价
</view>
<view
class=
"descColor font-24"
>
{{
goods
.
goods_attr
}}
</view>
<view
class=
"btn-comment r-8"
:data-listidx=
"idx"
:data-goodsidx=
"goodsidx"
>
评价
</view>
</view>
</view>
</view>
...
...
@@ -38,11 +50,63 @@
import
rate
from
'
@/components/rate/index.vue
'
import
mediaView
from
'
@/components/comments/media-view.vue
'
import
words
from
'
@/components/comments/words.vue
'
import
{
unCommentList
}
from
'
@/apis/comment.js
'
import
{
debounce
}
from
'
@/utils/common.js
'
export
default
{
data
()
{
return
{
list
:
[]
}
},
components
:
{
rate
,
mediaView
,
words
},
onLoad
(
ops
)
{
console
.
log
(
ops
)
const
{
id
}
=
ops
this
.
id
=
id
this
.
getUncoments
()
},
methods
:
{
async
getUncoments
()
{
try
{
const
{
status
,
data
}
=
await
unCommentList
({
page
:
1
,
pagenum
:
10
})
if
(
status
)
{
this
.
list
=
data
.
list
}
}
catch
(
e
){
console
.
log
(
e
)
}
},
handleDeital
()
{
if
(
!
this
.
id
)
return
uni
.
redirectTo
({
url
:
'
/subPages/comments/detail?id=
'
+
this
.
id
})
},
handleComment
:
debounce
(
function
(
e
)
{
const
{
listidx
,
goodsidx
}
=
e
.
target
.
dataset
const
item
=
this
.
list
[
listidx
].
goods
[
goodsidx
]
uni
.
navigateBack
({
delta
:
1
,
success
:
()
=>
{
uni
.
$emit
(
'
backPage
'
,
{
item
,
type
:
'
comment
'
})
}
})
// uni.navigateTo({
// url: '/subPages/comments/comment',
// success: res => {
// res.eventChannel.emit('comment_event', { item, type: 'comment' })
// }
// })
},
1000
)
}
}
</
script
>
...
...
@@ -88,6 +152,9 @@
.title
,
.desc
{
@include
text-ellipsis
(
2
);
}
.title
{
align-self
:
flex-start
;
}
}
.btn-comment
{
padding
:
8rpx
32rpx
;
...
...
utils/common.js
View file @
3f3dae48
...
...
@@ -163,7 +163,7 @@ export function resetCommentData(data) {
type
:
'
video
'
})
}
reply
=
item
.
reply
.
map
(
r
=>
{
reply
=
item
.
reply
?
item
.
reply
.
map
(
r
=>
{
const
videos
=
r
.
video_url
&&
{
url
:
`
${
baseUrl
}
/
${
r
.
video_url
}
`
,
tpye
:
'
video
'
...
...
@@ -174,7 +174,10 @@ export function resetCommentData(data) {
}))
||
null
console
.
log
(
imgs
)
let
r_media
=
[]
r_media
=
[...
imgs
]
&&
(
videos
&&
r_media
.
unshift
(
videos
))
r_media
=
[...
imgs
]
if
(
videos
)
{
r_media
.
unshift
(
videos
)
}
return
{
content
:
r
.
content
,
user_name
:
r
.
user_name
,
...
...
@@ -183,7 +186,7 @@ export function resetCommentData(data) {
// ri
media
:
r_media
}
})
})
:
null
add_data
=
item
.
add_data
?
{
content
:
item
.
add_data
.
content
,
past_day
:
item
.
past_day
,
...
...
@@ -201,7 +204,10 @@ export function resetCommentData(data) {
nickname
:
item
.
nickname
,
avatar
:
item
.
avatar
,
add_time
:
item
.
add_time
,
grade
:
item
.
com_grade
com_grade
:
item
.
com_grade
,
serve_grade
:
item
.
serve_grade
||
0
,
goods_grade
:
item
.
goods_grade
||
0
,
logistics_grade
:
item
.
logistics_grade
||
0
},
goods
:
{
goods_name
:
item
.
goods_name
||
null
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment