welcome.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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:2,
  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.friends){
  151. this.carhelp.set("friends_invitation",{
  152. op:op,
  153. date:new Date().getTime()
  154. })
  155. }else if(op.gunId){
  156. var k=API.codeOperation("jp_team51_charge_id:A_"+op.gunId);
  157. if(k){
  158. uni.redirectTo({
  159. url:k
  160. })
  161. }
  162. }else if(op.jpcode){
  163. var k=API.codeOperation(op.jpcode);
  164. if(k){
  165. uni.redirectTo({
  166. url:k
  167. })
  168. }
  169. }else{
  170. this.onReadyIng()
  171. }
  172. },
  173. onUnload(){
  174. document.body.style=""
  175. },
  176. onReady() {
  177. }
  178. }
  179. </script>
  180. <style>
  181. page{
  182. /* background:url(../../static/img/welcome_bg.png) no-repeat;
  183. background-size:100%; */
  184. background-color: #ffffff;
  185. }
  186. </style>
  187. <style lang="scss" scoped>
  188. .welcome{
  189. position: relative;
  190. }
  191. .welcome-next{
  192. position: absolute;
  193. padding: 4px 15px;
  194. color:#fff;
  195. border-radius: 14px;
  196. background:rgba(0,0,0,0.5);
  197. right: 15px;
  198. top: 15px;
  199. }
  200. .welcome-foot{
  201. position:fixed;
  202. left: 0;
  203. right: 0;
  204. bottom: 0;
  205. background-color: #fff;
  206. height: 100px;
  207. display: flex;
  208. align-items: center;
  209. justify-content: center;
  210. }
  211. .welcome-logo{
  212. position: absolute;
  213. left: 50%;
  214. margin-left: -100px;
  215. top: 120px;
  216. }
  217. .welcome-btn{
  218. position: fixed;
  219. left: 48px;
  220. right: 48px;
  221. bottom:48px;
  222. text-align: center;
  223. .welcomeBtn{
  224. color:#009143;
  225. border-color:#fff;
  226. }
  227. p{
  228. color:#fff;
  229. margin-top: 12px;
  230. font-size: 16px;
  231. }
  232. }
  233. </style>