welcome.vue 6.4 KB

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