live - 副本.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. <template>
  2. <view>
  3. <!-- <view class="top">
  4. <image :src="picUrlss + 'activity_top.png'" mode="widthFix"></image>
  5. </view> -->
  6. <view class="banner">
  7. <swiper class="swiper" @change="swiperChange" autoplay="true" interval="5000" duration="300">
  8. <block v-for="(item, index) in bannerList" :key="index">
  9. <swiper-item>
  10. <contact-button :img-url="item.pic + '?x-oss-process=style/w750-auto'" image-mode="aspectFill" class-name="banner-img" v-if="item.type == 8"></contact-button>
  11. <!-- <button open-type="contact" v-if="item.type == 8">
  12. <image lazy-load="true" :src="item.pic + '?x-oss-process=style/w750-auto'" mode="aspectFill"></image>
  13. </button> -->
  14. <image lazy-load="true" :src="item.pic + '?x-oss-process=style/w750-auto'"mode="aspectFill" @tap="getUrl2(item)" :data-type="item.type" :data-content="item.content" :data-merchant="url" v-else></image>
  15. </swiper-item>
  16. </block>
  17. </swiper>
  18. <view class="dots ddflex">
  19. <block v-for="(item, index) in bannerList" :key="index"><view :class="['dot', index == swiperCurrent ? 'active' : '']"></view></block>
  20. </view>
  21. </view>
  22. <view class="cons">
  23. <view class="box" v-if="liveList&&liveList.length>0">
  24. <view class="title ddflex">
  25. <view class="fflex">直播课</view>
  26. <navigator url="/service/live/live" hover-class="none" class="more ddflex">更多直播<image src="../../static/pages/images/more.png"></image></navigator>
  27. </view>
  28. <view class="live-list">
  29. <view class="li ddflex">
  30. </view>
  31. <view class="li ddflex" v-for="(item, index) in liveList" :key="index" @click="intoLive(item.roomid,index)">
  32. <view class="live-img">
  33. <image :src="item.share_img" mode="aspectFill" class="live-pic"></image>
  34. <view class="live-sta ddflex" v-if="item.live_status == 101"><image :src="picUrlss+'meizhihua/zb_ico.png'"></image>直播中</view>
  35. <view class="live-sta end ddflex" v-if="item.live_status == 103"><image :src="picUrlss+'meizhihua/zb_ico_end.png'"></image>直播完</view>
  36. </view>
  37. <view class="fflex">
  38. <view class="live-tit tover">{{item.name}}</view>
  39. <view class="live-bri tover" v-if="item.live_status == 102">直播时间:<text>{{item.time}}</text></view>
  40. <!-- <view class="live-bri tover">小学生口腔保健应知</view> -->
  41. <view class="live-opt ddflex">
  42. <view class="fflex ddflex">
  43. <!-- <image src="../../static/pages/images/userimg.png" mode="aspectFill" class="userimg"></image>
  44. <view class="username">小光医生</view> -->
  45. </view>
  46. <view class="live-btn">{{item.live_status == 103 ? '查看回放':'进入直播'}}</view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="box" v-if="matchList&&matchList.length>0">
  53. <view class="title ddflex">
  54. <view class="fflex">活动报名</view>
  55. <navigator url="/topic/activitys/activity" hover-class="none" class="more ddflex">更多活动<image src="../../static/pages/images/more.png"></image></navigator>
  56. </view>
  57. <view class="act-list">
  58. <view class="li" v-for="(item,index) in matchList" :key="index">
  59. <view class="infos ddflex" @click="toActivity(item)">
  60. <view class="imgbox">
  61. <image :src="item.pic" mode="aspectFill"></image>
  62. <!-- <text class="tag">已认证</text> -->
  63. </view>
  64. <view class="fflex">
  65. <view class="act-tit tovers">{{item.title}}</view>
  66. <view class="ddflex">
  67. <view class="area fflex tover">
  68. <text>{{getTime(item.startTime)}} 开始</text>
  69. <!-- <text>湖南长沙</text> -->
  70. </view>
  71. <view class="money" v-if="userinfovip.levelGrade>0&& !userinfovip.end"><text v-if="item.vipMoney">¥</text>{{item.vipMoney ? item.vipMoney : '免费' }}</view>
  72. <view class="money" v-else><text v-if="item.money">¥</text>{{item.money ? item.money : '免费'}}</view>
  73. </view>
  74. </view>
  75. </view>
  76. <view class="stas ddflex">
  77. <view class="tag-box ddflex fflex">
  78. {{item.brief}}
  79. <!-- <text>#经销商</text>
  80. <text>#服务商</text>
  81. <text>#新零售</text> -->
  82. </view>
  83. <view class="act-btn" v-if="!item.isEnlist" @click="toActivity(item)">立即报名</view>
  84. <view class="act-btn" @click="jumpUrl('/mine/activity/activity')" v-else>查看报名</view>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. <foot channel="live" :isUpdate="isUpdate" v-if="query.isSwitchTab"></foot>
  91. </view>
  92. </template>
  93. <script>
  94. //index.js
  95. //获取应用实例
  96. const app = getApp();
  97. const req = require('../../utils/request.js');
  98. const api = require('../../utils/api.js');
  99. const utils = require('../../utils/util.js');
  100. const mes = require('../../utils/requestmessage.js');
  101. const route = require('../../utils/route');
  102. const QQMapWX = require("../../utils/qqmap.js");
  103. import foot from '../../components/nav-bar/index';
  104. import footerCopyright from '../../components/footer-copyright/footer-copyright';
  105. var timer; //定时器状态
  106. export default {
  107. data() {
  108. return {
  109. picUrlss: req.public.picUrls,
  110. query: {},
  111. isLogin: false,
  112. liveList: [],
  113. matchList: [],
  114. query: {},
  115. userinfovip: {},
  116. swiperCurrent: 0,
  117. bannerList: []
  118. };
  119. },
  120. components: {
  121. foot,
  122. footerCopyright,
  123. },
  124. onReachBottom() {
  125. },
  126. onLoad: async function(options) {
  127. if(options.isSwitchTab) options.isSwitchTab = true;
  128. this.query = options;
  129. req.silenceLogin(options.userId, '');
  130. },
  131. async onShow() {
  132. this.isLogin = req.isAuth();
  133. this.getBannerList();
  134. this.getMatchList()
  135. if(this.isLogin){
  136. this.getuserVip();
  137. }
  138. },
  139. onShareAppMessage: function() {
  140. let url = '/pages/activity/index'
  141. if(req.getStorage('userInfo')){
  142. url += '?userId=' + req.getStorage('userInfo').id
  143. }
  144. return{
  145. path: url
  146. }
  147. },
  148. onShareTimeline() {
  149. },
  150. methods: {
  151. getBannerList() {
  152. req.getRequest('/api/banner', {
  153. code: '0003'
  154. }, data => {
  155. this.bannerList = data;
  156. });
  157. },
  158. swiperChange(e){
  159. this.swiperCurrent = e.detail.current
  160. },
  161. getUrl2(e){
  162. app.globalData.clickBanner(e);
  163. },
  164. getLiveList() {
  165. let that = this;
  166. let form = {
  167. page: 1,
  168. limit: 1
  169. };
  170. req.getRequest('/api/live/list', form, data => {
  171. if (data) {
  172. data.map(item => {
  173. if (item.start_time) {
  174. item.time = util.transTime(item.start_time);
  175. }
  176. return item;
  177. });
  178. }
  179. that.liveList = data
  180. });
  181. },
  182. getLive(id) {
  183. return new Promise((resolve, reject) => {
  184. req.getRequest('/api/live/playBack', {
  185. page: 1,
  186. limit: 10,
  187. room_id: id
  188. }, data => {
  189. this.videoList = data;
  190. resolve();
  191. });
  192. });
  193. },
  194. intoLive(roomId, index) {
  195. let redirect = '/service/liveMiddle/liveMiddle?id=' + roomId
  196. req.isLogin().then(success => {
  197. if (success) {
  198. uni.navigateTo({
  199. url: redirect // url:`plugin-private://wx2b03c6e691cd7370/pages/live-player-plugin?room_id=${roomId}`
  200. });
  201. }
  202. });
  203. },
  204. async playBack(event) {
  205. let roomId = event.currentTarget.dataset.id;
  206. await this.getLive(roomId);
  207. let videoList = JSON.stringify(this.videoList);
  208. if (videoList.length < 1) return req.msg('回放生成中');
  209. uni.navigateTo({
  210. url: '/service/video/video?videoList=' + videoList
  211. });
  212. },
  213. getTime(time){
  214. if(time){
  215. return time.substring(0,16)
  216. }
  217. },
  218. getMatchList(){
  219. let form = {
  220. page: 1,
  221. limit: 3,
  222. state: 2
  223. }
  224. req.getRequest('/api/match/list',form,res => {
  225. this.matchList = res;
  226. });
  227. },
  228. toActivity(item){
  229. uni.navigateTo({
  230. url: '/topic/activityDetail/activityDetail?id=' + item.id
  231. })
  232. },
  233. getuserVip() {
  234. req.getRequest('/api/user/levelDetails', {}, data => {
  235. let expireTime = Array;
  236. if (data.expireTime) {
  237. expireTime = data.expireTime.split(" ");
  238. data.expireTime = data.expireTime.replace(/-/g, '/');
  239. } // 解决苹果不兼容---日期
  240. let nowTime = new Date().getTime();
  241. let endTime = new Date(data.expireTime).getTime();
  242. let times = parseInt((endTime - nowTime) / 1000); // var expireTime= new Date(data.expireTime)
  243. // console.log(times, nowTime, endTime, data.expireTime);
  244. this.userinfovip = data;
  245. if (times <= 0) {
  246. this.userinfovip.end = true;
  247. } else {
  248. this.userinfovip.end = false;
  249. }
  250. });
  251. },
  252. jumpUrl(url) {
  253. uni.navigateTo({
  254. url: url
  255. })
  256. }
  257. }
  258. };
  259. </script>
  260. <style>
  261. @import "live.css";
  262. </style>