douyin-scrollview.nvue 50 KB

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