代码拉取完成,页面将自动刷新
var util = require('we7/resource/js/util.js');
var timeQueue = require('lionfish_comshop/utils/timeQueue');
require('lionfish_comshop/utils//mixins.js');
App({
onLaunch: function() {
// wx.hideTabBar();
wx.getSystemInfo({
success: res => {
//导航高度
this.globalData.navHeight = res.statusBarHeight + 46;
},
fail(err) {
console.log(err);
}
})
var userInfo = wx.getStorageSync("userInfo");
this.globalData.userInfo = userInfo;
var currentCommunity = wx.getStorageSync("community");
this.globalData.hasDefaultCommunity = !!currentCommunity;
this.globalData.community = currentCommunity;
this.globalData.systemInfo = wx.getSystemInfoSync();
var model = this.globalData.systemInfo.model;
this.globalData.isIpx = model.indexOf("iPhone X") > -1 || model.indexOf("unknown<iPhone") > -1;
this.globalData.timer = new timeQueue.default();
},
onShow: function() {
this.getUpdate();
},
onHide: function() {},
//加载微擎工具类
util: util,
//用户信息,sessionid是用户是否登录的凭证
userInfo: {
sessionid: null,
},
globalData: {
systemInfo: {},
isIpx: false,
userInfo: {},
canGetGPS: true,
city: {},
community: {},
location: {},
hasDefaultCommunity: true,
historyCommunity: [],
changedCommunity: false,
disUserInfo: {},
changeCity: "",
timer: 0,
formIds: [],
community_id: '',
placeholdeImg: '',
cartNum: 0,
cartNumStamp: 0,
common_header_backgroundimage: '',
appLoadStatus: 1, // 1 正常 0 未登录 2 未选择社区
goodsListCarCount: [],
typeCateId: 0,
navBackUrl: '',
isblack: 0,
skin: {
color: '#ff5344',
subColor: '#ed7b3a',
lighter: '#fff9f4'
},
goods_sale_unit: '件'
},
getUpdate: function() {
if (wx.canIUse("getUpdateManager")) {
const updateManager = wx.getUpdateManager();
updateManager.onCheckForUpdate(function(res) {
res.hasUpdate && (updateManager.onUpdateReady(function() {
wx.showModal({
title: "更新提示",
content: "新版本已经准备好,是否马上重启小程序?",
success: function(t) {
t.confirm && updateManager.applyUpdate();
}
});
}), updateManager.onUpdateFailed(function() {
wx.showModal({
title: "已经有新版本了哟~",
content: "新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~"
});
}));
});
} else wx.showModal({
title: "提示",
content: "当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。"
});
},
getConfig: function() {
var token = wx.getStorageSync('token');
return new Promise((resolve, reject) => {
util.request({
url: 'entry/wxapp/user',
data: {
controller: 'index.get_firstload_msg',
token,
m: 'lionfish_comshop'
},
method: 'post',
dataType: 'json',
success: function(res) {
if (res.data.code == 0) {
let {
new_head_id,
default_head_info
} = res.data;
if (new_head_id > 0 && Object.keys(default_head_info).length) {
wx.setStorageSync('community', default_head_info);
}
resolve(res)
} else {
reject()
}
}
})
})
},
convertHtmlToText: function convertHtmlToText(inputText) {
var returnText = "" + inputText;
returnText = returnText.replace(/<\/div>/ig, '\r\n');
returnText = returnText.replace(/<\/li>/ig, '\r\n');
returnText = returnText.replace(/<li>/ig, ' * ');
returnText = returnText.replace(/<\/ul>/ig, '\r\n');
//-- remove BR tags and replace them with line break
returnText = returnText.replace(/<br\s*[\/]?>/gi, "\r\n");
//-- remove P and A tags but preserve what's inside of them
returnText=returnText.replace(/<p.*?>/gi, "\r\n");
returnText=returnText.replace(/<a.*href="(.*?)".*>(.*?)<\/a>/gi, " $2 ($1)");
//-- remove all inside SCRIPT and STYLE tags
returnText=returnText.replace(/<script.*>[\w\W]{1,}(.*?)[\w\W]{1,}<\/script>/gi, "");
returnText=returnText.replace(/<style.*>[\w\W]{1,}(.*?)[\w\W]{1,}<\/style>/gi, "");
//-- remove all else
returnText=returnText.replace(/<(?:.|\s)*?>/g, "");
//-- get rid of more than 2 multiple line breaks:
returnText=returnText.replace(/(?:(?:\r\n|\r|\n)\s*){2,}/gim, "\r\n\r\n");
//-- get rid of more than 2 spaces:
returnText = returnText.replace(/ +(?= )/g,'');
//-- get rid of html-encoded characters:
returnText=returnText.replace(/ /gi," ");
returnText=returnText.replace(/&/gi,"&");
returnText=returnText.replace(/"/gi,'"');
returnText=returnText.replace(/</gi,'<');
returnText=returnText.replace(/>/gi,'>');
return returnText;
},
setShareConfig: function(){
wx.showShareMenu({
menus: ['shareAppMessage', 'shareTimeline']
})
},
siteInfo: require('siteinfo.js')
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。