Code snippets: https://developers.weixin.qq.com/s/GCBSbsmH7jkw
Problem a: it is necessary to write the conditions for rendering code in the component?
? Question 2: how to get in the custom components example App attribute
Question 3: why didn't the console, interrupt point is useless??
Lifetimes: {
Attached: the function () {
Conlose. Log (" test ")
},
},
WXML
& lt; Block wx: if="{{isrenzheng===0}}" & gt;{{textContent}} & lt;/view>
- & gt;Please login for face recognition & lt;/text>
Js
//components/verify/verify the js
Var serv=the require ("../../libs/call - service. Js');
Const app=getApp ();
Component ({
Options: {
MultipleSlots: true
},
/* *
* component list of attributes for the
*/
Properties: {
//isrenzheng: {type: String, value: ""}
},
/* *
* the component of the initial data
*/
Data: {
Isrenzheng: app. GlobalData. IsCert,
IconString: ", "
DialogShow: true,
TextContent: "this operation requires you to log in to verify,"
Buttons: [{text: 'cancelled'}, {text: 'sure'}],
Disabled: false
},
/* *
* components list
*/
Methods: {
FormSubmit (e) {
The console. The log (e)
The console. The log (" whether the user's face recognition by "+ app. GlobalData. IsCert)
Var _this=this
Var username=e.d etail. Value. The username
Var useridcard=e.d etail. Value. Useridcard
If (username=='| | useridcard==' ') {
Wx. ShowToast ({
Title: 'please enter the information,
Icon: "none"
})
Return
} else {
The console. The log (" jump to face knowledge page ")
Var param={
IdCard: useridcard,
Name: the username,
OpenId: app. GlobalData. OpenerId,
IsCert: 1
}
Var _this=this
Serv. Get (' byWxIntf/getBizToken. Do 'param, function (res) {
//the console. The log (" getBizToken ");
console.log(res.data);
var result=res.data;
//the console. The log (" result: "+ result);
The console. The log (" url: "+ result. Url);
The console. The log (" BizToken: "+ result. BizToken);
If (true) {
Let BizToken=result. BizToken;
//call the real-name nuclear body function
Wx. StartVerify ({
Data: {
Token: BizToken//BizToken
},
Success: (res)=& gt; {//trigger
after a successful verification//res contains authentication token of success, it needs to add 500 ms delay, prevent iOS does not perform under the logic behind the
SetTimeout ()=& gt; {
After the success of the//verification, get a token after the logical processing of concrete will be subject to customer own logic
The console. The info (" -- -- -- -- -- -- -- -- -- -- yes -- -- -- -- -- -- -- -- -- -- - success! - ")
Wx. ShowModal ({
Title: "prompt",
Content: "congratulations to verify success!" ,
ShowCancel: false,
Success (res) {
If (res. Confirm) {
The console. The log (' user click ok ')
//_this. TriggerEvent (" formSubmit, "{1} isrenzheng:)
_this. SetData ({
Isrenzheng: 1
})
}
}
})
Serv. Get (' byWxIntf/updateWxUserIdent. Do 'param, function (res) {
The console. The log (" updateWxUserIdent: "+ res. Data);
})
App. GlobalData. IsCert=1;
}, 500);
},
Fail: (err)=& gt; {//verification failure triggered when
//err contains the error code and error messages, pop-up prompts error
SetTimeout ()=& gt; {
Wx. ShowModal ({
Title: "prompt",
Content: err... ErrorMsg,
ShowCancel: false
})
}, 500);
}
});
}
});
}
},
_tapDialogButton: function (e) {
//the console log (e)
Var index=e.d etail. Index
If (index==0) {
Wx. NavigateBack ({//return
Delta: 1
})
}
Enclosing setData ({
DialogShow: false
})
},
}
})