小程序消息推送一直提示模板id错误,也不弹出消息订阅?
[图片] 本地开发者工具均正常 真机调试,体验版,审核上线后小程序均无法弹出订阅消息无法点击, 报错:error occurs:no such file or directory, access 'wxfile://usr/miniprogramLog/log2' [图片] 代码如下: //index.wxml
<view class="jinyong" wx:if="{{zt==9999}}">
禁止登录,请与管理员联系。
</view>
//index.js
//获取应用实例
const app = getApp()
Page({
data: {
zt: 100
},
onLoad: function () {
//判断是用户是否绑定了
var that = this;
if (app.globalData.employId && app.globalData.employId != '') {
var zc = wx.getStorageSync('config');
var zt = wx.getStorageSync('zt');
console.log(zt, "ok")
if (zt == 0) {
//未注册
if (zc.isreg != 1) {
wx.reLaunch({
url: '/pages/welcome/welcome'
})
return false;
}else{
//未注册,前往注册页面
wx.reLaunch({
url: '/pages/reg/reg'
})
}
} else if (zt == 1) {
//前往报修者页面
wx.reLaunch({
url: '/pages/baoxiu/baoxiu'
})
} else if (zt == 2) {
//前往管理者页面
wx.reLaunch({
url: '/pages/guanli/guanli'
})
} else if (zt == 3) {
//前往维修者页面
wx.reLaunch({
url: '/pages/weixiu/weixiu'
})
} else {
that.setData({
zt: zt
})
wx.hideLoading();
}
} else {
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.employIdCallback = employId => {
if (employId != '') {
var zc = wx.getStorageSync('config');
var zt = wx.getStorageSync('zt');
console.log(zt, "no")
if (zt == 0) {
if (zc.isreg != 1) {
wx.reLaunch({
url: '/pages/welcome/welcome'
})
return false;
}else{
//未注册,前往注册页面
wx.reLaunch({
url: '/pages/reg/reg'
})
}
} else if (zt == 1) {
//前往报修者页面
wx.reLaunch({
url: '/pages/baoxiu/baoxiu'
})
} else if (zt == 2) {
//前往管理者页面
wx.reLaunch({
url: '/pages/guanli/guanli'
})
} else if (zt == 3) {
//前往维修者页面
wx.reLaunch({
url: '/pages/weixiu/weixiu'
})
} else {
that.setData({
zt: zt
})
wx.hideLoading();
}
}
}
}
}
})
//reg.js
const app = getApp();
var istj = false;
Page({
/**
* 页面的初始数据
*/
data: {
viewtop: 85, //搜索viewTOP值
jyss: true, //禁用搜索按钮
uname: '', //搜索框输入的内容
showuser: false, //是否显示信息预览
userdata: {} //服务器返回的用户信息
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
var jn = wx.getMenuButtonBoundingClientRect();
this.setData({
viewtop: jn.bottom + 10
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
inputtext: function (e) {
var s = e.detail.value;
if (s.length == 11) {
var jyan = false;
} else {
var jyan = true;
}
this.setData({
uname: s,
jyss: jyan
})
},
sousuozz: function () {
var that = this;
console.log(that.data.uname);
var u = app.globalData.url + "searchuser.php";
var d = {
uname: that.data.uname
}
app.http(u, d).then(res => {
that.setData({
showuser: true,
userdata: res
})
}).catch(res => {
console.log('fail:', res);
that.setData({
showuser: false
})
}).finally(() => {
console.log('finally:', "结束");
})
},
guerenzhuce: function () {
if (istj) {
return;
}
istj = true;
var that = this;
if (that.data.userdata.zt == "1") {
var url = '/pages/baoxiu/baoxiu';
var tpid = ['MOvRtmKSY5mRI2XqB_nH-VApmzrDHc0FZ4E-0Wzyj9g', 'KMYzyHUc6MzdVQOYsieKp6RXwVL4zIJzp5gqBEu-SS0', 'UzrUdg1FWtPDzFi-qk8ZsUoWaY1JXG0YT8doNOR788s'];
} else if (that.data.userdata.zt == "2") {
var url = '/pages/guanli/guanli';
var tpid = ['MOvRtmKSY5mRI2XqB_nH-VApmzrDHc0FZ4E-0Wzyj9g', 'iDE5oCmrNt4Cxf1GauUJOxkaFGVQ48In1ORnjjKloIc', 'tIzdBWbk6-y9M6fpJo76e8T2NVdoLiS5PR9DIpHH47E'];
} else if (that.data.userdata.zt == "3") {
var url = '/pages/weixiu/weixiu';
var tpid = ['KMYzyHUc6MzdVQOYsieKp6RXwVL4zIJzp5gqBEu-SS0',
'KMYzyHUc6MzdVQOYsieKp6RXwVL4zIJzp5gqBEu-SS0',
'KMYzyHUc6MzdVQOYsieKp6RXwVL4zIJzp5gqBEu-SS0'];
} else {
wx.showModal({
title: '提示',
content: '无效角色,请与管理员联系。',
showCancel: false,
success(res) {
if (res.confirm) {
istj = false;
return;
}
}
})
}
wx.requestSubscribeMessage({
tmplIds: tpid,
success(res) {
console.log("success", res);
var id = that.data.userdata.id;
var d = {
uid: wx.getStorageSync('uid'),
id: id
};
var u = app.globalData.url + "reg.php";
app.http(u, d).then(res => {
wx.showToast({
title: '注册成功',
icon: 'success',
duration: 2000
});
wx.setStorageSync('zt', that.data.userdata.zt);
setTimeout(() => {
wx.reLaunch({
url: url
})
}, 2000);
}).catch(res => {
console.log('fail:', res);
}).finally(() => {
console.log('finally:', "结束");
istj = false;
})
},
fail(res) {
console.log("fail", res);
istj = false;
}
})
}
})
11111 //app.js
App({
onLaunch: function() {
//wx.clearStorage();
wx.removeStorageSync('uid');
wx.removeStorageSync('zt');
wx.removeStorageSync('qm');
wx.showLoading({
title: 'Loading...'
})
var that = this;
wx.login({
success: function(res) {
wx.request({
url: that.globalData.url + 'login.php',
data: {
code: res.code
},
success: function(res) {
console.log("APP",res.data);
that.globalData.employId = res.data.openid;
if (res.data.status == '1') {
wx.setStorageSync('uid', res.data.openid);
wx.setStorageSync('zt', res.data.zt);
wx.setStorageSync('config', res.data.config);
} else {
wx.setStorageSync('uid', res.data.openid);
wx.setStorageSync('zt', res.data.zt);
wx.showModal({
title: '提示',
content: '禁止登录',
showCancel: false
})
}
if (that.employIdCallback) {
that.employIdCallback(res.data.openid);
}
}
})
}
})
},
http: require("utils/request.js").request,
globalData: {
url: 'https://www.***.com/mini/',
employId: ''
}
})