index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. if(wx.getStorageSync("is_other_first") == false){
  171. wx.setStorageSync("is_other", false);
  172. } else{
  173. wx.setStorageSync("is_other", true);
  174. }
  175. wx.getStorageInfo({
  176. success(res) {
  177. console.log("当前存储的数据", res.keys);
  178. let $keys = res.keys;
  179. $keys.forEach(($val, $index) => {
  180. console.log($val, wx.getStorageSync($val));
  181. });
  182. },
  183. });
  184. userDetail().then((res) => {
  185. let $data = res.data;
  186. //判断如果是第一次登录就 弹出领取体验卡
  187. $this.userinfo = $data.data;
  188. user_store.setters.set_userinfo($this.userinfo);
  189. });
  190. },
  191. onHide() {},
  192. onLoad($option) {
  193. if (process.env.NODE_ENV == "development") {
  194. // wx.setStorageSync("token", "ZbNv-hpdpmxk895iqUrEwe4kCJjEWCJD");
  195. }
  196. if (game_store.getters.getGameStatus() == 1) {
  197. Dialog.alert({
  198. title: "系统提示",
  199. message: "正在结束上一个游戏",
  200. }).then(() => {
  201. post_data(game_store.getters.getGameAttMedDatas());
  202. });
  203. }
  204. // 判断存储是否登录
  205. let $token = wx.getStorageSync("token");
  206. if ($token) {
  207. user_store.setters.set_token($token);
  208. user_store.setters.set_login(true);
  209. this.is_login = user_store.getters.get_login_status();
  210. // wx.navigateTo({
  211. // url: "/pages/payment/main",
  212. // });
  213. // 存在token时候录入
  214. setUserLogin().then((res) => {
  215. console.log("录入", res);
  216. });
  217. }
  218. },
  219. created() {
  220. $this = this;
  221. },
  222. onShareAppMessage() {
  223. return {
  224. title: "欢迎进入水母星球",
  225. imageUrl: "http://img.shuimuai.com/sharePahe_one.jpg",
  226. path: "/pages/index/main",
  227. };
  228. },
  229. };
  230. </script>
  231. <style scoped>
  232. /*@import "index.css";*/
  233. .login_card {
  234. height: 335px;
  235. background-color: #ffffff;
  236. position: relative;
  237. z-index: 3;
  238. top: -90px;
  239. margin: 0px 10px;
  240. background-image: url(https://img.shuimuai.com/shuimugongzhu.png);
  241. background-position: center;
  242. background-size: 100% 100%;
  243. background-color: rgba(255, 255, 255, 0);
  244. }
  245. /* 功能服务 */
  246. .service {
  247. position: absolute;
  248. width: 100%;
  249. top: 570px;
  250. z-index: 1;
  251. }
  252. .service_login_page {
  253. top: 500px !important;
  254. }
  255. .service .content {
  256. width: 100%;
  257. }
  258. .service .content image {
  259. width: 186px;
  260. height: 89px;
  261. }
  262. .head .line {
  263. width: 4px;
  264. height: 14px;
  265. background-color: #5d4db8;
  266. margin-right: 7px;
  267. }
  268. .head view {
  269. display: flex;
  270. justify-self: start;
  271. align-items: center;
  272. }
  273. .personal_card {
  274. height: 300px;
  275. position: relative;
  276. z-index: 5;
  277. }
  278. </style>