topic.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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">
  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. };
  42. },
  43. onLoad() {
  44. this.getListTopic();
  45. },
  46. onReachBottom() {
  47. this.form.page++;
  48. this.getListTopic();
  49. },
  50. methods: {
  51. // 监听获取话题输入
  52. inputTopicText(e) {
  53. this.isLoad = true;
  54. this.form.page = 1;
  55. this.getListTopic();
  56. },
  57. selectedBack(obj) {
  58. let pages = getCurrentPages(); //获取所有页面栈实例列表
  59. let prevPage = pages[pages.length - 2]; //上一页页面实例
  60. prevPage.$vm.htObj = obj; //修改上一页data里面的searchVal参数值为1211
  61. uni.navigateBack({
  62. //uni.navigateTo跳转的返回,默认1为返回上一级
  63. delta: 1
  64. });
  65. },
  66. getListTopic() {
  67. if (!this.isLoad) return false;
  68. this.isLoad = false;
  69. let that = this;
  70. if (this.cTitle) {
  71. this.form.dialogue = this.cTitle;
  72. } else {
  73. this.form.dialogue = '';
  74. }
  75. this.form.poiLongitude = req.getStorage('loctionAddressMap').location.lng;
  76. this.form.poiLatitude = req.getStorage('loctionAddressMap').location.lat;
  77. // this.form.orderType=1;
  78. // '/api/v3/dialogue/list'
  79. req.getRequest(api.get_nearby_dialogue, this.form, data => {
  80. if (data && data.length >= this.form.limit) {
  81. this.isLoad = true;
  82. }
  83. if (that.form.page > 1) {
  84. data = that.topicList.concat(data);
  85. }
  86. that.topicList = data;
  87. });
  88. },
  89. getSaveTopic() {
  90. var dataP = {
  91. title: this.cTitle
  92. };
  93. req.postRequest('/api/v3/dialogue/save', dataP, data => {
  94. this.selectedBack(data);
  95. });
  96. }
  97. }
  98. };
  99. </script>
  100. <style>
  101. @import './topic.css';
  102. </style>