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
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = MQingshiAuthor::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'create_time' => $this->create_time, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'gh_id', $this->gh_id])->andFilterWhere(['like', 'author_openid', $this->author_openid])->andFilterWhere(['like', 'p1', $this->p1])->andFilterWhere(['like', 'p2', $this->p2])->andFilterWhere(['like', 'p3', $this->p3]);
     return $dataProvider;
 }
Ejemplo n.º 3
0
 /**
  * Finds the MQingshiAuthor model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return MQingshiAuthor the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = MQingshiAuthor::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 4
0
 public function actionQingshiVote()
 {
     $this->layout = false;
     $id = $_GET["id"];
     //$gh_id = U::getSessionParam('gh_id');
     $gh_id = 'gh_03a74ac96138';
     $openid = U::getSessionParam('openid');
     $wx_user = \app\models\MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
     if (empty($wx_user) || $wx_user->subscribe === 0) {
         return $this->render('need_subscribe');
     }
     $qingshi_author = \app\models\MQingshiAuthor::findOne(['id' => $id]);
     return $this->render('qingshi-vote', ['observer' => $wx_user, 'qingshi_author' => $qingshi_author]);
 }
Ejemplo n.º 5
0
echo "<h2>情诗内容</h2><hr>";
echo "<h3>" . $model->p1 . "</h3>";
echo "<h3>" . $model->p2 . "</h3>";
echo "<h3>" . $model->p3 . "</h3>";
?>

    <br> <br>
    <!--
    <//?= $form->field($model, 'create_time')->textInput() ?>
    -->

    <!--
    <//?= $form->field($model, 'status')->textInput() ?>
    -->

    <?php 
echo $form->field($model, 'status')->dropDownList(MQingshiAuthor::getQingshiStatusOption());
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? '创建' : '修改', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Ejemplo n.º 6
0
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <!--
    <p>
        <//?= Html::a('Create Mqingshi Author', ['create'], ['class' => 'btn btn-success']) ?>
    </p>
    -->

    <p>
        <?php 
echo Html::a('投票排行', ['qingshi-score/index'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['label' => '微信昵称', 'format' => 'html', 'value' => function ($model, $key, $index, $column) {
    $user = $model->user;
    return empty($user) ? '' : "<img width=48 src=" . $model->user->headimgurl . "><br>" . emoji_unified_to_html(emoji_softbank_to_unified($user->nickname));
}, 'filter' => false, 'headerOptions' => array('style' => 'width:90px;')], 'p1', 'p2', 'p3', ['attribute' => 'create_time', 'headerOptions' => array('style' => 'width:90px;')], ['attribute' => 'status', 'label' => '状态', 'value' => function ($model, $key, $index, $column) {
    return MQingshiAuthor::getQingshiStatusOption($model->status);
}, 'filter' => MQingshiAuthor::getQingshiStatusOption(), 'headerOptions' => array('style' => 'width:120px;')], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}', 'buttons' => ['update' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, ['title' => Yii::t('yii', 'Update'), 'data-pjax' => '0']);
}, 'delete' => function ($url, $model) {
    return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['title' => Yii::t('yii', 'Delete'), 'data-confirm' => Yii::t('yii', '确认要删除?'), 'data-method' => 'post', 'data-pjax' => '0']);
}]]]]);
?>

</div>
Ejemplo n.º 7
0
            <ul class="table-view">

            <li class="table-view-cell media">
                <div class="media-body">
                    名次
                </div>

                <span class="badge" style="font-size: 12pt">
                    所得票数
                </span>
            </li>

            <?php 
foreach ($votes as $vote) {
    $top++;
    $author = \app\models\MQingshiAuthor::findOne(['author_openid' => $vote->author_openid]);
    ?>

              <li class="table-view-cell media">
                <a  data-ignore="push" class="navigate-right" href="<?php 
    echo \yii\helpers\Url::to(['qingshi-vote', 'id' => $author->id]);
    ?>
">

                <sapn class="pull-left" style="font-size: 18pt; font-weight: bolder;color:green;">
                    <?php 
    echo $top;
    ?>
.
                    &nbsp;&nbsp;
                </sapn>