Ejemplo n.º 1
0
 public function showInList()
 {
     $data = [];
     $data['id'] = $this->ad_id;
     $data['status'] = $this->ad_status;
     $date = new DateTime($this->created_at);
     $data['created_at'] = $date->format('Y-m-d H:i:s');
     $data['created_at_timestamps'] = strtotime($data['created_at']);
     if (empty($this->eventItem)) {
         $this->load('eventItem');
     }
     if (empty($this->eventItem)) {
         $data['title'] = '';
         $data['cover_img'] = null;
         $data['url'] = '';
         $data['brief'] = '';
         $data['active_at'] = '';
     } else {
         $data['title'] = $this->eventItem->e_title;
         $data['cover_img'] = Img::filterKey('cover_img', Img::toArray($this->eventItem->cover_img));
         $data['url'] = $this->eventItem->url;
         $data['brief'] = $this->eventItem->e_brief;
         $data['active_at'] = $this->eventItem->e_start_at;
     }
     return $data;
 }
Ejemplo n.º 2
0
 public function showDetail()
 {
     $data = [];
     $data['id'] = $this->a_id;
     $data['sub_title'] = $this->a_sub_title;
     $data['win_username'] = $this->a_win_username;
     $data['win_price'] = $this->a_win_price;
     $data['status'] = $this->a_status;
     $data['cost'] = $this->a_cost;
     $data['current_time'] = Tools::getNow();
     if (empty($this->eventItem)) {
         $data['title'] = '';
         $data['start_at'] = '';
         $data['end_at'] = '';
         $data['url'] = '';
         $data['cover_img'] = [];
         $data['detail_content_img'] = [];
         $data['detail_header_img'] = [];
     } else {
         $data['title'] = $this->eventItem->e_title;
         $data['start_at'] = $this->eventItem->e_start_at;
         $data['end_at'] = $this->eventItem->e_end_at;
         $data['url'] = $this->eventItem->url;
         $data['cover_img'] = Img::filterKey('cover_img', Img::toArray($this->eventItem->cover_img));
         $data['detail_content_img'] = Img::filterKey('detail_content_img', Img::toArray($this->eventItem->cover_img));
         $data['detail_header_img'] = Img::filterKey('detail_header_img', Img::toArray($this->eventItem->cover_img));
     }
     return $data;
 }
Ejemplo n.º 3
0
 public function getContent()
 {
     $content = json_decode($this->p_desc, JSON_OBJECT_AS_ARRAY);
     $pic_text = [];
     if (empty($this->_imgs)) {
         $this->loadImgs();
     }
     $imgs = Img::filterKey('prod_img_', $this->_imgs, true);
     foreach ($imgs as $key => $img) {
         $txt = empty($content[$key]) ? '' : $content[$key];
         $pic_text[] = ['img' => $img, 'text' => $txt];
     }
     return $pic_text;
 }
