note_pad.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465
  1. <template>
  2. <view class="note_pad">
  3. <view class="note" v-if="curTab == 0">
  4. <custom-nav :bgColor="lineBg" class="nav">
  5. <view class="cur" @click="goBack">
  6. <text class="iconfont iconzuojiantou"></text>
  7. <text>便签</text>
  8. </view>
  9. </custom-nav>
  10. <view class="note_bg" :style="{ 'padding-top': height + 'px' }">
  11. <image src="../../static/imgs/note_bg.png"></image>
  12. <view class="note_con">
  13. <view class="note_user">
  14. <view class="flexS">
  15. <image :src="userInfo.avatar"></image>
  16. <view>
  17. <view style="font-size:36rpx;font-weight: bold;margin-bottom:10rpx;">{{ userInfo.nickname }}</view>
  18. <view style="font-size:24rpx;">{{ userInfo.phone }}</view>
  19. </view>
  20. </view>
  21. <view class="level flexC">
  22. <text class="iconfont iconxunzhang"></text>
  23. <text>{{ userInfo.level }}</text>
  24. </view>
  25. </view>
  26. <view class="flexS note_count" :style="{ top: top + 'rpx' }">
  27. <view class="flexCC" style="margin-right:75rpx;">
  28. <view class="intr">便签数</view>
  29. <view>
  30. <text class="count">{{ noteList.count.total ? noteList.count.total : 0 }}</text>
  31. <text class="unit">个</text>
  32. </view>
  33. </view>
  34. <view class="flexCC">
  35. <view class="intr">已发布</view>
  36. <view>
  37. <text class="count">{{ noteList.count.release_total ? noteList.count.release_total : 0 }}</text>
  38. <text class="unit">个</text>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="note_list">
  45. <view class="con" v-for="(item, index) in noteList.list" :key="index">
  46. <view class="con_title">第{{ item.season }}届大卫博士创业{{ item.type == 1 ? '密训营' : '实战营' }}</view>
  47. <view v-for="temp in item.note_list" :key="temp.id" @click="skipAdd(temp.id, item.type)">
  48. <view class="con_list flexB" :class="temp.level == 1 ? 'border1' : temp.level == 2 ? 'border2' : 'border0'">
  49. <view>
  50. <view class="note_name">{{ temp.title }}</view>
  51. <view class="note_del">
  52. <text class="iconfont iconshijian"></text>
  53. <text>{{ temp.created_at }}</text>
  54. <text style="color:#F44545;margin-left:10rpx;font-weight: bold;">{{ temp.status == 1 ? '已发布' : '' }}</text>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. <view class="find" v-if="curTab == 1">
  63. <custom-nav :bgColor="bgColor">
  64. <view class="current" @click="goBack">
  65. <text class="iconfont iconzuojiantou"></text>
  66. <text>发现便签</text>
  67. </view>
  68. </custom-nav>
  69. <view class="find_con" v-for="item in findList" :key="item.id" @click="noteDetail(item.id)">
  70. <view class="find_list">
  71. <view class="flexS user">
  72. <image :src="item.get_user.avatar" class="photo"></image>
  73. <text>{{ item.get_user.nickname }}</text>
  74. </view>
  75. <view class="find_title">{{ item.title }}</view>
  76. <view class="find_intr">{{ item.summary }}</view>
  77. <view class="find_img" v-if="item.cover_url"><image :src="item.cover_url" mode="widthFix"></image></view>
  78. <view class="flexB">
  79. <text style="font-size:24rpx;color:#999;">{{ item.time }}</text>
  80. <view class="flexS">
  81. <view style="margin-right:15rpx;" @click.stop="giveLike(item.id, item.like_status)">
  82. <image
  83. :src="item.like_status ? '../../static/imgs/like.png' : '../../static/imgs/before_like.png'"
  84. style="width: 37rpx;height:31rpx;vertical-align:middle;"
  85. ></image>
  86. <text style="margin-left:10rpx;">{{ item.like }}</text>
  87. </view>
  88. <view>
  89. <image src="../../static/imgs/comment.png" style="width: 33rpx;height:33rpx;vertical-align:middle;"></image>
  90. <text style="margin-left:10rpx;">{{ item.comment }}</text>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. <view class="block"></view>
  96. </view>
  97. </view>
  98. <view class="note_bottom flexA">
  99. <view @click="choose(0)" class="flexCC">
  100. <image :src="curTab == 0 ? '../../static/imgs/note_active.png' : '../../static/imgs/note.png'" style="width:53rpx;height:49rpx;"></image>
  101. <view :class="curTab == 0 ? 'active' : ''">便签</view>
  102. </view>
  103. <view class="add" @click="addNote"><image src="../../static/imgs/add.png"></image></view>
  104. <view @click="choose(1)" class="flexCC">
  105. <image :src="curTab == 1 ? '../../static/imgs/find_active.png' : '../../static/imgs/find.png'" style="width:53rpx;height:49rpx;"></image>
  106. <view :class="curTab == 1 ? 'active' : ''">发现</view>
  107. </view>
  108. </view>
  109. </view>
  110. </template>
  111. <script>
  112. let app = getApp();
  113. import customNav from '../../components/custom-nav.vue';
  114. import { findNote, myNote, clickHeart } from '../../api/note.js';
  115. export default {
  116. data() {
  117. return {
  118. noteList: '', //便签列表
  119. findList: '', //发现列表
  120. curTab: 0, //便签跟发现之间的切换
  121. userInfo: '',
  122. lineBg: 'linear-gradient(180deg, #FC9863 0%, #F76454 100%)', //自定义导航栏背景色(便签)
  123. bgColor: '#fff', //自定义导航栏背景色(发现)
  124. height: '', // 导航栏下第一个元素的高度 适配机型
  125. top: ''
  126. };
  127. },
  128. components: {
  129. customNav
  130. },
  131. onLoad(options) {
  132. this.height = app.globalData.navBarHeight;
  133. //便签详情返回显示发现页面
  134. this.curTab = options.curTab;
  135. },
  136. onShow() {
  137. if (!uni.getStorageSync('token')) {
  138. uni.switchTab({
  139. url: '../index/index'
  140. });
  141. }
  142. if (this.curTab == 1) {
  143. this.getFindNote();
  144. } else {
  145. this.getNote();
  146. }
  147. this.userInfo = uni.getStorageSync('userInfo');
  148. },
  149. methods: {
  150. goBack() {
  151. uni.switchTab({
  152. url: '../mine/mine'
  153. });
  154. },
  155. /*
  156. * 获取便签列表
  157. */
  158. getNote() {
  159. myNote().then(res => {
  160. if (res.code == 200) {
  161. this.noteList = res.data;
  162. } else {
  163. uni.showModal({
  164. content: res.message || '获取便签列表失败',
  165. showCancel: false
  166. });
  167. }
  168. });
  169. },
  170. /*
  171. * 点击跳转到编辑页面
  172. */
  173. skipAdd(id, type) {
  174. console.log(type);
  175. uni.navigateTo({
  176. url: '../add_note/add_note?id=' + id + '&type=' + type
  177. });
  178. },
  179. /*
  180. * 获取发现里的列表
  181. */
  182. getFindNote() {
  183. findNote().then(res => {
  184. if (res.code == 200) {
  185. this.findList = res.data.list;
  186. } else {
  187. uni.showModal({
  188. content: res.message || '获取列表失败',
  189. showCancel: false
  190. });
  191. }
  192. });
  193. },
  194. /*
  195. * 发现列表点赞
  196. * @parmas id 当前便签的id
  197. */
  198. giveLike(id, isLike) {
  199. if (isLike) {
  200. uni.showModal({
  201. content: '您已点过赞了',
  202. showCancel: false
  203. });
  204. return false;
  205. }
  206. clickHeart({ id }).then(res => {
  207. if (res.code == 200) {
  208. uni.showToast({
  209. title: '点赞成功',
  210. icon: 'none'
  211. });
  212. this.getFindNote();
  213. } else {
  214. uni.showModal({
  215. content: '点赞失败',
  216. showCancel: false
  217. });
  218. }
  219. });
  220. },
  221. //跳转到详情
  222. noteDetail(id) {
  223. uni.navigateTo({
  224. url: '../note_detail/note_detail?id=' + id
  225. });
  226. },
  227. /*
  228. * 便签和发现的tab切换
  229. * desc:tabType 0 便签 1 发现
  230. */
  231. choose(tabType) {
  232. this.curTab = tabType;
  233. if (tabType == 0) {
  234. this.getNote();
  235. } else {
  236. this.getFindNote();
  237. }
  238. },
  239. //添加便签
  240. addNote() {
  241. uni.navigateTo({
  242. url: '../add_note/add_note'
  243. });
  244. }
  245. }
  246. };
  247. </script>
  248. <style lang="scss">
  249. .current {
  250. font-size: 36rpx;
  251. font-weight: bold;
  252. .iconfont {
  253. font-size: 40rpx;
  254. color: #333;
  255. margin-left: 15rpx;
  256. vertical-align: -2rpx;
  257. }
  258. }
  259. .cur {
  260. font-size: 36rpx;
  261. font-weight: bold;
  262. .iconfont,
  263. text {
  264. color: #fff;
  265. }
  266. text:last-child {
  267. margin-left: 255rpx;
  268. }
  269. }
  270. .note_pad {
  271. height: 100vh;
  272. width: 100%;
  273. position: relative;
  274. }
  275. .note_bottom {
  276. width: 100%;
  277. height: 100rpx;
  278. background: #fff;
  279. position: fixed;
  280. bottom: 0;
  281. left: 0;
  282. padding: 0 30rpx;
  283. box-sizing: border-box;
  284. z-index: 9999;
  285. > view {
  286. view {
  287. font-size: 20rpx;
  288. color: #999;
  289. margin-top: 6rpx;
  290. }
  291. .active {
  292. color: #f76454;
  293. }
  294. }
  295. .add {
  296. margin-top: -15rpx;
  297. image {
  298. width: 172rpx;
  299. height: 172rpx;
  300. margin-top: -62rpx;
  301. }
  302. }
  303. }
  304. .note {
  305. .note_bg {
  306. position: relative;
  307. image {
  308. width: 100%;
  309. height: 342rpx;
  310. }
  311. .note_con {
  312. position: absolute;
  313. left: 0;
  314. top: 11vh;
  315. width: 100%;
  316. padding-left: 30rpx;
  317. image {
  318. width: 98rpx;
  319. height: 98rpx;
  320. border-radius: 50%;
  321. margin-right: 15rpx;
  322. }
  323. .note_user {
  324. display: flex;
  325. justify-content: space-between;
  326. .level {
  327. width: 142rpx;
  328. height: 50rpx;
  329. background: linear-gradient(203deg, #fbdcac 0%, #ffefd7 31%, #ffdca5 55%, #feeacb 90%, #f9d193 100%);
  330. opacity: 1;
  331. border-radius: 30rpx 0px 0px 30rpx;
  332. color: #f44545;
  333. font-size: 24rpx;
  334. .iconfont {
  335. margin-top: 8rpx;
  336. }
  337. }
  338. view {
  339. color: #fff;
  340. }
  341. }
  342. .note_count {
  343. margin-top: 40rpx;
  344. .intr {
  345. font-size: 24rpx;
  346. color: #fff;
  347. opacity: 0.6;
  348. }
  349. .count {
  350. font-size: 64rpx;
  351. color: #fff;
  352. font-weight: bold;
  353. }
  354. .unit {
  355. font-size: 28rpx;
  356. color: #fff;
  357. margin-left: 5rpx;
  358. }
  359. }
  360. }
  361. }
  362. .note_list {
  363. padding-bottom: 160rpx;
  364. .con {
  365. .con_title {
  366. font-size: 32rpx;
  367. font-weight: bold;
  368. margin: 40rpx 0 0 30rpx;
  369. color: #333;
  370. }
  371. .con_list {
  372. width: 690rpx;
  373. margin: 30rpx auto;
  374. background: #fff;
  375. border-radius: 4rpx 20rpx 20rpx 4rpx;
  376. padding: 30rpx;
  377. box-sizing: border-box;
  378. .note_name {
  379. font-size: 36rpx;
  380. font-weight: bold;
  381. }
  382. .note_del {
  383. font-size: 24rpx;
  384. color: #999;
  385. margin-top: 12rpx;
  386. .iconfont {
  387. font-size: 30rpx;
  388. vertical-align: -2rpx;
  389. margin-right: 8rpx;
  390. }
  391. }
  392. }
  393. .border0 {
  394. border-left: 8rpx solid #f76454;
  395. }
  396. .border1 {
  397. border-left: 8rpx solid #82bdff;
  398. }
  399. .border2 {
  400. border-left: 8rpx solid #50cb60;
  401. }
  402. }
  403. }
  404. }
  405. .find {
  406. padding-top: 150rpx;
  407. width: 100%;
  408. height: 100%;
  409. background: #fff;
  410. .find_con {
  411. width: 100%;
  412. background: #fff;
  413. .find_list {
  414. width: 690rpx;
  415. margin: 0 auto 30rpx;
  416. padding: 20rpx 0;
  417. box-sizing: border-box;
  418. background: #fff;
  419. }
  420. .block {
  421. width: 100%;
  422. height: 20rpx;
  423. background-color: #f9f9fb;
  424. }
  425. .user {
  426. .photo {
  427. width: 76rpx;
  428. height: 76rpx;
  429. border-radius: 50%;
  430. margin-right: 15rpx;
  431. }
  432. text {
  433. font-size: 28rpx;
  434. font-weight: bold;
  435. }
  436. }
  437. .find_title {
  438. font-size: 32rpx;
  439. color: #333;
  440. font-weight: bold;
  441. margin-top: 30rpx;
  442. }
  443. .find_intr {
  444. margin: 10rpx 0 30rpx;
  445. font-size: 28rpx;
  446. color: #333;
  447. }
  448. .find_img {
  449. margin: 30rpx 0;
  450. image {
  451. width: 100%;
  452. height: 100%;
  453. }
  454. }
  455. }
  456. .find_con:last-child {
  457. padding-bottom: 180rpx;
  458. }
  459. }
  460. </style>