This commit is contained in:
haomingming
2023-05-09 15:04:05 +08:00
parent 7b9b80be8d
commit 807698b89f
53 changed files with 896 additions and 222 deletions
+2 -2
View File
@@ -31,7 +31,7 @@ class HTTP {
'Authorization': "Bearer " + wx.getStorageSync('AUTH_TOKEN_'+usertype)
},
success: (res) => {
console.log("header Authorization: ", res.header.Authorization);
// console.log("header Authorization: ", res.header.Authorization);
var Authorization_token = res.header.Authorization;
if(Authorization_token){
wx.setStorageSync('AUTH_TOKEN_'+usertype, Authorization_token);//当token快过期时,服务器会返回新token,本地刷新
@@ -58,7 +58,7 @@ class HTTP {
this._show_error(showLoading, err.data.message)
},
complete: (res) => {
console.log("res from cmplete ",res)
// console.log("res from cmplete ",res)
const code = res.data.code;
if (code == 200) {
if(showLoading) wx.hideLoading();
+68
View File
@@ -0,0 +1,68 @@
function requestSubscribeMessage(tmplIds){
return new Promise((resolve, reject) => {
wx.requestSubscribeMessage({
tmplIds: tmplIds,
success (res) {
console.log("succ:", res)
resolve(res)
},
fail(err){
console.log("error:", err)
let code = err.errCode
let title = "未知错误";
switch (code) {
case 10001:
title = "参数传空了"
break;
case 10002:
title = "请检查您的网络"
break;
case 10003:
title = "请检查您的网络"
break;
case 10004:
title = "参数类型错误"
break;
case 10005:
title = "无法展示 UI"
break;
case 20001:
title = "没有模板数据"
break;
case 20002:
title = "模板消息类型错误"
break;
case 20003:
title = "模板消息数量超过上限"
break;
case 20004:
title = "用户关闭了主开关,无法进行订阅"
break;
case 20005:
title = "小程序被禁封"
break;
case 20013:
title = "不允许通过该接口订阅设备消息"
break;
default:
break;
}
// wx.showToast({
// title: title,
// icon: 'error'
// })
reject(err)
}
})
})
}
module.exports = {
requestSubscribeMessage
}
+7 -1
View File
@@ -148,11 +148,16 @@ const likeWeChatTimeAgoChat = stringTime =>{
}
// px 转换为 rpx ,传参类型是数字(Number)
const rpxTopx = px => {
const pxTorpx = px => {
let deviceWidth = wx.getSystemInfoSync().windowWidth; //获取设备屏幕宽度
let rpx = (750 / deviceWidth) * Number(px)
return Math.floor(rpx);
}
// px 转换为 rpx ,传参类型是数字(Number)
const rpxTopx = rpx => {
let px = rpx / 750 * wx.getSystemInfoSync().windowWidth;
return Math.floor(px);
}
module.exports = {
formatTime,
@@ -160,6 +165,7 @@ module.exports = {
formatNumber,
getTimeAgo,
rpxTopx,
pxTorpx,
getTimeAgoChat,
likeWeChatTimeAgoChat
}