diff --git a/apis/interfaces/auth.js b/apis/interfaces/auth.js index 27acc98..8f037f4 100644 --- a/apis/interfaces/auth.js +++ b/apis/interfaces/auth.js @@ -5,9 +5,7 @@ import {req} from "../request" const authPhone = data => req({url: "auth/mini", method: "POST", data: data}) //登录 -const authInfo = data => req({url: "auth/mini/info", method: "POST", data: data}) //完善用户信息 export default({ - authPhone, - authInfo + authPhone }) diff --git a/apis/request.js b/apis/request.js index 904f9bc..45f6484 100644 --- a/apis/request.js +++ b/apis/request.js @@ -86,9 +86,10 @@ const upload = (obj) => { if (jsonData.status_code == 200) { resolve(jsonData.data) } else { - if (jsonData.status_code == 401) { + if (res.data.status_code == 401 || res.data.status_code == 400) { reject({ - login: false + login : false, + codeBeen: false }) } errInfo(jsonData) diff --git a/app.json b/app.json index b8ba4d5..6407083 100644 --- a/app.json +++ b/app.json @@ -1,6 +1,7 @@ { "pages": [ - "pages/videos/videos" + "pages/shortVideo/shortVideo", + "pages/login/login" ], "window": { "backgroundTextStyle": "light", diff --git a/components/videoSwiper/videoSwiper.js b/components/swiperVideo/swiperVideo.js similarity index 52% rename from components/videoSwiper/videoSwiper.js rename to components/swiperVideo/swiperVideo.js index 5a9613c..6e12469 100644 --- a/components/videoSwiper/videoSwiper.js +++ b/components/swiperVideo/swiperVideo.js @@ -10,13 +10,20 @@ Component({ * 组件的属性列表 */ properties: { + // 视频列表 videoList: { type : Array, value : [] }, - playId : { - type : Number, - value : 0 + // 是否自动播放 + autoPlay: { + type : Boolean, + value : true + }, + // 视频展示方式 + fit:{ + type : String, + value : "contain" } }, @@ -26,7 +33,8 @@ Component({ data: { controls: false, showPlay: false, - isPlay : true + isPlay : false, + playId : 0 }, /** @@ -39,6 +47,9 @@ Component({ current = e.detail.current, currentId = this.data.playId, prevId = videoLists[current].video_id + + // 滚动回调 + this.triggerEvent("swiperindex", {current: current}) // 停止老 let videoContextCurrent = wx.createVideoContext("video" + currentId, this) @@ -69,30 +80,44 @@ Component({ this.setData({ isPlay : !isPlayState }) + }, + // 视频播放状态 + vipdeBindPlay(e){ + this.triggerEvent("play", { + playType : e.type, + videoId : e.currentTarget.dataset.videoid + }) - // let videoId, - // priorId = this.data.playId + if(e.type == "play"){ + this.setData({ + isPlay: true + }) + }else if(e.type == "pause"){ + this.setData({ + isPlay: false + }) + } + } + }, + /** + * 生命周期组件 + */ + lifetimes: { + attached(){ + let videoList = this.data.videoList - // if(e.type == "tap"){ - // // 点击播放视频 - // videoId = "video" + e.currentTarget.dataset.videoid - // // 实例化video - // let videoContext = wx.createVideoContext(videoId) - // // 播放视频 - // videoContext.play() - - // wx.showToast({ - // title: "播放", - // icon : "none" - // }) - // }else{ - // // 滑动切换视频 - // videoId = e - // } - - // console.log("当前的:", videoId) - // console.log("上一个:", priorId) + // 默认当前视频id + if(videoList.length > 0){ + this.setData({ + playId: videoList[0].video_id + }) + // 是否默认播放 + if(this.data.autoPlay){ + let playVideoContext = wx.createVideoContext("video" + videoList[0].video_id, this) + playVideoContext.play() + } + } } } }) diff --git a/components/videoSwiper/videoSwiper.json b/components/swiperVideo/swiperVideo.json similarity index 100% rename from components/videoSwiper/videoSwiper.json rename to components/swiperVideo/swiperVideo.json diff --git a/components/swiperVideo/swiperVideo.wxml b/components/swiperVideo/swiperVideo.wxml new file mode 100644 index 0000000..535a236 --- /dev/null +++ b/components/swiperVideo/swiperVideo.wxml @@ -0,0 +1,19 @@ + + + + + + + diff --git a/components/swiperVideo/swiperVideo.wxss b/components/swiperVideo/swiperVideo.wxss new file mode 100644 index 0000000..8b4285a --- /dev/null +++ b/components/swiperVideo/swiperVideo.wxss @@ -0,0 +1,36 @@ + +/** + * Web唐明明 + * 一个梦想做木雕手艺人的程序员 + * explain: videoSwiper + */ + + .videoSwiper{ + background-color: #0e0c1a; + height: 100%; +} + +.videoSwiperItem{ + position: relative; + -webkit-overflow-scrolling:touch; +} + +.videoSwiperItem video{ + width: 100%; + height: 100%; +} + +/* 视频按钮 */ +.videoLayer-play{ + position: relative; + width: 78rpx; + height: 78rpx; + left: calc(50% - 39rpx); + top: calc(50% - 39rpx); + opacity: 0; + transition: all .5s; +} + +.videoLayer-play.show{ + opacity: .7; +} diff --git a/components/videoSwiper/videoSwiper.wxml b/components/videoSwiper/videoSwiper.wxml deleted file mode 100644 index b07b246..0000000 --- a/components/videoSwiper/videoSwiper.wxml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - @ 哈尔滨域展科技开发 - 计算机网络技术服务,软件开发及咨询、技术评测、技术转让服务; - - - - - - - - - 12.5w - - - - 1000 - - - - 2.9w - - - - - - - - - - diff --git a/pages/login/login.js b/pages/login/login.js new file mode 100644 index 0000000..ca1152f --- /dev/null +++ b/pages/login/login.js @@ -0,0 +1,58 @@ + +/** + * Web唐明明 + * 一个梦想做木雕手艺人的程序员 + */ + +Page({ + + /** + * 页面的初始数据 + */ + data: { + code : "" + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(){ + this.wxLogin() + }, + + /** + * 手机号码授权 + */ + PhoneNumber(e){ + if(!e.detail.encryptedData){ + this.wxLogin() + return + } + wx.$api.auth.authPhone({ + code : this.data.code, + iv : e.detail.iv, + encryptedData : e.detail.encryptedData, + parent_id : "" + }).then(res=>{ + // 存储登录信息 + wx.setStorageSync('token', res.access_token) + // 返回首页 + wx.navigateBack() + }).catch(()=>{ + this.wxLogin() + }) + }, + + /** + * 更新code + */ + wxLogin(){ + wx.login({ + success: res=>{ + this.setData({ + code: res.code + }) + } + }) + } +}) \ No newline at end of file diff --git a/pages/login/login.json b/pages/login/login.json new file mode 100644 index 0000000..478f1e0 --- /dev/null +++ b/pages/login/login.json @@ -0,0 +1,7 @@ + +{ + "usingComponents": { + "userinfo-layer" : "/components/loginLayer/loginLayer" + }, + "navigationBarTitleText": "" +} diff --git a/pages/login/login.wxml b/pages/login/login.wxml new file mode 100644 index 0000000..9bf97c0 --- /dev/null +++ b/pages/login/login.wxml @@ -0,0 +1,11 @@ + + + + + + + + + 点击授权登录表示您已阅读并同意 用户隐私规则用户服务协议 + + diff --git a/pages/login/login.wxss b/pages/login/login.wxss new file mode 100644 index 0000000..cecb73b --- /dev/null +++ b/pages/login/login.wxss @@ -0,0 +1,71 @@ + +/** + * Web唐明明 + * 一个梦想做木雕手艺人的程序员 + */ + +page{ + background-color: white; +} + +.login{ + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-box-pack: center; + position: relative; + text-align: center; + height: 100vh; + width: 100vw; + padding: 100rpx 100rpx 200rpx; + box-sizing: border-box; +} + +/* btn */ +.login-btn[size="default"]{ + width: 100%; + height: 90rpx; + line-height: 90rpx; + padding: 0; + font-size: 34rpx; + border-radius: 0; + background: #2d6af6; + color: white; +} + +/* header */ +.login-header{ + text-align: center; + padding-bottom: 70rpx; +} + +.login-logo{ + width: 128rpx; + height: 128rpx; + background: #eee; + vertical-align: top; +} + +.login-title{ + font-weight: bold; + padding: 50rpx 0 20rpx; + font-size: 40rpx; +} + +.login-subhead{ + font-size: 26rpx; + color: #afafaf; +} + +/* 用户协议 */ +.login-agree{ + margin-top: 20vh; + color: #afafaf; + font-size: 26rpx; + text-align: center; + line-height: 50rpx; +} + +.login-agree text{ + color: #ff8d37; + padding: 0 5rpx; +} diff --git a/pages/shortVideo/shortVideo.js b/pages/shortVideo/shortVideo.js new file mode 100644 index 0000000..2483a41 --- /dev/null +++ b/pages/shortVideo/shortVideo.js @@ -0,0 +1,67 @@ + +Page({ + + /** + * 页面的初始数据 + */ + data: { + videoList : [], //获取短视频列表 + videoIndex : 0, //当前播放视频的下标 + videoId : "", //当前播放的视频id + playState : true, //视频播放状态 + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad(options) { + wx.$api.video.videos().then(res=>{ + this.setData({ + videoList: res, + videoId : res[0].video_id + }) + }) + }, + + /*** + * 视频的播放状态 + */ + videoPlay(e){ + if(e.detail.playType == "play" && this.data.playState == false){ + this.setData({ + playState : true, + videoId : e.detail.videoId + }) + }else if(e.detail.playType == "pause" && this.data.playState == true){ + this.setData({ + playState : false + }) + } + }, + + /** + * 获取视频下标 + */ + swiperIndex(e){ + this.setData({ + videoIndex: e.detail.current + }) + }, + + /** + * 点赞视频 + */ + binLike(){ + let hasLogin = wx.getStorageSync("token") + + if(hasLogin == ""){ + wx.navigateTo({ + url: "/pages/login/login" + }) + }else{ + wx.showToast({ + title: "点赞成功" + }) + } + } +}) diff --git a/pages/videos/videos.json b/pages/shortVideo/shortVideo.json similarity index 67% rename from pages/videos/videos.json rename to pages/shortVideo/shortVideo.json index 3a435cb..7565d74 100644 --- a/pages/videos/videos.json +++ b/pages/shortVideo/shortVideo.json @@ -1,9 +1,8 @@ - { "usingComponents": { - "videoSwiper": "/components/videoSwiper/videoSwiper" + "swiperViode": "/components/swiperVideo/swiperVideo" }, "navigationStyle": "custom", "navigationBarTextStyle": "white", "disableScroll": true -} +} \ No newline at end of file diff --git a/pages/shortVideo/shortVideo.wxml b/pages/shortVideo/shortVideo.wxml new file mode 100644 index 0000000..30aefd0 --- /dev/null +++ b/pages/shortVideo/shortVideo.wxml @@ -0,0 +1,41 @@ + + + + + + @ {{videoList[videoIndex].company.name || "-"}} + {{videoList[videoIndex].description || "-"}} + + + + + + + + + {{videoList[videoIndex].likes || "0"}} + + + + + {{videoList[videoIndex].shares || "0"}} + + + + + + + + + \ No newline at end of file diff --git a/components/videoSwiper/videoSwiper.wxss b/pages/shortVideo/shortVideo.wxss similarity index 55% rename from components/videoSwiper/videoSwiper.wxss rename to pages/shortVideo/shortVideo.wxss index 3ee4c15..40e6c66 100644 --- a/components/videoSwiper/videoSwiper.wxss +++ b/pages/shortVideo/shortVideo.wxss @@ -2,80 +2,59 @@ /** * Web唐明明 * 一个梦想做木雕手艺人的程序员 - * explain: videoSwiper */ -.videoSwiper{ - background-color: #0e0c1a; - height: 100%; - width: 100%; +page{ + background: #0e0c1a; } -.videoSwiperItem{ +.videos-content{ position: relative; -} - -.video{ - z-index: 1; - width: 100%; - height: 100%; -} - -/* 播放按钮 */ -.videoLayer-play{ - position: absolute; - width: 78rpx; - height: 78rpx; - opacity: .6; - top: calc(50% - 39rpx); - left: calc(50% - 39rpx); + height: 100vh; } /* 视频信息 */ -.videoInfo, -.videoTool{ - position: fixed; - bottom: 0; - z-index: 999; -} - -.videoInfo{ - left: 0; - padding: 0 0 50rpx 30rpx; +.video-info{ + position: absolute; + bottom: 50rpx; + left: 30rpx; width: calc(100% - 218rpx); - box-sizing: border-box; - color: white; } -.videoInfoUser{ +.video-user, +.video-title{ + color: white; + text-shadow: 0 3rpx 3rpx rgba(0, 0, 0, .3); +} + +.video-user{ font-weight: bold; + padding-bottom: 10rpx; font-size: 38rpx; } -.videoInfoTitle{ - padding-top: 10rpx; +.video-title{ font-size: 28rpx; line-height: 40rpx; } /* 视频工具栏 */ -.videoTool{ - right: 0; - width: 128rpx; - padding: 0 30rpx 50rpx 0; - box-sizing: border-box; +.video-tool{ + position: absolute; + right: 30rpx; + bottom: 50rpx; } -.videoTool-item{ +.video-tool-item{ margin-top: 40rpx; text-align: center; } -.videoTool-item:first-child{ +.video-tool-item:first-child{ margin-top: 0; } -.videoTool-cover{ +.video-tool-cover{ width: 98rpx; height: 98rpx; border-radius: 50%; @@ -84,25 +63,25 @@ box-sizing: border-box; } -.videoTool-icon{ +.video-tool-icon{ width: 48rpx; vertical-align: top; } -.videoTool-number{ +.video-tool-number{ font-size: 26rpx; line-height: 50rpx; color: white; } /* 黑胶唱片 */ -.videoTool-vinyl{ +.video-tool-vinyl{ width: 98rpx; height: 98rpx; position: relative; } -.videoTool-vinyl.rotate{ +.video-tool-vinyl.rotate{ animation: rotate 10s linear infinite; } @@ -115,22 +94,22 @@ } } -.videoTool-vinyl-cover, -.videoTool-vinyl-back{ +.video-tool-vinyl-cover, +.video-tool-vinyl-back{ position: absolute; } -.videoTool-vinyl-back{ +.video-tool-vinyl-back{ top: 0; left: 0; width: 100%; height: 100%; } -.videoTool-vinyl-cover{ +.video-tool-vinyl-cover{ width: 50%; height: 50%; left: 25%; top: 25%; border-radius: 50%; -} \ No newline at end of file +} diff --git a/pages/videos/videos.js b/pages/videos/videos.js deleted file mode 100644 index 7479f44..0000000 --- a/pages/videos/videos.js +++ /dev/null @@ -1,24 +0,0 @@ - -Page({ - - /** - * 页面的初始数据 - */ - data: { - videoList: [], //获取短视频列表 - showId : 0 //当前播放得id - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad(options) { - wx.$api.video.videos().then(res=>{ - console.log(res) - this.setData({ - videoList: res, - showId : res[0].video_id - }) - }) - } -}) \ No newline at end of file diff --git a/pages/videos/videos.wxml b/pages/videos/videos.wxml deleted file mode 100644 index 2037b3c..0000000 --- a/pages/videos/videos.wxml +++ /dev/null @@ -1,7 +0,0 @@ - - - diff --git a/pages/videos/videos.wxss b/pages/videos/videos.wxss deleted file mode 100644 index 9985056..0000000 --- a/pages/videos/videos.wxss +++ /dev/null @@ -1,16 +0,0 @@ - -/** - * Web唐明明 - * 一个梦想做木雕手艺人的程序员 - */ - -page{ - /* background: #0e0c1a; */ -} - -.videoSwiper{ - width: 100%; - height: 100%; - background: #ddd; - position: absolute; -} diff --git a/static/img/cover.jpeg b/static/img/cover.jpeg deleted file mode 100644 index fe972a7..0000000 Binary files a/static/img/cover.jpeg and /dev/null differ diff --git a/static/img/logo.jpeg b/static/img/logo.jpeg new file mode 100644 index 0000000..6f4568a Binary files /dev/null and b/static/img/logo.jpeg differ