|
@@ -10,7 +10,9 @@ Page({
|
|
|
*/
|
|
|
data: {
|
|
|
focus:false,
|
|
|
- scrollTop:0
|
|
|
+ scrollTop:0,
|
|
|
+ template_id:"RIsv-Kj_Aws7OnbOxv_v1iQDDESXo0ePPLJQpjkHuus",
|
|
|
+ subscribe:false
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -18,12 +20,13 @@ Page({
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
this.getData()
|
|
|
- wx.getSetting({
|
|
|
- withSubscriptions:true,
|
|
|
- success (res) {
|
|
|
- console.log(res)
|
|
|
- console.log(res.subscriptionsSetting)
|
|
|
- }
|
|
|
+ wx.getStorage({
|
|
|
+ key: this.data.template_id,
|
|
|
+ success: res=> {
|
|
|
+ this.setData({
|
|
|
+ subscribe: true
|
|
|
+ })
|
|
|
+ },
|
|
|
})
|
|
|
},
|
|
|
getData(){
|
|
@@ -44,10 +47,20 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
subscribe(){
|
|
|
+ const template_id = this.data.template_id
|
|
|
+ const that = this;
|
|
|
wx.requestSubscribeMessage({
|
|
|
- tmplIds: ['RIsv-Kj_Aws7OnbOxv_v1iQDDESXo0ePPLJQpjkHuus'],
|
|
|
+ tmplIds: [template_id],
|
|
|
success (res) {
|
|
|
- console.log(res)
|
|
|
+ if(res[template_id]=='accept'){
|
|
|
+ wx.setStorage({
|
|
|
+ key: template_id,
|
|
|
+ data: "accept",
|
|
|
+ })
|
|
|
+ that.setData({
|
|
|
+ subscribe:true
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
},
|
|
@@ -79,13 +92,11 @@ Page({
|
|
|
onShow: function () {
|
|
|
let that = this;
|
|
|
wx.createSelectorQuery().select("#messageScroll").boundingClientRect(function(rect){
|
|
|
+ console.log(rect)
|
|
|
wx.pageScrollTo({
|
|
|
scrollTop:rect.height,
|
|
|
duration:100
|
|
|
})
|
|
|
- that.setData({
|
|
|
- scrollTop:rect.height - that.data.scrollTop
|
|
|
- })
|
|
|
}).exec()
|
|
|
},
|
|
|
|