小程序常用实用例子

拍照

// 选择照片

ChooseImage() {

wx.chooseImage({

count: 4, //默认9

sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有

sourceType: ['album'], //从相册选择

success: (res) => {

if (this.data.imgList.length != 0) {

this.setData({

imgList: this.data.imgList.concat(res.tempFilePaths)

})

} else {

this.setData({

imgList: res.tempFilePaths

})

}

}

});

},

页面

<view class="solids" bindtap="ChooseImage" wx:if="{{imgList.length<4}}">

<text class="cuIcon-cameraadd"></text>

</view>

照片预览

<view class="bg-img" wx:for="{{imgList}}" wx:key="index" bindtap="ViewImage" data-url="{{imgList[index]}}">

<image src='{{imgList[index]}}' mode='aspectFill'></image>

<view class="cu-tag bg-red" catchtap="DelImg" data-index="{{index}}">

<text class="cuIcon-close"></text>

</view>

</view>

// 预览照片

ViewImage(e) {

wx.previewImage({

urls: this.data.imgList,

current: e.currentTarget.dataset.url

});

},

// 打电话

CallPhone(e) {

console.log(e, e.currentTarget.dataset.phone)

let phoneNumber = e.currentTarget.dataset.phone

let showphone = e.currentTarget.dataset.showphone

wx.showModal({

title: '温馨提示',

content: `是否拨打${showphone}号码?`,

confirmText: '确定拨打',

confirmColor: '#0081ff',

cancelText: '取消',

cancelColor: '#acb5bd',

success: res => {

console.log(res)

if (res.confirm) {

wx.makePhoneCall({

phoneNumber: phoneNumber,

success: res => {

console.log(res)

},

fail: err => {

console.log(err)

}

})

}

},

fail: err => {

console.log(err)

}

})

},

相关推荐
2501_915909061 小时前
tcpdump 抓包数据分析实战,命令、过滤、常见故障定位与真机补充流程
网络·测试工具·ios·小程序·uni-app·iphone·tcpdump
赵庆明老师5 小时前
Uniapp微信小程序开发:微信小程序支付功能后台代码
微信小程序·小程序·uni-app
00后程序员张8 小时前
tcpdump 抓包分析,命令、过滤技巧、常见症状定位与移动真机补充方案
网络·测试工具·ios·小程序·uni-app·iphone·tcpdump
会点法律的程序员10 小时前
小程序 地理位置授权怎么搞
前端·小程序·uni-app
2501_9159214314 小时前
iOS 26 电耗监测与优化,耗电问题实战 + 多工具 辅助策略
android·macos·ios·小程序·uni-app·cocoa·iphone
2501_9159214314 小时前
苹果软件混淆与 iOS 应用加固白皮书,IPA 文件加密、反编译防护与无源码混淆方案全解析
android·ios·小程序·https·uni-app·iphone·webview
@二十六14 小时前
微信小程序订阅消息工具封装,兼容一次性订阅和长期订阅
微信小程序·小程序·订阅消息
dcloud_jibinbin15 小时前
【uniapp】体验优化:开源工具集 uni-toolkit 发布
前端·webpack·性能优化·小程序·uni-app·vue
用力的活着16 小时前
uniapp 微信小程序蓝牙接收中文乱码
微信小程序·小程序·uni-app
流***陌16 小时前
陪诊陪护小程序前端功能解析:就医照料的便捷对接与全流程保障
小程序