douyin-scrollview.nvue 49 KB

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