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

录音:

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 })
  },
相关推荐
2501_9160074739 分钟前
iOS App 上架实战 从内测到应用商店发布的全周期流程解析
android·ios·小程序·https·uni-app·iphone·webview
小小怪下士_---_6 小时前
uniapp开发微信小程序自定义导航栏
前端·vue.js·微信小程序·小程序·uni-app
摸着石头过河的石头8 小时前
小程序调试全攻略:微信/支付宝避坑指南,小白也能一次通关
前端·微信小程序
fakaifa1 天前
点大餐饮独立版系统源码v1.0.3+uniapp前端+搭建教程
小程序·uni-app·php·源码下载·点大餐饮·扫码点单
Dignity_呱1 天前
如何在不发版时,实现小程序的 AB 测试?
前端·面试·微信小程序
说私域1 天前
基于开源 AI 大模型 AI 智能名片 S2B2C 商城小程序视角下的企业组织能力建设与破圈升级
人工智能·小程序
fakaifa2 天前
【最新版】CRMEB Pro版v3.4系统源码全开源+PC端+uniapp前端+搭建教程
人工智能·小程序·uni-app·php·crmeb·源码下载·crmebpro
2501_915918412 天前
iOS 应用上架全流程实践,从开发内测到正式发布的多工具组合方案
android·ios·小程序·https·uni-app·iphone·webview
上海云盾第一敬业销售2 天前
小程序被爬虫攻击,使用waf能防护吗?
爬虫·小程序
suncentwl2 天前
做一个答题pk小程序多少钱?
小程序·答题小程序·知识竞赛·答题pk软件