GoodsEvaluation.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <home-base :show="false"><view style="position: absolute;top:0;right:0;left:0;bottom:0" class="scroll-view-wrapper div container">
  3. <view class="div common-header-wrap">
  4. <view class="status-holder"></view>
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar title="商品评价" class="common-header" left-icon="back" @clickLeft="goBack()">
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <view class="scroll-view-wrapper div ui-evaluation" style="height:100%">
  14. <view class="div ui-evaluation-header">
  15. <view class="div flex-header">
  16. <view class="div"
  17. v-for="(item, index) in staticData"
  18. v-bind:key="item.id"
  19. v-bind:class="{ active: currentTag == item.value }"
  20. v-on:click="changeTab(item.value, item.grade)"
  21. >
  22. {{ item.name }}
  23. </view>
  24. </view>
  25. </view>
  26. <view class="scroll-view div" style="position:relative">
  27. <scroll-view
  28. style="position: absolute;top:0;right:0;left:0;bottom:0"
  29. class="div ui-evaluation-body"
  30. @scrolltolower="loadMore"
  31. scroll-y="true"
  32. >
  33. <view
  34. class="div list"
  35. v-for="(item, index) in reviewList"
  36. v-if="reviewList.length > 0"
  37. :key="index"
  38. >
  39. <view class="div item">
  40. <view class="span">
  41. <image mode="aspectFit" class="img avatar" :src="item.member_avatar" />
  42. {{ item.geval_isanonymous?'匿名':item.geval_frommembername }}
  43. <view class="span"
  44. v-bind:class="{
  45. 'good-review': item.geval_scores > 3,
  46. 'medium-review': item.geval_scores > 1,
  47. 'bad-review': item.geval_scores == 1
  48. }"
  49. >{{ getGrade(item.geval_scores) }}</view
  50. >
  51. </view>
  52. <text class="span">{{ getTime(item.geval_addtime) }}</text>
  53. </view>
  54. <view class="p" v-if="item.geval_content">{{ item.geval_content }}</view>
  55. <view class="p" v-if="!item.geval_content">无评价信息</view>
  56. <view class="p explain" v-if="item.geval_explain">掌柜回复:{{ item.geval_explain }}</view>
  57. <view class="div geval-image-list" v-if="item.geval_image && item.geval_image.length">
  58. <view class="div geval-image-item" v-for="(image,i) in item.geval_image" :key="i">
  59. <view class="div image-wrapper"><image mode="aspectFit" class="img image" :src="image" @click="openImage(image)" /></view>
  60. </view>
  61. </view>
  62. </view>
  63. </scroll-view>
  64. <view class="div list-empty" v-if="reviewList.length <= 0">
  65. <view class="div iconfont empty-icon">&#xe636;</view>
  66. <view class="p">本商品暂无评价</view>
  67. </view>
  68. </view>
  69. <uni-popup ref="isshow" class="popup" >
  70. <image mode="aspectFit" class="img" :src="showimage" :style="getBannerStyle" @click="hidePopup('isshow')">
  71. </uni-popup>
  72. </view>
  73. </view></home-base>
  74. </template>
  75. <script>
  76. import {getFontSize} from '@/util/common'
  77. import TitleHeader from '../../TitleHeader'
  78. import HomeBase from '../HomeBase'
  79. import { mapState, mapMutations, mapActions } from 'vuex'
  80. import EmptyRecord from '../../EmptyRecord'
  81. import { evaluation } from './static'
  82. import { getReviewList } from '../../../api/homegoodsdetail'
  83. export default {
  84. data () {
  85. return {
  86. navHeight: 0,
  87. screenWidth:0,
  88. showimage: '',
  89. staticData: evaluation,
  90. id: 0,
  91. currentTag: 'total',
  92. grade: 0,
  93. subTotal: {},
  94. reviewList: [],
  95. page: 0,
  96. loading: false,
  97. hasmore: true
  98. }
  99. },
  100. components:{
  101. TitleHeader,
  102. HomeBase,
  103. EmptyRecord
  104. },
  105. onLoad: function (option) {
  106. this.id=option.goods_id
  107. this.loadMore()
  108. },
  109. computed: {
  110. fontSize(){
  111. return getFontSize()
  112. },
  113. getBannerStyle: function () {
  114. const res = uni.getSystemInfoSync()
  115. var width = res.windowWidth
  116. var height = res.windowHeight
  117. let itemWidth = width
  118. let itemHeight = height
  119. return "width:"+itemWidth +"px;height:"+itemHeight +"px"
  120. }
  121. },
  122. mounted(){
  123. // #ifdef MP-WEIXIN
  124. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  125. // #endif
  126. this.screenWidth=uni.getSystemInfoSync().screenWidth
  127. // this.changePictureCode()
  128. },
  129. methods:{
  130. goBack(){uni.navigateBack({delta:1})},
  131. showPopup(id){
  132. this.$refs[id].open()
  133. },
  134. hidePopup(id){
  135. this.$refs[id].close()
  136. },
  137. openImage (src) {
  138. this.showimage = src
  139. this.isshow = true
  140. },
  141. loadMore () {
  142. if(this.loading){
  143. return
  144. }
  145. this.loading = true
  146. if (this.hasmore) {
  147. this.page = ++this.page
  148. this.getReviewList(true)
  149. }
  150. },
  151. getReviewList (ispush) {
  152. getReviewList(this.id, this.grade, 10, this.page).then(res => {
  153. this.loading = false
  154. if (res) {
  155. if (ispush) {
  156. this.reviewList = this.reviewList.concat(res.result.goods_eval_list)
  157. } else {
  158. this.reviewList = res.result.goods_eval_list
  159. }
  160. this.hasmore = res.result.hasmore
  161. }
  162. })
  163. },
  164. changeTab (value, grade) {
  165. this.currentTag = value
  166. this.grade = grade
  167. this.getReviewList(false)
  168. },
  169. getGrade (grade) {
  170. if (grade == 1) {
  171. return '差评'
  172. } else if (grade > 3) {
  173. return '好评'
  174. } else {
  175. return '中评'
  176. }
  177. },
  178. getTime (timestamps) {
  179. let date = new Date(timestamps * 1000)
  180. let year = date.getFullYear()
  181. let month = date.getMonth() + 1
  182. let day = date.getDate()
  183. return year + '-' + month + '-' + day
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="scss" scoped>
  189. .scroll-view-wrapper{display: flex;flex-direction: column;}
  190. .scroll-view{flex:1}
  191. .ui-evaluation {
  192. .ui-evaluation-header {
  193. background: #ffffff;
  194. .flex-header {
  195. width: auto;
  196. display: flex;
  197. display: -webkit-flex;
  198. display: -moz-flex;
  199. flex-basis: 100%;
  200. justify-content: space-around;
  201. align-content: center;
  202. align-items: center;
  203. height:2.2rem;
  204. .div {
  205. color: $descTextColor;
  206. font-size:$subFontSize;
  207. height:1.2rem;
  208. border: 0.5px solid #eee;
  209. padding: 0 0.45rem;
  210. line-height: 1.2rem;
  211. text-align: center;
  212. border-radius: 1.2rem;
  213. &.active {
  214. color: $primaryColor;
  215. border: 0.5px solid $primaryColor;
  216. }
  217. }
  218. }
  219. }
  220. .ui-evaluation-body {
  221. padding: 0 0.75rem;
  222. background: rgba(255, 255, 255, 1);
  223. box-sizing: border-box;
  224. .list {
  225. padding: 0.75rem 0;
  226. border-bottom: 0.5px dashed #eee;
  227. color: #333;
  228. font-size:$subFontSize;
  229. .item {
  230. overflow: hidden;
  231. padding-bottom:0.75rem;
  232. display: flex;
  233. justify-content: space-between;
  234. align-content: center;
  235. align-items: center;
  236. .avatar{width:2rem;height: 2rem;border-radius: 50%;margin-right: .3rem;}
  237. .span {
  238. &:first-child {
  239. display: flex;
  240. justify-content: space-around;
  241. align-content: center;
  242. align-items: center;
  243. .span {
  244. margin-left:0.75rem;
  245. color: #ffffff;
  246. font-size:$fontSize;
  247. }
  248. }
  249. &:last-child {
  250. color: #999999;
  251. font-size:$fontSize;
  252. }
  253. &.good-review {
  254. background: #fc2e39;
  255. width:1.8rem;
  256. height:0.8rem;
  257. text-align: center;
  258. background-size: cover;
  259. line-height:0.8rem;
  260. border-radius:0.4rem;
  261. }
  262. &.medium-review {
  263. background: $primaryColor;
  264. width:1.8rem;
  265. height:0.8rem;
  266. text-align: center;
  267. background-size: cover;
  268. line-height:0.8rem;
  269. border-radius:0.4rem;
  270. }
  271. &.bad-review {
  272. background: #c3c3c3;
  273. width:1.8rem;
  274. height:0.8rem;
  275. text-align: center;
  276. background-size: cover;
  277. line-height:0.8rem;
  278. border-radius:0.4rem;
  279. }
  280. }
  281. }
  282. .p {
  283. padding: 0;
  284. margin: 0;
  285. flex-basis: 100%;
  286. display: -webkit-box;
  287. -webkit-box-orient: vertical;
  288. -webkit-line-clamp: 2;
  289. overflow: hidden;
  290. }
  291. .explain{color:orange}
  292. }
  293. }
  294. .list-empty {
  295. position: absolute;
  296. top: 50%;
  297. left: 50%;
  298. transform: translate(-50%, -50%);
  299. text-align: center;
  300. .empty-icon{font-size:3rem;padding:1rem 0;color:#999}
  301. .img {
  302. width:2.75rem;
  303. }
  304. .p {
  305. color: #7c7f88;
  306. font-size:$subFontSize;
  307. padding: 0;
  308. margin: 0;
  309. font-weight: normal;
  310. }
  311. }
  312. .geval-image-list{overflow: hidden;margin-top:1rem;
  313. .geval-image-item{width:33.33%;height:0;padding-bottom: 33.33%;float: left;position: relative;
  314. .image-wrapper{position: absolute;left:0;right:0.1rem;top:0;bottom:0.1rem;
  315. .image{width:100%;height: 100%;}
  316. }
  317. }
  318. }
  319. }
  320. </style>