Browse Source

Signed-off-by: yukangzhe <382985154@qq.com>

yukangzhe 3 years ago
parent
commit
a06250230f

+ 42 - 142
pages/demo/demo.js

@@ -13,166 +13,66 @@ Page({
    * 页面的初始数据
    * 页面的初始数据
    */
    */
   data: {
   data: {
-    video: "",
-    poster: 'http://y.gtimg.cn/music/photo_new/T002R300x300M000003rsKF44GyaSk.jpg?max_age=2592000',
-    name: '此时此刻',
-    author: '许巍',
-    audiosrc: 'https://www.1ting.com/api/audio?/2020/05/18/18a_yx/01.mp3',
+    height: 0,
+    animation: {},
+    left: 750
   },
   },
 
 
-  changeVideo:function(){
-    var that = this
-    var uploader = new VODUpload({
-      //阿里账号ID,必须有值
-      userId: "WaWQOn6gXod13WLEp8cr4ljUdvcbXJ",
-      //网络原因失败时,重新上传次数,默认为3
-      retryCount: 3,
-      //网络原因失败时,重新上传间隔时间,默认为2秒
-      retryDuration: 2,
-      //开始上传
-      'onUploadstarted': function (uploadInfo) {
-        console.log(uploadInfo)
-        // console.log("onUploadStarted:" + uploadInfo.file.name + ", endpoint:" + uploadInfo.endpoint + ", bucket:" + uploadInfo.bucket + ", object:" + uploadInfo.object)
-        //上传方式1,需要根据uploadInfo.videoId是否有值,调用点播的不同接口获取uploadauth和uploadAddress,如果videoId有值,调用刷新视频上传凭证接口,否则调用创建视频上传凭证接口
-        if (uploadInfo.videoId) {
-          console.log('true');
-          //如果uploadInfo.videoId存在,调用刷新视频上传凭证接口
-        } else {
-          console.log('false');
-          //如果uploadInfo.videoId不存在,调用获取视频上传地址和凭证接口
-        }
-        //从点播服务获取的uploadAuth、uploadAddress和videoId,设置SDK
-        uploader.setUploadAuthAndAddress(uploadInfo, that.data.uploadAuth, that.data.uploadAddress, that.data.videoId);
+  takePhoto() {
+    const ctx = wx.createCameraContext()
+    ctx.takePhoto({
+      quality: 'high',
+      success: (res) => {
+        console.log(res.tempImagePath)
       },
       },
-      //文件上传成功
-      'onUploadSucceed': function (uploadInfo) {
-        console.log("上传成功:" + JSON.stringify(uploadInfo))
-        that.setData({
-          poster: uploadInfo.coverUrl,
-          src: uploadInfo.url
-        })
-        // console.log("onUploadSucceed: " + uploadInfo.file.name + ", endpoint:" + uploadInfo.endpoint + ", bucket:" + uploadInfo.bucket + ", object:" + uploadInfo.object);
-      },
-      //文件上传失败
-      'onUploadFailed': function (uploadInfo, code, message) {
-        console.log("onUploadFailed: file:" + uploadInfo.file.name + ",code:" + code + ", message:" + message);
-      },
-      //文件上传进度,单位:字节
-      'onUploadProgress': function (uploadInfo, totalSize, loadedPercent) {
-        // console.log("onUploadProgress:file:" + uploadInfo.file.name + ", fileSize:" + totalSize + ", percent:" + Math.ceil(loadedPercent * 100) + "%");
-      },
-      //上传凭证超时
-      'onUploadTokenExpired': function (uploadInfo) {
-        console.log("onUploadTokenExpired");
-        //实现时,根据uploadInfo.videoId调用刷新视频上传凭证接口重新获取UploadAuth
-        //从点播服务刷新的uploadAuth,设置到SDK里
-        uploader.resumeUploadWithAuth(uploadAuth);
-      },
-      //全部文件上传结束
-      'onUploadEnd': function (uploadInfo) {
-        console.log("onUploadEnd: uploaded all the files");
-      }
-    });
-
-    wx.chooseVideo({
-      camera: ['album'],
-      success(res){
-        var file = {url: res.tempFilePath, coverUrl: res.thumbTempFilePath};
-        var userData = '{"Vod":{}}';
-        const urls = urlDef.urls;
-        let createUrl = urls.video_create_upload + '?title=' + res.tempFilePath + '&fileName=' + res.tempFilePath;
-        util.apiPost(createUrl).then((rs) => {
-          
-          let d = JSON.parse(rs.data);
-          // console.log('createUploadVideo ' + JSON.stringify(d));
-          that.setData({
-             uploadAuth : d.UploadAuth,
-             uploadAddress : d.UploadAddress,
-             videoId : d.VideoId,
-          })
-          uploader.addFile(file, null, null, null, userData)
-          uploader.startUpload();
-          // uploader.setUploadAuthAndAddress(uploadInfo, uploadAuth, uploadAddress, videoId);
-        }, e => {
-          console.log('createUploadVideo error ' + JSON.stringify(e));
-        });
+      error(e) {
+        console.log(e.detail)
       }
       }
     })
     })
   },
   },
-
-  audioPlay: function () {
-    
-    // audio.src = 'https://webfs.yun.kugou.com/202102261333/6839aa7db664ae01c1f11d5185d92c13/G129/M08/1B/0B/IYcBAFxqmLKABFylADPZC9WDX8A077.mp3';
-    audio.src = this.data.audioSrc
-    audio.play()
-    // this.audioCtx.play()
-  },
-  audioPause: function () {
-    this.audioCtx.pause()
-  },
-  audio14: function () {
-    this.audioCtx.seek(14)
-  },
-  audioStart: function () {
-    this.audioCtx.seek(0)
+  scanCode:function(e){
+    console.log(JSON.stringify(e))
   },
   },
 
 
-  startRecord:function(){
-    var that = this
-    wx.getSetting({
-      success(res) {
-        if (!res.authSetting['scope.record']) {
-          wx.authorize({
-            scope: 'scope.record',
-            success () {
-              // 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问
-              that.getRecord()
-            }
-          })
-        } else {
-          that.getRecord()
-        }
-      }
+  closeCamera:function(){
+    this.animation = wx.createAnimation({
+      timingFunction: 'linear',
+      duration: 500
     })
     })
-    
+    const left = 750
 
 
-    
-  },
-
-  getRecord: function () {
-    const options = {}
-    recordManager.start(options)
-  },
-
-  endRecord: function () {
-    recordManager.stop()
-    recordManager.onStop((res) => {  //监听录音停止的事件
-      console.log("监听录音停止事件",res)
-      if (res.duration < 1000) {
-        wx.showToast({
-          title: '录音时间太短'
-        })
-        return;
-      } else {
-       
-        var tempFilePath = res.tempFilePath; // 文件临时路径
-        console.log("文件临时路径", tempFilePath)
-        audio.src = tempFilePath
-        audio.play()
-      }
-    });
+    this.animation.translateX(left).step()
+    this.setData({
+      animation:this.animation.export()
+    })
   },
   },
 
 
-  playAudio:function(){
-    this.audioContext.play()
+  showCamera:function(){
+    this.animation = wx.createAnimation({
+      timingFunction: 'linear',
+      duration: 500
+    })
+    const left = 0
+    this.animation.translateX(left).step()
+    this.setData({
+      animation:this.animation.export(),
+    })
   },
   },
+ 
 
 
   /**
   /**
    * 生命周期函数--监听页面加载
    * 生命周期函数--监听页面加载
    */
    */
   onLoad: function (options) {
   onLoad: function (options) {
-    this.audioCtx = wx.createAudioContext('myAudio')
-   
+  
+
+    wx.getSystemInfo({
+      success: (result) => {
+        this.setData({
+          height: result.windowHeight
+        })
+      },
+    })
   },
   },
 
 
   /**
   /**

+ 5 - 13
pages/demo/demo.wxml

@@ -1,14 +1,6 @@
-<view>
-  <view>
-    <view bindtap="changeVideo">上传视频</view>
-    <video poster="{{poster}}" src="{{src}}"></video>
-  </view>
+<view class="camera-view" animation="{{animation}}" style="left:{{left}}rpx">
+  <view class="close-camera" bindtap="closeCamera">关闭</view>
+  <camera device-position="back" mode="scanCode" resolution="high" flash="off" bindscancode="scanCode" binderror="error" style="width: 100%; height: {{height}}px;"></camera>
+</view>
 
 
-  <view>
-    <audio poster="{{poster}}" name="{{name}}" author="{{author}}" src="{{audiosrc}}" id="myAudio" controls></audio>
-    <button type="primary" bindtap="getRecord">录音</button>
-    <button type="primary" bindtap="endRecord">停止并播放</button>
-    <button type="primary" bindtap="audio14">设置当前播放时间为14秒</button>
-    <button type="primary" bindtap="audioStart">回到开头</button>
-  </view>
-</view>
+<view bindtap="showCamera">显示</view>

+ 15 - 0
pages/demo/demo.wxss

@@ -0,0 +1,15 @@
+.close-camera{
+  position: absolute;
+    z-index: 2;
+    color: #FFF;
+    top: 20rpx;
+    right: 20rpx;
+    font-size: 36rpx;
+    padding: 25rpx;
+}
+.camera-view{
+  position: absolute;
+    top: 0;
+    width: 750rpx;
+    left: 750rpx;
+}

+ 41 - 9
pages/editMyself/editMyself.js

@@ -1,4 +1,7 @@
 // pages/editMyself/editMyself.js
 // pages/editMyself/editMyself.js
+const app = getApp()
+const util = require("../../utils/util")
+const urlDef = require("../../utils/urls")
 Page({
 Page({
 
 
   /**
   /**
@@ -7,19 +10,48 @@ Page({
   data: {
   data: {
     index: 0,
     index: 0,
     array:['未知','男','女'],
     array:['未知','男','女'],
-   
+    name: '',
+    src: ''
   },
   },
 
 
-  changeHead:function(){
-    var that = this
+  changeHead: function () {
+    const that = this
+    const urls = urlDef.urls;
     wx.chooseImage({
     wx.chooseImage({
-      count: 1,
-      sourceType:['album', 'camera'],
-      success(res){
-        console.log(JSON.stringify(res))
-        that.setData({
-          src: res.tempFilePaths[0]
+      count: 6,
+      sourceType: ['album', 'camera'],
+      success(res) {
+        wx.showLoading({
+          title: '上传中...',
         })
         })
+        for (var i in res.tempFilePaths) {
+          wx.uploadFile({
+            filePath: res.tempFilePaths[i],
+            name: 'name',
+            url: urls.file_upload,
+            header: util.getHeaders(),
+            success(res) {
+              wx.showToast({
+                title: '上传成功',
+              })
+              const rs = JSON.parse(JSON.parse(JSON.stringify(res.data)))
+              that.setData({
+               src: rs.data[0].url
+              })
+            },
+            fail(res) {
+              wx.showToast({
+                title: '上传失败',
+                icon: none
+              })
+            },
+            complete(res) {
+              wx.hideLoading({
+                success: (res) => { },
+              })
+            }
+          })
+        }
       }
       }
     })
     })
   },
   },

+ 39 - 1
pages/student/student.js

@@ -5,14 +5,52 @@ Page({
    * 页面的初始数据
    * 页面的初始数据
    */
    */
   data: {
   data: {
+    height: 0,
+    animation: {},
+    left: 750
+  },
+
+  closeCamera:function(){
+    this.animation = wx.createAnimation({
+      timingFunction: 'linear',
+      duration: 400
+    })
+    const left = 750
+    this.animation.translateX(left).step()
+    this.setData({
+      animation:this.animation.export()
+    })
+  },
 
 
+  showCamaer:function(){
+    this.animation = wx.createAnimation({
+      timingFunction: 'linear',
+      duration: 100
+    })
+    const left = 0
+    this.animation.translateX(left).step()
+    this.setData({
+      animation:this.animation.export(),
+      left
+    })
+   
+  },
+
+  scanCode:function(e){
+    console.log(JSON.stringify(e))
   },
   },
 
 
   /**
   /**
    * 生命周期函数--监听页面加载
    * 生命周期函数--监听页面加载
    */
    */
   onLoad: function (options) {
   onLoad: function (options) {
-
+    wx.getSystemInfo({
+      success: (result) => {
+        this.setData({
+          height: result.windowHeight
+        })
+      },
+    })
   },
   },
 
 
   /**
   /**

+ 44 - 32
pages/student/student.wxml

@@ -1,38 +1,50 @@
 <view class="container">
 <view class="container">
-<image class="bgImg" mode="widthFix" src="https://app.schoolwisdoms.com/static/app/student/imgs/invitation_bg.png"></image>
-<view class="btn-view">
-  <view class="left-radius"></view>
-  <view class="right-radius"></view>
-  <view class="btn-box">
-    <view class="share-btn">海报分享邀请好友</view>
-    <view class="line"></view>
-    <view class="other-btn">
-      <view class="">
-        <image class="icon-img" mode="heightFix" src="https://app.schoolwisdoms.com/static/app/student/imgs/sm_link.png"></image>
-        <text>链接邀请</text>
-      </view>
-      <view class="">
-        <image class="icon-img" mode="heightFix" src="https://app.schoolwisdoms.com/static/app/student/imgs/sm_code.png"></image>
-        <text>面对面扫码</text>
+  <view class="camera-view" animation="{{animation}}" style="left:{{left}}rpx">
+    <view class="close-camera" bindtap="closeCamera">关闭</view>
+    <camera device-position="back" mode="scanCode" resolution="high" flash="off" bindscancode="scanCode"
+      binderror="error" style="width: 100%; height: {{height}}px;"></camera>
+  </view>
+
+  <image class="bgImg" mode="widthFix" src="https://app.schoolwisdoms.com/static/app/student/imgs/invitation_bg.png">
+  </image>
+  <view class="btn-view">
+    <view class="left-radius"></view>
+    <view class="right-radius"></view>
+    <view class="btn-box">
+      <view class="share-btn">海报分享邀请好友</view>
+      <view class="line"></view>
+      <view class="other-btn">
+        <view class="">
+          <image class="icon-img" mode="heightFix"
+            src="https://app.schoolwisdoms.com/static/app/student/imgs/sm_link.png"></image>
+          <text>链接邀请</text>
+        </view>
+        <view class="" bindtap="showCamaer">
+          <image class="icon-img" mode="heightFix"
+            src="https://app.schoolwisdoms.com/static/app/student/imgs/sm_code.png"></image>
+          <text>面对面扫码</text>
+        </view>
       </view>
       </view>
     </view>
     </view>
   </view>
   </view>
-</view>
-<image class="bgImg step-one" mode="widthFix" src="https://app.schoolwisdoms.com/static/app/student/imgs/invitation-c1.png"></image>
-<image class="bgImg step-two" mode="widthFix" src="https://app.schoolwisdoms.com/static/app/student/imgs/invitation-c2.png"></image>
-<view class="total-view">
-  <view>
-    0
-    <text>已试听/人</text>
-  </view>
-  <view>
-    0
-    <text>已购课/人</text>
-  </view>
-  <view>
-    0
-    <text>获得奖励</text>
+  <image class="bgImg step-one" mode="widthFix"
+    src="https://app.schoolwisdoms.com/static/app/student/imgs/invitation-c1.png"></image>
+  <image class="bgImg step-two" mode="widthFix"
+    src="https://app.schoolwisdoms.com/static/app/student/imgs/invitation-c2.png"></image>
+  <view class="total-view">
+    <view>
+      0
+      <text>已试听/人</text>
+    </view>
+    <view>
+      0
+      <text>已购课/人</text>
+    </view>
+    <view>
+      0
+      <text>获得奖励</text>
+    </view>
   </view>
   </view>
-</view>
-<image class="bgImg step-three" mode="widthFix" src="https://app.schoolwisdoms.com/static/app/student/imgs/invitation-c3.png"></image>
+  <image class="bgImg step-three" mode="widthFix"
+    src="https://app.schoolwisdoms.com/static/app/student/imgs/invitation-c3.png"></image>
 </view>
 </view>

+ 17 - 0
pages/student/student.wxss

@@ -112,4 +112,21 @@ image{
     font-weight: 400;
     font-weight: 400;
     font-size: 32rpx;
     font-size: 32rpx;
     color: #999;
     color: #999;
+}
+
+.close-camera{
+  position: absolute;
+    z-index: 2;
+    color: #FFF;
+    top: 20rpx;
+    right: 20rpx;
+    font-size: 36rpx;
+    padding: 25rpx;
+}
+.camera-view{
+  position: absolute;
+    top: 0;
+    width: 750rpx;
+    left: 750rpx;
+    z-index: 3;
 }
 }

+ 2 - 2
project.config.json

@@ -62,8 +62,8 @@
     "miniprogram": {
     "miniprogram": {
       "list": [
       "list": [
         {
         {
-          "name": "pages/index/index",
-          "pathName": "pages/index/index",
+          "name": "pages/demo/demo",
+          "pathName": "pages/demo/demo",
           "query": "",
           "query": "",
           "scene": null
           "scene": null
         }
         }