update-password.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. use yii\widgets\ActiveForm;
  3. use common\helpers\Url;
  4. $this->title = '修改密码';
  5. $this->params['breadcrumbs'][] = ['label' => $this->title];
  6. ?>
  7. <div class="row">
  8. <div class="col-lg-12">
  9. <div class="box">
  10. <div class="box-header with-border">
  11. <h3 class="box-title">基本信息</h3>
  12. </div>
  13. <?php $form = ActiveForm::begin([
  14. 'id' => 'pwd',
  15. 'fieldConfig' => [
  16. 'template' => "<div class='row'><div class='col-sm-2 text-right'>{label}</div><div class='col-sm-10'>{input}\n{hint}\n{error}</div></div>",
  17. ]
  18. ]); ?>
  19. <div class="box-body">
  20. <?= $form->field($model, 'passwd')->passwordInput() ?>
  21. <?= $form->field($model, 'passwd_new')->passwordInput() ?>
  22. <?= $form->field($model, 'passwd_repetition')->passwordInput() ?>
  23. </div>
  24. <div class="box-footer text-center">
  25. <button class="btn btn-primary" type="submit">保存</button>
  26. </div>
  27. <?php ActiveForm::end(); ?>
  28. </div>
  29. </div>
  30. </div>
  31. <script>
  32. var $form = $('#pwd');
  33. $form.on('beforeSubmit', function () {
  34. var data = $form.serialize();
  35. $.ajax({
  36. type: "post",
  37. url: "<?= Url::to(['update-password']); ?>",
  38. dataType: "json",
  39. data: data,
  40. success: function (data) {
  41. if (parseInt(data.code) === 200) {
  42. parent.location.reload();
  43. window.location.reload();
  44. } else {
  45. rfWarning(data.message);
  46. }
  47. }
  48. });
  49. return false; // 防止默认提交
  50. });
  51. </script>
粤ICP备19079148号