topic.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view class="con">
  3. <view class="search ddflex">
  4. <image src="../../static/images/ssico.png" class="ssico"></image>
  5. <input v-model="cTitle" placeholder="自定义话题" @input="inputTopicText" placeholder-class="placeholder" class="ipt fflex" />
  6. <!-- <view class="clear">取消</view> -->
  7. </view>
  8. <view class="new" v-if="cTitle && havePermissionTopic">
  9. <view class="tip">没有找到想要参与的话题?</view>
  10. <view class="create" @click="getSaveTopic()">
  11. 创建新话题:
  12. <text>{{ cTitle }}</text>
  13. </view>
  14. </view>
  15. <view class="list">
  16. <view class="li ddflex" @click="selectedBack('')">
  17. <image src="../static/images/ht_no.png"></image>
  18. <view class="fflex tover">不参与任何话题</view>
  19. </view>
  20. <view class="li ddflex" v-for="(item, index) in topicList" :key="index" @click="selectedBack(item)">
  21. <image src="../static/images/ht_ico.png"></image>
  22. <view class="fflex tover">{{ item.title }}</view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. const app = getApp();
  29. const api = require('../../utils/api.js');
  30. const req = require('../../utils/request.js');
  31. export default {
  32. data() {
  33. return {
  34. isLoad: true,
  35. form: {
  36. // page: 1,
  37. // limit: 10
  38. },
  39. topicList: [],
  40. cTitle: '', //输入的话题关键词
  41. havePermissionTopic:false,//是否有创建话题的权限
  42. };
  43. },
  44. onLoad() {
  45. this.getListTopic();
  46. this.getUserPermission()
  47. },
  48. onReachBottom() {
  49. this.form.page++;
  50. this.getListTopic();
  51. },
  52. methods: {
  53. getUserPermission(){
  54. req.getRequest('/api/user/getUserPermission',{},res=>{
  55. if(res){
  56. this.havePermissionTopic = res.map(item=>item.permissions).indexOf('sys:topic')>-1?true:false
  57. }
  58. })
  59. },
  60. // 监听获取话题输入
  61. inputTopicText(e) {
  62. this.isLoad = true;
  63. this.form.page = 1;
  64. this.getListTopic();
  65. },
  66. selectedBack(obj) {
  67. let pages = getCurrentPages(); //获取所有页面栈实例列表
  68. let prevPage = pages[pages.length - 2]; //上一页页面实例
  69. prevPage.$vm.htObj = obj; //修改上一页data里面的searchVal参数值为1211
  70. uni.navigateBack({
  71. //uni.navigateTo跳转的返回,默认1为返回上一级
  72. delta: 1
  73. });
  74. },
  75. getListTopic() {
  76. if (!this.isLoad) return false;
  77. this.isLoad = false;
  78. let that = this;
  79. if (this.cTitle) {
  80. this.form.dialogue = this.cTitle;
  81. } else {
  82. this.form.dialogue = '';
  83. }
  84. this.form.poiLongitude = req.getStorage('loctionAddressMap').location.lng;
  85. this.form.poiLatitude = req.getStorage('loctionAddressMap').location.lat;
  86. // this.form.orderType=1;
  87. // '/api/v3/dialogue/list'
  88. req.getRequest('/api/v3/dialogue/list', this.form, data => {
  89. if (data && data.length >= this.form.limit) {
  90. this.isLoad = true;
  91. }
  92. if (that.form.page > 1) {
  93. data = that.topicList.concat(data);
  94. }
  95. that.topicList = data;
  96. });
  97. },
  98. getSaveTopic() {
  99. var dataP = {
  100. title: this.cTitle
  101. };
  102. req.postRequest('/api/v3/dialogue/save', dataP, data => {
  103. this.selectedBack(data);
  104. });
  105. }
  106. }
  107. };
  108. </script>
  109. <style>
  110. @import './topic.css';
  111. </style>