123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- <template>
-
- <view class="container">
- <view class="add-container">
- <form @submit="bindAddSubmit">
- <view class="form-container">
- <view class="macid-item">
- <input type="text" name="macid" placeholder="请输入15位IMEI号" class="form-input" :value="macid" />
- <image src="/static/resource/images/xiangji2.png" class="form-img-right" @tap="bindScanCode"></image>
- </view>
- <view class="form-btn">
- <button class="login-btn" form-type="submit">添加设备</button>
- </view>
- </view>
- </form>
- <image src="/static/resource/images/shuoming.png" class="bottom-img"></image>
- </view>
- </view>
- </template>
- <script>
- var config = require('../../common/config.js');
- var http = require('../../common/http.js');
- var common = require('../../common/common.js');
- var storage = require('../../common/storage.js');
- export default {
- data() {
- return {
- macid: ''
- };
- }
-
- ,
- onLoad: function (options) {},
-
- onReady: function () {},
-
- onShow: function () {},
-
- onHide: function () {},
-
- onUnload: function () {},
-
- onPullDownRefresh: function () {},
-
- onReachBottom: function () {},
-
- onShareAppMessage: function () {},
- methods: {
- bindScanCode() {
- uni.scanCode({
- onlyFromCamera: true,
- scanType: [],
- success: (res) => {
- console.log(res);
- if (res.result) {
- this.setData({
- macid: res.result
- });
- }
- },
- fail: function (res) {},
- complete: function (res) {}
- });
- },
- bindAddSubmit(e) {
- console.log(e.detail.value);
- const macid = e.detail.value.macid;
- if (common.isEmpty(macid)) {
- common.simpleToast('请输入设备编号');
- return;
- }
- http.postApi(
- config.API_BATTERY_BIND,
- {
- macid: macid
- },
- (resp) => {
- if (resp.data.code === 200) {
- common.simpleToast('添加成功');
- storage.setRefreshDeviceoPage(true);
- setTimeout(function () {
- uni.navigateBack({
- delta: 1
- });
- }, 1500);
- } else {
- common.simpleToast(resp.data.msg);
- }
- }
- );
- }
- }
- };
- </script>
- <style>
- @import './addDevice.css';
- </style>
|