Browse Source

当用户是点击别人的分享链接进来时,如果没有登录,强制跳转至登录页

fenggang 5 years ago
parent
commit
4326e13e41

+ 2 - 1
app.json

@@ -9,7 +9,8 @@
     "pages/mine/msg/msg",
     "pages/mine/question/question",
     "pages/allParticipant/allParticipant",
-    "pages/share-poster/share-poster"
+    "pages/share-poster/share-poster",
+    "pages/article/article"
   ],
   "tabBar": {
     "selectedColor": "#2d8cf0",

+ 66 - 0
pages/article/article.js

@@ -0,0 +1,66 @@
+// pages/article.js
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad: function (options) {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide: function () {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload: function () {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh: function () {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom: function () {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 3 - 0
pages/article/article.json

@@ -0,0 +1,3 @@
+{
+  "usingComponents": {}
+}

+ 2 - 0
pages/article/article.wxml

@@ -0,0 +1,2 @@
+<!--pages/article.wxml-->
+<web-view src="https://mp.weixin.qq.com/s/WmWV6TlPKsX-BB98nRwldA" bindmessage=""></web-view>

+ 1 - 0
pages/article/article.wxss

@@ -0,0 +1 @@
+/* pages/article.wxss */

+ 7 - 1
pages/award-detail/award-detail.js

@@ -85,7 +85,7 @@ Page({
     return {
       title: '抽奖:' + title + ' X ' + winner_count,
       imageUrl: cover_images[0],
-      path: '/pages/award-detail/award-detail?id=' + id + '&from=share&friendID=' + wx.getStorageSync('USER_INFO').user.id
+      path: '/pages/award-detail/award-detail?id=' + id + '&from=share&friendID=' + wx.getStorageSync('USER_INFO') ? wx.getStorageSync('USER_INFO').user.id : null
     }
   },
 	onLoad(query) {
@@ -93,6 +93,9 @@ Page({
     const { id } = query
     // 当用户是从分享页面进入时调用邀请接口
     if(query.from && query.from === 'share' && query.friendID) {
+      if(!USER_INFO) {
+        wx.navigateTo({url: '/pages/login/login'})
+      }
       if(query.friendID !== USER_INFO.user.id) {
         invite(id, query.friendID)
         .then(data => {
@@ -183,5 +186,8 @@ Page({
         }
       }
     })
+  },
+  test(){
+    wx.navigateTo({url: '/pages/article/article'})
   }
 })

+ 1 - 0
pages/award-detail/award-detail.wxml

@@ -1,5 +1,6 @@
 <import src="../../lib/wxParse/wxParse.wxml"></import>
 <view class="award-detail">
+<button type="default" bindtap="test">测试公众号页面</button>
   <view class="banner-wrapper">
     <swiper class="swiper" current="{{swiperIndex}}">
       <block wx:for="{{cover_images}}" wx:key="{{item}}">