index0.html 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. <style type="text/css">
  15. body, html {
  16. width: 100%;
  17. height: 100%;
  18. }
  19. .aui-nav .aui-bar-tab {
  20. background: #fff;
  21. }
  22. .aui-bar {
  23. text-align: center;
  24. /*height: 3.3rem;*/
  25. }
  26. #con {
  27. height: 100%;
  28. }
  29. #app{
  30. background: linear-gradient(#00a0ea,#040da9);
  31. display: flex;
  32. justify-content: center;
  33. align-items: center;
  34. height: calc(100% - 80px)
  35. }
  36. .my-swipe{
  37. width: 60%;
  38. background: #ffffff;
  39. box-shadow: 0 6px 12px 7px rgba(0,0,0,0.2);
  40. height: 60%;
  41. border-radius: 10px;
  42. }
  43. .my-swipe-item{
  44. /*display: flex;
  45. flex-wrap: wrap;
  46. justify-content: center;*/
  47. padding: 32px 24px;
  48. box-sizing: border-box;
  49. position: relative;
  50. }
  51. .avatar{
  52. width: 2.2rem;
  53. height: 2.2rem;
  54. border-radius: 1.1rem;
  55. overflow: hidden;
  56. background: rgba(0,0,0,.2);
  57. display: flex;
  58. justify-content: center;
  59. align-items: center;
  60. margin: 0 auto;
  61. }
  62. img{
  63. width: 100%;
  64. height: auto;
  65. }
  66. .title{
  67. text-align: center;
  68. margin-top: .2rem;
  69. font-size: 0.32rem;
  70. }
  71. .title span{
  72. color: #00a0ea;
  73. font-weight: 600;
  74. }
  75. .btn-goin{
  76. position: absolute;
  77. bottom: 1rem;
  78. margin: 0 auto;
  79. width: 80%
  80. }
  81. </style>
  82. </head>
  83. <body>
  84. <div id="con">
  85. <header class="aui-bar aui-bar-nav" id="aui-header">{{ $t('change.title') }}</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}}{{ $t('change.agent') }}</span></div>
  94. <van-button class="btn-goin" round type="info" @click="selectedRole(item)">{{ $t('change.enter') }}</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="$t('change.loadingError')">
  100. <van-button round type="danger" class="bottom-button" @click="reback">
  101. {{ $t('change.reBack') }}
  102. </van-button>
  103. </van-empty>
  104. </div>
  105. </div>
  106. </div>
  107. </body>
  108. <script type="text/javascript" src="./script/api.js"></script>
  109. <script type="text/javascript" src="./script/aui-tab.js" ></script>
  110. <script type="text/javascript" src="./script/httpRequest.js"></script>
  111. <script type="text/javascript" src="./script/js/vue.js"></script>
  112. <script type="text/javascript" src="./script/js/vant-ui.js"></script>
  113. <script type="text/javascript" src="./script/js/main.js"></script>
  114. <script type="text/javascript" src="./script/vue_plugins.js"></script>
  115. <script type="text/javascript" src="./script/js/vue-i18n.js"></script>
  116. <script type="text/javascript" src="main/pcr/js/zh.js"></script>
  117. <script type="text/javascript" src="main/pcr/js/en.js"></script>
  118. <script type="text/javascript">
  119. apiready = function() {
  120. function setLang(){
  121. var langType;
  122. var isLang = $api.getStorage('lang')
  123. if (!isLang) {
  124. //备注:屏蔽多语言功能
  125. // langType = navigator.language.toUpperCase().indexOf('EN') != -1 ? 'en' : 'cn'
  126. langType = "cn";
  127. $api.setStorage('lang', langType);
  128. } else {
  129. langType = isLang
  130. }
  131. // let langType = $api.getStorage('lang') || 'cn'
  132. i18n = new VueI18n({
  133. locale: langType,//设置语言
  134. messages: {
  135. en: getEn(),
  136. cn: getCn()
  137. }
  138. })
  139. };
  140. var i18n;
  141. setLang();
  142. api.addEventListener({
  143. name:'setLang'
  144. }, function(lang){
  145. i18n.locale = lang.value
  146. })
  147. //$api.clearStorage();
  148. var header = $api.byId('aui-header');
  149. $api.fixStatusBar(header);
  150. var headerPos = $api.offset(header);
  151. var body_h = $api.offset($api.dom('body')).h;
  152. api.addEventListener({
  153. name: 'rebacklogin'
  154. }, function(ret, err){
  155. if( ret ){
  156. // alert( JSON.stringify( ret ) );
  157. }else{
  158. // alert( JSON.stringify( err ) );
  159. }
  160. });
  161. new Vue({
  162. el: "#con",
  163. i18n,
  164. data: {
  165. loginid: "",
  166. roleScene: "",
  167. currentItem:0,
  168. roleList: [],
  169. showScope: false,
  170. loadingShow: true
  171. },
  172. computed:{
  173. },
  174. created: function(){
  175. var _this = this;
  176. // 判断是否登录
  177. if(!this.isLogin()){
  178. _this.openLogin(headerPos, body_h);
  179. };
  180. // 判断是否需要选择角色,需要选择角色的情况:showScope为true
  181. if(typeof $api.getStorage("showScope") == "string" && $api.getStorage("showScope")=="true"){
  182. // 需要选择角色
  183. if($api.getStorage("roleScene")==""||$api.getStorage("roleScene")==undefined){
  184. _this.openLogin(headerPos, body_h);
  185. }else{
  186. _this.loginEntrance($api.getStorage("roleScene"),'.');
  187. }
  188. }else if(typeof $api.getStorage("showScope") == "string" && $api.getStorage("showScope")=="false"){
  189. // 不需要选择角色,直接进入对应的界面
  190. _this.loginEntrance($api.getStorage("roleScene"),'.');
  191. }else{
  192. _this.openLogin(headerPos, body_h);
  193. };
  194. // 这里是账号密码登录的数据
  195. api.addEventListener({name:"saveUserPwdInfo"},function(info){
  196. // 设置多语言
  197. setLang();
  198. _this.showScope = info.value.data.data.showScope;
  199. if(_this.showScope){
  200. // 选择业务场景
  201. _this.roleList = info.value.data.data.scopeList;
  202. }else{
  203. // 默认不选择业务场景时
  204. $api.setStorage('roleScene', info.value.data.data.spart);
  205. _this.loginEntrance(info.value.data.data.spart,'.');
  206. }
  207. });
  208. },
  209. mounted: function(){
  210. var _this = this;
  211. setTimeout(function(){
  212. // 防止数据没存进storage,可以点击退出重新登录
  213. _this.loadingShow = false;
  214. },6*1000)
  215. },
  216. methods: {
  217. reback: function(){
  218. // 加载失败退出重新登录
  219. this.openLogin(headerPos, body_h);
  220. },
  221. onChange(index) {
  222. this.currentItem = index;
  223. },
  224. openLogin(headerPos, body_h, footer_h) {
  225. $api.clearStorage();
  226. api.openWin({
  227. name : 'login',
  228. url : './main/login.html',
  229. rect : {
  230. x : 0,
  231. y : 0,
  232. w : 'auto',
  233. h : body_h - footer_h - headerPos.h
  234. },
  235. animation : {
  236. type : "none", //动画类型(详见动画类型常量)
  237. subType : "from_right", //动画子类型(详见动画子类型常量)
  238. duration : 200 //动画过渡时间,默认300毫秒
  239. }
  240. });
  241. },
  242. selectedRole(params){
  243. var _this = this;
  244. this.showModal(this.$t('change.tipsTitle'), this.$t('change.tips1')+params.spartName+ this.$t('change.tips2'), [this.$t('common.cancel'), this.$t('common.confirm')],function(index){
  245. if(index==1){
  246. var data = {
  247. token : $api.getStorage("token"),
  248. vkorg : params.vkorg,
  249. vtweg : params.vtweg,
  250. spart: params.spart,
  251. url : 'json',
  252. type : 'body'
  253. };
  254. _this.$post("confirmBusinessScope", data, function(ret) {
  255. if(ret.code==0||ret.code=="0"){
  256. _this.loginEntrance(params.spart,'.');
  257. $api.setStorage('roleScene', params.spart);
  258. $api.setStorage("token", ret.data.token);
  259. }
  260. })
  261. }else{
  262. $api.clearStorage("roleScene");
  263. }
  264. })
  265. }
  266. }
  267. });
  268. }
  269. </script>
  270. </html>