Authored by Rock Zhang

给意见反馈添加图片选项

@@ -344,14 +344,18 @@ class UserData @@ -344,14 +344,18 @@ class UserData
344 * 344 *
345 * @param int $uid 用户ID 345 * @param int $uid 用户ID
346 * @param string $content 意见内容 346 * @param string $content 意见内容
  347 + * @param mixed $image 图片地址
347 * @param int $suggest_type 意见类型 348 * @param int $suggest_type 意见类型
348 * @return array 意见反馈接口返回的数据 349 * @return array 意见反馈接口返回的数据
349 */ 350 */
350 - public static function savesuggestData($uid, $content, $suggest_type) 351 + public static function savesuggestData($uid, $content, $image, $suggest_type)
351 { 352 {
352 $param = Yohobuy::param(); 353 $param = Yohobuy::param();
353 $param['uid'] = $uid; 354 $param['uid'] = $uid;
354 $param['content'] = $content; 355 $param['content'] = $content;
  356 + if($image !== null) {
  357 + $param['image'] = $image;
  358 + }
355 $param['suggest_type'] = $suggest_type; 359 $param['suggest_type'] = $suggest_type;
356 $param['client_secret'] = Sign::getSign($param); 360 $param['client_secret'] = Sign::getSign($param);
357 361
@@ -187,7 +187,11 @@ class Images @@ -187,7 +187,11 @@ class Images
187 187
188 if(count($file) == 1 || !is_array($file)) 188 if(count($file) == 1 || !is_array($file))
189 { 189 {
190 - $imgList['imgList'][] = array('imgUrl' => self::getSourceUrl(current($result['data']['imagesList']), 'suggest') . $imgExtra); 190 + $imgRelUrl = current($result['data']['imagesList']);
  191 + $imgList['imgList'][] = array(
  192 + 'imgUrl' => self::getSourceUrl($imgRelUrl, 'suggest') . $imgExtra,
  193 + 'imgRelUrl' => $imgRelUrl
  194 + );
191 } 195 }
192 else 196 else
193 { 197 {
@@ -195,6 +199,7 @@ class Images @@ -195,6 +199,7 @@ class Images
195 foreach ($result['data']['imagesList'] as $val) { 199 foreach ($result['data']['imagesList'] as $val) {
196 $img = array(); 200 $img = array();
197 $img['imgUrl'] = self::getSourceUrl($val, 'suggest') . $imgExtra; 201 $img['imgUrl'] = self::getSourceUrl($val, 'suggest') . $imgExtra;
  202 + $img['imgRelUrl'] = $val;
198 $imgList['imgList'][] = $img; 203 $imgList['imgList'][] = $img;
199 } 204 }
200 } 205 }
@@ -384,7 +384,8 @@ class HomeController extends AbstractAction @@ -384,7 +384,8 @@ class HomeController extends AbstractAction
384 $uid = $this->getUid(); 384 $uid = $this->getUid();
385 $content = $this->post('content', ''); 385 $content = $this->post('content', '');
386 $suggest_type = $this->post('suggest_type', 2); 386 $suggest_type = $this->post('suggest_type', 2);
387 - $result = \Index\UserModel::saveSuggestData($uid, $content, $suggest_type); 387 + $image = $this->post('image', null);
  388 + $result = \Index\UserModel::saveSuggestData($uid, $content, $image, $suggest_type);
388 389
389 $this->echoJson($result); 390 $this->echoJson($result);
390 } 391 }
@@ -487,15 +487,16 @@ class UserModel @@ -487,15 +487,16 @@ class UserModel
487 * 487 *
488 * @param int $uid 用户ID 488 * @param int $uid 用户ID
489 * @param string $content 意见内容 489 * @param string $content 意见内容
  490 + * @param mixed $image 图片地址
490 * @param int $suggest_type 意见类型 491 * @param int $suggest_type 意见类型
491 * @return array|mixed 保存意见反馈数据之后的返回 492 * @return array|mixed 保存意见反馈数据之后的返回
492 */ 493 */
493 - public static function saveSuggestData($uid, $content, $suggest_type) 494 + public static function saveSuggestData($uid, $content, $image, $suggest_type)
494 { 495 {
495 $result = array('code' => 400, 'message' => '保存出错'); 496 $result = array('code' => 400, 'message' => '保存出错');
496 497
497 // 调用接口保存意见反馈数据 498 // 调用接口保存意见反馈数据
498 - $save = UserData::savesuggestData($uid, $content, $suggest_type); 499 + $save = UserData::savesuggestData($uid, $content, $image, $suggest_type);
499 500
500 if (isset($save['code']) && $save['code'] == 200) { 501 if (isset($save['code']) && $save['code'] == 200) {
501 $result['code'] = 200; 502 $result['code'] = 200;