feat: 调用云函数
This commit is contained in:
6
cloudfunctions/getPhoneNum/config.json
Normal file
6
cloudfunctions/getPhoneNum/config.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"permissions": {
|
||||
"openapi": [
|
||||
]
|
||||
}
|
||||
}
|
||||
11
cloudfunctions/getPhoneNum/index.js
Normal file
11
cloudfunctions/getPhoneNum/index.js
Normal file
@@ -0,0 +1,11 @@
|
||||
// 云函数入口文件
|
||||
const cloud = require('wx-server-sdk')
|
||||
|
||||
cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境
|
||||
|
||||
// 云函数入口函数
|
||||
exports.main = async (event, context) => {
|
||||
const wxContext = cloud.getWXContext()
|
||||
var moblie = event.weRunData.data.phoneNumber;
|
||||
return moblie
|
||||
}
|
||||
14
cloudfunctions/getPhoneNum/package.json
Normal file
14
cloudfunctions/getPhoneNum/package.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "getPhoneNum",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"wx-server-sdk": "~2.6.3"
|
||||
}
|
||||
}
|
||||
2
dist/pages/my/index.js
vendored
2
dist/pages/my/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/pages/my/index.js.LICENSE.txt
vendored
2
dist/pages/my/index.js.LICENSE.txt
vendored
@@ -24,6 +24,8 @@
|
||||
|
||||
/*! @antmjs/vantui/es/cell */
|
||||
|
||||
/*! @antmjs/vantui/es/image */
|
||||
|
||||
/*! @antmjs/vantui/es/tab */
|
||||
|
||||
/*! @antmjs/vantui/es/tabs */
|
||||
|
||||
5
dist/project.config.json
vendored
5
dist/project.config.json
vendored
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"miniprogramRoot": "",
|
||||
"miniprogramRoot": "./",
|
||||
"projectname": "myApp",
|
||||
"description": "city",
|
||||
"appid": "wx2b2ec2ba5ee694bc",
|
||||
@@ -28,7 +28,8 @@
|
||||
"simulatorType": "wechat",
|
||||
"simulatorPluginLibVersion": {},
|
||||
"condition": {},
|
||||
"libVersion": "2.27.2",
|
||||
"libVersion": "2.27.3",
|
||||
"srcMiniprogramRoot": "dist/",
|
||||
"packOptions": {
|
||||
"ignore": [],
|
||||
"include": []
|
||||
|
||||
2
dist/taro.js
vendored
2
dist/taro.js
vendored
@@ -1,2 +1,2 @@
|
||||
/*! For license information please see taro.js.LICENSE.txt */
|
||||
"use strict";(wx.webpackJsonp=wx.webpackJsonp||[]).push([["taro"],{"./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js":function(t,n,e){e.d(n,{Button:function(){return a},Form:function(){return i},Image:function(){return f},Input:function(){return c},Navigator:function(){return m},OpenData:function(){return w},RichText:function(){return o},ScrollView:function(){return s},Text:function(){return u},Textarea:function(){return p},View:function(){return r}});var r="view",o="rich-text",u="text",a="button",i="form",c="input",p="textarea",s="scroll-view",m="navigator",f="image",w="open-data"},"./node_modules/@tarojs/webpack5-runner/dist/template/comp.js":function(t,n,e){var r=e("webpack/container/remote/@tarojs/runtime");Component((0,r.createRecursiveComponentConfig)())},"./node_modules/@tarojs/webpack5-runner/dist/template/custom-wrapper.js":function(t,n,e){var r=e("webpack/container/remote/@tarojs/runtime");Component((0,r.createRecursiveComponentConfig)("custom-wrapper"))}}]);
|
||||
"use strict";(wx.webpackJsonp=wx.webpackJsonp||[]).push([["taro"],{"./node_modules/@tarojs/plugin-platform-weapp/dist/components-react.js":function(t,n,e){e.d(n,{Button:function(){return a},Form:function(){return i},Image:function(){return f},Input:function(){return c},Navigator:function(){return m},RichText:function(){return o},ScrollView:function(){return s},Text:function(){return u},Textarea:function(){return p},View:function(){return r}});var r="view",o="rich-text",u="text",a="button",i="form",c="input",p="textarea",s="scroll-view",m="navigator",f="image"},"./node_modules/@tarojs/webpack5-runner/dist/template/comp.js":function(t,n,e){var r=e("webpack/container/remote/@tarojs/runtime");Component((0,r.createRecursiveComponentConfig)())},"./node_modules/@tarojs/webpack5-runner/dist/template/custom-wrapper.js":function(t,n,e){var r=e("webpack/container/remote/@tarojs/runtime");Component((0,r.createRecursiveComponentConfig)("custom-wrapper"))}}]);
|
||||
@@ -17,10 +17,26 @@
|
||||
"coverView": true,
|
||||
"showShadowRootInWxmlPanel": false,
|
||||
"scopeDataCheck": false,
|
||||
"useCompilerModule": false
|
||||
"useCompilerModule": false,
|
||||
"babelSetting": {
|
||||
"ignore": [],
|
||||
"disablePlugins": [],
|
||||
"outputPath": ""
|
||||
}
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"simulatorType": "wechat",
|
||||
"simulatorPluginLibVersion": {},
|
||||
"condition": {}
|
||||
}
|
||||
"condition": {},
|
||||
"libVersion": "2.27.3",
|
||||
"srcMiniprogramRoot": "dist/",
|
||||
"packOptions": {
|
||||
"ignore": [],
|
||||
"include": []
|
||||
},
|
||||
"editorSetting": {
|
||||
"tabIndent": "insertSpaces",
|
||||
"tabSize": 2
|
||||
},
|
||||
"cloudfunctionTemplateRoot": "cloudfunctionTemplate/"
|
||||
}
|
||||
@@ -20,23 +20,31 @@ import ActiveCard from "../components/ActiveCard";
|
||||
const my = (props: any) => {
|
||||
// const [active, setActive] = react.useState(props?.active ?? 0);
|
||||
|
||||
|
||||
// 云函数,-获取手机号
|
||||
const getLogin = (e:any) => {
|
||||
Taro.cloud
|
||||
.callFunction({
|
||||
name: "getPhoneNum",
|
||||
data: {
|
||||
weRunData: Taro.cloud.CloudID(e.detail.cloudID)
|
||||
},
|
||||
})
|
||||
.then((res:any) => {
|
||||
console.log('res11')
|
||||
console.log('res',res)
|
||||
// this.setState({
|
||||
// context: res.result,
|
||||
// });
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
// 设置标题
|
||||
definePageConfig({
|
||||
navigationBarTitleText: "我的",
|
||||
});
|
||||
|
||||
// Taro.getUserProfile({
|
||||
// desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
|
||||
// success: (res) => {
|
||||
// // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
|
||||
// console.log('res',res)
|
||||
// // this.setState({
|
||||
// // userInfo: res.userInfo,
|
||||
// // hasUserInfo: true
|
||||
// // })
|
||||
// }
|
||||
// })
|
||||
}, []);
|
||||
|
||||
const CardCom = () => {
|
||||
@@ -63,17 +71,9 @@ const my = (props: any) => {
|
||||
|
||||
const getPhoneNumber = (e:any) => {
|
||||
console.log('点击获取手机事件', e.detail.cloudID);
|
||||
Taro.cloud.callFunction({
|
||||
name: "getPhone",
|
||||
data: {
|
||||
cloudID: e.detail.cloudID
|
||||
// weRunData
|
||||
},
|
||||
}).then((res:any) => {
|
||||
console.log(res);
|
||||
console.log(res.result.list[0].data.phoneNumber);
|
||||
|
||||
})
|
||||
// 调用云函数获取手机号
|
||||
getLogin(e)
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -83,13 +83,13 @@ const my = (props: any) => {
|
||||
{/* 头像 */}
|
||||
<View className={`myImage`}>
|
||||
{/* 微信开放api-用户头像 */}
|
||||
<OpenData type="userAvatarUrl"></OpenData>
|
||||
{/* <Image
|
||||
{/* <OpenData type="userAvatarUrl"></OpenData> */}
|
||||
<Image
|
||||
round
|
||||
width="100px"
|
||||
height="100px"
|
||||
src="cloud://cloud1-5g5xrgza12a0dd6d.636c-cloud1-5g5xrgza12a0dd6d-1253665791/images/images-2.jpg"
|
||||
/> */}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<View>
|
||||
|
||||
Reference in New Issue
Block a user