新增直播轮播组件
This commit is contained in:
@@ -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
11
apis/interfaces/video.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* 视频
|
||||||
|
*/
|
||||||
|
import {req} from "../request"
|
||||||
|
|
||||||
|
const videos = () => req({url: "videos"}) //获取视频列表
|
||||||
|
|
||||||
|
export default({
|
||||||
|
videos
|
||||||
|
})
|
||||||
41
app.js
41
app.js
@@ -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)
|
|
||||||
|
|
||||||
// 登录
|
|
||||||
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: {
|
globalData: {
|
||||||
userInfo: null
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
2
app.json
2
app.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"pages": [
|
"pages": [
|
||||||
"pages/index/index"
|
"pages/videos/videos"
|
||||||
],
|
],
|
||||||
"window": {
|
"window": {
|
||||||
"backgroundTextStyle": "light",
|
"backgroundTextStyle": "light",
|
||||||
|
|||||||
29
components/videoSwiper/videoSwiper.js
Normal file
29
components/videoSwiper/videoSwiper.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
/**
|
||||||
|
* Web唐明明
|
||||||
|
* 一个梦想做木雕手艺人的程序员
|
||||||
|
* explain: videoSwiper
|
||||||
|
*/
|
||||||
|
|
||||||
|
Component({
|
||||||
|
/**
|
||||||
|
* 组件的属性列表
|
||||||
|
*/
|
||||||
|
properties: {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件的初始数据
|
||||||
|
*/
|
||||||
|
data: {
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组件的方法列表
|
||||||
|
*/
|
||||||
|
methods: {
|
||||||
|
|
||||||
|
}
|
||||||
|
})
|
||||||
4
components/videoSwiper/videoSwiper.json
Normal file
4
components/videoSwiper/videoSwiper.json
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"component": true,
|
||||||
|
"usingComponents": {}
|
||||||
|
}
|
||||||
2
components/videoSwiper/videoSwiper.wxml
Normal file
2
components/videoSwiper/videoSwiper.wxml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<!--components/videoSwiper/videoSwiper.wxml-->
|
||||||
|
<text>components/videoSwiper/videoSwiper.wxml</text>
|
||||||
1
components/videoSwiper/videoSwiper.wxss
Normal file
1
components/videoSwiper/videoSwiper.wxss
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/* components/videoSwiper/videoSwiper.wxss */
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
// pages/index/index.js
|
|
||||||
Page({
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 页面的初始数据
|
|
||||||
*/
|
|
||||||
data: {
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生命周期函数--监听页面加载
|
|
||||||
*/
|
|
||||||
onLoad (options) {
|
|
||||||
|
|
||||||
}
|
|
||||||
})
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"usingComponents": {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
<!--pages/index/index.wxml-->
|
|
||||||
<text>pages/index/index.wxml</text>
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
/* pages/index/index.wxss */
|
|
||||||
22
pages/videos/videos.js
Normal file
22
pages/videos/videos.js
Normal 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
6
pages/videos/videos.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
{
|
||||||
|
"usingComponents": {
|
||||||
|
"mp-video-swiper": "/components/videoSwiper/videoSwiper"
|
||||||
|
}
|
||||||
|
}
|
||||||
6
pages/videos/videos.wxml
Normal file
6
pages/videos/videos.wxml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
<mp-video-swiper
|
||||||
|
video-list="{{videoList}}"
|
||||||
|
class="videoSwiper"
|
||||||
|
>
|
||||||
|
</mp-video-swiper>
|
||||||
6
pages/videos/videos.wxss
Normal file
6
pages/videos/videos.wxss
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
.videoSwiper{
|
||||||
|
width: 100%;
|
||||||
|
height: 100vh;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
"ignore": []
|
"ignore": []
|
||||||
},
|
},
|
||||||
"setting": {
|
"setting": {
|
||||||
"urlCheck": true,
|
"urlCheck": false,
|
||||||
"es6": true,
|
"es6": true,
|
||||||
"enhance": false,
|
"enhance": false,
|
||||||
"postcss": true,
|
"postcss": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user