问题
移动端修改:
修复方式:
public function get_course_list()
{
list($page, $limit, $special_id) = UtilService::getMore([
['page', 1],
['limit', 10],
['special_id', 0],
], null, true);
$is_member = isset($this->userInfo['level']) ? $this->userInfo['level'] : 0;
//不登录也能查看
$task_list = SpecialCourse::getSpecialSourceList($special_id, $limit, $page, $this->uid, $is_member);
if (!$task_list['list']) return JsonService::successful([]);
foreach ($task_list['list'] as $k => $v) {
$task_list['list'][$k]['type_name'] = SPECIAL_TYPE[$v['type']];
if (!isset($task_list['list'][$k]['special_task'])) {
$watch = SpecialWatch::whetherWatch($this->uid, $special_id, $v['id']);
if ($watch && $watch['percentage'] > 100) {
$watch['percentage'] = 100;
}
$task_list['list'][$k]['watch'] = $watch;
}
}
return JsonService::successful($task_list);
}
public static function materialViewing($uid, $data)
{
$viewing = self::where(['uid' => $uid, 'special_id' => $data['special_id'], 'task_id' => $data['task_id']])->find();
if ($data['percentage'] < 0) $data['percentage'] = 0;
if ($data['percentage'] > 100) $data['percentage'] = 100;
if ($viewing) {
$dat['viewing_time'] = $data['viewing_time'];
$dat['percentage'] = $data['percentage'];
$dat['total'] = $data['total'];
if ($data['percentage'] > $viewing['percentage']) {
return self::edit($dat, $viewing['id']);
} else {
return true;
}
} else {
$data['uid'] = $uid;
$data['add_time'] = time();
return self::set($data);
}
}
pc端修改:
public function get_course_list()
{
list($page, $limit, $special_id) = UtilService::getMore([
['page', 1],
['limit', 10],
['special_id', 0],
], null, true);
$is_member = isset($this->userInfo['level']) ? $this->userInfo['level'] : 0;
//不登录也能查看
$task_list = SpecialCourse::getSpecialSourceList($special_id, $limit, $page, $this->uid, $is_member);
if (!$task_list['list']) return JsonService::successful([]);
foreach ($task_list['list'] as $k => $v) {
$task_list['list'][$k]['type_name'] = SPECIAL_TYPE[$v['type']];
if (!isset($task_list['list'][$k]['special_task'])) {
$watch = SpecialWatch::whetherWatch($this->uid, $special_id, $v['id']);
if ($watch && $watch['percentage'] > 100) {
$watch['percentage'] = 100;
}
$task_list['list'][$k]['watch'] = $watch;
}
}
return JsonService::successful($task_list);
}
public static function materialViewing($uid, $data)
{
$viewing = self::where(['uid' => $uid, 'special_id' => $data['special_id'], 'task_id' => $data['task_id']])->find();
if ($data['percentage'] < 0) $data['percentage'] = 0;
if ($data['percentage'] > 100) $data['percentage'] = 100;
if ($viewing) {
$dat['viewing_time'] = $data['viewing_time'];
$dat['percentage'] = $data['percentage'];
$dat['total'] = $data['total'];
if ($data['percentage'] > $viewing['percentage']) {
return self::edit($dat, $viewing['id']);
} else {
return true;
}
} else {
$data['uid'] = $uid;
$data['add_time'] = time();
return self::set($data);
}
}