comment.nvue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <div class="subnvue flex" @click.stop="">
  3. <div class="mask" @click="hide()"></div>
  4. <div class="content flex" ref="content">
  5. <div class="top flex">
  6. <div class="title">评论</div>
  7. <div @click="hide()" class="hideBtn flex">
  8. <text class="iconfont">&#xe628;</text>
  9. </div>
  10. </div>
  11. <scroll-view scroll-y class="srcoll-view">
  12. <div v-for="(item,index) in dataList" class="card" :key="index">
  13. <div class="card-left">
  14. <image class="card-image" src="../../static/logo.png"></image>
  15. <div class="card-content">
  16. <div class="card-top">
  17. <text class="card-name size-14" @click="replyName(item.name)">{{item.name}}</text>
  18. <text class="color-grey">{{item.time}}</text>
  19. </div>
  20. <div class="card-message">
  21. <text class="margin-right size-14" v-if="item.reply">回复</text>
  22. <text class="color-bule margin-right size-14" v-if="item.reply" @click="replyName(item.reply)">{{item.reply}}:</text>
  23. <text class="card-text size-14" :style="{height:`${Math.ceil(item.message.length/15)*30}upx`}">{{item.message}}</text>
  24. </div>
  25. <!-- <div class="card-bottom">
  26. <text class="color-grey">查看7条回复></text>
  27. </div> -->
  28. </div>
  29. </div>
  30. <div class="card-right">
  31. <text class="iconfont card-icon color-gray">&#xe603;</text>
  32. <text class="color-gray">赞</text>
  33. <text class="iconfont card-icon color-gray">&#xe67f;</text>
  34. <text class="color-gray">踩</text>
  35. </div>
  36. </div>
  37. </scroll-view>
  38. <div class="bottom flex" @click="showInput">
  39. <div class="input" v-if="flag">
  40. <text class="color-gray" style="color: #9C9C9C;">{{placeholder}}</text>
  41. </div>
  42. <!-- <input v-if="flag" class="input" @click="showInput" disabled v-model="message" :placeholder="placeholder"/>
  43. -->
  44. </div>
  45. </div>
  46. </div>
  47. </template>
  48. <script>
  49. //#ifdef APP-NVUE
  50. const animation = weex.requireModule('animation')
  51. const modal = weex.requireModule('modal');
  52. //#endif
  53. export default {
  54. data() {
  55. return {
  56. flag:true,
  57. canHide:false,
  58. message:'',
  59. placeholder:'来聊聊天把',
  60. reply:'',
  61. dataList:[
  62. {name:'张三',time:'04-03',message:'下载来试试喀喀喀喀喀喀喀喀喀酷酷酷酷酷酷酷酷',reply:'春雷'},
  63. {name:'张三',time:'04-03',message:'下载来试试',reply:'春雷'}
  64. ]
  65. }
  66. },
  67. beforeCreate() {
  68. // #ifdef APP-NVUE
  69. var domModule = weex.requireModule('dom');
  70. domModule.addRule('fontFace', {
  71. 'fontFamily': "iconfont",
  72. 'src': "url('../../static/subnvue/iconfont.ttf')"
  73. });
  74. // #endif
  75. },
  76. created() {
  77. uni.$on('showComment', this.showComment)
  78. uni.$on('sendComment', this.sendComment)
  79. },
  80. destroyed() {
  81. uni.$off('showComment')
  82. uni.$off('sendComment')
  83. },
  84. methods: {
  85. replyName(name){
  86. this.reply = name
  87. this.placeholder = `回复 ${name} :`
  88. },
  89. //发送评论
  90. sendComment(val){
  91. console.log(val)
  92. this.dataList.push({
  93. name:'春雷',
  94. time:'04-03',
  95. message:val,
  96. reply:this.reply,
  97. })
  98. this.reply = ''
  99. },
  100. //显示评论
  101. showComment(val){
  102. this.flag = true
  103. this.canHide = false
  104. let content = this.$refs.content;
  105. animation.transition(content, {
  106. styles: {transform: `translate(0px, 0px)`,},
  107. duration: 200, //ms
  108. timingFunction: 'ease-in-out',
  109. delay: 0 //ms
  110. },()=>{
  111. this.canHide = true
  112. })
  113. },
  114. hide() {
  115. if(!this.canHide) return
  116. let content = this.$refs.content;
  117. animation.transition(content, {
  118. styles: {transform: `translate(0px, 1000rpx)`,},
  119. duration: 200, //ms
  120. timingFunction: 'ease-in-out',
  121. delay: 0 //ms
  122. },()=>{
  123. uni.getSubNVueById('comment').hide()
  124. })
  125. },
  126. showInput(){
  127. uni.getSubNVueById('input-box').show('none',0,()=>{
  128. this.flag = false
  129. uni.$emit('showInput')
  130. });
  131. }
  132. }
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. /* #ifndef APP-PLUS-NVUE */
  137. @font-face {
  138. font-family: "iconfont";
  139. src: url('~@/static/subnvue/iconfont.ttf') format('truetype');
  140. }
  141. /* #endif*/
  142. .iconfont{
  143. font-family: "iconfont";
  144. font-family: iconfont;
  145. font-size: 16px;
  146. }
  147. .color-gray{
  148. color: #515352;
  149. font-size: 14px;
  150. }
  151. .color-grey{
  152. color: #A8ACAF;
  153. font-size: 12px;
  154. }
  155. .color-bule{
  156. color: #55ADDF;
  157. }
  158. .margin-right{
  159. margin-right: 20rpx;
  160. }
  161. .subnvue {
  162. flex-direction: column;
  163. flex: 1;
  164. background-color: transparent;
  165. position: relative;
  166. }
  167. .mask{
  168. flex-direction: column;
  169. background-color:#000 ;
  170. opacity: 0.4;
  171. flex: 1;
  172. }
  173. .content{
  174. position: absolute;
  175. background-color: #fff;
  176. width: 750rpx;
  177. bottom: 0;
  178. height: 1000rpx;
  179. transform: translateY(1000rpx);
  180. flex-direction: column;
  181. justify-content: space-between;
  182. border-top-left-radius:30rpx;
  183. border-top-right-radius:30rpx;
  184. }
  185. .top{
  186. padding: 20rpx;
  187. flex-direction: row;
  188. justify-content: space-between;
  189. }
  190. .size-14{
  191. font-size: 14px;
  192. }
  193. .title{
  194. flex: 1;
  195. align-items: center;
  196. }
  197. .hideBtn{
  198. padding: 10rpx;
  199. justify-content: center;
  200. align-items: center;
  201. }
  202. /* 底部输入框 */
  203. .bottom{
  204. align-items: center;
  205. flex-direction: row;
  206. background-color: red;
  207. justify-content: space-between;
  208. }
  209. .input{
  210. box-shadow: 0 -1px 4px 1px rgba(0,0,0,0.1);
  211. font-size: 16px;
  212. flex-direction: row;
  213. align-items: center;
  214. flex: 1;
  215. height: 100rpx;
  216. padding: 30rpx;
  217. background-color: #fff;
  218. }
  219. .bottomBtn{
  220. padding: 5rpx 15rpx;
  221. border-radius:10rpx;
  222. margin-left: 30rpx;
  223. }
  224. .bottom-text{
  225. color: #fff;
  226. }
  227. /* 评论滚动区 */
  228. .srcoll-view{
  229. flex: 1;
  230. }
  231. .card{
  232. position: relative;
  233. flex-direction: row;
  234. justify-content: space-between;
  235. padding: 30rpx;
  236. }
  237. .card-left{
  238. flex-direction: row;
  239. }
  240. /* 中 */
  241. .card-content{
  242. flex: 1;
  243. }
  244. .card-image{
  245. height: 70rpx;
  246. width: 70rpx;
  247. border-radius: 50%;
  248. margin-right: 35rpx;
  249. }
  250. .card-top{
  251. height: 80rpx;
  252. justify-content: space-between;
  253. }
  254. .card-message{
  255. padding: 20rpx 0;
  256. flex-direction: row;
  257. width: 600rpx;
  258. }
  259. .card-text{
  260. flex: 1;
  261. }
  262. /* 右 */
  263. .card-right{
  264. position: absolute;
  265. right:30rpx;
  266. top:30rpx;
  267. flex-direction: row;
  268. }
  269. .card-icon{
  270. margin-left: 40rpx;
  271. margin-right: 20rpx;
  272. }
  273. </style>