app.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //app.js viptime
  2. // appid wx842cf17c56448e51
  3. // appid 装修宝 wxf33092e34e6ae8b1
  4. var d = new Date()
  5. App({
  6. globalData:{
  7. statusBarHeight:'',
  8. titleBarHeight:44,
  9. imgUrl:'https://o.nczyzs.com/',//imgzqxgtest
  10. wburl:'https://img.yunxiekeji.cn',
  11. simgUrl:'https://wzh-zqxg.oss-cn-hangzhou.aliyuncs.com/',
  12. webUrl:'https://zqxg.cc/',//测试环境 saastest https://saasdev.zhuangqixiaoguan.com/,正式环境https://wzh.nczyzs.com/
  13. token:'',
  14. userflag:false,//true是有个人信息,false没有个人信息
  15. phone:false,//true是有手机号,false是没有手机号
  16. shareuserid:'',//分享人的id
  17. currentUserId: '',
  18. agentEmployeEid: "",
  19. brokeruserId: '',
  20. vrString: '',
  21. companyobj:{},
  22. shareperson:{},
  23. sharempid:'',
  24. personMsg:{},//org_type 2是设计师,其他的是销售
  25. unreadNum:0,
  26. official_openid: null,
  27. screenHeight:'100%',
  28. sharename:'',//分享人的昵称
  29. timearr:[],
  30. addstate:'',//add是添加客户页面,list是客户列表页面
  31. clientype:'',
  32. companyname:'',
  33. agentName: "",
  34. platform: '',
  35. vraddress: '',
  36. sharepersonobj:{},
  37. timeline:'',//1是从“单页模式”打开小程序”,2是朋友圈内打开“单页模式”
  38. useversion:true,
  39. },
  40. onLaunch: function (opts) {
  41. var that = this;
  42. // wx.loadFontFace({
  43. // family: 'digifaw',
  44. // global:true,
  45. // source: 'url("https://wzh.nczyzs.com/static/fonts/digifaw.ttf")',
  46. // success: console.log
  47. // })
  48. this.globalData.timearr = [];
  49. const updateManager = wx.getUpdateManager()
  50. updateManager.onCheckForUpdate(function (res) {
  51. // 请求完新版本信息的回调
  52. console.log(res.hasUpdate)
  53. })
  54. updateManager.onUpdateReady(function () {
  55. wx.showModal({
  56. title: '更新提示',
  57. content: '新版本已经准备好,是否重启应用?',
  58. success: function (res) {
  59. if (res.confirm) {
  60. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  61. updateManager.applyUpdate()
  62. }
  63. }
  64. })
  65. })
  66. updateManager.onUpdateFailed(function () {
  67. // 新的版本下载失败
  68. wx.showModal({
  69. title: '更新提示',
  70. content: '新版本下载失败',
  71. showCancel: false
  72. })
  73. })
  74. wx.getSystemInfo({
  75. success: (res) => {
  76. that.globalData.screenHeight = res.safeArea.height;
  77. that.globalData.platform = res.platform;
  78. that.globalData.statusBarHeight = res.statusBarHeight;
  79. if (!!that.globalData.statusBarHeight && res.platform != 'devtools') {
  80. wx.setStorage({
  81. key: "statusBarHeight",
  82. data: res.statusBarHeight
  83. })
  84. }
  85. },
  86. fail: (res) => {
  87. }
  88. })
  89. var that = this;
  90. var obj = wx.getLaunchOptionsSync();
  91. if(obj.scene==1155){
  92. that.globalData.timeline=1;
  93. if(obj.path=='index/pages/namecard/namecard'){
  94. wx.reLaunch({
  95. url:'/share/pages/shareCard/shareCard?uid=' + obj.query.uid + '&empid=' + obj.query.empid + '&ctp=' + obj.query.ctp,
  96. })
  97. }
  98. }else if(obj.scene==1154&&(obj.path=='index/pages/namecard/namecard'||obj.path=='share/pages/shareCard/shareCard'||obj.path=='pages/index/index')){
  99. that.globalData.timeline=2;
  100. }else{
  101. that.globalData.timeline='';
  102. }
  103. },
  104. onShow: function (options) {
  105. var that = this;
  106. var obj = wx.getLaunchOptionsSync();
  107. if(obj.scene==1155){
  108. that.globalData.timeline=1;
  109. if(obj.path=='index/pages/namecard/namecard'){
  110. wx.reLaunch({
  111. url:'/share/pages/shareCard/shareCard?uid=' + obj.query.uid + '&empid=' + obj.query.empid + '&ctp=' + obj.query.ctp,
  112. })
  113. }
  114. }else if(obj.scene==1154&&(obj.path=='index/pages/namecard/namecard'||obj.path=='share/pages/shareCard/shareCard'||obj.path=='pages/index/index')){
  115. that.globalData.timeline=2;
  116. }else{
  117. that.globalData.timeline='';
  118. }
  119. wx.getStorage({
  120. key: 'lastpath',
  121. success(res) {
  122. let arr = obj.path.split('/');
  123. if (res.data == obj.path && obj.path == 'mycustomer/pages/invite/invite') {
  124. wx.reLaunch({
  125. url: '/pages/index/index',
  126. })
  127. }
  128. }
  129. })
  130. if (obj.path == 'mycustomer/pages/invite/invite') {
  131. wx.removeStorage({
  132. key: "lastpath",
  133. })
  134. } else {
  135. wx.setStorage({
  136. key: "lastpath",
  137. data: obj.path
  138. })
  139. }
  140. },
  141. })