friendSCirlce.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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. 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. this.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. this.loadData()
  256. })
  257. }
  258. },
  259. doComment(item, comment) {debugger
  260. this.selectedComment = comment;
  261. if(!this.selectedComment){
  262. this.selectedComment.id = ''
  263. }
  264. this.selectedCircle = item;
  265. if (comment != null && comment.userId == this.userInfo.id) {
  266. this.show2 = true;
  267. return;
  268. }
  269. this.showInput = !this.showInput;
  270. this.commentValue = '';
  271. this.$forceUpdate();
  272. },
  273. async submitComment() {
  274. debugger
  275. // if (!this.commentValue) {
  276. // uni.$u.toast('请输入内容');
  277. // return;
  278. // }
  279. this.formData = {
  280. circleFriendsId: this.selectedCircle.id,
  281. commonId: this.userInfo.id,
  282. head: this.userInfo.head,
  283. nickname: this.userInfo.nickname,
  284. commentContent:this.commentValue,
  285. commentId:this.selectedComment.id,
  286. commentName:this.selectedComment.nickname,
  287. }
  288. this.formData.interactionFlag = 2
  289. this.$request.baseRequest('admin.unimall.circleFriendsDetail', 'add', {
  290. circleFriendsDetail: JSON.stringify(this.formData)
  291. }, failres => {
  292. console.log('res+++++', failres.errmsg)
  293. uni.showToast({
  294. icon: "none",
  295. title: failres.errmsg,
  296. duration: 3000
  297. });
  298. uni.hideLoading()
  299. }).then(async res => {
  300. console.log(res)
  301. uni.showToast({
  302. icon: "success",
  303. title: '评论成功!',
  304. duration: 2000
  305. });
  306. this.loadData()
  307. })
  308. // let params = {
  309. // comment: this.commentValue,
  310. // circleId: this.selectedCircle.id,
  311. // circleUserId: this.selectedCircle.userId
  312. // };
  313. // if (this.selectedComment) {
  314. // let tmp = {
  315. // pid: this.selectedComment.id,
  316. // comUserId: this.selectedComment.userId
  317. // };
  318. // params = uni.$u.deepMerge(params, tmp);
  319. // }
  320. // let res = await addComment(params);
  321. // if (res) {
  322. // uni.$u.toast('评论成功');
  323. // this.getCircleDetail(this.selectedCircle.id, this.selectedCircle.index);
  324. // }
  325. },
  326. sheetSelect(val) {
  327. console.log('---sheetSelect---');
  328. this.doDelComment();
  329. },
  330. async doDelComment() {
  331. let params = {
  332. id: this.selectedComment.id,
  333. circleId: this.selectedComment.circleId
  334. };
  335. let res = await delComment(params);
  336. console.log('doDelComment', res);
  337. if (res) {
  338. uni.$u.toast('删除成功');
  339. this.getCircleDetail(this.selectedCircle.id, this.selectedCircle.index);
  340. }
  341. }
  342. }
  343. };
  344. </script>
  345. <style lang="scss">
  346. .u-swiper {
  347. position: relative;
  348. }
  349. .bottom {
  350. bottom: 0;
  351. position: fixed;
  352. height: 120upx;
  353. width: 750upx;
  354. // padding: 0 20upx;
  355. background-color: #eee;
  356. align-items: center;
  357. justify-content: center;
  358. display: flex;
  359. z-index: 999;
  360. }
  361. .bottom-bt {
  362. display: flex;
  363. flex-direction: row;
  364. align-items: center;
  365. }
  366. .bottom-bt-input {
  367. width: 550upx;
  368. height: 70upx;
  369. padding: 0 15upx;
  370. border-radius: 10upx;
  371. background-color: #fff;
  372. margin-right: 20upx;
  373. font-size: 28upx;
  374. color: #333;
  375. }
  376. .bottom-bt-button {
  377. padding: 0 20upx;
  378. height: 55upx;
  379. line-height: 55upx;
  380. background-color: #344577;
  381. font-size: 28upx;
  382. color: #fff;
  383. border-radius: 10upx;
  384. }
  385. .add {
  386. width: 84rpx;
  387. height: auto;
  388. position: fixed;
  389. bottom: 200rpx;
  390. right: 30rpx;
  391. height: auto;
  392. z-index: 999;
  393. }
  394. </style>