friendSCirlce.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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. that.mescroll.endBySize(curPageLen, totalPage)
  156. });
  157. uni.hideLoading()
  158. })
  159. },
  160. getCircleDetail(id, index) {
  161. let param = {
  162. id: id,
  163. searchType: 1,
  164. latitude: 0,
  165. longitude: 0
  166. };
  167. if (this.locateInformation.location) {
  168. param.latitude = this.locateInformation.location.lat;
  169. param.longitude = this.locateInformation.location.lng;
  170. }
  171. getCircleDetail({
  172. params: param
  173. })
  174. .then(res => {
  175. console.log('getCircleDetail====', res);
  176. if (res) {
  177. let data = res;
  178. if (data.mediaType == 1) {
  179. let arr = data.url.split(',');
  180. if (arr.length > 1) {
  181. let list = [];
  182. arr.forEach(item2 => {
  183. list.push(item2);
  184. });
  185. data.urlList = list;
  186. } else {
  187. data.urlList = arr;
  188. }
  189. }
  190. data.dateTime = friendlyDate(new Date(data.createTime.replace(/\-/g, '/')).getTime());
  191. this.list[index].thumbNumber = data.thumbNumber;
  192. this.list[index].commentNumber = data.commentNumber;
  193. this.list[index].thumbed = data.thumbed;
  194. this.list[index].thumbs = data.thumbs;
  195. this.list[index].comments = data.comments;
  196. console.log('data====', data);
  197. console.log('index====', index);
  198. console.log('this.list====', this.list);
  199. this.$forceUpdate();
  200. } else {}
  201. })
  202. .catch(err => {
  203. console.log(err, 'catch');
  204. });
  205. },
  206. //点赞
  207. async doThumb(item) {
  208. if (item.helpFlag == 0) {
  209. this.formData = {
  210. circleFriendsId: item.id,
  211. commonId: this.userInfo.id,
  212. head: this.userInfo.head,
  213. nickname: this.userInfo.nickname
  214. }
  215. this.formData.interactionFlag = 1
  216. this.$request.baseRequest('admin.unimall.circleFriendsDetail', 'add', {
  217. circleFriendsDetail: JSON.stringify(this.formData)
  218. }, failres => {
  219. console.log('res+++++', failres.errmsg)
  220. uni.showToast({
  221. icon: "none",
  222. title: failres.errmsg,
  223. duration: 3000
  224. });
  225. uni.hideLoading()
  226. }).then(async res => {
  227. console.log(res)
  228. uni.showToast({
  229. icon: "success",
  230. title: '点赞成功!',
  231. duration: 2000
  232. });
  233. this.loadData()
  234. })
  235. } else {
  236. this.$request.baseRequest('admin.unimall.circleFriendsDetail', 'cancelLike', {
  237. circleFriendsId: item.id,
  238. commonId: this.userInfo.id,
  239. }, failres => {
  240. console.log('res+++++', failres.errmsg)
  241. uni.showToast({
  242. icon: "none",
  243. title: failres.errmsg,
  244. duration: 3000
  245. });
  246. uni.hideLoading()
  247. }).then(async res => {
  248. console.log(res)
  249. uni.showToast({
  250. icon: "success",
  251. title: '取消成功!',
  252. duration: 2000
  253. });
  254. this.loadData()
  255. })
  256. }
  257. },
  258. doComment(item, comment) {
  259. this.selectedComment = comment;
  260. this.selectedCircle = item;
  261. if (comment != null && comment.userId == this.userInfo.id) {
  262. this.show2 = true;
  263. return;
  264. }
  265. this.showInput = !this.showInput;
  266. this.commentValue = '';
  267. this.$forceUpdate();
  268. },
  269. async submitComment() {
  270. if (!this.commentValue) {
  271. uni.$u.toast('请输入内容');
  272. return;
  273. }
  274. let params = {
  275. comment: this.commentValue,
  276. circleId: this.selectedCircle.id,
  277. circleUserId: this.selectedCircle.userId
  278. };
  279. if (this.selectedComment) {
  280. let tmp = {
  281. pid: this.selectedComment.id,
  282. comUserId: this.selectedComment.userId
  283. };
  284. params = uni.$u.deepMerge(params, tmp);
  285. }
  286. let res = await addComment(params);
  287. if (res) {
  288. uni.$u.toast('评论成功');
  289. this.getCircleDetail(this.selectedCircle.id, this.selectedCircle.index);
  290. }
  291. },
  292. sheetSelect(val) {
  293. console.log('---sheetSelect---');
  294. this.doDelComment();
  295. },
  296. async doDelComment() {
  297. let params = {
  298. id: this.selectedComment.id,
  299. circleId: this.selectedComment.circleId
  300. };
  301. let res = await delComment(params);
  302. console.log('doDelComment', res);
  303. if (res) {
  304. uni.$u.toast('删除成功');
  305. this.getCircleDetail(this.selectedCircle.id, this.selectedCircle.index);
  306. }
  307. }
  308. }
  309. };
  310. </script>
  311. <style lang="scss">
  312. .u-swiper {
  313. position: relative;
  314. }
  315. .bottom {
  316. bottom: 0;
  317. position: fixed;
  318. height: 120upx;
  319. width: 750upx;
  320. // padding: 0 20upx;
  321. background-color: #eee;
  322. align-items: center;
  323. justify-content: center;
  324. display: flex;
  325. z-index: 999;
  326. }
  327. .bottom-bt {
  328. display: flex;
  329. flex-direction: row;
  330. align-items: center;
  331. }
  332. .bottom-bt-input {
  333. width: 550upx;
  334. height: 70upx;
  335. padding: 0 15upx;
  336. border-radius: 10upx;
  337. background-color: #fff;
  338. margin-right: 20upx;
  339. font-size: 28upx;
  340. color: #333;
  341. }
  342. .bottom-bt-button {
  343. padding: 0 20upx;
  344. height: 55upx;
  345. line-height: 55upx;
  346. background-color: #344577;
  347. font-size: 28upx;
  348. color: #fff;
  349. border-radius: 10upx;
  350. }
  351. .add {
  352. width: 84rpx;
  353. height: auto;
  354. position: fixed;
  355. bottom: 200rpx;
  356. right: 30rpx;
  357. height: auto;
  358. z-index: 999;
  359. }
  360. </style>