friendSCirlce.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. <template>
  2. <view class="u-page">
  3. <mescroll-uni :up="upOption" :down="downOption" ref="mescrollRef" @init="mescrollInit" @up="upCallback"
  4. @down="downCallback">
  5. <circle-item ref="mescrollItem" :list="list" @click="showInput = false" @doThumb="doThumb"
  6. @doComment="doComment"></circle-item>
  7. </mescroll-uni>
  8. <view class="bottom" v-if="showInput">
  9. <view class="bottom-bt">
  10. <input class="bottom-bt-input" placeholder="请输入内容" v-model="commentValue" />
  11. <text class="bottom-bt-button" @click="submitComment">发送</text>
  12. </view>
  13. </view>
  14. <image v-if='hidden!="隐藏"' src="../../static/imgs/cirlce/add.png" mode="widthFix" class="add" @click="addCircle"></image>
  15. <u-action-sheet :show="show2" @close="show2 = false" @select="sheetSelect" :actions="actions2"
  16. cancelText="取消"></u-action-sheet>
  17. </view>
  18. </template>
  19. <script>
  20. var that;
  21. import circleItem from './circle-item.vue';
  22. import {
  23. mapState,
  24. mapMutations
  25. } from 'vuex';
  26. import MescrollMixin from '@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js';
  27. import {
  28. friendlyDate
  29. } from '@/common/util.js';
  30. export default {
  31. mixins: [MescrollMixin],
  32. components: {
  33. circleItem
  34. },
  35. data() {
  36. return {
  37. formData: {
  38. circleFriendsId: '',
  39. commonId: '',
  40. head: '',
  41. nickname: '',
  42. interactionFlag: '',
  43. },
  44. hidden:'',
  45. userInfo: {},
  46. circleId: '',
  47. downOption: {
  48. auto: false,
  49. textColor: '#bbb'
  50. },
  51. upOption: {
  52. page: {
  53. size: 10 // 每页数据的数量,默认10
  54. },
  55. auto: false,
  56. noMoreSize: 1,
  57. textNoMore: '没有更多了~',
  58. textColor: '#bbb'
  59. },
  60. list: [],
  61. requestParams: {
  62. searchType: 1,
  63. latitude: 0,
  64. longitude: 0,
  65. pageSize: 10,
  66. pageNo: 1
  67. },
  68. show2: false,
  69. actions2: [{
  70. name: '删除'
  71. }],
  72. showInput: false
  73. };
  74. },
  75. onLoad(options) {
  76. that = this
  77. this.circleId = options.id
  78. this.userInfo = uni.getStorageSync("userInfo")
  79. // 需要固定swiper的高度 (需减去悬浮tabs的高度64rpx)
  80. // this.height = uni.getSystemInfoSync().windowHeight - uni.upx2px(100) + 'px';
  81. // this.tabHeight = uni.upx2px(100) + 'px';
  82. this.loadData(true);
  83. },
  84. methods: {
  85. addCircle() {
  86. console.log(1111)
  87. uni.navigateTo({
  88. url: "/pageA/circle/addFriendCirlce?id=" + this.circleId
  89. })
  90. },
  91. /*下拉刷新的回调 */
  92. downCallback() {
  93. // this.loadData(true);
  94. this.mescroll.resetUpScroll();
  95. },
  96. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  97. upCallback(page) {
  98. console.log('upCallback=================', page);
  99. this.requestParams.pageNo = page.num;
  100. this.requestParams.pageSize = page.size;
  101. this.loadData();
  102. },
  103. scroll() {},
  104. change(index) {
  105. console.log('change=========', index);
  106. this.requestParams.searchType = index + 1;
  107. this.loadData(true);
  108. },
  109. // 处理图片
  110. imageInfo(url) {
  111. let promise = new Promise(function(resolve, reject) {
  112. uni.getImageInfo({
  113. src: url,
  114. success: function(image) {
  115. resolve(image)
  116. console.log(image.width);
  117. console.log(image.height);
  118. }
  119. });
  120. })
  121. return promise
  122. },
  123. loadData(refresh) {
  124. this.$request.baseRequest('admin.dictData', 'list', {
  125. dictType:'circle_friends'
  126. }, failres => {
  127. }).then( res => {
  128. console.log(res,11111)
  129. this.hidden=res.data.items[0].dictLabel
  130. })
  131. this.$request.baseRequest('admin.unimall.circleFriendsInfo', 'list', {
  132. page: this.requestParams.pageNo,
  133. limit: this.requestParams.pageSize,
  134. circleId: this.circleId,
  135. currentCommonId: this.userInfo.id
  136. }, failres => {
  137. console.log('res+++++', failres.errmsg)
  138. uni.showToast({
  139. icon: "none",
  140. title: failres.errmsg,
  141. duration: 3000
  142. });
  143. uni.hideLoading()
  144. }).then(async res => {
  145. console.log(res)
  146. if (this.requestParams.pageNo.num == 1) this.list = [];
  147. let curPageLen = res.data.items.length;
  148. let totalPage = res.data.total;
  149. this.list = res.data.items
  150. for (let i = 0; i < this.list.length; i++) {
  151. this.list[i].urlList = this.list[i].image.split(",")
  152. if (this.list[i].mediaType == 2) {
  153. let _image = await this.imageInfo(this.list[i].image +
  154. '?x-oss-process=video/snapshot,t_1000,f_jpg,w_800,h_600,m_fast,ar_auto')
  155. console.log("_image", _image)
  156. if (_image.width > _image.height) {
  157. this.list[i].direction = 1
  158. } else {
  159. this.list[i].direction = 2
  160. }
  161. }
  162. }
  163. this.$nextTick(() => {
  164. this.$forceUpdate();
  165. that.mescroll.endBySize(curPageLen, totalPage)
  166. });
  167. uni.hideLoading()
  168. })
  169. },
  170. getCircleDetail(id, index) {
  171. let param = {
  172. id: id,
  173. searchType: 1,
  174. latitude: 0,
  175. longitude: 0
  176. };
  177. if (this.locateInformation.location) {
  178. param.latitude = this.locateInformation.location.lat;
  179. param.longitude = this.locateInformation.location.lng;
  180. }
  181. getCircleDetail({
  182. params: param
  183. })
  184. .then(res => {
  185. console.log('getCircleDetail====', res);
  186. if (res) {
  187. let data = res;
  188. if (data.mediaType == 1) {
  189. let arr = data.url.split(',');
  190. if (arr.length > 1) {
  191. let list = [];
  192. arr.forEach(item2 => {
  193. list.push(item2);
  194. });
  195. data.urlList = list;
  196. } else {
  197. data.urlList = arr;
  198. }
  199. }
  200. data.dateTime = friendlyDate(new Date(data.createTime.replace(/\-/g, '/')).getTime());
  201. this.list[index].thumbNumber = data.thumbNumber;
  202. this.list[index].commentNumber = data.commentNumber;
  203. this.list[index].thumbed = data.thumbed;
  204. this.list[index].thumbs = data.thumbs;
  205. this.list[index].comments = data.comments;
  206. console.log('data====', data);
  207. console.log('index====', index);
  208. console.log('this.list====', this.list);
  209. this.$forceUpdate();
  210. } else {}
  211. })
  212. .catch(err => {
  213. console.log(err, 'catch');
  214. });
  215. },
  216. //点赞
  217. async doThumb(item) {
  218. if (item.helpFlag == 0) {
  219. this.formData = {
  220. circleFriendsId: item.id,
  221. commonId: this.userInfo.id,
  222. head: this.userInfo.head,
  223. nickname: this.userInfo.nickname
  224. }
  225. this.formData.interactionFlag = 1
  226. this.$request.baseRequest('admin.unimall.circleFriendsDetail', 'add', {
  227. circleFriendsDetail: JSON.stringify(this.formData)
  228. }, failres => {
  229. console.log('res+++++', failres.errmsg)
  230. uni.showToast({
  231. icon: "none",
  232. title: failres.errmsg,
  233. duration: 3000
  234. });
  235. uni.hideLoading()
  236. }).then(async res => {
  237. console.log(res)
  238. uni.showToast({
  239. icon: "success",
  240. title: '点赞成功!',
  241. duration: 2000
  242. });
  243. that.loadData()
  244. })
  245. } else {
  246. this.$request.baseRequest('admin.unimall.circleFriendsDetail', 'cancelLike', {
  247. circleFriendsId: item.id,
  248. commonId: this.userInfo.id,
  249. }, failres => {
  250. console.log('res+++++', failres.errmsg)
  251. uni.showToast({
  252. icon: "none",
  253. title: failres.errmsg,
  254. duration: 3000
  255. });
  256. uni.hideLoading()
  257. }).then(async res => {
  258. console.log(res)
  259. uni.showToast({
  260. icon: "success",
  261. title: '取消成功!',
  262. duration: 2000
  263. });
  264. that.loadData()
  265. })
  266. }
  267. },
  268. doComment(item, comment) {
  269. this.selectedComment = comment;
  270. if(!this.selectedComment){
  271. this.selectedComment = {
  272. id:''
  273. }
  274. }
  275. this.selectedCircle = item;
  276. if (comment != null && comment.userId == this.userInfo.id) {
  277. this.show2 = true;
  278. return;
  279. }
  280. this.showInput = !this.showInput;
  281. this.commentValue = '';
  282. this.$forceUpdate();
  283. },
  284. async submitComment() {
  285. // if (!this.commentValue) {
  286. // uni.$u.toast('请输入内容');
  287. // return;
  288. // }
  289. if(this.selectedComment.id){
  290. this.formData = {
  291. circleFriendsId: this.selectedCircle.id,
  292. commonId: this.userInfo.id,
  293. head: this.userInfo.head,
  294. nickname: this.userInfo.nickname,
  295. commentContent:this.commentValue,
  296. commentId:this.selectedComment.id,
  297. commentName:this.selectedComment.nickname,
  298. }
  299. }else{
  300. this.formData = {
  301. circleFriendsId: this.selectedCircle.id,
  302. commonId: this.userInfo.id,
  303. head: this.userInfo.head,
  304. nickname: this.userInfo.nickname,
  305. commentContent:this.commentValue,
  306. commentName:this.selectedComment.nickname,
  307. }
  308. }
  309. this.formData.interactionFlag = 2
  310. this.$request.baseRequest('admin.unimall.circleFriendsDetail', 'add', {
  311. circleFriendsDetail: JSON.stringify(this.formData)
  312. }, failres => {
  313. console.log('res+++++', failres.errmsg)
  314. uni.showToast({
  315. icon: "none",
  316. title: failres.errmsg,
  317. duration: 3000
  318. });
  319. uni.hideLoading()
  320. }).then(async res => {
  321. console.log(res)
  322. uni.showToast({
  323. icon: "success",
  324. title: '评论成功!',
  325. duration: 2000
  326. });
  327. this.showInput =false
  328. this.loadData()
  329. })
  330. // let params = {
  331. // comment: this.commentValue,
  332. // circleId: this.selectedCircle.id,
  333. // circleUserId: this.selectedCircle.userId
  334. // };
  335. // if (this.selectedComment) {
  336. // let tmp = {
  337. // pid: this.selectedComment.id,
  338. // comUserId: this.selectedComment.userId
  339. // };
  340. // params = uni.$u.deepMerge(params, tmp);
  341. // }
  342. // let res = await addComment(params);
  343. // if (res) {
  344. // uni.$u.toast('评论成功');
  345. // this.getCircleDetail(this.selectedCircle.id, this.selectedCircle.index);
  346. // }
  347. },
  348. sheetSelect(val) {
  349. console.log('---sheetSelect---');
  350. this.doDelComment();
  351. },
  352. async doDelComment() {
  353. let params = {
  354. id: this.selectedComment.id,
  355. circleId: this.selectedComment.circleId
  356. };
  357. let res = await delComment(params);
  358. console.log('doDelComment', res);
  359. if (res) {
  360. uni.$u.toast('删除成功');
  361. this.getCircleDetail(this.selectedCircle.id, this.selectedCircle.index);
  362. }
  363. }
  364. }
  365. };
  366. </script>
  367. <style lang="scss">
  368. .u-swiper {
  369. position: relative;
  370. }
  371. .bottom {
  372. bottom: 0;
  373. position: fixed;
  374. height: 120upx;
  375. width: 750upx;
  376. // padding: 0 20upx;
  377. background-color: #eee;
  378. align-items: center;
  379. justify-content: center;
  380. display: flex;
  381. z-index: 999;
  382. }
  383. .bottom-bt {
  384. display: flex;
  385. flex-direction: row;
  386. align-items: center;
  387. }
  388. .bottom-bt-input {
  389. width: 550upx;
  390. height: 70upx;
  391. padding: 0 15upx;
  392. border-radius: 10upx;
  393. background-color: #fff;
  394. margin-right: 20upx;
  395. font-size: 28upx;
  396. color: #333;
  397. }
  398. .bottom-bt-button {
  399. padding: 0 20upx;
  400. height: 55upx;
  401. line-height: 55upx;
  402. background-color: #344577;
  403. font-size: 28upx;
  404. color: #fff;
  405. border-radius: 10upx;
  406. }
  407. .add {
  408. width: 84rpx;
  409. height: auto;
  410. position: fixed;
  411. bottom: 200rpx;
  412. right: 30rpx;
  413. height: auto;
  414. z-index: 999;
  415. }
  416. </style>