myNote.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408
  1. <template>
  2. <view class="content-box" >
  3. <image class="bg-img" src="/static/image/home/home_top_bg.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/other/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/image/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="goDetail" class="cover" :src="noteData.imgUrl" mode="scaleToFill"></image>
  28. <view @tap="goDetail" class="title es-fw-500 es-fs-30 es-mb-20">{{noteData.courseName}}</view>
  29. <view @tap="goDetail" 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/image/course/calendar.png"></image>
  33. </view>
  34. <view class="es-ml-20 es-mt-20 es-fw-500 es-fs-24 es-c-99">{{ $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.$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. deleteNoteAction(){
  175. uni.showLoading({title:""});
  176. delCourseNote({"noteId":this.noteId}).then(res => {
  177. uni.hideLoading();
  178. if(res.code==200){
  179. uni.showToast({title: "删除成功",icon: 'none'});
  180. setTimeout(e => {
  181. this.$navBack();
  182. uni.$emit('refreshMyNote', { });
  183. }, 2000);
  184. }else{
  185. uni.showToast({title: res.msg,icon: 'none'});
  186. }
  187. this.isLike=!this.isLike;
  188. },
  189. rej => {}
  190. );
  191. },
  192. goDetail() {
  193. if(this.noteData.courseIsDel == 1 || this.noteData.courseIsShow == 0) {
  194. uni.showToast({
  195. title: '该课程已下架',
  196. icon: 'error'
  197. })
  198. return
  199. }
  200. this.$navTo('./info?courseId='+this.noteData.courseId)
  201. }
  202. }
  203. }
  204. </script>
  205. <style scoped lang="scss">
  206. page{
  207. height: 100%;
  208. background-color: #f7f7f7;
  209. }
  210. .grace-page-header {
  211. position: fixed;
  212. width: 100%;
  213. left: 0;
  214. top: 0;
  215. z-index: 98;
  216. border-bottom: 0px solid #FFFFFF;
  217. .grace-page-status-bar {
  218. width: 100%;
  219. height: var(--status-bar-height);
  220. }
  221. .grace-page-header-nav {
  222. width: 100%;
  223. display: flex;
  224. flex-direction: row;
  225. flex-wrap: nowrap;
  226. align-items: center;
  227. justify-content: space-between;
  228. }
  229. .grace-header-main {
  230. width: 300rpx;
  231. flex: auto;
  232. overflow: hidden;
  233. margin:0 20rpx;
  234. height: 48rpx;
  235. text-align: center;
  236. color: #fff;
  237. }
  238. }
  239. .u-nav-left{
  240. display: flex;
  241. justify-content: space-between;
  242. align-items: center;
  243. margin-left: 25rpx;
  244. .back{
  245. width: 18rpx;
  246. height: 31rpx;
  247. }
  248. }
  249. .u-nav-right{
  250. position: absolute;
  251. right:20rpx;
  252. display: flex;
  253. justify-content: space-between;
  254. align-items: center;
  255. .right-icon{
  256. width: 27rpx;
  257. height: 29rpx;
  258. margin-right: 30rpx;
  259. }
  260. .edit{
  261. color: #fff;
  262. font-size: 34rpx;
  263. margin-right: 10rpx;
  264. font-weight: normal;
  265. }
  266. }
  267. .bg-img{
  268. position: fixed;
  269. width: 100%;
  270. height: 524rpx;
  271. top: 0;
  272. left: 0;
  273. right: 0;
  274. bottom: 0;
  275. z-index: 0;
  276. }
  277. .nav_box{
  278. width: 100%;
  279. .status_bar {
  280. height: var(--status-bar-height);
  281. width: 100%;
  282. }
  283. .nav_bar {
  284. height: 44px;
  285. width: 100%;
  286. }
  287. }
  288. .search-box {
  289. width: calc(100% - 60rpx);
  290. height: 70rpx;
  291. display: flex;
  292. flex-direction: row;
  293. align-items: center;
  294. justify-content: space-between;
  295. background: #fff;
  296. border-radius: 35rpx;
  297. margin:30rpx;
  298. margin-top: 10rpx;
  299. padding-left: 30rpx;
  300. position: relative;
  301. z-index: 10;
  302. .left{
  303. display: flex;
  304. flex-direction: row;
  305. align-items: center;
  306. justify-content: flex-start;
  307. }
  308. image{
  309. width: 28upx;
  310. height: 28upx;
  311. margin-right: 16upx;
  312. }
  313. .input-text{
  314. color: #333;
  315. font-size: 24rpx;
  316. height: 70rpx;
  317. line-height:70rpx ;
  318. }
  319. .uni-input-placeholder{
  320. color:#999;
  321. }
  322. .button{
  323. background: #FF5C03;
  324. border-radius: 29rpx;
  325. width: 108rpx;
  326. height: 54rpx;
  327. line-height: 54rpx;
  328. color: #fff;
  329. font-size: 26rpx;
  330. margin-right: 10rpx;
  331. }
  332. }
  333. .cover{
  334. height:300rpx ;
  335. width: 100%;
  336. border-radius: 20rpx;
  337. }
  338. .title{
  339. color:#0173FF;
  340. }
  341. .calendar{
  342. background-color:#FFE8DC ;
  343. width: 60rpx;
  344. height: 60rpx;
  345. border-radius: 50%;
  346. }
  347. .textAreaBox{
  348. background-color: #fff;
  349. padding-left: 15rpx;
  350. padding-right: 15rpx;
  351. height: 200px;
  352. }
  353. .textArea{
  354. background-color: #fff;
  355. border-radius: 10rpx;
  356. width: 100%;
  357. height: 100%;
  358. font-size: 30rpx;
  359. }
  360. .btn-box{
  361. margin-top: 15rpx;
  362. height: 120upx;
  363. padding: 0 30upx;
  364. display: flex;
  365. align-items: center;
  366. justify-content: center;
  367. .sub-btn{
  368. width: 100%;
  369. height: 88upx;
  370. line-height: 88upx;
  371. text-align: center;
  372. font-size: 30upx;
  373. font-family: PingFang SC;
  374. font-weight: bold;
  375. color: #FFFFFF;
  376. background: #FF5C03;
  377. border-radius: 44upx;
  378. }
  379. }
  380. </style>