index.nvue 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456
  1. <template>
  2. <view class="container">
  3. <!--
  4. 注意:这是 App 所用页面,请勿引入微信小程序或浏览器运行,最好运行在真机
  5. 1. new_index.nvue、index.nvue这两个是App页面
  6. 2. index.nvue - 页面预加载使用 - 在线预加载方案
  7. 3. 另外:data.js 是上一版本留下的假数据,这一版改成了 URL 请求了(如不需要可以删除,也可作为后端请求参考)
  8. 4. 请各位大神多多留手,我已经把请求内存开到最大了
  9. 5. 视频 id 切记是字符串类型
  10. 6. 这里仅 App 端引入了 App 端专用评论,小程序 、H5 引入的时候 可以作为参考
  11. App、小程序、H5评论请参考插件:https://ext.dcloud.net.cn/plugin?id=7875
  12. -->
  13. <!-- 头部导航 -->
  14. <!-- <view class="footer">
  15. <text class="items" @click="goIndex">首页</text>
  16. <text class="items on">视频</text>
  17. <view class="items" @click="goCarts">
  18. <view class="itemCon">
  19. <text class="cart">购物车</text>
  20. <uni-badge v-if="cartNum>0" class="uni-badge-left-margin" type='error' :text="cartNum" />
  21. </view>
  22. </view>
  23. <text class="items" @click="goUser">我的</text>
  24. </view> -->
  25. <view class="header">
  26. <view>
  27. <view class="sys-title" v-if="dataList[k]">
  28. <text class="name" v-if="dataList.length && dataList[k].desc.length>=8">{{dataList[k].desc.slice(0,8)}}...</text>
  29. <text class="name" v-else>{{dataList[k].desc}}</text>
  30. <image class="returnImg" src="../static/img/index/f.png" @click="returnPage"></image>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="noVideo acea-row row-center-wrapper" v-if="!dataList.length">
  35. <view>
  36. <image :src="imgHost+'/statics/images/no-video.png'" class="pictrue"></image>
  37. <text class="tips">暂无短视频内容哦~</text>
  38. </view>
  39. </view>
  40. <!-- <view @click="tolistVideo" style="position: fixed; margin-top: 100upx; right: 40upx;">
  41. <text style="padding: 10upx; padding-left: 40upx; padding-right: 40upx; border-radius: 20upx; background-color: #F8F8F8; font-size: 14px;">H5/小程序</text>
  42. </view>
  43. <view @click="autoPlay" style="position: fixed; margin-top: 100upx; left: 40upx;">
  44. <text style="padding: 10upx; padding-left: 40upx; padding-right: 40upx; border-radius: 20upx; background-color: #F8F8F8; color: #007AFF; font-weight: bold; font-size: 14px;">{{autoplayText}}</text>
  45. </view>
  46. <view @click="previewVideo" style="position: fixed; margin-top: 200upx; right: 40upx;">
  47. <text style="padding: 10upx; padding-left: 40upx; padding-right: 40upx; border-radius: 20upx; background-color: #F8F8F8; font-size: 14px;">App端-预览视频界面</text>
  48. </view>
  49. <view @click="wxh5Video" style="position: fixed; margin-top: 300upx; right: 40upx;">
  50. <text style="padding: 10upx; padding-left: 40upx; padding-right: 40upx; border-radius: 20upx; background-color: #F8F8F8; font-size: 14px;">微信/H5端-预览视频界面</text>
  51. </view> -->
  52. <image v-if="isShowAixin" src="../static/img/index/aixining.png" :style="'position: fixed; margin-left: '+ aixinLeft +'px; margin-top: '+ aixinTop +'px; width: 70px; height: 65px; transform: rotate('+ Rotate +'deg);'"></image>
  53. <view :style="'width: '+ windowWidth +'px; height: '+ boxStyle.height +'px;'">
  54. <!--
  55. 1.这里的 swiper 不是用来控制视频滑动的,而是用来控制左右滑动的,如果不需要的可以改成 view
  56. 2.为了 视频无限加载,已经把 21 行的 appear 去掉了,加上了 loadmore 方法(第10行)
  57. 3.由于方法比较多,可以采取下面的方式查看代码:
  58. (1)Mac:按住 option 键,然后点击方法名,即可跳转到方法
  59. (2)windows:按住 Alt 键,然后鼠标左击,即可跳转到方法
  60. -->
  61. <list @loadmore="getData" @scroll="scrolls" :loadmoreoffset="wHeight*1" :show-scrollbar="false" ref="listBox" :pagingEnabled="true" :scrollable="true">
  62. <!-- 刷新模块 -->
  63. <refresh class="refresh" @refresh="onrefresh" @pullingdown="onpullingdown" :display="refreshing ? 'show' : 'hide'">
  64. <loading style="background-color: #FFFFFF;">
  65. <image src="../static/img/index/logins.gif" :style="'width: 80upx; height: 40upx; margin-top: 80upx; margin-bottom: 30upx; margin-left: '+ (windowWidth - 200) +'px;'"></image>
  66. </loading>
  67. </refresh>
  68. <!-- 循环数据 -->
  69. <cell v-for="(item,i) in dataList" :key="i">
  70. <!-- 用div把视频模组套起来 -->
  71. <div :style="'width: '+ windowWidth +'px; height: '+ boxStyle.height +'px;'" @disappear="stop()">
  72. <view v-if="Math.abs(k-i)<=1">
  73. <view class="root">
  74. <!--
  75. 具体视频参数可以参考官方文档
  76. 说明:
  77. 1.v-if很关键,这里主要是为了减少 dom 元素【这样才不会加载视频多了闪退】,
  78. 这里 Math.abs(k-i)<=5 也就是往上预加载 5 个视频,往下预加载 5
  79. 个视频这样做的目的是为了让视频能够提前加载但是不播放,在真正滑到位
  80. 置的时候播放视频。
  81. 【2.0.1就是 1 Math.abs(k-i)<=1:请勿修改,记住,要不然会提前播放很多视频】
  82. 2.要注意 @play="playIngs" 里面的 playIngs 方法,这个方法只是在视频播放的时候
  83. 起效果,我们控制视频播放不是用这个的。这个的主要作用是给视频封面的。我们先用
  84. 下面的视频封面盖住视频,等到视频播放的时候,我们不要急着直接播放,而是延迟一下下,
  85. 300-600ms左右。因为视频播放需要一点点时间,这点时间里会黑屏,这个时候我们就用
  86. 下面的封面盖住,这样用户就不会有从黑屏到有画面的感觉了,但是如果遇到视频太大,缓冲
  87. 时间太长,还是会出现短暂的黑屏,大部分是不会有黑屏的(这样盖住的话)。
  88. 【更新记录:2.0版】已经解决了视频黑屏问题,和加载速度慢的情况,如果还是出现了黑屏,
  89. 意味着此时手滑动的速度,已经超过了视频加载的速度,对于这个问题,建议修改 preloadNumber
  90. 变量,当它的值大一点的时候就会提前加载视频,这样用户在滑到视频的时候就不会有停顿感了
  91. 【注意】:老用户在 video 中增加和修改
  92. (1):muted="!item.playIng",
  93. (2)@timeupdate="timeupdate($event,i)"
  94. (3)把 199 行注释了,
  95. (4):id="item.id",
  96. (5)修改:uni.createVideoContext(this.dataList[this.k].id + '' + this.k,this) 为
  97. uni.createVideoContext(this.dataList[this.k].id,this)
  98. (6)在 timeupdate 方法里加入,if(index == this.k){把里面的加一个总的判断}
  99. 3.其他的下面有详解
  100. -->
  101. <video
  102. :ref="'item'+i"
  103. :id="item.id"
  104. :loop="true"
  105. :src="item.video_url"
  106. :muted="item.isplay"
  107. @play="playIngs(i)"
  108. :enable-progress-gesture="false"
  109. :page-gesture="false"
  110. :controls="false"
  111. :http-cache="true"
  112. :show-loading="false"
  113. :show-fullscreen-btn="false"
  114. :show-center-play-btn="false"
  115. :style="boxStyle"
  116. :object-fit="object_fit"
  117. @timeupdate="timeupdate($event,i)"
  118. ></video>
  119. <!-- 这里是封面 -->
  120. <image
  121. v-if="!item.playIng"
  122. :src="item.video_url+'?x-oss-process=video/snapshot,t_100,f_jpg'"
  123. :mode="mode"
  124. :style="'width: '+ windowWidth +'px; height: '+ (wHeight - deleteHeight) +'px; position: absolute;'"
  125. ></image>
  126. <!--
  127. mode: 图片裁剪、缩放的模式
  128. mode 有 14 种模式,其中 5 种是缩放模式,9 种是裁剪模式。
  129. https://uniapp.dcloud.io/component/image
  130. -->
  131. </view>
  132. <!-- 直接用 view 就行了,一样是可以覆盖原生组件的 -->
  133. <!-- 这个是暂停时出现的图标 -->
  134. <view class="videoHover" @click="tapVideoHover(item.state,$event)" @touchstart="touchstartHover" :style="boxStyle">
  135. <image v-if="item.state=='pause'" class="playState" src="../static/img/index/play.png"></image>
  136. </view>
  137. <view class="userInfo">
  138. <!-- 1.头像 -->
  139. <image v-if="item.isShowProgressBarTime == false" @click="tozuozhe(item)" class="userAvatar" :src="item.type_image" mode="aspectFill"></image>
  140. <!-- 2.点赞 -->
  141. <view v-if="item.isShowProgressBarTime == false" @click="cLike(item);" style="opacity: 0.9; margin-top: 5px;">
  142. <image v-if="item.is_like" src="../static/img/index/xin.png" style="width: 30px; height: 30px; position: absolute; right: 7px;"></image>
  143. <image v-if="!item.is_like" src="../static/img/index/xin-2.png" style="width: 30px; height: 30px; position: absolute; right: 7px;"></image>
  144. <text style="color: #FFFFFF; margin-top: 5px; font-size: 11px; text-align: center; margin-top: 36px; font-weight: 400;">{{item.like_num>0?item.like_num:'点赞'}}</text>
  145. </view>
  146. <!-- 收藏 -->
  147. <view @click="cCollect(item);" style="opacity: 0.9; margin-top: 18px;">
  148. <image v-if="item.is_collect" src="../static/img/index/collection02.png" style="width: 30px; height: 30px; position: absolute; right: 7px;"></image>
  149. <image v-if="!item.is_collect" src="../static/img/index/collection01.png" style="width: 30px; height: 30px; position: absolute; right: 7px;"></image>
  150. <text style="color: #FFFFFF; margin-top: 5px; font-size: 11px; text-align: center; margin-top: 36px; font-weight: 400;">{{item.collect_num>0?item.collect_num:'收藏'}}</text>
  151. </view>
  152. <!-- 3.评论 -->
  153. <view v-if="item.isShowProgressBarTime == false" class="comment" @click="toComment(item)" style="opacity: 0.9; margin-top: 18px;">
  154. <image src="../static/img/index/evaluate.png" style="width: 30px; height: 30px; position: absolute; right: 8px;"></image>
  155. <text style="color: #FFFFFF; font-size: 11px; font-weight: 400; text-align: center; margin-top: 36px;">{{item.comment_num>0?item.comment_num:'抢首评'}}</text>
  156. </view>
  157. <!-- 4.分享 -->
  158. <view class="shares" v-if="item.isShowProgressBarTime == false" @click="appShare('WXSceneSession',item.id)">
  159. <image class="img" src="../static/img/index/we-chat.png"></image>
  160. <text class="text">分享</text>
  161. </view>
  162. </view>
  163. <!-- 最底下的文字部分 -->
  164. <view class="content" v-if="dataList.length !== 0 && dataList[k].isShowProgressBarTime == false">
  165. <!-- <view class="cart" @click="goCart(item)" v-if="item.product_num>0">
  166. <image class="cartPic" src="../static/img/index/shopping-car.png"></image>
  167. <text class="cartName">购物</text>
  168. <text class="line"></text>
  169. <text class="cartName">视频款请点击这里购买</text>
  170. </view> -->
  171. <view class="timeCon" :style="'width: '+ (windowWidth - 90) +'px;'">
  172. <text class="userName" v-if="item.type_name.length<=12">@{{item.type_name}}</text>
  173. <text class="userName" v-else>{{item.type_name.slice(0,12)}}...</text>
  174. <!-- <text class="time">.{{item.date}}</text> -->
  175. </view>
  176. <view class="words" :style="'width: '+ (windowWidth - 120) +'px;'">
  177. <view v-if="item.isMore || item.desc.length<=33">
  178. <text class="info">{{item.desc}}</text>
  179. <!-- <view class="close">
  180. <text v-if="item.isMore" class="more" @click="moreTap(item)">收起</text>
  181. <image v-if="item.isMore" class="imgClose" src="../static/img/index/drop-down.png"></image>
  182. </view> -->
  183. </view>
  184. <view class="wordsCon" v-else>
  185. <text class="info">{{item.desc.slice(0,33)}}...</text>
  186. <!-- <text class="more" @click="moreTap(item)">更多</text>
  187. <image class="img" src="../static/img/index/drop-down.png"></image> -->
  188. </view>
  189. </view>
  190. <view class="goodsList" v-if="goodsList.length">
  191. <scroll-view :scroll="false" :scroll-x="true" :show-scrollbar="false" class="scroll">
  192. <view class="scroll-item" v-for="(goodsItem,goodsIndex) in goodsList" :key="goodsIndex">
  193. <view class="title">
  194. <image class="img" src="../static/img/index/shopping-car.png"></image>
  195. <text class="titleCon">商品热卖中</text>
  196. </view>
  197. <view class="item" @click="goDetails(goodsItem)">
  198. <image class="pictrue" :src="goodsItem.image"></image>
  199. <view class="text">
  200. <view class="textCon">
  201. <text class="line1" v-if="goodsItem.store_name.length>=9">{{goodsItem.store_name.slice(0,9)}}...</text>
  202. <text class="line1" v-else>{{goodsItem.store_name}}</text>
  203. <text class="discount" v-if="goodsItem.promotions.title">{{goodsItem.promotions.title}}</text>
  204. </view>
  205. <view class="money">
  206. <text class="lable">¥</text>
  207. <text class="price">{{util.HandlePrice(goodsItem.price,0)}}</text>
  208. <text class="priceNum">{{util.HandlePrice(goodsItem.price,1)}}</text>
  209. </view>
  210. <!-- <baseMoney :money="goodsItem.price" color='#333' symbolSize="20" integerSize="36"
  211. decimalSize="20" weight></baseMoney> -->
  212. </view>
  213. <text class="bnt">购买</text>
  214. </view>
  215. </view>
  216. </scroll-view>
  217. </view>
  218. <view class="goodsCart">
  219. <view class="pictrue" @click="goCart(item)" v-if="item.product_num>0">
  220. <image class="img" src="../static/img/index/goodsCart.png"></image>
  221. <uni-badge v-if="goodsCount>0" class="uni-badge-left-margin" :custom-style="{'background-color': '#fff','color': '#E93323',
  222. 'font-size': '22rpx'}" :text="goodsCount" />
  223. </view>
  224. <view class="text" v-if="recommend" @click="navTap(1)">
  225. <text class="lable">#</text>
  226. <text class="see">大家都在看</text>
  227. <text class="line"></text>
  228. <text class="title" v-if="recommend && recommend.length>=10">{{recommend.slice(0,10)}}...</text>
  229. <text class="title" v-else>{{recommend}}</text>
  230. <text class="jumpLook">查看</text>
  231. </view>
  232. </view>
  233. </view>
  234. <!-- 1.视频预览时的图片,currenttimes:就是获取当前滑块的时间点,如果不需要,可以注释掉 -->
  235. <!-- 2.如果使用下面的视频预览的话要注意的是视频链接最好是阿里云上的,因为
  236. https://xxxxxxxxx.mp4?x-oss-process=video/snapshot,t_1000,f_jpg
  237. 这个是阿里云的东西,至于其他的视频截帧我还没有试过。
  238. -->
  239. <!-- 3.阿里云视频截帧地址:https://help.aliyun.com/document_detail/64555.html -->
  240. <image
  241. v-if="item.isShowimage == true"
  242. :src="item.src+'?x-oss-process=video/snapshot,t_'+ currenttimes +'000,f_jpg'"
  243. mode="aspectFill"
  244. :style="'width: 120upx; height: 160upx; border-radius: 10upx; position: absolute; bottom: '+ (ProgressBarBottom + 160) +'upx; left: '+ (currentPositions - 15) +'px;'"
  245. ></image>
  246. </view>
  247. </div>
  248. </cell>
  249. </list>
  250. <!-- 1.注意:进度条这类拖拽的东西不能放进block\cell这些循环体中的,要不然touchmove方法会捕捉有误 -->
  251. <!-- <view v-if="dataList.length !== 0 && dataList[k].isShowProgressBarTime == true" :style="'position: absolute; bottom: '+ (ProgressBarBottom + this.windowWidth*0.2)/2 +'px; left: '+ (windowWidth*2 - this.windowWidth*1.35)/2 +'px;'">
  252. <text style="font-size: 22px; font-weight: bold; color: #F1F1F1;">{{changeTime}} / {{videoTimes}}</text>
  253. </view> -->
  254. <!-- 这里就是进度条了:纯手工进度条,调整位置的话就把他们的 bottom 改成一下就行了 -->
  255. <!-- <view v-if="isDragging == false" @touchmove="touchmove" @touchend="touchend" @touchstart="touchstart" style="position: absolute; bottom: 0; left: 0;"> -->
  256. <!-- 1.这一步必须加,为了适配低端机型 -->
  257. <!-- <text :style="'width: '+ windowWidth +'px; opacity: 0;'">.</text> -->
  258. <!-- 2.这是未加载的时的右边的灰色部分 -->
  259. <!-- <view :style="'width: '+ windowWidth +'px; height: 4upx; background-color: #C8C7CC; position: absolute; bottom: '+ ProgressBarBottom +'upx; opacity: '+ ProgressBarOpacity +';'"></view> -->
  260. <!-- 3.这里我采用的分离式办法:就是让滑动样式和不滑动的样式分开,这样相互不干扰,可以避免进度条闪动的问题 -->
  261. <!-- 4.注意:isShowProgressBarTime 加入了返回数据中 -->
  262. <!-- <view v-if="dataList.length !== 0 && dataList[k].isShowProgressBarTime == false" :style="'width: '+ (currentPosition) +'px; height: 4upx; background-color: #FFFFFF; position: absolute; bottom: '+ ProgressBarBottom +'upx; left: 0; opacity: '+ (ProgressBarOpacity - 0.1) +';'"></view>
  263. <view v-if="dataList.length !== 0 && dataList[k].isShowProgressBarTime == true" :style="'width: '+ (currentPositions) +'px; height: 8upx; background-color: #FFFFFF; position: absolute; bottom: '+ ProgressBarBottom +'upx; left: 0; opacity: '+ (ProgressBarOpacity + 0.05) +';'"></view>
  264. <view v-if="dataList.length !== 0 && dataList[k].isShowProgressBarTime == false" :style="'width: 4px; height: 4px; background-color: #FFFFFF; border-radius: 10px; position: absolute; bottom: '+ (ProgressBarBottom - 2) +'upx; left: '+ (currentPosition) +'px; opacity: '+ ProgressBarOpacity +';'"></view>
  265. <view v-if="dataList.length !== 0 && dataList[k].isShowProgressBarTime == true" :style="'width: '+ dotWidth +'px; height: '+ dotWidth +'px; background-color: #FFFFFF; border-radius: 10px; position: absolute; bottom: '+ (ProgressBarBottom - 5) +'upx; left: '+ (currentPositions - 5) +'px; opacity: '+ ProgressBarOpacity +';'"></view> -->
  266. <!-- </view> -->
  267. </view>
  268. <!--
  269. 请前往 douyin-scrollview.nvue 文件查看
  270. 已经全部注释
  271. 这里就是引入评论插件
  272. -->
  273. <uni-popup type="bottom" ref="pinglun" @touchmove.stop.prevent="moveHandle">
  274. <view :style="'width: '+ windowWidth +'px; height: '+ (boxStyle.height/heightNum) +'px; background-color: #fff; border-top-left-radius: 10px; border-top-right-radius: 10px;'">
  275. <!--
  276. 注意:
  277. deleteIOSHeight
  278. deleteAndroidHeight
  279. 这两个参数用于控制评论等的高度
  280. -->
  281. <douyin-scrollview
  282. :Width="windowWidth"
  283. :Height="(boxStyle.height/1.18)"
  284. :deleteIOSHeight="36"
  285. :deleteAndroidHeight="15"
  286. @closeScrollview="closeScrollview"
  287. @pinlunFun="pinlunFun"
  288. ></douyin-scrollview>
  289. </view>
  290. </uni-popup>
  291. <uni-popup type="bottom" ref="pinglunGoods" @touchmove.stop.prevent="moveHandle">
  292. <view :style="'width: '+ windowWidth +'px;background-color: #F5F5F5; border-top-left-radius: 10px; border-top-right-radius: 10px;'">
  293. <goodsList
  294. :Width="windowWidth"
  295. :Height="(boxStyle.height/1.18)"
  296. @closeGoodsList="closeGoodsList"
  297. ></goodsList>
  298. </view>
  299. </uni-popup>
  300. </view>
  301. </template>
  302. <script>
  303. // import userList from './data.js'//这个是假数据
  304. import util from '@/utils/util.js';
  305. const app = getApp();
  306. import {
  307. toLogin
  308. } from '@/libs/login.js';
  309. import {
  310. mapGetters
  311. } from 'vuex';
  312. /*
  313. 引入评论组件
  314. */
  315. import douyinScrollview from '../components/douyin-scrollview/douyin-scrollview.nvue'
  316. import goodsList from '../components/goodsList/index.vue'
  317. import {
  318. videoList,
  319. markeVideo,
  320. videoProduct,
  321. videoInfo
  322. } from '@/api/short-video.js';
  323. import {
  324. HTTP_REQUEST_URL
  325. } from '@/config/app.js';
  326. import {
  327. getCartCounts,
  328. } from '@/api/order.js';
  329. export default {
  330. computed: mapGetters(['isLogin','uid','cartNum']),
  331. data() {
  332. return {
  333. util:util,
  334. isGoods:false,
  335. //下面打🌟号的是必须要的基础字段
  336. //下面打💗号的是拥有滑动条的必须字段
  337. dataList:[],//用于数据循环的列表🌟💗
  338. wHeight:0,//获取的屏幕高度🌟💗
  339. boxStyle:{//视频,图片封面样式🌟💗
  340. 'height': 0,
  341. 'width': 0,
  342. },
  343. k:0,//默认为0🌟💗
  344. playIngIds:[],//正在播放的视频id列队,列队用于处理滑动过快导致的跳频问题🌟💗
  345. ready:false,//可忽略
  346. isDragging: false,//false代表停止滑动🌟💗
  347. refreshing: true,//用于下拉刷新🌟💗
  348. windowWidth: 0,//获取屏幕宽度🌟💗
  349. windowHeight: 0,
  350. dex: [0,0],//用于判断是上滑还是下滑,第一个存旧值,第二个存新值【目前在1.0.7已经废弃】
  351. currents: 0,//用于左右滑动,0代表视频界面,1代表右滑界面🌟💗
  352. platform: '',//用于获取操作系统:ios、android🌟💗
  353. playIng: false,//用于视频初始化时是否播放,默认不播放🌟💗
  354. videoTime: '',//视频总时长,这个主要用来截取时间数值💗
  355. videoTimes: '',//视频时长,用这个来获取时间值,例如:00:30这个时间值💗
  356. changeTime: '',//显示滑动进度条时变化的时间💗
  357. isShowimage: false,//是否显示封面【1.0.4已废弃,但是意思需要记住】
  358. currenttimes: 0,//当前时间💗
  359. isShowProgressBarTime: false,//是否拖动进度条,如果拖动(true)则显示进度条时间,否则不显示(false)【1.0.4已废弃,但是意思需要记住】
  360. ProgressBarOpacity: 0.7,//进度条不拖动时的默认值,就是透明的💗
  361. dotWidth: 0,//播放的小圆点,默认没有💗
  362. deleteHeight: 0,//测试高度🌟💗
  363. percent: 0,//百分小数💗
  364. currentPosition: 0,//滑块当前位置💗//2.0已弃用,现已用于后端参数
  365. currentPositions: 0,//滑块当前位置的副本💗//2.0已弃用,现已用于后端参数
  366. newTime: 0,//跟手滑动后的最新时间💗
  367. timeNumber: 0,//🌟💗
  368. ProgressBarBottom: 20,//进度条离底部的距离💗
  369. object_fit: 'contain',//视频样式默认包含🌟💗
  370. mode: 'aspectFit',//图片封面样式🌟💗
  371. timeout: "",//🌟用来阻止 setTimeout()方法
  372. voice: "",//🌟用来阻止 setTimeout()方法
  373. oldVideo: "",
  374. isAutoplay: false,//是否开启自动播放(默认不开启)
  375. autoplayText: "开启自动播放",
  376. timers: "",
  377. // 引入评论 - 参数
  378. heightNum: 1.18,
  379. // 双击点赞参数
  380. touchNum: 0,
  381. aixinLeft: 0,
  382. aixinTop: 0,
  383. isShowAixin: false,
  384. Rotate: 0,
  385. currentNav:1,
  386. limit: 6,
  387. page: 1,
  388. goodsList: [],
  389. goodsCount: 0,
  390. recommend:''
  391. }
  392. },
  393. components:{
  394. douyinScrollview,
  395. goodsList
  396. },
  397. watch:{
  398. async k(k,old_k){//监听 k 值的变化,可以控制视频的播放与暂停
  399. // console.log('的点点滴滴多',this.dataList[k].id);
  400. this.dataList[old_k].state = 'stop'//如果是被滑走的视频,就停止播放
  401. this.dataList[old_k].playIng = false//如果视频暂停,就加载封面
  402. this.dataList[old_k].isplay = true
  403. // uni.createVideoContext(this.dataList[old_k].id,this).seek(0)
  404. uni.createVideoContext(this.dataList[old_k].id,this).play()
  405. clearTimeout(this.oldVideo)
  406. this.oldVideo = await setTimeout(()=>{
  407. uni.createVideoContext(this.dataList[old_k].id,this).seek(0)
  408. uni.createVideoContext(this.dataList[old_k].id,this).pause()
  409. console.log('预留第' + (old_k + 1) + '个视频:' + this.dataList[old_k].id)
  410. },500)
  411. uni.createVideoContext(this.dataList[k].id,this).play();
  412. clearTimeout(this.voice)
  413. this.voice = await setTimeout(()=>{
  414. this.dataList[k].isplay = false
  415. },300)
  416. await setTimeout(()=>{
  417. this.dataList[k].playIng = true
  418. },850)
  419. //【2.0版本更新内容】- start
  420. var p = k
  421. ++p
  422. await setTimeout(async ()=>{
  423. uni.createVideoContext(this.dataList[p].id,this).play()
  424. clearTimeout(this.timeout)
  425. this.timeout = await setTimeout(()=>{
  426. uni.createVideoContext(this.dataList[p].id,this).seek(0)
  427. uni.createVideoContext(this.dataList[p].id,this).pause()
  428. console.log('预加载第' + (p + 1) + '个视频:' + this.dataList[p].id)
  429. },1500)
  430. },20)
  431. //【2.0版本更新内容】- end
  432. //【此处处理进度条卡住的问题】
  433. if(uni.getSystemInfoSync().platform !== 'ios'){
  434. await setTimeout(()=>{
  435. uni.createVideoContext(this.dataList[k].id,this).pause()
  436. uni.createVideoContext(this.dataList[k].id,this).play()
  437. },100)
  438. }
  439. }
  440. },
  441. onShow(){
  442. console.log('回到前台');
  443. if(this.dataList.length !== 0){
  444. this.dataList[this.k].state = 'play';
  445. uni.createVideoContext(this.dataList[this.k].id,this).play()
  446. }
  447. },
  448. onHide(){
  449. this.dataList[this.k].state = 'pause';//界面隐藏也要停止播放视频
  450. uni.createVideoContext(this.dataList[this.k].id,this).pause();//暂停以后继续播放
  451. console.log('到后台');
  452. },
  453. onLoad(options){
  454. this.videoID = options.id || 0;
  455. if (options.spid) app.globalData.spid = options.spid;
  456. console.log('到后台');
  457. this.platform = uni.getSystemInfoSync().platform
  458. var model = uni.getSystemInfoSync().model
  459. if(this.platform == 'ios' && (model !== 'iPhone6' || model !== 'iPhone6s' || model !== 'iPhone7' || model !== 'iPhone8')){
  460. this.deleteHeight = 32//有 tabbar的 修改这里可以改变视频高度
  461. /*
  462. 引入评论参数
  463. */
  464. this.heightNum = 1.27
  465. } else {
  466. this.deleteHeight = 0
  467. /*
  468. 引入评论参数
  469. */
  470. this.heightNum = 1.18
  471. }
  472. this.windowWidth = uni.getSystemInfoSync().screenWidth//获取屏幕宽度
  473. this.boxStyle.width = this.windowWidth + 'px'//给宽度加px
  474. this.wHeight = uni.getSystemInfoSync().screenHeight;//获取屏幕高度
  475. this.boxStyle.height = this.wHeight - this.deleteHeight;//改变视频高度
  476. this.get()//这一步,加载视频数据
  477. if (this.isLogin) {
  478. this.getCartNum()
  479. }
  480. },
  481. onReady() {
  482. },
  483. methods: {
  484. // 返回上一页
  485. returnPage(){
  486. uni.switchTab({
  487. url: '/pages/index/index'
  488. });
  489. },
  490. goDetails(item){
  491. uni.navigateTo({
  492. url: `/pages/goods_details/index?id=${item.id}`
  493. });
  494. },
  495. productList(id){
  496. videoProduct(id).then(res=>{
  497. this.goodsCount = res.data.count;
  498. this.goodsList = res.data.list;
  499. }).catch(err=>{
  500. uni.showToast({
  501. title: err,
  502. icon: 'none',
  503. duration: 2000
  504. });
  505. })
  506. },
  507. getVideoInfo(id){
  508. videoInfo(id).then(res=>{
  509. this.recommend = res.data.recommend.desc;
  510. this.videoID = res.data.recommend.id;
  511. }).catch(err=>{
  512. uni.showToast({
  513. title: err,
  514. icon: 'none',
  515. duration: 2000
  516. });
  517. })
  518. },
  519. getCartNum: function() {
  520. getCartCounts().then(res => {
  521. this.$store.commit('indexData/setCartNum', res.data.count + '')
  522. });
  523. },
  524. goIndex(){
  525. uni.switchTab({
  526. url: '/pages/index/index'
  527. })
  528. },
  529. goCarts(){
  530. uni.switchTab({
  531. url: '/pages/order_addcart/order_addcart'
  532. })
  533. },
  534. goUser(){
  535. uni.switchTab({
  536. url: '/pages/user/index'
  537. })
  538. },
  539. pinlunFun(e){
  540. let videoID = uni.getStorageSync("videoID");
  541. this.dataList.forEach(item=>{
  542. if(item.id == videoID){
  543. item.comment_num = e;
  544. }
  545. })
  546. },
  547. cShare(id){
  548. markeVideo('share',id).then(res=>{}).catch(err=>{
  549. return uni.showToast({
  550. title: err,
  551. icon: 'none',
  552. duration: 2000
  553. });
  554. })
  555. },
  556. // 分享
  557. // #ifdef APP-PLUS
  558. appShare(scene,id) {
  559. let that = this
  560. uni.showLoading({
  561. title: '加载中',
  562. mask: true
  563. });
  564. let uid = this.uid?this.uid:0;
  565. let data = this.dataList[this.k];
  566. let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
  567. let curRoute = routes[routes.length - 1].$page.fullPath // 获取当前页面路由,也就是最后一个打开的页面路由
  568. uni.share({
  569. provider: "weixin",
  570. scene: scene,
  571. type: 0,
  572. href: `${HTTP_REQUEST_URL}/pages/short_video/nvueSwiper/index?spid=${that.uid}&id=${id}`,
  573. title: data.type_name || '',
  574. summary: data.desc || '',
  575. imageUrl: data.image || '',
  576. success: function(res) {
  577. uni.hideLoading();
  578. that.cShare(id);
  579. },
  580. fail: function(err) {
  581. uni.showToast({
  582. title: '分享失败',
  583. icon: 'none',
  584. duration: 2000
  585. })
  586. }
  587. });
  588. },
  589. // #endif
  590. onMyEvent: function() {
  591. this.$set(this, 'isGoods', false);
  592. },
  593. goCart(item){
  594. if (this.isLogin === false) {
  595. return toLogin();
  596. }
  597. // uni.showToast({
  598. // title: '加载中...',
  599. // icon: 'none',
  600. // position: 'bottom',
  601. // duration: 300
  602. // })
  603. uni.setStorageSync("videoID",parseInt(item.id));
  604. this.$refs.pinglunGoods.open('bottom');
  605. },
  606. navTap(n){
  607. this.currentNav = n;
  608. this.oldVideo = "";
  609. this.k = 0;
  610. this.page = 1;
  611. this.dataList = [];
  612. this.get();
  613. },
  614. moreTap(item){
  615. item.isMore = !item.isMore;
  616. },
  617. autoPlay(){
  618. this.isAutoplay = !this.isAutoplay;
  619. if(!this.isAutoplay){
  620. this.autoplayText = "开启自动播放"
  621. uni.showToast({
  622. title: "关闭自动播放",
  623. icon: 'none',
  624. duration: 3000
  625. })
  626. } else {
  627. this.autoplayText = "关闭自动播放"
  628. uni.showToast({
  629. title: "开启自动播放",
  630. icon: 'none',
  631. duration: 3000
  632. })
  633. }
  634. },
  635. getData(){
  636. // 这里就是数据加载完以后再向后端发送数据的地方,
  637. videoList({
  638. page: this.page,
  639. limit: this.limit,
  640. order_type: this.currentNav,
  641. id: (this.page > 1 || this.currentNav == 2) ? 0 : this.videoID
  642. }).then(res=>{
  643. this.page = this.page + 1;
  644. var msg = res.data
  645. for (let i = 0; i < msg.length; i++) {
  646. this.dataList.push(msg[i])
  647. }
  648. }).catch(err=>{
  649. return uni.showToast({ title: err, icon: 'none', duration: 2000 });
  650. })
  651. },
  652. touchstart(event){
  653. this.dataList[this.k].isShowimage = true //刚触摸的时候就要显示预览视频图片了
  654. this.dataList[this.k].isShowProgressBarTime = true //显示时间线
  655. this.ProgressBarOpacity = 1 //让滑块显示起来更明显一点
  656. this.dotWidth = 10 //让点显示起来更明显一点
  657. },
  658. touchend(){//当手松开后,跳到最新时间
  659. uni.createVideoContext(this.dataList[this.k].id,this).seek(this.newTime)
  660. if(this.dataList[this.k].state == 'pause'){
  661. this.dataList[this.k].state = 'play'
  662. uni.createVideoContext(this.dataList[this.k].id,this).play()
  663. }
  664. this.dataList[this.k].isShowProgressBarTime = false //触摸结束后,隐藏时间线
  665. this.dataList[this.k].isShowimage = false //触摸结束后,隐藏时间预览
  666. this.ProgressBarOpacity = 0.5 //隐藏起来进度条,不那么明显了
  667. this.dotWidth = 0 //隐藏起来进度条,不那么明显了
  668. },
  669. touchmove(event){//当手移动滑块时,计算位置、百分小数、新的时间
  670. var msg = []
  671. if(this.videoTime !== ''){
  672. msg = this.videoTime.split(':')
  673. }
  674. var timeNumber = Number(msg[0])*60 + Number(msg[1])
  675. this.currentPositions = event.changedTouches[0].screenX
  676. this.percent = this.currentPositions / this.windowWidth
  677. this.newTime = this.percent*timeNumber
  678. this.currenttimes = parseInt(this.newTime)
  679. let theTime = this.newTime
  680. let middle = 0;// 分
  681. if(theTime > 60) {
  682. middle = parseInt(theTime/60);
  683. theTime = parseInt(theTime%60);
  684. }
  685. this.changeTime = `${Math.round(middle)>9?Math.round(middle):'0'+Math.round(middle)}:${Math.round(theTime)>9?Math.round(theTime):'0'+Math.round(theTime)}`
  686. },
  687. timeupdate(event,index){//计算滑块当前位置,计算当前百分小数
  688. // console.log(index)
  689. if(index == this.k){
  690. // console.log(event)
  691. var currenttime = event.detail.currentTime
  692. this.timeNumber = Math.round(event.detail.duration)
  693. this.getTime()
  694. this.percent = currenttime/this.timeNumber
  695. this.currentPosition = this.windowWidth*this.percent
  696. let theTime = currenttime
  697. let middle = 0;// 分
  698. if(theTime > 60) {
  699. middle = parseInt(theTime/60);
  700. theTime = parseInt(theTime%60);
  701. }
  702. this.changeTime = `${Math.round(middle)>9?Math.round(middle):'0'+Math.round(middle)}:${Math.round(theTime)>9?Math.round(theTime):'0'+Math.round(theTime)}`
  703. //自动切换视频
  704. if(this.isAutoplay){//true,代表自动播放
  705. if(Math.round(currenttime) == this.timeNumber - 1){
  706. const dom = uni.requireNativePlugin('dom')
  707. let doms = 'item'+(this.k+1)
  708. setTimeout(()=>{
  709. let el = this.$refs[doms][0]
  710. dom.scrollToElement(el,{
  711. offset: 0,
  712. animated: true
  713. })
  714. },500)
  715. }
  716. }
  717. }
  718. },
  719. getTime(){//得到时间函数
  720. this.videoTime = this.formatSeconds(this.timeNumber);
  721. // console.log(that.videoTime)
  722. var msg = []
  723. if(this.videoTime !== ''){
  724. msg = this.videoTime.split(':')
  725. }
  726. this.videoTimes = `${msg[0]>9?msg[0]:'0'+msg[0]}:${msg[1]>9?msg[1]:'0'+msg[1]}`;
  727. },
  728. formatSeconds(value) {//获取时间函数
  729. let theTime = parseInt(value);// 秒
  730. let middle= 0;// 分
  731. if(theTime > 60) {
  732. middle= parseInt(theTime/60);
  733. theTime = parseInt(theTime%60);
  734. }
  735. return `${middle>9?middle:middle}:${theTime>9?theTime:theTime}`;
  736. },
  737. playIngs(index) {
  738. //
  739. },
  740. moreVideo(index){
  741. },
  742. toVideo(index){
  743. },
  744. erweima(){
  745. },
  746. tozuozhe(item){
  747. this.currents = 1//点击头像以后就会切换
  748. if(item.type==0){
  749. uni.reLaunch({
  750. url: `/pages/index/index`
  751. });
  752. }else{
  753. uni.reLaunch({
  754. url: `/pages/store_cate/store_cate?id=`+item.relation_id
  755. });
  756. }
  757. },
  758. stop(){
  759. // console.log('stop')
  760. },
  761. scrolls (event) {
  762. this.isDragging = event.isDragging
  763. if (!event.isDragging) {//isDragging:判断用户是不是在滑动,滑动:true,停止滑动:false。我们要用户停止滑动时才给 k 赋值,这样就可以避免很多麻烦
  764. var i = Math.round(Math.abs(event.contentOffset.y) / (this.wHeight - this.deleteHeight + 1))//先用绝对值取出滑动的距离,然后除以屏幕高度,取一个整,就知道你现在滑动到哪一个视频了
  765. if(i !== this.k){//这里加判断是因为这个方法会执行很多次,会造成重复请求,所以这里写一个限制
  766. if(uni.getSystemInfoSync().platform == 'ios'){
  767. this.k = i//判断了用户没有滑动,确认了用户的确是在看这个视频,然后就赋值啦
  768. this.dataList[this.k].state = 'play'
  769. console.log('正在播放 --> 第' + (this.k + 1) + '个视频~')
  770. this.productList(this.dataList[this.k].id);
  771. this.getVideoInfo(this.dataList[this.k].id);
  772. } else {
  773. clearTimeout(this.timers);
  774. this.timers = setTimeout(()=>{
  775. this.k = i//判断了用户没有滑动,确认了用户的确是在看这个视频,然后就赋值啦
  776. this.dataList[this.k].state = 'play'
  777. console.log('正在播放 --> 第' + (this.k + 1) + '个视频~')
  778. this.productList(this.dataList[this.k].id);
  779. this.getVideoInfo(this.dataList[this.k].id);
  780. },80)
  781. }
  782. }
  783. }
  784. },
  785. get(){
  786. // 这个方法主要就是用来第一次进入视频播放时用来处理的
  787. videoList({
  788. page: this.page,
  789. limit: this.limit,
  790. order_type: this.currentNav,
  791. id: (this.page > 1) ? 0 : this.videoID
  792. }).then(async (res)=>{
  793. this.page = this.page + 1;
  794. var msg = res.data;
  795. this.dataList = msg;
  796. this.dataList[0].state = "play";
  797. this.productList(this.dataList[this.k].id);
  798. this.getVideoInfo(this.dataList[this.k].id);
  799. await setTimeout(()=>{
  800. //这里的延迟是为了避免执行时间太快而直接跳过执行的bug
  801. uni.createVideoContext(this.dataList[0].id,this).seek(0)
  802. uni.createVideoContext(this.dataList[0].id,this).play()
  803. },200)
  804. this.dataList[0].isplay = false
  805. await setTimeout(()=>{
  806. this.dataList[0].playIng = true
  807. },500)
  808. var p = 0
  809. await setTimeout(async ()=>{
  810. ++p
  811. uni.createVideoContext(this.dataList[p].id,this).play()
  812. await setTimeout(()=>{
  813. uni.createVideoContext(this.dataList[p].id,this).seek(0)
  814. uni.createVideoContext(this.dataList[p].id,this).pause()
  815. console.log('预加载第' + (p + 1) + '个视频s:' + this.dataList[p].id)
  816. },800)
  817. },50)
  818. }).catch(err=>{
  819. return uni.showToast({
  820. title: err,
  821. icon: 'none',
  822. duration: 2000
  823. });
  824. })
  825. },
  826. onpullingdown(){
  827. // console.log('正在下拉刷新,此时手还在触摸没有松开')
  828. this.refreshing = true
  829. },
  830. onrefresh(){
  831. // console.log('下拉刷新完毕,此时手松开了')
  832. setTimeout(()=>{
  833. this.refreshing = false
  834. },1000)
  835. },
  836. // 双击点赞效果
  837. touchstartHover(event){
  838. if(this.touchNum >= 1){
  839. // console.log('双击 -- X坐标:'+ event.touches[0].screenX);
  840. // console.log('双击 -- Y坐标:'+ event.touches[0].screenY);
  841. this.aixinLeft = event.touches[0].screenX - 50;
  842. this.aixinTop = event.touches[0].screenY - 50;
  843. this.isShowAixin = true;
  844. let max = 40; let min = -40;
  845. this.Rotate = Math.floor(Math.random() * (max - min + 1)) + min;
  846. setTimeout(()=>{
  847. this.isShowAixin = false;
  848. },700)
  849. this.onTabItemTaps();
  850. }
  851. },
  852. //点击播放&&暂停
  853. tapVideoHover(state,event){
  854. this.dataList[this.k].isShowimage = false
  855. this.dataList[this.k].isShowProgressBarTime = false
  856. this.ProgressBarOpacity = 0.5
  857. this.dotWidth = 0
  858. console.log('state--',state);
  859. // 1.启用双击点赞 --- start
  860. this.touchNum++;
  861. setTimeout(()=>{
  862. if(this.touchNum == 1){
  863. if(state=='play'||state=='continue'){
  864. this.dataList[this.k].state = 'pause';
  865. }else{
  866. this.dataList[this.k].state = 'continue';
  867. }
  868. if(this.dataList[this.k].state == 'continue'){
  869. uni.createVideoContext(this.dataList[this.k].id,this).play();//暂停以后继续播放
  870. }
  871. if(this.dataList[this.k].state == 'pause'){
  872. uni.createVideoContext(this.dataList[this.k].id,this).pause();//暂停以后继续播放
  873. }
  874. }
  875. if(this.touchNum >= 2){
  876. // this.doubleLike();
  877. }
  878. this.touchNum = 0;
  879. },200)
  880. // --------------- ending
  881. // 2. 不启用双击点赞 start
  882. // if(state=='play'||state=='continue'){
  883. // this.dataList[this.k].state = 'pause';
  884. // }else{
  885. // this.dataList[this.k].state = 'continue';
  886. // }
  887. // if(this.dataList[this.k].state == 'continue'){
  888. // uni.createVideoContext(this.dataList[this.k].id,this).play();//暂停以后继续播放
  889. // }
  890. // if(this.dataList[this.k].state == 'pause'){
  891. // uni.createVideoContext(this.dataList[this.k].id,this).pause();//暂停以后继续播放
  892. // }
  893. // --------------- ending
  894. },
  895. doubleLike(){
  896. if(this.dataList[this.k].is_like == false){
  897. this.dataList[this.k].like_num += 1;
  898. this.dataList[this.k].is_like = true;
  899. }
  900. /*
  901. 点赞
  902. */
  903. },
  904. toComment(item){
  905. // 注意点击评论之后会执行这里
  906. /*
  907. (1)先加载缓冲
  908. (2)获取当前视频 ID 信息
  909. (3)🌟🌟🌟🌟重要🌟🌟🌟🌟
  910. - 一定要记得看 index.vue 里面
  911. uni.setStorageSync("user",this.peopleList[i]);
  912. 这个东西,用于存储当前用户信息。在 插件里面会使用到这个东西,
  913. 记得写一下。
  914. (4)打开评论
  915. */
  916. uni.showToast({
  917. title: '加载中...',
  918. icon: 'none',
  919. position: 'bottom',
  920. duration: 300
  921. })
  922. uni.setStorageSync("videoID",parseInt(item.id));
  923. uni.setStorageSync("pinlunNum",item.comment_num);
  924. this.$refs.pinglun.open('bottom')
  925. },
  926. wxh5Video(){
  927. uni.navigateTo({
  928. url: '../wxh5previewVideo/wxh5previewVideo'
  929. })
  930. },
  931. previewVideo(){
  932. uni.navigateTo({
  933. url: '../previewVideo/previewVideo'
  934. })
  935. },
  936. toTwoVideo(){
  937. uni.navigateTo({
  938. url: '../new_index/new_index'
  939. })
  940. },
  941. tolistVideo(){
  942. uni.navigateTo({
  943. url: '../nvueSwiper/nvueSwiper'
  944. })
  945. },
  946. cLike(item){
  947. markeVideo('like',item.id).then(res=>{
  948. this.dataList[this.k].is_like = !this.dataList[this.k].is_like
  949. const video = this.dataList[this.k];
  950. item.is_like?video.like_num += 1:video.like_num -= 1;
  951. }).catch(err=>{
  952. return uni.showToast({
  953. title: err,
  954. icon: 'none',
  955. duration: 2000
  956. });
  957. })
  958. /*
  959. 点赞
  960. */
  961. },
  962. /*
  963. 收藏
  964. */
  965. cCollect(item){
  966. markeVideo('collect',item.id).then(res=>{
  967. this.dataList[this.k].is_collect = !this.dataList[this.k].is_collect
  968. const video = this.dataList[this.k];
  969. item.is_collect?video.collect_num += 1:video.collect_num -= 1;
  970. }).catch(err=>{
  971. return uni.showToast({
  972. title: err,
  973. icon: 'none',
  974. duration: 2000
  975. });
  976. })
  977. },
  978. moveHandle(){},
  979. closeScrollview(){
  980. // 点击评论里面的叉叉,就会关闭评论
  981. this.$refs.pinglun.close();
  982. },
  983. closeGoodsList(){
  984. this.$refs.pinglunGoods.close();
  985. },
  986. onTabItemTaps() {
  987. // #ifdef APP-PLUS
  988. if (uni.getSystemInfoSync().platform == "ios") {
  989. let UIImpactFeedbackGenerator = plus.ios.importClass('UIImpactFeedbackGenerator');
  990. let impact = new UIImpactFeedbackGenerator();
  991. impact.prepare();
  992. impact.init(1);
  993. impact.impactOccurred();
  994. }
  995. if (uni.getSystemInfoSync().platform == "android") {
  996. uni.vibrateShort({
  997. success: () => {
  998. console.log('点击震动');
  999. }
  1000. });
  1001. }
  1002. // #endif
  1003. }
  1004. }
  1005. }
  1006. </script>
  1007. <style lang="scss">
  1008. .goodsCart{
  1009. flex-direction: row;
  1010. align-items: center;
  1011. margin-top: 48rpx;
  1012. .pictrue{
  1013. position: relative;
  1014. width: 90rpx;
  1015. .img{
  1016. width: 72rpx;
  1017. height: 72rpx;
  1018. }
  1019. .uni-badge-left-margin{
  1020. position: absolute;
  1021. right: 0;
  1022. top:-4rpx;
  1023. }
  1024. }
  1025. .text{
  1026. width: 574rpx;
  1027. height: 72rpx;
  1028. background: rgba(255,255,255,0.15);
  1029. border-radius: 200rpx;
  1030. border: 4rpx solid rgba(255,255,255,0.1);
  1031. flex-direction: row;
  1032. justify-content: center;
  1033. align-items: center;
  1034. margin-left: 25rpx;
  1035. .lable{
  1036. width: 32rpx;
  1037. height: 32rpx;
  1038. background: linear-gradient(to right, #E93323, #FF7931);
  1039. border-radius: 50%;
  1040. text-align: center;
  1041. line-height: 32rpx;
  1042. color: #fff;
  1043. font-size: 22rpx;
  1044. }
  1045. .see{
  1046. font-size: 22rpx;
  1047. color: #E93323;
  1048. margin-left: 16rpx;
  1049. }
  1050. .line{
  1051. width: 1rpx;
  1052. height: 16rpx;
  1053. background: rgba(255,255,255,0.6);
  1054. margin: 0 12rpx;
  1055. }
  1056. .title{
  1057. width: 250rpx;
  1058. font-size: 22rpx;
  1059. color: #fff;
  1060. }
  1061. .jumpLook{
  1062. font-size: 22rpx;
  1063. margin-left: 42rpx;
  1064. color: #fff;
  1065. }
  1066. }
  1067. }
  1068. .goodsList{
  1069. margin-top: 20rpx;
  1070. .scroll{
  1071. width: 600rpx;
  1072. display: flex;
  1073. flex-direction: row;
  1074. .scroll-item {
  1075. width: 440rpx;
  1076. height: 180rpx;
  1077. background-color: #FFE9EA;
  1078. border-radius: 16rpx;
  1079. margin-right: 24rpx;
  1080. .title{
  1081. width: 100%;
  1082. height: 48rpx;
  1083. flex-direction: row;
  1084. align-items: center;
  1085. padding: 0 12rpx;
  1086. .titleCon{
  1087. font-size: 22rpx;
  1088. font-weight: 500;
  1089. color: #E93323;
  1090. }
  1091. .img{
  1092. width: 24rpx;
  1093. height: 24rpx;
  1094. margin-right: 4rpx;
  1095. }
  1096. }
  1097. .item{
  1098. width: 440rpx;
  1099. background-color: #fff;
  1100. border-radius: 16rpx;
  1101. padding: 14rpx;
  1102. flex-direction: row;
  1103. align-items: center;
  1104. position: relative;
  1105. .pictrue{
  1106. width: 104rpx;
  1107. height: 104rpx;
  1108. border-radius: 16rpx;
  1109. background-color: #ccc;
  1110. margin-right: 12rpx;
  1111. border-radius: 16rpx;
  1112. }
  1113. .text{
  1114. width: 290rpx;
  1115. .textCon{
  1116. height: 66rpx;
  1117. .line1{
  1118. font-size: 12px;
  1119. color: #333;
  1120. }
  1121. }
  1122. .money{
  1123. display: flex;
  1124. flex-direction: row;
  1125. align-items: flex-end;
  1126. .lable{
  1127. font-size: 20rpx;
  1128. }
  1129. .price{
  1130. font-size: 36rpx;
  1131. line-height: 36rpx;
  1132. }
  1133. .priceNum{
  1134. font-size: 20rpx;
  1135. }
  1136. }
  1137. .discount{
  1138. font-weight: 400;
  1139. color: #E93323;
  1140. font-size: 20rpx;
  1141. margin-bottom: 6rpx;
  1142. }
  1143. }
  1144. .bnt{
  1145. width: 96rpx;
  1146. height: 48rpx;
  1147. background: linear-gradient(to right, #E93323, #FF7931);
  1148. border-radius: 26rpx;
  1149. text-align: center;
  1150. line-height: 48rpx;
  1151. position: absolute;
  1152. right: 10rpx;
  1153. bottom: 14rpx;
  1154. font-size: 24rpx;
  1155. color: #fff;
  1156. font-weight: 500;
  1157. }
  1158. }
  1159. }
  1160. }
  1161. }
  1162. .shares{
  1163. opacity: 0.9;
  1164. margin-top: 17px;
  1165. .img{
  1166. width: 30px;
  1167. height: 30px;
  1168. position: absolute;
  1169. right: 6px;
  1170. }
  1171. .text{
  1172. color: #FFFFFF;
  1173. margin-top: 5px;
  1174. font-size: 11px;
  1175. text-align: center;
  1176. font-weight: 400;
  1177. margin-top: 36px;
  1178. }
  1179. }
  1180. .noVideo{
  1181. position: fixed;
  1182. top: 400rpx;
  1183. z-index: 9;
  1184. width:750rpx;
  1185. flex-direction: row;
  1186. justify-content: center;
  1187. .pictrue{
  1188. width: 414rpx;
  1189. height: 256rpx;
  1190. }
  1191. .tips{
  1192. text-align: center;
  1193. margin-top: 14rpx;
  1194. font-size: 26rpx;
  1195. color: #999;
  1196. }
  1197. }
  1198. .footer{
  1199. align-items: center;
  1200. justify-content: space-around;
  1201. flex-direction: row;
  1202. background-color: #161616;
  1203. height: 100rpx;
  1204. position: fixed;
  1205. bottom: 0;
  1206. z-index: 9;
  1207. width: 750rpx;
  1208. line-height: 100rpx;
  1209. .items{
  1210. color: #999999;
  1211. font-size: 30rpx;
  1212. width: 50%;
  1213. text-align: center;
  1214. .itemCon{
  1215. position: relative;
  1216. }
  1217. .cart{
  1218. color: #999999;
  1219. font-size: 30rpx;
  1220. display: flex;
  1221. height: 100rpx;
  1222. line-height: 100rpx;
  1223. }
  1224. &.on{
  1225. color: #fff;
  1226. }
  1227. .uni-badge-left-margin{
  1228. position: absolute;
  1229. right: 0px;
  1230. top: 5px;
  1231. }
  1232. .uni-badge{
  1233. border: 1px solid #e93323;
  1234. background-color: #e93323;
  1235. }
  1236. .cartNum{
  1237. position:absolute;
  1238. height: 28rpx;
  1239. background: #E93323;
  1240. border-radius: 15rpx;
  1241. color: #fff;
  1242. line-height: 27rpx;
  1243. padding: 0 8rpx;
  1244. right: 0px;
  1245. top: 20rpx;
  1246. font-size: 22rpx;
  1247. }
  1248. }
  1249. }
  1250. .header {
  1251. position: fixed;
  1252. z-index: 9;
  1253. width: 750rpx;
  1254. // flex-direction: row;
  1255. // justify-content: center;
  1256. .sys-title{
  1257. width: 750rpx;
  1258. height: 200rpx;
  1259. position: relative;
  1260. flex-direction: row;
  1261. align-items: center;
  1262. justify-content: center;
  1263. .name{
  1264. color: #FFFFFF;
  1265. font-size: 34rpx;
  1266. }
  1267. .returnImg{
  1268. position: absolute;
  1269. top:50%;
  1270. left:20rpx;
  1271. width: 40rpx;
  1272. height: 40rpx;
  1273. margin-top: -20rpx;
  1274. }
  1275. }
  1276. }
  1277. .container {background-color: #000000;}
  1278. .item {
  1279. /* width : 750rpx; */
  1280. background-color: #000000;
  1281. position: relative;
  1282. }
  1283. .videoHover{
  1284. position: absolute;
  1285. top: 0;
  1286. left: 0;
  1287. flex: 1;
  1288. background-color: rgba(0,0,0,0.1);
  1289. justify-content: center;
  1290. align-items: center;
  1291. /* border-style: dashed;
  1292. border-color: #DD524D;
  1293. border-width: 1px; */
  1294. }
  1295. .playState{
  1296. width: 160rpx;
  1297. height: 160rpx;
  1298. opacity: 0.2;
  1299. }
  1300. .userInfo{
  1301. position: absolute;
  1302. bottom:90px;
  1303. right: 10px;
  1304. flex-direction: column;
  1305. }
  1306. .userAvatar{
  1307. width : 96rpx;
  1308. height: 96rpx;
  1309. border-radius: 100%;
  1310. margin-bottom: 15px;
  1311. border:1px solid #fff;
  1312. }
  1313. .likeIco,.shareIco,.commentIco{
  1314. width : 60rpx;
  1315. height: 60rpx;
  1316. margin-top: 15px;
  1317. }
  1318. .likeNum,.commentNum,.shareTex{
  1319. color: #ffffff;
  1320. font-size: 30rpx;
  1321. text-align: center;
  1322. margin: 5px;
  1323. }
  1324. .content{
  1325. width: 720rpx;
  1326. z-index: 99;
  1327. position: absolute;
  1328. bottom: 20px;
  1329. /* justify-content: center; */
  1330. padding: 15rpx;
  1331. flex-direction: column;
  1332. justify-content: flex-start;
  1333. color: #ffffff;
  1334. left:5px;
  1335. .time{
  1336. font-size: 24rpx;
  1337. color: rgba(255,255,255,0.5);
  1338. margin-left: 12rpx;
  1339. }
  1340. .cart{
  1341. background: rgba(153,153,153,0.3);
  1342. width: 376rpx;
  1343. height: 48rpx;
  1344. border-radius: 4rpx;
  1345. margin-bottom: 22rpx;
  1346. flex-direction:row;
  1347. justify-content: center;
  1348. align-items: center;
  1349. .cartPic{
  1350. width: 36rpx;
  1351. height: 36rpx;
  1352. margin-right: 14rpx;
  1353. }
  1354. .cartName{
  1355. font-size: 24rpx;
  1356. color: #fff;
  1357. }
  1358. .line{
  1359. width: 2rpx;
  1360. height: 22rpx;
  1361. background-color: rgba(255,255,255,0.3);
  1362. margin: 0 12rpx;
  1363. }
  1364. }
  1365. }
  1366. .timeCon{
  1367. flex-direction:row;
  1368. align-items: center;
  1369. .userName {
  1370. font-size: 32rpx;
  1371. color: #ffffff;
  1372. font-weight: 500;
  1373. }
  1374. }
  1375. .words {
  1376. margin-top: 12rpx;
  1377. .close{
  1378. display: flex;
  1379. flex-direction: row;
  1380. align-items: center;
  1381. justify-content: flex-end;
  1382. margin-right: 20rpx;
  1383. .imgClose{
  1384. width: 18rpx;
  1385. height: 10rpx;
  1386. margin-left: 10rpx;
  1387. }
  1388. }
  1389. .wordsCon{
  1390. position: relative;
  1391. .more{
  1392. position: absolute;
  1393. bottom: 0;
  1394. right: 40rpx;
  1395. font-size: 26rpx;
  1396. }
  1397. .img{
  1398. width: 18rpx;
  1399. height: 10rpx;
  1400. margin-left: 4rpx;
  1401. position: absolute;
  1402. bottom: 7rpx;
  1403. right: 20rpx;
  1404. }
  1405. }
  1406. .info{
  1407. color: #fff;
  1408. font-size: 28rpx;
  1409. }
  1410. .more{
  1411. font-size: 26rpx;
  1412. color: #AAAAAA;
  1413. font-weight: 400;
  1414. }
  1415. }
  1416. .root{
  1417. background-color: #000000;
  1418. }
  1419. </style>