1、前端需要修改:
路径:/pages/users/user_vip/index.vue
方便复制:
v-if="item.lack_exp_num==0"
item.lack_exp_num
progressValue(item, index) {
let width = 100;
let num = item.exp_num - parseFloat(item.lack_exp_num)
width = (num / item.exp_num)*100
return {
'width': `${width}%`,
'background-color': item.color,
};
},
2、后端需要修改:
方便复制:
public function getUserLevelInfo(int $uid)
{
$data = ['user' => [], 'level_info' => [], 'level_list' => [], 'task' => []];
//商城会员是否开启
if (!sys_config('member_func_status')) {
return $data;
}
/** @var UserServices $userServices */
$userServices = app()->make(UserServices::class);
$user = $userServices->getUserInfo($uid);
if (!$user) {
throw new ValidateException('没有此会员');
}
/** @var StoreCouponUserServices $storeCoupon */
$storeCoupon = app()->make(StoreCouponUserServices::class);
$user['couponCount'] = $storeCoupon->getUserValidCouponCount((int)$uid);
$data['user'] = $user;
/** @var SystemUserLevelServices $systemUserLevel */
$systemUserLevel = app()->make(SystemUserLevelServices::class);
$levelList = $systemUserLevel->getList(['is_del' => 0, 'is_show' => 1]);
$i = 0;
foreach ($levelList as &$level) {
$level['next_exp_num'] = $levelList[$i + 1]['exp_num'] ?? $level['exp_num'];
$level['image'] = set_file_url($level['image']);
$level['icon'] = set_file_url($level['icon']);
$i++;
}
$data['level_list'] = $levelList;
$levelInfo = $this->getUerLevelInfoByUid($uid);
if (!$levelInfo) {//不存在等级 展示最低等级
/** @var SystemUserLevelServices $systemUserLevel */
$systemUserLevel = app()->make(SystemUserLevelServices::class);
$alllevelInfo = $systemUserLevel->getList([['is_del', '=', 0], ['is_show', '=', 1]], 'id,name,icon,grade', 1, 1);
$levelInfo = $alllevelInfo[0] ?? [];
if ($levelInfo) {
$levelInfo['id'] = 0;
}
}
if ($levelInfo) {
$levelInfo['vip'] = true;
$levelInfo['vip_id'] = $levelInfo['id'];
$levelInfo['vip_icon'] = $levelInfo['icon'];
$levelInfo['vip_name'] = $levelInfo['name'];
}
$data['level_info'] = $levelInfo;
$i = 0;
foreach ($levelList as &$level) {
if ($level['grade'] < $levelInfo['grade']) {
$level['next_exp_num'] = $levelList[$i + 1]['exp_num'] ?? $level['exp_num'];
$level['lack_exp_num'] = 0;
} else {
$level['next_exp_num'] = $level['exp_num'];
if ($user['exp'] > $level['exp_num']) {
$level['lack_exp_num'] = 0;
} else {
$level['lack_exp_num'] = bcsub((string)$level['exp_num'], (string)$user['exp'], 0);
}
}
$level['image'] = set_file_url($level['image']);
$level['icon'] = set_file_url($level['icon']);
$i++;
}
$data['level_list'] = $levelList;
$data['level_info']['exp'] = $user['exp'] ?? 0;
/** @var UserBillServices $userBillservices */
$userBillservices = app()->make(UserBillServices::class);
$data['level_info']['today_exp'] = $userBillservices->getExpSum($uid, 'today');
$task = [];
/** @var UserSignServices $userSignServices */
$userSignServices = app()->make(UserSignServices::class);
$task['sign_count'] = $userSignServices->getSignSumDay($uid);
$config = SystemConfigService::more(['sign_give_exp', 'order_give_exp', 'invite_user_exp']);
$task['sign'] = $config['sign_give_exp'] ?? 0;
$task['order'] = $config['order_give_exp'] ?? 0;
$task['invite'] = $config['invite_user_exp'] ?? 0;
$data['task'] = $task;
//检测升级
UserLevelJob::dispatch([$uid]);
return $data;
}
3、改完前端需要重新打包小程序、h5,后端要重启swoole