網(wǎng)站開發(fā)與應(yīng)用專業(yè)最近國(guó)際新聞大事
學(xué)習(xí)使用微信小程序?qū)崿F(xiàn)智能名片電子名片功能代碼
- 撥打手機(jī)號(hào)功能
- 一鍵復(fù)制信息功能
- 定位導(dǎo)航功能
- 存入手機(jī)通訊錄功能
- 轉(zhuǎn)發(fā)分享功能
撥打手機(jī)號(hào)功能
wx.makePhoneCall({phoneNumber: 'qipa250' //僅為示例,并非真實(shí)的電話號(hào)碼
})
一鍵復(fù)制信息功能
wx.getClipboardData({success (res){console.log(res.data)}
})
復(fù)制到剪貼板
定位導(dǎo)航功能
wx.getLocation({type: 'gcj02', //返回可以用于wx.openLocation的經(jīng)緯度success (res) {const latitude = res.latitudeconst longitude = res.longitudewx.openLocation({latitude,longitude,scale: 18})}
})
存入手機(jī)通訊錄功能
wx.addPhoneContact({firstName: ifirstName,mobilePhoneNumber: mobilePhoneNumber,weChatNumber: weChatNumber,organization: organization,title: title,addressStreet: addressStreet,email: email});
添加手機(jī)通訊錄聯(lián)系人。用戶可以選擇將該表單以「新增聯(lián)系人」或「添加到已有聯(lián)系人」的方式,寫入手機(jī)系統(tǒng)通訊錄。
轉(zhuǎn)發(fā)分享功能
頁(yè)面內(nèi)發(fā)起轉(zhuǎn)發(fā)。通過給 button 組件設(shè)置屬性 open-type=“share”,可以在用戶點(diǎn)擊按鈕后觸發(fā) Page.onShareAppMessage 事件,相關(guān)組件:button。
/*** 用戶點(diǎn)擊右上角分享*/onShareAppMessage(res) {this.setData({is_share: false,container_top: 50,})console.log('res===', res);//分享地址 路徑,傳遞參數(shù)到指定頁(yè)面。(為空則為當(dāng)前頁(yè)面路徑)let share_path = '/qipa250/pages/my-card/index?qipa=' + this.data.qipa+ "&tel=" + this.data.phone;let share_title = this.data.nickname + '的名片,請(qǐng)惠存';if (res.from == 'button') {// 來自頁(yè)面內(nèi)轉(zhuǎn)發(fā)按鈕return {title: share_title,path: share_path,}} else {//否則是三個(gè)點(diǎn)return {title: share_title, //分享內(nèi)容(為空則為當(dāng)前頁(yè)面文本)path: share_path};}}