Dynamic.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <div class="usremei-container">
  3. <div class="dynamic-title">《社会保障金》</div>
  4. <div class="dynamic-desc">
  5. 通常指社会保险,是中国社会保障体系的核心组成部分,中国政府网表示,涵盖了养老保险、医疗保险、失业保险、工伤保险和生育保险五个险种。简单来说,社会保障金是国家为了保障劳动者在年老、失业、疾病、疾病、工伤和生育等情况下,能够享有生活保障而建立的社会制度。
  6. </div>
  7. <div class="invite-list">
  8. <div class="invite-item" v-for="item in rewards" :key="item.renshu">
  9. <div class="invite-info">
  10. <div class="invite-title">邀请{{ item.renshu }}人实名认证</div>
  11. <div class="invite-reward">{{ item.reward }}</div>
  12. </div>
  13. <button
  14. class="btn"
  15. :class="{
  16. 'not-reached': item.status === 'not-reached',
  17. 'received': item.status === 'received',
  18. 'can-receive': item.status === 'can-receive'
  19. }"
  20. :disabled="item.status !== 'can-receive'"
  21. @click="receiveReward(item.renshu, item.status === 'received')"
  22. >
  23. {{ item.status === 'not-reached' ? '未达标' : (item.status === 'received' ? '已领取' : '领取') }}
  24. </button>
  25. </div>
  26. </div>
  27. <!-- 实名认证提示弹窗 -->
  28. <div v-if="showAuthDialog" class="custom-dialog-mask">
  29. <div class="custom-dialog auth-dialog">
  30. <div class="dialog-close" @click="showAuthDialog = false">
  31. <i class="close-icon"></i>
  32. </div>
  33. <div class="dialog-icon">
  34. <svg t="1710401275044" class="auth-icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="6356">
  35. <path d="M512 512m-448 0a448 448 0 1 0 896 0 448 448 0 1 0-896 0Z" fill="#1890FF" p-id="6357"></path>
  36. <path d="M512 320c-17.7 0-32 14.3-32 32v256c0 17.7 14.3 32 32 32s32-14.3 32-32V352c0-17.7-14.3-32-32-32z" fill="#FFFFFF" p-id="6358"></path>
  37. <path d="M512 720m-48 0a48 48 0 1 0 96 0 48 48 0 1 0-96 0Z" fill="#FFFFFF" p-id="6359"></path>
  38. </svg>
  39. </div>
  40. <div class="dialog-title auth-title">温馨提示</div>
  41. <div class="dialog-content">您还未完成实名认证<br/>请先进行实名认证</div>
  42. <button class="dialog-btn auth-btn" @click="goToAuth">去认证</button>
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script>
  48. import { getShareccb, getShareccbList } from '@/api/profile';
  49. import { getUserInfo } from '@/api/home';
  50. export default {
  51. name: 'Dynamic',
  52. data() {
  53. return {
  54. rewards: [
  55. { renshu: 6, title: '邀请6人实名认证', reward: '奖励30积分以及60000元保障金', status: 'not-reached' },
  56. { renshu: 15, title: '邀请15人实名认证', reward: '奖励150积分以及150000元保障金', status: 'can-receive' },
  57. { renshu: 30, title: '邀请30人实名认证', reward: '奖励300积分以及300000元保障金', status: 'received' },
  58. { renshu: 60, title: '邀请60人实名认证', reward: '奖励600积分以及600000元保障金', status: 'can-receive' },
  59. { renshu: 150, title: '邀请150人实名认证', reward: '奖励1500积分以及1500000元保障金', status: 'can-receive' }
  60. ],
  61. userInfo: {},
  62. showAuthDialog: false
  63. }
  64. },
  65. methods: {
  66. async getUserInfo() {
  67. try {
  68. const res = await getUserInfo();
  69. this.userInfo = res.data;
  70. // 检查是否已实名认证
  71. if (this.userInfo.if_real === 0) {
  72. this.showAuthDialog = true;
  73. }
  74. } catch (error) {
  75. console.error('获取用户信息失败:', error);
  76. }
  77. },
  78. async getShareccbList() {
  79. try {
  80. const res = await getShareccbList();
  81. if (res.code === 1 && Array.isArray(res.data)) {
  82. // 根据接口返回的received状态,更新rewards
  83. this.rewards = this.rewards.map(item => {
  84. const found = res.data.find(d => d.renshu === item.renshu);
  85. if (found) {
  86. // 假设接口返回的状态有 received(已领取), canReceive(可领取), notReached(未达标)
  87. let status = 'not-reached';
  88. if (found.received) status = 'received';
  89. else if (found.canReceive) status = 'can-receive';
  90. return { ...item, status };
  91. }
  92. return item;
  93. });
  94. }
  95. } catch (error) {
  96. console.error('获取奖励列表失败:', error);
  97. }
  98. },
  99. async receiveReward(renshu, received) {
  100. if (received) return;
  101. if (this.userInfo.if_real === 0) {
  102. this.showAuthDialog = true;
  103. return;
  104. }
  105. try {
  106. const res = await getShareccb(renshu);
  107. alert(res.msg);
  108. this.getShareccbList();
  109. } catch (e) {
  110. // 接口异常时不弹窗
  111. }
  112. },
  113. goToAuth() {
  114. this.$router.push('/user-center');
  115. }
  116. },
  117. created() {
  118. this.getUserInfo();
  119. this.getShareccbList();
  120. }
  121. }
  122. </script>
  123. <style scoped>
  124. .usremei-container {
  125. min-height: 100vh;
  126. background: #b94040;
  127. padding-top: 30px;
  128. padding-bottom: 30px;
  129. box-sizing: border-box;
  130. overflow-y: auto;
  131. position: relative;
  132. padding-bottom: 100px;
  133. }
  134. .dynamic-title {
  135. text-align: center;
  136. font-size: 20px;
  137. font-weight: bold;
  138. color: #b94040;
  139. background: #fff;
  140. border-radius: 12px 12px 0 0;
  141. margin: 0 auto;
  142. width: 90%;
  143. padding: 18px 0 8px 0;
  144. }
  145. .dynamic-desc {
  146. background: #fff;
  147. color: #b94040;
  148. font-size: 15px;
  149. line-height: 1.7;
  150. border-radius: 0 0 12px 12px;
  151. margin: 0 auto 24px auto;
  152. width: 90%;
  153. padding: 12px 18px 18px 18px;
  154. word-break: break-all;
  155. overflow-wrap: break-word;
  156. box-sizing: border-box;
  157. }
  158. .invite-list {
  159. width: 90%;
  160. margin: 0 auto;
  161. }
  162. .invite-item {
  163. background: #fff;
  164. margin-bottom: 18px;
  165. display: flex;
  166. align-items: center;
  167. justify-content: space-between;
  168. padding: 16px 20px;
  169. border-radius: 12px;
  170. box-shadow: 0 2px 8px rgba(208,2,27,0.06);
  171. }
  172. .invite-info {
  173. display: flex;
  174. flex-direction: column;
  175. align-items: flex-start;
  176. }
  177. .invite-title {
  178. font-size: 15px;
  179. color: #222;
  180. font-weight: 600;
  181. margin-bottom: 6px;
  182. }
  183. .invite-reward {
  184. font-size: 14px;
  185. color: #d0021b;
  186. }
  187. .btn {
  188. min-width: 70px;
  189. height: 32px;
  190. border: none;
  191. border-radius: 16px;
  192. font-size: 15px;
  193. font-weight: 500;
  194. padding: 0 18px;
  195. cursor: pointer;
  196. transition: all 0.2s;
  197. }
  198. .btn.not-reached {
  199. background: #bdbdbd;
  200. color: #fff;
  201. }
  202. .btn.can-receive {
  203. background: #b94040;
  204. color: #fff;
  205. }
  206. .btn.received {
  207. background: #fff;
  208. color: #bdbdbd;
  209. border: 1px solid #bdbdbd;
  210. }
  211. .custom-dialog-mask {
  212. position: fixed;
  213. top: 0;
  214. left: 0;
  215. right: 0;
  216. bottom: 0;
  217. background: rgba(0, 0, 0, 0.6);
  218. display: flex;
  219. align-items: center;
  220. justify-content: center;
  221. z-index: 9999;
  222. }
  223. .custom-dialog {
  224. position: relative;
  225. width: 280px;
  226. background: #fff;
  227. border-radius: 12px;
  228. padding: 20px;
  229. text-align: center;
  230. animation: dialogFadeIn 0.3s ease;
  231. }
  232. .dialog-icon {
  233. width: 60px;
  234. height: 60px;
  235. margin: 0 auto 16px;
  236. }
  237. .auth-icon {
  238. width: 100%;
  239. height: 100%;
  240. }
  241. .dialog-title {
  242. font-size: 18px;
  243. font-weight: 500;
  244. margin-bottom: 12px;
  245. }
  246. .auth-title {
  247. color: #1890FF;
  248. }
  249. .dialog-content {
  250. font-size: 14px;
  251. color: #666;
  252. line-height: 1.8;
  253. margin: 16px 0 24px;
  254. }
  255. .dialog-btn {
  256. width: 100%;
  257. height: 40px;
  258. border: none;
  259. border-radius: 20px;
  260. font-size: 16px;
  261. color: #fff;
  262. cursor: pointer;
  263. transition: all 0.3s ease;
  264. }
  265. .auth-btn {
  266. background: #1890FF;
  267. }
  268. .auth-btn:hover {
  269. background: #40a9ff;
  270. }
  271. .auth-dialog {
  272. box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  273. }
  274. .dialog-close {
  275. position: absolute;
  276. top: 12px;
  277. right: 12px;
  278. width: 24px;
  279. height: 24px;
  280. display: flex;
  281. align-items: center;
  282. justify-content: center;
  283. cursor: pointer;
  284. transition: all 0.3s ease;
  285. }
  286. .dialog-close:hover {
  287. transform: rotate(90deg);
  288. }
  289. .dialog-close .close-icon {
  290. position: relative;
  291. width: 16px;
  292. height: 16px;
  293. }
  294. .dialog-close .close-icon::before,
  295. .dialog-close .close-icon::after {
  296. content: '';
  297. position: absolute;
  298. width: 100%;
  299. height: 2px;
  300. background-color: #999;
  301. top: 50%;
  302. left: 0;
  303. }
  304. .dialog-close .close-icon::before {
  305. transform: rotate(45deg);
  306. }
  307. .dialog-close .close-icon::after {
  308. transform: rotate(-45deg);
  309. }
  310. @keyframes dialogFadeIn {
  311. from {
  312. opacity: 0;
  313. transform: scale(0.9);
  314. }
  315. to {
  316. opacity: 1;
  317. transform: scale(1);
  318. }
  319. }
  320. </style>