index.nvue 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  1. <template>
  2. <view class="shortVideo">
  3. <!--
  4. 注意:这是 H5、微信小程序界面,请勿和 new_index.nvue、index.nvue 混用
  5. 1. new_index.nvue、index.nvue这两个是App页面
  6. 2. 另外:data.js 是上一版本留下的假数据,这一版改成了 URL 请求了(如不需要可以删除,也可作为后端请求参考)
  7. 3. 请各位大神多多留手,我已经把请求内存开到最大了
  8. 4. 视频 id 切记是字符串类型
  9. -->
  10. <!-- <view class="footer acea-row row-around row-middle">
  11. <text class="items" @click="goIndex">首页</text>
  12. <text class="items on">视频</text>
  13. <view class="items" @click="goCarts"><text>购物车</text>
  14. <uni-badge v-if="cartNum>0" class="uni-badge-left-margin" type='error' :text="cartNum" />
  15. </view>
  16. <text class="items" @click="goUser">我的</text>
  17. </view> -->
  18. <view class="header">
  19. <view>
  20. <!-- #ifdef MP -->
  21. <view :style="{height:getHeight.barTop+'px'}"></view>
  22. <view class="sys-title" :style="{height:getHeight.barHeight+'px'}" v-if="dataList[k]">
  23. <view v-if="dataList.length && dataList[k].desc.length>=8">{{dataList[k].desc.slice(0,8)}}...</view>
  24. <view v-else>{{dataList[k].desc}}</view>
  25. <image src="../static/img/index/f.png" @click="returnPage"></image>
  26. </view>
  27. <!-- #endif -->
  28. <!-- #ifndef MP -->
  29. <view class="sys-title on" v-if="dataList[k]">
  30. <view v-if="dataList.length && dataList[k].desc.length>=8">{{dataList[k].desc.slice(0,8)}}...</view>
  31. <view v-else>{{dataList[k].desc}}</view>
  32. <image src="../static/img/index/f.png" @click="returnPage"></image>
  33. </view>
  34. <!-- #endif -->
  35. </view>
  36. </view>
  37. <view class="noVideo acea-row row-center-wrapper" v-if="!dataList.length">
  38. <view>
  39. <image :src="imgHost+'/statics/images/no-video.png'" class="pictrue"></image>
  40. <text class="tips">暂无短视频内容哦~</text>
  41. </view>
  42. </view>
  43. <image v-if="isShowAixin" src="../static/img/index/aixining.png"
  44. :style="'position: fixed; margin-left: '+ aixinLeft +'px; margin-top: '+ aixinTop +'px; width: 70px; height: 65px; transform: rotate('+ Rotate +'deg);'">
  45. </image>
  46. <swiper :style="'width: '+ windowWidth +'px; height: '+ (windowHeight) +'px; background-color: #000000;'"
  47. :vertical="true" @animationfinish="animationfinish" previous-margin="0rpx" @change="change" :current="k"
  48. :indicator-dots="false">
  49. <swiper-item v-for="(list,index) in dataList">
  50. <view v-if="Math.abs(k-index)<=1">
  51. <view>
  52. <!--
  53. 1.v-if:用于控制视频在节点的渲染数
  54. 2.muted的默认值是 false,代表默认是禁音视频的
  55. 3.http-cache默认开启视频缓存
  56. 4.poster(封面(方案一)):这里的封面默认处理存储在阿里云的视频
  57. 5.show-loading:这里默认去掉播放转圈的标志
  58. v-if="Math.abs(k-index)<=1"
  59. -->
  60. <video :id="list.id+''+index" :loop="true" :muted="list.isplay" :controls="false"
  61. :http-cache="true" :page-gesture="false" :show-fullscreen-btn="false" :show-loading="false"
  62. :show-center-play-btn="false" :enable-progress-gesture="false" :src="list.video_url"
  63. @ended="ended" @click="tapVideoHover(list.state,$event)"
  64. :style="'width: '+ windowWidth +'px; height: '+ windowHeight +'px; background-color: #000000; z-index: -1;'"
  65. :poster="list.video_url+'?x-oss-process=video/snapshot,t_100,f_jpg'"></video>
  66. <!--
  67. 1.这里是封面(方案二):这里的封面可以自定义。
  68. 2.也在代码中做了批注,两种方案可以共存,不会相互影响。
  69. -->
  70. <image v-if="!list.playIng" :src="list.video_url+'?x-oss-process=video/snapshot,t_100,f_jpg'"
  71. :style="'width: '+ windowWidth +'px; height: '+ windowHeight +'px; position: absolute;'"
  72. mode="aspectFit"></image>
  73. </view>
  74. <!-- 播放状态:pause 的时候就会暂停 -->
  75. <view class="videoHover" @click="tapVideoHover(list.state,$event)" @touchstart="touchstartHover"
  76. :style="'width: '+ windowWidth +'px; height: '+ windowHeight +'px;'">
  77. <image v-if="list.state=='pause'" class="playState" src="../static/img/index/play.png"></image>
  78. </view>
  79. <view class="userInfo">
  80. <!-- 1.头像 -->
  81. <view class="pictrue">
  82. <image @click="tozuozhe(list)" class="userAvatar" :style="list.is_live?'border-width:0':''"
  83. :src="list.type_image" mode="aspectFill"></image>
  84. <!-- #ifdef MP -->
  85. <view class="live" v-if="list.is_live" @click="goLive"></view>
  86. <!-- #endif -->
  87. </view>
  88. <!-- 2.点赞 -->
  89. <view @click="cLike(list);" class="likes">
  90. <image v-if="list.is_like" src="../static/img/index/xin.png"></image>
  91. <image v-if="!list.is_like" src="../static/img/index/xin-2.png"></image>
  92. <text :class="{'likeNumActive':list.is_like}">{{list.like_num>0?list.like_num:'点赞'}}</text>
  93. </view>
  94. <!-- 收藏 -->
  95. <view @click="cCollect(list)" class="collects">
  96. <image v-if="list.is_collect" src="../static/img/index/collection02.png"></image>
  97. <image v-if="!list.is_collect" src="../static/img/index/collection01.png"></image>
  98. <text :class="{'likeNumActive':list.is_collect}">{{list.collect_num>0?list.collect_num:'收藏'}}</text>
  99. </view>
  100. <!-- 3.评论 -->
  101. <view class="comment" @click="toComment(list)" style="opacity: 0.9; margin-top: 18px;">
  102. <image src="../static/img/index/evaluate.png"></image>
  103. <text>{{list.comment_num>0?list.comment_num:'抢首评'}}</text>
  104. </view>
  105. <!-- 4.分享 -->
  106. <!-- #ifdef H5 -->
  107. <view @click="share(list.id)" class="shares" v-if="$wechat.isWeixin()">
  108. <image src="../static/img/index/we-chat.png"></image>
  109. <text>分享</text>
  110. </view>
  111. <view @click="getId(list.id)" class="shares copy-data"
  112. :data-clipboard-text="imgHost+'/pages/short_video/nvueSwiper/index?id='+ list.id" v-else>
  113. <image src="../static/img/index/we-chat.png"></image>
  114. <text>分享</text>
  115. </view>
  116. <!-- #endif -->
  117. <!-- #ifdef MP -->
  118. <button open-type="share" hover-class="none"
  119. style="margin-top: 17px;background-color: transparent;position: relative;height: 85rpx;"
  120. @click="getId(list.id)">
  121. <image src="../static/img/index/we-chat.png"
  122. style="width: 62rpx; height: 48rpx; position: absolute; right: 5px;"></image>
  123. <text
  124. style="color: #FFFFFF; font-size: 12px; text-align: center;position: absolute;top:52rpx;right: 24rpx;">分享</text>
  125. </button>
  126. <!-- <button class="item" open-type="share" hover-class="none">
  127. <view class="pictrue">
  128. <image src="../../static/images/weixin.png"></image>
  129. </view>
  130. <view class="">分享给好友</view>
  131. </button> -->
  132. <!-- #endif -->
  133. </view>
  134. <!-- 最底下的文字部分 -->
  135. <view class="content">
  136. <!-- <view class="cart" @click="goCart(list)" v-if="list.product_num>0">
  137. <image class="cartPic" src="../static/img/index/shopping-car.png"></image>
  138. <text class="cartName">购物</text>
  139. <text class="line"></text>
  140. <text class="cartName">视频款请点击这里购买</text>
  141. </view> -->
  142. <view class="timeCon" :style="'width: '+ (windowWidth - 90) +'px;'">
  143. <text class="userName line1"
  144. :style="'max-width: '+ (windowWidth-160) +'px;'">@{{list.type_name}}</text>
  145. <!-- <text class="time">.{{list.date}}</text> -->
  146. </view>
  147. <view class="words" :style="'width: '+ (windowWidth - 120) +'px;'">
  148. <view v-if="list.isMore || list.desc.length<=33">
  149. <text class="info">{{list.desc}}</text>
  150. <!-- <view class="close">
  151. <text v-if="list.isMore" class="more" @click="moreTap(list)">收起</text>
  152. <image v-if="list.isMore" class="imgClose" src="../static/img/index/drop-down.png">
  153. </image>
  154. </view> -->
  155. </view>
  156. <view class="wordsCon" v-else>
  157. <text class="info">{{list.desc.slice(0,33)}}...</text>
  158. <!-- <text class="more" @click="moreTap(list)">更多</text>
  159. <image class="img" src="../static/img/index/drop-down.png"></image> -->
  160. </view>
  161. </view>
  162. <view class="goodsList" v-if="goodsList.length">
  163. <scroll-view scroll-x="true" class="scroll">
  164. <view class="scroll-item" v-for="(goodsItem,goodsIndex) in goodsList" :key="goodsIndex">
  165. <view class="title">
  166. <image src="../static/img/index/shopping-car.png"></image>
  167. <view>商品热卖中</view>
  168. </view>
  169. <view class="item" @click="goDetails(goodsItem)">
  170. <view class="pictrue">
  171. <image :src="goodsItem.image"></image>
  172. </view>
  173. <view class="text">
  174. <view class="textCon">
  175. <view class="line1" v-if="goodsItem.store_name.length>=11">{{goodsItem.store_name.slice(0,11)}}...</view>
  176. <view class="line1" v-else>{{goodsItem.store_name}}</view>
  177. <view class="discount" v-if="goodsItem.promotions.title">{{goodsItem.promotions.title}}</view>
  178. </view>
  179. <baseMoney :money="goodsItem.price" color='#333' symbolSize="20" integerSize="36"
  180. decimalSize="20" weight></baseMoney>
  181. </view>
  182. <view class="bnt">购买</view>
  183. </view>
  184. </view>
  185. </scroll-view>
  186. </view>
  187. <view class="goodsCart">
  188. <view class="pictrue" @click="goCart(list)" v-if="list.product_num>0">
  189. <image src="../static/img/index/goodsCart.png"></image>
  190. <uni-badge v-if="goodsCount>0" class="uni-badge-left-margin" :text="goodsCount" />
  191. </view>
  192. <view class="text" @click="navTap(1)" v-if="recommend">
  193. <view class="lable">#</view>
  194. <view class="see">大家都在看</view>
  195. <view class="line"></view>
  196. <view class="title" v-if="recommend && recommend.length>=10">{{recommend.slice(0,10)}}...</view>
  197. <view class="title" v-else>{{recommend}}</view>
  198. <view class="jumpLook">查看</view>
  199. </view>
  200. </view>
  201. </view>
  202. </view>
  203. </swiper-item>
  204. </swiper>
  205. <uni-popup type="bottom" ref="pinglun" @touchmove.stop.prevent="moveHandle">
  206. <view
  207. :style="'width: '+ windowWidth +'px;background-color: #fff; border-top-left-radius: 16px; border-top-right-radius: 16px;'">
  208. <!--
  209. 注意:
  210. deleteIOSHeight
  211. deleteAndroidHeight
  212. 这两个参数用于控制评论等的高度
  213. -->
  214. <douyin-scrollview v-if="isComment" ref="comments" :Width="windowWidth" :Height="(boxStyle.height/1.23)"
  215. :deleteIOSHeight="36" :deleteAndroidHeight="15" :pinlunNum="pinlunNum" :videoID="videoID"
  216. @closeScrollview="closeScrollview" @pinlunFun="pinlunFun"></douyin-scrollview>
  217. </view>
  218. </uni-popup>
  219. <uni-popup type="bottom" ref="pinglunGoods" @touchmove.stop.prevent="moveHandle">
  220. <view
  221. :style="'width: '+ windowWidth +'px; background-color: #F5F5F5; border-top-left-radius: 16px; border-top-right-radius: 16px;'">
  222. <goodsList ref="goodsLists" :Width="windowWidth" :Height="(boxStyle.height/1.18)" @closeGoodsList="closeGoodsList"></goodsList>
  223. </view>
  224. </uni-popup>
  225. <image v-if="H5ShareBox" class="shareImg" :src="imgHost + '/statics/images/share-info.png'"
  226. @click="H5ShareBox = false"></image>
  227. </view>
  228. </template>
  229. <script>
  230. const app = getApp();
  231. // import userList from '../new_index/data.js'//这个是假数据
  232. import {
  233. toLogin
  234. } from '@/libs/login.js';
  235. import {
  236. mapGetters
  237. } from 'vuex';
  238. /*
  239. 引入评论组件
  240. */
  241. import douyinScrollview from '../components/douyin-scrollview/douyin-scrollview.vue'
  242. import goodsList from '../components/goodsList/index.vue'
  243. import {
  244. HTTP_REQUEST_URL
  245. } from '@/config/app';
  246. import {
  247. videoList,
  248. markeVideo,
  249. videoProduct,
  250. videoInfo
  251. } from '@/api/short-video.js';
  252. import {
  253. getCartCounts,
  254. } from '@/api/order.js';
  255. import ClipboardJS from "@/plugin/clipboard/clipboard.js";
  256. export default {
  257. components: {
  258. douyinScrollview,
  259. goodsList
  260. },
  261. computed: mapGetters(['isLogin', 'uid', 'cartNum']),
  262. data() {
  263. return {
  264. // #ifdef MP
  265. getHeight: this.$util.getWXStatusHeight(),
  266. // #endif
  267. imgHost: HTTP_REQUEST_URL,
  268. videoID: 0, //视频id
  269. pinlunNum: 0,
  270. windowWidth: 0,
  271. windowHeight: 0,
  272. platform: "",
  273. deleteHeight: 0,
  274. isComment: 0,
  275. dataList: [],
  276. k: 0,
  277. oldVideo: "",
  278. voice: "",
  279. timeout: "",
  280. current: 0,
  281. boxStyle: { //视频,图片封面样式🌟💗
  282. 'height': 0,
  283. 'width': 0,
  284. },
  285. // 引入评论 - 参数
  286. heightNum: 1.3,
  287. // 双击点赞参数
  288. touchNum: 0,
  289. aixinLeft: 0,
  290. aixinTop: 0,
  291. isShowAixin: false,
  292. Rotate: 0,
  293. currentNav: 1,
  294. limit: 3,
  295. page: 1,
  296. oldCurrent: 1,
  297. H5ShareBox: false,
  298. goodsList: [],
  299. goodsCount: 0,
  300. recommend:''
  301. }
  302. },
  303. watch: {
  304. currentNav(news, old) {
  305. this.oldCurrent = old;
  306. },
  307. k(k, old_k) {
  308. if (this.oldCurrent != this.currentNav) {
  309. this.oldCurrent = this.currentNav
  310. return false
  311. }
  312. this.dataList[old_k].playIng = false //如果视频暂停,就加载封面
  313. this.dataList[old_k].isplay = true
  314. this.dataList[old_k].state = 'pause'
  315. console.log('预留第' + (old_k + 1) + '个视频:' + this.dataList[old_k].id + '' + old_k)
  316. // 2.0版本已经去掉了下面这一句,视频不用暂停,只需要把声音禁止就行
  317. uni.createVideoContext(this.dataList[old_k].id + '' + old_k, this)
  318. .stop() //如果视频暂停,那么旧视频停止,这里的this.dataList[old_k].id + '' + old_k,后面加 old_k 是为了每一个视频的 id 值不同,这样就可以大程度的避免串音问题
  319. console.log('已经暂停 --> 第' + (old_k + 1) + '个视频~') //提示
  320. this.dataList[k].state = 'play'
  321. setTimeout(() => {
  322. uni.createVideoContext(this.dataList[k].id + '' + k, this).play()
  323. setTimeout(() => {
  324. this.dataList[k].isplay = false
  325. this.dataList[k].playIng = true
  326. }, 50)
  327. }, 250)
  328. var p = k + 1;
  329. // console.log('预加载第' + (p + 1) + '个视频:' + this.dataList[p].id+''+p)
  330. }
  331. },
  332. onLoad(options) {
  333. this.videoID = options.id || 0;
  334. this.getOptions(options);
  335. this.platform = uni.getSystemInfoSync().platform
  336. var model = uni.getSystemInfoSync().model
  337. if (this.platform == 'ios' && (model !== 'iPhone6' || model !== 'iPhone6s' || model !== 'iPhone7' || model !==
  338. 'iPhone8')) {
  339. this.deleteHeight = 0 //有 tabbar的 修改这里可以改变视频高度
  340. }
  341. this.windowWidth = uni.getSystemInfoSync().windowWidth
  342. this.windowHeight = uni.getSystemInfoSync().windowHeight
  343. this.boxStyle.width = this.windowWidth + 'px' //给宽度加px
  344. this.boxStyle.height = this.windowHeight - this.deleteHeight; //有 tabbar的 修改这里可以改变视频高度
  345. this.get() //刚进入页面加载数据
  346. if (this.isLogin) {
  347. this.getCartNum()
  348. }
  349. },
  350. onShow() {
  351. if (this.dataList.length !== 0) {
  352. this.dataList[this.k].state = 'play';
  353. uni.createVideoContext(this.dataList[this.k].id + '' + this.k, this).play()
  354. }
  355. },
  356. onHide() {
  357. this.dataList[this.k].state = 'pause'; //界面隐藏也要停止播放视频
  358. uni.createVideoContext(this.dataList[this.k].id + '' + this.k, this).pause(); //暂停以后继续播放
  359. console.log('到后台');
  360. },
  361. onReady: function() {
  362. // #ifdef H5
  363. this.$nextTick(function() {
  364. const clipboard = new ClipboardJS(".copy-data");
  365. clipboard.on("success", () => {
  366. this.$util.Tips({
  367. title: '复制成功'
  368. });
  369. });
  370. });
  371. // #endif
  372. },
  373. // #ifdef MP
  374. onShareAppMessage: function() {
  375. let uid = this.uid ? this.uid : 0;
  376. let data = this.dataList[this.k];
  377. this.cShare(this.videoID);
  378. return {
  379. title: data.type_name || '',
  380. imageUrl: data.image || '',
  381. path: '/pages/short_video/nvueSwiper/index?spid=' + uid + '&id=' + this.videoID
  382. };
  383. },
  384. // #endif
  385. methods: {
  386. // 返回上一页
  387. returnPage(){
  388. uni.switchTab({
  389. url: '/pages/index/index'
  390. });
  391. },
  392. goDetails(item){
  393. uni.navigateTo({
  394. url: `/pages/goods_details/index?id=${item.id}`
  395. });
  396. },
  397. productList(id){
  398. videoProduct(id).then(res=>{
  399. this.goodsCount = res.data.count;
  400. this.goodsList = res.data.list;
  401. }).catch(err=>{
  402. uni.showToast({
  403. title: err,
  404. icon: 'none',
  405. duration: 2000
  406. });
  407. })
  408. },
  409. getVideoInfo(id){
  410. videoInfo(id).then(res=>{
  411. this.recommend = res.data.recommend.desc;
  412. this.videoID = res.data.recommend.id;
  413. }).catch(err=>{
  414. uni.showToast({
  415. title: err,
  416. icon: 'none',
  417. duration: 2000
  418. });
  419. })
  420. },
  421. getCartNum: function() {
  422. getCartCounts().then(res => {
  423. this.$store.commit('indexData/setCartNum', res.data.count +'')
  424. });
  425. },
  426. goIndex() {
  427. uni.switchTab({
  428. url: '/pages/index/index'
  429. })
  430. },
  431. goCarts() {
  432. uni.switchTab({
  433. url: '/pages/order_addcart/order_addcart'
  434. })
  435. },
  436. goUser() {
  437. uni.switchTab({
  438. url: '/pages/user/index'
  439. })
  440. },
  441. goLive() {
  442. uni.navigateTo({
  443. url: `/pages/columnGoods/live_list/index`
  444. });
  445. },
  446. tozuozhe(item) {
  447. if (item.type == 0) {
  448. uni.reLaunch({
  449. url: `/pages/index/index`
  450. });
  451. } else {
  452. uni.reLaunch({
  453. url: `/pages/store_cate/store_cate?id=` + item.relation_id
  454. });
  455. }
  456. },
  457. getOptions(options) {
  458. let that = this;
  459. // #ifdef MP
  460. if (options.scene) {
  461. let value = that.$util.getUrlParams(decodeURIComponent(options.scene));
  462. //记录推广人uid
  463. if (value.spid) app.globalData.spid = value.spid;
  464. if (value.id) that.videoID = value.id || 0;
  465. }
  466. // #endif
  467. if (options.spid) app.globalData.spid = options.spid;
  468. },
  469. // #ifdef H5
  470. // 微信分享;
  471. setOpenShare: function(id) {
  472. let that = this;
  473. let uid = this.uid ? this.uid : 0;
  474. let href = location.href;
  475. if (that.$wechat.isWeixin()) {
  476. let data = this.dataList[that.k];
  477. let configAppMessage = {
  478. desc: data.desc,
  479. title: data.type_name,
  480. link: href.indexOf('?') === -1 ? href + '?spid=' + uid + '&id=' + id : href + '&spid=' +
  481. uid + '&id=' + id,
  482. imgUrl: data.image,
  483. success:function(res){
  484. that.cShare(id);
  485. }
  486. };
  487. that.$wechat.wechatEvevt(['updateAppMessageShareData', 'updateTimelineShareData',
  488. 'onMenuShareAppMessage',
  489. 'onMenuShareTimeline'
  490. ],
  491. configAppMessage);
  492. }
  493. },
  494. // #endif
  495. goCart(item) {
  496. if (this.isLogin === false) {
  497. // #ifndef MP
  498. return toLogin();
  499. // #endif
  500. // #ifdef MP
  501. uni.showToast({
  502. title: '请登录',
  503. icon: 'none',
  504. duration: 1000
  505. });
  506. return
  507. // #endif
  508. }
  509. // uni.showToast({
  510. // title: '加载中...',
  511. // icon: 'none',
  512. // position: 'bottom',
  513. // duration: 300
  514. // })
  515. // #ifdef H5
  516. uni.setStorageSync("videoID", parseInt(item.id));
  517. // #endif
  518. // #ifdef MP
  519. this.$refs.goodsLists.productList(item.id, 1);
  520. // #endif
  521. this.$refs.pinglunGoods.open('bottom')
  522. },
  523. navTap(n) {
  524. this.currentNav = n;
  525. this.timeout = "";
  526. this.k = 0;
  527. this.page = 1;
  528. this.dataList = [];
  529. this.get();
  530. },
  531. moreTap(item) {
  532. item.isMore = !item.isMore;
  533. },
  534. moveHandle() {},
  535. closeScrollview() {
  536. // 点击评论里面的叉叉,就会关闭评论
  537. this.$refs.pinglun.close();
  538. this.isComment = false
  539. },
  540. closeGoodsList(){
  541. this.$refs.pinglunGoods.close();
  542. },
  543. pinlunFun(e,videoID) {
  544. this.pinlunNum = e;
  545. this.dataList.forEach(item => {
  546. if (item.id == videoID) {
  547. item.comment_num = e;
  548. }
  549. })
  550. // this.isComment = false
  551. },
  552. toComment(item) {
  553. this.isComment = true
  554. console.log('我被点了')
  555. // 注意点击评论之后会执行这里
  556. /*
  557. (1)先加载缓冲
  558. (2)获取当前视频 ID 信息
  559. (3)🌟🌟🌟🌟重要🌟🌟🌟🌟
  560. - 一定要记得看 index.vue 里面
  561. uni.setStorageSync("user",this.peopleList[i]);
  562. 这个东西,用于存储当前用户信息。在 插件里面会使用到这个东西,
  563. 记得写一下。
  564. (4)打开评论
  565. */
  566. uni.showToast({
  567. title: '加载中...',
  568. icon: 'none',
  569. position: 'bottom',
  570. duration: 300
  571. })
  572. this.$nextTick(e => {
  573. this.pinlunNum = item.comment_num;
  574. // #ifdef H5
  575. this.videoID = parseInt(item.id);
  576. // #endif
  577. // #ifdef MP
  578. this.$refs.comments.getnewpinlun(item.id, 1);
  579. // #endif
  580. this.$refs.pinglun.open('bottom')
  581. })
  582. },
  583. ended() {
  584. // 1.播放当前视频结束时触发,自动切换下一个视频
  585. // this.current = this.k+1
  586. },
  587. // 双击点赞效果
  588. touchstartHover(event) {
  589. if (this.touchNum >= 1) {
  590. // console.log('双击 -- X坐标:'+ event.touches[0].screenX);
  591. // console.log('双击 -- Y坐标:'+ event.touches[0].screenY);
  592. this.aixinLeft = event.touches[0].screenX - 50;
  593. this.aixinTop = event.touches[0].screenY - 50;
  594. this.isShowAixin = true;
  595. let max = 40;
  596. let min = -40;
  597. this.Rotate = Math.floor(Math.random() * (max - min + 1)) + min;
  598. setTimeout(() => {
  599. this.isShowAixin = false;
  600. }, 700)
  601. }
  602. },
  603. //点击播放&&暂停
  604. tapVideoHover(state, event) {
  605. this.dataList[this.k].isShowimage = false
  606. this.dataList[this.k].isShowProgressBarTime = false
  607. this.ProgressBarOpacity = 0.5
  608. this.dotWidth = 0
  609. console.log('state--', state);
  610. // 1.启用双击点赞 --- start
  611. this.touchNum++;
  612. setTimeout(() => {
  613. if (this.touchNum == 1) {
  614. if (state == 'play' || state == 'continue') {
  615. this.dataList[this.k].state = 'pause';
  616. } else {
  617. this.dataList[this.k].state = 'continue';
  618. }
  619. if (this.dataList[this.k].state == 'continue') {
  620. uni.createVideoContext(this.dataList[this.k].id + '' + this.k, this).play(); //暂停以后继续播放
  621. }
  622. if (this.dataList[this.k].state == 'pause') {
  623. uni.createVideoContext(this.dataList[this.k].id + '' + this.k, this)
  624. .pause(); //暂停以后继续播放
  625. }
  626. }
  627. if (this.touchNum >= 2) {
  628. // this.doubleLike();
  629. }
  630. this.touchNum = 0;
  631. }, 200)
  632. // --------------- ending
  633. // 2. 不启用双击点赞 start
  634. // if(state=='play'||state=='continue'){
  635. // this.dataList[this.k].state = 'pause';
  636. // }else{
  637. // this.dataList[this.k].state = 'continue';
  638. // }
  639. // if(this.dataList[this.k].state == 'continue'){
  640. // uni.createVideoContext(this.dataList[this.k].id+''+this.k,this).play();//暂停以后继续播放
  641. // }
  642. // if(this.dataList[this.k].state == 'pause'){
  643. // uni.createVideoContext(this.dataList[this.k].id+''+this.k,this).pause();//暂停以后继续播放
  644. // }
  645. // --------------- ending
  646. },
  647. doubleLike() {
  648. if (this.dataList[this.k].is_like == false) {
  649. this.dataList[this.k].like_num += 1;
  650. this.dataList[this.k].is_like = true;
  651. }
  652. /*
  653. 点赞
  654. */
  655. },
  656. change(event) {
  657. this.k = event.detail.current
  658. this.productList(this.dataList[this.k].id);
  659. this.getVideoInfo(this.dataList[this.k].id);
  660. },
  661. animationfinish(event) {
  662. // 1.这里进行判断,如果是最后一个视频就进入 get() 方法加载视频进入列表
  663. if (this.k == this.dataList.length - 1) {
  664. this.GET()
  665. }
  666. },
  667. //每一组结束时新的请求
  668. GET() {
  669. videoList({
  670. page: this.page,
  671. limit: this.limit,
  672. order_type: this.currentNav,
  673. id: (this.page > 1 || this.currentNav == 2)? 0 : this.videoID
  674. }).then(res => {
  675. this.page = this.page + 1;
  676. var msg = res.data
  677. // 2.这里把视频添加到视频列表
  678. for (let i = 0; i < msg.length; i++) {
  679. this.dataList.push(msg[i])
  680. }
  681. }).catch(err => {
  682. return uni.showToast({
  683. title: err,
  684. icon: 'none',
  685. duration: 2000
  686. });
  687. })
  688. },
  689. get() {
  690. // 1.这里引入后端请求数据
  691. videoList({
  692. page: this.page,
  693. limit: this.limit,
  694. order_type: this.currentNav,
  695. id: (this.page > 1)?0:this.videoID
  696. }).then(res => {
  697. this.page = this.page + 1;
  698. var msg = res.data
  699. // 2.这里把视频添加到视频列表
  700. for (let i = 0; i < msg.length; i++) {
  701. this.dataList.push(msg[i])
  702. }
  703. // #ifdef H5
  704. if (this.isLogin) {
  705. this.setOpenShare(this.videoID);
  706. }
  707. // #endif
  708. this.productList(this.dataList[this.k].id);
  709. this.getVideoInfo(this.dataList[this.k].id);
  710. // 3.播放当前视频
  711. setTimeout(() => {
  712. this.dataList[this.k].isplay = false
  713. this.dataList[this.k].state = 'play'
  714. // uni.createVideoContext(this.dataList[0].id,this).seek(0)
  715. // uni.createVideoContext(this.dataList[0].id,this).play()
  716. uni.createVideoContext(this.dataList[this.k].id + '' + this.k, this).seek(0)
  717. uni.createVideoContext(this.dataList[this.k].id + '' + this.k, this).play()
  718. this.dataList[this.k].playIng = true
  719. }, 200)
  720. // start - 预加载开始
  721. var p = this.k
  722. ++p
  723. if(this.dataList[p].id){
  724. setTimeout(() => {
  725. uni.createVideoContext(this.dataList[p].id + '' + p, this).play()
  726. }, 20)
  727. clearTimeout(this.timeout)
  728. this.timeout = setTimeout(() => {
  729. uni.createVideoContext(this.dataList[p].id + '' + p, this).seek(0)
  730. uni.createVideoContext(this.dataList[p].id + '' + p, this).pause()
  731. console.log('预加载第' + (p + 1) + '个视频:' + this.dataList[p].id + '' + p)
  732. }, 1500)
  733. }
  734. // end - 预加载结束
  735. }).catch(err => {
  736. return uni.showToast({
  737. title: err,
  738. icon: 'none',
  739. duration: 2000
  740. });
  741. })
  742. },
  743. cShare(id){
  744. markeVideo('share',id).then(res=>{}).catch(err=>{
  745. return uni.showToast({
  746. title: err,
  747. icon: 'none',
  748. duration: 2000
  749. });
  750. })
  751. },
  752. getId(id) {
  753. this.videoID = id;
  754. // #ifdef H5
  755. this.cShare(id);
  756. // #endif
  757. },
  758. share(id) {
  759. this.H5ShareBox = true;
  760. // #ifdef H5
  761. if (this.isLogin) {
  762. this.setOpenShare(id);
  763. }
  764. // #endif
  765. },
  766. cLike(item) {
  767. markeVideo('like', item.id).then(res => {
  768. this.dataList[this.k].is_like = !this.dataList[this.k].is_like
  769. const video = this.dataList[this.k];
  770. item.is_like ? video.like_num += 1 : video.like_num -= 1;
  771. }).catch(err => {
  772. return uni.showToast({
  773. title: err,
  774. icon: 'none',
  775. duration: 2000
  776. });
  777. })
  778. },
  779. cCollect(item) {
  780. markeVideo('collect', item.id).then(res => {
  781. this.dataList[this.k].is_collect = !this.dataList[this.k].is_collect
  782. const video = this.dataList[this.k];
  783. item.is_collect ? video.collect_num += 1 : video.collect_num -= 1;
  784. }).catch(err => {
  785. return uni.showToast({
  786. title: err,
  787. icon: 'none',
  788. duration: 2000
  789. });
  790. })
  791. },
  792. }
  793. }
  794. </script>
  795. <style lang="scss">
  796. .goodsCart{
  797. flex-direction: row;
  798. align-items: center;
  799. margin-top: 48rpx;
  800. .pictrue{
  801. position: relative;
  802. width: 72rpx;
  803. image{
  804. width: 72rpx;
  805. height: 72rpx;
  806. }
  807. .uni-badge-left-margin{
  808. position: absolute;
  809. right: -14rpx;
  810. top:-10rpx;
  811. }
  812. /deep/.uni-badge--error{
  813. background-color: #fff;
  814. color: #E93323;
  815. font-size: 22rpx;
  816. }
  817. }
  818. .text{
  819. width: 580rpx;
  820. height: 72rpx;
  821. background: rgba(255,255,255,0.15);
  822. border-radius: 200rpx;
  823. border: 4rpx solid rgba(255,255,255,0.1);
  824. flex-direction: row;
  825. justify-content: center;
  826. align-items: center;
  827. margin-left: 34rpx;
  828. backdrop-filter: blur(10px);
  829. .lable{
  830. width: 32rpx;
  831. height: 32rpx;
  832. background: linear-gradient(90deg, #E93323 0%, #FF7931 100%);
  833. border-radius: 50%;
  834. text-align: center;
  835. line-height: 32rpx;
  836. }
  837. .see{
  838. font-size: 22rpx;
  839. color: #E93323;
  840. margin-left: 16rpx;
  841. }
  842. .line{
  843. width: 1rpx;
  844. height: 16rpx;
  845. background: rgba(255,255,255,0.6);
  846. margin: 0 12rpx;
  847. }
  848. .title{
  849. width: 238rpx;
  850. font-size: 22rpx;
  851. }
  852. .jumpLook{
  853. font-size: 22rpx;
  854. margin-left: 42rpx;
  855. }
  856. }
  857. }
  858. .goodsList{
  859. margin-top: 20rpx;
  860. .scroll{
  861. white-space: nowrap;
  862. .scroll-item {
  863. display: inline-block;
  864. width: 440rpx;
  865. height: 180rpx;
  866. background-color: #FFE9EA;
  867. border-radius: 16rpx;
  868. margin-right: 24rpx;
  869. .title{
  870. font-size: 22rpx;
  871. font-weight: 500;
  872. color: #E93323;
  873. width: 100%;
  874. height: 48rpx;
  875. flex-direction: row;
  876. align-items: center;
  877. padding: 0 12rpx;
  878. image{
  879. width: 24rpx;
  880. height: 24rpx;
  881. margin-right: 4rpx;
  882. }
  883. }
  884. .item{
  885. width: 100%;
  886. background-color: #fff;
  887. border-radius: 16rpx;
  888. padding: 14rpx;
  889. flex-direction: row;
  890. align-items: center;
  891. position: relative;
  892. .pictrue{
  893. width: 104rpx;
  894. height: 104rpx;
  895. border-radius: 16rpx;
  896. background-color: #ccc;
  897. margin-right: 12rpx;
  898. image{
  899. width: 100%;
  900. height: 100%;
  901. border-radius: 16rpx;
  902. }
  903. }
  904. .text{
  905. width: 290rpx;
  906. font-size: 24rpx;
  907. color: #333;
  908. .textCon{
  909. height: 66rpx;
  910. }
  911. .discount{
  912. font-weight: 400;
  913. color: #E93323;
  914. font-size: 20rpx;
  915. margin-bottom: 6rpx;
  916. }
  917. }
  918. .bnt{
  919. width: 96rpx;
  920. height: 48rpx;
  921. background: linear-gradient(90deg, #E93323 0%, #FF7931 100%);
  922. border-radius: 26rpx;
  923. text-align: center;
  924. line-height: 48rpx;
  925. position: absolute;
  926. right: 10rpx;
  927. bottom: 14rpx;
  928. font-size: 24rpx;
  929. color: #fff;
  930. font-weight: 500;
  931. }
  932. }
  933. }
  934. }
  935. }
  936. .shares{
  937. opacity: 0.9;
  938. margin-top: 17px;
  939. image{
  940. width: 60rpx;
  941. height: 60rpx;
  942. position: absolute;
  943. left: 50%;
  944. margin-left: -30rpx;
  945. }
  946. text{
  947. color: #FFFFFF;
  948. margin-top: 5px;
  949. font-size: 11px;
  950. text-align: center;
  951. margin-top: 34px;
  952. }
  953. }
  954. .comment{
  955. image{
  956. width: 60rpx;
  957. height: 60rpx;
  958. position: absolute;
  959. left: 50%;
  960. margin-left: -30rpx;
  961. }
  962. text{
  963. color: #FFFFFF;
  964. font-size: 11px;
  965. font-weight: 400;
  966. text-align: center;
  967. margin-top: 34px;
  968. }
  969. }
  970. .likes{
  971. opacity: 0.9;
  972. margin-top: 5px;
  973. image{
  974. width: 60rpx;
  975. height: 60rpx;
  976. position: absolute;
  977. left: 50%;
  978. margin-left: -30rpx;
  979. }
  980. text{
  981. color: #FFFFFF;
  982. font-size: 11px;
  983. text-align: center;
  984. margin-top: 34px;
  985. font-weight: 400;
  986. }
  987. }
  988. .collects{
  989. opacity: 0.9;
  990. margin-top: 18px;
  991. image{
  992. width: 60rpx;
  993. height: 60rpx;
  994. position: absolute;
  995. left: 50%;
  996. margin-left: -30rpx;
  997. }
  998. text{
  999. color: #FFFFFF;
  1000. margin-top: 5px;
  1001. font-size: 11px;
  1002. text-align: center;
  1003. margin-top: 34px;
  1004. font-weight: 400;
  1005. }
  1006. }
  1007. .shortVideo {
  1008. height: 100vh;
  1009. background-color: #000000;
  1010. }
  1011. .shareImg {
  1012. z-index: 1000;
  1013. position: fixed;
  1014. left: 0;
  1015. top: 0;
  1016. width: 100%;
  1017. height: 100%;
  1018. }
  1019. .container {
  1020. background-color: #000000;
  1021. }
  1022. .item {
  1023. /* width : 750rpx; */
  1024. background-color: #000000;
  1025. position: relative;
  1026. }
  1027. .videoHover {
  1028. position: absolute;
  1029. top: 0;
  1030. left: 0;
  1031. flex: 1;
  1032. background-color: rgba(0, 0, 0, 0.1);
  1033. justify-content: center;
  1034. align-items: center;
  1035. /* border-style: dashed;
  1036. border-color: #DD524D;
  1037. border-width: 1px; */
  1038. }
  1039. .playState {
  1040. width: 160rpx;
  1041. height: 160rpx;
  1042. opacity: 0.2;
  1043. }
  1044. .userInfo {
  1045. position: absolute;
  1046. bottom: 102px;
  1047. right: 10px;
  1048. flex-direction: column;
  1049. .pictrue {
  1050. width: 96rpx;
  1051. height: 96rpx;
  1052. margin-bottom: 15px;
  1053. flex-direction: column;
  1054. justify-content: center;
  1055. align-items: center;
  1056. position: relative;
  1057. image{
  1058. width: 100%;
  1059. height: 100%;
  1060. border:1px solid #fff;
  1061. border-radius: 100%;
  1062. }
  1063. .live {
  1064. width: 96rpx;
  1065. height: 96rpx;
  1066. background: url('../static/img/index/live-avatar.png') no-repeat;
  1067. background-size: 100% 100%;
  1068. position: absolute;
  1069. top: 2rpx;
  1070. left: 2rpx;
  1071. }
  1072. }
  1073. }
  1074. .likeIco,
  1075. .shareIco,
  1076. .commentIco {
  1077. width: 60rpx;
  1078. height: 60rpx;
  1079. margin-top: 15px;
  1080. }
  1081. .likeNum,
  1082. .commentNum,
  1083. .shareTex {
  1084. color: #ffffff;
  1085. font-size: 30rpx;
  1086. text-align: center;
  1087. margin: 5px;
  1088. }
  1089. .likeNumActive {
  1090. color: red;
  1091. }
  1092. .noVideo {
  1093. position: fixed;
  1094. top: 400rpx;
  1095. z-index: 9;
  1096. width: 750rpx;
  1097. flex-direction: row;
  1098. justify-content: center;
  1099. .pictrue {
  1100. width: 414rpx;
  1101. height: 256rpx;
  1102. }
  1103. .tips {
  1104. text-align: center;
  1105. margin-top: 14rpx;
  1106. font-size: 26rpx;
  1107. color: #999;
  1108. }
  1109. }
  1110. .footer {
  1111. flex-direction: row;
  1112. background-color: #161616;
  1113. height: 118rpx;
  1114. position: fixed;
  1115. bottom: 0;
  1116. z-index: 9;
  1117. width: 750rpx;
  1118. line-height: 100rpx;
  1119. .items {
  1120. position: relative;
  1121. color: #999999;
  1122. font-size: 30rpx;
  1123. .cart {
  1124. color: #999999;
  1125. font-size: 30rpx;
  1126. }
  1127. &.on {
  1128. color: #fff;
  1129. }
  1130. .uni-badge-left-margin{
  1131. position: absolute;
  1132. /* #ifdef MP */
  1133. right: -15px;
  1134. top: -8px;
  1135. /* #endif */
  1136. /* #ifdef H5 */
  1137. right: -11px;
  1138. top: 8px;
  1139. /* #endif */
  1140. }
  1141. /deep/.uni-badge{
  1142. border: 1px solid #e93323;
  1143. background-color: #e93323;
  1144. }
  1145. .cartNum {
  1146. position: absolute;
  1147. height: 28rpx;
  1148. background: #E93323;
  1149. border-radius: 15rpx;
  1150. color: #fff;
  1151. line-height: 27rpx;
  1152. padding: 0 8rpx 0 4rpx;
  1153. right: -10px;
  1154. top: 14px;
  1155. font-size: 22rpx;
  1156. display: block;
  1157. }
  1158. }
  1159. }
  1160. .header {
  1161. position: fixed;
  1162. z-index: 9;
  1163. width: 750rpx;
  1164. flex-direction: row;
  1165. justify-content: center;
  1166. color: #FFFFFF;
  1167. .sys-title{
  1168. width: 750rpx;
  1169. position: relative;
  1170. flex-direction: row;
  1171. align-items: center;
  1172. justify-content: center;
  1173. &.on{
  1174. height: 110rpx;
  1175. }
  1176. image{
  1177. position: absolute;
  1178. top:50%;
  1179. left:20rpx;
  1180. width: 40rpx;
  1181. height: 40rpx;
  1182. margin-top: -20rpx;
  1183. }
  1184. }
  1185. }
  1186. .content {
  1187. width: 590rpx;
  1188. z-index: 99;
  1189. position: absolute;
  1190. bottom: 30px;
  1191. /* justify-content: center; */
  1192. padding: 15rpx 0;
  1193. flex-direction: column;
  1194. justify-content: flex-start;
  1195. color: #ffffff;
  1196. left: 50%;
  1197. margin-left: -345rpx;
  1198. .time {
  1199. font-size: 24rpx;
  1200. color: rgba(255, 255, 255, 0.5);
  1201. margin-left: 12rpx;
  1202. }
  1203. .cart {
  1204. background: rgba(153, 153, 153, 0.3);
  1205. width: 376rpx;
  1206. height: 48rpx;
  1207. border-radius: 4rpx;
  1208. margin-bottom: 22rpx;
  1209. flex-direction: row;
  1210. justify-content: center;
  1211. align-items: center;
  1212. .cartPic {
  1213. width: 36rpx;
  1214. height: 36rpx;
  1215. margin-right: 14rpx;
  1216. }
  1217. .cartName {
  1218. font-size: 24rpx;
  1219. color: #fff;
  1220. }
  1221. .line {
  1222. width: 2rpx;
  1223. height: 22rpx;
  1224. background-color: rgba(255, 255, 255, 0.3);
  1225. margin: 0 12rpx;
  1226. }
  1227. }
  1228. }
  1229. .timeCon {
  1230. flex-direction: row;
  1231. align-items: center;
  1232. .userName {
  1233. font-size: 32rpx;
  1234. color: #ffffff;
  1235. font-weight: 500;
  1236. }
  1237. }
  1238. .words {
  1239. margin-top: 12rpx;
  1240. .close {
  1241. display: flex;
  1242. flex-direction: row;
  1243. align-items: center;
  1244. justify-content: flex-end;
  1245. margin-right: 20rpx;
  1246. .imgClose {
  1247. width: 18rpx;
  1248. height: 10rpx;
  1249. margin-left: 10rpx;
  1250. }
  1251. }
  1252. .wordsCon {
  1253. position: relative;
  1254. .more {
  1255. position: absolute;
  1256. bottom: 0;
  1257. right: 40rpx;
  1258. font-size: 26rpx;
  1259. }
  1260. .img {
  1261. width: 18rpx;
  1262. height: 10rpx;
  1263. margin-left: 4rpx;
  1264. position: absolute;
  1265. bottom: 7rpx;
  1266. right: 15rpx;
  1267. }
  1268. }
  1269. .info {
  1270. color: #fff;
  1271. font-size: 28rpx;
  1272. }
  1273. .more {
  1274. font-size: 26rpx;
  1275. color: #AAAAAA;
  1276. font-weight: 400;
  1277. }
  1278. }
  1279. .root {
  1280. background-color: #000000;
  1281. }
  1282. </style>