exchangeShare.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <view>
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative;top: 40px;">
  5. <view style="position: fixed;z-index: 100;">
  6. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="交流圈">
  7. </uni-nav-bar>
  8. </view>
  9. <u-action-sheet :list="actionSheetList" v-model="post_show" @click="message"></u-action-sheet>
  10. <view class="invitations">
  11. <view class="invitations_item" v-for="(items,index) in invitation" :key="index" @click="particulars(items)">
  12. <view class="invitations_item_left">
  13. <image :src="items.img_urls" mode="" v-if="items.img_urls!='' && items.img_urls!=null"></image>
  14. <image :src="$imageURL+'/projectimg'+defaultimg" mode="" v-else></image>
  15. </view>
  16. <view class="invitations_item_right">
  17. <view class="invitations_item_right_top">
  18. <image :src="$imageURL+'/bigdata_app'+'/image/expertDiagnosis/6940a11a251770f1b0d8b7b10ebdf9b.png'" mode="" v-if="Number(items.heat) == 1"></image>
  19. <span>{{items.title}}</span>
  20. </view>
  21. <view class="invitations_item_right_contert" v-html="items.content">
  22. </view>
  23. <view class="invitations_item_right_bot">
  24. <image :src="$imageURL+'/bigdata_app'+'/image/expertDiagnosis/d2014837228702eeceb762bc5302b3f.png'" mode=""></image>
  25. <span>{{items.username}}</span>
  26. <p>查看详情</p>
  27. </view>
  28. <view class="delinvit" v-if="myTF" @click.stop="delinvit(items.lower)">
  29. 删除
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view class="addindent" @click="postmessage">
  36. 发 帖
  37. </view>
  38. <view class="top" v-if="isTop" @click="top">
  39. <image :src="$imageURL+'/bigdata_app'+'/image/6209a98f0cb3b5086f2ca36152c9269.png'" mode=""></image>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. // pest.pests.pests_heat_rank
  48. invitation: [],
  49. actionSheetList: [{
  50. text: "我的发帖"
  51. }, {
  52. text: "我要发帖"
  53. }],
  54. post_show: false,
  55. defaultimg: '/images/expertDiagnosis/img01.png',
  56. page:1,
  57. myTF:false ,//判断是全部发帖还是我的发帖
  58. isTop:false
  59. }
  60. },
  61. methods: {
  62. async getInvitation(str) { //获取全部发帖 自己发帖"my"
  63. const res = await this.$myRequest({
  64. url: '/api/api_gateway?method=pest.pests.pests_answers_list',
  65. data: {
  66. screen:str,
  67. page:this.page,
  68. page_size:10
  69. }
  70. })
  71. this.invitation = this.invitation.concat(res.data)
  72. for (var i = 0; i < this.invitation.length; i++) {
  73. var index1 = this.invitation[i].content.indexOf("/>") + 2
  74. var index2 = this.invitation[i].content.indexOf('<img')
  75. var str = this.invitation[i].content.slice(index2, index1)
  76. this.invitation[i].content = this.invitation[i].content.replace(str, '')
  77. }
  78. console.log(this.invitation)
  79. },
  80. //pest.pests.del_pests_card删除帖子
  81. async delInvitation(data) { //获取全部发帖 自己发帖"my"
  82. const res = await this.$myRequest({
  83. url: '/api/api_gateway?method=pest.pests.del_pests_card',
  84. data: {
  85. lower:data,
  86. card:1
  87. }
  88. })
  89. if(res.code==200){
  90. this.$forceUpdate()
  91. }
  92. },
  93. clickLeft() {
  94. uni.navigateTo({
  95. url: './index'
  96. })
  97. },
  98. particulars(items) { //详情页
  99. uni.navigateTo({
  100. url: "particulars?items=" + items.id
  101. })
  102. },
  103. postmessage() { //发帖
  104. this.post_show = true
  105. },
  106. message(index) {
  107. if (this.actionSheetList[index].text.includes("我要发帖")) {
  108. uni.navigateTo({
  109. url: "./postmessage"
  110. })
  111. } else if (this.actionSheetList[index].text.includes("我的发帖")) {
  112. this.actionSheetList[index].text = "全部发帖"
  113. this.page = 1
  114. let str = "my"
  115. this.invitation = []
  116. this.getInvitation(str)
  117. this.myTF = true
  118. } else if (this.actionSheetList[index].text.includes("全部发帖")) {
  119. this.page = 1
  120. let str = ""
  121. this.invitation = []
  122. this.getInvitation(str)
  123. this.myTF = false
  124. }
  125. },
  126. delinvit(items){
  127. uni.showModal({
  128. title: '提示',
  129. content: '是否删除该帖子?',
  130. success: (res)=> {
  131. if (res.confirm) {
  132. this.delInvitation(items)
  133. this.page = 1
  134. let str = "my"
  135. this.invitation = []
  136. this.getInvitation(str)
  137. } else if (res.cancel) {
  138. console.log('用户点击取消');
  139. }
  140. }
  141. });
  142. },
  143. top() {
  144. uni.pageScrollTo({
  145. scrollTop: 0,
  146. duration: 500
  147. })
  148. }
  149. },
  150. onLoad() {
  151. let str = ""
  152. this.getInvitation(str)
  153. },
  154. onReachBottom(){
  155. this.page ++
  156. if(this.myTF){
  157. let str = "my"
  158. this.getInvitation(str)
  159. }else{
  160. let str = ""
  161. this.getInvitation(str)
  162. }
  163. },
  164. onBackPress(options) {
  165. if (options.from === 'navigateBack') {
  166. return false;
  167. }
  168. this.clickLeft();
  169. return true;
  170. },
  171. onPageScroll(e) { //nvue暂不支持滚动监听,可用bindingx代替
  172. if (e.scrollTop > 200) { //距离大于200时显示
  173. this.isTop = true
  174. } else { //距离小于200时隐藏
  175. this.isTop = false
  176. }
  177. },
  178. }
  179. </script>
  180. <style lang="scss">
  181. .right_icon {
  182. width: 40rpx;
  183. height: 40rpx;
  184. position: absolute;
  185. top: 26rpx;
  186. right: 26rpx;
  187. }
  188. .invitations {
  189. width: 100%;
  190. position: relative;
  191. top: 88rpx;
  192. margin-bottom: 50px;
  193. .invitations_item {
  194. width: 90%;
  195. margin: 0 auto;
  196. display: flex;
  197. justify-content: space-between;
  198. padding: 30rpx 0;
  199. .invitations_item_left {
  200. width: 26%;
  201. image {
  202. width: 100%;
  203. height: 180rpx;
  204. }
  205. }
  206. .invitations_item_right {
  207. width: 71%;
  208. position: relative;
  209. .invitations_item_right_top {
  210. width: 100%;
  211. image {
  212. width: 32rpx;
  213. height: 32rpx;
  214. margin: 0 16rpx 0 0;
  215. vertical-align: text-bottom;
  216. }
  217. span {
  218. font-weight: 700;
  219. }
  220. }
  221. .delinvit{
  222. position: absolute;
  223. right: 0;
  224. top: 0;
  225. color: #ff0000;
  226. }
  227. .invitations_item_right_contert {
  228. width: 100%;
  229. margin: 10rpx 0;
  230. overflow: hidden;
  231. -webkit-line-clamp: 2;
  232. text-overflow: ellipsis;
  233. display: -webkit-box;
  234. -webkit-box-orient: vertical;
  235. }
  236. .invitations_item_right_bot {
  237. display: flex;
  238. position: absolute;
  239. bottom: 12rpx;
  240. height: 50rpx;
  241. width: 100%;
  242. image {
  243. width: 50rpx;
  244. height: 50rpx;
  245. position: absolute;
  246. }
  247. span {
  248. color: #B9B9B9;
  249. margin-left: 74rpx;
  250. line-height: 50rpx;
  251. }
  252. p {
  253. width: 100rpx;
  254. height: 40rpx;
  255. font-size: 24rpx;
  256. border: 2rpx solid #5FAE50;
  257. line-height: 40rpx;
  258. padding: 0 10rpx;
  259. position: absolute;
  260. right: 0;
  261. top: 6rpx;
  262. color: #5FAE50;
  263. }
  264. }
  265. }
  266. }
  267. }
  268. .addindent{
  269. width: 100%;
  270. position: fixed;
  271. bottom: 0;
  272. left: 0;
  273. height: 80rpx;
  274. text-align: center;
  275. line-height: 80rpx;
  276. background-color: #71cd9a;
  277. color: #ffffff;
  278. font-size: 16px;
  279. z-index: 100;
  280. }
  281. .top {
  282. position: fixed;
  283. right: 30px;
  284. bottom: 100px;
  285. z-index: 100;
  286. image{
  287. width: 100rpx;
  288. height: 100rpx;
  289. }
  290. }
  291. </style>