article.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  1. <template>
  2. <view class="page">
  3. <view class="header">
  4. <view class="left">
  5. <image class="img" mode="aspectFill" src="../../static/article/name.png"></image>
  6. </view>
  7. <view class="right">
  8. <view class="btn" @click="goFabu">发动态</view>
  9. </view>
  10. </view>
  11. <view class="list_info">
  12. <block v-for="(item,index) in list" :key="index">
  13. <view class="item">
  14. <view class="avator" @click="goHome(item.userID)">
  15. <image class="icon" :src="item.avator" mode="aspectFill">
  16. </image>
  17. </view>
  18. <view class="tit">
  19. <view class="list1">
  20. <view class="name">
  21. {{item.nickname}}
  22. </view>
  23. <view class="sex2" v-if="item.sex == 2">
  24. <image class="icon" src="../../static/icon/woman.png" mode="aspectFill">
  25. </image>
  26. {{item.age}}
  27. </view>
  28. <view class="sex1" v-else>
  29. <image class="icon" src="../../static/icon/man.png" mode="aspectFill">
  30. </image>
  31. {{item.age}}
  32. </view>
  33. <view class="xinzuo" v-if="item.xinzuo != ''">{{item.xinzuo}}</view>
  34. </view>
  35. <view class="time">{{item.dtime}}</view>
  36. </view>
  37. <view class="state">
  38. </view>
  39. </view>
  40. <view class="content">
  41. {{item.content}}
  42. </view>
  43. <view class="photo_list">
  44. <view class="img" v-for="(item2,index2) in toArr(item.images)" :key="index2"
  45. @click="previewOpen(item.images,index2)" v-if="item2 != ''">
  46. <!-- <image class="icon" :src="item2" mode="aspectFill"></image> -->
  47. <image-cache class="icon" mode="aspectFill" :src="item2"></image-cache>
  48. </view>
  49. </view>
  50. <view class="desc">
  51. <view class="addr">{{item.city}}</view>
  52. <view class="img" @click="ZhanTA(item,index)" v-if="item.is_like < 1">
  53. <image class="icon" src="../../static/icon/zan.png" mode="aspectFill"></image>
  54. {{item.num_like}}
  55. </view>
  56. <view class="img" v-else>
  57. <image class="icon" src="../../static/icon/like.png" mode="aspectFill"></image>
  58. {{item.num_like}}
  59. </view>
  60. <view class="img" v-if="false">
  61. <image class="icon" src="../../static/icon/reply.png" mode="aspectFill"></image>
  62. {{item.num_comment}}
  63. </view>
  64. </view>
  65. <view class="line"></view>
  66. </block>
  67. <view class="blankHeight"></view>
  68. </view>
  69. <!-- <view class="no-content">
  70. <image class="icon" mode="widthFix" src="../../static/home/no.png"></image>
  71. <text>暂无数据</text>
  72. </view> -->
  73. <!-- 提示框 -->
  74. <DialogBox ref="DialogBox"></DialogBox>
  75. <previewImage ref="previewImage" :opacity="0.8" :circular="true" :imgs="imgs" :descs="descs"></previewImage>
  76. </view>
  77. </template>
  78. <script>
  79. import previewImage from '@/components/kxj-previewImage/kxj-previewImage.vue'; //引用插件
  80. export default {
  81. components: {
  82. previewImage
  83. },
  84. data() {
  85. return {
  86. page: 1,
  87. list: [],
  88. imgs: [],
  89. descs: []
  90. }
  91. },
  92. onLoad() {
  93. },
  94. onShow() {
  95. this.page = 1;
  96. this.loadData();
  97. },
  98. methods: {
  99. onBack() {},
  100. goFabu() {
  101. uni.navigateTo({
  102. url: '/pages/article/addArticle'
  103. })
  104. },
  105. goHome(userID) {
  106. uni.navigateTo({
  107. url: '/pages/index/peopleHome?uid=' + userID
  108. })
  109. },
  110. toArr(imgs) {
  111. let arr = imgs.split("|");
  112. return arr;
  113. },
  114. //打开预览e
  115. previewOpen(imgs1, index) {
  116. this.imgs = imgs1.split("|");
  117. setTimeout(() => this.$refs.previewImage.open(index), 0)
  118. return; //如需测试和uni原生预览差别可注释这两行
  119. },
  120. loadData() {
  121. var offset = (this.page - 1) * 20;
  122. uni.request({
  123. url: this.$apiHost + '/Article/getlist',
  124. data: {
  125. uuid: getApp().globalData.uuid,
  126. offset: offset,
  127. ismy: 0
  128. },
  129. header: {
  130. "content-type": "application/json",
  131. 'sign': getApp().globalData.headerSign
  132. },
  133. success: (res) => {
  134. console.log('请求了qqqqqqqqq');
  135. if (res.data.list == undefined || res.data.list == null) {
  136. res.data.list = []
  137. }
  138. if (this.page > 1) {
  139. this.list = this.list.concat(res.data.list)
  140. } else {
  141. this.list = res.data.list;
  142. }
  143. },
  144. complete: (com) => {
  145. // uni.hideLoading();
  146. },
  147. fail: (e) => {
  148. console.log("----e:", e);
  149. }
  150. });
  151. },
  152. ZhanTA(item, index) {
  153. // this.list[index].is_like = 1;
  154. // this.list[index].num_like++;
  155. // return;
  156. let that = this;
  157. uni.request({
  158. url: this.$apiHost + '/Article/zanTA',
  159. data: {
  160. uuid: getApp().globalData.uuid,
  161. id: item.id
  162. },
  163. header: {
  164. "content-type": "application/json",
  165. 'sign': getApp().globalData.headerSign
  166. },
  167. success: (res) => {
  168. console.log("----:", res.data);
  169. if (res.data.success == "yes") {
  170. that.list[index].is_like = 1;
  171. that.list[index].num_like++;
  172. }
  173. },
  174. complete: (com) => {
  175. // uni.hideLoading();
  176. },
  177. fail: (e) => {
  178. console.log("----e:", e);
  179. }
  180. });
  181. }
  182. },
  183. //滚动到底部
  184. onReachBottom() {
  185. console.log("onReachBottom");
  186. if (this.list.length > 0) {
  187. this.page++;
  188. this.loadData()
  189. }
  190. },
  191. //下拉刷新
  192. onPullDownRefresh() {
  193. console.log("onPullDownRefresh")
  194. this.list = []
  195. this.page = 1
  196. // console.log(this.lx)
  197. this.loadData()
  198. // setTimeout(() => {
  199. // uni.stopPullDownRefresh()
  200. // },1000)
  201. },
  202. }
  203. </script>
  204. <style scoped lang="scss">
  205. @import 'article.scss';
  206. </style>