details.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. <template>
  2. <view style="width: 100%;">
  3. <tui-modal :show="editname" @cancel="hide1" :custom="true" fadeIn >
  4. <view class="tui-modal-custom">
  5. <input placeholder="请输入内容" class="tui-modal-input"/>
  6. <tui-button height="72rpx" :size="28" shape="circle" @click="handleClick1">保存</tui-button>
  7. </view>
  8. </tui-modal>
  9. <tui-modal :show="editbirthday" @cancel="hide2" :custom="true" fadeIn >
  10. <view class="tui-modal-custom">
  11. <input placeholder="日期" class="tui-modal-input"/>
  12. <tui-button height="72rpx" :size="28" shape="circle" @click="handleClick2">保存</tui-button>
  13. </view>
  14. </tui-modal>
  15. <tui-modal :show="edithobby" @cancel="hide3" :custom="true" fadeIn >
  16. <view class="tui-modal-custom">
  17. <input placeholder="爱好" class="tui-modal-input"/>
  18. <tui-button height="72rpx" :size="28" shape="circle" @click="handleClick3">保存</tui-button>
  19. </view>
  20. </tui-modal>
  21. <view v-if="" class="hello">
  22. <view id="moments">
  23. <view class="home-pic">
  24. <view class="home-pic-base">
  25. <view class="top-pic" @tap="personal">
  26. <image class="header" src="@/static/index/test/header06.jpg"></image>
  27. </view>
  28. <view class="top-name">{{userName}}</view>
  29. <view class="top-id">ID号:3867676552</view>
  30. </view>
  31. </view>
  32. <view style="margin-top: 30px;">
  33. <tui-tabs :tabs="navbar" backgroundColor="#fafafa" :height="88" :currentTab="currentTab>1?0:currentTab"
  34. :sliderWidth="75" :sliderHeight="60" bottom="50%" color="#888" selectedColor="#C74547" :bold="true"
  35. sliderBgColor="#C74547" @change="change" itemWidth="50%" :width="100" unlined></tui-tabs>
  36. </view>
  37. <view v-if="currentTab==0" style="padding: 30rpx 30rpx;" :key="index" :id="'post-'+index">
  38. <view class="tui-flex" style="width: 100%;height:128rpx;margin-bottom:30rpx;">
  39. <view class="tui-col-2" style="font-size: 40rpx;display: table-cell;">01<text style="font-size: 28rpx;">8月</text></view>
  40. <view class="tui-col-2">
  41. <image style="width: 100%;height: 100%;" src="@/static/images/basic/grid.png"></image>
  42. </view>
  43. <view class=" tui-col-8" style="margin-left: 20rpx;overflow: hidden;font-size: 28rpx;padding: 10rpx 0;">奥术大师奥术大师奥术大师奥术大师奥术大师奥术大师奥术大师奥术大师奥术大师奥术大师奥术大师奥术大师</view>
  44. </view>
  45. </view>
  46. <view v-if="currentTab==1" style="padding: 30rpx 30rpx;" :key="index" :id="'post-'+index">
  47. <view style="margin: 10rpx 0;">
  48. <view class="tui-title">
  49. <view>姓名<tui-icon name="edit" :size="22" style="margin-left: 6rpx;" @click="name"></tui-icon></view>
  50. </view>
  51. <view class="tui-default" style="background: #fff;font-size: 24rpx;">
  52. <view class="contenfont">
  53. <view class="container" v-for="(item,index11) in textfont" :key="index11" :class="fold ? 'fold' : 'unfold'" v-if="item.font !==''" >
  54. <label>
  55. <span>{{item.font}}</span>
  56. </label>
  57. </view>
  58. <view style="width: 100%;text-align: center;">
  59. <view class="show" @click="btn" v-show="fold"><tui-icon name="arrowdown"></tui-icon></view>
  60. <view class="show" @click="btn" v-show="!fold"><tui-icon name="arrowup"></tui-icon></view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. <view style="margin: 10rpx 0;">
  66. <view class="tui-title">
  67. <view>生日<tui-icon name="edit" :size="22" style="margin-left: 6rpx;" @click="birthday"></tui-icon></view>
  68. </view>
  69. <view class="tui-default" style="background: #fff;font-size: 24rpx;">
  70. <view class="contenfont">
  71. <view class="container" v-for="(item,index11) in textfont" :key="index11" :class="fold ? 'fold' : 'unfold'" v-if="item.font !==''" >
  72. <label>
  73. <span>{{item.font}}</span>
  74. </label>
  75. </view>
  76. <view style="width: 100%;text-align: center;">
  77. <view class="show" @click="btn" v-show="fold"><tui-icon name="arrowdown"></tui-icon></view>
  78. <view class="show" @click="btn" v-show="!fold"><tui-icon name="arrowup"></tui-icon></view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. <view style="margin: 10rpx 0;">
  84. <view class="tui-title">
  85. <view>喜好<tui-icon name="edit" :size="22" style="margin-left: 6rpx;" @click="hobby"></tui-icon></view>
  86. </view>
  87. <view class="tui-default" style="background: #fff;font-size: 24rpx;">
  88. <view class="contenfont">
  89. <view class="container" v-for="(item,index11) in textfont" :key="index11" :class="fold ? 'fold' : 'unfold'" v-if="item.font !==''" >
  90. <label>
  91. <span>{{item.font}}</span>
  92. </label>
  93. </view>
  94. <view style="width: 100%;text-align: center;">
  95. <view class="show" @click="btn" v-show="fold"><tui-icon name="arrowdown"></tui-icon></view>
  96. <view class="show" @click="btn" v-show="!fold"><tui-icon name="arrowup"></tui-icon></view>
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. <view class="foot" v-show="showInput">
  103. <chat-input @send-message="send_comment" @blur="blur" :focus="focus" :placeholder="input_placeholder"></chat-input>
  104. <!-- <chat-input @send-message="send_comment" @blur="blur" :placeholder="input_placeholder"></chat-input> -->
  105. </view>
  106. <view class="uni-loadmore" v-if="showLoadMore">{{loadMoreText}}</view>
  107. </view>
  108. </view>
  109. </view>
  110. </template>
  111. <script>
  112. import chatInput from '@/components/im-chat/chatinput.vue'; //input框
  113. import tuiButton from "@/components/thorui/tui-button/tui-button"
  114. import tuiIcon from '@/components/thorui/tui-icon/tui-icon';
  115. import tRtPopup from '@/components/views/t-rt-popup/t-rt-popup';
  116. import postData from '@/common/index/index.post.data.js';//族友圈数据
  117. import personalData from '@/common/index/personal.post.data.js';//我的近况数据
  118. import uniPopup from '@/components/uni-popup/uni-popup.vue'
  119. import uniPopupMessage from '@/components/uni-popup/uni-popup-message.vue'
  120. import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
  121. import tuiModal from "@/components/thorui/tui-modal/tui-modal"
  122. import {
  123. mapState,
  124. mapMutations
  125. } from 'vuex'
  126. export default {
  127. components: {
  128. chatInput,
  129. tuiButton,
  130. tRtPopup,
  131. tuiIcon,
  132. uniPopup,
  133. uniPopupMessage,
  134. uniPopupDialog,
  135. tuiModal
  136. },
  137. data() {
  138. return {
  139. editname: false,
  140. editbirthday: false,
  141. edithobby: false,
  142. navbar: [ {
  143. name: "TA的说说"
  144. }, {
  145. name: "TA详情"
  146. }],
  147. textfont:[{
  148. font:"合抱之木,生于毫末;九层之台,起于垒土。实现中华民族伟大复兴是一个长期而艰巨的过程,需要凝聚磅礴之力,才能实现质的飞跃实现中华民族伟大复兴的中国梦汇聚了强。大的中国力量2013年3月17日"
  149. }],
  150. users: personalData,
  151. show: false,
  152. posts: postData,//模拟数据
  153. user_id: 4,
  154. username: 'Liuxy',
  155. index: '',
  156. fold:true,
  157. comment_index: '',
  158. currentTab: 0,
  159. input_placeholder: '评论', //占位内容
  160. focus: false, //是否自动聚焦输入框
  161. is_reply: false, //回复还是评论
  162. showInput: false, //评论输入框
  163. screenHeight: '', //屏幕高度(系统)
  164. platform: '',
  165. windowHeight: '' ,//可用窗口高度(不计入软键盘)
  166. loadMoreText: "加载中...",
  167. showLoadMore: false,
  168. }
  169. },
  170. mounted() {
  171. uni.getStorage({
  172. key: 'posts',
  173. success: function (res) {
  174. console.log(res.data);
  175. this.posts = res.data;
  176. }
  177. });
  178. },
  179. onLoad() {
  180. uni.getSystemInfo({ //获取设备信息
  181. success: (res) => {
  182. this.screenHeight = res.screenHeight;
  183. this.platform = res.platform;
  184. }
  185. });
  186. uni.startPullDownRefresh();
  187. },
  188. onShow() {
  189. uni.onWindowResize((res) => { //监听窗口尺寸变化,窗口尺寸不包括底部导航栏
  190. if(this.platform === 'ios'){
  191. this.windowHeight = res.size.windowHeight;
  192. this.adjust();
  193. }else{
  194. if (this.screenHeight - res.size.windowHeight > 60 && this.windowHeight <= res.size.windowHeight) {
  195. this.windowHeight = res.size.windowHeight;
  196. this.adjust();
  197. }
  198. }
  199. });
  200. },
  201. onHide() {
  202. },
  203. onUnload() {
  204. this.max = 0,
  205. this.data = [],
  206. this.loadMoreText = "加载更多",
  207. this.showLoadMore = false;
  208. },
  209. onReachBottom() { //监听上拉触底事件
  210. console.log('onReachBottom');
  211. this.showLoadMore = true;
  212. setTimeout(() => {
  213. //获取数据
  214. if (this.posts.length < 20){//测试数据
  215. this.posts = this.posts.concat(this.posts);
  216. }else{
  217. this.loadMoreText = "暂无更多";
  218. }
  219. }, 1000);
  220. },
  221. onPullDownRefresh() { //监听下拉刷新动作
  222. console.log('onPullDownRefresh');
  223. // 这里获取数据
  224. setTimeout(function() {
  225. //初始化数据
  226. uni.stopPullDownRefresh(); //停止下拉刷新
  227. }, 1000);
  228. },
  229. onNavigationBarButtonTap(e) {
  230. if (e.index === 0) {
  231. this.$refs.rtBubble.toggle();
  232. }
  233. },
  234. computed: mapState(['forcedLogin', 'hasLogin', 'userName']),
  235. methods: {
  236. name() {
  237. this.editname = true;
  238. },
  239. hide1() {
  240. this.editname = false;
  241. },
  242. handleClick1() {
  243. this.hide1();
  244. },
  245. birthday() {
  246. this.editbirthday = true;
  247. },
  248. hide2() {
  249. this.editbirthday = false;
  250. },
  251. handleClick2() {
  252. this.hide2();
  253. },
  254. hobby() {
  255. this.edithobby = true;
  256. },
  257. hide3() {
  258. this.edithobby = false;
  259. },
  260. handleClick3() {
  261. this.hide3();
  262. },
  263. btn:function(){ // 收起 展开
  264. this.fold=!this.fold;
  265. },
  266. open(){
  267. this.$refs.popup.open()
  268. },
  269. close(){
  270. this.$refs.popup.close()
  271. },
  272. change(e) {
  273. this.currentTab = e.index
  274. },
  275. showTips: function(e) {
  276. let index = e.currentTarget.dataset.index;
  277. let options = {
  278. msg: this.basicData[index].msg,
  279. duration: this.basicData[index].duration || 2000,
  280. type: this.basicData[index].type
  281. };
  282. this.$refs.toast.showTips(options);
  283. },
  284. switchTabs: function(e) {
  285. this.index = e.currentTarget.dataset.index
  286. },
  287. friends: function() {
  288. uni.navigateTo({
  289. url: './friends/friends'
  290. });
  291. },
  292. join: function() {
  293. uni.navigateTo({
  294. url: './join/join'
  295. });
  296. },
  297. establish: function() {
  298. uni.navigateTo({
  299. url: './establish/establish'
  300. });
  301. },
  302. personal: function() {
  303. uni.navigateTo({
  304. url: './personal/personal'
  305. });
  306. },
  307. loginurl: function() {
  308. uni.navigateTo({
  309. url: '/pages/login/login'
  310. });
  311. },
  312. rtBubble() {
  313. this.$refs.rtBubble.toggle();
  314. },
  315. topBubble() {
  316. this.show = !this.show;
  317. },
  318. navigateTo(url) {
  319. uni.navigateTo({
  320. url: url
  321. });
  322. },
  323. like(index) {
  324. if (this.posts[index].islike === 0) {
  325. this.posts[index].islike = 1;
  326. this.posts[index].like.push({
  327. "uid": this.user_id,
  328. "username": "," + this.username
  329. });
  330. } else {
  331. this.posts[index].islike = 0;
  332. this.posts[index].like.splice(this.posts[index].like.indexOf({
  333. "uid": this.user_id,
  334. "username": "," + this.username
  335. }), 1);
  336. }
  337. },
  338. comment(index) {
  339. this.showInput = true; //调起input框
  340. this.focus = true;
  341. this.index = index;
  342. },
  343. adjust() { //当弹出软键盘发生评论动作时,调整页面位置pageScrollTo
  344. return;
  345. uni.createSelectorQuery().selectViewport().scrollOffset(res => {
  346. var scrollTop = res.scrollTop;
  347. let view = uni.createSelectorQuery().select("#post-" + this.index);
  348. view.boundingClientRect(data => {
  349. console.log("data:" + JSON.stringify(data));
  350. console.log("手机屏幕高度:" + this.screenHeight);
  351. console.log("竖直滚动位置" + scrollTop);
  352. console.log("节点离页面顶部的距离为" + data.top);
  353. console.log("节点高度为" + data.height);
  354. console.log("窗口高度为" + this.windowHeight);
  355. uni.pageScrollTo({
  356. scrollTop: scrollTop - (this.windowHeight - (data.height + data.top + 45)), //一顿乱算
  357. // scrollTop: 50,
  358. duration: 300
  359. });
  360. }).exec();
  361. }).exec();
  362. },
  363. reply(index, comment_index) {
  364. this.is_reply = true; //回复中
  365. this.showInput = true; //调起input框
  366. let replyTo = this.posts[index].comments.comment[comment_index].username;
  367. this.input_placeholder = '回复' + replyTo;
  368. this.index = index; //post索引
  369. this.comment_index = comment_index; //评论索引
  370. this.focus = true;
  371. },
  372. blur: function() {
  373. this.init_input();
  374. },
  375. send_comment: function(message) {
  376. if (this.is_reply) {
  377. var reply_username = this.posts[this.index].comments.comment[this.comment_index].username;
  378. var comment_content = '回复' + reply_username + ':' + message.content;
  379. } else {
  380. var comment_content = message.content;
  381. }
  382. this.posts[this.index].comments.total += 1;
  383. this.posts[this.index].comments.comment.push({
  384. "uid": this.user_id,
  385. "username": this.username,
  386. "content": comment_content //直接获取input中的值
  387. });
  388. this.init_input();
  389. },
  390. init_input() {
  391. this.showInput = false;
  392. this.focus = false;
  393. this.input_placeholder = '评论';
  394. this.is_reply = false;
  395. },
  396. previewImage(imageList, image_index) {
  397. var current = imageList[image_index];
  398. uni.previewImage({
  399. current: current,
  400. urls: imageList
  401. });
  402. },
  403. goPublish() {
  404. uni.navigateTo({
  405. url: './publish/publish',
  406. success: res => {},
  407. fail: () => {},
  408. complete: () => {}
  409. });
  410. },
  411. }
  412. }
  413. </script>
  414. <style>
  415. @import url("@/common/index/index.css");
  416. @import '@/static/style/thorui.css';
  417. .tui-modal-input {
  418. width: 80%;
  419. border-bottom: 1rpx solid #e6e6e6;
  420. margin: 30rpx auto 50rpx;
  421. padding-bottom: 20rpx;
  422. font-size: 32rpx;
  423. }
  424. .fold{
  425. height: 120rpx;
  426. overflow: hidden;
  427. padding: 20rpx 20rpx 0px 20rpx;
  428. }
  429. .unfold{height: auto;
  430. overflow: hidden;
  431. padding: 20rpx 20rpx 0px 20rpx;}
  432. .hello {
  433. display: flex;
  434. flex: 1;
  435. flex-direction: column;
  436. width: 100%;
  437. }
  438. .uni-loadmore{
  439. height:80upx;
  440. line-height:80upx;
  441. text-align:center;
  442. padding-bottom:30upx;
  443. }
  444. .tui-subsection {
  445. width: 50%;
  446. display: flex;
  447. align-items: center;
  448. justify-content: center;
  449. margin: 80upx auto 20upx;
  450. border-radius: 10rpx;
  451. overflow: hidden;
  452. transform: translateZ(0);
  453. border: 0;
  454. position: relative;
  455. border: 1rpx solid #5677fc;
  456. }
  457. .tui-subsection-item {
  458. position: relative;
  459. z-index: 10;
  460. }
  461. .tui-subsection view {
  462. flex: 1;
  463. font-size: 28rpx;
  464. text-align: center;
  465. padding: 10rpx 30rpx;
  466. color: #5677fc;
  467. position: relative;
  468. border-right: 1rpx solid #5677fc;
  469. }
  470. .tui-last-child {
  471. border-right: 0 !important;
  472. }
  473. .tui-subsection .tui-active {
  474. background-color: #5677fc;
  475. color: #fff;
  476. }
  477. .title {
  478. color: #8f8f94;
  479. margin-top: 210upx;
  480. }
  481. .ul {
  482. font-size: 110upx;
  483. color: #8f8f94;
  484. margin-top: 210upx;
  485. width: 100%;
  486. }
  487. .ul>view {
  488. line-height: 50rpx;
  489. }
  490. .sub-title {
  491. font-size: 24rpx;
  492. color: #7a7a7a;
  493. padding-top: 18rpx;
  494. }
  495. .tui-title {
  496. width: 100%;
  497. box-sizing: border-box;
  498. font-weight: bold;
  499. }
  500. .tui-btn-box {
  501. width: 100%;
  502. padding: 0rpx 30rpx;
  503. box-sizing: border-box;
  504. position: relative;
  505. }
  506. .tui-chat-item {
  507. width: 100%;
  508. padding: 30rpx 30rpx 0 30rpx;
  509. box-sizing: border-box;
  510. display: flex;
  511. position: relative;
  512. }
  513. .tui-chat-box {
  514. max-width: 70%;
  515. }
  516. .tui-user-name {
  517. font-size: 24rpx;
  518. color: #999;
  519. }
  520. .tui-chat-text {
  521. width: 100%;
  522. min-width: 40rpx;
  523. padding: 18rpx 24rpx;
  524. display: flex;
  525. align-items: center;
  526. flex-wrap: wrap;
  527. word-break: break-all;
  528. box-sizing: border-box;
  529. }
  530. .tui-user-avatar {
  531. width: 84rpx;
  532. height: 84rpx;
  533. border-radius: 50%;
  534. flex-shrink: 0;
  535. }
  536. .tui-mr {
  537. margin-right: 24rpx;
  538. }
  539. .tui-ml {
  540. margin-left: 24rpx;
  541. }
  542. .tui-flex-end {
  543. justify-content: flex-end;
  544. }
  545. .tui-chat-text {
  546. width: 100%;
  547. min-width: 40rpx;
  548. padding: 18rpx 24rpx;
  549. display: flex;
  550. align-items: center;
  551. flex-wrap: wrap;
  552. word-break: break-all;
  553. color: #fff;
  554. box-sizing: border-box;
  555. }
  556. .tui-menu-item {
  557. width: 100%;
  558. padding: 30rpx 20rpx;
  559. box-sizing: border-box;
  560. }
  561. </style>