msg.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542
  1. <template>
  2. <view class="msg">
  3. <statusBar :item="navBarData"></statusBar>
  4. <view class="allRead" @click="updateisread">
  5. 一键已读
  6. </view>
  7. <view class="top">
  8. <view class="left" @click="puMsg" :class="current == 0 ? info1 : info2">
  9. <view class="" style="position: relative;">
  10. <view class="msgq" v-if="msgn>0">
  11. {{msgn}}
  12. </view>
  13. <text>消息通知</text>
  14. </view>
  15. <view v-if="current == 0" class="yun">
  16. <image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 10.png"
  17. mode="aspectFill"></image>
  18. </view>
  19. </view>
  20. <view class="right" @click="sysMsg" :class="current == 1 ? info1 : info2">
  21. <view class="" style="position: relative;">
  22. <view class="msgq" v-if="msgn2>0">
  23. {{msgn2}}
  24. </view>
  25. <text>系统通知</text>
  26. </view>
  27. <view v-if="current == 1" class="yun">
  28. <image src="https://teacherapi.cocorobo.cn/teaching-file/static//yym/Ellipse 10.png"
  29. mode="aspectFill"></image>
  30. </view>
  31. </view>
  32. </view>
  33. <swiper class="scroll-view-height" @change="swipeIndex" :current="current" :duration="300">
  34. <swiper-item>
  35. <scroll-view scroll-y="true" @scrolltolower="informlower" style="height: 100%;">
  36. <view class="">
  37. <view class="" v-for="(item,index) in Msglist" :key="index">
  38. <view class="msgBlock" @click="readOneMsg" :data-id="item">
  39. <view class="dian" v-if="!item.isread">•</view>
  40. <view class="tit">
  41. <view>活动报名成功</view>
  42. <view class="msgtime">
  43. {{item.create_at}}
  44. </view>
  45. </view>
  46. <view class="contxt">恭喜!您已成功完成<text style="color: rgba(0, 86, 168, 1);"
  47. @click.stop="gotoDetail"
  48. :data-link="item">“{{item.acName}}”</text>活动报名。您的参与信息已经成功提交,您现在是我们活动的一部分,我们非常期待与您共度美好时光。
  49. </view>
  50. <!-- <view class="contxt">
  51. 以下是一些额外信息,以确保您充分了解您的参与:
  52. </view> -->
  53. <!-- <view class="contxt1">
  54. <view class="" style="width: 2em;text-align: center;">•</view>
  55. <view class="uiTit"> <view class="uiAcTit">活动名称:</view> [{{item.acName}}]</view>
  56. </view> -->
  57. <!-- <view class="contxt1" style="display: flex;">
  58. <view class="" style="width: 2em;text-align: center;">•</view>
  59. <view class=""> 日期: [{{item.begin_at}}]</view>
  60. </view> -->
  61. <view class="contxt1">
  62. <view class="" style="width: 2em;flex-shrink: 1; text-align: center;">•</view>
  63. <view class="uiTit">
  64. <view class="uiAcTit">时间:</view> [{{item.begin_at}}]
  65. </view>
  66. </view>
  67. <!-- <view class="contxt1" >
  68. <view class="" style="width: 2em;text-align: center;">•</view>
  69. <view class="uiTit"> <view class="uiAcTit">地点:</view> [{{item.address}}]</view>
  70. </view>
  71. <view class="contxt1" >
  72. <view class="" style="width: 2em;text-align: center;">•</view>
  73. <view class="uiTit"> <view class="uiAcTit">活动形式:</view> [{{item.acshape}}]</view>
  74. </view> -->
  75. </view>
  76. <view class="msgBlock" v-if="item.type==1" @click="readOneMsg" :data-id="item">
  77. <view class="dian" v-if="!item.isread">•</view>
  78. <view class="tit">
  79. <view>活动开始提醒</view>
  80. <text class="msgtime">{{item.create_at}}</text>
  81. </view>
  82. <view class="contxt">
  83. <text style="color: rgba(0, 86, 168, 1);">“丽湖职教双创教育国际虚拟教研室 • 常规教研活动
  84. 第9期”</text>活动现在已经在我们的平台上正式上线,欢迎您点击浏览和积极参加。不要错过这个令人兴奋的机会,我们期待着与您一同度过难忘的时光。点击活动名称进入活动详情哦!
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <view class="loading">
  90. <view v-if="clLoading==1">数据加载中...</view>
  91. <view v-if="clLoading==2">没有更多了~~</view>
  92. </view>
  93. </scroll-view>
  94. </swiper-item>
  95. <swiper-item>
  96. <scroll-view scroll-y="true" @scrolltolower="syslower" style="height: 100%;">
  97. <view class="">
  98. <view class="" v-for="(item,index) in syslist" :key="index">
  99. <view class="msgBlock" @click="readOneMsg" :data-id="item">
  100. <view class="dian" v-if="!item.isread">•</view>
  101. <view class="tit">
  102. <view>恭喜您,成功加入会员</view>
  103. <text class="msgtime">{{item.create_at}}</text>
  104. </view>
  105. <view class="contxt1">
  106. 尊敬的<text style="color: rgba(0, 86, 168, 1);">{{item.username}}</text>,
  107. </view>
  108. <view class="contxt">
  109. 我们很高兴通知您,您已成功加入<text style="color: rgba(0, 86, 168, 1);"
  110. @click="gotoHome">[丽湖国际双创虚拟教研室小程序会员]</text>!欢迎加入我们的团队,我们期待与您一同合作并参与。
  111. </view>
  112. </view>
  113. </view>
  114. </view>
  115. <view class="loading">
  116. <view v-if="sysLoading==1">数据加载中...</view>
  117. <view v-if="sysLoading==2">没有更多了~~</view>
  118. </view>
  119. </scroll-view>
  120. </swiper-item>
  121. </swiper>
  122. <!-- 弹窗 -->
  123. <view style="width: 750rpx;height: 100vh;background-color: rgba(0, 0, 0, .5);padding: 0;position: absolute;"
  124. v-show="showPopup">
  125. <!-- <view class="mask" v-show="showPopup" @click="closePopup"></view> -->
  126. <view class="popup-container">
  127. <view class="popup">
  128. <view class="header">
  129. <text>确认一键已读?</text>
  130. </view>
  131. <view class="footer">
  132. <view class="cancel-btn" @click="showPopup=false">取消</view>
  133. <view class="confirm-btn" @click="conf">确认</view>
  134. </view>
  135. </view>
  136. </view>
  137. </view>
  138. </view>
  139. </template>
  140. <script>
  141. export default {
  142. data() {
  143. return {
  144. navBarData: {
  145. title: '活动消息',
  146. btn: 1
  147. },
  148. Msglist: [],
  149. syslist: [],
  150. showPopup: false,
  151. adv: {},
  152. current: 0, //消息页面切换
  153. info1: "info1", //类名
  154. info2: "info2",
  155. msgn: 0,
  156. msgn2: 0,
  157. clLoading: 0,
  158. sysLoading: 0,
  159. clcurrentPage: 1, //页数
  160. syscurrentPage: 1, //页数
  161. };
  162. },
  163. methods: {
  164. // 获取消息通知数据
  165. gotoHome() {
  166. // const url = "https://mp.weixin.qq.com/s/QZEGcvBn3aW7aHirMFLBQA";
  167. const url = this.adv.href
  168. uni.navigateTo({
  169. url: "/pages/skipone/skipone?item=" + encodeURIComponent(JSON.stringify(url))
  170. // url: "/pages/skipone/skipone?url=" + encodeURIComponent(url),
  171. });
  172. // uni.switchTab({
  173. // url:'/pages/index/index'
  174. // })
  175. },
  176. getdata() {
  177. let data = {
  178. oid: this.$store.state.user.openid, //用户id
  179. ty: 0,
  180. page: this.clcurrentPage,
  181. lim: 15
  182. }
  183. this.$request('/selectMessage', "POST", data).then(res => {
  184. // console.log('获取消息通知数据', res);
  185. if (!res[0].length) {
  186. this.clLoading = 2
  187. } else {
  188. this.clLoading = 0
  189. }
  190. if (this.clcurrentPage == 1) {
  191. this.Msglist = []
  192. }
  193. this.Msglist = [...this.Msglist, ...res[0]]
  194. })
  195. },
  196. // 获取系统通知数据
  197. getdata2() {
  198. let data = {
  199. oid: this.$store.state.user.openid, //用户id
  200. ty: 1,
  201. page: this.syscurrentPage,
  202. lim: 15
  203. }
  204. this.$request('/selectMessage', "POST", data).then(res => {
  205. console.log('获取系统通知数据', res);
  206. if (!res[0].length) {
  207. this.sysLoading = 2
  208. } else {
  209. this.sysLoading = 0
  210. }
  211. if (this.syscurrentPage == 1) {
  212. this.syslist = []
  213. }
  214. this.syslist = [...this.syslist, ...res[0]]
  215. })
  216. },
  217. // 点击单个已读
  218. readOneMsg(e) {
  219. const data = e.currentTarget.dataset.id
  220. let a = {
  221. openid: this.$store.state.user.openid, //用户id
  222. id: data.id
  223. }
  224. if (data.isread == 0) {
  225. this.$request('/updateOneIsRead', "POST", a).then(res => {
  226. // console.log(res);
  227. this.getMag()
  228. // 去除信息列表右上未读红点,current判断所在哪个消息列表
  229. if (this.current == 0) {
  230. this.Msglist.forEach(e => {
  231. if (data.id == e.id) {
  232. e.isread = 1
  233. }
  234. })
  235. } else {
  236. this.syslist.forEach(e => {
  237. if (data.id == e.id) {
  238. e.isread = 1
  239. }
  240. })
  241. }
  242. })
  243. }
  244. },
  245. // 去活动详情页
  246. gotoDetail(e) {
  247. // console.log('e',e.currentTarget.dataset.link);
  248. let aid = e.currentTarget.dataset.link.acId;
  249. uni.navigateTo({
  250. url: `/pages/activityDetailNew/activityDetailNew?acId=${aid}`
  251. });
  252. },
  253. // 消息通知触底
  254. informlower() {
  255. console.log('没触底?');
  256. if (this.clLoading == 2) return
  257. this.clLoading = 1
  258. this.clcurrentPage++
  259. setTimeout(()=>{
  260. this.getdata()
  261. }, 1000)
  262. },
  263. // 系统通知触底
  264. syslower() {
  265. console.log('没触底?');
  266. if (this.sysLoading == 2) return
  267. this.sysLoading = 1
  268. this.syscurrentPage++
  269. setTimeout(()=>{
  270. this.getdata2()
  271. }, 1000)
  272. },
  273. // 一键已读
  274. updateisread() {
  275. this.showPopup = true
  276. },
  277. // 弹窗确认一键已读
  278. conf() {
  279. let data = {
  280. oid: this.$store.state.user.openid, //用户id
  281. type: this.current,
  282. }
  283. this.$request('/updateIsRead', "POST", data).then(res => {
  284. // console.log('获取', res);
  285. // 未读提示红点重置为0,在后面赋值
  286. // this.msgn = 0
  287. // this.msgn2 = 0
  288. // 调用方法赋值未读红点
  289. this.getMag()
  290. // 去除信息列表右上未读红点,current判断所在哪个消息列表
  291. if (this.current == 0) {
  292. this.Msglist.forEach(e => {
  293. e.isread = 1
  294. })
  295. } else {
  296. this.syslist.forEach(e => {
  297. e.isread = 1
  298. })
  299. }
  300. this.showPopup = false
  301. })
  302. },
  303. // 获取未读信息条数
  304. getMag() {
  305. this.$request('/selectUnreadMsg', "POST", {
  306. oid: this.$store.state.user.openid
  307. }).then(res => {
  308. console.log('获取未读信息', res);
  309. // 未读提示红点重置为0,在后面赋值
  310. this.msgn = 0 //系统通知
  311. this.msgn2 = 0 //消息通知
  312. // 获取全部未读信息
  313. let arr = res[0]
  314. if (arr.length != 0) {
  315. // 遍历未读信息,展示信息切换栏右上红点信息
  316. arr.forEach(e => {
  317. if (e.type == 0) {
  318. this.msgn = res[0][0].msg
  319. } else if (e.type == 1 && arr.length == 2) {
  320. this.msgn2 = res[0][1].msg
  321. } else if (e.type == 1 && arr.length == 1) {
  322. this.msgn2 = res[0][0].msg
  323. }
  324. })
  325. }
  326. })
  327. },
  328. // 切换消息页面
  329. puMsg() {
  330. this.current = 0;
  331. },
  332. sysMsg() {
  333. this.current = 1;
  334. },
  335. swipeIndex(index) {
  336. this.current = index.detail.current;
  337. },
  338. // 获取顶部大图
  339. getAdv() {
  340. this.$request('/selectAdvertisement', "get", {
  341. typ: 0
  342. }).then(res => {
  343. // console.log(res);
  344. this.adv = res[0][0]
  345. })
  346. }
  347. },
  348. onShow() {
  349. this.syscurrentPage=1
  350. this.clcurrentPage=1
  351. this.getAdv()
  352. // 消息通知
  353. // this.Msglist = []
  354. // 系统通知
  355. // this.syslist = []
  356. this.getdata()
  357. this.getdata2()
  358. this.getMag()
  359. }
  360. }
  361. </script>
  362. <style lang="scss">
  363. .msg {
  364. display: flex;
  365. flex-direction: column;
  366. flex: 1;
  367. justify-content: space-between;
  368. width: 750rpx;
  369. height: 100vh;
  370. .allRead {
  371. position: fixed;
  372. font-size: 20rpx;
  373. width: 90rpx;
  374. height: 90rpx;
  375. border-radius: 50%;
  376. text-align: center;
  377. line-height: 90rpx;
  378. background-color: rgba(0, 86, 168, 1);
  379. color: #fff;
  380. right: 70rpx;
  381. z-index: 10;
  382. bottom: 100rpx;
  383. }
  384. .loading {
  385. height: 30rpx;
  386. text-align: center;
  387. padding-top: 20rpx;
  388. padding-bottom: 100rpx;
  389. font-size: 26rpx;
  390. color: #888;
  391. line-height: 2em;
  392. }
  393. .top {
  394. display: flex;
  395. justify-content: space-between;
  396. margin: auto;
  397. width: 100%;
  398. background-color: #ffffff;
  399. padding: 10px 20%;
  400. // position: relative;
  401. .msgq {
  402. width: 32rpx;
  403. height: 32rpx;
  404. background-color: rgba(213, 73, 65, 1);
  405. border-radius: 50rpx;
  406. color: #fff;
  407. font-size: 20rpx;
  408. display: flex;
  409. justify-content: center;
  410. align-items: center;
  411. position: absolute;
  412. top: -10rpx;
  413. right: -20rpx;
  414. font-weight: normal !important;
  415. }
  416. .info1 {
  417. font-weight: bold !important;
  418. position: relative;
  419. color: rgba(0, 0, 0, 0.8);
  420. font-size: 34rpx;
  421. line-height: 48rpx;
  422. width: 136rpx;
  423. height: 48rpx;
  424. text-align: center;
  425. .yun {
  426. width: 134rpx;
  427. height: 32rpx;
  428. position: absolute;
  429. left: 0;
  430. bottom: -10rpx;
  431. image {
  432. width: 100%;
  433. height: 100%;
  434. }
  435. }
  436. }
  437. .info2 {
  438. color: rgba(0, 0, 0, 0.6);
  439. font-size: 34rpx;
  440. font-weight: 400;
  441. line-height: 48rpx;
  442. width: 136rpx;
  443. height: 48rpx;
  444. text-align: center;
  445. // font-family: 微软雅黑;
  446. }
  447. }
  448. .scroll-view-height {
  449. padding: 20rpx 0;
  450. flex: 1;
  451. .msgBlock {
  452. width: 720rpx;
  453. margin: auto;
  454. background-color: #ffffff;
  455. border-radius: 12px;
  456. padding: 28rpx 24rpx 32rpx 24rpx;
  457. margin-bottom: 20rpx;
  458. position: relative;
  459. .dian {
  460. position: absolute;
  461. right: 10rpx;
  462. top: -20rpx;
  463. font-size: 60rpx;
  464. color: rgba(213, 73, 65, 1);
  465. }
  466. .tit {
  467. font-size: 34rpx;
  468. font-weight: 400;
  469. height: 48rpx;
  470. line-height: 48rpx;
  471. margin-bottom: 20rpx;
  472. color: rgba(0, 0, 0, 0.8);
  473. display: flex;
  474. justify-content: space-between;
  475. .msgtime {
  476. line-height: 58rpx;
  477. font-size: 28rpx;
  478. color: rgba(0, 0, 0, 0.4);
  479. }
  480. }
  481. .contxt {
  482. text-indent: 2em;
  483. color: rgba(0, 0, 0, 0.6);
  484. font-size: 28rpx;
  485. line-height: 40rpx;
  486. }
  487. .contxt1 {
  488. color: rgba(0, 0, 0, 0.6);
  489. font-size: 28rpx;
  490. margin-top: 10rpx;
  491. line-height: 40rpx;
  492. display: flex;
  493. .uiTit {
  494. display: flex;
  495. .uiAcTit {
  496. width: auto;
  497. // width: 120rpx;
  498. // flex-shrink: 0;
  499. }
  500. }
  501. }
  502. }
  503. }
  504. }
  505. </style>