exchangeShare.vue 6.9 KB

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