welcome.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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. branchParameter:process.car.branchParameter
  105. },
  106. header: {
  107. 'Content-Type': 'application/x-www-form-urlencoded',
  108. 'X-Requested-With': 'XMLHttpRequest',
  109. }
  110. }).then((response) => {
  111. let [error, res] = response;
  112. if (res.data.code == 200&&res.data.result) {
  113. var token = res ? res.data.data.token : '';
  114. this.carhelp.setPersonInfo(res.data.data.regUser );
  115. this.carhelp.setToken(token);
  116. this.carhelp.setPersonInfoPlus(res.data.data);
  117. } else{
  118. this.carhelp.logoff()
  119. }
  120. this.isReady2=true;
  121. }).catch(error => {
  122. })
  123. },
  124. setBackImg(){
  125. try{
  126. var img=this.carhelp.getConfig().homepageLogo
  127. if(img){
  128. this.$refs.imgw.src=img
  129. //this.src=img
  130. //document.body.style="background:url("+img+") no-repeat;background-size: 100%;"
  131. }else{
  132. //this.src="@/assets/static/img/welcome_bg.png"
  133. var img =require("@/assets/static/img/welcome_bg.png")
  134. this.$refs.imgw.src=img
  135. }
  136. }catch(e){
  137. //TODO handle the exception
  138. }
  139. },
  140. gotoIndex(){
  141. if(this.isReady){
  142. this.isReady=false
  143. uni.redirectTo({
  144. url: '/pages/index/index'
  145. });
  146. }
  147. },
  148. indexstep(){
  149. setTimeout(()=>{
  150. this.step--;
  151. if(this.step<0){
  152. if(this.isReady2){
  153. this.gotoIndex()
  154. }else{
  155. this.step=0;
  156. this.indexstep()
  157. }
  158. }else{
  159. this.indexstep()
  160. }
  161. },1000)
  162. },
  163. onReadyIng(){
  164. //let state = {};
  165. uni.getSystemInfo({
  166. success: (res) => {
  167. var windowH=res.windowHeight;
  168. this.imgH=(windowH-100)+"px";
  169. }
  170. })
  171. this.indexstep()
  172. this.setBackImg( )
  173. },
  174. },
  175. onLoad(op) {
  176. this.findNoLTextConfigure()
  177. this.findByOpenId()
  178. if(op.friends){
  179. this.carhelp.set("friends_invitation",{
  180. op:op,
  181. date:new Date().getTime()
  182. })
  183. uni.redirectTo({
  184. url:'/pages/login/login'
  185. })
  186. //this.onReadyIng()
  187. }else if(op.gunId){
  188. var k=API.codeOperation("jp_team51_charge_id:A_"+op.gunId);
  189. if(k){
  190. uni.redirectTo({
  191. url:k
  192. })
  193. }
  194. }else if(op.jpcode){
  195. var k=API.codeOperation(op.jpcode);
  196. if(k){
  197. uni.redirectTo({
  198. url:k
  199. })
  200. }
  201. }else{
  202. this.onReadyIng()
  203. }
  204. },
  205. onUnload(){
  206. document.body.style=""
  207. },
  208. onReady() {
  209. }
  210. }
  211. </script>
  212. <style>
  213. page{
  214. background-color: #ffffff;
  215. }
  216. </style>
  217. <style lang="scss" scoped>
  218. .welcome{
  219. position: relative;
  220. }
  221. .welcome-next{
  222. position: absolute;
  223. padding: 4px 15px;
  224. color:#fff;
  225. border-radius: 14px;
  226. background:rgba(0,0,0,0.5);
  227. right: 15px;
  228. top: 15px;
  229. }
  230. .welcome-foot{
  231. position:fixed;
  232. left: 0;
  233. right: 0;
  234. bottom: 0;
  235. background-color: #fff;
  236. height: 100px;
  237. display: flex;
  238. align-items: center;
  239. justify-content: center;
  240. }
  241. .welcome-logo{
  242. position: absolute;
  243. left: 50%;
  244. margin-left: -100px;
  245. top: 120px;
  246. }
  247. .welcome-btn{
  248. position: fixed;
  249. left: 48px;
  250. right: 48px;
  251. bottom:48px;
  252. text-align: center;
  253. .welcomeBtn{
  254. color:#009143;
  255. border-color:#fff;
  256. }
  257. p{
  258. color:#fff;
  259. margin-top: 12px;
  260. font-size: 16px;
  261. }
  262. }
  263. </style>