removeInfo.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="container">
  3. <view class="desc-box">
  4. 请您勾选需要删除的内容,删除后数据可能无法恢复,请您务必谨慎操作!
  5. </view>
  6. <view class="form-box">
  7. <u-checkbox-group @change="checkboxGroupChange" shape="circle" wrap>
  8. <u-checkbox
  9. v-model="item.checked"
  10. v-for="(item, index) in checkOption" :key="index"
  11. :name="item.name"
  12. >{{item.name}}</u-checkbox>
  13. </u-checkbox-group>
  14. </view>
  15. <view class="bottom-box">
  16. <u-button type="primary" shape="circle" @click="onSubmit" :disabled="isSelect">提交</u-button>
  17. </view>
  18. </view>
  19. </template>
  20. <script setup>
  21. import { ref, reactive, computed } from 'vue'
  22. import { onLoad, onReady } from '@dcloudio/uni-app'
  23. import { msgError, msgSuccess, showConfirm } from '@/utils/common'
  24. import { removeInfo } from '@/api/setting.js'
  25. const params = [
  26. {
  27. value: 1,
  28. name: '消息'
  29. },
  30. {
  31. value: 2,
  32. name: '浏览历史'
  33. },
  34. {
  35. value: 3,
  36. name: '收藏'
  37. },
  38. {
  39. value: 4,
  40. name: '评论'
  41. },
  42. {
  43. value: 5,
  44. name: '点赞'
  45. },
  46. {
  47. value: 6,
  48. name: '订单(关闭)'
  49. },
  50. ]
  51. const checkOption = ref([
  52. // {
  53. // name: '浏览记录',
  54. // checked: false,
  55. // disabled: false
  56. // },
  57. {
  58. name: '收藏',
  59. checked: false,
  60. disabled: false
  61. },
  62. {
  63. name: '评论',
  64. checked: false,
  65. disabled: false
  66. }
  67. ])
  68. const isSelect = computed(() => {
  69. return checkOption.value.filter(item => item.checked).length === 0
  70. })
  71. function checkboxGroupChange() {
  72. }
  73. function onSubmit() {
  74. showConfirm('是否确认删除').then(res => {
  75. if (res.confirm) {
  76. const selectOption = checkOption.value.filter(item => item.checked)
  77. const selectType = params.filter(item => selectOption.find(s => s.name === item.name)).map(item => item.value)
  78. const form = {
  79. type: `${selectType}`
  80. }
  81. removeInfo(form).then(res => {
  82. if (res && res.code === 0) {
  83. msgSuccess('操作成功')
  84. setTimeout(() => {
  85. uni.navigateBack()
  86. }, 500)
  87. } else {
  88. msgError('操作失败')
  89. }
  90. })
  91. }
  92. })
  93. }
  94. </script>
  95. <style lang="scss" scoped>
  96. .container {
  97. height: 100vh;
  98. width: 100vw;
  99. background-color: $uni-bg-color;
  100. padding: 20rpx;
  101. .desc-box {
  102. text-indent: 2em;
  103. line-height: 60rpx;
  104. padding: 20rpx 0;
  105. margin-bottom: 20rpx;
  106. }
  107. .form-box {
  108. padding: 20rpx 0;
  109. .input-code {
  110. display: flex;
  111. align-items: center;
  112. gap: 20rpx;
  113. .input {
  114. width: 70%;
  115. }
  116. .btn {
  117. width: 30%;
  118. text-align: center;
  119. }
  120. }
  121. }
  122. .bottom-box {
  123. margin-top: 50rpx;
  124. padding: 0 50rpx;
  125. }
  126. }
  127. </style>