<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                * [xcxLogin.js](http://www.hmoore.net/wangking/uniapp/1899323#xcxLoginjs_1) * [main.js 中注冊該方法](http://www.hmoore.net/wangking/uniapp/1899323#mainjs__157) * [客戶端調用](http://www.hmoore.net/wangking/uniapp/1899323#_177) ## xcxLogin.js > 存放路徑 /common/xcxLogin.js > 參考 《[一個5年的web前端開源的uni-app快速開發模板](https://ext.dcloud.net.cn/plugin?id=2009)》 ~~~ import store from '@/config/store'; import $http from '@/config/requestConfig' import base from '@/config/baseUrl'; // #ifdef H5 import { h5Login } from '@/config/html5Utils'; // #endif let code = ""; let loginStart = true; let userInfo = { token: "" }; let lastPageUrl = ""; // 微信小程序登錄 function onLogin(type = "judge",callback) { //判斷登錄狀態 if (loginStart) { lastPageUrl = ""; loginStart = false; const _this = this; let platform; // #ifdef MP-WEIXIN platform = 'weixin'; // #endif // #ifdef MP-ALIPAY platform = 'alipay'; // #endif // #ifdef MP-BAIDU platform = 'baidu'; // #endif uni.login({ provider: platform, success: function(loginRes) { if (loginRes.errMsg == 'login:ok') { code = loginRes.code; // 獲取用戶信息 uni.getUserInfo({ provider: platform, success: function(infoRes) { getUserInfo(infoRes, "", callback); }, fail() { if(type != "try"){ store.commit('setLoginPopupShow', true); Object.defineProperty(userInfo, "token", { get: function(val) { return {}; }, set: function(newVal) { callback && callback(); } }); setTimeout(() => { loginStart = true; }, 2000); }else{ loginStart = true; } } }); } } }); } } //微信小程序獲取用戶信息 function getUserInfo(info, type, callback) { let httpData = { wxSmallCode: code, //小程序code iv: info.iv, //小程序加密算法的初始向量 encryptedData: info.encryptedData //包括敏感數據在內的完整用戶信息的加密數據 }; // store.state.chatScenesInfo里面是小程序二維碼附帶的信息 if(store.state.chatScenesInfo.recommendCode){ // 推薦碼 httpData.recommendUid = store.state.chatScenesInfo.recommendCode; } $http.post('api/open/v1/login', httpData).then(res => { loginStart = true; store.commit('setUserInfo', res); if (type == "authorized") { userInfo.token = res.token; store.commit('setLoginPopupShow', false); }else{ callback && callback(); } uni.showToast({ title: "登錄成功" }); }, err => { loginStart = true; }); } //判斷是否登錄(所有端) function judgeLogin(callback, type = "judge"){ let storeUserInfo = store.state.userInfo; if(!storeUserInfo.token){ // nvue頁面讀取不到vuex里面數據,將取緩存 storeUserInfo = uni.getStorageSync("userInfo"); } if (type != "force" && storeUserInfo.token) { callback(); } else if (storeUserInfo.token && !storeUserInfo.phone) { if (type == "force") { uni.navigateTo({ url: '/pages/user/bindPhone' }); } else { uni.showModal({ title: "提示", content: "您還未綁定手機號,請先綁定~", confirmText: "去綁定", cancelText: "再逛會", success: (res) => { if (res.confirm) { uni.navigateTo({ url: '/pages/user/bindPhone' }); } } }); } } else { // #ifdef MP onLogin(type, callback); // #endif // #ifdef APP-PLUS uni.showModal({ title: "登錄提示", content: "此時此刻需要您登錄喔~", confirmText: "去登錄", cancelText: "再逛會", success: (res) => { if (res.confirm) { uni.navigateTo({ url: "/pages/user/login" }); } } }); // #endif // #ifdef H5 h5Login(type, () => { callback(); }); // #endif } } export { onLogin, getUserInfo, judgeLogin } ~~~ ## main.js 中注冊該方法 > 路徑 /main.js ~~~ import Vue from 'vue' import App from './App' import xcxLogin from './common/xcxLogin.js' Vue.config.productionTip = false Vue.prototype.$xcxLogin = xcxLogin App.mpType = 'app' const app = new Vue({ ...App }) app.$mount() ~~~ ## 客戶端調用 > 參考 《[一個5年的web前端開源的uni-app快速開發模板](https://ext.dcloud.net.cn/plugin?id=2009)》 ~~~ // 暫無 ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看