index.vue 4.5 KB

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