welcome.vue 5.4 KB

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