Newer
Older
miniprogram / pages / demo / demo.js
bello on 5 Mar 2020 2 KB Initial Commit

const config = require("../../config")

Page({

  /**
   * 页面的初始数据
   */
  data: {
    demoImg: config.demoImgUrl,
    demoImg2: config.demoImgUrl2,
    tmpPhotoPath: '', //拍照返回的路径
    tmpThumbPath: '', //录像返回的路径
    tmpVideoPath: '',  //录像返回的路径
    tmpRecordPath: '', //录音返回的路径 
  },

  /*
   *  打开拍照页面 
   */
  openCameraPage: function (event) {
    
    wx.navigateTo({
      url: '../camera/camera?type='+event.currentTarget.dataset.id,
    })
  },

  openVoicePage: function (event) {

    wx.navigateTo({
      url: '../voice/voice',
    })
  },

  /**
   * 预览图片
   */
  previewPhoto() {
    wx.navigateTo({
      url: '../preview/previewphoto?video=&record=&url='+this.data.tmpPhotoPath,
    })
  },

  /**
   * 预览视频
   */
  previewVideo() {
    wx.navigateTo({
      url: '../preview/previewphoto?url=&record=&video=' + this.data.tmpVideoPath,
    })
  },

  /**
   * 预览录音
   */
  previewRecord() {
    wx.navigateTo({
      url: '../preview/previewphoto?url=&video=&record=' + encodeURIComponent(this.data.tmpRecordPath),
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData ({
      tmpPhotoPath: '',
      tmpThumbPath: '',
      tmpVideoPath: '',
      tmpRecordPath: '',
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    
  }
})