123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- // 微信端
- function iosBackRefresh () {
- var isPageHide = false
- window.addEventListener('pageshow', function () {
- if (isPageHide) {
- location.reload()
- }
- })
- window.addEventListener('pagehide', function () {
- isPageHide = true
- })
- }
- var temp = '<div class="side-line" v-if="lists.length"><div class="list-msg"><div class="l-msg"><div class="words" v-for="item in lists" :key="item.id"><img class="dot-img" src="../images/no-read-dot.png" v-if="item.isRead == 0"><img class="dot-img" src="../images/read-dot.png" v-else><h3 :class="{isActive: item.isRead == 0}">@@item.msg_type@@</h3><span @click="titleGoto(item)">@@item.title@@</span><p>@@item.createtime@@</p></div></div><img @click="gotoUrl" class="r-msg" src="../images/jyxia.png"></div></div>'
- var vm = new Vue({
- el: '#vue-message-index-app',
- delimiters: ['@@', '@@'],
- template: temp,
- data: function () {
- return {
- lists: []
- }
- },
- created() {
- this.getList()
- },
- mounted() {
- iosBackRefresh()
- },
- methods: {
- getList() {
- var _this = this
- $.ajax({
- type:'POST',
- url:'/jymessageCenter/latestNews',
- success:function (res) {
- if (res.data) {
- res.data.forEach(v => {
- v.msg_type = _this.msgType(v.msg_type)
- v.createtime = dateMatter(v.createtime, 'out')
- })
- _this.lists = res.data
- }
- }
- })
- },
- topRead(ids, url, type) {
- const _this = this
- $.ajax({
- type: 'POST',
- url:'/jymessageCenter/markRead',
- data: {
- msgId: ids,
- msgType: type
- },
- success:function () {
- if (url) {
- window.open(url)
- } else {
- _this.getList()
- }
- }
- })
- },
- titleGoto(item) {
- let wxType = getType()
- let appType = androidOrIOS()
- let urls = item.url
- if (wxType) {
- if (item.isRead == 0) {
- this.topRead(item.id, urls.weChatUrl, item.msg_type)
- } else {
- if (urls.weChatUrl) {
- //链接中如果是www.jianyu360.cn域名,微信中会唤起app,该用window.open
- window.open(urls.weChatUrl)
- } else {
- return
- }
- }
- } else {
- if (appType == 'android') {
- if (item.isRead == 0) {
- this.topRead(item.id, urls.androidUrl, item.msg_type)
- } else {
- if (urls.androidUrl) {
- location.href = urls.androidUrl
- } else {
- return
- }
- }
- } else {
- if (item.isRead == 0) {
- this.topRead(item.id, urls.iosUrl, item.msg_type)
- } else {
- if (urls.iosUrl) {
- location.href = urls.iosUrl
- } else {
- return
- }
- }
- }
- }
- },
- gotoUrl() {
- // location.href = '/weixin/frontPage/messageCenter/sess/index?msg=2'
- window.open('/weixin/frontPage/messageCenter/sess/index?msg=2')
- },
- msgType(val) {
- const obj = {
- '1': '活动优惠',
- '2': '服务通知',
- '3': '订阅消息',
- '4': '项目动态 ',
- '5': '企业动态',
- '6': '分析报告 ',
- '7': '系统通知',
- }
- return obj[val]
- }
- }
- })
|