msg.vue 14 KB

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