home.vue 4.3 KB

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