소스 검색

更新 体验/登录 跳转逻辑

wangzhihui 4 년 전
부모
커밋
d0b9b05692
2개의 변경된 파일9개의 추가작업 그리고 19개의 파일을 삭제
  1. 8 18
      miniprogram/pages/index/index.js
  2. 1 1
      miniprogram/pages/index/index.wxml

+ 8 - 18
miniprogram/pages/index/index.js

@@ -12,26 +12,12 @@ Page({
    * 页面的初始数据
    */
   data: {
-
+    loginStatus: false
   },
-  go() {
-    if (wx.getStorageSync('userId')) {
-      wx.navigateTo({
-        url: '/pages/takePhoto/takePhoto',
-      })
-    } else {
-      this.getOpenid()
-    }
-  },
-  async getOpenid() {
 
-    let res = await cloudApi("getOpenId")
-    let {
-      openId
-    } = res.result
-    wx.setStorageSync('openId', openId)
+  async login() {
     let res1 = await postApi("/user/wx/login", {
-      openId
+      openId: wx.getStorageSync('openId')
     })
 
     if (res1.data.status == 0) {
@@ -63,7 +49,11 @@ Page({
 
   },
   onLoad: function (options) {
-    this.getOpenid()
+    if (wx.getStorageSync('userId') && wx.getStorageSync('shipName')) {
+      this.setData({
+        loginStatus: true
+      })
+    }
   },
 
   /**

+ 1 - 1
miniprogram/pages/index/index.wxml

@@ -1,2 +1,2 @@
 <image class="main" mode="aspectFit" src="../../images/index.png"></image>
-<view bindtap="go" class="go">去体验</view>
+<view bindtap="login" class="go">{{loginStatus?'去拍照':'去体验'}}</view>