msg.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  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. current: 0, //消息页面切换
  152. info1: "info1", //类名
  153. info2: "info2",
  154. msgn: 0,
  155. msgn2: 0,
  156. clLoading: 0,
  157. sysLoading: 0,
  158. clcurrentPage: 1, //页数
  159. syscurrentPage: 1, //页数
  160. };
  161. },
  162. methods: {
  163. // 获取消息通知数据
  164. gotoHome() {
  165. const url = "https://mp.weixin.qq.com/s/QZEGcvBn3aW7aHirMFLBQA";
  166. uni.navigateTo({
  167. url: "/pages/skipone/skipone?url=" + encodeURIComponent(url),
  168. });
  169. // uni.switchTab({
  170. // url:'/pages/index/index'
  171. // })
  172. },
  173. getdata() {
  174. let data = {
  175. oid: this.$store.state.user.openid, //用户id
  176. ty: 0,
  177. page: this.clcurrentPage,
  178. lim: 15
  179. }
  180. this.$request('/selectMessage', "POST", data).then(res => {
  181. console.log('获取消息通知数据', res);
  182. if (!res[0].length) {
  183. this.clLoading = 2
  184. } else {
  185. this.clLoading = 0
  186. }
  187. this.Msglist = [...this.Msglist, ...res[0]]
  188. })
  189. },
  190. // 获取系统通知数据
  191. getdata2() {
  192. let data = {
  193. oid: this.$store.state.user.openid, //用户id
  194. ty: 1,
  195. page: this.syscurrentPage,
  196. lim: 15
  197. }
  198. this.$request('/selectMessage', "POST", data).then(res => {
  199. console.log('获取系统通知数据', res);
  200. if (!res[0].length) {
  201. this.sysLoading = 2
  202. } else {
  203. this.sysLoading = 0
  204. }
  205. this.syslist = [...this.syslist, ...res[0]]
  206. })
  207. },
  208. // 点击单个已读
  209. readOneMsg(e) {
  210. const data = e.currentTarget.dataset.id
  211. console.log(data);
  212. let a = {
  213. openid: this.$store.state.user.openid, //用户id
  214. id: data.id
  215. }
  216. if (data.isread == 0) {
  217. this.$request('/updateOneIsRead', "POST", a).then(res => {
  218. console.log(res);
  219. this.getMag()
  220. // 去除信息列表右上未读红点,current判断所在哪个消息列表
  221. if (this.current == 0) {
  222. this.Msglist.forEach(e => {
  223. if (data.id == e.id) {
  224. e.isread = 1
  225. }
  226. })
  227. } else {
  228. this.syslist.forEach(e => {
  229. if (data.id == e.id) {
  230. e.isread = 1
  231. }
  232. })
  233. }
  234. })
  235. }
  236. },
  237. gotoDetail(e) {
  238. // console.log('e',e.currentTarget.dataset.link);
  239. let aid = e.currentTarget.dataset.link.acId;
  240. uni.navigateTo({
  241. url: `/pages/activityDetailNew/activityDetailNew?acId=${aid}`
  242. });
  243. // uni.navigateTo({
  244. // url: "/pages/skipone/skipone?url=" + encodeURIComponent(link),
  245. // });
  246. // let cid=e.currentTarget.dataset.link
  247. // console.log(e.currentTarget.dataset.cid);
  248. // uni.navigateTo({
  249. // url: `/pages/activityDetailNew/activityDetailNew?acId=${cid}`
  250. // })
  251. },
  252. // 消息通知触底
  253. informlower() {
  254. console.log('没触底?');
  255. if (this.clLoading == 2) return
  256. this.clLoading = 1
  257. this.clcurrentPage++
  258. setTimeout(this.getdata, 1000)
  259. },
  260. // 系统通知触底
  261. syslower() {
  262. console.log('没触底?');
  263. if (this.sysLoading == 2) return
  264. this.sysLoading = 1
  265. this.syscurrentPage++
  266. setTimeout(this.getdata2, 1000)
  267. },
  268. // 更新已读
  269. updateisread() {
  270. this.showPopup = true
  271. },
  272. // 弹窗确认已读
  273. conf() {
  274. let data = {
  275. oid: this.$store.state.user.openid, //用户id
  276. type: this.current,
  277. }
  278. this.$request('/updateIsRead', "POST", data).then(res => {
  279. // console.log('获取', res);
  280. // 未读提示红点重置为0,在后面赋值
  281. // this.msgn = 0
  282. // this.msgn2 = 0
  283. // 调用方法赋值未读红点
  284. this.getMag()
  285. // 去除信息列表右上未读红点,current判断所在哪个消息列表
  286. if (this.current == 0) {
  287. this.Msglist.forEach(e => {
  288. e.isread = 1
  289. })
  290. } else {
  291. this.syslist.forEach(e => {
  292. e.isread = 1
  293. })
  294. }
  295. this.showPopup = false
  296. })
  297. },
  298. // 获取未读信息
  299. getMag() {
  300. this.$request('/selectUnreadMsg', "POST", {
  301. oid: this.$store.state.user.openid
  302. }).then(res => {
  303. console.log('获取未读信息', res);
  304. // 未读提示红点重置为0,在后面赋值
  305. this.msgn = 0
  306. this.msgn2 = 0
  307. // 获取全部未读信息
  308. let arr = res[0]
  309. if (arr.length != 0) {
  310. // 遍历未读信息,展示信息切换栏右上红点信息
  311. arr.forEach(e => {
  312. if (e.type == 0) {
  313. this.msgn = res[0][0].msg
  314. } else if (e.type == 1 && arr.length == 2) {
  315. this.msgn2 = res[0][1].msg
  316. } else if (e.type == 1 && arr.length == 1) {
  317. this.msgn2 = res[0][0].msg
  318. }
  319. })
  320. }
  321. })
  322. },
  323. // 切换消息页面
  324. puMsg() {
  325. this.current = 0;
  326. },
  327. sysMsg() {
  328. this.current = 1;
  329. },
  330. swipeIndex(index) {
  331. this.current = index.detail.current;
  332. },
  333. },
  334. onShow() {
  335. // 消息通知
  336. this.Msglist = []
  337. //系统通知
  338. this.syslist = []
  339. this.getdata()
  340. this.getdata2()
  341. this.getMag()
  342. }
  343. }
  344. </script>
  345. <style lang="scss">
  346. .msg {
  347. display: flex;
  348. flex-direction: column;
  349. flex: 1;
  350. justify-content: space-between;
  351. width: 750rpx;
  352. height: 100vh;
  353. .allRead {
  354. position: fixed;
  355. font-size: 20rpx;
  356. width: 90rpx;
  357. height: 90rpx;
  358. border-radius: 50%;
  359. text-align: center;
  360. line-height: 90rpx;
  361. background-color: rgba(0, 86, 168, 1);
  362. color: #fff;
  363. right: 70rpx;
  364. z-index: 10;
  365. bottom: 100rpx;
  366. }
  367. .loading {
  368. height: 30rpx;
  369. text-align: center;
  370. padding-top: 20rpx;
  371. padding-bottom: 100rpx;
  372. font-size: 26rpx;
  373. color: #888;
  374. line-height: 2em;
  375. }
  376. .top {
  377. display: flex;
  378. justify-content: space-between;
  379. margin: auto;
  380. width: 100%;
  381. background-color: #ffffff;
  382. padding: 10px 20%;
  383. // position: relative;
  384. .msgq {
  385. width: 32rpx;
  386. height: 32rpx;
  387. background-color: rgba(213, 73, 65, 1);
  388. border-radius: 50rpx;
  389. color: #fff;
  390. font-size: 20rpx;
  391. display: flex;
  392. justify-content: center;
  393. align-items: center;
  394. position: absolute;
  395. top: -10rpx;
  396. right: -20rpx;
  397. font-weight: normal !important;
  398. }
  399. .info1 {
  400. font-weight: bold !important;
  401. position: relative;
  402. color: rgba(0, 0, 0, 0.8);
  403. font-size: 34rpx;
  404. line-height: 48rpx;
  405. width: 136rpx;
  406. height: 48rpx;
  407. text-align: center;
  408. .yun {
  409. width: 134rpx;
  410. height: 32rpx;
  411. position: absolute;
  412. left: 0;
  413. bottom: -10rpx;
  414. image {
  415. width: 100%;
  416. height: 100%;
  417. }
  418. }
  419. }
  420. .info2 {
  421. color: rgba(0, 0, 0, 0.6);
  422. font-size: 34rpx;
  423. font-weight: 400;
  424. line-height: 48rpx;
  425. width: 136rpx;
  426. height: 48rpx;
  427. text-align: center;
  428. font-family: 微软雅黑;
  429. }
  430. }
  431. .scroll-view-height {
  432. padding: 20rpx 0;
  433. flex: 1;
  434. .msgBlock {
  435. width: 720rpx;
  436. margin: auto;
  437. background-color: #ffffff;
  438. border-radius: 12px;
  439. padding: 28rpx 24rpx 32rpx 24rpx;
  440. margin-bottom: 20rpx;
  441. position: relative;
  442. .dian {
  443. position: absolute;
  444. right: 10rpx;
  445. top: -20rpx;
  446. font-size: 60rpx;
  447. color: rgba(213, 73, 65, 1);
  448. }
  449. .tit {
  450. font-size: 34rpx;
  451. font-weight: 400;
  452. height: 48rpx;
  453. line-height: 48rpx;
  454. margin-bottom: 20rpx;
  455. color: rgba(0, 0, 0, 0.8);
  456. display: flex;
  457. justify-content: space-between;
  458. .msgtime {
  459. line-height: 58rpx;
  460. font-size: 28rpx;
  461. color: rgba(0, 0, 0, 0.4);
  462. }
  463. }
  464. .contxt {
  465. text-indent: 2em;
  466. color: rgba(0, 0, 0, 0.6);
  467. font-size: 28rpx;
  468. line-height: 40rpx;
  469. }
  470. .contxt1 {
  471. color: rgba(0, 0, 0, 0.6);
  472. font-size: 28rpx;
  473. margin-top: 10rpx;
  474. line-height: 40rpx;
  475. display: flex;
  476. .uiTit {
  477. display: flex;
  478. .uiAcTit {
  479. width: auto;
  480. // width: 120rpx;
  481. // flex-shrink: 0;
  482. }
  483. }
  484. }
  485. }
  486. }
  487. }
  488. </style>