success.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <view class="success-page">
  3. <!-- 顶部标题区 -->
  4. <view class="header">
  5. <text class="header-title">盐龙街道住宅小区物业公司选聘调研</text>
  6. </view>
  7. <!-- 提交成功提示 -->
  8. <view class="success提示">
  9. <!-- <view class="success-icon">
  10. <uni-icons type="success" size="60" color="#00B42A"></uni-icons>
  11. </view> -->
  12. <text class="success-text">提交成功!</text>
  13. <text class="sub-text">感谢您的参与,您的意见将被认真对待</text>
  14. </view>
  15. <!-- 投票统计区 -->
  16. <view class="stats-container">
  17. <text class="name-text">{{name}}投票进度</text>
  18. <!-- 已投/未投统计 -->
  19. <view class="vote-count">
  20. <view class="count-item">
  21. <text class="count-num">{{ totalVoted }}</text>
  22. <text class="count-label">已投票</text>
  23. </view>
  24. <view class="count-item">
  25. <text class="count-num">{{ totalUnvoted }}</text>
  26. <text class="count-label">未投票</text>
  27. </view>
  28. <view class="count-item">
  29. <text class="count-num">{{ totalVoters }}</text>
  30. <text class="count-label">总户数</text>
  31. </view>
  32. </view>
  33. <!-- 选项占比统计 -->
  34. <view class="options-stats">
  35. <text class="stats-title">各选项占比</text>
  36. <!-- 占比列表 -->
  37. <view class="option-item" v-for="(item, index) in voteOptions" :key="index">
  38. <view class="option-info">
  39. <text class="option-name">{{ item.name }}</text>
  40. <text class="option-ratio">{{ item.ratio }}%</text>
  41. </view>
  42. <!-- 进度条 -->
  43. <view class="progress-bar">
  44. <view
  45. class="progress"
  46. :style="{
  47. width: item.ratio + '%',
  48. backgroundColor: item.color
  49. }"
  50. ></view>
  51. </view>
  52. <!-- 票数详情 -->
  53. <text class="votes-detail">{{ item.votes }} 票</text>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- 底部按钮 -->
  58. <!-- <view class="btn-group">
  59. <button class="back-btn" @click="navigateBack">返回首页</button>
  60. <button class="share-btn" @click="handleShare">分享结果</button>
  61. </view> -->
  62. </view>
  63. </template>
  64. <script>
  65. import voteRecordService from "@/api/vote/voteRecordService.js"
  66. export default {
  67. data() {
  68. return {
  69. name:'',
  70. // 总数据(实际项目中从接口获取)
  71. totalVoters: 568, // 总户数
  72. totalVoted: 326, // 已投票数
  73. totalUnvoted: 242, // 未投票数(计算得出:totalVoters - totalVoted)
  74. // 选项数据(实际项目中从接口获取)
  75. voteOptions: [
  76. { name: '续签', value: '1', votes: 185, ratio: 56.7, color: '#1677ff' },
  77. { name: '公开招标', value: '2', votes: 98, ratio: 30.1, color: '#36d399' },
  78. { name: '弃权', value: '3', votes: 32, ratio: 9.8, color: '#722ed1' },
  79. { name: '其他', value: '4', votes: 11, ratio: 3.4, color: '#ff7d00' }
  80. ]
  81. };
  82. },
  83. onLoad(options) {
  84. console.log(options)
  85. if(options.id){
  86. this.getStatistics(options.id)
  87. }
  88. // 实际项目中从接口获取数据后更新
  89. // 示例:this.fetchVoteStats();
  90. },
  91. methods: {
  92. // 模拟从接口获取数据
  93. getStatistics(id) {
  94. var _this=this
  95. voteRecordService.getStatistics(id).then((data) => {
  96. if(data.length>0){
  97. var res=data[0]
  98. _this.totalVoters=res.allcount
  99. _this.totalVoted=res.ytcount
  100. _this.totalUnvoted=res.wtcount
  101. _this.voteOptions[0].votes=res.xqCount
  102. _this.voteOptions[0].ratio=res.xqPct
  103. _this.voteOptions[1].votes=res.zbCount
  104. _this.voteOptions[1].ratio=res.zbPct
  105. _this.voteOptions[2].votes=res.qqCount
  106. _this.voteOptions[2].ratio=res.qqPct
  107. _this.voteOptions[3].votes=res.qtCount
  108. _this.voteOptions[3].ratio=res.qtPct
  109. _this.name=res.name
  110. }
  111. console.log(data)
  112. }).catch(e => {
  113. console.error(e)
  114. })
  115. },
  116. // 返回首页
  117. navigateBack() {
  118. uni.reLaunch({
  119. url: '/pages/index/index' // 替换为首页路径
  120. });
  121. },
  122. // 分享结果
  123. handleShare() {
  124. // 调用Uniapp分享API
  125. uni.share({
  126. title: '盐龙街道物业选聘投票结果',
  127. path: '/pages/success/vote-success', // 分享页面路径
  128. imageUrl: '/static/share-img.png', // 分享图片(需提前准备)
  129. success: () => {
  130. uni.showToast({ title: '分享成功', icon: 'none' });
  131. },
  132. fail: (err) => {
  133. console.log('分享失败', err);
  134. }
  135. });
  136. }
  137. }
  138. };
  139. </script>
  140. <style scoped>
  141. .success-page {
  142. min-height: 100vh;
  143. background-color: #f5f7fa;
  144. padding-bottom: 30px;
  145. }
  146. /* 顶部标题栏 */
  147. .header {
  148. background-color: #00aaff;
  149. padding: 25rpx 20rpx;
  150. text-align: center;
  151. }
  152. .header-title {
  153. color: #ffffff;
  154. font-size: 32rpx;
  155. font-weight: 500;
  156. line-height: 1.5;
  157. }
  158. /* 成功提示区 */
  159. .success提示 {
  160. padding: 20px 0 20px;
  161. text-align: center;
  162. background-color: #fff;
  163. margin-bottom: 15px;
  164. }
  165. .success-icon {
  166. margin-bottom: 15px;
  167. }
  168. .success-text {
  169. font-size: 20px;
  170. color: #333;
  171. font-weight: 600;
  172. display: block;
  173. margin-bottom: 8px;
  174. }
  175. .sub-text {
  176. font-size: 14px;
  177. color: #666;
  178. }
  179. /* 统计容器 */
  180. .stats-container {
  181. width: 92%;
  182. margin: 0 auto;
  183. background-color: #fff;
  184. border-radius: 10px;
  185. padding: 10px 15px;
  186. box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  187. }
  188. .name-text{
  189. display: flex;
  190. align-items: center;
  191. justify-content: center;
  192. margin: 0 auto;
  193. width: 100%;
  194. text-align: center;
  195. font-size: 16px;
  196. font-weight: 800;
  197. margin-bottom: 10px;
  198. letter-spacing: 2px;
  199. }
  200. /* 已投/未投统计 */
  201. .vote-count {
  202. display: flex;
  203. justify-content: space-around;
  204. margin-bottom: 15px;
  205. padding-bottom: 20px;
  206. border-bottom: 1px solid #f0f0f0;
  207. }
  208. .count-item {
  209. text-align: center;
  210. }
  211. .count-num {
  212. font-size: 24px;
  213. font-weight: 700;
  214. color: #1677ff;
  215. display: block;
  216. margin-bottom: 5px;
  217. }
  218. .count-label {
  219. font-size: 14px;
  220. color: #666;
  221. }
  222. /* 选项占比统计 */
  223. .options-stats {
  224. margin-top: 10px;
  225. }
  226. .stats-title {
  227. font-size: 16px;
  228. font-weight: 500;
  229. color: #333;
  230. display: block;
  231. margin-bottom: 15px;
  232. padding-left: 5px;
  233. }
  234. /* 单个选项样式 */
  235. .option-item {
  236. margin-bottom: 20px;
  237. }
  238. .option-info {
  239. display: flex;
  240. justify-content: space-between;
  241. margin-bottom: 8px;
  242. }
  243. .option-name {
  244. font-size: 15px;
  245. color: #444;
  246. }
  247. .option-ratio {
  248. font-size: 14px;
  249. font-weight: 500;
  250. color: #1677ff;
  251. }
  252. /* 进度条样式 */
  253. .progress-bar {
  254. height: 8px;
  255. width: 100%;
  256. background-color: #f0f0f0;
  257. border-radius: 4px;
  258. overflow: hidden;
  259. margin-bottom: 5px;
  260. }
  261. .progress {
  262. height: 100%;
  263. border-radius: 4px;
  264. transition: width 0.5s ease;
  265. }
  266. /* 票数详情 */
  267. .votes-detail {
  268. font-size: 12px;
  269. color: #999;
  270. }
  271. /* 底部按钮组 */
  272. .btn-group {
  273. width: 92%;
  274. margin: 30px auto 0;
  275. display: flex;
  276. gap: 15px;
  277. }
  278. .back-btn, .share-btn {
  279. flex: 1;
  280. height: 45px;
  281. line-height: 45px;
  282. border-radius: 8px;
  283. font-size: 16px;
  284. font-weight: 500;
  285. }
  286. .back-btn {
  287. background-color: #fff;
  288. color: #333;
  289. border: 1px solid #eee;
  290. }
  291. .share-btn {
  292. background-color: #1677ff;
  293. color: #fff;
  294. border: none;
  295. }
  296. </style>