云函数

This commit is contained in:
2021-04-08 09:13:57 +08:00
parent ab7a7cf62f
commit 61d399cde1
3 changed files with 35 additions and 3 deletions

12
app.js
View File

@@ -8,6 +8,18 @@ App({
appkey: 'BC-5d0a3ae138494c93869320535ee155fc' appkey: 'BC-5d0a3ae138494c93869320535ee155fc'
}); });
wx.GoEasyIM = GoEasyIM; wx.GoEasyIM = GoEasyIM;
if (!wx.cloud) {
console.error('请使用 2.2.3 或以上的基础库以使用云能力')
} else {
wx.cloud.init({
// env 参数说明:
// env 参数决定接下来小程序发起的云开发调用wx.cloud.xxx会默认请求到哪个云环境的资源
// 此处请填入环境 ID, 环境 ID 可打开云控制台查看
// 如不填则使用默认环境(第一个创建的环境)
// env: 'my-env-id',
traceUser: true,
})
}
}, },
formatDate: function (time) { formatDate: function (time) {
const date = new Date(time); const date = new Date(time);

View File

@@ -47,6 +47,22 @@ Page({
// map: wx.createMapContext('map') // map: wx.createMapContext('map')
// }) // })
// console.log(this.data.map) // console.log(this.data.map)
wx.cloud.callFunction({
name: 'login',
data: {},
success: res => {
console.log('[云函数] [login] user openid: ', res.result.openid)
// app.globalData.openid = res.result.openid
// wx.navigateTo({
// url: '../userConsole/userConsole',
// })
},
fail: err => {
console.error('[云函数] [login] 调用失败', err)
// wx.navigateTo({
// url: '../deployFunctions/deployFunctions',
// })
}
})
} }
}) })

View File

@@ -2,12 +2,16 @@
<view class="container"> <view class="container">
<view class="login"> <view class="login">
<form bindsubmit="login"> <form bindsubmit="login">
<view class="title">GoEasy IM</view> <view class="title">用户登录</view>
<input class="input-box" type="text" placeholder="请输入账号" name="username" confirm-hold hold-keyboard="{{true}}" adjust-position="{{true}}"/> <input class="input-box" type="text" placeholder="请输入账号" name="username" confirm-hold hold-keyboard="{{true}}" adjust-position="{{true}}"/>
<input class="input-box" type="password" placeholder="请输入密码" name= "password" /> <input class="input-box" type="password" placeholder="请输入密码" name= "password" />
<view wx:if="{{showError}}" class="error">请输入正确的用户名和密码</view> <view wx:if="{{showError}}" class="error">请输入正确的用户名和密码</view>
<button class="login-btn" form-type="submit">登录</button> <button class="login-btn" form-type="submit">登录</button>
<view class="login-tips">登录所需用户名和密码见 restapi.js</view> <view class="login-tips">后台没有上线,上线之后直接用微信登录,下面用户随机选一个都行</view>
<view class="login-tips">用户名 Mattie 密码 123</view>
<view class="login-tips">用户名 Wallace 密码 123</view>
<view class="login-tips">用户名 Tracy 密码 123</view>
<view class="login-tips">用户名 Juanita 密码 123</view>
</form> </form>
</view> </view>
</view> </view>