Ejemplo n.º 4
0
 public function putHeadImg()
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $img_token = Input::get('img_token');
     try {
         $user = User::chkUserByToken($token, $u_id);
         if ($img_token) {
             $imgObj = new Img('user', $img_token);
             $imgs = $imgObj->getSavedImg($u_id, implode(',', [$user->u_head_img]), true);
             $head_img = Img::filterKey('head_img', $imgs);
             $user->u_head_img = implode(',', $head_img);
             $user->save();
         } else {
             throw new Exception("请上传头像", 2001);
         }
         $data['head_img'] = $head_img;
         $re = Tools::reTrue('修改头像成功', $data);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '修改头像失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
Ejemplo n.º 5
0
 public function showInOffice()
 {
     $this->loadImg();
     $data = [];
     $data['id'] = $this->b_id;
     $data['title'] = $this->b_title;
     $data['desc'] = $this->b_desc;
     $data['type'] = $this->b_type;
     $data['category'] = $this->b_product_category;
     $data['source'] = $this->b_product_source;
     $data['logo'] = $this->getLogo();
     $data['cover_img'] = Img::filterKey('cover_img', $this->_imgs);
     $data['fans'] = $this->b_fans_count;
     $data['status'] = $this->b_status;
     $data['lng'] = $this->longitude;
     $data['lat'] = $this->latitude;
     $data['cust_group'] = $this->b_customer_group;
     $data['promo_strategy'] = $this->b_promo_strategy;
     $data['is_fund'] = $this->b_with_fund;
     $data['open'] = $this->b_open;
     $data['open_from'] = $this->b_open_from;
     $data['open_to'] = $this->b_open_to;
     $data['open_on'] = $this->open_on;
     $data['source'] = $this->b_product_source;
     $data['cust_group'] = $this->b_customer_group;
     $data['promo_strategy'] = $this->b_promo_strategy;
     $data['is_fund'] = $this->b_with_fund;
     $data['status'] = $this->b_status;
     $data['remark'] = $this->remark;
     if (!empty($this->fund)) {
         $data['fund'] = $this->fund->showDetail();
     }
     if (!empty($this->user)) {
         $data['user'] = $this->user->showInOffice();
     }
     return $data;
 }
Ejemplo n.º 6
0
 public function putUserBase()
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $name = Input::get('name');
     $nickname = Input::get('nickname', '');
     $gender = Input::get('gender', '');
     $bio = Input::get('biograph', '');
     $id_number = Input::get('id_number', '');
     $id_school = Input::get('id_school', 0);
     $entry_year = Input::get('entry_year', '');
     $major = Input::get('major', '');
     $stu_num = Input::get('stu_num', '');
     $mobile = Input::get('mobile', '');
     $age = Input::get('age', '');
     $birth = Input::get('birth', '');
     $img_token = Input::get('img_token', '');
     $modified_img = Input::get('modified_img', '');
     $modified_img_index = Input::get('modified_img_index', '');
     if ($modified_img) {
         $modified_img = explode(',', $modified_img);
     }
     try {
         $user = User::chkUserByToken($token, $u_id);
         $profile = TmpUserProfileBase::find($u_id);
         if (empty($profile)) {
             $profile = new TmpUserProfileBase();
             $profile->u_id = $u_id;
         }
         $user->u_name = $name;
         $user->u_nickname = $nickname;
         $user->u_sex = $gender;
         $user->u_biograph = $bio;
         $user->u_age = $age;
         $user->u_birthday = $birth;
         if ($id_school) {
             $profile->s_id = $id_school;
             $user->u_school_id = $id_school;
         }
         if ($mobile) {
             $user->u_mobile = $mobile;
         }
         $profile->u_entry_year = $entry_year;
         $profile->u_major = $major;
         $profile->u_id_number = $id_number;
         $profile->u_student_number = $stu_num;
         if (is_numeric($modified_img_index)) {
             $imgObj = new Img('user', $img_token);
             $new_paths = [];
             if (!empty($modified_img)) {
                 foreach ($modified_img as $old_path) {
                     $new_path = $imgObj->reindexImg($u_id, $modified_img_index, $old_path);
                     $new_paths[] = $new_path;
                     $modified_img_index++;
                 }
                 $to_delete = Img::toArray($user->u_home_img);
                 foreach ($to_delete as $obj) {
                     if (!in_array($obj, $new_paths)) {
                         $imgObj->remove($u_id, $obj);
                     }
                 }
                 $new_paths = Img::attachHost($new_paths);
                 $user->u_home_img = implode(',', $new_paths);
             }
         }
         if ($img_token) {
             $imgObj = new Img('user', $img_token);
             $imgs = $imgObj->getSavedImg($u_id, implode(',', [$profile->u_id_imgs, $profile->u_student_imgs, $user->u_home_img, $user->u_head_img]), true);
             $stu_imgs = Img::filterKey('student_img_', $imgs);
             $id_imgs = Img::filterKey('identity_img_', $imgs);
             $home_imgs = Img::filterKey('home_img_', $imgs);
             $head_img = Img::filterKey('head_img', $imgs);
             if (!empty($modified_img)) {
                 foreach ($modified_img as $del) {
                     if (array_key_exists($del, $home_imgs)) {
                         unset($home_imgs[$del]);
                     }
                 }
             }
             $profile->u_student_imgs = implode(',', $stu_imgs);
             $profile->u_id_imgs = implode(',', $id_imgs);
             $user->u_home_img = implode(',', $home_imgs);
             $user->u_head_img = implode(',', $head_img);
         }
         $this->saveClubInfo($user);
         $profile->save();
         $user->save();
         $re = Tools::reTrue('提交信息成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '提交信息失败:' . $e->getMessage());
     }
     return Response::json($re);
 }