main.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <view class="content">
  3. <view class="cu-bar bg-white solid-bottom">
  4. <view class="action">
  5. <!-- <text class="cuIcon-title text-blue"></text>按钮形状 -->
  6. </view>
  7. <view class="action">
  8. <navigator class="action" url="design" hover-class="none">
  9. <text class="text-df text-purple" @tap="onNavUser">编辑</text>
  10. </navigator>
  11. </view>
  12. </view>
  13. <view class="cu-card">
  14. <view class="cu-item shadow">
  15. <view class="content">
  16. <view class="solids-bottom padding-xs flex align-center">
  17. <view class="flex-sub text-center">
  18. <view class="cu-avatar xl round margin-left" style="background-image:url(https://ossweb-img.qq.com/images/lol/web201310/skin/big99008.jpg);"></view>
  19. <view class="solid-bottom text-lg padding">
  20. <text class="text-black">ColorUI组件库</text>
  21. </view>
  22. <view class="padding">页面小标题,首要层级显示内容</view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="cu-card article">
  29. <view class="cu-item shadow">
  30. <view class="title"><view class="text-cut">最近在玩</view></view>
  31. <view class="content">
  32. <image src="https://ossweb-img.qq.com/images/lol/web201310/skin/big10006.jpg"
  33. mode="aspectFill"></image>
  34. <view class="desc">
  35. <view class="text-content"> 折磨生出苦难,苦难又会加剧折磨,凡间这无穷的循环,将有我来终结!真正的恩典因不完整而美丽,因情感而真诚,因脆弱而自由!</view>
  36. <view>
  37. <view class="cu-tag bg-red light sm round">正义天使</view>
  38. <view class="cu-tag bg-green light sm round">史诗</view>
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="cu-card article">
  45. <view class="cu-item shadow">
  46. <view class="title"><view class="text-cut">关注游戏</view></view>
  47. <view class="content">
  48. <image src="https://ossweb-img.qq.com/images/lol/web201310/skin/big10006.jpg"
  49. mode="aspectFill"></image>
  50. <view class="desc">
  51. <view class="text-content"> 折磨生出苦难,苦难又会加剧折磨,凡间这无穷的循环,将有我来终结!真正的恩典因不完整而美丽,因情感而真诚,因脆弱而自由!</view>
  52. <view>
  53. <view class="cu-tag bg-red light sm round">正义天使</view>
  54. <view class="cu-tag bg-green light sm round">史诗</view>
  55. </view>
  56. </view>
  57. </view>
  58. </view>
  59. </view>
  60. <view v-if="hasLogin" class="hello">
  61. <view class="title">
  62. 您好 {{userName}},您已成功登录。
  63. </view>
  64. <view class="ul">
  65. <view>这是 uni-app 带登录模板的示例App首页。</view>
  66. <view>在 “我的” 中点击 “退出” 可以 “注销当前账户”</view>
  67. </view>
  68. </view>
  69. <view v-if="!hasLogin" class="hello">
  70. <view class="title">
  71. 您好 游客。
  72. </view>
  73. <view class="ul">
  74. <view>这是 uni-app 带登录模板的示例App首页。</view>
  75. <view>在 “我的” 中点击 “登录” 可以 “登录您的账户”</view>
  76. </view>
  77. </view>
  78. </view>
  79. </template>
  80. <script>
  81. import {
  82. mapState
  83. } from 'vuex'
  84. export default {
  85. computed: mapState(['forcedLogin', 'hasLogin', 'userName']),
  86. onLoad() {
  87. if (!this.hasLogin) {
  88. uni.showModal({
  89. title: '未登录',
  90. content: '您未登录,需要登录后才能继续',
  91. /**
  92. * 如果需要强制登录,不显示取消按钮
  93. */
  94. showCancel: !this.forcedLogin,
  95. success: (res) => {
  96. if (res.confirm) {
  97. /**
  98. * 如果需要强制登录,使用reLaunch方式
  99. */
  100. if (this.forcedLogin) {
  101. uni.reLaunch({
  102. url: '../login/login'
  103. });
  104. } else {
  105. uni.navigateTo({
  106. url: '../login/login'
  107. });
  108. }
  109. }
  110. }
  111. });
  112. }
  113. },
  114. methods:{
  115. onNavUser(){
  116. uni.navigateTo({
  117. url: '../user/user'
  118. });
  119. }
  120. }
  121. }
  122. </script>
  123. <style>
  124. .hello {
  125. display: flex;
  126. flex: 1;
  127. flex-direction: column;
  128. }
  129. .title {
  130. color: #8f8f94;
  131. margin-top: 50upx;
  132. }
  133. .ul {
  134. font-size: 30upx;
  135. color: #8f8f94;
  136. margin-top: 50upx;
  137. }
  138. .ul>view {
  139. line-height: 50upx;
  140. }
  141. </style>