home.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <view class="content">
  3. <view>
  4. <view class="zdyNav">
  5. <view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
  6. <view class="nav">
  7. <view>欧洲维修</view>
  8. </view>
  9. </view>
  10. <view class="status_bar" :style="{height: iStatusBarHeight + 'px'}"></view>
  11. <view style="height: 44px;"></view>
  12. <view class="homePg">
  13. <view class="bg">
  14. <view class="logIn" @click="logIn">立即登录</view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. data() {
  23. return {
  24. iStatusBarHeight: '',
  25. wxdata:"",
  26. wxCode:'',
  27. }
  28. },
  29. onLoad() {
  30. this.iStatusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  31. var userId = uni.getStorageSync("logInData").uid;
  32. if (userId) {
  33. var type = uni.getStorageSync("logInData").type;
  34. if(type==1){
  35. uni.navigateTo({
  36. url:'../index/index'
  37. })
  38. }else if(type==2){
  39. uni.navigateTo({
  40. url:'../shop/shopIndex/index'
  41. })
  42. }
  43. }
  44. },
  45. methods: {
  46. logIn() {
  47. var that=this;
  48. uni.getUserProfile({
  49. lang:'zh_CN',
  50. desc:'登录',
  51. success:(res)=>{
  52. console.log(res);
  53. that.wxdata=res;
  54. /* uni.setStorage({
  55. key: 'wxdata',
  56. data: res,
  57. success: function () {
  58. }
  59. }); */
  60. that.ipLogin()
  61. },
  62. fail:(res)=>{
  63. console.log(res)
  64. }
  65. });
  66. //#ifdef H5
  67. uni.navigateTo({
  68. url: '../logIn/logIn'
  69. })
  70. // #endif
  71. },
  72. ipLogin(){
  73. var that=this;
  74. uni.showLoading({ });
  75. uni.login({
  76. provider: 'weixin',
  77. success: function (loginRes) {
  78. console.log(loginRes)
  79. that.wxCode=loginRes.code
  80. that.getWxOpenID()
  81. //that.gologin()
  82. /* uni.navigateTo({
  83. url: '../logIn/logIn?code='+loginRes.code
  84. }) */
  85. }
  86. });
  87. },
  88. getWxOpenID(){
  89. var that=this;
  90. uni.showLoading({
  91. title: '请稍等'
  92. })
  93. this.$http('accompany/superusers/getWxOpenID', {
  94. code:this.wxCode,
  95. },'GET').then(res => {
  96. //console.log(res)
  97. //this.openID=res.data.openid;
  98. //this.session_key=res.data.session_key;
  99. console.log(this.openID)
  100. uni.setStorage({
  101. key: 'wxOpendata',
  102. data: res.data,
  103. success: function () {
  104. // that.ipLogin()
  105. uni.navigateTo({
  106. url: '../logIn/logIn'
  107. })
  108. }
  109. });
  110. //this.Login()
  111. })
  112. },
  113. }
  114. }
  115. </script>
  116. <style>
  117. .content {
  118. background-color: #EB5808;
  119. width: 100%;
  120. height: 100%;
  121. }
  122. /* #ifdef H5 */
  123. .content {
  124. background-color: #EB5808;
  125. width: 100%;
  126. height: 100%;
  127. }
  128. /* #endif */
  129. .zdyNav {
  130. position: fixed;
  131. left: 0;
  132. top: 0;
  133. background: #FFFFFF;
  134. z-index: 11;
  135. }
  136. .status_bar {
  137. background: #FFFFFF;
  138. }
  139. .nav {
  140. width: 100vw;
  141. height: 44px;
  142. background: #FFFFFF;
  143. text-align: center;
  144. font-size: 34rpx;
  145. line-height: 44px;
  146. font-weight: bold;
  147. }
  148. .homePg {
  149. position: fixed;
  150. width: 100vw;
  151. height: calc(100vh - 44px);
  152. background-color: #EB5808;
  153. }
  154. .bg {
  155. width: 100vw;
  156. height: calc(100vh - 44px);
  157. background: url('http://dmsimg.66km.com/yypb/home_yypb.png') no-repeat;
  158. background-size: 100%;
  159. position: relative;
  160. }
  161. .logIn{
  162. width: 442rpx;
  163. height: 88rpx;
  164. background-color: #FF4F00;
  165. border-radius: 44rpx;
  166. color: #FFFFFF;
  167. font-size: 30rpx;
  168. text-align: center;
  169. line-height: 88rpx;
  170. position: absolute;
  171. left: 154rpx;
  172. top: 874rpx;
  173. }
  174. </style>