为何实现不了以下功能?
发布于 5 年前 作者 yinxiulan 9441 次浏览 来自 问答

功能是:在加载这个页面的时候,当你已经认证过了,此处会变为

已认证。

相关功能代码:

wxml

<view class="subtitleid="shenfenbindtap="wrtusermsg">
        {{renzheng}}
            <!-- {{certificationOk == 2?"已认证":"未认证"}} -->
        </view>

n那个三元表达式我不清楚为何用不了,所以换了个变量。

js
data: {
        userInfo: null,
        certificationOk: null,
        avatarUrl: '',
    userInfo: {},
    logged: false,
    takeSession: false,
    requestResult: '',
    username:'',
    renzheng:"未认证"
    },
onload:function(options){
usermsg.where({
            upload:"1",
                    }).get({
                      success:function(res){
                        console.log(res);
                        this.setData({
                            renzheng:"已认证",
                            
                        })
                        console.log(certificationOk);
                      }
                    })//此处是用上传参数时的所附带的upload字段来判断是否已经认证(上传过数据了)
}
d但在此处数据库查询成功后该页面却仍然显示

2 回复
确定 this能找到嘛?certificationOk是否有赋值为2,工具栏是否有报错,能否贴下代码片段
onload:(options){
  usermsg.where({
    upload:"1",
  }).get({
     success:function(res){
         console.log(res);
            this.setData({
              renzheng:"已认证",
            })
             console.log(certificationOk);
      }
  })//此处是用上传参数时的所附带的upload字段来判断是否已经认证(上传过数据了)
}
var app = getApp()
const db = wx.cloud.database();
const usermsg = db.collection('usermsg');
Page({
    data: {
        userInfonull,
        certificationOknull,
        avatarUrl'',
    userInfo: {},
    loggedfalse,
    takeSessionfalse,
    requestResult'',
    username:'',
    renzheng:"未认证"
    },

    onPullDownRefresh :function(){
        utils.getUserData();
        wx.stopPullDownRefresh()
    },
    
    onLoadfunction (options{
        var that = this;
        wx.getSetting({
            successres => {
              if (res.authSetting['scope.userInfo']) {
                // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
                console.log("已经授权");
                wx.getUserInfo({
                  successres => {
                    console.log(res);
                    this.setData({
                      avatarUrl: res.userInfo.avatarUrl,
                      userInfo: res.userInfo,
                      username:res.userInfo.nickName
                    })
                  }
                })
              }else{
                  console.log("未授权");
              }
            }
          })
          usermsg.where({
            upload:"1",
                    }).get({
                      success:function(res){
                        console.log(res);
                        this.setData({
                            renzheng:"已认证".data,
                            
                        })
                        console.log(certificationOk);
                      }
                    })
        
    },
b不清楚是否能找到,能找到应该也不至于赋值不上了,那个certification虽然没有赋值为2,但可以先不管,因为我用的是{{renzheng}}变量,相关代码已贴出
回到顶部