Default.cshtml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. @using VberZero
  2. @model VberZero.AppService.Notifications.Dto.NotificationSettingsDto
  3. <div class="menu-item px-5" data-kt-menu-trigger="hover" data-kt-menu-placement="left-start" data-kt-menu-flip="bottom, top">
  4. <a href="#" class="menu-link px-5">
  5. <span class="menu-title">
  6. <span class="fas fa-envelope-open-text pe-2"></span>
  7. 我的订阅
  8. </span>
  9. <span class="menu-arrow"></span>
  10. </a>
  11. <div class="menu-sub menu-sub-dropdown w-175px py-4">
  12. @if (Model?.Notifications.Count > 0)
  13. {
  14. foreach (var notification in Model.Notifications)
  15. {
  16. var isCheck = notification.IsSubscribed ? "checked=\"checked\"" : "";
  17. <div class="menu-content px-3">
  18. <label class="form-check form-switch form-check-custom form-check-solid">
  19. <input class="form-check-input w-30px h-20px" type="checkbox" value="" name="@(notification.Name)" @(isCheck) onchange="UpdateNotificationSetting(this)"/>
  20. <span class="form-check-label text-muted fs-7">@(notification.DisplayName)</span>
  21. </label>
  22. </div>
  23. }
  24. }
  25. @{
  26. var isReceive = Model is {ReceiveNotifications: true } ? "checked=\"checked\"" : "";
  27. }
  28. <div class="separator my-2"></div>
  29. <div class="menu-item px-3">
  30. <div class="menu-content px-3">
  31. <label class="form-check form-switch form-check-custom form-check-solid">
  32. <input class="form-check-input w-30px h-20px" name="receiveNotifications" type="checkbox" @(isReceive) onchange="UpdateNotificationSetting(this)"/>
  33. <span class="form-check-label text-muted fs-7">订阅通知</span>
  34. </label>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. <script>
  40. function UpdateNotificationSetting(that) {
  41. let $this = $(that), name = $this.attr("name"), isCheck = $this.is(":checked");
  42. console.log(name, isCheck);
  43. abp.ajax({
  44. url: '@(VzConsts.ApiAppUrl)Notification/UpdateNotificationSetting',
  45. data: JSON.stringify({
  46. name: name,
  47. isSubscribed: isCheck
  48. }),
  49. success:() => {
  50. abp.notify.success("更改成功!");
  51. },
  52. error:() => {
  53. $this.prop("checked", !isCheck);
  54. }
  55. }); }
  56. </script>