friendSCirlce.vue 11 KB

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