rates.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace WY\app\controller\mobile;
  3. use WY\app\libs\Controller;
  4. if (!defined('WY_ROOT')) {
  5. exit;
  6. }
  7. class rates extends CheckUser
  8. {
  9. public function index()
  10. {
  11. $userprice = $this->model()->select('a.id,a.uprice,a.is_state,b.name')->from('userprice a')->left('acc b')->on('a.channelid=b.id')->join()->where(array('fields' => 'userid=?', 'values' => array($_SESSION['login_userid'])))->fetchAll();
  12. $data = array('title' => '我的费率', 'userprice' => $userprice);
  13. $this->put('rates.php', $data);
  14. }
  15. public function edit()
  16. {
  17. $id = $this->req->post('id');
  18. if ($id) {
  19. if ($data = $this->model()->select('is_state')->from('userprice')->where(array('fields' => 'userid=? and id=?', 'values' => array($_SESSION['login_userid'], $id)))->fetchRow()) {
  20. $st = $data['is_state'] ? 0 : 1;
  21. if ($st == '1') {
  22. $this->model()->from('userprice')->updateSet(array('is_state' => $st))->where(array('fields' => 'userid=? and id=?', 'values' => array($_SESSION['login_userid'], $id)))->update();
  23. echo json_encode(array('status' => 1, 'st' => $st));
  24. exit;
  25. }
  26. }
  27. }
  28. echo json_encode(array('status' => 0));
  29. }
  30. }