|
@@ -29,21 +29,20 @@ Page({
|
|
},
|
|
},
|
|
{
|
|
{
|
|
icon: 'guide@2x.png',
|
|
icon: 'guide@2x.png',
|
|
- name: '选购指南',
|
|
|
|
- path: 'guide'
|
|
|
|
|
|
+ name: '全部产品',
|
|
|
|
+ path: 'goods'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
icon: 'collection@2x.png',
|
|
icon: 'collection@2x.png',
|
|
name: '收藏',
|
|
name: '收藏',
|
|
path: 'collection'
|
|
path: 'collection'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ icon: 'news.png',
|
|
|
|
+ name: '选购指南',
|
|
|
|
+ path: 'guide'
|
|
}
|
|
}
|
|
],
|
|
],
|
|
- objNews: {
|
|
|
|
- icon: 'news.png',
|
|
|
|
- name: '农事天地',
|
|
|
|
- path: 'news'
|
|
|
|
- },
|
|
|
|
- hasNewsTab: false,
|
|
|
|
categoryList: [],
|
|
categoryList: [],
|
|
leftList: [],
|
|
leftList: [],
|
|
rightList: []
|
|
rightList: []
|
|
@@ -64,19 +63,13 @@ Page({
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
*/
|
|
onReady() {
|
|
onReady() {
|
|
- this.setData({
|
|
|
|
- hasNewsTab: this.getTabBar().data.list.findIndex(item => item.pagePath === 'pages/news/news') > -1
|
|
|
|
- })
|
|
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
*/
|
|
onShow() {
|
|
onShow() {
|
|
- const that = this
|
|
|
|
- this.getTabBar().init((value) => {
|
|
|
|
- console.log(value)
|
|
|
|
- })
|
|
|
|
|
|
+ this.getTabBar().init()
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -241,7 +234,9 @@ Page({
|
|
handleNav(item) {
|
|
handleNav(item) {
|
|
if (Object.prototype.toString.call(item) === '[object Object]' && item.path) {
|
|
if (Object.prototype.toString.call(item) === '[object Object]' && item.path) {
|
|
const path = item.path
|
|
const path = item.path
|
|
-
|
|
|
|
|
|
+ if (!path) {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
if (path === 'news' || path === 'partner') {
|
|
if (path === 'news' || path === 'partner') {
|
|
wx.switchTab({
|
|
wx.switchTab({
|
|
url: `/pages/${path}/${path}`
|
|
url: `/pages/${path}/${path}`
|
|
@@ -274,38 +269,46 @@ Page({
|
|
const moIdState = subscriptionsSetting.itemSettings[tmplIds]
|
|
const moIdState = subscriptionsSetting.itemSettings[tmplIds]
|
|
if (moIdState === 'accept') {
|
|
if (moIdState === 'accept') {
|
|
// 接受了消息推送
|
|
// 接受了消息推送
|
|
|
|
+ that.handleNav(item)
|
|
} else if (moIdState === 'reject') {
|
|
} else if (moIdState === 'reject') {
|
|
// 拒绝消息推送
|
|
// 拒绝消息推送
|
|
|
|
+ that.handleNav(item)
|
|
} else if (moIdState === 'ban') {
|
|
} else if (moIdState === 'ban') {
|
|
// 已被后台封禁
|
|
// 已被后台封禁
|
|
|
|
+ that.handleNav(item)
|
|
|
|
+ } else {
|
|
|
|
+ that.handleSubscribeMessageBridge(tmplIds, item)
|
|
}
|
|
}
|
|
-
|
|
|
|
- that.handleNav(item)
|
|
|
|
} else {
|
|
} else {
|
|
- // 当用户没有点击 ’总是保持以上选择,不再询问‘ 按钮。那每次执到这都会拉起授权弹窗
|
|
|
|
- wx.showModal({
|
|
|
|
- title: '提示',
|
|
|
|
- content: '请授权开通服务通知',
|
|
|
|
- showCancel: true,
|
|
|
|
- success: function (res) {
|
|
|
|
- if (res.confirm) {
|
|
|
|
- wx.requestSubscribeMessage({
|
|
|
|
- tmplIds: [tmplIds],
|
|
|
|
- success(res) {
|
|
|
|
- that.handleNav(item)
|
|
|
|
- },
|
|
|
|
- fail(err) {
|
|
|
|
- that.handleNav(item)
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
|
|
+ that.handleSubscribeMessageBridge(tmplIds, item)
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
// 订阅消息未开启
|
|
// 订阅消息未开启
|
|
|
|
+ that.handleSubscribeMessageBridge(tmplIds, item)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (err) {}
|
|
} catch (err) {}
|
|
|
|
+ },
|
|
|
|
+ handleSubscribeMessageBridge(tmplIds, item) {
|
|
|
|
+ const that = this
|
|
|
|
+ // 当用户没有点击 ’总是保持以上选择,不再询问‘ 按钮。那每次执到这都会拉起授权弹窗
|
|
|
|
+ wx.showModal({
|
|
|
|
+ title: '提示',
|
|
|
|
+ content: '请授权开通服务通知',
|
|
|
|
+ showCancel: true,
|
|
|
|
+ success: function (res) {
|
|
|
|
+ if (res.confirm) {
|
|
|
|
+ wx.requestSubscribeMessage({
|
|
|
|
+ tmplIds: [tmplIds],
|
|
|
|
+ success(res) {
|
|
|
|
+ that.handleNav(item)
|
|
|
|
+ },
|
|
|
|
+ fail(err) {
|
|
|
|
+ that.handleNav(item)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
}
|
|
}
|
|
})
|
|
})
|