del.wpy 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <style lang="less">
  2. .del {
  3. position: absolute;
  4. left: 0;
  5. top: 0;
  6. width: 100%;
  7. height: 100%;
  8. background: rgba(0, 0, 0, .3);
  9. view {
  10. position: fixed;
  11. left: 10%;
  12. width: 80%;
  13. height: 100rpx;
  14. background: #fff;
  15. border-radius: 20rpx;
  16. text-align: center;
  17. line-height: 100rpx;
  18. font-size: 36rpx;
  19. }
  20. .delete {
  21. bottom: 147rpx;
  22. }
  23. .cancel {
  24. bottom: 36rpx;
  25. }
  26. .btn-slect {
  27. color: #F86363;
  28. }
  29. }
  30. </style>
  31. <template>
  32. <view class="del" wx:if="{{syncFlag == 'true'}}">
  33. <view class="delete {{slectFlag ? 'btn-slect' : ''}}" @tap="del">删除</view>
  34. <view class="cancel {{slectFlag ? '' : 'btn-slect'}}" @tap="hide">取消</view>
  35. </view>
  36. </template>
  37. <script>
  38. import wepy from 'wepy'
  39. import { httpRequestApi } from '../util/httpRequestApi'
  40. export default class Del extends wepy.component {
  41. data = {
  42. slectFlag: false
  43. }
  44. props = {
  45. syncFlag: {
  46. type: String,
  47. default: 'null',
  48. twoWay: true
  49. },
  50. index: {
  51. type: Number,
  52. default: 'null'
  53. },
  54. fileList: {
  55. type: Array,
  56. default: 'null',
  57. twoWay: true
  58. }
  59. }
  60. methods = {
  61. del () {
  62. this.slectFlag = !this.slectFlag
  63. this.syncFlag = 'false'
  64. console.log(this.fileList)
  65. const taskJoinUser = this.fileList[this.index].taskJoinUser
  66. const id = taskJoinUser.id ? taskJoinUser.id : ''
  67. httpRequestApi.delFile(id, 'CLOSE').success(res => {
  68. console.log(res)
  69. this.fileList[this.index].taskJoinUser.fileStatus = 'CLOSE'
  70. this.$apply()
  71. wx.showToast({
  72. title: '成功',
  73. icon: 'success',
  74. duration: 2000
  75. })
  76. })
  77. this.$apply()
  78. },
  79. hide () {
  80. this.slectFlag = !this.slectFlag
  81. this.syncFlag = 'false'
  82. this.$apply()
  83. }
  84. }
  85. onLoad () {
  86. console.log(this.syncFlag)
  87. }
  88. }
  89. </script>