|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
|
|
|
|
|
'use strict';
|
|
|
|
|
var module = angular.module('shopify.auth', ['ui.router', 'ui.bootstrap']);
|
|
|
|
|
var module = angular.module('shopify.auth', ['ui.router', 'ui.bootstrap', 'ngMessages']);
|
|
|
|
|
module.config(['$stateProvider', function ($stateProvider) {
|
|
|
|
|
$stateProvider.state('shopify', {
|
|
|
|
|
url: '/shopify',
|
|
|
|
@ -21,45 +21,199 @@ define(['angular', 'uiRouter', 'uiBootstrap'], function (angular) {
|
|
|
|
|
});
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
|
|
module.controller('ShopifyRootController',['$scope','$http','$state',function ($scope, $http, $state) {
|
|
|
|
|
module.controller('ShopifyRootController', ['$scope', '$http', '$state', function ($scope, $http, $state) {
|
|
|
|
|
if ($state.is('shopify')) {
|
|
|
|
|
$state.go('shopify.auth')
|
|
|
|
|
}
|
|
|
|
|
}])
|
|
|
|
|
|
|
|
|
|
module.controller('ShopifyAuthController',['$scope','$http','$state', function ($scope, $http, $state) {
|
|
|
|
|
module.controller('ShopifyAuthController', ['$scope', '$http', '$state', function ($scope, $http, $state) {
|
|
|
|
|
var that = $scope;
|
|
|
|
|
that.store = {
|
|
|
|
|
loginId: ''
|
|
|
|
|
}
|
|
|
|
|
that.validStoreLoginId = function () {
|
|
|
|
|
$http.get("/shopify/store/exist",{params: that.store}).then(function (res) {
|
|
|
|
|
$http.get("/shopify/store/exist", {params: that.store}).then(function (res) {
|
|
|
|
|
if (res.data) {
|
|
|
|
|
$state.go('shopify.login', {userId: that.store.loginId});
|
|
|
|
|
}else {
|
|
|
|
|
} else {
|
|
|
|
|
$state.go('shopify.register', {userId: that.store.loginId});
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
|
|
module.controller('ShopifyLoginController',['$scope','$http','$state', function ($scope, $http, $state) {
|
|
|
|
|
var that = $scope;
|
|
|
|
|
module.controller('ShopifyLoginController', ['$scope', '$http', '$state', function ($scope, $http, $state) {
|
|
|
|
|
var that = $scope;
|
|
|
|
|
that.model = {
|
|
|
|
|
shop: '',
|
|
|
|
|
loginId: '',
|
|
|
|
|
password: ''
|
|
|
|
|
}
|
|
|
|
|
that.activeShopifyMerchant = function () {
|
|
|
|
|
$http.post("/shopify/auth/permission",that.model).then(function (res) {
|
|
|
|
|
console.log("permissionUrl",res.data.url)
|
|
|
|
|
$http.post("/shopify/auth/permission", that.model).then(function (res) {
|
|
|
|
|
console.log("permissionUrl", res.data.url)
|
|
|
|
|
location.href = res.data.url
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
|
|
module.controller('ShopifyRegisterController',['$scope','$http','$state', function ($scope, $http, $state) {
|
|
|
|
|
module.controller('ShopifyRegisterController', ['$scope', '$http', '$state', function ($scope, $http, $state) {
|
|
|
|
|
var stateMap = [
|
|
|
|
|
{
|
|
|
|
|
"label": "ACT",
|
|
|
|
|
"value": "ACT"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "NSW",
|
|
|
|
|
"value": "NSW"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "NT",
|
|
|
|
|
"value": "NT"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "QLD",
|
|
|
|
|
"value": "QLD"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "SA",
|
|
|
|
|
"value": "SA"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "TAS",
|
|
|
|
|
"value": "TAS"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "VIC",
|
|
|
|
|
"value": "VIC"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "WA",
|
|
|
|
|
"value": "WA"
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
var industryMap = [
|
|
|
|
|
{
|
|
|
|
|
"label": "Shoes&Garments",
|
|
|
|
|
"value": "343"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Comprehensive mall",
|
|
|
|
|
"value": "484"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Food",
|
|
|
|
|
"value": "485"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Cosmetics",
|
|
|
|
|
"value": "486"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Maternal and infant",
|
|
|
|
|
"value": "487"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Digital appliance",
|
|
|
|
|
"value": "488"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Logistics",
|
|
|
|
|
"value": "489"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Education Industry",
|
|
|
|
|
"value": "490"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Hotel Industry",
|
|
|
|
|
"value": "491"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Stationery/office supplies",
|
|
|
|
|
"value": "492"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Air Ticket",
|
|
|
|
|
"value": "493"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Other trade industry",
|
|
|
|
|
"value": "494"
|
|
|
|
|
}, {
|
|
|
|
|
"label": "Overseas Education",
|
|
|
|
|
"value": "528"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Travel ticket",
|
|
|
|
|
"value": "529"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Car rental",
|
|
|
|
|
"value": "530"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "International Conference",
|
|
|
|
|
"value": "531"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Software",
|
|
|
|
|
"value": "532"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"label": "Medical Service",
|
|
|
|
|
"value": "533"
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
$scope.states = angular.copy(stateMap);
|
|
|
|
|
$scope.industries = angular.copy(industryMap);
|
|
|
|
|
$scope.partner = {};
|
|
|
|
|
$scope.saveForm = function (form) {
|
|
|
|
|
if (form.$invalid) {
|
|
|
|
|
angular.forEach(form, function (item, key) {
|
|
|
|
|
if (key.indexOf('$') < 0) {
|
|
|
|
|
item.$dirty = true;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if ($scope.partner.password != $scope.partner.password_again) {
|
|
|
|
|
$scope.resError = 'Inconsistent passwords';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
$('#login-btn').attr('disabled', true);
|
|
|
|
|
|
|
|
|
|
const paymentMerchant = {
|
|
|
|
|
companyName: $scope.partner.companyName,
|
|
|
|
|
address: $scope.partner.address,
|
|
|
|
|
suburb: $scope.partner.suburb,
|
|
|
|
|
postcode: $scope.partner.postcode,
|
|
|
|
|
state: $scope.partner.state,
|
|
|
|
|
country: $scope.partner.country,
|
|
|
|
|
contactPerson: $scope.partner.contactPerson,
|
|
|
|
|
contactPhone: $scope.partner.contactPhone,
|
|
|
|
|
contactEmail: $scope.partner.contactEmail
|
|
|
|
|
}
|
|
|
|
|
const PaymentAccountCommand = {
|
|
|
|
|
loginId: $scope.partner.loginId,
|
|
|
|
|
password: $scope.partner.password
|
|
|
|
|
}
|
|
|
|
|
const param = {
|
|
|
|
|
paymentMerchant,
|
|
|
|
|
PaymentAccountCommand,
|
|
|
|
|
shopifyShop: $scope.partner.shopifyShop
|
|
|
|
|
}
|
|
|
|
|
console.log("参数:", param)
|
|
|
|
|
$http.post('shopify/store/register', param).then(function (resp) {
|
|
|
|
|
// alert("Registered merchant application has been submitted successfully");
|
|
|
|
|
// location.href = 'partner_register_success.html';
|
|
|
|
|
}, function (resp) {
|
|
|
|
|
alert(resp.data.message);
|
|
|
|
|
$scope.resError = resp.data.message;
|
|
|
|
|
$('#login-btn').attr('disabled', false);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
}]);
|
|
|
|
|
|
|
|
|
|
return module;
|
|
|
|
|