小程序常用实用例子

拍照

// 选择照片

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)

}

})

},

相关推荐
胡西风_foxww8 小时前
微信小程序转Vue2组件智能提示词
微信小程序·小程序·提示词·智能体·vue2组件
七七软件开发8 小时前
一对一交友小程序 / APP 系统架构分析
java·python·小程序·系统架构·php
2501_9160074710 小时前
iPhone查看App日志和系统崩溃日志的完整实用指南
android·ios·小程序·https·uni-app·iphone·webview
说私域12 小时前
基于开源链动2+1模式AI智能名片S2B2C商城小程序的私域流量拉新策略研究
人工智能·小程序·开源
2501_9159184113 小时前
iOS 抓不到包怎么办?全流程排查思路与替代引导
android·ios·小程序·https·uni-app·iphone·webview
七七软件开发14 小时前
团购商城 app 系统架构分析
java·python·小程序·eclipse·系统架构·php
七七软件开发14 小时前
打车小程序 app 系统架构分析
java·python·小程序·系统架构·交友
说私域1 天前
从渠道渗透到圈层渗透:开源链动2+1模式、AI智能名片与S2B2C商城小程序的协同创新路径研究
人工智能·小程序·开源
一匹电信狗2 天前
【Linux我做主】进程优先级
linux·运维·服务器·c++·ubuntu·小程序·unix
壹立科技2 天前
Java源码构建智能名片小程序
java·开发语言·小程序