index0.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <!doctype html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width" />
  6. <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
  7. <title>APP</title>
  8. <link rel="stylesheet" type="text/css" href="./css/api.css" />
  9. <!--<link rel="stylesheet" type="text/css" href="./css/aui.css" />-->
  10. <link rel="stylesheet" type="text/css" href="./css/aui-win.css" />
  11. <link rel="stylesheet" type="text/css" href="./css/css/vant-ui.css" />
  12. <link rel="stylesheet" type="text/css" href="./css/iconfont.css">
  13. <link rel="stylesheet" type="text/css" href="./css/main.css" />
  14. <script src="./script/js/vue.js"></script>
  15. <script src="./script/js/vant-ui.js"></script>
  16. <script src="./script/js/main.js"></script>
  17. <script src="./script/vue_plugins.js"></script>
  18. <style type="text/css">
  19. body, html {
  20. width: 100%;
  21. height: 100%;
  22. }
  23. .aui-nav .aui-bar-tab {
  24. background: #fff;
  25. }
  26. .aui-bar {
  27. text-align: center;
  28. /*height: 3.3rem;*/
  29. }
  30. #app{
  31. background: linear-gradient(#00a0ea,#040da9);
  32. display: flex;
  33. justify-content: center;
  34. align-items: center;
  35. height: 100%;
  36. }
  37. .my-swipe{
  38. width: 60%;
  39. background: #ffffff;
  40. box-shadow: 0 6px 12px 7px rgba(0,0,0,0.2);
  41. height: 60%;
  42. border-radius: 10px;
  43. }
  44. .my-swipe-item{
  45. /*display: flex;
  46. flex-wrap: wrap;
  47. justify-content: center;*/
  48. padding: 32px 24px;
  49. box-sizing: border-box;
  50. position: relative;
  51. }
  52. .avatar{
  53. width: 2.2rem;
  54. height: 2.2rem;
  55. border-radius: 1.1rem;
  56. overflow: hidden;
  57. background: rgba(0,0,0,.2);
  58. display: flex;
  59. justify-content: center;
  60. align-items: center;
  61. margin: 0 auto;
  62. }
  63. img{
  64. width: 100%;
  65. height: auto;
  66. }
  67. .title{
  68. text-align: center;
  69. margin-top: .2rem;
  70. font-size: 0.32rem;
  71. }
  72. .title span{
  73. color: #00a0ea;
  74. font-weight: 600;
  75. }
  76. .btn-goin{
  77. position: absolute;
  78. bottom: 1rem;
  79. margin: 0 auto;
  80. width: 80%
  81. }
  82. </style>
  83. </head>
  84. <body>
  85. <header class="aui-bar aui-bar-nav" id="aui-header">选择你的角色</header>
  86. <div id="app" v-cloak>
  87. <van-swipe v-if="showScope" class="my-swipe" @change="onChange">
  88. <van-swipe-item class="my-swipe-item" v-for="(item,index) in roleList" :key="index">
  89. <div class="avatar">
  90. <img v-if="item.spart=='10'" src="./image/image/t.png" />
  91. <img v-else-if="item.spart=='40'" src="./image/image/p.png" />
  92. </div>
  93. <div class="title"><span>{{item.spartName}}经销商</span></div>
  94. <van-button class="btn-goin" round type="info" @click="selectedRole(item)">立即进入</van-button>
  95. </van-swipe-item>
  96. </van-swipe>
  97. <div v-else style="width:100%;height:100%;text-align:center;line-height:100%;">
  98. <van-loading v-show="loadingShow"></van-loading>
  99. <van-empty v-show="!loadingShow" description="页面加载失败">
  100. <van-button round type="danger" class="bottom-button" @click="reback">
  101. 退出重新登录
  102. </van-button>
  103. </van-empty>
  104. </div>
  105. </div>
  106. </body>
  107. <script type="text/javascript" src="./script/api.js"></script>
  108. <script type="text/javascript" src="./script/aui-tab.js" ></script>
  109. <script type="text/javascript" src="./script/httpRequest.js"></script>
  110. <script type="text/javascript">
  111. apiready = function() {
  112. //$api.clearStorage();
  113. var header = $api.byId('aui-header');
  114. $api.fixStatusBar(header);
  115. var headerPos = $api.offset(header);
  116. var body_h = $api.offset($api.dom('body')).h;
  117. api.addEventListener({
  118. name: 'rebacklogin'
  119. }, function(ret, err){
  120. if( ret ){
  121. // alert( JSON.stringify( ret ) );
  122. }else{
  123. // alert( JSON.stringify( err ) );
  124. }
  125. });
  126. new Vue({
  127. el: "#app",
  128. data: {
  129. loginid: "",
  130. roleScene: "",
  131. currentItem:0,
  132. roleList: [],
  133. showScope: false,
  134. loadingShow: true
  135. },
  136. created: function(){
  137. var _this = this;
  138. // 判断是否登录
  139. if(!this.isLogin()){
  140. _this.openLogin(headerPos, body_h);
  141. };
  142. // 判断是否需要选择角色,需要选择角色的情况:showScope为true
  143. if(typeof $api.getStorage("showScope") == "string" && $api.getStorage("showScope")=="true"){
  144. // 需要选择角色
  145. if(typeof $api.getStorage("showScope") != "string"||$api.getStorage("roleScene")==""||$api.getStorage("roleScene")==undefined){
  146. _this.openLogin(headerPos, body_h);
  147. }else{
  148. _this.loginEntrance($api.getStorage("roleScene"),'.');
  149. }
  150. }else if(typeof $api.getStorage("showScope") == "string" && $api.getStorage("showScope")=="false"){
  151. // 不需要选择角色,直接进入对应的界面
  152. _this.loginEntrance($api.getStorage("roleScene"),'.');
  153. }else{
  154. _this.openLogin(headerPos, body_h);
  155. };
  156. // 这里是账号密码登录的数据
  157. api.addEventListener({name:"saveUserPwdInfo"},function(info){
  158. _this.showScope = info.value.data.data.showScope;
  159. if(_this.showScope){
  160. // 选择业务场景
  161. _this.roleList = info.value.data.data.scopeList;
  162. }else{
  163. // 默认不选择业务场景时
  164. $api.setStorage('roleScene', info.value.data.data.spart);
  165. _this.loginEntrance(info.value.data.data.spart,'.');
  166. }
  167. });
  168. },
  169. mounted: function(){
  170. var _this = this;
  171. setTimeout(function(){
  172. _this.loadingShow = false;
  173. },6*1000)
  174. },
  175. methods: {
  176. reback: function(){
  177. // 加载失败退出重新登录
  178. this.openLogin(headerPos, body_h);
  179. },
  180. onChange(index) {
  181. this.currentItem = index;
  182. },
  183. openLogin(headerPos, body_h, footer_h) {
  184. $api.clearStorage();
  185. api.openWin({
  186. name : 'login',
  187. url : './main/login.html',
  188. rect : {
  189. x : 0,
  190. y : 0,
  191. w : 'auto',
  192. h : body_h - footer_h - headerPos.h
  193. },
  194. animation : {
  195. type : "none", //动画类型(详见动画类型常量)
  196. subType : "from_right", //动画子类型(详见动画子类型常量)
  197. duration : 200 //动画过渡时间,默认300毫秒
  198. }
  199. });
  200. },
  201. selectedRole(params){
  202. var _this = this;
  203. this.showModal("场景确认",'您确认进入'+params.spartName+'业务场景?', ["取消", "确认"],function(index){
  204. if(index==1){
  205. var data = {
  206. token : $api.getStorage("token"),
  207. vkorg : params.vkorg,
  208. vtweg : params.vtweg,
  209. spart: params.spart,
  210. url : 'json',
  211. type : 'body'
  212. };
  213. _this.$post("confirmBusinessScope", data, function(ret) {
  214. if(ret.code==0||ret.code=="0"){
  215. _this.loginEntrance(params.spart,'.');
  216. $api.setStorage('roleScene', params.spart);
  217. $api.setStorage("token", ret.data.token);
  218. }
  219. })
  220. }else{
  221. $api.clearStorage("roleScene");
  222. }
  223. })
  224. }
  225. }
  226. });
  227. }
  228. </script>
  229. </html>