crmeb标准版、开源版目前在会员未登录的状态下,会员中心--我的服务,不显示任何功能模块,直接以空白占位,我个人觉得不够大气,在H5端、APP端直接跳转到会员登录页面,微信小程序端定格在会员中心页面,这个地方我进行了微调了,让三端都统一定格在会员中心页面,但会员中心在用户未登录的情况下,我的服务不显示功能模块。因此我们还需要对页面功能进行调整,让用户未登录的情况下,也可以让我的服务模块中的所有功能模块显示出来。效果如下图:
这是原版未登录状态下会员中心页面:
这是改良后未登录状态下会员中心页面:
通过阅读代码,可以发现,我的服务中的功能模块路由为api/menu/user,而这个路由不需要验证用户登录状态,那么改良功能就方便了,不需要动PHP代码,只需要修改uniapp中的模板代码即可,通过路由查找,在模板中getMyMenus方法即是获取我的服务模块的,因此在会员中心模板中找到这个方法,将getMyMenus移到验证会员登录状态外即可,这样重新打包发布模板就达到了最终目的。
对于在H5和APP端,会员中心页面在未登录状态下,会员自动跳转到登录页面的改良也是非常简单的,只要找到以下代码修改。
// #ifdef H5 || APP-PLUS
if (that.isLogin == false) {
toLogin()
}
//获取用户信息回来后授权
let cacheCode = this.$Cache.get('snsapi_userinfo_code');
let res1 = cacheCode ? option.code != cacheCode : true;
if (this.isWeixin && option.code && res1 && option.scope === 'snsapi_userinfo') {
this.$Cache.set('snsapi_userinfo_code', option.code);
Auth.auth(option.code).then(res => {
this.getUserInfo();
}).catch(err => {})
}
// #endif
修改为:
// #ifdef H5 || APP-PLUS
//获取用户信息回来后授权
let cacheCode = this.$Cache.get('snsapi_userinfo_code');
let res1 = cacheCode ? option.code != cacheCode : true;
if (this.isWeixin && option.code && res1 && option.scope === 'snsapi_userinfo') {
this.$Cache.set('snsapi_userinfo_code', option.code);
Auth.auth(option.code).then(res => {
this.getUserInfo();
}).catch(err => {})
}
// #endif
在会员中心页面,我还将轮播改良了下,就是在会员未登录时,就直接不让显示了,否则会员中心的轮播广告会一并显示出来,那么我们只需要对这个模块加一个验证就ok了。
<view class="slider-wrapper" v-if="imgUrls.length>0 && my_banner_status && isLogin">
如果开发中遇到不懂的,欢迎私信交流。