more.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="app">
  3. <uni-nav-bar statusBar backgroundColor="#fff" fixed title="更多操作" left-icon="left" @clickLeft="utils.navigateBack()"/>
  4. <view class="btn" @tap="tapBlack" v-if="is_black == 0">加入黑名单</view>
  5. <view class="btn" @tap="tapBlackRmove" v-else>移除黑名单</view>
  6. <view class="btn color" @tap="tapDelete">删除好友</view>
  7. </view>
  8. </template>
  9. <style lang="scss">
  10. .btn{background: #fff;padding: 10px;text-align: center;font-size: 16px;margin-top: 10px;color: $ic-default-text;}
  11. .btn.color{color: red;font-weight: bold;}
  12. </style>
  13. <script>
  14. import {mapState,mapMutations } from 'vuex';
  15. export default {
  16. data() {
  17. return {
  18. usercode : "",
  19. is_black:0
  20. }
  21. },
  22. onLoad(option){
  23. this.usercode = option.usercode || "";
  24. this.is_black = option.is_black || 0;
  25. },
  26. methods: {
  27. tapBlack:function(){
  28. this.utils.showModal("加入黑名单,你将不会再收到对方的消息?",()=>{
  29. uni.showLoading({ title: '提交中..'});
  30. this
  31. .request
  32. .post("setBlack",{usercode:this.usercode,type:'black'})
  33. .then(res => {
  34. uni.hideLoading();
  35. if(res.code == 200) {
  36. this.utils.Tip("操作成功");
  37. uni.navigateBack();
  38. } else {
  39. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  40. }
  41. })
  42. .catch(res=>{
  43. console.log(res);
  44. uni.hideLoading();
  45. uni.showModal({title: '系统提示',content: '加载失败,重新点击尝试!',showCancel: false});
  46. });
  47. });
  48. },
  49. /**
  50. * 移除黑名单
  51. */
  52. tapBlackRmove:function(){
  53. uni.showLoading({ title: '提交中..'});
  54. this
  55. .request
  56. .post("setBlack",{usercode:this.usercode,type:'remove'})
  57. .then(res => {
  58. uni.hideLoading();
  59. if(res.code == 200) {
  60. this.utils.Tip("操作成功");
  61. uni.navigateBack();
  62. } else {
  63. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  64. }
  65. })
  66. .catch(res=>{
  67. console.log(res);
  68. uni.hideLoading();
  69. uni.showModal({title: '系统提示',content: '加载失败,重新点击尝试!',showCancel: false});
  70. });
  71. },
  72. /**
  73. * 删除好友
  74. */
  75. tapDelete:function(){
  76. this.utils.showModal("你确定要删除好友?",()=>{
  77. uni.showLoading({ title: '提交中..'});
  78. this
  79. .request
  80. .post("FriendDel",{usercode:this.usercode})
  81. .then(res => {
  82. uni.hideLoading();
  83. if(res.code == 200) {
  84. this.utils.Tip("操作成功");
  85. uni.navigateBack();
  86. } else {
  87. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  88. }
  89. })
  90. .catch(res=>{
  91. console.log(res);
  92. uni.hideLoading();
  93. uni.showModal({title: '系统提示',content: '加载失败,重新点击尝试!',showCancel: false});
  94. });
  95. });
  96. }
  97. }
  98. }
  99. </script>