微信小程式人工智慧之新增學生資訊
阿新 • • 發佈:2019-02-06
我們需要根據學生的基本資訊來識別人臉
wxml
<!--pages/add/add.wxml--> <form bindsubmit='formSubmit'> <view class="weui-cells__title">填寫個人資訊</view> <view class="weui-cell weui-cell_input"> <view class="weui-cell__hd"> <view class="weui-label">學號</view> </view> <view class="weui-cell__bd"> <input class="weui-input" name="no" placeholder="請輸入學號" value='1635050222'/> </view> </view> <view class="weui-cell weui-cell_input"> <view class="weui-cell__hd"> <view class="weui-label">姓名</view> </view> <view class="weui-cell__bd"> <input class="weui-input" name="name" placeholder="請輸入姓名" value='張三'/> </view> </view> <view class="weui-cell weui-cell_input"> <view class="weui-cell__hd"> <view class="weui-label">性別</view> </view> <view class="weui-cell__bd"> <input class="weui-input" name="sex" value='{{sex}}' /> </view> <view class="weui-cell__ft"> <switch checked bindchange='switch1Change' /> </view> </view> <view class="weui-cell weui-cell_input"> <view class="weui-cell__hd"> <view class="weui-label">年齡</view> </view> <view class="weui-cell__bd"> <input class="weui-input" name="age" placeholder="請輸入年齡" value='18' /> </view> </view> <view class="weui-btn-area"> <button class="weui-btn" type="primary" form-type='submit'>確定</button> </view> </form>
js
// pages/add/add.js //獲取應用例項 const app = getApp() Page({ /** * 頁面的初始資料 */ data: { sex: '男', imageList: [], id: null }, switch1Change: function (e) { if (e.detail.value) { this.setData({ sex: '男' }); } else { this.setData({ sex: '女' }); } }, formSubmit: function (e) { console.log(e.detail.value); wx.request({ url: app.globalData.url.add, method: 'POST', data: e.detail.value, header: { 'content-type': 'application/x-www-form-urlencoded', Cookie: wx.getStorageSync('session_id') }, success: (res) => { console.log(res); if (res.data.error==true) { wx.showToast({ title: res.data.msg, icon: 'none', duration: 2000 }) } else { // console.log(res.data.id); wx.showToast({ title:res.data.msg, icon: 'success', duration: 2000, success: function () { setTimeout(function () { wx.navigateTo({ url: '../headimg/headimg?id=' + res.data.id }) }, 2000) } }) } } }) }, /** * 生命週期函式--監聽頁面載入 */ onLoad: function (options) { }, /** * 生命週期函式--監聽頁面初次渲染完成 */ onReady: function () { }, /** * 生命週期函式--監聽頁面顯示 */ onShow: function () { }, /** * 生命週期函式--監聽頁面隱藏 */ onHide: function () { }, /** * 生命週期函式--監聽頁面解除安裝 */ onUnload: function () { }, /** * 頁面相關事件處理函式--監聽使用者下拉動作 */ onPullDownRefresh: function () { }, /** * 頁面上拉觸底事件的處理函式 */ onReachBottom: function () { }, /** * 使用者點選右上角分享 */ onShareAppMessage: function () { } })