welcome.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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. this.$refs.imgw.src="@/assets/static/img/welcome_bg.png"
  134. }
  135. }catch(e){
  136. //TODO handle the exception
  137. }
  138. },
  139. gotoIndex(){
  140. if(this.isReady){
  141. this.isReady=false
  142. uni.redirectTo({
  143. url: '/pages/index/index'
  144. });
  145. }
  146. },
  147. indexstep(){
  148. setTimeout(()=>{
  149. this.step--;
  150. if(this.step<0){
  151. if(this.isReady2){
  152. this.gotoIndex()
  153. }else{
  154. this.step=0;
  155. this.indexstep()
  156. }
  157. }else{
  158. this.indexstep()
  159. }
  160. },1000)
  161. },
  162. onReadyIng(){
  163. //let state = {};
  164. uni.getSystemInfo({
  165. success: (res) => {
  166. var windowH=res.windowHeight;
  167. this.imgH=(windowH-100)+"px";
  168. }
  169. })
  170. this.indexstep()
  171. this.setBackImg( )
  172. },
  173. },
  174. onLoad(op) {
  175. this.findNoLTextConfigure()
  176. this.findByOpenId()
  177. if(op.friends){
  178. this.carhelp.set("friends_invitation",{
  179. op:op,
  180. date:new Date().getTime()
  181. })
  182. uni.redirectTo({
  183. url:'/pages/login/login'
  184. })
  185. //this.onReadyIng()
  186. }else if(op.gunId){
  187. var k=API.codeOperation("jp_team51_charge_id:A_"+op.gunId);
  188. if(k){
  189. uni.redirectTo({
  190. url:k
  191. })
  192. }
  193. }else if(op.jpcode){
  194. var k=API.codeOperation(op.jpcode);
  195. if(k){
  196. uni.redirectTo({
  197. url:k
  198. })
  199. }
  200. }else{
  201. this.onReadyIng()
  202. }
  203. },
  204. onUnload(){
  205. document.body.style=""
  206. },
  207. onReady() {
  208. }
  209. }
  210. </script>
  211. <style>
  212. page{
  213. background-color: #ffffff;
  214. }
  215. </style>
  216. <style lang="scss" scoped>
  217. .welcome{
  218. position: relative;
  219. }
  220. .welcome-next{
  221. position: absolute;
  222. padding: 4px 15px;
  223. color:#fff;
  224. border-radius: 14px;
  225. background:rgba(0,0,0,0.5);
  226. right: 15px;
  227. top: 15px;
  228. }
  229. .welcome-foot{
  230. position:fixed;
  231. left: 0;
  232. right: 0;
  233. bottom: 0;
  234. background-color: #fff;
  235. height: 100px;
  236. display: flex;
  237. align-items: center;
  238. justify-content: center;
  239. }
  240. .welcome-logo{
  241. position: absolute;
  242. left: 50%;
  243. margin-left: -100px;
  244. top: 120px;
  245. }
  246. .welcome-btn{
  247. position: fixed;
  248. left: 48px;
  249. right: 48px;
  250. bottom:48px;
  251. text-align: center;
  252. .welcomeBtn{
  253. color:#009143;
  254. border-color:#fff;
  255. }
  256. p{
  257. color:#fff;
  258. margin-top: 12px;
  259. font-size: 16px;
  260. }
  261. }
  262. </style>