修复播放器时间问题

master
许宏杰 1 year ago
parent 8cd5e358d6
commit 918ae73292

@ -51,6 +51,5 @@ export function getNet(id) {
return request({
url: "/netEwm/net/" + id,
method: "get",
});
}

@ -1,341 +0,0 @@
<template>
<view class="container" style="padding:25rpx;">
<view class="wifi-data">
<view class="wifi-icon">
<u-icon color="#ffffff" name="wifi" size="30"></u-icon>
</view>
<view class="wifi-datas" color="#2979ff">
<view class="wifi-name">jichuang_5G</view>
<view class="wifi-hot">
<text class="hot-text">快速连接</text>
<text class="hot-icon">.</text>
<text class="hot-text">无需密码</text>
<text class="hot-icon">.</text>
<text class="hot-text">保护隐私</text>
</view>
</view>
</view>
<view class="wifi-success">
WI-FI连接成功
</view>
<!-- <u-button type="primary" text="一键连接WI-FI" @click="handleCode()"></u-button> -->
<u-popup :show="show" mode="bottom">
<view class="video-container">
<view class="video-btns" :style="{paddingTop:statusBarHeight+'rpx'}">
<view class="second" v-show="countdown > 0">{{countdown}} </view>
<view class="second" v-show="countdown == 0"></view>
<view class="close" @click="handleClose()"></view>
</view>
<video id="video-box" v-if="show" :src="urlPath" :autoplay="true" :controls="false"
@timeupdate="changeTimeupdate"></video>
</view>
</u-popup>
</view>
</template>
<script>
import {
findById,
getShanghu,
getPoster,
addNetHistory,
addPosterHistory
} from '@/api/index.js'
export default {
data() {
return {
baseUrl: getApp().globalData.config.baseUrl,
pathData: '',
urlPath: '',
time: null,
countdown: 5,
videoCurrentTime: 0,
show: false,
from: {},
statusBarHeight: 20,
shanghuId: null,
posterData: {},
}
},
onLoad(option) {
// #ifdef MP-WEIXIN
let sys = uni.$u.sys()
this.statusBarHeight = sys.statusBarHeight + 44
// #endif
// if (option.shanghuId) {
// this.shanghuId = option.shanghuId
// //shanghuIdWIFI
// this.getFindbyid()
// } else {
// uni.showToast({
// title: '',
// icon: 'error'
// })
// }
},
methods: {
handleCode() {
uni.scanCode({
success: (res) => {
console.log('二维码信息', res)
}
})
},
//WIFI
getFindbyid() {
findById(this.shanghuId).then(res => {
this.from = {
wifiName: res.data.wifiName,
wifiPass: res.data.wifiPass
}
//广
this.lookPoster()
})
},
//广
lookPoster() {
let _this = this
uni.showModal({
title: '温馨提示',
content: '连接WIFI需要观看一段视频广告是否确认',
success: (res) => {
if (res.confirm) {
//广
getShanghu(_this.shanghuId).then(shanghu => {
//广id
let posterId = shanghu.data.posterId
//广
getPoster(posterId).then(poster => {
_this.posterData = {
posterId: poster.data.id,
shanghuId: _this.shanghuId,
posterName: poster.data.posterName,
startTime: poster.data.startTime,
endTime: poster.data.endTime,
videoPath: poster.data.videoPath,
}
//
_this.urlPath = this.baseUrl + poster.data
.videoPath;
_this.show = true
//
_this.EnableTimer()
})
})
} else {
uni.showToast({
title: '连接失败',
icon: 'error'
})
}
}
})
},
//
EnableTimer() {
this.time = setInterval(() => {
if (this.countdown > 0) {
this.countdown--
} else {
clearInterval(this.time)
}
}, 1000)
},
//
changeTimeupdate(event) {
let {
currentTime,
duration
} = event.detail
this.videoCurrentTime = currentTime
},
//
handleClose() {
this.show = false
if (this.videoCurrentTime >= 5) {
//WIFI
this.handleWifi()
} else {
uni.showToast({
title: '获取奖励失败',
icon: 'error'
})
this.countdown = 5
this.videoCurrentTime = 0
}
//
clearInterval(this.time)
//广
addPosterHistory(this.posterData)
},
handleWifi: function() {
let that = this
uni.getSystemInfo({
success: function(res) {
var system = '';
if (res.platform == 'android') system = parseInt(res.system.substr(8));
if (res.platform == 'ios') system = parseInt(res.system.substr(4));
if (res.platform == 'android' && system < 6) {
wx.showToast({
title: '手机版本不支持',
icon: 'error',
})
return
}
if (res.platform == 'ios' && system < 11.2) {
wx.showToast({
title: '手机版本不支持',
icon: 'error'
})
return
}
//2. Wi-Fi
that.startWifi();
}
})
},
// Wi-Fi
startWifi: function() {
var that = this
uni.startWifi({
success: function() {
//Wifi
that.Connected();
},
fail: function(res) {
uni.showToast({
title: '初始化WIFI失败',
icon: 'error'
})
}
})
},
Connected: function() {
var that = this
uni.connectWifi({
SSID: this.from.wifiName, //wifi
BSSID: '',
password: this.from.wifiPass, //wifi
success: function(res) {
addNetHistory({
shanghuId: _this.shanghuId,
wifiName: this.from.wifiName,
wifiPass: this.from.wifiPass,
isTrue: that.videoCurrentTime >= 5 ? 1 : 2
}).then(res => {
uni.showToast({
title: '连接成功',
icon: 'success'
})
})
},
fail: function(res) {
uni.showToast({
title: 'wifi连接失败',
icon: 'error'
})
}
})
},
},
}
</script>
<style lang="scss" scoped>
page {
background: #F5F7F8;
}
.wifi-data {
border-radius: 16rpx;
background-color: #ffffff;
box-sizing: border-box;
padding: 20rpx;
display: flex;
align-items: center;
.wifi-icon {
height: 100rpx;
width: 100rpx;
border-radius: 50%;
background: #32B78B;
display: flex;
align-items: center;
justify-content: center;
}
.wifi-datas {
box-sizing: border-box;
padding-left: 20rpx;
.wifi-name {
font-size: 28rpx;
font-weight: bold;
color: #333;
margin-bottom: 6px;
}
.wifi-hot {
color: #9DA2AB;
.hot-text {
font-size: 24rpx;
}
.hot-icon {
margin: 0 10rpx;
}
}
}
}
.wifi-success {
margin-top: 20rpx;
border-radius: 16rpx;
background-color: #ffffff;
box-sizing: border-box;
padding: 40rpx 20rpx;
color: #32B78B;
font-size: 28rpx;
text-align: center;
}
.video-container {
width: 100%;
position: relative;
#video-box {
height: 100vh;
width: 100%;
}
.video-btns {
position: absolute;
left: 0;
top: 0;
z-index: 100;
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
padding: 0 20rpx;
&>view {
border: 1px solid #ccc;
color: white;
font-size: 24rpx;
border-radius: 25rpx;
box-sizing: border-box;
padding: 8rpx 20rpx;
}
}
}
</style>

