index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. <template>
  2. <div id="container">
  3. <!-- banner模块-->
  4. <banner></banner>
  5. <!-- 未登录 登录窗口模块-->
  6. <div class="login_card" v-if="!is_login">
  7. <!-- 登录窗口-->
  8. <login_container v-if="login_status == 'login'"
  9. @changeStatus="change_status"
  10. @changeTitle="change_title"
  11. ></login_container>
  12. <!-- 注册窗口-->
  13. <regist_container v-if="login_status == 'regist'"
  14. @changeStatus='change_status'
  15. @change_login_status="change_login_status"
  16. :title="regist_title"
  17. ></regist_container>
  18. </div>
  19. <!-- 登陆后 的个人首页-->
  20. <div class="personal_card" v-if="is_login">
  21. <personal_container @change_login_status="change_login_status"></personal_container>
  22. <device_container></device_container>
  23. </div>
  24. <div class="service" :class="{'service_login_page':is_login==false}">
  25. <view class="padding-tb">
  26. <text class="cuIcon-titles text-primary"></text>
  27. <text class="">功能服务</text>
  28. </view>
  29. <div class="content">
  30. <van-row>
  31. <van-col span="12">
  32. <img src="https://img.shuimuai.com/index_btn_chongzhizhongxin.png"
  33. @click="to_page('user_center/recharge')"></img>
  34. </van-col>
  35. <van-col span="12">
  36. <img src="https://img.shuimuai.com/web/index_btn_gerenzhongxin.png" @click="to_page('user_center')"></img>
  37. </van-col>
  38. </van-row>
  39. <van-row>
  40. <van-col span="12">
  41. <img src="https://img.shuimuai.com/web/index_btn_chengjijilu.png" @click="to_page('game_record')"></img>
  42. </van-col>
  43. <van-col span="12">
  44. <img src="https://img.shuimuai.com/index_btn_dailishang.png" @click="to_page('agent/index')"></img>
  45. </van-col>
  46. </van-row>
  47. </div>
  48. </div>
  49. <van-toast id="van-toast"/>
  50. <!-- <button class="cu-btn lg cu-btn-primary text-white text-center margin-tb" @click="auth_msg">获取消息授权-->
  51. <!-- </button>-->
  52. </div>
  53. </template>
  54. <script>
  55. import banner from '@/components/banner'
  56. import login_container from '@/components/index/login'
  57. import regist_container from '@/components/index/regist'
  58. import personal_container from "@/components/index/personal";
  59. import device_container from "@/components/device/device";
  60. import Toast from '../../../static/vant/toast/toast';
  61. import {userDetail} from "../../requests/user";
  62. import user_store from "../../store/index"
  63. import {reload_userinfo} from "../../utils/user";
  64. var $this
  65. export default {
  66. name: "index_container",
  67. components: {
  68. banner, login_container, regist_container, personal_container, device_container
  69. },
  70. data() {
  71. return {
  72. // 三种状态 扫码scan 注册regist 登录login
  73. login_status: "login",
  74. // is_login: false,
  75. is_login: false,
  76. regist_title: ""
  77. }
  78. },
  79. methods: {
  80. get_init_data() {
  81. },
  82. //切换到扫码
  83. change_status($status) {
  84. this.login_status = $status
  85. },
  86. //跳转充值中心
  87. to_recharge() {
  88. mpvue.navigateTo({
  89. url: "/pages/user_center/recharge/main"
  90. })
  91. },
  92. //修改登录状态
  93. change_login_status() {
  94. this.is_login = user_store.getters.get_login_status()
  95. },
  96. // 修改界面的文字
  97. change_title($status) {
  98. if ($status == 0) {
  99. this.regist_title = "注册"
  100. } else if ($status == 1) {
  101. this.regist_title = "登录"
  102. }
  103. },
  104. //跳转页面
  105. to_page($page) {
  106. if ($page == 'agent/index') {
  107. //店员店长不可进
  108. console.log([8, 9].indexOf($this.userinfo.level)!=-1)
  109. if ([8, 9].indexOf($this.userinfo.level) != -1) {
  110. Toast.fail("店员、店长不可进")
  111. return false
  112. }
  113. }
  114. if (!this.is_login) {
  115. Toast.fail("请先登录")
  116. return false
  117. }
  118. mpvue.navigateTo({
  119. url: "/pages/" + $page + "/main"
  120. })
  121. },
  122. auth_msg() {
  123. wx.requestSubscribeMessage({
  124. tmplIds: ['NV-xb_oOPutXLVge0ZnBxct_nNxS1j1XNCMtfp2c8zw', '70xngszQ62NWHbbCjbggbz5-pvOu3Z8ttLbjfplJXLg'],
  125. success(res) {
  126. console.log(res)
  127. Toast.success("授权成功")
  128. }
  129. })
  130. }
  131. },
  132. mounted() {
  133. },
  134. onShow() {
  135. userDetail().then((res) => {
  136. let $data = res.data
  137. //判断如果是第一次登录就 弹出领取体验卡
  138. $this.userinfo = $data.data
  139. user_store.setters.set_userinfo($this.userinfo)
  140. })
  141. },
  142. onLoad($option) {
  143. // 判断存储是否登录
  144. let $token = wx.getStorageSync('token')
  145. if ($token) {
  146. user_store.setters.set_token($token)
  147. user_store.setters.set_login(true)
  148. this.is_login = user_store.getters.get_login_status()
  149. }
  150. },
  151. created() {
  152. $this = this
  153. }
  154. }
  155. </script>
  156. <style scoped>
  157. /*@import "index.css";*/
  158. .login_card {
  159. height: 335px;
  160. background-color: #ffffff;
  161. position: relative;
  162. z-index: 3;
  163. top: -90px;
  164. margin: 0px 10px;
  165. background-image: url(https://img.shuimuai.com/shuimugongzhu.png);
  166. background-position: center;
  167. background-size: 100% 100%;
  168. background-color: rgba(255, 255, 255, 0);
  169. }
  170. /* 功能服务 */
  171. .service {
  172. position: absolute;
  173. width: 100%;
  174. top: 570px;
  175. }
  176. .service_login_page {
  177. top: 500px !important;
  178. }
  179. .service .content {
  180. width: 100%;
  181. }
  182. .service .content image {
  183. width: 186px;
  184. height: 89px;
  185. }
  186. .head .line {
  187. width: 4px;
  188. height: 14px;
  189. background-color: #5d4db8;
  190. margin-right: 7px;
  191. }
  192. .head view {
  193. display: flex;
  194. justify-self: start;
  195. align-items: center;
  196. }
  197. .personal_card {
  198. height: 300px;
  199. position: relative;
  200. }
  201. </style>