/**
* 页面的初始数据
*/
const App = getApp();
Page({
data: {
devicelist: [],
idlist:[],
deviceindex:0,
choose_device_id: 0,
},
/** * 生命周期函数--监听页面显示 */ onShow: function () { var that = this; //url: App.globalData.URL + 'mydevicelist', //清运 var url ='http://box/mpapi/web/oampapi/mydevicelist'; App.wxRequest('POST', url, { admin_id:wx.getStorageSync('admin_id'), }, (res => { that.setData({ devicelist: res.data_list, idlist: res.id_list, manlist: res.man_list, }) })) },
bindPickerChange: function(e) {
var that = this;
console.log('picker发送选择改变,携带值为', e.detail.value)
this.setData({
deviceindex: e.detail.value,
choose_device_id: that.data.idlist[e.detail.value],
})
},
recovery:function(e){
var that = this;
//var device_name = e.detail.value.device_name;
var device_name = that.data.devicelist[that.data.deviceindex];
var run_man = e.detail.value.run_man;
if(!device_name){
wx.showToast({
title: '请选择设备',
icon: 'none',
duration: 2000
})
}else{
wx.request({
//url: App.globalData.URL + 'run', //清运
url: 'http://box/mpapi/web/oampapi/run',
data: {
device_name: device_name,
device_id: that.data.choose_device_id,
run_man:run_man,
},
method: 'POST',
dataType: 'json',
header: {
'Content-Type': 'application/x-www-form-urlencoded'
},
success: function (res) {
// wx.hideToast()
if(res.data.code==200){
wx.showToast({
title: '提交成功', // 标题
icon: 'success', // 图标类型,默认success
duration: 2000, // 提示窗停留时间,默认1500ms
success:function(){
setTimeout(function () {
//要延时执行的代码
setTimeout(function(){
wx.navigateBack({})
},1500)
}, 1500)//延迟时间
}
})
}
}
})
}
},
})
<view class="seat">
<picker bindchange="bindPickerChange" value="{{deviceindex}}" range="{{devicelist}}">
<view class="picker">
选择设备:{{devicelist[deviceindex]}}
</view>
</picker>
</view>
<view class="box">
<input name="run_man" placeholder="" class="seat" value="{{manlist[deviceindex]}}"></input>
</view>
//给运营助手选择设备用 public function actionMydevicelist(){ $device_list = []; $id_list = []; $man_list = []; $admin = Admin::find()->where(['admin_id'=>$admin_id])->asArray()->one(); if($admin['merchant_id'] !=0){ $device = Device::find()->where(['merchant_id'=>$admin['merchant_id']])->asArray()->all(); }else{ $device = Device::find()->asArray()->all(); } if($device){ foreach ($device as $key=>$value){ $device_list[] = $value['device_name']; $id_list[] = $value['device_id']; $man_list[] = $value['device_man'] ? $value['device_man'] : ''; } } return ['code' => 200, 'msg' => '查询成功','data_list'=>$device_list,'id_list'=>$id_list,'man_list'=> $man_list]; }
//运营助手 清运上报 public function actionRun(){ if(!Yii::$app->request->isPost){ return ['code'=>400,'msg'=>'请求方式错误!']; } $data = Yii::$app->request->post(); $boxlog = new Boxlog(); $boxlog->device_id = $data['device_id']; $boxlog->create_at = time(); $boxlog->user_id = $data['user_id']; $boxlog->run_man = $data['run_man']; if($boxlog->save()){ return ['code'=>200,'msg'=>'上报成功']; // }else{ return ['code'=>200,'msg'=>'上报失败']; } }
浙公网安备 33010602011771号