2023-09-22 15:07:26 +08:00
|
|
|
|
import Vue from 'vue'
|
|
|
|
|
|
import Vuex from 'vuex'
|
|
|
|
|
|
Vue.use(Vuex)
|
|
|
|
|
|
const store = new Vuex.Store({
|
|
|
|
|
|
state: {
|
|
|
|
|
|
//公共的变量,这里的变量不能随便修改,只能通过触发mutations的方法才能改变
|
|
|
|
|
|
},
|
|
|
|
|
|
mutations: {
|
|
|
|
|
|
//相当于同步的操作
|
|
|
|
|
|
//点击确认
|
2023-11-15 10:31:52 +08:00
|
|
|
|
integralsubscribesuccess(state) {
|
2023-09-22 15:07:26 +08:00
|
|
|
|
wx.requestSubscribeMessage({
|
|
|
|
|
|
tmplIds: [
|
2023-11-15 10:31:52 +08:00
|
|
|
|
// 'S_c9bR4znSWpXg-6ACIMn7AkaR11dzo113XM8w4CKz0'
|
2023-09-22 15:07:26 +08:00
|
|
|
|
],
|
|
|
|
|
|
success(res) {},
|
|
|
|
|
|
fail(err) {},
|
|
|
|
|
|
complete(scc) {}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2023-11-15 10:31:52 +08:00
|
|
|
|
subscribesuccess(state) {
|
2023-09-22 15:07:26 +08:00
|
|
|
|
wx.requestSubscribeMessage({
|
|
|
|
|
|
tmplIds: [
|
2023-11-15 10:31:52 +08:00
|
|
|
|
'8InV9jXDT5sMj9OWfXEvlLQGlw2UaWfZ9OBMFxufmfk',
|
|
|
|
|
|
'2wn1BssReKjZasxKKZRWxBN0VqSmGmkuhc3AhTr18I0',
|
|
|
|
|
|
'MSSKCxOdtMUkY1ACu-u3itz8Vh_w5xDkO2llAOGwElU',
|
2023-09-22 15:07:26 +08:00
|
|
|
|
],
|
|
|
|
|
|
success(res) {},
|
|
|
|
|
|
fail(err) {},
|
|
|
|
|
|
complete(scc) {}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
actions: {
|
|
|
|
|
|
//相当于异步的操作,不能直接改变state的值,只能通过触发mutations的方法才能改变
|
|
|
|
|
|
integralopenPopup(contxt) {
|
|
|
|
|
|
// 获取用户的当前设置,判断是否点击了“总是保持以上,不在询问”
|
|
|
|
|
|
wx.getSetting({
|
|
|
|
|
|
withSubscriptions: true, // 是否获取用户订阅消息的订阅状态,默认false不返回
|
|
|
|
|
|
success(res) {
|
|
|
|
|
|
if (res.authSetting['scope.subscribeMessage']) {} else {
|
|
|
|
|
|
//因为没有选择总是保持,所以需要调起授权弹窗再次授权
|
|
|
|
|
|
contxt.commit('integralsubscribesuccess')
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 是否设置过授权
|
|
|
|
|
|
openPopup(contxt) {
|
|
|
|
|
|
// 获取用户的当前设置,判断是否点击了“总是保持以上,不在询问”
|
|
|
|
|
|
wx.getSetting({
|
|
|
|
|
|
withSubscriptions: true, // 是否获取用户订阅消息的订阅状态,默认false不返回
|
|
|
|
|
|
success(res) {
|
|
|
|
|
|
if (res.authSetting['scope.subscribeMessage']) {} else {
|
|
|
|
|
|
//因为没有选择总是保持,所以需要调起授权弹窗再次授权
|
|
|
|
|
|
contxt.commit('subscribesuccess')
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2023-11-15 10:31:52 +08:00
|
|
|
|
export default store
|