bayi 1 year atrás
parent
commit
c42df96f64
3 changed files with 131 additions and 128 deletions
  1. 125 124
      app.js
  2. 2 3
      pages/invite/index.wxml
  3. 4 1
      pages/reading/index.js

+ 125 - 124
app.js

@@ -1,140 +1,141 @@
 // app.js
 import {
-  loginLog,
-  userLogin,
-  getMyInfo
+    loginLog,
+    userLogin,
+    getMyInfo
 } from '~/api/user'
 import {
-  createStoreBindings
+    createStoreBindings
 } from 'mobx-miniprogram-bindings'
 import {
-  store
+    store
 } from '~/store/index'
 let storeBindings
 App({
-  async onLaunch() {
-    this.updateApplet()
-    this.checkIsIos()
-    this.getNavbarInfo()
-    await loginLog()
-  },
-  async onShow(options) {
-    if (!this.storeBindings) {
-      this.storeBindings = createStoreBindings(this, {
-        store,
-        actions: ['setUser']
-      })
-    }
-    let shareUid = options.query.uid || ''
-    let uid = wx.getStorageSync('uid')
-    if (uid) {
-      let userInfo = await getMyInfo()
-      this.setUser(userInfo.user)
-      if (getApp().callBack) {
-        getApp().callBack();
-      }
-    } else {
-      this.login(shareUid)
-    }
-  },
-  login(shareUid) {
-    wx.login({
-      success: async (res) => {
-        if (res.code) {
-          // 获取openid
-          let data = {
-            code: res.code,
-            shareUid
-          }
-          let userRes = await userLogin(data)
-          this.setUser(userRes.data)
-          wx.setStorageSync('uid', userRes.data.uid)
-          wx.setStorageSync('user', userRes.data)
-          this.globalData.userInfo = userRes.data
-          if (getApp().callBack) {
-            getApp().callBack(userRes);
-          }
-        }
-      }
-    })
-  },
-  checkIsIos: function () {
-    wx.getSystemInfo({
-      success: (res) => {
-        // 设备显示区域的宽度,单位px
-        this.globalData.windowWidth = res.windowWidth
-        this.globalData.windowHeight = res.windowHeight
-        if (res.system.search('iOS') != -1) {
-          this.globalData.isIOS = true
-        }
-        let {
-          scene
-        } = wx.getLaunchOptionsSync()
-        // 1023	安卓系统桌面图标,1104微信聊天主界面下拉,「我的小程序」栏(基础库2.2.4-2.29.0版本废弃,2.29.1版本起生效) 
-        if (scene != 1023) {
-          let preTime = wx.getStorageSync('preDesktopTime')
-          let flag = !preTime ? true : (new Date() - preTime) / 43200000 > 1 ? true : false
-          if (flag || !preTime) {
-            this.globalData.desktopTips = true
-            wx.setStorage({
-              key: "preDesktopTime",
-              data: new Date()
+    async onLaunch() {
+        this.updateApplet()
+        this.checkIsIos()
+        this.getNavbarInfo()
+        await loginLog()
+    },
+    async onShow(options) {
+        if (!this.storeBindings) {
+            this.storeBindings = createStoreBindings(this, {
+                store,
+                actions: ['setUser']
             })
-          }
         }
-      }
-    })
-  },
-  getNavbarInfo() {
-    // 获取系统信息
-    const systemInfo = wx.getSystemInfoSync();
-    // 胶囊按钮位置信息
-    const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
-    // 导航栏高度 = 状态栏高度 + 44
-    this.globalData.navBarHeight = systemInfo.statusBarHeight + 44;
-    this.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right;
-    this.globalData.menuTop = menuButtonInfo.top;
-    this.globalData.menuHeight = menuButtonInfo.height;
-  },
-  updateApplet() {
-    // 获取小程序更新机制兼容
-    if (wx.canIUse('getUpdateManager')) {
-      const updateManager = wx.getUpdateManager()
-      updateManager.onCheckForUpdate(function (res) {
-        // 请求完新版本信息的回调
-        if (res.hasUpdate) {
-          updateManager.onUpdateReady(function () {
-            wx.showModal({
-              title: '更新提示',
-              content: '新版本已经准备好,是否重启应用?',
-              success: function (res) {
-                if (res.confirm) {
-                  // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
-                  updateManager.applyUpdate()
+        let shareUid = options.query.uid || ''
+        console.log(shareUid,'shareUid');
+        let uid = wx.getStorageSync('uid')
+        if (uid) {
+            let userInfo = await getMyInfo()
+            this.setUser(userInfo.user)
+            if (getApp().callBack) {
+                getApp().callBack();
+            }
+        } else {
+            this.login(shareUid)
+        }
+    },
+    login(shareUid) {
+        wx.login({
+            success: async (res) => {
+                if (res.code) {
+                    // 获取openid
+                    let data = {
+                        code: res.code,
+                        shareUid
+                    }
+                    let userRes = await userLogin(data)
+                    this.setUser(userRes.data)
+                    wx.setStorageSync('uid', userRes.data.uid)
+                    wx.setStorageSync('user', userRes.data)
+                    this.globalData.userInfo = userRes.data
+                    if (getApp().callBack) {
+                        getApp().callBack(userRes);
+                    }
+                }
+            }
+        })
+    },
+    checkIsIos: function () {
+        wx.getSystemInfo({
+            success: (res) => {
+                // 设备显示区域的宽度,单位px
+                this.globalData.windowWidth = res.windowWidth
+                this.globalData.windowHeight = res.windowHeight
+                if (res.system.search('iOS') != -1) {
+                    this.globalData.isIOS = true
+                }
+                let {
+                    scene
+                } = wx.getLaunchOptionsSync()
+                // 1023	安卓系统桌面图标,1104微信聊天主界面下拉,「我的小程序」栏(基础库2.2.4-2.29.0版本废弃,2.29.1版本起生效) 
+                if (scene != 1023) {
+                    let preTime = wx.getStorageSync('preDesktopTime')
+                    let flag = !preTime ? true : (new Date() - preTime) / 43200000 > 1 ? true : false
+                    if (flag || !preTime) {
+                        this.globalData.desktopTips = true
+                        wx.setStorage({
+                            key: "preDesktopTime",
+                            data: new Date()
+                        })
+                    }
+                }
+            }
+        })
+    },
+    getNavbarInfo() {
+        // 获取系统信息
+        const systemInfo = wx.getSystemInfoSync();
+        // 胶囊按钮位置信息
+        const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
+        // 导航栏高度 = 状态栏高度 + 44
+        this.globalData.navBarHeight = systemInfo.statusBarHeight + 44;
+        this.globalData.menuRight = systemInfo.screenWidth - menuButtonInfo.right;
+        this.globalData.menuTop = menuButtonInfo.top;
+        this.globalData.menuHeight = menuButtonInfo.height;
+    },
+    updateApplet() {
+        // 获取小程序更新机制兼容
+        if (wx.canIUse('getUpdateManager')) {
+            const updateManager = wx.getUpdateManager()
+            updateManager.onCheckForUpdate(function (res) {
+                // 请求完新版本信息的回调
+                if (res.hasUpdate) {
+                    updateManager.onUpdateReady(function () {
+                        wx.showModal({
+                            title: '更新提示',
+                            content: '新版本已经准备好,是否重启应用?',
+                            success: function (res) {
+                                if (res.confirm) {
+                                    // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+                                    updateManager.applyUpdate()
+                                }
+                            }
+                        })
+                    })
+                    updateManager.onUpdateFailed(function () {
+                        // 新的版本下载失败
+                        wx.showModal({
+                            title: '已经有新版本了哟~',
+                            content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
+                        })
+                    })
                 }
-              }
-            })
-          })
-          updateManager.onUpdateFailed(function () {
-            // 新的版本下载失败
-            wx.showModal({
-              title: '已经有新版本了哟~',
-              content: '新版本已经上线啦~,请您删除当前小程序,重新搜索打开哟~',
             })
-          })
         }
-      })
+    },
+    globalData: {
+        userInfo: null,
+        isIOS: false, // 判断设备是否为苹果
+        desktopTips: false,
+        navBarHeight: 0, // 导航栏高度
+        menuRight: 0, // 胶囊距右方间距(方保持左、右间距一致)
+        menuTop: 0, // 胶囊距底部间距(保持底部间距一致)
+        menuHeight: 0, // 胶囊高度(自定义内容可与胶囊高度保证一致)
+        windowWidth: 0,
+        windowHeight: 0
     }
-  },
-  globalData: {
-    userInfo: null,
-    isIOS: false, // 判断设备是否为苹果
-    desktopTips: false,
-    navBarHeight: 0, // 导航栏高度
-    menuRight: 0, // 胶囊距右方间距(方保持左、右间距一致)
-    menuTop: 0, // 胶囊距底部间距(保持底部间距一致)
-    menuHeight: 0, // 胶囊高度(自定义内容可与胶囊高度保证一致)
-    windowWidth: 0,
-    windowHeight: 0
-  }
 })

+ 2 - 3
pages/invite/index.wxml

@@ -205,13 +205,12 @@
             <view class="item" wx:for="{{list}}" wx:key="eid">
                 <view class="left">
                     <view class="num">{{index+1}}</view>
-                    <image src="{{item.avatar}}" class="avatar" data-uid="{{item.uid}}"
-                        bindtap="jumpUserInfo" />
+                    <image src="{{item.avatar}}" class="avatar" data-uid="{{item.uid}}" bindtap="jumpUserInfo" />
                     <view class="nickName textOver">{{item.nickName||item.eid}}</view>
                 </view>
                 <view class="time">{{filters.formatDate(item.gmtCreated,1)}}</view>
             </view>
-            <view class="copywriting">
+            <view class="copywriting" wx:if="{{list.length==0}}">
                 <view class="text">别的小伙伴已经拿到大奖啦!</view>
                 <view>快去邀请你的小伙伴为你助力!</view>
             </view>

+ 4 - 1
pages/reading/index.js

@@ -663,7 +663,7 @@ Page({
         } else {
             this.innerAudioContext.play();
         }
-        await userEvent({
+        userEvent({
             action: 'WXREADING',
             readId: this.data.videoInfo.userRead.id
         })
@@ -776,6 +776,9 @@ Page({
                 this.selectComponent('#vipModal').open({
                     type: detail.payType == 'LIFELONG' ? 'sip' : 'vip'
                 })
+                this.setData({
+                    isVip: true
+                })
                 setTimeout(() => {
                     this.getVipInfo()
                 }, 1500)