代码拉取完成,页面将自动刷新
<script>
import Vue from 'vue'
// #ifdef H5
import pageAnimation from 'components/Michael-pageAnimationPlus/index.vue'
// #endif
import api from 'api/index'
export default {
// #ifdef H5
mixins: [pageAnimation],
// #endif
onLaunch: function(option) {
console.log('onLaunch',option);
let sharePath = option.path || ''
let shareparamObj = option.query || {}
let shareparam = '?'
Object.keys(shareparamObj).forEach(function(key,i,v){
shareparam = shareparam + key + '=' + shareparamObj[key] + '&'
})
shareparam = shareparam.substring(0,shareparam.length - 1)
let shareUrl = sharePath + shareparam
console.log(shareUrl);
uni.setStorageSync('shareUrl',shareUrl)
uni.removeStorageSync('shopInfo')
uni.getSystemInfo({
success: function(e) {
// #ifndef MP
Vue.prototype.StatusBar = e.statusBarHeight;
if (e.platform == 'android') {
Vue.prototype.CustomBar = e.statusBarHeight + 50;
} else {
Vue.prototype.CustomBar = e.statusBarHeight + 45;
};
// #endif
// #ifdef MP-WEIXIN
Vue.prototype.StatusBar = e.statusBarHeight;
let custom = wx.getMenuButtonBoundingClientRect();
Vue.prototype.Custom = custom;
Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
// #endif
// #ifdef MP-ALIPAY
Vue.prototype.StatusBar = e.statusBarHeight;
Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
// #endif
}
})
uni.setStorage({
key: 'option',
data: option
})
// #ifdef H5
var me = this;
let url = window.location.href
let re = /^http[s]?:\/\/.+\/s\/([^\/]+)/ig;
let m = re.exec(url);
let appId = '';
if (m && m.length > 0) {
//更新当前店铺AppId
appId = m[1];
this.$store.commit('upAppId', appId);
this.getShopInfoFun(appId)
this.cssFun(appId)
} else {
//未找到店铺、404页面
uni.redirectTo({
url: './otherPage/pages/404'
})
}
// #endif
// #ifdef H5
//0:H5 1:小程序
uni.setStorageSync('appplatform', 0);
// #endif
// #ifdef MP-WEIXIN
uni.setStorageSync('appplatform', 1);
uni.setStorageSync('isLogin', '1');
//S20082500001
if (!wx.cloud) {
console.error(" 2.2.3 或以上的基础库以使用云能力")
} else {
wx.cloud.init({
env: "cloud1-0g1hxyqr295dea7c",
traceUser: true,
})
}
//S20091300001
let appId = option.query.appId || 'S21020100001'
this.$store.commit('upAppId', appId);
let token = uni.getStorageSync('access_token_' + appId) || ''
uni.setStorageSync('appId',appId)
if (!token) {
uni.redirectTo({
url: 'pages/login/wxLimit',
complete(res) {
console.log(res);
}
})
}else{
if(shareUrl){
uni.redirectTo({
url:shareUrl,
complete(res) {
console.log(res);
}
})
}else{
uni.redirectTo({
url:'pages/index/index'
})
}
}
// #endif
},
onHide: function() {
console.log('App Hide');
},
onShow: function(option) {
console.log(option);
let _this = this
const updateManager = uni.getUpdateManager();
console.log(updateManager);
updateManager.onCheckForUpdate(function(res) {
// 请求完新版本信息的回调
console.log('请求完新版本信息的回调', res);
if (res.hasUpdate) {
updateManager.onUpdateReady(function(res) {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success(res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate();
}
}
});
});
updateManager.onUpdateFailed(function(res) {
// 新的版本下载失败
uni.showModal({
title: '更新提示',
content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~'
})
});
} else {
let token = uni.getStorageSync('access_token_S21020100001') || ''
if(token){
_this.getVipUserFun()
}
}
});
},
methods: {
//获取门店会员信息
getVipUserFun: function() {
this.$api.getVipUser({}).then(res => {
// debugger;
console.log('获取门店会员信息', res)
if (res.success) {
this.userInfo = res.data || {}
uni.setStorageSync('userInfo',JSON.stringify(res.data))
if(this.userInfo.phone){
this.queryPersonListFun()
}
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
}
})
},
//名片详情
queryPersonListFun: function() {
this.$api.queryPersonList({
keyword: this.userInfo.phone,
start: 1,
page:1,
limit: 20
}).then(res => {
// debugger;
console.log('名片详情', res)
if (res.success) {
if(res.data.total > 0){
this.personInfo = res.data.list[0] || {}
console.log('9999999',this.personInfo);
if(this.personInfo.PositionID){
uni.setStorageSync('personInfo',JSON.stringify(this.personInfo))
uni.setStorageSync('PositionID',this.personInfo.PositionID)
}else{
uni.removeStorageSync('PositionID')
}
}
} else {
uni.showToast({
title: res.message,
icon: 'none'
})
}
})
},
//显示异常
exApiFun: function(res) {
this.$api.exApi({
"message": res.message,
"trace": res.stacktrace
}).then(res => {
console.log('显示异常', res)
if (res.success) {
} else {
}
})
},
//获得店铺信息
getShopInfoFun: function(appId) {
this.$api.getShopInfo({
"appId": appId
}).then(res => {
console.log('获得店铺信息', res)
if (res.success) {
this.shopInfo = res.data || {}
uni.setStorageSync('shopInfo', JSON.stringify(this.shopInfo))
}
})
},
//获得样式
cssFun: function(appId) {
this.$api.layout('/' + appId + '/subject').then(res => {
console.log('获得样式', res)
if (res.success) {
this.subjectObj = JSON.parse(res.data.context)
if (this.subjectObj.color == '#222220') {
this.$store.commit('themeFun', 'theme-one')
} else if (this.subjectObj.color == '#4452E4') {
this.$store.commit('themeFun', 'theme-two')
} else if (this.subjectObj.color == '#00C802') {
this.$store.commit('themeFun', 'theme-three')
} else if (this.subjectObj.color == '#1F71FF;') {
this.$store.commit('themeFun', 'theme-four')
} else if (this.subjectObj.color == '#F13F37') {
this.$store.commit('themeFun', 'theme-five')
} else if (this.subjectObj.color == '#F5A90F') {
this.$store.commit('themeFun', 'theme-six')
} else if (this.subjectObj.color == '#FA6400') {
this.$store.commit('themeFun', 'theme-seven')
} else if (this.subjectObj.color == '#2AB7F3') {
this.$store.commit('themeFun', 'theme-eight')
} else if (this.subjectObj.color == '#9C80FF') {
this.$store.commit('themeFun', 'theme-nine')
} else if (this.subjectObj.color == '#F36A8E') {
this.$store.commit('themeFun', 'theme-ten')
} else if (this.subjectObj.color == '#243b87') {
this.$store.commit('themeFun', 'theme-eleven')
}else{
this.$store.commit('themeFun', 'theme-one')
}
console.log(this.subjectObj);
} else {
this.$store.commit('themeFun', 'theme-one')
// uni.showToast({
// title: res.message,
// icon: 'none'
// })
}
})
},
isWx: function() {
let ua = navigator.userAgent.toLowerCase();
return ua.match(/MicroMessenger/i) == "micromessenger";
},
getToPage: function() {
// #ifdef H5
var paths = location.href.split('#');
return paths.length > 0 ? paths[1] : '';
// #endif
},
getH5Url: function(toPage) {
return api.host_url + '/s/' + uni.getStorageSync('appId') + '/#/' + (toPage || '');
},
isLogin: function() {
if (!uni.getStorageSync('access_token_' + uni.getStorageSync('appId'))) {
this.userValidIdentity();
return false;
}
// this.$store.commit('upLogin', 2);
return true;
},
////非首页授权、跳转页授权、先进入授权界面,在进跳转页
userValidIdentity: function() {
// #ifdef H5
var toPage = this.getToPage();
if (!uni.getStorageSync('access_token_' + uni.getStorageSync('appId'))) {
if (toPage && toPage.indexOf('pages/index/spaceIndex') == -1) {
//检测token是否过期、30天过期
//1.request check token
//2.验证token是否存在
//页面加载后跳转、在每个页面做判断更好
var url = encodeURIComponent(toPage);
// alert('url:::' + url)
uni.redirectTo({
url: '../../pages/index/spaceIndex?toPage=' + url,
success() {
console.log('redirect spaceIndex', url);
},
fail() {
console.error('redirect spaceIndex error', arguments)
}
})
} else {
uni.redirectTo({
url: '../../pages/index/spaceIndex',
success() {
console.log('redirect spaceIndex', url);
},
fail() {
console.error('redirect spaceIndex error', arguments)
}
})
}
}
// #endif
}
}
};
</script>
<style lang="scss">
@import "colorui/main.css";
@import "colorui/icon.css";
@import "uview-ui/index.scss";
@import "static/css/common.css";
body {
margin: 0;
letter-spacing: 1px;
font-family: 'Helvetica Neue', Helvetica, sans-serif;
word-break: break-all;
/* font-family: "\9ED1\4F53"; */
background-color: #F9F9F9;
}
//底部适配
@supports (bottom: constant(safe-area-inset-bottom)) or (bottom: env(safe-area-inset-bottom)) {
.product-bottom,.buy-shop-bottom,.bottom-block { //你的容器选择器名称
padding-bottom: constant(safe-area-inset-bottom)!important;
padding-bottom: env(safe-area-inset-bottom)!important;
box-sizing: content-box!important;
}
/* .left-block,.problem-block,.problem-score{
bottom: 180rpx !important;
} */
}
uni-rich-text img{ max-width: 100% !important;}
.cu-custom {
/* #ifdef H5 */
display: none;
/* #endif */
}
img {
pointer-events: auto !important;
}
uni-toast {
z-index: 2000;
}
uni-picker-item {
font-size: 320rpx !important;
}
/* 解决头条小程序组件内引入字体不生效的问题 */
/* #ifdef MP-TOUTIAO */
@font-face {
font-family: uniicons;
src: url('/static/uni.ttf');
}
/* #endif */
</style>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。