detail.html 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. {extend name="public/base"/}
  2. {block name="css"}
  3. <style>
  4. .article{
  5. background:white;
  6. padding:0 10px;
  7. margin-bottom:10px;
  8. }
  9. .article h3{
  10. padding:10px 0;
  11. margin:0;
  12. }
  13. .article .article-info{
  14. align-items:center;
  15. display:flex;
  16. justify-content:space-between;
  17. margin:5px;
  18. font-size:12px;
  19. }
  20. .article .article-info .s-time{
  21. color:#b4b4b4;
  22. }
  23. .article .article-info .s-comment{
  24. background:#f5f7f9;
  25. border-radius:5px;
  26. flex-shrink:0;
  27. font-size:14px;
  28. padding:5px 10px;
  29. }
  30. .content{
  31. padding-bottom:1px;
  32. }
  33. .content, .content img{
  34. max-width:100%;
  35. }
  36. </style>
  37. {/block}
  38. {block name="body"}
  39. <van-nav-bar
  40. class="nav-theme"
  41. :fixed="true"
  42. :placeholder="true"
  43. left-text="返回"
  44. left-arrow
  45. @click-left="onBack"
  46. >
  47. <template #title>
  48. <span class="text-white">活动详情</span>
  49. </template>
  50. </van-nav-bar>
  51. <div class="article">
  52. <header>
  53. <h3>{$info.title}</h3>
  54. <section class="article-info">
  55. <div class="s-author">
  56. <div class="s-time">
  57. <time>{$info.start_time} 至 {$info.end_time}</time>
  58. </div>
  59. </div>
  60. </section>
  61. </header>
  62. <section class="content">
  63. {$info.content}
  64. </section>
  65. </div>
  66. <van-radio-group v-model="checked" :disabled="is_apply">
  67. <van-cell-group inset>
  68. {volist name="info.option" id="v"}
  69. <van-cell title="{$v}" clickable @click="onOption('{$v}')">
  70. <template #right-icon>
  71. <van-radio name="{$v}"></van-radio>
  72. </template>
  73. </van-cell>
  74. {/volist}
  75. <van-button type="primary" block @click="submit" v-if="!is_apply">提交</van-button>
  76. </van-cell-group>
  77. </van-radio-group>
  78. {/block}
  79. {block name="script"}
  80. <script>
  81. function v_setup() {
  82. let base = {};
  83. base.is_click = false;
  84. base.is_apply = Vue.ref({$is_apply});
  85. base.checked = Vue.ref('{$option_name}');
  86. base.onBack = () => {
  87. location.href = "{:url('/')}";
  88. };
  89. base.onOption = (v) => {
  90. if (base.is_apply.value) {
  91. return false;
  92. }
  93. base.checked.value = v;
  94. };
  95. base.submit = () => {
  96. if (base.is_click) {
  97. return false;
  98. }
  99. base.is_click = true;
  100. if (base.checked.value === '') {
  101. vant.showFailToast('请选择投票的项目');
  102. base.is_click = false;
  103. return false;
  104. }
  105. postJson('/vote/apply', {option_name: base.checked.value, id: {$info.id}}).then(({data, code}) => {
  106. base.is_click = false;
  107. if (code === 0) {
  108. vant.showSuccessToast('投票成功');
  109. base.is_apply.value = true;
  110. }
  111. })
  112. };
  113. return base;
  114. }
  115. </script>
  116. {/block}