index.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <script>
  2. import Banner from "@/components/index/banner";
  3. import Welcome from "@/components/index/welcome";
  4. import Login from "@/components/index/login";
  5. import Cards from "@/components/index/cards";
  6. import Connection from "@/components/connection/index";
  7. import Toast from "../../../static/vant/toast/toast";
  8. import {setUserLogin} from "../../requests/user";
  9. import user_store from "../../store/index";
  10. let $this;
  11. export default {
  12. name: "index_container",
  13. components: {
  14. Banner,
  15. Welcome,
  16. Login,
  17. Cards,
  18. Connection,
  19. },
  20. data() {
  21. return {
  22. // 欢迎界面0,注册1 登录2
  23. welcome_status: 0,
  24. // 登录状态
  25. is_login: false
  26. };
  27. },
  28. created() {
  29. $this = this;
  30. },
  31. methods: {
  32. /**
  33. * 切换 注册/登录
  34. * @param $status 欢迎界面0,注册1,登录2
  35. */
  36. changeWelcome($status) {
  37. this.welcome_status = $status;
  38. },
  39. //修改登录状态
  40. changeLoginStatus() {
  41. this.is_login = user_store.getters.get_login_status();
  42. },
  43. //跳转页面
  44. pageTo($page) {
  45. if (!this.is_login) {
  46. Toast.fail("请先登录");
  47. return false;
  48. }
  49. mpvue.navigateTo({
  50. url: "/pages/" + $page + "/main",
  51. });
  52. }
  53. },
  54. onLoad() {
  55. // if (process.env.NODE_ENV == "development") {
  56. // wx.setStorageSync('token', "WxN3rgbWyVpjyBhi4uT6mZmwajZ3dFlm");
  57. // }
  58. // 判断存储是否登录
  59. let $token = wx.getStorageSync("token");
  60. if ($token) {
  61. user_store.setters.set_token($token);
  62. user_store.setters.set_login(true);
  63. this.is_login = user_store.getters.get_login_status();
  64. // 登录小程序录入
  65. setUserLogin();
  66. }
  67. },
  68. onShareAppMessage() {
  69. return {
  70. title: "欢迎进入水母星球",
  71. imageUrl: "http://img.shuimuai.com/sharePahe_one.jpg",
  72. path: "/pages/index/main",
  73. };
  74. },
  75. };
  76. </script>
  77. <template>
  78. <div id="container">
  79. <!-- banner模块 -->
  80. <Banner></Banner>
  81. <!-- 未登录 登录窗口模块-->
  82. <div v-if="!is_login" class="login_card">
  83. <!-- 欢迎模块 -->
  84. <Welcome v-if="welcome_status===0" @signStatus="changeWelcome"></Welcome>
  85. <!--登录注册窗口 -->
  86. <Login v-else :sign="welcome_status" @welcomeStatus="changeWelcome" @loginStatus="changeLoginStatus"></Login>
  87. </div>
  88. <!-- 登陆后 个人首页-->
  89. <div v-if="is_login" class="personal_card">
  90. <Cards></Cards>
  91. <Connection></Connection>
  92. </div>
  93. <div class="service" :class="{'service_login_page':!is_login}">
  94. <view class="padding-tb">
  95. <text class="cuIcon-titles text-primary"></text>
  96. <text class="">功能服务</text>
  97. </view>
  98. <div class="content">
  99. <van-row>
  100. <van-col span="12">
  101. <img src="https://img.shuimuai.com/web/index_btn_chengjijilu.png" @click="pageTo('game_record')">
  102. </van-col>
  103. <van-col span="12">
  104. <img src="https://img.shuimuai.com/web/index_btn_gerenzhongxin.png" @click="pageTo('user_center')">
  105. </van-col>
  106. </van-row>
  107. </div>
  108. </div>
  109. <van-toast id="van-toast"/>
  110. <van-dialog id="van-dialog"/>
  111. <van-notify id="van-notify"/>
  112. </div>
  113. </template>
  114. <style scoped>
  115. /*@import "index.css";*/
  116. .login_card {
  117. height: 335px;
  118. background-color: #ffffff;
  119. position: relative;
  120. z-index: 3;
  121. top: -90px;
  122. margin: 0px 10px;
  123. background-image: url(https://img.shuimuai.com/shuimugongzhu.png);
  124. background-position: center;
  125. background-size: 100% 100%;
  126. background-color: rgba(255, 255, 255, 0);
  127. }
  128. /* 功能服务 */
  129. .service {
  130. position: absolute;
  131. width: 100%;
  132. top: 570px;
  133. z-index: 1;
  134. }
  135. .service_login_page {
  136. top: 500px !important;
  137. }
  138. .service .content {
  139. width: 100%;
  140. }
  141. .service .content image {
  142. width: 186px;
  143. height: 89px;
  144. }
  145. .head .line {
  146. width: 4px;
  147. height: 14px;
  148. background-color: #5d4db8;
  149. margin-right: 7px;
  150. }
  151. .head view {
  152. display: flex;
  153. justify-self: start;
  154. align-items: center;
  155. }
  156. .personal_card {
  157. height: 300px;
  158. position: relative;
  159. z-index: 5;
  160. }
  161. </style>