12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- const APP = getApp();
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- deviceNum: "",
- },
- /**
- * 扫码
- */
- scanCode: function () {
- const that = this;
- wx.scanCode({
- success(res) {
- that.setData({
- deviceNum: res.result
- })
- },
- fail: function () {
- console.log("调用摄像头失败")
- }
- })
- },
- /**
- * 提交表单
- */
- submit: function (form) {
- const params = {
- name: form.detail.value.deviceName,
- deviceNum: form.detail.value.deviceNum,
- }
- if (params.deviceNum == null || params.deviceNum === "") {
- APP.Modal.tips("请输入设备码!")
- return;
- }
- if (params.name == null || params.name === "") {
- APP.Modal.tips("请输入设备名称!")
- return;
- }
- //禁用提交按钮
- this.setData({
- deviceNum: "",
- deviceName: "",
- })
- APP.Post(APP.Url.bind, params).then(res => {
- //更新设备集合
- APP.Get(APP.Url.getListByUserId, params, false).then(res => {
- APP.globalData.deviceList = res.data;
- APP.Modal.tips("添加成功!");
- })
- })
- },
- })
|