douyin-scrollview.nvue 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401
  1. <template>
  2. <view style="">
  3. <!-- <view style="height: 45upx;"></view> -->
  4. <image @click="closeSheet" class="closeBnt" :src="imgHost + '/statics/images/close.png'" mode=""></image>
  5. <text class="numberComment">{{pinlunNum}}条评论</text>
  6. <view
  7. :style="'width: '+ Width +'px; height: '+ (Height/num) +'px; margin-top: 20upx; background-color: #fff; display: flex; flex-direction: column;'">
  8. <text v-if="pinlunList.length == 0"
  9. :style="'font-size: 14px; font-weight: bold; color: #a3a1a4; margin-top: 150upx; margin-left: '+ (Width/2.9) +'px; position: absolute;'">
  10. ~ 快来评论吧 ~</text>
  11. <list :show-scrollbar="false" :scrollable="true" @loadmore="loadmore" @scroll="scrolls">
  12. <cell v-for="(list,index) in pinlunList">
  13. <view :style="'width: '+ Width +'px; display: flex; flex-direction: row;'">
  14. <!-- 1.用户的头像 -->
  15. <image :src="list.avatar" mode="aspectFill" class="pictrue"></image>
  16. <!-- 2.一级评论 -->
  17. <view
  18. :style="'width: '+ (Width*0.8) +'px; display: flex; flex-direction: column; margin-top: 40upx; margin-left: 20upx;'">
  19. <!-- 3.用户名称,并自动判断是否为视频作者 -->
  20. <view style="display: flex; flex-direction: row;">
  21. <text class="name">{{list.nickname}}</text>
  22. <image v-if="list.is_money_level>0" class="vip" src="@/static/images/vip.png"></image>
  23. <!-- 4.如果是视频作者就显示 作者 -->
  24. <view v-if="list.uid == 0"
  25. style="background-color: #E43D33; border-radius: 5upx; margin-left: 15upx;">
  26. <text
  27. style="font-size: 8px; font-weight: bold; padding: 5upx; padding-left: 8upx; padding-right: 8upx; font-weight: bold; color: #FFFFFF;">商家</text>
  28. </view>
  29. </view>
  30. <!-- 5.
  31. 由于 rich-text 有很多 bug
  32. 所以这里已经摒弃了,
  33. 使用自研文本解析器
  34. -->
  35. <view @click="huifu(index)"
  36. :style="'width: '+ (Width*0.78) +'px; display: flex; flex-direction: row; flex-wrap: wrap; margin-top: 8upx;'">
  37. <text
  38. :style="'width: '+ (Width*0.78) +'px;font-size: 28rpx; font-weight: 400; color: #333; margin-left: -3upx;'">{{list.content}}</text>
  39. <!-- <rich-text :nodes="list.content"></rich-text> -->
  40. </view>
  41. <!-- 7.这里就是 时间、回复、点赞、点赞量显示的地方 -->
  42. <view
  43. :style="'width: '+ (Width*0.8) +'px; height: 40upx; display: flex; flex-direction: row; margin-top: 25upx;'">
  44. <text style="font-size: 12px; color: #a3a1a4;">{{list.add_time}} .
  45. {{list.city?list.city:''}}</text>
  46. <text @click="huifu(index)" class="time">回复</text>
  47. <!-- <text v-if="userID == list.userID" @click="deletepinlun(index)" class="time">删除</text> -->
  48. <image v-if="!list.is_like" class="like" @click="tolike(list,index)"
  49. :src="imgHost + '/statics/images/zan01.png'"></image>
  50. <image v-if="list.is_like" class="like" @click="tolike(list,index)"
  51. :src="imgHost + '/statics/images/zan02.png'"></image>
  52. <text class="likeNum" @click="tolike(list,index)">{{list.like_num}}</text>
  53. </view>
  54. <!-- 8.用户回复的子评论会显示在这里
  55. 这里 update 用于刷新视图
  56. -->
  57. <block v-for="(li,inde) in list.reply" v-if="list.isShow">
  58. <view :style="'width: '+ (Width*0.8) +'px; display: flex; flex-direction: row;'">
  59. <!-- 9.子评论 用户头像 -->
  60. <image :src="li.avatar" mode="aspectFill" class="childrenPic"></image>
  61. <!-- 10.动态计算宽度 子评论列表 -->
  62. <view
  63. :style="'width: '+ (Width*0.8*0.87) +'px; display: flex; flex-direction: column; margin-top: 40upx; margin-left: 20upx;'">
  64. <view style="display: flex; flex-direction: row;">
  65. <view style="display: flex; flex-direction: row;">
  66. <!-- 11.回复评论的人显示在这里 -->
  67. <text class="childrenName">{{li.nickname}}</text>
  68. <image v-if="li.is_money_level>0" class="vip"
  69. src="@/static/images/vip.png"></image>
  70. <!-- 12.同时要判断评论人是不是作者,如果是作者就在这里显示 -->
  71. <view v-if="li.uid==0"
  72. style="background-color: #E43D33; border-radius: 5upx; margin-left: 15upx;">
  73. <text
  74. style="font-size: 8px; font-weight: bold; padding: 5upx; padding-left: 8upx; padding-right: 8upx; font-weight: bold; color: #FFFFFF;">商家</text>
  75. </view>
  76. </view>
  77. <!-- 13.图片是一个向右的小图标 -->
  78. <!-- <image src="../../static/douyin/you-3.png" style="width: 20upx; height: 20upx; margin-top: 5upx; margin-left: 10upx;"></image> -->
  79. <!-- 14.被回复用户的名称 会显示在这里 -->
  80. <!-- <view style="display: flex; flex-direction: row; margin-left: 10upx;"> -->
  81. <!-- <text style="font-size: 12px; font-weight: bold; color: #a3a1a4;">{{li.gethuifuUser}}</text> -->
  82. <!-- 15.同时要判断评论人是不是作者,如果是作者就在这里显示 -->
  83. <!-- <view v-if="videouserID == li.gethuifuUserID" style="background-color: #E43D33; border-radius: 5upx; margin-left: 15upx;">
  84. <text style="font-size: 8px; font-weight: bold; padding: 5upx; padding-left: 8upx; padding-right: 8upx; font-weight: bold; color: #FFFFFF;">作者</text>
  85. </view> -->
  86. <!-- </view> -->
  87. </view>
  88. <!-- 16.
  89. 由于 rich-text 有很多 bug
  90. 所以这里已经摒弃了,
  91. 使用自研文本表情解析器
  92. -->
  93. <view
  94. :style="'width: '+ (Width*0.8*0.85) +'px; display: flex; flex-direction: row; flex-wrap: wrap; margin-top: 8upx;word-break: break-all;'">
  95. <text
  96. :style="'width: '+ (Width*0.8*0.85) +'px;font-size: 28rpx; font-weight: 400; color: #333; margin-left: -3upx;'">{{li.content}}</text>
  97. </view>
  98. <!-- 17.如果 子评论 用户输入了 GIF 表情,就会在这里显示 -->
  99. <!-- <image v-if="li.imageURL !== ''" :src="li.imageURL" mode="aspectFill" style="width: 140upx; height: 140upx; margin-top: 20upx; border-radius: 10upx;"></image> -->
  100. <!-- 18.这里就是 时间、回复、点赞、点赞量显示的地方 -->
  101. <view
  102. :style="'width: '+ (Width*0.8*0.87) +'px; height: 40upx; display: flex; flex-direction: row; margin-top: 16upx;'">
  103. <text style="font-size: 12px; color: #a3a1a4;">{{li.add_time}} .
  104. {{li.city?li.city:''}}</text>
  105. <!-- <text @click="sonhuifu(index,inde)" style="font-size: 12px; font-weight: bold; color: #a3a1a4; margin-left: 20upx;">回复</text> -->
  106. <!-- <text v-if="userID == li.userID" @click="deletesonpinlun(index,inde)" class="time">删除</text> -->
  107. <image class="childrenLike" v-if="!li.is_like"
  108. @click="tosonlike(index,inde,li)"
  109. :src="imgHost + '/statics/images/zan01.png'"></image>
  110. <image class="childrenLike" v-if="li.is_like"
  111. @click="tosonlike(index,inde,li)"
  112. :src="imgHost + '/statics/images/zan02.png'"></image>
  113. <text class="childrenLikeNum"
  114. @click="tosonlike(index,inde,li)">{{li.like_num}}</text>
  115. </view>
  116. </view>
  117. </view>
  118. </block>
  119. <!-- 19。显示 【展开xx条评论】、【收起评论】 -->
  120. <view v-if="list.reply_count > 0"
  121. :style="'width: '+ (Width*0.8) +'px; display: flex; flex-direction: row; margin-top: 30upx;'">
  122. <view
  123. style="width: 60upx; height: 1px; background-color: #a3a1a4; opacity: 0.6; margin-top: 13upx;">
  124. </view>
  125. <text @click="zhangkai(index,list)" v-if="list.reply_count!=list.reply.length"
  126. style="font-size: 12px; font-weight: bold; color: #cdcbd4; margin-left: 12upx;">展开{{list.reply_count}}条回复</text>
  127. <text @click="shouqi(list)" v-if="list.reply.length"
  128. style="font-size: 12px; font-weight: bold; color: #cdcbd4; margin-left: 12upx;">收起</text>
  129. </view>
  130. </view>
  131. </view>
  132. <!-- 20.留一定的高度以免视图被遮挡 -->
  133. <view v-if="index == (pinlunList.length-1)" :style="'width: '+ Width +'px; height: 80px;'"></view>
  134. </cell>
  135. </list>
  136. </view>
  137. <!-- 21.底部,模拟假的输入框 -->
  138. <view v-if="show && ischangepinlun==false" @touchstart="parentPinglun"
  139. :style="'width: '+ Width +'px; height: '+ plHeight +'px; background-color: #fff; position: fixed; bottom: 0;'">
  140. <view
  141. :style="'width: '+ (Width-30) +'px; height: 32px; margin-left: 15px; margin-top: 14upx; background-color: #eee; border-radius: 100upx; display: flex; flex-direction: row;'">
  142. <text v-if="platform=='ios'"
  143. style="font-size: 14px; color: #999; margin-top: 17upx; margin-left: 30upx;">说点什么呗~</text>
  144. <text v-if="platform!=='ios'"
  145. style="font-size: 14px; color: #999; margin-top: 13upx; margin-left: 30upx;">说点什么呗~</text>
  146. <image :src="imgHost + '/statics/images/send01.png'"
  147. style="width: 40upx; margin-top: 15upx; height: 40upx; position: absolute; right: 25upx;"></image>
  148. </view>
  149. </view>
  150. <view v-if="show && ischangepinlun==true" @touchstart="parentPinglun"
  151. :style="'width: '+ Width +'px; height: '+ plHeight +'px; background-color: #fff;'">
  152. <view
  153. :style="'width: '+ (Width-30) +'px; height: 32px;margin-left: 15px; margin-top: 20upx; background-color: #eee; border-radius: 100upx; display: flex; flex-direction: row;'">
  154. <text v-if="platform=='ios'"
  155. style="font-size: 14px; color: #a3a1a4; margin-top: 17upx; margin-left: 30upx;">说点什么呗~</text>
  156. <text v-if="platform!=='ios'"
  157. style="font-size: 14px; color: #a3a1a4; margin-top: 13upx; margin-left: 30upx;">说点什么呗~</text>
  158. <image :src="imgHost + '/statics/images/send01.png'"
  159. style="width: 40upx; margin-top: 15upx; height: 40upx; position: absolute; right: 25upx;"></image>
  160. </view>
  161. </view>
  162. <!--
  163. 下面就是真正的评论框
  164. 包含:
  165. 1.输入框
  166. 2.表情输入框
  167. 3.GIF表情库
  168. 4.最近使用表情和全部表情
  169. 5.自己上传表情
  170. 6. @ 自己的好友
  171. 7.自带微博表情 和 QQ 表情
  172. 8.能记忆输入
  173. -->
  174. <uni-popup type="bottom" ref="openPinglun" @touchmove.stop.prevent="movehandle" @change="change">
  175. <view style="display: flex; flex-direction: column;">
  176. <view @click="openPinglun"
  177. :style="'width: '+ Width +'px; background-color: #FFFFFF; display: flex; flex-direction: row;'">
  178. <view
  179. :style="'width: '+ (Width-30)*percent +'px; margin-left: 15px; margin-top: 20upx; background-color: #f2f0f4; border-radius: '+ borderRadius +'upx; margin-bottom: 20upx; display: flex; flex-direction: row;'">
  180. <!--
  181. 9.输入框
  182. -->
  183. <textarea
  184. :style="'width: '+ (Width-60)*percent +'px; height: 20px; margin-bottom: 20upx; font-size: 15px; color: #000000; margin-top: 20upx; margin-left: 30upx;'"
  185. :placeholder="placeholder" :cursor-spacing="cursorSpacing" :auto-focus="autoFocus"
  186. :auto-height="autoHeight" :adjust-position="adjustPosition" v-model="value" maxlength="150"
  187. @linechange="linechange" @keyboardheightchange="keyboardheightchange" @focus="focus"
  188. @click="clickTextarea" @blur="blur"></textarea>
  189. <!-- <image src="@/static/douyin/atuser.png" style="width: 70upx; height: 70upx; position: absolute; right: 110upx; margin-top: 8upx;"></image> -->
  190. <!-- 10.点击表情展开评论框 -->
  191. <!-- <image v-if="!isopen" @click="toemoji" src="@/static/douyin/biaoqing-2.png" style="width: 50upx; margin-top: 15upx; height: 50upx; position: absolute; right: 25upx;"></image>
  192. <image v-if="isopen" @click="toemoji" src="@/static/douyin/jianpan.png" style="width: 50upx; margin-top: 15upx; height: 50upx; position: absolute; right: 25upx;"></image> -->
  193. </view>
  194. <!-- 11.发送按钮
  195. 符合:有内容、或者是输入 GIF 图片都可以通过
  196. -->
  197. <view v-if="(value!=='' || imageURL !== '') && isSend" @click="sendSMS"
  198. style="width: 30px; height: 30px; border-radius: 40px; margin-top: 30upx; margin-left: 20upx;">
  199. <image :src="imgHost + '/statics/images/send02.png'" style="width: 30px; height: 30px;"></image>
  200. </view>
  201. </view>
  202. </view>
  203. <!-- 12.用于显示用户选择的 GIF 图片 -->
  204. <view v-if="isShowImage" :style="'width: '+ Width +'px; height: 75px; background-color: #FFFFFF;'">
  205. <view style="display: flex; flex-direction: row;">
  206. <image :src="imageURL" mode="aspectFill"
  207. style="width: 120upx; height: 120upx; margin-top: 10upx; margin-left: 50upx;"></image>
  208. <!-- <image @click="deleteimageURL" src="../../static/douyin/zfxsc.png" style="width: 30upx; height: 30upx; position: absolute; margin-left: 140upx; margin-top: 12upx;"></image> -->
  209. </view>
  210. </view>
  211. <!-- 13.
  212. 表情 区
  213. -->
  214. <view :style="'width: '+ Width +'px; height: '+ emojiHeight +'px; background-color: #FFFFFF;'">
  215. <!--
  216. isToShow:这个参数用于控制显示,不动它即可
  217. -->
  218. <block v-if="isToShow">
  219. <!-- 14.表情选择栏:
  220. 最近输入的 GIF 图在:timeEmoji
  221. 默认展示的 表情 :nowEmoji
  222. 自己上传的图片:likeEmoji
  223. GIF 图片库:gifEmoji
  224. -->
  225. <!-- <scroll-view :style="'width: '+ Width +'px; height: 40px; background-color: #FFFFFF;'" :scroll-x="true" style="display: flex; flex-direction: row;" :show-scrollbar="false">
  226. <view :style="'display: flex; flex-direction: row; width: '+ Width +'px; padding-top: 10upx; padding-bottom: 10upx; border-bottom: 1upx solid #f3f1f4;'">
  227. <view :style="'width: 90upx; height: 60upx; border-radius: 60upx; position: absolute; background-color: #f8f4f7; margin-top: -8upx; margin-left: '+ (Width*0.04)*currentNum +'px;'"></view>
  228. <image @click="timeEmoji" src="../../static/douyin/time.png" style="width: 45upx; height: 45upx; margin-left: 50upx;"></image>
  229. <image @click="nowEmoji" src="../../static/douyin/biaoqing-2.png" style="width: 50upx; height: 50upx; margin-left: 50upx; margin-top: -5upx;"></image>
  230. <image @click="likeEmoji" src="../../static/douyin/xianxing.png" style="width: 55upx; height: 55upx; margin-left: 50upx; margin-top: -5upx;"></image>
  231. <view @click="gifEmoji" style="width: 45upx; height: 45upx; border-radius: 55upx; border: 2px solid #303133; margin-left: 52upx; margin-top: 0upx;">
  232. <image src="../../static/douyin/gif-2.png" style="width: 35upx; height: 35upx;"></image>
  233. </view>
  234. </view>
  235. </scroll-view> -->
  236. <!-- 15.表情选择栏:
  237. 最近输入的 GIF 图在:timeEmoji
  238. 默认展示的 表情 :nowEmoji
  239. 自己上传的图片:likeEmoji
  240. GIF 图片库:gifEmoji
  241. -->
  242. <swiper
  243. :style="'width: '+ Width +'px; height: '+ (emojiHeight-40) +'px; background-color: #FFFFFF;'"
  244. :current="current" @change="currentChange">
  245. <swiper-item>
  246. <scroll-view
  247. :style="'width: '+ Width +'px; height: '+ (emojiHeight-40) +'px; background-color: #FFFFFF;'"
  248. :scroll-y="true">
  249. <text v-if="nowImage.length !== 0" @click="qingkonGIF"
  250. style="font-size: 12px; margin-top: 20upx; position: absolute; right: 40upx; color: #007AFF;">清空</text>
  251. <view style="display: flex; flex-direction: row; flex-wrap: wrap; margin-top: 40upx;">
  252. <block v-for="(list,index) in nowImage">
  253. <image @click="clicknowImage(index)" :src="list" mode="aspectFill"
  254. style="width: 120upx; height: 120upx; margin-top: 40upx; margin-left: 55upx;">
  255. </image>
  256. <!-- <image @click="deletenowImage(index)" src="../../static/douyin/zfxsc.png" style="width: 30upx; height: 30upx; position: absolute; right: 0; margin-top: 40upx;"></image> -->
  257. </block>
  258. <block v-if="nowImage.length == 0">
  259. <text
  260. :style="'font-size: 14px; color: #999999; margin-top: 200upx; margin-left: '+ (Width/3.2) +'px;'">~
  261. 您还没使用过图片 ~</text>
  262. </block>
  263. </view>
  264. <view :style="'width: '+ Width +'px; height: 80px;'"></view>
  265. </scroll-view>
  266. </swiper-item>
  267. <swiper-item>
  268. <scroll-view
  269. :style="'width: '+ Width +'px; height: '+ (emojiHeight-40) +'px; background-color: #FFFFFF;'"
  270. :scroll-y="true">
  271. <block v-if="nowTimeEmojiList.length !== 0">
  272. <text style="font-size: 12px; margin-top: 20upx; margin-left: 30upx;">最近使用</text>
  273. <text @click="qingkon"
  274. style="font-size: 12px; margin-top: 20upx; position: absolute; right: 40upx; color: #007AFF;">清空</text>
  275. <view
  276. style="display: flex; flex-direction: row; flex-wrap: wrap; margin-bottom: 20upx;">
  277. <!-- QQ - 表情包 -->
  278. <block v-for="(list,index) in nowTimeEmojiList">
  279. <image @click="clicknowTimeEmoji(index)"
  280. :src="'../../static/emojis/qq/'+list.url+''"
  281. style="width: 35px; height: 35px; margin-top: 30upx; margin-left: 36upx;">
  282. </image>
  283. </block>
  284. <!-- 新浪微博 - 表情包 -->
  285. <!-- <block v-for="(list,index) in sinaEmojilist">
  286. <image @click="clicksinaEmoji(index)" :src="list.url" style="width: 35px; height: 35px; margin-top: 30upx; margin-left: 36upx;"></image>
  287. </block> -->
  288. </view>
  289. </block>
  290. <text style="font-size: 12px; margin-top: 20upx; margin-left: 30upx;">全部表情</text>
  291. <view style="display: flex; flex-direction: row; flex-wrap: wrap;">
  292. <!-- QQ - 表情包 -->
  293. <block v-for="(list,index) in emojilist">
  294. <image @click="clickEmoji(index)" :src="'../../static/emojis/qq/'+list.url+''"
  295. style="width: 35px; height: 35px; margin-top: 30upx; margin-left: 36upx;">
  296. </image>
  297. </block>
  298. <!-- 新浪微博 - 表情包 -->
  299. <!-- <block v-for="(list,index) in sinaEmojilist">
  300. <image @click="clicksinaEmoji(index)" :src="list.url" style="width: 35px; height: 35px; margin-top: 30upx; margin-left: 36upx;"></image>
  301. </block> -->
  302. </view>
  303. <view :style="'width: '+ Width +'px; height: 80px;'"></view>
  304. </scroll-view>
  305. <view v-if="platform=='ios'"
  306. style="position: absolute; display: flex; flex-direction: row; bottom: 0; right: 0; width: 300upx; height: 160upx; background-color: #FFFFFF; box-shadow: -20px -40px 20px 60upx #FFFFFF; border-radius: 2upx;">
  307. <view @click="undo"
  308. style="width: 130upx; height: 60upx; margin-top: 20upx; border-radius: 40upx; border: 1upx solid #c6c5c8;">
  309. <!-- <image src="../../static/douyin/shanchu-3.png" style="width: 45upx; height: 30upx; margin-top: 15upx; margin-left: 40upx;"></image> -->
  310. </view>
  311. <!-- 16.发送按钮
  312. 符合:有内容、或者是输入 GIF 图片都可以通过
  313. -->
  314. <view v-if="(value!=='' || imageURL !== '') && isSend" @click="sendSMS"
  315. style="width: 130upx; height: 60upx; margin-top: 20upx; margin-left: 20upx; border-radius: 40upx; background-color: #ff1a63;">
  316. <text
  317. style="font-size: 14px; font-weight: bold; text-align: center; color: #FFFFFF; padding-top: 10upx;">发送</text>
  318. </view>
  319. <view v-if="(value == '' && imageURL == '') && isSend"
  320. style="width: 130upx; height: 60upx; margin-top: 20upx; margin-left: 20upx; border-radius: 40upx; background-color: #bab9bb;">
  321. <text
  322. style="font-size: 14px; font-weight: bold; text-align: center; color: #FFFFFF; padding-top: 10upx;">发送</text>
  323. </view>
  324. </view>
  325. <view v-if="platform!=='ios'"
  326. style="position: absolute; display: flex; flex-direction: row; bottom: 20upx; right: 20upx; width: 300upx; height: 80upx; padding: 10upx; background-color: #eceef1; border-radius: 20upx;">
  327. <view @click="undo"
  328. style="width: 130upx; height: 60upx; margin-top: 0; border-radius: 40upx; border: 1upx solid #c6c5c8;">
  329. <image src="../../static/douyin/shanchu-3.png"
  330. style="width: 45upx; height: 30upx; margin-top: 15upx; margin-left: 40upx;">
  331. </image>
  332. </view>
  333. <!-- 16.发送按钮
  334. 符合:有内容、或者是输入 GIF 图片都可以通过
  335. -->
  336. <view v-if="(value!=='' || imageURL !== '') && isSend" @click="sendSMS"
  337. style="width: 130upx; height: 60upx; margin-top: 0; margin-left: 20upx; border-radius: 40upx; background-color: #ff1a63;">
  338. <text
  339. style="font-size: 14px; font-weight: bold; text-align: center; color: #FFFFFF; padding-top: 10upx;">发送</text>
  340. </view>
  341. <view v-if="(value == '' && imageURL == '') && isSend"
  342. style="width: 130upx; height: 60upx; margin-top: 0; margin-left: 20upx; border-radius: 40upx; background-color: #bab9bb;">
  343. <text
  344. style="font-size: 14px; font-weight: bold; text-align: center; color: #FFFFFF; padding-top: 10upx;">发送</text>
  345. </view>
  346. </view>
  347. </swiper-item>
  348. <swiper-item>
  349. <scroll-view
  350. :style="'width: '+ Width +'px; height: '+ (emojiHeight-40) +'px; background-color: #FFFFFF;'"
  351. :scroll-y="true">
  352. <view style="display: flex; flex-direction: row; flex-wrap: wrap;">
  353. <view v-if="platform=='ios'" @click="addlikeImage"
  354. style="width: 120upx; height: 120upx; border-radius: 10upx; border: 1upx dashed #000000; margin-top: 40upx; margin-left: 55upx;">
  355. <!-- <image src="../../static/douyin/jia-9.png" style="width: 50upx; height: 50upx; margin-top: 35upx; margin-left: 35upx;"></image> -->
  356. </view>
  357. <view v-if="platform!=='ios'" @click="addlikeImage"
  358. style="width: 120upx; height: 120upx; border-radius: 10upx; border: 1px solid #000000; margin-top: 40upx; margin-left: 55upx;">
  359. <!-- <image src="../../static/douyin/jia-9.png" style="width: 50upx; height: 50upx; margin-top: 35upx; margin-left: 35upx;"></image> -->
  360. </view>
  361. <block v-for="(list,index) in likeImage">
  362. <image @click="clickLikeImage(index)" :src="list" mode="aspectFill"
  363. style="width: 120upx; height: 120upx; margin-top: 40upx; margin-left: 55upx;">
  364. </image>
  365. <!-- <image @click="deleteImage(index)" src="../../static/douyin/zfxsc.png" style="width: 30upx; height: 30upx; position: absolute; right: 0; margin-top: 40upx;"></image> -->
  366. </block>
  367. </view>
  368. <view :style="'width: '+ Width +'px; height: 80px;'"></view>
  369. </scroll-view>
  370. </swiper-item>
  371. <swiper-item>
  372. <scroll-view
  373. :style="'width: '+ Width +'px; height: '+ (emojiHeight-40) +'px; background-color: #FFFFFF;'"
  374. :scroll-y="true" @scrolltolower="scrolltolowerGIF">
  375. <view style="display: flex; flex-direction: row; flex-wrap: wrap;">
  376. <view v-if="platform=='ios'" @click="searchGIF"
  377. style="width: 120upx; height: 120upx; border-radius: 10upx; border: 1upx dashed #000000; margin-top: 40upx; margin-left: 55upx;">
  378. <!-- <image src="../../static/douyin/sousuo-7.png" style="width: 50upx; height: 50upx; margin-top: 35upx; margin-left: 35upx;"></image> -->
  379. </view>
  380. <view v-if="platform!=='ios'" @click="searchGIF"
  381. style="width: 120upx; height: 120upx; border-radius: 10upx; border: 1px solid #000000; margin-top: 40upx; margin-left: 55upx;">
  382. <!-- <image src="../../static/douyin/sousuo-7.png" style="width: 50upx; height: 50upx; margin-top: 35upx; margin-left: 35upx;"></image> -->
  383. </view>
  384. <block v-for="(list,index) in gifAndpnglist">
  385. <image @click="clickGIF(index)" :src="list.url" mode="aspectFill"
  386. style="width: 120upx; height: 120upx; margin-top: 40upx; margin-left: 55upx;">
  387. </image>
  388. </block>
  389. </view>
  390. <view :style="'width: '+ Width +'px; height: 80px;'"></view>
  391. </scroll-view>
  392. </swiper-item>
  393. </swiper>
  394. </block>
  395. <block v-if="!isToShow">
  396. <!-- 这里为空即可,不加任何东西 -->
  397. </block>
  398. </view>
  399. </uni-popup>
  400. <!-- 1.
  401. 这个弹窗用于搜索 GIF
  402. -->
  403. <uni-popup type="bottom" ref="searchEmoji" @touchmove.stop.prevent="movesearch" @change="searchGIFChange">
  404. <view v-if="searchGIFValue !== ''"
  405. :style="'width: '+ Width +'px; height: 80px; border-bottom: 1upx solid #e3e1e5; background-color: #FFFFFF; border-top-left-radius: 20upx; border-top-right-radius: 20upx;'">
  406. <!-- 2.
  407. 搜出来的 GIF 都在这里
  408. -->
  409. <scroll-view
  410. :style="'width: '+ Width +'px; height: 80px; border-bottom: 1upx solid #e3e1e5; display: flex; flex-direction: row;'"
  411. :scroll-x="true" style="display: flex; flex-direction: row;" :show-scrollbar="false">
  412. <block v-for="(list,index) in GifList">
  413. <image @click="selectGIF(index)" :src="list.url" mode="aspectFill"
  414. style="width: 120upx; height: 120upx; margin-top: 20upx; margin-left: 20upx;"></image>
  415. </block>
  416. <view style="width: 20upx; height: 120upx; margin-left: 10upx;"></view>
  417. </scroll-view>
  418. </view>
  419. <!-- 3.
  420. 动态图输入框
  421. -->
  422. <view :style="'width: '+ Width +'px; background-color: #FFFFFF; display: flex; flex-direction: row;'">
  423. <view
  424. :style="'width: '+ (Width-30) +'px; margin-left: 15px; margin-top: 20upx; background-color: #FFFFFF; margin-bottom: 20upx; display: flex; flex-direction: row;'">
  425. <input
  426. :style="'width: '+ (Width*0.8) +'px; height: 20px; margin-bottom: 20upx; font-size: 15px; color: #000000; margin-top: 15upx; margin-left: 30upx;'"
  427. placeholder="搜索表情包" v-model="searchGIFValue" :auto-focus="false" :adjust-position="false"
  428. @blur="blurGIF" />
  429. <!-- <image v-if="searchGIFValue !== ''" @click="clearSearchValue" src="../../static/douyin/chacha-4.png" style=" width: 25upx; height: 25upx; margin-top: 20upx; margin-left: 30upx;"></image> -->
  430. </view>
  431. </view>
  432. <view v-if="platform=='ios'"
  433. :style="'width: '+ Width +'px; height: '+ (emojiHeight+40) +'px; background-color: #FFFFFF;'">
  434. <!-- 这里不要动就行 -->
  435. </view>
  436. <view v-if="platform!=='ios'"
  437. :style="'width: '+ Width +'px; height: '+ emojiHeight +'px; background-color: #FFFFFF;'">
  438. <!-- 这里不要动就行 -->
  439. </view>
  440. </uni-popup>
  441. </view>
  442. </template>
  443. <script>
  444. // 1.先引入表情库,(完全手撸,十分繁琐)(这个是 QQ 的表情库)
  445. // import emojiList from '../../common/emoji/biaoqin.js'
  446. // 2.这个表情库是新浪微博 的表情库
  447. // import sinaEmojiList from '../../common/emoji/sina.js'
  448. // 3.这个一定要引入进来,用来解析生成的 <html>【🌟🌟🌟🌟🌟】十分重要【这里已经对原来的文件进行了改编】
  449. import parsehtml from '../../common/html-parse/parse_html.js'
  450. // 4.这里引入时间函数 用来上传时用的
  451. import time from '../../common/time-utils/currentData.js'
  452. import {
  453. HTTP_REQUEST_URL
  454. } from '@/config/app';
  455. import {
  456. commentList,
  457. markeComment,
  458. replyCommentList,
  459. replyCommentLike
  460. } from '@/api/short-video.js';
  461. import {
  462. mapGetters
  463. } from 'vuex';
  464. export default {
  465. name: "douyin-scrollview",
  466. props: {
  467. Width: {
  468. type: Number,
  469. default: 0
  470. },
  471. Height: {
  472. type: Number,
  473. default: 0
  474. },
  475. deleteIOSHeight: {
  476. type: Number,
  477. default: 0
  478. },
  479. deleteAndroidHeight: {
  480. type: Number,
  481. default: 0
  482. }
  483. },
  484. computed: mapGetters(['uid']),
  485. data() {
  486. return {
  487. videoID: 0,
  488. pinlunNum: 0,
  489. // 每一个参数都重要
  490. // 解释如下:
  491. // ----- start ----- 评论输入框部分
  492. num: 1.15, //用来处理评论的高度
  493. plHeight: 0, //评论高度
  494. value: "", //用户在输入框输入信息的数据
  495. autoHeight: false, //这个默认即可(用于评论框自动适应高度)
  496. borderRadius: 100, //评论框圆角大小
  497. lineheight: 0, //默认即可(用于处理评论框高度)
  498. percent: 1, //默认(用于处理发送按钮已经评论框宽度)
  499. show: true, //默认(是否显示评论框)
  500. emojiHeight: 0, //表情区域的高度
  501. emojiheight: 0, //用于处理表情区域的高度
  502. cursorSpacing: 20, //键盘距离输入框的距离
  503. autoFocus: true, //是否自动聚焦(默认聚焦)
  504. isopen: false, //(默认不展开)
  505. isToShow: false, //默认
  506. adjustPosition: false, //默认
  507. placeholder: "说点什么呗~",
  508. //
  509. current: 1, //当前切换的位置
  510. emojilist: [], //表情数组
  511. nowTimeEmojiList: [], //最近输入的表情
  512. sinaEmojilist: [], //新浪微博表情
  513. currentNum: 4.4, //默认
  514. likeImage: [], //默认
  515. nowImage: [], //默认
  516. gifAndpngList: [], //默认
  517. gifAndpnglist: [], //默认
  518. searchGIFValue: "", //默认
  519. isSearcopen: false, //默认
  520. GifList: [], //默认
  521. isShowImage: false, //默认
  522. imageURL: "", //默认
  523. platform: "", //默认
  524. systemVerson: "", //系统版本
  525. ischangepinlun: true, //默认显示全面屏手机评论样式
  526. // ----- end ----- 评论输入框部分
  527. // ----- start ----- 评论内容部分
  528. pinlunList: [], //用于在界面展示的 评论数组
  529. pinlunListX: [], //这个是用来存储原始评论数据的数组
  530. pinlun_list: [], //用于存储界面 评论数组 的副本
  531. isSend: true, //默认
  532. userID: "", //当前用户的 ID
  533. videouserID: "", //当前视频作者的 ID
  534. update: true, //用于刷新视图
  535. huifuUser: "", //回复信息的人的名字
  536. gethuifuUser: "", //被回复的人(也就是接收者的名字)
  537. gethuifuUserID: "", //被回复的人的 ID
  538. istohuifu: false, //是否是去回复(默认不是)
  539. huifuindex: -1, //回复信息所在下标
  540. iszhangkai: false, //默认不展开评论
  541. imgHost: HTTP_REQUEST_URL,
  542. // ----- end ----- 评论内容部分
  543. limit: 10,
  544. page: 1,
  545. pages: 1,
  546. parentNum: 0
  547. };
  548. },
  549. watch: {
  550. // 监听 输入表情值 并搜索 GIF 表情
  551. searchGIFValue(val) {
  552. this.isopen = false;
  553. if (val !== '') {
  554. var sms = []
  555. for (let i = 0; i < this.gifAndpngList.length; i++) {
  556. if (this.gifAndpngList[i].name.indexOf(val) !== -1) {
  557. sms.push(this.gifAndpngList[i]);
  558. }
  559. }
  560. this.GifList = sms;
  561. }
  562. },
  563. // 监听 输入框输入数据
  564. value(val) {
  565. if (val == "") {
  566. this.autoHeight = false
  567. if (this.imageURL !== '') {
  568. this.percent = 0.9
  569. } else {
  570. this.percent = 1
  571. }
  572. } else {
  573. this.autoHeight = true
  574. this.percent = 0.9
  575. }
  576. },
  577. // 监听 GIF图片(用户选择一个 GIF 图片以后这个值就会被赋值)
  578. imageURL(val) {
  579. if (val !== '') {
  580. this.percent = 0.9
  581. } else {
  582. if (this.value == '') {
  583. this.percent = 1
  584. }
  585. }
  586. },
  587. // 监听 输入框 高度变化
  588. lineheight(newVal, oldVal) {
  589. if (Math.abs(newVal) < 30) {
  590. this.borderRadius = 100
  591. } else {
  592. this.borderRadius = 30
  593. }
  594. }
  595. },
  596. /*
  597. 打开组件之后开始执行下面方法
  598. */
  599. created() {
  600. // 1.isToShow 用于输入框显示(默认不改)
  601. this.isToShow = false;
  602. // 2.判断当前设备信息
  603. var model = uni.getSystemInfoSync().model;
  604. // 3.判断当前设备信息
  605. this.platform = uni.getSystemInfoSync().platform;
  606. // 3.1 获取系统版本
  607. var systemVerson = uni.getSystemInfoSync().system
  608. if (systemVerson.split(' ')[0] == "Android") {
  609. if (systemVerson.split(' ')[1] < 9) {
  610. // 低端安卓机
  611. this.ischangepinlun = false //小于安卓 8
  612. this.windowHeight = uni.getSystemInfoSync().screenHeight;
  613. this.emojiHeight = this.windowHeight / 2.1 - this.deleteAndroidHeight;
  614. } else {
  615. // 全面屏安卓机
  616. this.ischangepinlun = true //全面屏
  617. this.windowHeight = uni.getSystemInfoSync().screenHeight;
  618. this.emojiHeight = this.windowHeight / 2.6 - this.deleteAndroidHeight;
  619. }
  620. } else {
  621. if (uni.getSystemInfoSync().platform == 'ios' && (model !== 'iPhone6' || model !== 'iPhone6s' || model !==
  622. 'iPhone7' || model !== 'iPhone8')) {
  623. // 全面屏iPhone
  624. this.ischangepinlun = true //全面屏
  625. this.windowHeight = uni.getSystemInfoSync().screenHeight;
  626. this.emojiHeight = this.windowHeight / 2.2 - this.deleteIOSHeight;
  627. } else {
  628. // 非全面屏iPhone
  629. this.ischangepinlun = false
  630. this.windowHeight = uni.getSystemInfoSync().screenHeight;
  631. this.emojiHeight = this.windowHeight / 2.1 - this.deleteIOSHeight;
  632. }
  633. }
  634. // 4.获取当前 视频 ID
  635. this.videoID = uni.getStorageSync("videoID");
  636. //4.1获取当前 视频 数量
  637. this.pinlunNum = uni.getStorageSync("pinlunNum");
  638. // 5.获取当前 用户 ID
  639. this.userID = uni.getStorageSync("user")._id;
  640. // 6.获取评论信息
  641. this.getnewpinlun();
  642. // 7.根据设备信息,处理评论区域高度
  643. if (uni.getSystemInfoSync().platform == 'ios' && (model !== 'iPhone6' || model !== 'iPhone6s' || model !==
  644. 'iPhone7' || model !== 'iPhone8')) {
  645. this.num = 1.25
  646. } else {
  647. this.num = 1.15
  648. }
  649. if (uni.getSystemInfoSync().platform == 'ios') {
  650. this.adjustPosition = true
  651. } else {
  652. this.adjustPosition = false
  653. }
  654. this.plHeight = this.Height - (this.Height / this.num);
  655. console.log(this.plHeight);
  656. // 8.聚焦输入
  657. this.focus();
  658. // 9.判断是否有 GIF 图片
  659. if (this.imageURL !== '') {
  660. this.percent = 0.9
  661. }
  662. // 10.把之前准备好的 emoji 表情赋值给 数组,用于展示
  663. // this.emojilist = emojiList
  664. // this.sinaEmojilist = sinaEmojiList
  665. // 11.看看有没有喜欢的 GIF,有的话赋值
  666. this.likeImage = uni.getStorageSync("likeImage");
  667. // 11.看看有没有当前的 GIF,有的话赋值
  668. this.nowImage = uni.getStorageSync("nowImage");
  669. // 11.看看有没有当前的 emoji ,有的话赋值
  670. this.nowTimeEmojiList = uni.getStorageSync("nowTimeEmojiList");
  671. // 12.请求 GIF 表情库(这里的表情库都存在 json 文件里面了)
  672. /*
  673. 1.资源来源
  674. GitHub:https://github.com/zhaoolee/ChineseBQB
  675. Gitee:https://gitee.com/mirrors/ChineseBQB
  676. 这两个库 数据都是同步的,可以去参考,国内的话可以用 gitee 访问下载,如何丢到服务器里面
  677. */
  678. // uni.request({
  679. // url: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-bdb24c6d-8c19-4f80-8e7e-c9c9f037f131/bf6f0d2e-e065-4685-a104-218c42add104.json',
  680. // success: (res) => {
  681. // var gifAndpngList = res.data.data
  682. // var sms = []
  683. // for(let i=0;i<gifAndpngList.length;i++){
  684. // /*
  685. // 它的资源很多,这里只获取 gif 部分
  686. // */
  687. // if(gifAndpngList[i].name.indexOf("gif") !== -1){
  688. // sms.push(gifAndpngList[i])
  689. // }
  690. // }
  691. // this.gifAndpngList = sms
  692. // }
  693. // })
  694. },
  695. methods: {
  696. /*
  697. ---- 第一段,这里面含有 http 后台真实请求,以及返回处理的操作以及数据
  698. 【🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟】
  699. ---- start ----
  700. */
  701. getnewpinlun() {
  702. // 这里是对评论信息做处理
  703. commentList(this.videoID, {
  704. limit: 10,
  705. page: this.pages
  706. }).then(res => {
  707. this.pages = this.pages + 1
  708. this.pinlunList = this.pinlunList.concat(res.data);
  709. }).catch(err => {
  710. return uni.showToast({
  711. title: err,
  712. icon: 'none',
  713. duration: 2000
  714. });
  715. })
  716. },
  717. sendSMS() {
  718. this.isSend = false;
  719. uni.showLoading({
  720. title: '正在发送...'
  721. })
  722. let pid = this.parentNum ? 0 : this.pinlunList[this.huifuindex].id;
  723. let data = {
  724. id: this.videoID,
  725. pid: pid,
  726. content: this.value
  727. }
  728. markeComment(data).then(res => {
  729. uni.hideLoading();
  730. this.pinlunNum = this.pinlunNum + 1;
  731. this.$emit('pinlunFun', this.pinlunNum)
  732. this.value = "";
  733. this.imageURL = "";
  734. this.$refs.openPinglun.close();
  735. this.isSend = true;
  736. this.pages = 1;
  737. this.pinlunList = [];
  738. this.getnewpinlun();
  739. }).catch(err => {
  740. return uni.showToast({
  741. title: err,
  742. icon: 'none',
  743. duration: 2000
  744. });
  745. });
  746. },
  747. loadmore() {
  748. this.getnewpinlun();
  749. },
  750. scrolls() {},
  751. tolike(item, index) {
  752. // 处理评论
  753. replyCommentLike('like', item.id).then(res => {
  754. this.pinlunList[index].is_like = !this.pinlunList[index].is_like
  755. const video = this.pinlunList[index];
  756. item.is_like ? video.like_num += 1 : video.like_num -= 1;
  757. }).catch(err => {
  758. return uni.showToast({
  759. title: err,
  760. icon: 'none',
  761. duration: 2000
  762. });
  763. })
  764. },
  765. tosonlike(index, inde, item) {
  766. replyCommentLike('like', item.id).then(res => {
  767. this.pinlunList[index].reply[inde].is_like = !this.pinlunList[index].reply[inde].is_like
  768. const video = this.pinlunList[index].reply[inde];
  769. item.is_like ? video.like_num += 1 : video.like_num -= 1;
  770. }).catch(err => {
  771. return uni.showToast({
  772. title: err,
  773. icon: 'none',
  774. duration: 2000
  775. });
  776. })
  777. },
  778. zhangkai(index, item) {
  779. // 1.点击展开评论,一开始是不展开的(如果点击展开,就把 评论的副本的子评论赋值给当前页面页面评论,这样当前页面就可以显示子评论了)
  780. if (item.isShow == undefined || item.isShow == 'undefined') {
  781. this.page = 1;
  782. }
  783. replyCommentList(item.id, {
  784. limit: this.limit,
  785. page: this.page
  786. }).then(res => {
  787. this.page = this.page + 1;
  788. item.reply = item.reply.concat(res.data);
  789. if (item.reply.length) {
  790. item.isShow = true;
  791. }
  792. this.$set(this, 'pinlunList', this.pinlunList);
  793. }).catch(err => {
  794. return uni.showToast({
  795. title: err,
  796. icon: 'none',
  797. duration: 2000
  798. });
  799. })
  800. },
  801. shouqi(item) {
  802. this.page = 1
  803. item.reply = [];
  804. item.isShow = false;
  805. this.$set(this, 'pinlunList', this.pinlunList);
  806. },
  807. deletesonpinlun(index, inde) {},
  808. // deletepinlun(index){
  809. // // 删除 评论(子评论也将被删除)
  810. // uni.showModal({
  811. // title: '确定删除?',
  812. // content: '删除后子评论将被删除',
  813. // success: (re) => {
  814. // if(re.confirm){
  815. // uni.showLoading({
  816. // title: "正在删除"
  817. // })
  818. // var sms = []
  819. // for(let i=0;i<this.pinlunListX.length;i++){
  820. // if(i !== ((this.pinlunListX.length-1)-index)){
  821. // sms.push(this.pinlunListX[i]);
  822. // }
  823. // }
  824. // // console.log(this.pinlunListX)
  825. // uni.request({
  826. // url: 'https://bdb24c6d-8c19-4f80-8e7e-c9c9f037f131.bspapp.com/video',
  827. // method: 'POST',
  828. // data:{
  829. // info: 'add_pinlun',
  830. // _id: this.videoID,
  831. // pinlun: sms
  832. // },
  833. // success: (resx) => {
  834. // uni.hideLoading();
  835. // this.getnewpinlun();
  836. // }
  837. // })
  838. // }
  839. // }
  840. // })
  841. // },
  842. addlikeImage() {
  843. uni.showModal({
  844. title: '⏰演示项目提醒⏰',
  845. content: '请前往 douyin-scrollview.nvue组件\naddlikeImage()函数进行配置',
  846. success: () => {}
  847. })
  848. },
  849. /*
  850. 【🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟🌟】
  851. ----- end -----
  852. */
  853. sonhuifu(index, inde) {
  854. // 1.子评论回复
  855. /*
  856. (1)先处理回复人信息
  857. (2)处理被回复人信息
  858. (3)改变 “发送” 状态
  859. (4)打开评论框
  860. */
  861. this.huifuUser = uni.getStorageSync("user").username;
  862. this.gethuifuUser = this.pinlunList[index].sonPinlun[inde].username;
  863. this.gethuifuUserID = this.pinlunList[index].sonPinlun[inde].userID;
  864. this.istohuifu = true;
  865. this.placeholder = "回复:" + this.gethuifuUser;
  866. this.huifuindex = index;
  867. this.openPinglun();
  868. },
  869. huifu(index) {
  870. // 1.评论回复
  871. /*
  872. (1)先处理回复人信息
  873. (2)处理被回复人信息
  874. (3)改变 “发送” 状态
  875. (4)打开评论框
  876. */
  877. this.parentNum = 0;
  878. this.placeholder = "回复:" + this.pinlunList[index].nickname;
  879. this.huifuindex = index;
  880. this.openPinglun();
  881. },
  882. clicknowImage(index) {
  883. // 点击 GIF 图片信息
  884. this.imageURL = this.nowImage[index];
  885. this.isShowImage = true;
  886. },
  887. selectGIF(index) {
  888. // 选择 GIF 图片
  889. /*
  890. (1)获取 GIF 链接
  891. (2)清理搜索的 GIF 输入框信息
  892. (3)缓存 GIF 图片信息
  893. */
  894. this.imageURL = this.GifList[index].url;
  895. this.isShowImage = true;
  896. this.searchGIFValue = ""
  897. this.$refs.searchEmoji.close();
  898. if (uni.getStorageSync("nowImage").length == 0) {
  899. this.nowImage = []
  900. this.nowImage.push(this.imageURL)
  901. uni.setStorageSync("nowImage", this.nowImage);
  902. } else {
  903. this.nowImage = uni.getStorageSync("nowImage");
  904. let isTrue = true;
  905. for (let i = 0; i < this.nowImage.length; i++) {
  906. if (this.imageURL == this.nowImage[i]) {
  907. isTrue = false;
  908. }
  909. }
  910. if (isTrue) {
  911. this.nowImage.push(this.imageURL)
  912. }
  913. uni.setStorageSync("nowImage", this.nowImage);
  914. }
  915. },
  916. deleteimageURL() {
  917. // 清理 GIF 图片
  918. this.imageURL = "";
  919. this.isShowImage = false;
  920. },
  921. clickGIF(index) {
  922. // 在选择 GIF 列表,点击 GIF 图片,选择图片
  923. /*
  924. (1)获取 GIF 链接
  925. (2)清理搜索的 GIF 输入框信息
  926. (3)缓存 GIF 图片信息
  927. */
  928. this.imageURL = this.gifAndpnglist[index].url;
  929. this.isShowImage = true;
  930. if (uni.getStorageSync("nowImage").length == 0) {
  931. this.nowImage = []
  932. this.nowImage.push(this.imageURL)
  933. uni.setStorageSync("nowImage", this.nowImage);
  934. } else {
  935. this.nowImage = uni.getStorageSync("nowImage");
  936. let isTrue = true;
  937. for (let i = 0; i < this.nowImage.length; i++) {
  938. if (this.imageURL == this.nowImage[i]) {
  939. isTrue = false;
  940. }
  941. }
  942. if (isTrue) {
  943. this.nowImage.push(this.imageURL)
  944. }
  945. uni.setStorageSync("nowImage", this.nowImage);
  946. }
  947. },
  948. clearSearchValue() {
  949. // 点击搜索 GIF 的小叉叉,清理输入的值
  950. this.searchGIFValue = ""
  951. },
  952. blurGIF() {
  953. // 搜索 GIF 图片失去聚焦时
  954. // 关闭 GIF 输入框
  955. if (this.searchGIFValue == '') {
  956. this.$refs.searchEmoji.close();
  957. }
  958. },
  959. searchGIF() {
  960. // 点击搜索 GIF 图片
  961. // 打开输入框
  962. if (uni.getSystemInfoSync().platform == 'ios') {
  963. this.$refs.searchEmoji.open('bottom');
  964. } else {
  965. setTimeout(() => {
  966. this.$refs.searchEmoji.open('bottom');
  967. }, 500)
  968. }
  969. },
  970. deletenowImage(index) {
  971. // 删除当前图片
  972. var sms = []
  973. for (let i = 0; i < this.nowImage.length; i++) {
  974. if (this.nowImage[i] !== this.nowImage[index]) {
  975. sms.push(this.nowImage[i])
  976. }
  977. }
  978. this.nowImage = sms;
  979. uni.setStorageSync("nowImage", this.nowImage);
  980. },
  981. clickLikeImage(index) {
  982. // 点击喜欢的图片之后
  983. /*
  984. (1)获取图片信息
  985. (2)缓存图片 在本地
  986. */
  987. if (uni.getStorageSync("nowImage").length == 0) {
  988. this.nowImage = []
  989. this.nowImage.push(this.likeImage[index])
  990. uni.setStorageSync("nowImage", this.nowImage);
  991. } else {
  992. this.nowImage = uni.getStorageSync("nowImage");
  993. let isTrue = true;
  994. for (let i = 0; i < this.nowImage.length; i++) {
  995. if (this.likeImage[index] == this.nowImage[i]) {
  996. isTrue = false;
  997. }
  998. }
  999. if (isTrue) {
  1000. this.nowImage.push(this.likeImage[index])
  1001. }
  1002. uni.setStorageSync("nowImage", this.nowImage);
  1003. }
  1004. },
  1005. deleteImage(index) {
  1006. // 删除 图片
  1007. /*
  1008. (1)更新当前 GIF 图片列表
  1009. (2)同时去看看 最近使用图片里面有没有当前要删除的图片,
  1010. 如果有的话就一同删除掉
  1011. */
  1012. uni.showModal({
  1013. title: '确定删除?',
  1014. success: (re) => {
  1015. if (re.confirm) {
  1016. uni.removeSavedFile({
  1017. filePath: this.likeImage[index],
  1018. success: () => {
  1019. var sms = []
  1020. for (let i = 0; i < this.likeImage.length; i++) {
  1021. if (this.likeImage[i] !== this.likeImage[index]) {
  1022. sms.push(this.likeImage[i])
  1023. }
  1024. }
  1025. var smh = []
  1026. for (let i = 0; i < this.nowImage.length; i++) {
  1027. if (this.nowImage[i] !== this.likeImage[index]) {
  1028. smh.push(this.nowImage[i])
  1029. }
  1030. }
  1031. this.nowImage = smh;
  1032. uni.setStorageSync("nowImage", this.nowImage);
  1033. this.likeImage = sms;
  1034. uni.setStorageSync("likeImage", this.likeImage);
  1035. }
  1036. });
  1037. }
  1038. }
  1039. })
  1040. },
  1041. qingkonGIF() {
  1042. // 清空当前 GIF 图片
  1043. uni.showModal({
  1044. title: '确定清空?',
  1045. success: (re) => {
  1046. if (re.confirm) {
  1047. this.nowImage = []
  1048. uni.removeStorageSync("nowImage");
  1049. }
  1050. }
  1051. })
  1052. },
  1053. searchGIFChange(e) {
  1054. },
  1055. change(e) {
  1056. // 输入框开关变化
  1057. /*
  1058. (1)如果打开输入框(show == true)
  1059. - 此时请求 GIF 列表图片信息
  1060. (2)如果关闭输入框
  1061. - 恢复默认设置
  1062. */
  1063. this.isToShow = false;
  1064. if (e.show == true) {
  1065. this.show = false;
  1066. this.getGif();
  1067. } else {
  1068. uni.hideKeyboard();
  1069. this.show = true
  1070. this.autoFocus = true;
  1071. this.isopen = false;
  1072. this.current = 1;
  1073. this.currentNum = 4.4;
  1074. this.isShowImage = false;
  1075. this.cursorSpacing = 20;
  1076. this.placeholder = "说点什么呗~";
  1077. this.istohuifu = false;
  1078. }
  1079. },
  1080. /*
  1081. 以下方法都是输入框 状态变化,以及逻辑切换等信息
  1082. 虽然不起眼但是很重要 【🌟🌟🌟🌟🌟】
  1083. (如果是要复制的话都是要复制的)
  1084. */
  1085. // ------- start -------
  1086. clickTextarea() {
  1087. this.isopen = false;
  1088. if (uni.getSystemInfoSync().platform == 'ios') {
  1089. this.autoFocus = false;
  1090. setTimeout(() => {
  1091. this.autoFocus = true;
  1092. }, 200)
  1093. }
  1094. },
  1095. closeSheet() {
  1096. this.$emit('closeScrollview');
  1097. },
  1098. movehandle() {},
  1099. movesearch() {},
  1100. parentPinglun() {
  1101. this.parentNum = 1;
  1102. this.openPinglun();
  1103. },
  1104. openPinglun() {
  1105. this.$refs.openPinglun.open('bottom')
  1106. },
  1107. linechange(event) {
  1108. this.lineheight = event.detail.height
  1109. },
  1110. keyboardheightchange() {},
  1111. blur() {
  1112. uni.hideKeyboard();
  1113. },
  1114. focus() {
  1115. if (uni.getSystemInfoSync().platform == 'ios') {
  1116. this.autoFocus = false;
  1117. this.isopen = true;
  1118. }
  1119. setTimeout(() => {
  1120. this.autoFocus = true;
  1121. this.isopen = false;
  1122. setTimeout(() => {
  1123. if (uni.getSystemInfoSync().platform == 'ios') {
  1124. this.isToShow = true;
  1125. }
  1126. if (this.imageURL !== '') {
  1127. this.isShowImage = true;
  1128. }
  1129. }, 1500)
  1130. }, 20)
  1131. },
  1132. toemoji() {
  1133. if (this.isopen == false) {
  1134. this.isopen = true;
  1135. setTimeout(() => {
  1136. this.isToShow = true;
  1137. }, 500)
  1138. uni.hideKeyboard();
  1139. } else {
  1140. if (uni.getSystemInfoSync().platform == 'ios') {
  1141. this.isShowImage = false;
  1142. } else {
  1143. this.isToShow = false;
  1144. }
  1145. this.isopen = false;
  1146. this.autoFocus = false;
  1147. setTimeout(() => {
  1148. this.autoFocus = true;
  1149. if (this.imageURL !== '') {
  1150. setTimeout(() => {
  1151. this.isShowImage = true;
  1152. }, 1300)
  1153. }
  1154. }, 20)
  1155. }
  1156. },
  1157. undo() {
  1158. if (this.value !== "") {
  1159. var str = ""
  1160. for (let i = 0; i < this.value.length - 1; i++) {
  1161. str += this.value[i]
  1162. }
  1163. this.value = str;
  1164. }
  1165. },
  1166. timeEmoji() {
  1167. this.currentNum = 1
  1168. this.current = 0
  1169. },
  1170. nowEmoji() {
  1171. this.currentNum = 4.3
  1172. this.current = 1
  1173. },
  1174. likeEmoji() {
  1175. this.currentNum = 7.6
  1176. this.current = 2
  1177. },
  1178. gifEmoji() {
  1179. this.currentNum = 11.0
  1180. this.current = 3
  1181. },
  1182. qingkon() {
  1183. uni.showModal({
  1184. title: '确定清空?',
  1185. success: (re) => {
  1186. if (re.confirm) {
  1187. this.nowTimeEmojiList = []
  1188. uni.removeStorageSync("nowTimeEmojiList");
  1189. }
  1190. }
  1191. })
  1192. },
  1193. clicknowTimeEmoji(index) {
  1194. var str = this.nowTimeEmojiList[index].alt;
  1195. this.value += str;
  1196. },
  1197. clickEmoji(index) {
  1198. // console.log(this.emojilist[index])
  1199. var str = this.emojilist[index].alt;
  1200. this.value += str;
  1201. if (uni.getStorageSync("nowTimeEmojiList").length == 0) {
  1202. this.nowTimeEmojiList = []
  1203. this.nowTimeEmojiList.push(this.emojilist[index])
  1204. uni.setStorageSync("nowTimeEmojiList", this.nowTimeEmojiList);
  1205. } else {
  1206. this.nowTimeEmojiList = uni.getStorageSync("nowTimeEmojiList");
  1207. let isTrue = true;
  1208. for (let i = 0; i < this.nowTimeEmojiList.length; i++) {
  1209. if (this.emojilist[index].alt == this.nowTimeEmojiList[i].alt) {
  1210. isTrue = false;
  1211. }
  1212. }
  1213. if (isTrue) {
  1214. this.nowTimeEmojiList.push(this.emojilist[index])
  1215. }
  1216. uni.setStorageSync("nowTimeEmojiList", this.nowTimeEmojiList);
  1217. }
  1218. },
  1219. clicksinaEmoji(index) {
  1220. console.log(this.sinaEmojilist[index])
  1221. },
  1222. currentChange(e) {
  1223. var num = e.detail.current + 1
  1224. switch (num) {
  1225. case 1:
  1226. this.currentNum = 1
  1227. break;
  1228. case 2:
  1229. this.currentNum = 4.3
  1230. break;
  1231. case 3:
  1232. this.currentNum = 7.6
  1233. break;
  1234. case 4:
  1235. this.currentNum = 11.0
  1236. break;
  1237. default:
  1238. break;
  1239. }
  1240. },
  1241. getGif() {
  1242. var list = []
  1243. for (let i = 0; i < 15; i++) {
  1244. var num = Math.round(Math.random() * this.gifAndpngList.length);
  1245. list.push(this.gifAndpngList[num]);
  1246. }
  1247. this.gifAndpnglist = list
  1248. },
  1249. scrolltolowerGIF() {
  1250. for (let i = 0; i < 15; i++) {
  1251. var num = Math.round(Math.random() * this.gifAndpngList.length);
  1252. this.gifAndpnglist.push(this.gifAndpngList[num]);
  1253. }
  1254. }
  1255. // ------- end -------
  1256. }
  1257. }
  1258. </script>
  1259. <style lang="scss">
  1260. .vip {
  1261. width: 56rpx;
  1262. height: 20rpx;
  1263. margin-top: 5rpx;
  1264. margin-left: 16rpx;
  1265. }
  1266. .closeBnt {
  1267. position: absolute;
  1268. right: 30rpx;
  1269. margin-top: 34rpx;
  1270. width: 30rpx;
  1271. height: 30rpx;
  1272. }
  1273. .numberComment {
  1274. font-size: 26rpx;
  1275. font-weight: 500;
  1276. text-align: center;
  1277. color: #333;
  1278. margin-top: 34rpx;
  1279. }
  1280. .pictrue {
  1281. width: 60rpx;
  1282. height: 60rpx;
  1283. border: 1px solid #fff;
  1284. border-radius: 50rpx;
  1285. margin-top: 20px;
  1286. margin-left: 15px;
  1287. }
  1288. .name {
  1289. font-size: 24rpx;
  1290. font-weight: 500;
  1291. color: #666;
  1292. }
  1293. .time {
  1294. font-size: 22rpx;
  1295. font-weight: 400;
  1296. color: #999999;
  1297. margin-left: 10px;
  1298. margin-top: 2rpx;
  1299. }
  1300. .like {
  1301. color: #999;
  1302. position: absolute;
  1303. right: 45rpx;
  1304. margin-left: 5rpx;
  1305. width: 26rpx;
  1306. height: 26rpx;
  1307. }
  1308. .likeNum {
  1309. font-size: 22rpx;
  1310. color: #a3a1a4;
  1311. position: absolute;
  1312. right: 22rpx;
  1313. margin-top: 2rpx;
  1314. }
  1315. .childrenPic {
  1316. width: 40rpx;
  1317. height: 40rpx;
  1318. border: 1px solid red;
  1319. border-radius: 50%;
  1320. margin-top: 20px;
  1321. }
  1322. .childrenName {
  1323. font-size: 24rpx;
  1324. font-weight: 500;
  1325. color: #666;
  1326. }
  1327. .childrenLike {
  1328. color: #999;
  1329. position: absolute;
  1330. right: 20rpx;
  1331. width: 27rpx;
  1332. height: 27rpx;
  1333. }
  1334. .childrenLikeNum {
  1335. font-size: 22rpx;
  1336. color: #a3a1a4;
  1337. position: absolute;
  1338. right: 0rpx;
  1339. margin-top: 2rpx;
  1340. }
  1341. </style>