|
@@ -1,256 +1,80 @@
|
|
|
<template>
|
|
|
- <view>
|
|
|
- <polyv-player
|
|
|
- :vid="保利威的vid 保利威后台里有"
|
|
|
- :autoplay="true"
|
|
|
- >
|
|
|
- </polyv-player>
|
|
|
+ <view class="plv-mp-demo-page">
|
|
|
+ <player
|
|
|
+ class="plv-mp-demo-player"
|
|
|
+ :videoOption="videoOption"
|
|
|
+ />
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import plv from '../../wxcomponents/polyv-sdk/index';
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
- code: '',
|
|
|
- form:{
|
|
|
- realname:'',
|
|
|
- idCard:''
|
|
|
+ videoOption:{
|
|
|
+ mode: 'live',
|
|
|
+ uid: 'egsxlptzdq',
|
|
|
+ cid: '2553128',
|
|
|
+ openId: 'oQ5eX5BCtSjkE1ct8CzvxGWgh0hQ',
|
|
|
+ isAutoChange: false,
|
|
|
+ forceVideo: false,
|
|
|
},
|
|
|
- codeTips: '',
|
|
|
- read:''
|
|
|
+ detail: {},
|
|
|
};
|
|
|
},
|
|
|
mounted() {},
|
|
|
methods: {
|
|
|
- jumpBind(){
|
|
|
- let that = this
|
|
|
-
|
|
|
- if(!this.form.realname.trim()){
|
|
|
- this.$u.toast('请输入学员姓名');
|
|
|
- return
|
|
|
- }
|
|
|
- if(!this.form.idCard.trim()){
|
|
|
- this.$u.toast('请输入身份证卡号');
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- let IDRe18 = /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/
|
|
|
- let IDre15 = /^([1-6][1-9]|50)\d{4}\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}$/
|
|
|
-
|
|
|
- if( !IDRe18.test( this.form.idCard ) && !IDre15.test( this.form.idCard ) ) {
|
|
|
- this.$u.toast('请输入格式正确的身份证卡号');
|
|
|
- console.log(' 验证未通过 ')
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- this.$set(this.form,'realname',this.form.realname.trim()) //去除姓名两头空格
|
|
|
-
|
|
|
- that.isUse = true
|
|
|
- that.$api.bindId(this.form).then(
|
|
|
- res => {
|
|
|
- that.isUse = false
|
|
|
- if (res.data.code == 200) {
|
|
|
- uni.setStorageSync('user_account',uni.getStorageSync('user_account_temp'));
|
|
|
- uni.setStorageSync('token',uni.getStorageSync('token_temp'));
|
|
|
- uni.removeStorageSync('user_account_temp') //移除临时账号
|
|
|
- uni.removeStorageSync('token_temp') //移除临时token
|
|
|
- uni.reLaunch({
|
|
|
- url:'/pages/index/index'
|
|
|
- })
|
|
|
- that.$api.getInfo().then(resdata => {
|
|
|
- if(resdata.data.code == 200){
|
|
|
- that.$store.state.userInfo = resdata.data.data;
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- } else {
|
|
|
- that.$u.toast(res.data.msg);
|
|
|
- }
|
|
|
- },
|
|
|
- err => {
|
|
|
- that.isUse = false
|
|
|
- }
|
|
|
- );
|
|
|
-
|
|
|
- },
|
|
|
- radioGroupChange(e) {
|
|
|
- console.log(e);
|
|
|
- },
|
|
|
- codeChange(text) {
|
|
|
- this.codeTips = text;
|
|
|
-
|
|
|
- },
|
|
|
- // 获取验证码
|
|
|
- getCode() {
|
|
|
- if(this.$refs.uCode.canGetCode) {
|
|
|
- // 模拟向后端请求验证码
|
|
|
- uni.showLoading({
|
|
|
- title: '正在获取验证码',
|
|
|
- mask: true
|
|
|
- })
|
|
|
- setTimeout(() => {
|
|
|
- uni.hideLoading();
|
|
|
- // 这里此提示会被this.start()方法中的提示覆盖
|
|
|
- this.$u.toast('验证码已发送');
|
|
|
- // 通知验证码组件内部开始倒计时
|
|
|
- this.$refs.uCode.start();
|
|
|
- }, 2000);
|
|
|
- } else {
|
|
|
- this.$u.toast('倒计时结束后再发送');
|
|
|
- }
|
|
|
- },
|
|
|
- sectionChange(index) {
|
|
|
- this.current = index;
|
|
|
- },
|
|
|
- getPhoneNumber(e) {
|
|
|
- let that = this;
|
|
|
- uni.checkSession({
|
|
|
- success () {
|
|
|
- //session_key 未过期,并且在本生命周期一直有效
|
|
|
- that.putInfo(e)
|
|
|
- },
|
|
|
- fail () {
|
|
|
- // session_key 已经失效,需要重新执行登录流程
|
|
|
- uni.login({
|
|
|
- provider: 'weixin',
|
|
|
- success: function(loginRes) {
|
|
|
- that.code = loginRes.code;
|
|
|
- that.putInfo(e)
|
|
|
- }
|
|
|
- });
|
|
|
+ setLiveOption(status) {
|
|
|
+ const { userId, channelId, recordFileSimpleModel, playbackEnabled } = this.detail;
|
|
|
+ const playRecordFile = playbackEnabled && recordFileSimpleModel && status === 'end';
|
|
|
+
|
|
|
+ this.videoOption = {
|
|
|
+ mode: 'live',
|
|
|
+ uid: userId,
|
|
|
+ cid: channelId,
|
|
|
+ isAutoChange: false,
|
|
|
+ forceVideo: false,
|
|
|
+ vodsrc: playRecordFile ? recordFileSimpleModel.mp4 || recordFileSimpleModel.m3u8 : '',
|
|
|
+ liveMode: playRecordFile ? 2 : 1,
|
|
|
}
|
|
|
- })
|
|
|
- },
|
|
|
- putInfo(e){
|
|
|
- let that = this;
|
|
|
- if (e.detail.encryptedData) {
|
|
|
- let inviteCode = uni.getStorageSync("inviteCode")
|
|
|
- //用户同意授权
|
|
|
- var datas = {
|
|
|
- iv: e.detail.iv,
|
|
|
- encryptedData: e.detail.encryptedData,
|
|
|
- code: that.code
|
|
|
- };
|
|
|
- if(inviteCode){
|
|
|
- datas.inviteCode = inviteCode
|
|
|
- }
|
|
|
- that.$api.login(datas).then(
|
|
|
- res => {
|
|
|
- if (res.data.code == 200) {
|
|
|
- uni.setStorageSync('union_id', res.data.data.union_id);
|
|
|
- uni.setStorageSync('token', res.data.data.token);
|
|
|
- that.$api.getInfo().then(resdata => {
|
|
|
- if(resdata.data.code == 200){
|
|
|
- uni.navigateBack();
|
|
|
- that.$store.state.userInfo = resdata.data.data;
|
|
|
- }
|
|
|
-
|
|
|
- });
|
|
|
- } else {
|
|
|
- uni.showModal({
|
|
|
- title: '提示',
|
|
|
- content: res.data.msg,
|
|
|
- showCancel: false
|
|
|
- });
|
|
|
- }
|
|
|
- },
|
|
|
- err => {
|
|
|
- console.log(err);
|
|
|
- }
|
|
|
- );
|
|
|
- }
|
|
|
}
|
|
|
},
|
|
|
- onLoad(option) {
|
|
|
- let that = this;
|
|
|
- this.from = option.from;
|
|
|
- uni.removeStorageSync('user_account') //移除临时账号
|
|
|
- uni.removeStorageSync('token')
|
|
|
- uni.login({
|
|
|
- provider: 'weixin',
|
|
|
- success: function(loginRes) {
|
|
|
- that.code = loginRes.code;
|
|
|
- }
|
|
|
- });
|
|
|
+ onLoad(options) {
|
|
|
+ options.mode = 'live';
|
|
|
+ options.forceVideo = false;
|
|
|
+ options.channelId = '2553128'; // 频道ID
|
|
|
+ options.openId = 'oQ5eX5BCtSjkE1ct8CzvxGWgh0hQ'; // 用户openId
|
|
|
+ // userName: ''; // 用户名
|
|
|
+ // avatarUrl: ''; // 用户头像
|
|
|
+ options.userId = 'egsxlptzdq' // 2.0.0及以上版本的demo需要使用 userId 设置学员唯一id
|
|
|
+ plv.init(options)
|
|
|
+ .then(({ detail, chat }) => {
|
|
|
+
|
|
|
+ console.log(9999)
|
|
|
+ this.detail = detail
|
|
|
+ // 设置mode为live的videoOption
|
|
|
+ // this.setLiveOption();
|
|
|
+
|
|
|
+ if (detail.isPPT) {
|
|
|
+ chat.on(chat.events.SLICESTART, () => {
|
|
|
+ // 开始直播
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ plv.api.getOrdinaryLiveStatus(detail.stream);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ console.log(this.$refs.plv)
|
|
|
+ },
|
|
|
+ onUnload() {
|
|
|
+ plv.destroy();
|
|
|
}
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-<style scoped>
|
|
|
- .wxBtn{
|
|
|
- position: fixed;
|
|
|
- bottom: 10%;
|
|
|
- width: 100%;
|
|
|
- left: 0;
|
|
|
- }
|
|
|
- /deep/ .wxBtn button::after{
|
|
|
- border: none;
|
|
|
- }
|
|
|
- .loginBtn{
|
|
|
- width: 526rpx;
|
|
|
- height: 80rpx;
|
|
|
- background: linear-gradient(90deg, #015EEA, #00C0FA);
|
|
|
- box-shadow: 0rpx 10rpx 16rpx 4rpx rgba(1, 99, 235, 0.04);
|
|
|
- opacity: 0.6;
|
|
|
- border-radius: 40rpx;
|
|
|
- color: #FFFFFF;
|
|
|
- text-align: center;
|
|
|
- line-height: 80rpx;
|
|
|
- margin: 40rpx auto;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- .wxloginBtn{
|
|
|
- background: url("/static/loginBtn.png") no-repeat;
|
|
|
- background-size:100% 100%;
|
|
|
- border:none;
|
|
|
- width: 100rpx;
|
|
|
- height: 100rpx;
|
|
|
- }
|
|
|
-
|
|
|
- /deep/page {
|
|
|
- background-color: #FFFFFF;
|
|
|
- height: 100%;
|
|
|
- width: 100%;
|
|
|
+<style scoped lang="scss">
|
|
|
+ .plv-mp-demo-page {
|
|
|
+ height:500rpx;
|
|
|
}
|
|
|
- .login_box{
|
|
|
- width: 100%;
|
|
|
- height: 360rpx;
|
|
|
- background: #FFFFFF;
|
|
|
- box-shadow: 0rpx 0rpx 16rpx 4rpx rgba(1, 99, 235, 0.1);
|
|
|
- border-radius: 24rpx;
|
|
|
- margin-top: 30rpx;
|
|
|
- padding:40rpx 35rpx;
|
|
|
- }
|
|
|
- /deep/ .u-item-bg{
|
|
|
- border-radius: 32px !important;
|
|
|
- }
|
|
|
- /deep/ .u-subsection{
|
|
|
- border-radius: 32px !important;
|
|
|
- }
|
|
|
-.full_img {
|
|
|
- position: absolute;
|
|
|
- left: 0;
|
|
|
- display: block;
|
|
|
- width: 100%;
|
|
|
- z-index: -999;
|
|
|
- top: 0;
|
|
|
-}
|
|
|
-
|
|
|
-.head {
|
|
|
- height: 96rpx;
|
|
|
- width: 100%;
|
|
|
- line-height: 96rpx;
|
|
|
- margin-top: 40rpx;
|
|
|
- text-align: center;
|
|
|
- display: flex;
|
|
|
- position: relative;
|
|
|
- justify-content: center;
|
|
|
-}
|
|
|
-.icon {
|
|
|
- position: absolute;
|
|
|
- left: 30rpx;
|
|
|
-}
|
|
|
</style>
|