index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <template>
  2. <div id="container">
  3. <!-- banner模块-->
  4. <banner></banner>
  5. <!-- 未登录 登录窗口模块-->
  6. <div
  7. class="login_card"
  8. v-if="!is_login"
  9. >
  10. <!-- 登录窗口-->
  11. <login_container
  12. v-if="login_status == 'login'"
  13. @changeStatus="change_status"
  14. @changeTitle="change_title"
  15. ></login_container>
  16. <!-- 注册窗口-->
  17. <regist_container
  18. v-if="login_status == 'regist'"
  19. @changeStatus='change_status'
  20. @change_login_status="change_login_status"
  21. :title="regist_title"
  22. ></regist_container>
  23. </div>
  24. <!-- 登陆后 的个人首页-->
  25. <div
  26. class="personal_card"
  27. v-if="is_login"
  28. >
  29. <personal_container @change_login_status="change_login_status"></personal_container>
  30. <device_container></device_container>
  31. </div>
  32. <div
  33. class="service"
  34. :class="{'service_login_page':is_login==false}"
  35. >
  36. <view class="padding-tb">
  37. <text class="cuIcon-titles text-primary"></text>
  38. <text class="">功能服务</text>
  39. </view>
  40. <div class="content">
  41. <van-row>
  42. <van-col span="12">
  43. <img
  44. src="https://img.shuimuai.com/index_btn_chongzhizhongxin.png"
  45. @click="to_page('user_center/recharge')"
  46. >
  47. </van-col>
  48. <van-col span="12">
  49. <img
  50. src="https://img.shuimuai.com/web/index_btn_gerenzhongxin.png"
  51. @click="to_page('user_center')"
  52. >
  53. </van-col>
  54. </van-row>
  55. <van-row>
  56. <van-col span="12">
  57. <img
  58. src="https://img.shuimuai.com/web/index_btn_chengjijilu.png"
  59. @click="to_page('game_record')"
  60. >
  61. </van-col>
  62. <van-col span="12">
  63. <img
  64. src="https://img.shuimuai.com/index_btn_dailishang.png"
  65. @click="to_page('agent/index')"
  66. >
  67. </van-col>
  68. </van-row>
  69. </div>
  70. </div>
  71. <van-toast id="van-toast" />
  72. <van-dialog id="van-dialog" />
  73. <!-- <button class="cu-btn lg cu-btn-primary text-white text-center margin-tb" @click="auth_msg">获取消息授权-->
  74. <!-- </button>-->
  75. </div>
  76. </template>
  77. <script>
  78. import banner from "@/components/banner";
  79. import login_container from "@/components/index/login";
  80. import regist_container from "@/components/index/regist";
  81. import personal_container from "@/components/index/personal";
  82. import device_container from "@/components/device/device";
  83. import Toast from "../../../static/vant/toast/toast";
  84. import Dialog from "../../../static/vant/dialog/dialog";
  85. import { userDetail, setUserLogin } from "../../requests/user";
  86. import user_store from "../../store/index";
  87. import game_store from "../../store/game";
  88. import game_util, { post_data } from "../../utils/game";
  89. var $this;
  90. export default {
  91. name: "index_container",
  92. components: {
  93. banner,
  94. login_container,
  95. regist_container,
  96. personal_container,
  97. device_container,
  98. },
  99. data() {
  100. return {
  101. // 三种状态 扫码scan 注册regist 登录login
  102. login_status: "login",
  103. // is_login: false,
  104. is_login: false,
  105. regist_title: "",
  106. };
  107. },
  108. methods: {
  109. get_init_data() {},
  110. //切换到扫码
  111. change_status($status) {
  112. this.login_status = $status;
  113. },
  114. //跳转充值中心
  115. to_recharge() {
  116. mpvue.navigateTo({
  117. url: "/pages/user_center/recharge/main",
  118. });
  119. },
  120. //修改登录状态
  121. change_login_status() {
  122. this.is_login = user_store.getters.get_login_status();
  123. },
  124. // 修改界面的文字
  125. change_title($status) {
  126. if ($status == 0) {
  127. this.regist_title = "注册";
  128. } else if ($status == 1) {
  129. this.regist_title = "登录";
  130. }
  131. },
  132. //跳转页面
  133. to_page($page) {
  134. if ($page == "agent/index") {
  135. //店员店长不可进
  136. if ($this.userinfo.level == 8 || $this.userinfo.level == 9) {
  137. Toast.fail("店员、店长不可进");
  138. return false;
  139. }
  140. }
  141. if (!this.is_login) {
  142. Toast.fail("请先登录");
  143. return false;
  144. }
  145. mpvue.navigateTo({
  146. url: "/pages/" + $page + "/main",
  147. });
  148. },
  149. auth_msg() {
  150. wx.requestSubscribeMessage({
  151. tmplIds: [
  152. "NV-xb_oOPutXLVge0ZnBxct_nNxS1j1XNCMtfp2c8zw",
  153. "70xngszQ62NWHbbCjbggbz5-pvOu3Z8ttLbjfplJXLg",
  154. ],
  155. success(res) {
  156. console.log(res);
  157. Toast.success("授权成功");
  158. },
  159. });
  160. },
  161. },
  162. mounted() {
  163. wx.login({
  164. success(res) {
  165. console.log(res);
  166. },
  167. });
  168. },
  169. onShow() {
  170. wx.getStorageInfo({
  171. success(res) {
  172. console.log("当前存储的数据", res.keys);
  173. let $keys = res.keys;
  174. $keys.forEach(($val, $index) => {
  175. console.log($val, wx.getStorageSync($val));
  176. });
  177. },
  178. });
  179. userDetail().then((res) => {
  180. let $data = res.data;
  181. //判断如果是第一次登录就 弹出领取体验卡
  182. $this.userinfo = $data.data;
  183. user_store.setters.set_userinfo($this.userinfo);
  184. });
  185. },
  186. onHide() {},
  187. onLoad($option) {
  188. // if (process.env.NODE_ENV == "development") {
  189. // wx.setStorageSync("token", "ZbNv-hpdpmxk895iqUrEwe4kCJjEWCJD");
  190. // }
  191. if (game_store.getters.getGameStatus() == 1) {
  192. Dialog.alert({
  193. title: "系统提示",
  194. message: "正在结束上一个游戏",
  195. }).then(() => {
  196. post_data(game_store.getters.getGameAttMedDatas());
  197. });
  198. }
  199. // 判断存储是否登录
  200. let $token = wx.getStorageSync("token");
  201. if ($token) {
  202. user_store.setters.set_token($token);
  203. user_store.setters.set_login(true);
  204. this.is_login = user_store.getters.get_login_status();
  205. // wx.navigateTo({
  206. // url: "/pages/payment/main",
  207. // });
  208. // 存在token时候录入
  209. setUserLogin().then((res) => {
  210. console.log("录入", res);
  211. });
  212. }
  213. },
  214. created() {
  215. $this = this;
  216. },
  217. onShareAppMessage() {
  218. return {
  219. title: "欢迎进入水母星球",
  220. imageUrl: "http://img.shuimuai.com/sharePahe_one.jpg",
  221. path: "/pages/index/main",
  222. };
  223. },
  224. };
  225. </script>
  226. <style scoped>
  227. /*@import "index.css";*/
  228. .login_card {
  229. height: 335px;
  230. background-color: #ffffff;
  231. position: relative;
  232. z-index: 3;
  233. top: -90px;
  234. margin: 0px 10px;
  235. background-image: url(https://img.shuimuai.com/shuimugongzhu.png);
  236. background-position: center;
  237. background-size: 100% 100%;
  238. background-color: rgba(255, 255, 255, 0);
  239. }
  240. /* 功能服务 */
  241. .service {
  242. position: absolute;
  243. width: 100%;
  244. top: 570px;
  245. z-index: 1;
  246. }
  247. .service_login_page {
  248. top: 500px !important;
  249. }
  250. .service .content {
  251. width: 100%;
  252. }
  253. .service .content image {
  254. width: 186px;
  255. height: 89px;
  256. }
  257. .head .line {
  258. width: 4px;
  259. height: 14px;
  260. background-color: #5d4db8;
  261. margin-right: 7px;
  262. }
  263. .head view {
  264. display: flex;
  265. justify-self: start;
  266. align-items: center;
  267. }
  268. .personal_card {
  269. height: 300px;
  270. position: relative;
  271. z-index: 5;
  272. }
  273. </style>