<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [TOC] # 作為公用方法使用 ``` 導出 module.exports={ onShareAppMessage:function(url,customtitle,imgSrc){}, baocun(imageUrl){}, ..... } 引入 const core = require('../../utils/core.js'); ``` ## 保存圖片 ``` // 保存圖片到相冊 baocun(imageUrl) { //獲取相冊授權 let $this = this wx.getSetting({ success(res) { if (!res.authSetting['scope.writePhotosAlbum']) { wx.authorize({ scope: 'scope.writePhotosAlbum', success() { //這里是用戶同意授權后的回調 $this.baocunImg(imageUrl); }, fail() { //這里是用戶拒絕授權后的回調 wx.showModal({ title: '提示', content: '若不打開授權,則無法將圖片保存在相冊中!', showCancel: true, cancelText: '暫不授權', confirmText: '去授權', success: function (res) { if (res.confirm) { wx.openSetting({ //調起客戶端小程序設置界面,返回用戶設置的操作結果。 }) } else { console.log('用戶點擊取消') } } }) } }) } else { //用戶已經授權過了 $this.baocunImg(imageUrl); } } }) }, baocunImg(imageUrl) { let src = imageUrl wx.getImageInfo({ src, success: function (ret) { console.log(ret); var path = ret.path; wx.saveImageToPhotosAlbum({ filePath: path, success: function (res) { wx.showToast({ title: '保存成功', }) wx.previewImage({ current: '', urls: [url] }) }, fail: function (res) { console.log(res) wx.showToast({ title: '保存失敗', icon: 'none' }) } }) } }); } ``` ## 分享 ``` onShareAppMessage: function (url, customtitle, imgSrc) { // app.matomo.trackEvent("點擊", '分享', url) console.log("點擊", '分享', url) console.log("點擊", '分享', customtitle) console.log("點擊", '分享', imgSrc) let userinfo_id = wx.getStorageSync('userinfo').id, title = '', desc = '', imageUrl = baseUrl + 'share-card.jpg'; if (customtitle) { title = customtitle }; if (imgSrc) { imageUrl = imgSrc } url = url || '/pages/index/index/index'; url = url.indexOf('?') != -1 ? url + '&' : url + '?'; return { title: title, desc: desc, path: url + 'mid=' + userinfo_id, imageUrl, } }, ``` ## 獲取手機號 ``` 獲取手機號之前獲取code onLoad:function(options){ let $this = this wx.login({ success: res => { console.log(res) $this.setData({ code: res.code }) } }) } ``` ``` // 獲取手機號 getphonenumber: function (e) { let $this = this; if (e.detail.errMsg !== "getPhoneNumber:ok") { return; } // 檢查登錄態是否過期 wx.checkSession({ success(res) { console.log(res) let data = { code: $this.data.code, iv: e.detail.iv, encryptedData: e.detail.encryptedData } $this.memberPhone(data) }, fail(err) { // session_key 已經失效,需要重新執行登錄流程 console.log(err) wx.login({ success: res => { $this.setData({ code: res.code }) // app.setCache("code", res.code) let data = { code: res.code, iv: e.detail.iv, encryptedData: e.detail.encryptedData } $this.memberPhone(data) } }) wx.showToast({ title: '獲取手機號失敗,請重試', icon: "none" }) } }) }, ``` ``` //獲取手機號接口 memberPhone(data) { let $this = this http('post', 'memberPhone', { ...data }, function (res) { if (res.code == 200) { let phone = res.result $this.setData({ phone }) wx.setStorageSync('phone', phone); wx.showToast({ title: '成功', }) } else { wx.showToast({ title: '獲取手機號失敗,請重試', icon: "none" }) } }) }, ``` ## 登錄授權 ``` //登錄授權 bindgetuserinfo(e) { return new Promise((resolve, reject) => { console.log("login") let $this = this; let channel = wx.getStorageSync('apppath') wx.login({ success: function (ret) { console.log(ret) if (ret.code) { wx.getUserInfo({ success(res2) { http('post', 'wxLogin', { code: ret.code, encryptedData: res2.encryptedData, iv: res2.iv, userInfos: JSON.stringify(res2.userInfo), signature: res2.signature, channel, }, function (login_res) { console.log(login_res) if (login_res.code == 200) { let data = login_res.result console.log(data) wx.setStorageSync('userinfo', data.userInfo); wx.setStorageSync('phone', data.userInfo.mobile); wx.setStorageSync('userName', data.userInfo.nickname); wx.setStorageSync('userId', data.userId); // 設置統計代碼的openid // console.log($this) // $this.matomo.setUserId(data.userInfo.openid) resolve(true); } else { wx.showToast({ title: '獲取用戶登錄態失敗:' + login_res.message, icon: "none" }) } }) } }) } }, fail: function (rett) { wx.showToast({ title: '獲取用戶登錄態失敗:' + rett, icon: "none" }) reject(false); } }) }) } ```
                  <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>

                              哎呀哎呀视频在线观看