Ejemplo n.º 1
0
 public static function toupiaoAjax($author_openid, $vote_openid)
 {
     $qingshi_vote = self::findOne(['vote_openid' => $vote_openid]);
     if (empty($qingshi_vote)) {
         $qingshi_vote = new \app\models\MQingshiVote();
     } else {
         //已经投过一次票了,提示用户已投过票,只能每人只能投一次票哟
         return \yii\helpers\Json::encode(['code' => 11]);
     }
     $qingshi_vote->author_openid = $author_openid;
     $qingshi_vote->vote_openid = $vote_openid;
     $qingshi_vote->save(false);
     //写入到投票表中;
     $qingshi_score = \app\models\MQingshiScore::findOne(['author_openid' => $author_openid]);
     U::W($qingshi_score);
     if (empty($qingshi_score)) {
         $qingshi_score = new \app\models\MQingshiScore();
     }
     $qa = \app\models\MQingshiAuthor::findOne(['author_openid' => $author_openid]);
     $qingshi_score->author_openid = $author_openid;
     $qingshi_score->score = $qingshi_score->score + 1;
     $qingshi_score->status = 0;
     $qingshi_score->create_time = $qa->create_time;
     $qingshi_score->save(false);
     return \yii\helpers\Json::encode(['code' => 0]);
 }
Ejemplo n.º 2
0
 /**
  * Finds the MQingshiScore model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MQingshiScore the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MQingshiScore::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 3
0
            <?php 
} else {
    ?>
                <img width="128" src='/wx/web/images/wxmpres/headimg-blank.png' ><br>
                <?php 
    echo emoji_unified_to_html(emoji_softbank_to_unified($qingshi_author->user->nickname));
    ?>
            <?php 
}
?>
        </p>

        <center>

            <?php 
$vote_count = \app\models\MQingshiScore::findOne(['author_openid' => $qingshi_author->author_openid]);
if (empty($vote_count)) {
    ?>
                <span class="vt">得</span>
                <span class="badge" style="color:#bbb6d4; font-size: 14pt">
                    0
                </span>
                <span class="vt">票</span>
            <?php 
} else {
    ?>
                <span class="vt">得</span>
                <span class="badge" style="font-size: 14pt">
                    <?php 
    echo $vote_count->score;
    ?>