123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <script>
- export default {
- data() {
- return {
- getOn:true,
- globalData:{
- shareList:[],
- }
- }
- },
- onLaunch: function(param) {
-
- },
- onShow: function() {
- // #ifdef MP
- // 检查是否升级
- this.checkForUpdate();
- // #endif
- // 进入小程序,如果需要推送客服,请求客户信息,获取最新的微伴ID
- if( this.$checkAccess.getFollowQrcode() ){
- if( !this.getOn ) return ;
- this.getOn = false;
- // 判断数据
- this.$http.request('api/custom/get_info').then((callback)=>{
- this.getOn = true;
- if( callback.code == 'success' ){
- if( !callback.data.userpic ) callback.data.userpic = "../../static/icon/doctor.png";
- // 赋值
- this.userInfo = callback.data;
- // 存储登录标识
- uni.setStorageSync('userInfo',callback.data);
- }
- });
- }
- // 判断数据
- this.$http.request('/api/share_message/get_list').then((callback)=>{
- if( callback.code == 'success' ){
- // 赋值
- getApp().globalData.shareList = callback.data;
- }
- });
-
- },
- onHide: function() {
- console.log('App Hide');
- },
- methods:{
- // 检查是否升级
- checkForUpdate(){
- const _this = this;
- // 获取升级管理实例
- const updateManager = uni.getUpdateManager();
- // 请求版本回调
- updateManager.onCheckForUpdate(function(res){
- console.log(res);
- // 如果有版本升级
- if( res && res.hasUpdate ){
- uni.showModal({
- title:"更新提示",
- content:"检测到新版,点击确认升级程序",
- showCancel:false,
- success(res){
- if(res.confirm){
- uni.showLoading({title:"程序更新中"});
- // 判断是否准备好升级
- updateManager.onUpdateReady(function(res){
- // 关闭加载
- uni.hideLoading();
- // 当新版本下载完成,调用该方法会强制当前uni-app应用上新版本并重启
- updateManager.applyUpdate();
- })
- updateManager.onUpdateFailed(function(err){
- // 关闭加载
- uni.hideLoading();
- })
- }
- }
- })
- }
- })
-
- }
- }
- }
- </script>
- <style lang="less">
- /*每个页面公共css */
- page{
- font-family: Arial, Helvetica, sans-serif;
- background: #F5F5F5;
- }
- // 到底了
- .to_bottom{
- height: 40rpx;
- color: #999999;
- display: block;
- font-size: 20rpx;
- margin-top: 20rpx;
- line-height: 40rpx;
- text-align: center;
- padding-bottom: 160rpx;
- }
- </style>
|