微信小程序录音和头像上传

录音:

WXML

html 复制代码
<view class="box4">{{time}}</view>
<button bind:tap="recorderBtn">开始录音</button>
<button bind:tap="removeBtn">结束录音</button>
<button bind:tap="playBtn">播放录音</button>

JS

javascript 复制代码
Page({
  data:{
    time:0,
    clearTime:"",
    fileText:"",
  },
  recorderBtn(){
    this.data.clearTime = setInterval(()=>{
      this.data.time += 1;
      this.setData({time:this.data.time});
    },1000);
    a.start()
  },
  removeBtn(){
    clearInterval(this.data.clearTime);
    this.setData({time:0})
    a.stop();
    a.onStop((res)=>{
      this.data.fileText = res.tempFilePath;
    })
  },
  playBtn(){
    b.src = this.data.fileText;
    b.play();
  },

头像上传:

wxml

html 复制代码
<button class="avatar-wrapper" open-type="chooseAvatar" bindchooseavatar="onChooseAvatar">
  <image class="avatar" src="{{ avatarUrl }}" />
</button>

wxss

css 复制代码
.avatar-wrapper {
  width: 160rpx;
  height: 160rpx;
  padding: 0;
  background: none;
}
.avatar {
  width: 160rpx;
  height: 160rpx;
  border-radius: 20rpx;
}

js

javascript 复制代码
 const defaultAvatar = '../../images/banner.jpg';
Page({
  data:{
    avatarUrl:defaultAvatar,}
)},

onChooseAvatar(e){
    console.log(e);
    const { avatarUrl } = e.detail
    this.setData({ avatarUrl })
  },
相关推荐
笨笨狗吞噬者5 小时前
uni-app 编译小程序原生组件时疑似丢属性,可以给官方提 PR 了
前端·微信小程序·uni-app
摇滚侠8 小时前
JAVA 项目教程《苍穹外卖-11》,微信小程序项目,前后端分离,从开发到部署
java·开发语言·微信小程序
Emma_Maria10 小时前
【小程序】project.config.json 和project.private.config.json 区别以及对应字段含义
小程序
CHU72903510 小时前
家政保洁小程序功能架构解析
小程序
计算机徐师兄11 小时前
Java基于SSM的文玩销售小程序【附源码、文档说明】
java·小程序·文玩销售小程序·文玩销售·java文玩销售小程序·文玩销售微信小程序·java文玩销售微信小程序
雨雨雨雨雨别下啦12 小时前
【从0开始学前端】从0搭建uni-app小程序脚手架
小程序·uni-app
AnalogElectronic13 小时前
uniapp学习8,电动车充电小程序
学习·小程序·uni-app
2501_9159214313 小时前
iPhone 定位功能测试时不越狱来修改手机位置的方法
android·ios·智能手机·小程序·uni-app·iphone·webview
AnalogElectronic15 小时前
uniapp学习9,同时兼容h5和微信小程序的百度地图组件
学习·微信小程序·uni-app
游戏开发爱好者815 小时前
iOS 开发进阶,用 SniffMaster 实现 iPhone 抓包深度分析
android·ios·小程序·https·uni-app·iphone·webview