login.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. import { login,loginByWeChat,setPhone,setIPhoneNumber,bindWechat,updatePushId,loginByApple } from '@/api/user'
  2. import { qconfig } from '@/utils/config.js';
  3. import { navBack, registerIdCode,updateMsgDot,setSource } from '@/utils/common.js';
  4. import {isLogin} from '@/utils/common.js'
  5. let univerifyManager=null;
  6. let registrationID=uni.getStorageSync("registrationID");
  7. let userPhone="";
  8. let unionid="";
  9. let appleKey="";
  10. let loginType=3;//1账号密码 2:微信登录 3:手机号一键登录
  11. let isMobileLoginFst=false; //标识是否先手机号登录且没有绑定微信;(该手机号用户没有微信unionId)
  12. let pages = '';
  13. let url = ''; //当前页页面实例
  14. let source = 'app';
  15. // #ifdef APP-PLUS
  16. let isIOS = plus.os.name == 'iOS';
  17. if(isIOS){
  18. source='iOS';
  19. }
  20. // #endif
  21. // #ifndef APP-PLUS
  22. source = 'h5';
  23. // #endif
  24. export function showLoginPage(){
  25. pages = getCurrentPages();
  26. url = pages[ pages.length - 1];
  27. // #ifdef APP-PLUS
  28. if(qconfig!=undefined && qconfig.applyLogin){
  29. return;
  30. }
  31. if(!plus.runtime.isAgreePrivacy()) {
  32. if(url&&url.route=="pages/auth/login"){
  33. return;
  34. }
  35. uni.navigateTo({
  36. url: "/pages/auth/login"
  37. });
  38. return;
  39. }
  40. uni.showLoading({title:""});
  41. getRegistrationID();
  42. let that=this;
  43. univerifyManager = uni.getUniverifyManager();
  44. if(isIOS){
  45. uni.preLogin({
  46. provider: 'univerify',
  47. success(res){ //预登录成功
  48. // 显示一键登录选项
  49. uni.hideLoading();
  50. console.log("预登录成功");
  51. univerifyLogin(this);
  52. },
  53. fail(res){ // 预登录失败
  54. // 不显示一键登录选项(或置灰)
  55. // 根据错误信息判断失败原因,如有需要可将错误提交给统计服务器
  56. uni.hideLoading();
  57. if(res.errCode==30005 || res.errMsg.includes("无SIM卡")){
  58. if(url&&url.route=="pages/auth/login"){
  59. return;
  60. }
  61. setTimeout(function() {
  62. uni.navigateTo({url: "/pages/auth/login"});
  63. }, 400);
  64. }
  65. }
  66. });
  67. return;
  68. }else{
  69. //手机号一键登录时
  70. univerifyLogin(this);
  71. }
  72. const loginCallBack = (resinfo) => {
  73. // 获取一键登录弹框协议勾选状态
  74. univerifyManager.getCheckBoxState({success(res) {
  75. if(qconfig!=undefined){
  76. qconfig.applyLogin=false;
  77. }
  78. uni.hideLoading();
  79. if(!res.state){
  80. uni.showToast({title: "请同意服务条款和隐私政策",icon: 'none',position:'bottom'});
  81. return;
  82. }
  83. if(resinfo.provider=='weixin') {
  84. quickWechatLogin(false);
  85. }else if(resinfo.provider=='apple') {
  86. quickAppleLogin()
  87. }
  88. // 关闭一键登录弹框
  89. univerifyManager.close();
  90. }
  91. });
  92. }
  93. // 订阅自定义按钮点击事件
  94. univerifyManager.onButtonsClick(loginCallBack);
  95. // 取消订阅自定义按钮点击事件
  96. //univerifyManager.offButtonsClick(loginCallBack);
  97. if(qconfig!=undefined){
  98. qconfig.applyLogin=true;
  99. }
  100. uni.hideLoading();
  101. // #endif
  102. // #ifdef H5
  103. if(String(navigator.userAgent.toLowerCase().match(/MicroMessenger/i)) === "micromessenger"){
  104. let url=window.location.href;
  105. //let urlPaths=url.split("/h5");
  106. let urlPaths=url.split("/pages");
  107. let pagePath="/pages"+urlPaths[1];
  108. uni.setStorageSync('beforLoginPage',pagePath);
  109. uni.navigateTo({
  110. url: "/pages/auth/h5WxLogin"
  111. });
  112. }
  113. else{
  114. if(url&&url.route=="pages/auth/login"){
  115. return;
  116. }
  117. uni.navigateTo({
  118. url: "/pages/auth/login"
  119. });
  120. }
  121. // #endif
  122. }
  123. const univerifyLogin=function(that){
  124. let buttonslist=[
  125. {
  126. "provider": "weixin",
  127. "iconPath": "/static/image/login/weixin.png" // 图标路径仅支持本地图片
  128. }
  129. ]
  130. if(isIOS) {
  131. if(this.$checkWechatInstalled()){
  132. buttonslist=[
  133. {
  134. "provider": "weixin",
  135. "iconPath": "/static/image/login/weixin.png" // 图标路径仅支持本地图片
  136. },
  137. {
  138. "provider": "apple",
  139. "iconPath": "/static/image/login/apple.png" // 图标路径仅支持本地图片
  140. }
  141. ]
  142. }else{
  143. buttonslist=[
  144. {
  145. "provider": "apple",
  146. "iconPath": "/static/image/login/apple.png" // 图标路径仅支持本地图片
  147. }
  148. ]
  149. }
  150. }
  151. univerifyManager.login({
  152. provider: 'univerify',
  153. univerifyStyle: { // 自定义登录框样式
  154. fullScreen: true,
  155. authButton: {
  156. "title": "本机号码一键登录",
  157. "normalColor": "#FF5C03",
  158. "highlightColor": "#FF5C03",
  159. },
  160. otherLoginButton: {
  161. "title": "快捷登录",
  162. "visible": "false",
  163. },
  164. closeIcon: {
  165. "path": "static/image/icon_close.png",
  166. "width": "60px", //图标宽度 默认值:60px (HBuilderX 4.0支持)
  167. "height": "60px" //图标高度 默认值:60px (HBuilderX 4.0支持)
  168. },
  169. buttons: {
  170. "iconWidth": "44px", // 图标宽度(高度等比例缩放) 默认值:45px
  171. "list": buttonslist
  172. },
  173. privacyTerms: {
  174. "defaultCheckBoxState":false, // 条款勾选框初始状态 默认值: true
  175. "isCenterHint":false, //未勾选服务条款时点击登录按钮的提示是否居中显示 默认值: false (3.7.13+ 版本支持)
  176. "uncheckedImage":"", // 可选 条款勾选框未选中状态图片(仅支持本地图片 建议尺寸 24x24px)(3.2.0+ 版本支持)
  177. "checkedImage":"", // 可选 条款勾选框选中状态图片(仅支持本地图片 建议尺寸24x24px)(3.2.0+ 版本支持)
  178. "checkBoxSize":18, // 可选 条款勾选框大小
  179. "textColor": "#BBBBBB", // 文字颜色 默认值:#BBBBBB
  180. "termsColor": "#FF5C03", // 协议文字颜色 默认值: #5496E3
  181. "prefix": "我已阅读并同意", // 条款前的文案 默认值:“我已阅读并同意”
  182. "suffix": "并使用本机号码登录", // 条款后的文案 默认值:“并使用本机号码登录”
  183. "privacyItems": [ // 自定义协议条款,最大支持2个,需要同时设置url和title. 否则不生效
  184. {
  185. "url": "https://userapp.his.cdwjyyh.com/web/userAgreement", // 点击跳转的协议详情页面
  186. "title": "用户服务协议" // 协议名称
  187. },
  188. {
  189. "url": "https://userapp.his.cdwjyyh.com/web/privacyPolicy", // 点击跳转的协议详情页面
  190. "title": "隐私保护" // 协议名称
  191. }
  192. ]
  193. },
  194. },
  195. success(res){ // 登录成功
  196. console.log("qxj univerify login:"+JSON.stringify(res.authResult)); // {openid:'登录授权唯一标识',access_token:'接口返回的 token'}
  197. uni.hideLoading();
  198. if(qconfig!=undefined){
  199. qconfig.applyLogin=false;
  200. }
  201. loginType=3;
  202. loginByUniverify(res.authResult,0);
  203. },
  204. fail(res){
  205. uni.hideLoading();
  206. if(qconfig!=undefined){
  207. qconfig.applyLogin=false;
  208. }
  209. if(res.code==30008){ //用户点击了自定义按钮
  210. uni.getCheckBoxState({
  211. success(response){
  212. if(!response.state){
  213. uni.showToast({title: "请同意服务条款和隐私政策",icon: 'none',position:'bottom'});
  214. return;
  215. }
  216. if(res.provider=='weixin') {
  217. quickWechatLogin(false);
  218. }else if(res.provider=='apple') {
  219. quickAppleLogin()
  220. }
  221. },
  222. fail(err){
  223. console.log(err.errCode)
  224. console.log(err.errMsg)
  225. }
  226. });
  227. console.log("----qxj 一键登录调用2-----");
  228. }
  229. else if(res.code==30003){ //关闭验证界面
  230. return false;
  231. }
  232. else if(res.code==30005){ //预登录失败
  233. // uni.showToast({title: "一键登录失败请检查网络和SIM卡是否可用",icon: 'none',position:'bottom'});
  234. if(url&&url.route=="pages/auth/login"){
  235. return;
  236. }
  237. setTimeout(function() {
  238. uni.navigateTo({url: "/pages/auth/login"});
  239. }, 400);
  240. }
  241. }
  242. });
  243. };
  244. export function quickWechatLogin(isMobileLogin){
  245. isMobileLoginFst=isMobileLogin;
  246. loginType=2;
  247. uni.login({
  248. provider: "weixin",
  249. onlyAuthorize:true,
  250. success: async (res) => {
  251. let that=this;
  252. uni.showLoading({
  253. title:"处理中..."
  254. });
  255. if(isMobileLogin){
  256. bindWechatAct(userPhone,res.code);
  257. }
  258. else{
  259. const params={"code":res.code,"loginDevice":getLoginDevice(),"jpushId":registrationID,"source":plus.runtime.channel || source};
  260. loginByWeChatAct(params);
  261. }
  262. },
  263. fail: (err) => {
  264. console.log('login fail:', JSON.stringify(err));
  265. // 未开通
  266. if (err.code == 1000) {
  267. uni.showModal({
  268. title: '登录失败',
  269. content: `${err.errMsg}\n,错误码:${err.code}`,
  270. confirmText: '开通指南',
  271. cancelText: '确定',
  272. success: (res) => {
  273. if (res.confirm) {
  274. setTimeout(() => {
  275. plus.runtime.openWeb('https://ask.dcloud.net.cn/article/37965')
  276. }, 500)
  277. }
  278. }
  279. });
  280. return;
  281. }
  282. // 一键登录预登陆失败
  283. if (err.code == '30005') {
  284. uni.showModal({
  285. showCancel: false,
  286. title: '预登录失败',
  287. content: err.errMsg
  288. });
  289. return;
  290. }
  291. // 一键登录用户关闭验证界面
  292. if (err.code != '30003') {
  293. uni.showModal({
  294. showCancel: false,
  295. title: '登录失败',
  296. content: JSON.stringify(err)
  297. });
  298. }
  299. },
  300. complete: () => {
  301. }
  302. });
  303. };
  304. export function loginByWeChatAct(params){
  305. loginByWeChat(params).then(res => {
  306. if(res.code==200){
  307. if(res.user!=null){
  308. uni.hideLoading();
  309. uni.setStorageSync('AppToken',res.token);
  310. uni.setStorageSync('userInfo',JSON.stringify(res.user));
  311. uni.$emit('refreshUserInfo',{ "isFirst":res.isFirst });
  312. uni.$emit('showHealthButler');
  313. uni.closeAuthView();
  314. if(res.isFirst){ //未完成新手任务
  315. uni.navigateTo({ url: '/pages/user/integral/points' });
  316. }
  317. else {
  318. goPage()
  319. }
  320. }
  321. else{
  322. unionid=res.unionid;
  323. if(isMobileLoginFst){ //若先点击手机号登录且没有绑定微信
  324. bindWechatAct(userPhone,unionid);
  325. }else{
  326. if(res.isNew){ //是否绑定手机号
  327. bindMobile();
  328. }
  329. }
  330. }
  331. }
  332. else{
  333. uni.hideLoading();
  334. uni.showToast({title: res.msg,icon: 'none'});
  335. }
  336. },
  337. rej => {}
  338. );
  339. }
  340. export function bindMobile(type){
  341. // #ifdef APP-PLUS
  342. //uni.showLoading({title:""});
  343. const uniLogin = () => {
  344. uni.login({
  345. provider: 'univerify',
  346. univerifyStyle: { // 自定义登录框样式
  347. fullScreen: false,
  348. authButton: {
  349. "title": "绑定手机号",
  350. "normalColor": "#FF5C03",
  351. "highlightColor": "#FF5C03",
  352. },
  353. privacyTerms: {
  354. "defaultCheckBoxState":true, // 条款勾选框初始状态 默认值: true
  355. "isCenterHint":false, //未勾选服务条款时点击登录按钮的提示是否居中显示 默认值: false (3.7.13+ 版本支持)
  356. "uncheckedImage":"", // 可选 条款勾选框未选中状态图片(仅支持本地图片 建议尺寸 24x24px)(3.2.0+ 版本支持)
  357. "checkedImage":"", // 可选 条款勾选框选中状态图片(仅支持本地图片 建议尺寸24x24px)(3.2.0+ 版本支持)
  358. "checkBoxSize":18, // 可选 条款勾选框大小
  359. "textColor": "#BBBBBB", // 文字颜色 默认值:#BBBBBB
  360. "termsColor": "#FF5C03", // 协议文字颜色 默认值: #5496E3
  361. "prefix": "我已阅读并同意", // 条款前的文案 默认值:“我已阅读并同意”
  362. "suffix": "并使用本机号码登录", // 条款后的文案 默认值:“并使用本机号码登录”
  363. "privacyItems": [ // 自定义协议条款,最大支持2个,需要同时设置url和title. 否则不生效
  364. ]
  365. },
  366. },
  367. success(res){ //
  368. // console.log("qxj univerify login:"+JSON.stringify(res.authResult)); // {openid:'登录授权唯一标识',access_token:'接口返回的 token'}
  369. if(type==1) {
  370. loginByUniverify(res.authResult,3);
  371. } else {
  372. loginByUniverify(res.authResult,1);
  373. }
  374. },
  375. fail(res){
  376. uni.hideLoading();
  377. uni.closeAuthView();
  378. if(res.errCode==30005){ //预登录失败
  379. //uni.showToast({title: "一键登录失败请检查网络和SIM卡是否可用",icon: 'none',position:'bottom'});
  380. if(url&&url.route=="pages/auth/login"){
  381. return;
  382. }
  383. //setTimeout(function() {
  384. uni.navigateTo({url: "/pages/auth/login"});
  385. //}, 1800);
  386. }
  387. console.log("qxj failRes:"+JSON.stringify(res));
  388. }
  389. });
  390. };
  391. uniLogin();
  392. console.log("----qxj 一键登录调用3-----");
  393. // #endif
  394. // #ifdef H5
  395. if(url&&url.route=="pages/auth/login"){
  396. return;
  397. }
  398. uni.navigateTo({
  399. url: "/pages/auth/login"
  400. });
  401. // #endif
  402. };
  403. export function loginByUniverify(authResult,type){
  404. uniCloud.callFunction({
  405. name: 'loginByMobile', // 你的云函数名称
  406. data: {
  407. access_token: authResult.access_token, // 客户端一键登录接口返回的access_token
  408. openid:authResult.openid // 客户端一键登录接口返回的openid
  409. }
  410. }).then(res => {
  411. if(res.result.errCode==0){
  412. userPhone=res.result.phoneNumber;
  413. if(type==0){ //手机号一键登录
  414. loginActionAct();
  415. }else{ //微信登录绑定手机号
  416. setPhoneAct(userPhone,unionid);
  417. }
  418. }else{
  419. uni.showToast({title:res.result.message,icon: 'none' });
  420. }
  421. }).catch(err=>{
  422. // 处理错误
  423. console.error('调用云函数失败:',err);
  424. // 详细记录错误信息
  425. console.error('错误信息:', err.errMsg);
  426. })
  427. }
  428. export function loginActionAct(){
  429. if (loginType==3 && userPhone==null) {
  430. uni.showToast({title: "请授权手机号登录",icon: 'none'});
  431. return
  432. }
  433. var data = {
  434. phone:userPhone,
  435. jpushId:registrationID,
  436. loginType:loginType,
  437. loginDevice:getLoginDevice(),
  438. source:plus.runtime.channel || source
  439. };
  440. var that=this;
  441. uni.showLoading({
  442. title:"处理中..."
  443. });
  444. login(data).then(res => {
  445. uni.hideLoading();
  446. if(res.code==200){
  447. if(res.isNew){
  448. userPhone=res.phone;
  449. quickWechatLogin(true);
  450. return;
  451. }
  452. uni.setStorageSync('AppToken',res.token);
  453. uni.setStorageSync('userInfo',JSON.stringify(res.user));
  454. uni.$emit('showHealthButler');
  455. uni.closeAuthView();
  456. if(res.isFirst){
  457. // #ifdef APP-PLUS
  458. if(plus.runtime.channel=="baidu"){ //获取百度渠道标识
  459. let bdCmdType=uni.getStorageSync("bdCmdType");
  460. if(bdCmdType!=null && parseInt(bdCmdType)<1){
  461. registerIdCode("register",1,0,res.user.userId); //注册
  462. }
  463. }
  464. // #endif
  465. uni.$emit('refreshIM');
  466. uni.navigateTo({ url: '/pages/user/integral/points' });
  467. } else {
  468. goPage();
  469. }
  470. }
  471. else{
  472. uni.showToast({title: res.msg,icon: 'none'});
  473. }
  474. },
  475. rej => {}
  476. );
  477. }
  478. export function setPhoneAct(phone,unionId){
  479. let params={
  480. "phone":phone,
  481. "unionId":unionId,
  482. "jpushId":registrationID,
  483. "source":plus.runtime.channel || source
  484. };
  485. if(!isIOS){
  486. setPhone(params).then(res => {
  487. uni.hideLoading();
  488. if(res.code==200){
  489. uni.setStorageSync('AppToken',res.token);
  490. uni.setStorageSync('userInfo',JSON.stringify(res.user));
  491. uni.$emit('showHealthButler');
  492. uni.closeAuthView();
  493. goPage();
  494. }
  495. else{
  496. uni.showToast({title: res.msg,icon: 'none',duration:2000});
  497. }
  498. },
  499. rej => {}
  500. );
  501. }
  502. else{
  503. params.simExist=1;
  504. params.appleKey=appleKey;
  505. setIPhoneNumber(params).then(res => {
  506. uni.hideLoading();
  507. if(res.code==200){
  508. uni.setStorageSync('AppToken',res.token);
  509. uni.setStorageSync('userInfo',JSON.stringify(res.user));
  510. uni.$emit('showHealthButler');
  511. uni.closeAuthView();
  512. goPage();
  513. }
  514. else{
  515. uni.showToast({title: res.msg,icon: 'none',duration:2000});
  516. }
  517. },
  518. rej => {}
  519. );
  520. }
  521. }
  522. export function bindWechatAct(phone,code){
  523. let params={"phone":phone,"code":code,"jpushId":registrationID,"source":plus.runtime.channel || source};
  524. bindWechat(params).then(res => {
  525. uni.hideLoading();
  526. console.log("qxj bindWeChat res:"+JSON.stringify(res));
  527. if(res.code==200){
  528. uni.setStorageSync('AppToken',res.token);
  529. uni.setStorageSync('userInfo',JSON.stringify(res.user));
  530. uni.$emit('showHealthButler');
  531. uni.closeAuthView();
  532. goPage();
  533. // #ifdef APP-PLUS
  534. const jyJPush = uni.requireNativePlugin('JY-JPush');
  535. // jyJPush.setJYJPushAlias({userAlias: registrationID}, result=> {
  536. // console.log("qxj userAlias "+JSON.stringify(result));
  537. // });
  538. // #endif
  539. }
  540. else{
  541. uni.showToast({title: res.msg,icon: 'none'});
  542. setTimeout(function() {
  543. uni.closeAuthView();
  544. }, 1800);
  545. }
  546. },
  547. rej => {}
  548. );
  549. }
  550. export function getRegistrationID(type) {
  551. // #ifdef APP-PLUS
  552. registrationID = uni.getStorageSync("registrationID");
  553. const needUpdate = type === 'update' || !registrationID;
  554. if (needUpdate&&plus.runtime.isAgreePrivacy()) {
  555. uni.getPushClientId({success: res => {
  556. console.log("qxj getPushClientId:",res);
  557. if(!registrationID || registrationID != res.cid) {
  558. registrationID = res.cid
  559. uni.setStorageSync("registrationID",res.cid);
  560. if(type == 'update'&&isLogin()) {
  561. upPushClientId(res.cid)
  562. }
  563. }
  564. },
  565. fail:(err)=> {
  566. console.log("getRegistrationID error:",err)
  567. }
  568. });
  569. }
  570. // #endif
  571. }
  572. export function quickAppleLogin() {
  573. uni.login({
  574. provider: 'apple',
  575. success: function (loginRes) {
  576. appleKey = loginRes.authResult.openid
  577. const params={
  578. loginDevice:getLoginDevice(),
  579. jpushId:registrationID,
  580. source:plus.runtime.channel || source,
  581. appleKey: appleKey
  582. };
  583. uni.showLoading({
  584. title: '登录中'
  585. })
  586. loginByApple(params).then(res=>{
  587. uni.hideLoading();
  588. console.log("qxj loginByApple:",res);
  589. if(res.code==200){
  590. if(res.user!=null){
  591. uni.hideLoading();
  592. uni.setStorageSync('AppToken',res.token);
  593. uni.setStorageSync('userInfo',JSON.stringify(res.user));
  594. uni.$emit('refreshUserInfo',{ "isFirst":res.isFirst });
  595. uni.$emit('showHealthButler');
  596. uni.closeAuthView();
  597. if(res.isFirst){ //未完成新手任务
  598. uni.navigateTo({ url: '/pages/user/integral/points' });
  599. }
  600. else {
  601. goPage()
  602. }
  603. } else {
  604. if(res.isNew){ //是否绑定手机号
  605. bindMobile(1);
  606. }
  607. }
  608. }
  609. else{
  610. uni.hideLoading();
  611. uni.showToast({title: res.msg,icon: 'none'});
  612. }
  613. }).catch(()=>{
  614. uni.hideLoading()
  615. })
  616. },
  617. fail: function (err) {
  618. console.log(err);
  619. // 登录授权失败
  620. // err.code错误码参考`授权失败错误码(code)说明`
  621. }
  622. });
  623. }
  624. export function getLoginDevice(){
  625. let loginDevice = "";
  626. // #ifdef APP-PLUS
  627. if(plus.runtime.isAgreePrivacy()) {
  628. let devinfo=uni.getDeviceInfo();
  629. if(devinfo!=null){
  630. loginDevice += devinfo.deviceBrand ? devinfo.deviceBrand : "";
  631. loginDevice += devinfo.deviceModel ? " " + devinfo.deviceModel : "";
  632. loginDevice += devinfo.system ? " " + devinfo.system : "";
  633. }
  634. }
  635. // #endif
  636. return loginDevice;
  637. }
  638. export function goPage() {
  639. uni.$emit('refreshIM');
  640. pages = getCurrentPages();
  641. url = pages[ pages.length - 1];
  642. if(univerifyManager) {
  643. univerifyManager.close();
  644. uni.closeAuthView();
  645. univerifyManager = null
  646. }
  647. const openUrl = uni.getStorageSync("openUrl")
  648. if(openUrl) {
  649. uni.navigateTo({
  650. url: openUrl,
  651. success: function(res) {
  652. uni.removeStorageSync("openUrl")
  653. }
  654. });
  655. } else {
  656. uni.reLaunch({
  657. url: '../index/index',
  658. //url: '../course/index',
  659. //url: '../course/video/living-app',
  660. animationType: 'none',
  661. animationDuration: 2000
  662. });
  663. return;
  664. if(pages.length == 1) {
  665. uni.reLaunch({
  666. url: '../index/index',
  667. // url: '../course/index',
  668. //url: '../course/video/living-app',
  669. animationType: 'none',
  670. animationDuration: 2000
  671. })
  672. } else {
  673. navBack()
  674. }
  675. }
  676. updateMsgDot()
  677. setSource()
  678. }
  679. export function upPushClientId(pushId) {
  680. updatePushId({pushId:pushId})
  681. }