• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

小程序下拉列表

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
  /**
   * 页面的初始数据
   */
 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\'=>\'上报失败\'];
        }
    }

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
DIV实现下拉菜单 - 小小小程序员发布时间:2022-07-18
下一篇:
微信小程序实现列表下拉刷新上拉加载发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap