friendSCirlce.vue 11 KB

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