| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <script>
- import md5 from '@/common/md5.js';
- export default {
- globalData: {
- shareUrl: "https://ng.xazhima.com/",
- //shareUrl:"https://kgwxxcx.xixianxinqu.gov.cn/1026airqt/",
- globalTimestamp: Date.now().toString(),
- secret: "AirQK_weichat_app_zhima",
- selectedIndex:0,
- isSider:false,
- user_id: '',
- open_id:'',
- user_status:'',
- user_name:'',
- user_phone:'',
- user_headUrl:'',
- globalAuth:false,
- session_key: '',
- isAndroid:false,
- user_department:'',
- user_real_name:'',
- },
- onLaunch: function () {
- console.log("App Launch");
- // let equType = uni.getSystemInfoSync().platform;
- // switch(equType){
- // case 'android':
- // console.log('运行Android上')
- // setTimeout(()=>{
- // getApp().globalData.isAndroid = true
- // },100)
- // break;
- // case 'ios':
- // console.log('运行iOS上');
- // break;
- // default:
- // console.log('运行在开发者工具上')
- // break;
- // }
- this.loginLoad();
- },
- onShow: function () {
- console.log("App Show");
- // uni.hideTabBar({})
- },
- onHide: function () {
- console.log("App Hide");
- },
- methods:{
- loginLoad(){
- let that = this;
- uni.login({
- success(res) {
- that.loginRequest(res.code)
- }
- })
- },
- loginRequest(codeRes){
- let that = this;
- let md5Sign = md5("method="+'user'+"×tamp="+getApp().globalData.globalTimestamp+"&secret="+getApp().globalData.secret)
- let url = getApp().globalData.shareUrl+'api/api.php'+'?method=user&action=login×tamp='+getApp().globalData.globalTimestamp +'&sign='+md5Sign
- uni.request({
- url:url,
- method: 'POST',
- header: {
- 'content-type': 'application/x-www-form-urlencoded'
- },
- data: {
- code:codeRes
- },
- success: (res) => {
- console.log(res)
- if(res.data.code === 200){
- getApp().globalData.open_id = res.data.data.openid;
- getApp().globalData.user_status = res.data.data.status;
- getApp().globalData.session_key = res.data.data.session_key
- getApp().globalData.user_phone = res.data.data.phone;
- that.$isResolve();
- // uni.hideLoading()
- }
- },
- fail: () => {
- console.log("连接失败");
- }
- });
- },
- }
- };
- </script>
- <style>
- /*每个页面公共css */
- @import '@/common/uni.css';
- page {
- height: 100%;
- }
- *{touch-action: none;}
- .display-flex-start {
- display: flex;
- align-items: center;
- }
- .display-flex-end {
- display: flex;
- justify-content: flex-end;
- align-items: center;
- }
- .display-between {
- display: flex;
- justify-content: space-between;
- }
- .display-around {
- display: flex;
- justify-content: space-around;
- }
- .display-between-column {
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- }
- .display-around-column {
- display: flex;
- flex-direction: column;
- justify-content: space-around;
- }
- .display-wrap {
- display: flex;
- flex-wrap: wrap;
- }
- .items-center {
- align-items: center;
- }
- </style>
|