dever 7 лет назад
Родитель
Сommit
1333d35604
2 измененных файлов с 20 добавлено и 3 удалено
  1. 4 0
      assets/html/home.html
  2. 16 3
      src/Api.php

+ 4 - 0
assets/html/home.html

@@ -30,7 +30,11 @@
           <blockquote class="layui-elem-quote layui-quote-nm" <{if(isset($v2['checked'])):}>style="border-color: #1f25e2;"<{endif}>><{if($v2['pic']):}><img src="<{$v2['pic']}>" style="width:200px;" /><{else:}><{$v2['title']}><{endif}>&nbsp;&nbsp; <{if(isset($v2['checked']) && !is_numeric($v2['checked'])):}><{$v2['checked']}><{endif}></blockquote>
           <{endloop}>
           <{else:}>
+          <{if(isset($v1['answer'])):}>
           <p><{$v1['answer']}></p>
+          <{else:}>
+          <p>未作答</p>
+          <{endif}>
           <{endif}>
         </div>
       </div>

+ 16 - 3
src/Api.php

@@ -126,7 +126,7 @@ class Api
 	 *
 	 * @return mixed
 	 */
-	public function view($uid, $product_id, $order_id)
+	public function view($uid, $product_id, $order_id, $result = false)
 	{
 		$product = Dever::config('base', 'project')->product;
 
@@ -150,7 +150,11 @@ class Api
 			$answer = Dever::db('survey/user_answer')->one(array('uid' => $uid, 'info_id' => $v['id'], 'product_id' => $product_id, 'order_id' => $order_id));
 			if ($answer) {
 				if (($v['type'] == 3 || $v['type'] == 4) && strstr($answer['value'], 'http')) {
-					$answer['value'] = $this->getImg($answer['id'], $answer['value']);
+					if ($v) {
+						$answer['value'] = $this->getImg($answer['id'], $answer['value']);
+					} else {
+						$answer['value'] = Dever::local($answer['value']);
+					}
 				} elseif ($v['type'] == 12 || $v['type'] == 13) {
 					$v['content'] = $this->getOption($answer['id'], $answer['value'], $v['content']);
 				}
@@ -159,7 +163,12 @@ class Api
 				$v['answer'] = '未作答';
 			}
 			
-			$data['question'][$v['page_number']][$i] = $v;
+			if ($result) {
+				$data['question'][$i] = $v;
+			} else {
+				$data['question'][$v['page_number']][$i] = $v;
+			}
+			
 			$i++;
 		}
 
@@ -172,6 +181,10 @@ class Api
 			$data['page'] = $num . '%';
 		}
 
+		if ($result) {
+			return $data;
+		}
+
 		return Dever::render('home', $data);
 	}