Memberbank.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. namespace app\home\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  10. * 网站地址: https://www.valimart.net/
  11. * ----------------------------------------------------------------------------
  12. *
  13. * ============================================================================
  14. * 控制器
  15. */
  16. class Memberbank extends BaseMember {
  17. public function initialize() {
  18. parent::initialize();
  19. Lang::load(base_path() . 'home/lang/'.config('lang.default_lang').'/memberbank.lang.php');
  20. }
  21. public function index() {
  22. $memberbank_model=model('memberbank');
  23. $memberbank_list = $memberbank_model->getMemberbankList(array('member_id'=>session('member_id')));
  24. View::assign('memberbank_list', $memberbank_list);
  25. /* 设置买家当前菜单 */
  26. $this->setMemberCurMenu('member_bank');
  27. /* 设置买家当前栏目 */
  28. $this->setMemberCurItem('memberbank_index');
  29. return View::fetch($this->template_dir . 'index');
  30. }
  31. public function add() {
  32. if (!request()->isPost()) {
  33. $memberbank = array(
  34. 'memberbank_type' => 'bank',
  35. );
  36. View::assign('memberbank', $memberbank);
  37. /* 设置买家当前菜单 */
  38. $this->setMemberCurMenu('member_bank');
  39. /* 设置买家当前栏目 */
  40. $this->setMemberCurItem('memberbank_add');
  41. return View::fetch($this->template_dir . 'form');
  42. } else {
  43. $data = array(
  44. 'member_id' => session('member_id'),
  45. 'memberbank_type' => input('post.memberbank_type'),
  46. 'memberbank_truename' => input('post.memberbank_truename'),
  47. 'memberbank_name' => input('post.memberbank_name'),
  48. 'memberbank_no' => input('post.memberbank_no'),
  49. );
  50. $memberbank_validate = ds_validate('memberbank');
  51. if (!$memberbank_validate->scene('add')->check($data)) {
  52. ds_json_encode(10001,$memberbank_validate->getError());
  53. }
  54. $memberbank_model=model('memberbank');
  55. $result = $memberbank_model->addMemberbank($data);
  56. if ($result) {
  57. ds_json_encode(10000,lang('ds_common_save_succ'));
  58. } else {
  59. ds_json_encode(10001,lang('ds_common_save_fail'));
  60. }
  61. }
  62. }
  63. public function edit() {
  64. $memberbank_id = intval(input('param.memberbank_id'));
  65. if (0 >= $memberbank_id) {
  66. ds_json_encode(10001,lang('param_error'));
  67. }
  68. $memberbank_model=model('memberbank');
  69. $memberbank = $memberbank_model->getMemberbankInfo(array('member_id' => session('member_id'), 'memberbank_id' => $memberbank_id));
  70. if (empty($memberbank)) {
  71. ds_json_encode(10001,lang('memberbank_does_not_exist'));
  72. }
  73. if (!request()->isPost()) {
  74. View::assign('memberbank', $memberbank);
  75. /* 设置买家当前菜单 */
  76. $this->setMemberCurMenu('member_bank');
  77. /* 设置买家当前栏目 */
  78. $this->setMemberCurItem('memberbank_edit');
  79. return View::fetch($this->template_dir . 'form');
  80. } else {
  81. $data = array(
  82. 'memberbank_type' => input('post.memberbank_type'),
  83. 'memberbank_truename' => input('post.memberbank_truename'),
  84. 'memberbank_name' => input('post.memberbank_name'),
  85. 'memberbank_no' => input('post.memberbank_no'),
  86. );
  87. $memberbank_validate = ds_validate('memberbank');
  88. if (!$memberbank_validate->scene('edit')->check($data)) {
  89. ds_json_encode(10001,$memberbank_validate->getError());
  90. }
  91. $result = $memberbank_model->editMemberbank($data,array('member_id' => session('member_id'), 'memberbank_id' => $memberbank_id));
  92. if ($result) {
  93. ds_json_encode(10000,lang('ds_common_save_succ'));
  94. } else {
  95. ds_json_encode(10001,lang('ds_common_save_fail'));
  96. }
  97. }
  98. }
  99. public function drop() {
  100. $memberbank_id = intval(input('param.memberbank_id'));
  101. if (0 >= $memberbank_id) {
  102. ds_json_encode(10001,lang('empty_error'));
  103. }
  104. $memberbank_model=model('memberbank');
  105. $condition = array();
  106. $condition[] = array('memberbank_id','=',$memberbank_id);
  107. $condition[] = array('member_id','=',session('member_id'));
  108. $result = $memberbank_model->delMemberbank($condition);
  109. if ($result) {
  110. ds_json_encode(10000,lang('ds_common_del_succ'));
  111. } else {
  112. ds_json_encode(10001,lang('ds_common_del_fail'));
  113. }
  114. }
  115. /**
  116. * 栏目菜单
  117. */
  118. function getMemberItemList() {
  119. $item_list = array(
  120. array(
  121. 'name' => 'memberbank_index',
  122. 'text' => lang('memberbank_index'),
  123. 'url' => (string)url('Memberbank/index'),
  124. ),
  125. array(
  126. 'name' => 'memberbank_add',
  127. 'text' => lang('memberbank_add'),
  128. 'url' => (string)url('Memberbank/add'),
  129. ),
  130. );
  131. if (request()->action() == 'edit') {
  132. $item_list[] = array(
  133. 'name' => 'memberbank_edit',
  134. 'text' => lang('memberbank_edit'),
  135. 'url' => "javascript:void(0)",
  136. );
  137. }
  138. return $item_list;
  139. }
  140. }