share.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. <template>
  2. <view class="content">
  3. <view class="vheigh"></view>
  4. <!-- <view class="top-bg">
  5. <view class="top" @click="clickSearch()">
  6. <view class="top-icon">
  7. <image src="../../static/icon/icon.png" mode=""></image>
  8. </view>
  9. <view class="top-main">输入关键词搜索</view>
  10. </view>
  11. </view> -->
  12. <!-- <view class="navbar">
  13. <view class="nav-item" :class="{ current: tabCurrentIndex === 0 }" @click="tabClick('0')">笔记素材</view>
  14. <view class="nav-item" :class="{ current: tabCurrentIndex === 1 }" @click="tabClick('1')">买家反馈</view>
  15. </view> -->
  16. <swiper :current="tabCurrentIndex" :style="{ height: height }" class="swiper-box" duration="300"
  17. @change="changeTab">
  18. <swiper-item class="tab-content">
  19. <scroll-view scroll-y="true" class="list-scroll-content">
  20. <view class="main" v-for="(item, index) in bjsclist" :key="index"
  21. @click="navTo('/pages/zc/wzDetail?id=' + item.id)">
  22. <view class="main-userInfo">
  23. <view class="avatar">
  24. <image src="../../static/icon/fire.png" mode=""></image>
  25. </view>
  26. <view class="main-user-info">
  27. <view class="main-userName">{{ item.author }}</view>
  28. <view class="main-user-time">2022-12-20 20:52</view>
  29. </view>
  30. </view>
  31. <view class="main-info">{{ item.synopsis }}</view>
  32. <!-- <sunuiGrand :content="item.synopsis" clamp="4" expandText="全文" shinkText="收起" bg="#ffffff"></sunuiGrand> -->
  33. <!-- <view class="imagebox">
  34. <view class="image-item" v-for="(itm, inx) in item.share_images"><image :src="itm" mode=""></image></view>
  35. </view> -->
  36. <view class="main-bottom flex">
  37. <view class="main-bottom-item" @click.stop="navTo('/pages/zc/wzshare?id=' + item.id)">
  38. <view class="main-bottom-icon">
  39. <image src="../../static/icon/pyq.png" mode=""></image>
  40. </view>
  41. <view class="main-bottom-font">朋友圈</view>
  42. </view>
  43. <button class="main-bottom-item" open-type="share" @click.stop="seave(item)">
  44. <view class="main-bottom-icon1">
  45. <image src="../../static/icon/wxhy.png" mode=""></image>
  46. </view>
  47. <view class="main-bottom-font">微信好友</view>
  48. </button>
  49. <view class="main-bottom-item" @click.stop="wzdz(item)">
  50. <view class="main-bottom-icon" v-if="item.user_good == 1">
  51. <image src="../../static/icon/zanguo.png" mode=""></image>
  52. </view>
  53. <view class="main-bottom-icon" v-else>
  54. <image src="../../static/icon/zan.png" mode=""></image>
  55. </view>
  56. <view class="main-bottom-font">{{ item.goods_count }}</view>
  57. </view>
  58. </view>
  59. </view>
  60. </scroll-view>
  61. </swiper-item>
  62. <!-- <swiper-item class="tab-content">
  63. <scroll-view scroll-y="true" class="list-scroll-content">
  64. <view class="info">
  65. <view class="info-item" v-for="(item, index) in mjfklist" :key="index"
  66. @click="navTo('/pages/zc/plDetail?id=' + item.id)">
  67. <view class="info-image">
  68. <image :src="item.main_pic" mode=""></image>
  69. </view>
  70. <view class="info-name clamp">{{ item.title }}</view>
  71. <view class="info-userinfo flex">
  72. <view class="info-left">
  73. <view class="info-avatar">
  74. <image :src="item.avatar" mode=""></image>
  75. </view>
  76. <view class="info-userinfo-name">{{ item.nickname }}</view>
  77. </view>
  78. <view class="info-right" @click.stop="pldz(item)">
  79. <view class="info-avatar" v-if="item.user_good == 0">
  80. <image src="../../static/icon/zan.png" mode=""></image>
  81. </view>
  82. <view class="info-avatar" v-if="item.user_good == 1">
  83. <image src="../../static/icon/zanguo.png" mode=""></image>
  84. </view>
  85. <view class="info-userinfo-name">{{ item.goods_count }}</view>
  86. </view>
  87. </view>
  88. </view>
  89. </view>
  90. </scroll-view>
  91. </swiper-item> -->
  92. </swiper>
  93. </view>
  94. </template>
  95. <script>
  96. import {
  97. article
  98. } from '@/api/user.js';
  99. import {
  100. reply_list
  101. } from '@/api/product.js';
  102. import {
  103. article_good,
  104. reply_good
  105. } from '@/api/activity.js';
  106. import sunuiGrand from '@/components/sunui-grand/sunui-grand.vue';
  107. export default {
  108. // #ifdef MP
  109. onShareAppMessage: function(res) {
  110. console.log(this.share);
  111. if (res.from === 'button') {
  112. // 来自页面内分享按钮
  113. let pages = getCurrentPages();
  114. // 获取当前页面
  115. let page = pages[pages.length - 1];
  116. let path = '/' + page.route + '?';
  117. // 保存传值
  118. for (let i in page.options) {
  119. path += i + '=' + page.options[i] + '&';
  120. }
  121. // 保存邀请人
  122. let data = {
  123. path: path,
  124. imageUrl: this.share.image_input[0],
  125. title: this.share.title
  126. };
  127. console.log('data', data);
  128. return data;
  129. }
  130. },
  131. // #endif
  132. components: {
  133. sunuiGrand
  134. },
  135. data() {
  136. return {
  137. tabCurrentIndex: 0,
  138. height: '',
  139. bjsclist: '',
  140. mjfklist: '',
  141. share: ''
  142. };
  143. },
  144. onLoad() {},
  145. onShow() {
  146. this.loadData();
  147. },
  148. onReachBottom() {},
  149. onReady(res) {
  150. var _this = this;
  151. uni.getSystemInfo({
  152. success: resu => {
  153. const query = uni.createSelectorQuery();
  154. query.select('.swiper-box').boundingClientRect();
  155. query.exec(function(res) {
  156. _this.height = resu.windowHeight - res[0].top + 'px';
  157. console.log('打印页面的剩余高度', _this.height);
  158. });
  159. },
  160. fail: res => {}
  161. });
  162. },
  163. methods: {
  164. seave(item) {
  165. this.share = item;
  166. },
  167. clickSearch() {
  168. uni.navigateTo({
  169. url: '/pages/product/search'
  170. });
  171. },
  172. changeTab(e) {
  173. this.tabCurrentIndex = e.target.current;
  174. this.loadData();
  175. },
  176. tabClick(index) {
  177. this.tabCurrentIndex = index;
  178. this.loadData();
  179. },
  180. // 文章点赞
  181. wzdz(item) {
  182. article_good({}, item.id).then(e => {
  183. if (item.user_good == 0) {
  184. item.user_good = 1;
  185. item.goods_count += 1;
  186. } else {
  187. item.user_good = 0;
  188. item.goods_count -= 1;
  189. }
  190. });
  191. },
  192. // 评论点赞
  193. pldz(item) {
  194. reply_good({}, item.id).then(e => {
  195. if (item.user_good == 0) {
  196. item.user_good = 1;
  197. item.goods_count += 1;
  198. } else {
  199. item.user_good = 0;
  200. item.goods_count -= 1;
  201. }
  202. });
  203. },
  204. navTo(url) {
  205. uni.navigateTo({
  206. url
  207. });
  208. },
  209. async loadData(source) {
  210. let obj = this;
  211. if (this.tabCurrentIndex == 0) {
  212. article({
  213. page: 1,
  214. limit: 1000
  215. },
  216. 1
  217. )
  218. .then(({
  219. data
  220. }) => {
  221. this.bjsclist = data;
  222. })
  223. .catch(e => {
  224. console.log(e);
  225. });
  226. } else {
  227. reply_list({
  228. page: 1,
  229. limit: 1000
  230. },
  231. 0
  232. )
  233. .then(({
  234. data
  235. }) => {
  236. this.mjfklist = data;
  237. })
  238. .catch(e => {
  239. console.log(e);
  240. });
  241. }
  242. }
  243. }
  244. };
  245. </script>
  246. <style lang="scss">
  247. .vheigh {
  248. height: var(--status-bar-height);
  249. background-color: #ffffff;
  250. }
  251. button {
  252. padding: 0;
  253. margin: 0;
  254. border: none;
  255. background-color: #ffffff;
  256. line-height: 1;
  257. height: auto;
  258. }
  259. button::after {
  260. border: none;
  261. }
  262. page,
  263. .content {
  264. min-height: 100%;
  265. height: auto;
  266. }
  267. .top-bg {
  268. padding-top: 20rpx;
  269. background: #ffffff;
  270. }
  271. .list-scroll-content {
  272. background: #ffffff;
  273. height: 100%;
  274. .yan {
  275. padding-bottom: 100rpx;
  276. }
  277. }
  278. .top {
  279. width: 689rpx;
  280. height: 58rpx;
  281. background: #ededed;
  282. border-radius: 29rpx;
  283. margin: 0 auto;
  284. display: flex;
  285. justify-content: center;
  286. align-items: center;
  287. .top-icon {
  288. width: 32rpx;
  289. height: 32rpx;
  290. image {
  291. width: 100%;
  292. height: 100%;
  293. }
  294. }
  295. .top-main {
  296. margin-left: 20rpx;
  297. font-size: 28rpx;
  298. font-family: PingFang SC;
  299. font-weight: 500;
  300. color: #cbcbcb;
  301. }
  302. }
  303. .navbar {
  304. display: flex;
  305. height: 88rpx;
  306. padding: 0 5px;
  307. background: #ffffff;
  308. box-shadow: 0 1px 5px rgba(0, 0, 0, 0.06);
  309. position: relative;
  310. z-index: 10;
  311. .nav-item {
  312. flex: 1;
  313. display: flex;
  314. justify-content: center;
  315. align-items: center;
  316. height: 100%;
  317. font-size: 15px;
  318. color: #999999;
  319. position: relative;
  320. &.current {
  321. color: #000;
  322. &:after {
  323. content: '';
  324. position: absolute;
  325. left: 50%;
  326. bottom: 0;
  327. transform: translateX(-50%);
  328. width: 44px;
  329. height: 0;
  330. border-bottom: 2px solid #000000;
  331. }
  332. }
  333. }
  334. }
  335. .main {
  336. margin-top: 20rpx;
  337. padding: 35rpx 20rpx 24rpx;
  338. background: #ffffff;
  339. image {
  340. width: 100%;
  341. height: 100%;
  342. }
  343. .main-userInfo {
  344. display: flex;
  345. align-items: center;
  346. .avatar {
  347. width: 80rpx;
  348. height: 80rpx;
  349. background: #ffffff;
  350. border-radius: 50%;
  351. }
  352. .main-user-info {
  353. margin-left: 14rpx;
  354. line-height: 1;
  355. .main-userName {
  356. font-size: 28rpx;
  357. font-family: PingFang SC;
  358. font-weight: bold;
  359. color: #000000;
  360. }
  361. .main-user-time {
  362. margin-top: 14rpx;
  363. font-size: 21rpx;
  364. font-family: PingFang SC;
  365. font-weight: 500;
  366. color: #666666;
  367. }
  368. }
  369. }
  370. .main-info {
  371. margin-top: 20rpx;
  372. }
  373. .imagebox {
  374. margin-top: 40rpx;
  375. display: flex;
  376. align-items: center;
  377. flex-wrap: wrap;
  378. .image-item {
  379. margin: 10rpx;
  380. width: 30%;
  381. height: 230rpx;
  382. }
  383. }
  384. .main-bottom {
  385. margin-top: 60rpx;
  386. .main-bottom-item {
  387. padding: 30rpx 0;
  388. width: 33%;
  389. display: flex;
  390. justify-content: center;
  391. align-items: center;
  392. .main-bottom-icon {
  393. width: 36rpx;
  394. height: 36rpx;
  395. }
  396. .main-bottom-icon1 {
  397. width: 43rpx;
  398. height: 36rpx;
  399. }
  400. .main-bottom-icon2 {
  401. width: 36rpx;
  402. height: 36rpx;
  403. }
  404. .main-bottom-font {
  405. margin-left: 17rpx;
  406. font-size: 22rpx;
  407. font-family: PingFang SC;
  408. font-weight: 500;
  409. color: #333333;
  410. }
  411. }
  412. }
  413. }
  414. .info {
  415. padding: 10rpx;
  416. display: flex;
  417. flex-wrap: wrap;
  418. justify-content: space-between;
  419. image {
  420. width: 100%;
  421. height: 100%;
  422. }
  423. .info-item {
  424. width: 48%;
  425. padding-bottom: 20rpx;
  426. .info-image {
  427. width: 100%;
  428. height: 480rpx;
  429. }
  430. .info-name {
  431. margin-top: 20rpx;
  432. padding: 0 10rpx;
  433. font-size: 26rpx;
  434. font-family: PingFang SC;
  435. font-weight: bold;
  436. color: #000000;
  437. }
  438. .info-userinfo {
  439. margin-top: 20rpx;
  440. padding: 0 10rpx;
  441. .info-left {
  442. display: flex;
  443. align-items: center;
  444. .info-avatar {
  445. width: 32rpx;
  446. height: 32rpx;
  447. }
  448. }
  449. .info-userinfo-name {
  450. margin-left: 10rpx;
  451. font-size: 24rpx;
  452. font-family: PingFang SC;
  453. font-weight: bold;
  454. color: #999999;
  455. }
  456. .info-right {
  457. display: flex;
  458. align-items: center;
  459. .info-avatar {
  460. width: 30rpx;
  461. height: 30rpx;
  462. }
  463. }
  464. }
  465. }
  466. }
  467. </style>