index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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. //切换到扫码
  112. change_status($status) {
  113. this.login_status = $status;
  114. },
  115. //跳转充值中心
  116. to_recharge() {
  117. mpvue.navigateTo({
  118. url: "/pages/user_center/recharge/main",
  119. });
  120. },
  121. //修改登录状态
  122. change_login_status() {
  123. this.is_login = user_store.getters.get_login_status();
  124. },
  125. // 修改界面的文字
  126. change_title($status) {
  127. if ($status == 0) {
  128. this.regist_title = "注册";
  129. } else if ($status == 1) {
  130. this.regist_title = "登录";
  131. }
  132. },
  133. //跳转页面
  134. to_page($page) {
  135. if ($page == "agent/index") {
  136. //店员店长不可进
  137. if ($this.userinfo.level == 8 || $this.userinfo.level == 9) {
  138. Toast.fail("店员、店长不可进");
  139. return false;
  140. }
  141. }
  142. if (!this.is_login) {
  143. Toast.fail("请先登录");
  144. return false;
  145. }
  146. mpvue.navigateTo({
  147. url: "/pages/" + $page + "/main",
  148. });
  149. },
  150. auth_msg() {
  151. wx.requestSubscribeMessage({
  152. tmplIds: [
  153. "NV-xb_oOPutXLVge0ZnBxct_nNxS1j1XNCMtfp2c8zw",
  154. "70xngszQ62NWHbbCjbggbz5-pvOu3Z8ttLbjfplJXLg",
  155. ],
  156. success(res) {
  157. console.log(res);
  158. Toast.success("授权成功");
  159. },
  160. });
  161. },
  162. },
  163. mounted() {
  164. wx.login({
  165. success(res) {
  166. console.log(res);
  167. },
  168. });
  169. },
  170. onShow() {
  171. if (wx.getStorageSync("is_other_first") == false) {
  172. wx.setStorageSync("is_other", false);
  173. } else {
  174. wx.setStorageSync("is_other", true);
  175. }
  176. // wx.getStorageInfo({
  177. // success(res) {
  178. // console.log("当前存储的数据", res.keys);
  179. // let $keys = res.keys;
  180. // $keys.forEach(($val, $index) => {
  181. // console.log($val, wx.getStorageSync($val));
  182. // });
  183. // },
  184. // });
  185. userDetail().then((res) => {
  186. let $data = res.data;
  187. //判断如果是第一次登录就 弹出领取体验卡
  188. $this.userinfo = $data.data;
  189. user_store.setters.set_userinfo($this.userinfo);
  190. });
  191. },
  192. onHide() {
  193. },
  194. onLoad($option) {
  195. if (process.env.NODE_ENV == "development") {
  196. wx.setStorageSync("token", "ogsti72oUSkbPl4OL7gl9woLTxR6fk4V");
  197. }
  198. if (game_store.getters.getGameStatus() == 1) {
  199. Dialog.alert({
  200. title: "系统提示",
  201. message: "正在结束上一个游戏",
  202. }).then(() => {
  203. post_data(game_store.getters.getGameAttMedDatas());
  204. });
  205. }
  206. // 判断存储是否登录
  207. let $token = wx.getStorageSync("token");
  208. if ($token) {
  209. user_store.setters.set_token($token);
  210. user_store.setters.set_login(true);
  211. this.is_login = user_store.getters.get_login_status();
  212. // wx.navigateTo({
  213. // url: "/pages/payment/main",
  214. // });
  215. // 存在token时候录入
  216. setUserLogin().then((res) => {
  217. // console.log("录入", res);
  218. });
  219. }
  220. },
  221. created() {
  222. $this = this;
  223. },
  224. onShareAppMessage() {
  225. return {
  226. title: "欢迎进入水母星球",
  227. imageUrl: "http://img.shuimuai.com/sharePahe_one.jpg",
  228. path: "/pages/index/main",
  229. };
  230. },
  231. };
  232. </script>
  233. <style scoped>
  234. /*@import "index.css";*/
  235. .login_card {
  236. height: 335px;
  237. background-color: #ffffff;
  238. position: relative;
  239. z-index: 3;
  240. top: -90px;
  241. margin: 0px 10px;
  242. background-image: url(https://img.shuimuai.com/shuimugongzhu.png);
  243. background-position: center;
  244. background-size: 100% 100%;
  245. background-color: rgba(255, 255, 255, 0);
  246. }
  247. /* 功能服务 */
  248. .service {
  249. position: absolute;
  250. width: 100%;
  251. top: 570px;
  252. z-index: 1;
  253. }
  254. .service_login_page {
  255. top: 500px !important;
  256. }
  257. .service .content {
  258. width: 100%;
  259. }
  260. .service .content image {
  261. width: 186px;
  262. height: 89px;
  263. }
  264. .head .line {
  265. width: 4px;
  266. height: 14px;
  267. background-color: #5d4db8;
  268. margin-right: 7px;
  269. }
  270. .head view {
  271. display: flex;
  272. justify-self: start;
  273. align-items: center;
  274. }
  275. .personal_card {
  276. height: 300px;
  277. position: relative;
  278. z-index: 5;
  279. }
  280. </style>