I am developing an ionic woocommerce app and in it i am stuck on the registration page, in that when i entered the email id of new user then it doesn't show me any result in the console so i am stuck on that please help me!
This is the TS file::
import { Component } from '@angular/core';
import { NavController, NavParams, ToastController, AlertController } from 'ionic-angular';
import * as WC from 'woocommerce-api';
import { WoocommerceProvider } from '../../providers/woocommerce/woocommerce';
@Component({
selector: 'page-signup',
templateUrl: 'signup.html',
})
export class Signup {
newUser: any = {};
billing_shipping_same: boolean;
WooCommerce: any;
constructor(public navCtrl: NavController, public navParams: NavParams, public toastCtrl: ToastController, public alertCtrl: AlertController, private WP: WoocommerceProvider) {
this.newUser.billing_address = {};
this.newUser.shipping_address = {};
this.billing_shipping_same = false;
//this.newUser.billing_address.country = "India"
this.WooCommerce= WC({
url: "http://localhost/wordpress/",
consumerKey: "ck_3f8a38689e783d77ec1714a56c48bef8ed56420b",
consumerSecret: "cs_6ff20eecd59bf333fa60b572413575c85182558b",
wpAPI: true, // Enable the WP REST API integration
queryStringAuth: true,
verifySsl: true,
version: 'wc/v3'
});
}
ionViewDidLoad() {
console.log('ionViewDidLoad Signup');
}
setBillingToShipping(){
this.billing_shipping_same = !this.billing_shipping_same;
}
checkEmail(){
let validEmail = false;
let reg = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if(reg.test(this.newUser.email)){
//email looks valid
this.WooCommerce.getAsync("customers?email="+ this.newUser.email).then( (data) => {
console.log(data);
}
)}
}
signup(){
let customerData = {
customer : {}
}
customerData.customer = {
"email": this.newUser.email,
"first_name": this.newUser.first_name,
"last_name": this.newUser.last_name,
"username": this.newUser.username,
"password": this.newUser.password,
"billing_address": {
"first_name": this.newUser.first_name,
"last_name": this.newUser.last_name,
"company": "",
"address_1": this.newUser.billing_address.address_1,
"address_2": this.newUser.billing_address.address_2,
"city": this.newUser.billing_address.city,
"state": this.newUser.billing_address.state,
"postcode": this.newUser.billing_address.postcode,
"country": this.newUser.billing_address.country,
"email": this.newUser.email,
"phone": this.newUser.billing_address.phone
},
"shipping_address": {
"first_name": this.newUser.first_name,
"last_name": this.newUser.last_name,
"company": "",
"address_1": this.newUser.shipping_address.address_1,
"address_2": this.newUser.shipping_address.address_2,
"city": this.newUser.shipping_address.city,
"state": this.newUser.shipping_address.state,
"postcode": this.newUser.shipping_address.postcode,
"country": this.newUser.shipping_address.country
}
}
if(this.billing_shipping_same){
this.newUser.shipping_address = this.newUser.shipping_address;
}
this.WooCommerce.postAsync('customers', customerData).then( (data) => {
let response = (JSON.parse(data.body));
if(response.customer){
this.alertCtrl.create({
title: "Account Created",
message: "Your account has been created successfully! Please login to proceed.",
buttons: [{
text: "Login",
handler: ()=> {
//TODO
}
}]
}).present();
} else if(response.errors){
this.toastCtrl.create({
message: response.errors[0].message,
showCloseButton: true
}).present();
}
})
}
}
And this is the HTML file::
<ion-header>
<ion-navbar>
<ion-title>Customer Sign Up</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<ion-list>
<ion-item-divider color="danger">Personal Details</ion-item-divider>
<ion-item>
<ion-label>First Name</ion-label>
<ion-input type="text" [(ngModel)]="newUser.first_name"></ion-input>
</ion-item>
<ion-item>
<ion-label>Last Name</ion-label>
<ion-input type="text" [(ngModel)]="newUser.last_name"></ion-input>
</ion-item>
<ion-item>
<ion-label>Email</ion-label>
<ion-input type="email" [(ngModel)]="newUser.email" (blur)="checkEmail()"></ion-input>
</ion-item>
<ion-item>
<ion-label>Username</ion-label>
<ion-input type="text" [(ngModel)]="newUser.username"></ion-input>
</ion-item>
<ion-item>
<ion-label>Password</ion-label>
<ion-input type="password" [(ngModel)]="newUser.password"></ion-input>
</ion-item>
<ion-item>
<ion-label>Confirm Password</ion-label>
<ion-input type="text" [(ngModel)]="newUser.confirm_password"></ion-input>
</ion-item>
<ion-item-divider color="danger">Billing Details</ion-item-divider>
<ion-item>
<ion-label>Address Line 1</ion-label>
<ion-textarea type="text" maxlength="80" [(ngModel)]="newUser.billing_address.address_1"></ion-textarea>
</ion-item>
<ion-item>
<ion-label>Address Line 2</ion-label>
<ion-textarea type="text" maxlength="80" [(ngModel)]="newUser.billing_address.address_2"></ion-textarea>
</ion-item>
<ion-item>
<ion-label>Country</ion-label>
<ion-select [(ngModel)]="newUser.billing_address.country">
<ion-option value="India" selected="true">India</ion-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label>State</ion-label>
<ion-select [(ngModel)]="newUser.billing_address.state">
<ion-option value="New Delhi" selected="true">New Delhi</ion-option>
<ion-option value="Uttar Pradesh">Uttar Pradesh</ion-option>
<ion-option value="Maharashtra">Maharashtra</ion-option>
<ion-option value="Tamil Nadu">Tamil Nadu</ion-option>
<ion-option value="Madhya Pradesh">Madhya Pradesh</ion-option>
</ion-select>
</ion-item>
<ion-item>
<ion-label>City</ion-label>
<ion-input type="text" [(ngModel)]="newUser.billing_address.city"></ion-input>
</ion-item>
<ion-item>
<ion-label>Postal Code</ion-label>
<ion-input type="number" clearInput [(ngModel)]="newUser.billing_address.postcode"></ion-input>
</ion-item>
<ion-item>
<ion-label>Phone</ion-label>
<ion-input type="tel" clearInput [(ngModel)]="newUser.billing_address.phone"></ion-input>
</ion-item>
<ion-item>
<ion-label>Same Shipping Details</ion-label>
<ion-checkbox (ionChange)="setBillingToShipping()"></ion-checkbox>
</ion-item>
<ion-item-divider color="danger" *ngIf="!billing_shipping_same">Shipping Details</ion-item-divider>
<ion-item *ngIf="!billing_shipping_same">
<ion-label>Address Line 1</ion-label>
<ion-textarea type="text" maxlength="80" [(ngModel)]="newUser.shipping_address.address_1"></ion-textarea>
</ion-item>
<ion-item *ngIf="!billing_shipping_same">
<ion-label>Address Line 2</ion-label>
<ion-textarea type="text" maxlength="80" [(ngModel)]="newUser.shipping_address.address_2"></ion-textarea>
</ion-item>
<ion-item *ngIf="!billing_shipping_same">
<ion-label>Country</ion-label>
<ion-select [(ngModel)]="newUser.shipping_address.country">
<ion-option value="India" selected="true">India</ion-option>
</ion-select>
</ion-item>
<ion-item *ngIf="!billing_shipping_same">
<ion-label>State</ion-label>
<ion-select [(ngModel)]="newUser.shipping_address.state">
<ion-option value="New Delhi" selected="true">New Delhi</ion-option>
<ion-option value="Uttar Pradesh">Uttar Pradesh</ion-option>
<ion-option value="Maharashtra">Maharashtra</ion-option>
<ion-option value="Tamil Nadu">Tamil Nadu</ion-option>
<ion-option value="Madhya Pradesh">Madhya Pradesh</ion-option>
</ion-select>
</ion-item>
<ion-item *ngIf="!billing_shipping_same">
<ion-label>City</ion-label>
<ion-input type="text" [(ngModel)]="newUser.shipping_address.city"></ion-input>
</ion-item>
<ion-item *ngIf="!billing_shipping_same">
<ion-label>Postal Code</ion-label>
<ion-input type="number" clearInput [(ngModel)]="newUser.shipping_address.postcode"></ion-input>
</ion-item>
<ion-item *ngIf="!billing_shipping_same">
<ion-label>Phone</ion-label>
<ion-input type="tel" clearInput [(ngModel)]="newUser.shipping_address.phone"></ion-input>
</ion-item>
</ion-list>
</ion-content>
<ion-footer>
<button ion-button block color="danger" (click)="signup()">Sign Up</button>
</ion-footer>
so in this i am not able to get result of any user::
时Vue项目找不到图像