myNote.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <template>
  2. <view class="content-box" >
  3. <image class="bg-img" src="https://beiliyo-2025.obs.cn-north-4.myhuaweicloud.com/fs/20250115/1736955760372.png"></image>
  4. <view class="nav-bar">
  5. <view class="grace-page-header" :style="{ background:headerBG }">
  6. <!-- 沉浸式状态栏 -->
  7. <view class="grace-page-status-bar" :style="{ background:statusBarBG}"></view>
  8. <!-- 头部核心 -->
  9. <view class="grace-page-header-nav" id="gracePageHeader" :style="{minHeight:headerHeight+'px', height:headerHeight+'px', overflow:'hidden'}">
  10. <view class="u-nav-left" @tap="navBack()">
  11. <image class="back" src="@/static/images/course/ret-white.png" ></image>
  12. </view>
  13. <view class="grace-header-main es-fw-500">我的笔记</view>
  14. <view class="u-nav-right">
  15. <image class="right-icon" src="@/static/images/course/edit.png" @tap="deleteNote()" ></image>
  16. <view v-if="noteType!=2" class="edit" @tap="changeEdit()">{{!isEdit?'编辑':'取消'}}</view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="nav_box">
  21. <view class="status_bar"></view>
  22. <view class="nav_bar"></view>
  23. </view>
  24. </view>
  25. <mescroll-body ref="mescrollRef" style="background-color:#f7f7f7;min-height: 700px;" @init="mescrollInit" top="0" bottom="200" :down="downOption" :up="upOption" @down="downCallback" @up="upCallback">
  26. <view class="es-ml-30 es-mr-30 es-mt-30">
  27. <image @tap="$navTo('/pages_course/info?courseId='+noteData.courseId)" class="cover" :src="noteData.imgUrl" mode="scaleToFill"></image>
  28. <view @tap="$navTo('/pages_course/info?courseId='+noteData.courseId)" class="title es-fw-500 es-fs-30 es-mb-20">{{noteData.courseName}}</view>
  29. <view @tap="$navTo('/pages_course/info?courseId='+noteData.courseId)" class="es-fw-500 es-fs-26 es-c-33">{{noteData.videoName}}</view>
  30. <view class="x-start es-mt-20">
  31. <view class="calendar x-c es-w-60 es-h-60">
  32. <image class="es-w-28 es-h-30" src="@/static/images/course/calendar.png"></image>
  33. </view>
  34. <view class="es-ml-20 es-mt-20 es-fw-500 es-fs-24 es-c-99">{{ utils.formatDate(noteData.createTime)}}</view>
  35. </view>
  36. <view v-if="!isEdit" class="textAreaBox es-bc-ff es-br-20 es-mt-20 es-fw-n es-fs-30 es-c-33 es-pl-20 es-pt-20">
  37. {{noteData.content}}
  38. </view>
  39. <view v-if="isEdit" class="textAreaBox es-bc-ff es-br-20 es-mt-20 es-fw-n es-fs-30 es-c-33 x-c es-pl-20 es-pt-20">
  40. <textarea class="textArea" :focus="isEdit" :disabled="noteType==2" v-model="noteData.content" placeholder-style="color:#999" placeholder="请填写笔记内容"/>
  41. </view>
  42. <view v-if="isEdit" class="btn-box">
  43. <view class="sub-btn" @click="doSend()">保存</view>
  44. </view>
  45. </view>
  46. </mescroll-body>
  47. </view>
  48. </template>
  49. <script>
  50. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  51. import mescrollBody from "@/uni_modules/mescroll-uni/components/mescroll-body/mescroll-body.vue";
  52. import { getDictByKey } from '@/api/common'
  53. import { editCourseNote,getMyCourseNoteByNoteId,delCourseNote } from '@/api/course'
  54. export default {
  55. mixins: [MescrollMixin], // 使用mixin
  56. components: {
  57. mescrollBody,
  58. },
  59. data() {
  60. return {
  61. headerHeight:44,
  62. statusBarBG:"none",
  63. headerIndex:98,
  64. downOption: { //下拉刷新
  65. auto: false, // 不自动加载 (mixin已处理第一个tab触发downCallback)
  66. use:false
  67. },
  68. upOption: { //上拉加载
  69. auto: false, // 不自动加载
  70. use:false,
  71. page: {
  72. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  73. size: 10 // 每页数据的数量
  74. },
  75. noMoreSize: 5, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认5
  76. empty: {
  77. tip: '~ 空空如也 ~' // 提示
  78. // btnText: '去看看'
  79. }
  80. },
  81. dataList:[],
  82. noteId:null,
  83. fixedTop: false,
  84. top:0,
  85. isEdit:false,
  86. noteType:0,
  87. noteData:{"content":"","courseId":0,"noteType":0}
  88. }
  89. },
  90. onPageScroll(e) {
  91. this.top=e.scrollTop;
  92. },
  93. computed: {
  94. // 计算属性的 getter
  95. headerBG:function() {
  96. var top=this.top/88;
  97. return 'rgba(255,92,3, ' + top + ')';
  98. },
  99. },
  100. onShow(){
  101. },
  102. onLoad(options){
  103. this.noteId=options.noteId;
  104. this.noteType=options.noteType;
  105. this.requestData();
  106. },
  107. methods: {
  108. /*下拉刷新的回调 */
  109. downCallback() {
  110. this.mescroll.resetUpScroll();
  111. var that=this;
  112. },
  113. /*上拉加载的回调*/
  114. upCallback(page) {
  115. //this.mescroll.endByPage(1, 1);
  116. //this.mescroll.endSuccess(8,false);
  117. // if (page.num == 1) {
  118. // this.mescroll.endSuccess(8, false);
  119. // } else {
  120. // this.mescroll.endErr()
  121. // }
  122. },
  123. requestData(){
  124. getMyCourseNoteByNoteId(this.noteId).then(res => {
  125. if(res.code==200){
  126. this.noteData=res.data;
  127. }
  128. },
  129. rej => {}
  130. );
  131. },
  132. changeEdit(){
  133. this.isEdit=!this.isEdit;
  134. },
  135. doSend(){
  136. if(this.utils.isEmpty(this.noteData.content)){
  137. uni.showToast({title: '请输入笔记内容',icon: 'none'});
  138. return;
  139. }
  140. uni.showLoading({title:""});
  141. editCourseNote(this.noteData).then(res => {
  142. uni.hideLoading();
  143. if(res.code==200){
  144. uni.showToast({title: res.msg,icon: 'none'});
  145. }else{
  146. uni.showToast({title: res.msg,icon: 'none'});
  147. }
  148. this.isLike=!this.isLike;
  149. //this.isEdit=!this.isEdit;
  150. },
  151. rej => {}
  152. );
  153. },
  154. deleteNote(){
  155. let that=this;
  156. uni.showModal({
  157. title:"系统提示",
  158. content:"确定删除吗?",
  159. cancelText:'取消',
  160. confirmText:'确定',
  161. success: (res) => {
  162. console.log("qxj res:"+JSON.stringify(res));
  163. if (res.confirm) {
  164. that.deleteNoteAction();
  165. }
  166. else if(res.cancel) {
  167. }
  168. },
  169. fail: () => {
  170. uni.hideLoading();
  171. }
  172. });
  173. },
  174. navBack() {
  175. uni.navigateBack({
  176. animationType: 'pop-out',
  177. animationDuration: 200
  178. });
  179. },
  180. deleteNoteAction(){
  181. uni.showLoading({title:""});
  182. delCourseNote({"noteId":this.noteId}).then(res => {
  183. uni.hideLoading();
  184. if(res.code==200){
  185. uni.showToast({title: "删除成功",icon: 'none'});
  186. setTimeout(e => {
  187. this.navBack();
  188. uni.$emit('refreshMyNote', { });
  189. }, 2000);
  190. }else{
  191. uni.showToast({title: res.msg,icon: 'none'});
  192. }
  193. this.isLike=!this.isLike;
  194. },
  195. rej => {}
  196. );
  197. },
  198. }
  199. }
  200. </script>
  201. <style scoped lang="scss">
  202. page{
  203. height: 100%;
  204. background-color: #f7f7f7;
  205. }
  206. .grace-page-header {
  207. position: fixed;
  208. width: 100%;
  209. left: 0;
  210. top: 0;
  211. z-index: 98;
  212. border-bottom: 0px solid #FFFFFF;
  213. .grace-page-status-bar {
  214. width: 100%;
  215. height: var(--status-bar-height);
  216. }
  217. .grace-page-header-nav {
  218. width: 100%;
  219. display: flex;
  220. flex-direction: row;
  221. flex-wrap: nowrap;
  222. align-items: center;
  223. justify-content: space-between;
  224. }
  225. .grace-header-main {
  226. width: 300rpx;
  227. flex: auto;
  228. overflow: hidden;
  229. margin:0 20rpx;
  230. height: 48rpx;
  231. text-align: center;
  232. color: #fff;
  233. }
  234. }
  235. .u-nav-left{
  236. display: flex;
  237. justify-content: space-between;
  238. align-items: center;
  239. margin-left: 25rpx;
  240. .back{
  241. width: 18rpx;
  242. height: 31rpx;
  243. }
  244. }
  245. .u-nav-right{
  246. position: absolute;
  247. right:20rpx;
  248. display: flex;
  249. justify-content: space-between;
  250. align-items: center;
  251. .right-icon{
  252. width: 27rpx;
  253. height: 29rpx;
  254. margin-right: 30rpx;
  255. }
  256. .edit{
  257. color: #fff;
  258. font-size: 34rpx;
  259. margin-right: 10rpx;
  260. font-weight: normal;
  261. }
  262. }
  263. .bg-img{
  264. position: fixed;
  265. width: 100%;
  266. height: 524rpx;
  267. top: 0;
  268. left: 0;
  269. right: 0;
  270. bottom: 0;
  271. z-index: 0;
  272. }
  273. .nav_box{
  274. width: 100%;
  275. .status_bar {
  276. height: var(--status-bar-height);
  277. width: 100%;
  278. }
  279. .nav_bar {
  280. height: 44px;
  281. width: 100%;
  282. }
  283. }
  284. .search-box {
  285. width: calc(100% - 60rpx);
  286. height: 70rpx;
  287. display: flex;
  288. flex-direction: row;
  289. align-items: center;
  290. justify-content: space-between;
  291. background: #fff;
  292. border-radius: 35rpx;
  293. margin:30rpx;
  294. margin-top: 10rpx;
  295. padding-left: 30rpx;
  296. position: relative;
  297. z-index: 10;
  298. .left{
  299. display: flex;
  300. flex-direction: row;
  301. align-items: center;
  302. justify-content: flex-start;
  303. }
  304. image{
  305. width: 28upx;
  306. height: 28upx;
  307. margin-right: 16upx;
  308. }
  309. .input-text{
  310. color: #333;
  311. font-size: 24rpx;
  312. height: 70rpx;
  313. line-height:70rpx ;
  314. }
  315. .uni-input-placeholder{
  316. color:#999;
  317. }
  318. .button{
  319. background: #FF5C03;
  320. border-radius: 29rpx;
  321. width: 108rpx;
  322. height: 54rpx;
  323. line-height: 54rpx;
  324. color: #fff;
  325. font-size: 26rpx;
  326. margin-right: 10rpx;
  327. }
  328. }
  329. .cover{
  330. height:300rpx ;
  331. width: 100%;
  332. border-radius: 20rpx;
  333. }
  334. .title{
  335. color:#0173FF;
  336. }
  337. .calendar{
  338. background-color:#FFE8DC ;
  339. width: 60rpx;
  340. height: 60rpx;
  341. border-radius: 50%;
  342. }
  343. .textAreaBox{
  344. background-color: #fff;
  345. padding-left: 15rpx;
  346. padding-right: 15rpx;
  347. height: 200px;
  348. }
  349. .textArea{
  350. background-color: #fff;
  351. border-radius: 10rpx;
  352. width: 100%;
  353. height: 100%;
  354. font-size: 30rpx;
  355. }
  356. .btn-box{
  357. margin-top: 15rpx;
  358. height: 120upx;
  359. padding: 0 30upx;
  360. display: flex;
  361. align-items: center;
  362. justify-content: center;
  363. .sub-btn{
  364. width: 100%;
  365. height: 88upx;
  366. line-height: 88upx;
  367. text-align: center;
  368. font-size: 30upx;
  369. font-family: PingFang SC;
  370. font-weight: bold;
  371. color: #FFFFFF;
  372. background: #FF5C03;
  373. border-radius: 44upx;
  374. }
  375. }
  376. </style>