welcome.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <template>
  2. <view>
  3. <view class="welcome">
  4. <view class="welcome-state1" >
  5. <view class="welcome-next" style="z-index: 999;" @click="gotoIndex()">{{step?step+'|':''}}跳过</view>
  6. </view>
  7. <u-image id="imgw" v-if="imgmode" @load="imgsload" ref="imgw" mode="widthFix">
  8. <view slot="loading"></view>
  9. <view slot="error"></view>
  10. </u-image>
  11. <u-image v-if="!imgmode" :height="imgH" ref="imgw2" mode="aspectFill">
  12. <view slot="loading"></view>
  13. <view slot="error"></view>
  14. </u-image>
  15. <view class="welcome-foot">
  16. <u-image width="185px" height="48px" src="../../static/img/logo.png"></u-image>
  17. </view>
  18. <!-- <view class="welcome-state2">
  19. <view class="welcome-logo">
  20. <u-image width="200px" height="50px" src="../../static/img/logo2.png"></u-image>
  21. </view>
  22. <view class="welcome-btn">
  23. <u-button class="welcomeBtn" shape="circle">用户登录</u-button>
  24. <p>随便逛逛</p>
  25. </view>
  26. </view> -->
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. import * as loginApi from '@/apis/login.js'
  32. import * as API from '@/apis/index.js'
  33. export default {
  34. data() {
  35. return {
  36. isReady:true,
  37. step:3,
  38. imgH:'',
  39. imgmode:true
  40. }
  41. },
  42. methods: {
  43. imgsload(e){
  44. uni.getSystemInfo({
  45. success: (res) => {
  46. console.log(res)
  47. const query = uni.createSelectorQuery().in(this);
  48. query.select('#imgw').boundingClientRect(data => {
  49. console.log("得到布局位置信息" + JSON.stringify(data));
  50. console.log("节点离页面顶部的距离为" + data.height);
  51. var windowH=res.windowHeight;
  52. var imgH= data.height;
  53. var value=windowH-imgH;
  54. console.log(value)
  55. if(value>=100){
  56. this.imgmode=true
  57. document.getElementsByClassName("welcome-foot")[0].style="height:"+value+"px"
  58. }else{
  59. this.imgmode=false
  60. }
  61. }).exec();
  62. }
  63. })
  64. },
  65. findNoLTextConfigure(){
  66. loginApi.findNoLTextConfigure().then((response) => {
  67. this.carhelp.setConfig(response.data.configure)
  68. this.setBackImg()
  69. }).catch(error => {
  70. uni.showToast({
  71. title: error,
  72. icon: "none"
  73. })
  74. })
  75. },
  76. findByOpenId(){
  77. var openId=this.carhelp.getOpenId()
  78. if(openId==""){
  79. console.log("--------findByOpenId----------")
  80. setTimeout(()=>{
  81. this.findByOpenId()
  82. },1000)
  83. return
  84. }
  85. uni.request({
  86. method:'get',
  87. url: process.car.BASE_URL + "/mobile/regUser/findByOpenId",
  88. data: {
  89. openId:openId,
  90. },
  91. header: {
  92. 'Content-Type': 'application/x-www-form-urlencoded',
  93. 'X-Requested-With': 'XMLHttpRequest',
  94. }
  95. }).then((response) => {
  96. let [error, res] = response;
  97. if (res.data.code == 200&&res.data.result) {
  98. var token = res ? res.data.data.token : '';
  99. this.carhelp.setPersonInfo(res.data.data.regUser );
  100. this.carhelp.setToken(token);
  101. this.carhelp.setPersonInfoPlus(res.data.data);
  102. } else{
  103. this.carhelp.logoff()
  104. }
  105. }).catch(error => {
  106. })
  107. },
  108. setBackImg(){
  109. var img=this.carhelp.getConfig().homepageLogo
  110. if(img){
  111. this.$refs.imgw.src=img
  112. //document.body.style="background:url("+img+") no-repeat;background-size: 100%;"
  113. }else{
  114. this.$refs.imgw.src="../../static/img/welcome_bg.png"
  115. }
  116. },
  117. gotoIndex(){
  118. if(this.isReady){
  119. this.isReady=false
  120. uni.redirectTo({
  121. url: '/pages/index/index'
  122. });
  123. }
  124. },
  125. indexstep(){
  126. setTimeout(()=>{
  127. this.step--;
  128. if(this.step<0){
  129. this.gotoIndex()
  130. }else{
  131. this.indexstep()
  132. }
  133. },1000)
  134. },
  135. onReadyIng(){
  136. //let state = {};
  137. uni.getSystemInfo({
  138. success: (res) => {
  139. var windowH=res.windowHeight;
  140. this.imgH=(windowH-100)+"px";
  141. }
  142. })
  143. this.indexstep()
  144. this.setBackImg( )
  145. },
  146. },
  147. onLoad(op) {
  148. this.findNoLTextConfigure()
  149. this.findByOpenId()
  150. if(op.gunId){
  151. var k=API.codeOperation("jp_team51_charge_id:A_"+op.gunId);
  152. if(k){
  153. uni.redirectTo({
  154. url:k
  155. })
  156. }
  157. }else if(op.jpcode){
  158. var k=API.codeOperation(op.jpcode);
  159. if(k){
  160. uni.redirectTo({
  161. url:k
  162. })
  163. }
  164. }else{
  165. this.onReadyIng()
  166. }
  167. },
  168. onUnload(){
  169. document.body.style=""
  170. },
  171. onReady() {
  172. }
  173. }
  174. </script>
  175. <style>
  176. page{
  177. /* background:url(../../static/img/welcome_bg.png) no-repeat;
  178. background-size:100%; */
  179. background-color: #ffffff;
  180. }
  181. </style>
  182. <style lang="scss" scoped>
  183. .welcome{
  184. position: relative;
  185. }
  186. .welcome-next{
  187. position: absolute;
  188. padding: 4px 15px;
  189. color:#fff;
  190. border-radius: 14px;
  191. background:rgba(0,0,0,0.5);
  192. right: 15px;
  193. top: 15px;
  194. }
  195. .welcome-foot{
  196. position:fixed;
  197. left: 0;
  198. right: 0;
  199. bottom: 0;
  200. background-color: #fff;
  201. height: 100px;
  202. display: flex;
  203. align-items: center;
  204. justify-content: center;
  205. }
  206. .welcome-logo{
  207. position: absolute;
  208. left: 50%;
  209. margin-left: -100px;
  210. top: 120px;
  211. }
  212. .welcome-btn{
  213. position: fixed;
  214. left: 48px;
  215. right: 48px;
  216. bottom:48px;
  217. text-align: center;
  218. .welcomeBtn{
  219. color:#009143;
  220. border-color:#fff;
  221. }
  222. p{
  223. color:#fff;
  224. margin-top: 12px;
  225. font-size: 16px;
  226. }
  227. }
  228. </style>