Forráskód Böngészése

始宁农业小程序:个人中心未登录判断

panyong 2 éve
szülő
commit
c604250aec

+ 22 - 0
htmldev/shiningWxMini/pages/mine/mine.js

@@ -185,6 +185,13 @@ Page({
   jump(e) {
     const { page } = e.currentTarget.dataset
 
+    if (!this.data.sessionId) {
+      wx.navigateTo({
+        url: `/pages/login/login`
+      })
+      return
+    }
+
     wx.navigateTo({
       url: `/pages/${page}/${page}`
     })
@@ -234,6 +241,13 @@ Page({
     const { page } = e.currentTarget.dataset
     const that = this
 
+    if (!this.data.sessionId) {
+      wx.navigateTo({
+        url: `/pages/login/login`
+      })
+      return
+    }
+
     try {
       const { errMsg, subscriptionsSetting } = await wx.getSetting({ withSubscriptions: true })
       if (errMsg === 'getSetting:ok') {
@@ -294,5 +308,13 @@ Page({
         }
       }
     })
+  },
+  handleFormItemClick(e) {
+    const { formkey } = e.currentTarget.dataset
+    if ((formkey === 'user_head_img_url' || formkey === 'user_nickname') && !this.data.sessionId) {
+      wx.navigateTo({
+        url: `/pages/login/login`
+      })
+    }
   }
 })

+ 7 - 4
htmldev/shiningWxMini/pages/mine/mine.wxml

@@ -10,11 +10,11 @@
         preview-size="169rpx"
         data-formkey="user_head_img_url"
         preview-full-image="{{false}}"
-        use-before-read="{{true}}"
-        bind:before-read="beforeRead"
+        disabled="{{!sessionId}}"
         bind:click-preview="uploadImg"
         bind:after-read="afterRead"
-        bind:delete="delete"/>
+        bind:delete="delete"
+        bind:tap="handleFormItemClick"/>
     </view>
   </view>
   <view class="nickname-wrap">
@@ -35,7 +35,10 @@
              focus="{{isAutoFocus}}"
              placeholder="请输入昵称"
              cursor-spacing="{{52}}"
-             placeholder-class="app_header-search-placeholder"/>
+             data-formkey="user_nickname"
+             disabled="{{!sessionId}}"
+             placeholder-class="app_header-search-placeholder"
+             bind:tap="handleFormItemClick"/>
     </block>
   </view>
   <view