@ -25,12 +25,12 @@
<u-popup :show="show" mode="bottom">
<view class="video-container">
<view class="video-btns" :style="{paddingTop:statusBarHeight+'rpx'}">
<view class="second" v-show="countdown > 0">{{countdown}} </view>
<view class="second" v-show="countdown > 0">{{countdown}} WI-FI</view>
<view class="second" v-show="countdown == 0"></view>
<view class="close" @click="handleClose()"></view>
</view>
<video id="video-box" v-if="show" :src="baseUrl + posterForm.videoPath" :autoplay="true"
:controls="false" @timeupdate="changeTimeupdate"></video>
:controls="false" @timeupdate="changeTimeupdate" @play="play"></video>
</view>
</u-popup>
</view>
@ -64,15 +64,16 @@
let sys = uni.$u.sys()
this.statusBarHeight = sys.statusBarHeight + 44
// #endif
// if (option.shanghuId) {
// this.getNetinfo(option.shanghuId)
// } else {
// uni.showToast({
// title: '',
// icon: 'error'
// })
// }
this.getNetinfo(6)
if (option.posterId) {
this.getNetinfo(option.posterId)
} else {
uni.showToast({
title: '获取网络信息失败!',
icon: 'error'
})
}
// this.getNetinfo(8)
},
methods: {
//id
@ -94,10 +95,7 @@
getShanghu(that.wifiForm.shanghuId).then(shanghu => {
getPoster(shanghu.data.posterId).then(poster => {
that.posterForm = poster.data
that.posterForm.time = 10
that.countdown = that.posterForm.time
that.enableTimer()
that.setPosterHistory()
that.countdown = that.posterForm.duration
that.show = true
})
})
@ -117,6 +115,11 @@
}
addPosterHistory(data)
},
//
play() {
this.enableTimer() //
this.setPosterHistory()
},
//
enableTimer() {
this.time = setInterval(() => {
@ -124,28 +127,33 @@
this.countdown--
} else {
clearInterval(this.time)
this.handleClose()
}
}, 1000)
},
//
changeTimeupdate(e) {
this.videoCurrentTime = e.detail.currentTime
},
//
handleClose() {
if (this.videoCurrentTime >= this.posterForm.time) {
this.show = false
console.log(Math.ceil(this.videoCurrentTime), this.posterForm.duration, Math.ceil(this.videoCurrentTime) >=
this
.posterForm.duration)
if (Math.ceil(this.videoCurrentTime) >= this.posterForm.duration) {
//
this.handleWifi()
} else {
uni.showToast({
title: '获取奖励失败!',
title: '连接WI-FI失败!',
icon: 'error'
})
this.countdown = this.posterForm.time
this.countdown = this.posterForm.duration
this.videoCurrentTime = 0
}
clearInterval(this.time)
this.show = false
},
//WIFI
@ -159,20 +167,14 @@
var system = '';
if (res.platform == 'android') system = parseInt(res.system.substr(8));
if (res.platform == 'ios') system = parseInt(res.system.substr(4));
if (res.platform == 'android' && system < 6) {
wx.showToast({
if (res.platform == 'android' && system < 6 || res.platform == 'ios' && system <
11.2) {
uni.showToast({
title: '手机版本不支持',
icon: 'error',
})
return
}
if (res.platform == 'ios' && system < 11.2) {
wx.showToast({
title: '手机版本不支持',
icon: 'error'
})
return
}
that.startWifi();
}
})
@ -207,7 +209,6 @@
wifiPass: that.wifiForm.wifiPass,
shanghuId: that.wifiForm.shanghuId
})
uni.showToast({
title: '连接成功',
icon: 'success'
@ -229,7 +230,6 @@
<style lang="scss">
page {
height: 100%;
}
.container {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -780,8 +780,8 @@ function populateParameters(result) {
appVersion: "1.0.0",
appVersionCode: "100",
appLanguage: getAppLanguage(hostLanguage),
uniCompileVersion: "3.96",
uniRuntimeVersion: "3.96",
uniCompileVersion: "3.98",
uniRuntimeVersion: "3.98",
uniPlatform: undefined || "mp-weixin",
deviceBrand: deviceBrand,
deviceModel: model,

@ -164,7 +164,7 @@ __webpack_require__.r(__webpack_exports__);
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/* WEBPACK VAR INJECTION */(function(uni, wx) {
/* WEBPACK VAR INJECTION */(function(uni) {
Object.defineProperty(exports, "__esModule", {
value: true
@ -228,17 +228,18 @@ var _default = {
onLoad: function onLoad(option) {
var sys = uni.$u.sys();
this.statusBarHeight = sys.statusBarHeight + 44;
if (option.posterId) {
this.getNetinfo(option.posterId);
} else {
uni.showToast({
title: '获取网络信息失败!',
icon: 'error'
});
}
// if (option.shanghuId) {
// this.getNetinfo(option.shanghuId)
// } else {
// uni.showToast({
// title: '获取网络信息失败!',
// icon: 'error'
// })
// }
this.getNetinfo(6);
// this.getNetinfo(8)
},
methods: {
//根据微信扫小程序码进入首页拿到网络id查询网络详情
getNetinfo: function getNetinfo(netId) {
@ -259,10 +260,7 @@ var _default = {
(0, _index.getShanghu)(that.wifiForm.shanghuId).then(function (shanghu) {
(0, _index.getPoster)(shanghu.data.posterId).then(function (poster) {
that.posterForm = poster.data;
that.posterForm.time = 10;
that.countdown = that.posterForm.time;
that.enableTimer();
that.setPosterHistory();
that.countdown = that.posterForm.duration;
that.show = true;
});
});
@ -282,6 +280,11 @@ var _default = {
};
(0, _index.addPosterHistory)(data);
},
// 开始播放
play: function play() {
this.enableTimer(); //启用计时器
this.setPosterHistory();
},
//计时器
enableTimer: function enableTimer() {
var _this2 = this;
@ -290,6 +293,7 @@ var _default = {
_this2.countdown--;
} else {
clearInterval(_this2.time);
_this2.handleClose();
}
}, 1000);
},
@ -299,19 +303,20 @@ var _default = {
},
//关闭弹窗
handleClose: function handleClose() {
if (this.videoCurrentTime >= this.posterForm.time) {
this.show = false;
console.log(Math.ceil(this.videoCurrentTime), this.posterForm.duration, Math.ceil(this.videoCurrentTime) >= this.posterForm.duration);
if (Math.ceil(this.videoCurrentTime) >= this.posterForm.duration) {
//证明已经看过视频时间
this.handleWifi();
} else {
uni.showToast({
title: '获取奖励失败!',
title: '连接WI-FI失败!',
icon: 'error'
});
this.countdown = this.posterForm.time;
this.countdown = this.posterForm.duration;
this.videoCurrentTime = 0;
}
clearInterval(this.time);
this.show = false;
},
//判断当前机器是否支持连接WIFI
handleWifi: function handleWifi() {
@ -324,15 +329,8 @@ var _default = {
var system = '';
if (res.platform == 'android') system = parseInt(res.system.substr(8));
if (res.platform == 'ios') system = parseInt(res.system.substr(4));
if (res.platform == 'android' && system < 6) {
wx.showToast({
title: '手机版本不支持',
icon: 'error'
});
return;
}
if (res.platform == 'ios' && system < 11.2) {
wx.showToast({
if (res.platform == 'android' && system < 6 || res.platform == 'ios' && system < 11.2) {
uni.showToast({
title: '手机版本不支持',
icon: 'error'
});
@ -391,7 +389,7 @@ var _default = {
}
};
exports.default = _default;
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"], __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/wx.js */ 1)["default"]))
/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./node_modules/@dcloudio/uni-mp-weixin/dist/index.js */ 2)["default"]))
/***/ }),

@ -1 +1 @@
<view class="container"><view class="wifi-data"><view class="wifi-icon"><u-icon vue-id="8dd740cc-1" color="#ffffff" name="wifi" size="30" bind:__l="__l"></u-icon></view><view class="wifi-datas" color="#2979ff"><view class="wifi-name">{{wifiForm.wifiName}}</view><view class="wifi-hot"><text class="hot-text">快速连接</text><text class="hot-icon">.</text><text class="hot-text">无需密码</text><text class="hot-icon">.</text><text class="hot-text">保护隐私</text></view></view></view><block wx:if="{{!showBtn}}"><view class="wifi-success">WI-FI连接成功</view></block><block wx:if="{{showBtn}}"><u-button vue-id="8dd740cc-2" type="primary" text="一键连接WI-FI" data-event-opts="{{[['^click',[['handleLinkwifi']]]]}}" bind:click="__e" bind:__l="__l"></u-button></block><u-popup vue-id="8dd740cc-3" show="{{show}}" mode="bottom" bind:__l="__l" vue-slots="{{['default']}}"><view class="video-container"><view class="video-btns" style="{{'padding-top:'+(statusBarHeight+'rpx')+';'}}"><view hidden="{{!(countdown>0)}}" class="second">{{countdown+" 后获得奖励"}}</view><view hidden="{{!(countdown==0)}}" class="second">已获得奖励</view><view data-event-opts="{{[['tap',[['handleClose']]]]}}" class="close" bindtap="__e">关闭</view></view><block wx:if="{{show}}"><video id="video-box" src="{{baseUrl+posterForm.videoPath}}" autoplay="{{true}}" controls="{{false}}" data-event-opts="{{[['timeupdate',[['changeTimeupdate',['$event']]]]]}}" bindtimeupdate="__e"></video></block></view></u-popup></view>
<view class="container"><view class="wifi-data"><view class="wifi-icon"><u-icon vue-id="8dd740cc-1" color="#ffffff" name="wifi" size="30" bind:__l="__l"></u-icon></view><view class="wifi-datas" color="#2979ff"><view class="wifi-name">{{wifiForm.wifiName}}</view><view class="wifi-hot"><text class="hot-text">快速连接</text><text class="hot-icon">.</text><text class="hot-text">无需密码</text><text class="hot-icon">.</text><text class="hot-text">保护隐私</text></view></view></view><block wx:if="{{!showBtn}}"><view class="wifi-success">WI-FI连接成功</view></block><block wx:if="{{showBtn}}"><u-button vue-id="8dd740cc-2" type="primary" text="一键连接WI-FI" data-event-opts="{{[['^click',[['handleLinkwifi']]]]}}" bind:click="__e" bind:__l="__l"></u-button></block><u-popup vue-id="8dd740cc-3" show="{{show}}" mode="bottom" bind:__l="__l" vue-slots="{{['default']}}"><view class="video-container"><view class="video-btns" style="{{'padding-top:'+(statusBarHeight+'rpx')+';'}}"><view hidden="{{!(countdown>0)}}" class="second">{{countdown+" 后连接WI-FI"}}</view><view hidden="{{!(countdown==0)}}" class="second">已获得奖励</view><view data-event-opts="{{[['tap',[['handleClose']]]]}}" class="close" bindtap="__e">关闭</view></view><block wx:if="{{show}}"><video id="video-box" src="{{baseUrl+posterForm.videoPath}}" autoplay="{{true}}" controls="{{false}}" data-event-opts="{{[['timeupdate',[['changeTimeupdate',['$event']]]],['play',[['play',['$event']]]]]}}" bindtimeupdate="__e" bindplay="__e"></video></block></view></u-popup></view>

@ -21,24 +21,7 @@
"libVersion": "3.2.2",
"appid": "wxba26a482b035e825",
"projectname": "uniapp-deom",
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"game": {
"current": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": []
}
},
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2

@ -1,20 +0,0 @@
{
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"projectname": "uniapp-deom",
"setting": {
"compileHotReLoad": true
},
"condition": {
"miniprogram": {
"list": [
{
"name": "",
"pathName": "pages/index/index",
"query": "shanghuId=14",
"launchMode": "default",
"scene": 1047
}
]
}
}
}
Loading…
Cancel
Save