现在小程序做用户识别用什么api?
之前用openid做识别,然后就让对应的用户使用自己的小程序,
现在无法获取openid的话,应该怎么识别具体用户?
<!--miniprogram/pages/login/login.wxml-->
<view class="userinfo">
<view class="userinfo-avatar">
<open-data type="userAvatarUrl"></open-data>
</view>
<open-data type="userNickName"></open-data>
</view>
<button wx:if="{{canIUse&&!wait}}" class="btn"
type="primary" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 授权登录 </button>
<view wx:elif="{{!canIUse}}">请升级微信版本</view>
<view wx:elif="{{wait}}" class="tips">{{name}}请等待审核</view>
<view class='toast-box' hidden='{{!inputname}}'>
<view class='toastbg'></view>
<view class='showToast'>
<view class='toast-title'>
<text>新建姓名</text>
</view>
<view class='toast-main'>
<view class='toast-input'>
<input placeholder='请输入姓名' bindinput='setValue' data-name='stuEidtName'></input>
</view>
</view>
<view class='toast-button'>
<view class='button1'>
<button catchtap='cancel'>取消</button>
</view>
<view class='button2'>
<button catchtap='confirm'>确定</button>
</view>
</view>
</view>
</view>
// miniprogram/pages/login/login.js
// miniprogram/pages/putin/putin.js
import '../../utils/wxPromise.min.js'
const app = getApp()
Page({
data: {
canIUse: wx.canIUse('button.open-type.getUserInfo'),
openID: '',
wait: false,
inputname: false,
name: '',
},
onLoad: function () {
this.getdb();
},
getdb: function () {
/** * 赋值listTowsData,后续不用再读取*/
wx.pro.request({
url: 'https://hn2.api.XXX.com',
data: {
s: 'App.Table.FreeQuery',
model_name: 'towsClass',
where: '[["id", ">", "0"]]',
app_key: 'XXXXXXXXXXX'
},
method: 'GET',
header: {
'content-type': 'application/json'
}
}).then(res => {
app.listTowsData = res.data.data.list
}).catch(err => {
console.log(err)
}).finally(() => {
wx.hideLoading()
})
},
})
2 回复
<!--miniprogram/pages/login/login.wxml-->
<view class="userinfo">
<view class="userinfo-avatar">
<open-data type="userAvatarUrl"></open-data>
</view>
<open-data type="userNickName"></open-data>
</view>
<button wx:if="{{canIUse&&!wait}}" class="btn"
type="primary" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 授权登录 </button>
<view wx:elif="{{!canIUse}}">请升级微信版本</view>
<view wx:elif="{{wait}}" class="tips">{{name}}请等待审核</view>
<view class='toast-box' hidden='{{!inputname}}'>
<view class='toastbg'></view>
<view class='showToast'>
<view class='toast-title'>
<text>新建姓名</text>
</view>
<view class='toast-main'>
<view class='toast-input'>
<input placeholder='请输入姓名' bindinput='setValue' data-name='stuEidtName'></input>
</view>
</view>
<view class='toast-button'>
<view class='button1'>
<button catchtap='cancel'>取消</button>
</view>
<view class='button2'>
<button catchtap='confirm'>确定</button>
</view>
</view>
</view>
</view>