新增直播轮播组件

This commit is contained in:
唐明明
2020-11-30 17:38:19 +08:00
parent 4b8baab1e5
commit f267036d9b
17 changed files with 102 additions and 66 deletions

View File

@@ -5,9 +5,10 @@
import file from "./interfaces/file" import file from "./interfaces/file"
import auth from "./interfaces/auth" import auth from "./interfaces/auth"
import video from "./interfaces/video"
export default{ export default{
file, file,
auth auth,
video
} }

11
apis/interfaces/video.js Normal file
View File

@@ -0,0 +1,11 @@
/*
* 视频
*/
import {req} from "../request"
const videos = () => req({url: "videos"}) //获取视频列表
export default({
videos
})

45
app.js
View File

@@ -1,39 +1,12 @@
//app.js
import apis from "./apis/index"
App({ App({
onLaunch: function () { onLaunch() {
// 展示本地存储能力 //挂载api方法
var logs = wx.getStorageSync('logs') || [] wx.$api = apis
logs.unshift(Date.now()) },
wx.setStorageSync('logs', logs) globalData: {
// 登录 }
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}
}
})
},
globalData: {
userInfo: null
}
}) })

View File

@@ -1,6 +1,6 @@
{ {
"pages": [ "pages": [
"pages/index/index" "pages/videos/videos"
], ],
"window": { "window": {
"backgroundTextStyle": "light", "backgroundTextStyle": "light",

View File

@@ -0,0 +1,29 @@
/**
* Web唐明明
* 一个梦想做木雕手艺人的程序员
* explain: videoSwiper
*/
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
},
/**
* 组件的方法列表
*/
methods: {
}
})

View File

@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}

View File

@@ -0,0 +1,2 @@
<!--components/videoSwiper/videoSwiper.wxml-->
<text>components/videoSwiper/videoSwiper.wxml</text>

View File

@@ -0,0 +1 @@
/* components/videoSwiper/videoSwiper.wxss */

View File

@@ -1,17 +0,0 @@
// pages/index/index.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad (options) {
}
})

View File

@@ -1,5 +0,0 @@
{
"usingComponents": {
}
}

View File

@@ -1,2 +0,0 @@
<!--pages/index/index.wxml-->
<text>pages/index/index.wxml</text>

View File

@@ -1 +0,0 @@
/* pages/index/index.wxss */

22
pages/videos/videos.js Normal file
View File

@@ -0,0 +1,22 @@
Page({
/**
* 页面的初始数据
*/
data: {
videoList: [] //获取短视频列表
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
wx.$api.video.videos().then(res=>{
console.log(res)
this.setData({
videoList: res
})
})
}
})

6
pages/videos/videos.json Normal file
View File

@@ -0,0 +1,6 @@
{
"usingComponents": {
"mp-video-swiper": "/components/videoSwiper/videoSwiper"
}
}

6
pages/videos/videos.wxml Normal file
View File

@@ -0,0 +1,6 @@
<mp-video-swiper
video-list="{{videoList}}"
class="videoSwiper"
>
</mp-video-swiper>

6
pages/videos/videos.wxss Normal file
View File

@@ -0,0 +1,6 @@
.videoSwiper{
width: 100%;
height: 100vh;
position: relative;
}

View File

@@ -4,7 +4,7 @@
"ignore": [] "ignore": []
}, },
"setting": { "setting": {
"urlCheck": true, "urlCheck": false,
"es6": true, "es6": true,
"enhance": false, "enhance": false,
"postcss": true, "postcss": true,