Authored by shixiang

完成登录接口调试

review-叶弯弯
... ... @@ -44,4 +44,6 @@ SPEC CHECKSUMS:
React: 386bbe687faee56ab75bad6132813945d5857403
RNDeviceInfo: e3fe8d8fe52f74eab22b7d4784a4fdd2e9bf4a26
COCOAPODS: 0.39.0
PODFILE CHECKSUM: 204359fbddc735210f82703c7a0dbd08c58273a5
COCOAPODS: 1.0.0
... ...
... ... @@ -12,9 +12,9 @@
13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
2D6F93DC42758ED618A4ED3F /* libPods-YH_Vendor.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 2312FCCC9319C46CC691BBAA /* libPods-YH_Vendor.a */; };
875F164E1CCF71820051CA82 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 875F164D1CCF71820051CA82 /* libReact.a */; };
87D1E5321CEC1BC70050ADA3 /* libRNDeviceInfo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 87D1E5311CEC1BC70050ADA3 /* libRNDeviceInfo.a */; };
BDB44E315EC65A19AFDFE3D5 /* libPods-YH_Vendor.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A5497DA9F4E284B45CC00DB9 /* libPods-YH_Vendor.a */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
... ... @@ -39,11 +39,11 @@
13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = YH_Vendor/Images.xcassets; sourceTree = "<group>"; };
13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = YH_Vendor/Info.plist; sourceTree = "<group>"; };
13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = YH_Vendor/main.m; sourceTree = "<group>"; };
2312FCCC9319C46CC691BBAA /* libPods-YH_Vendor.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-YH_Vendor.a"; sourceTree = BUILT_PRODUCTS_DIR; };
32146CF42F1683ED997A873A /* Pods-YH_Vendor.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-YH_Vendor.release.xcconfig"; path = "Pods/Target Support Files/Pods-YH_Vendor/Pods-YH_Vendor.release.xcconfig"; sourceTree = "<group>"; };
875F164D1CCF71820051CA82 /* libReact.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libReact.a; path = "Pods/../build/Debug-iphoneos/libReact.a"; sourceTree = "<group>"; };
87D1E5311CEC1BC70050ADA3 /* libRNDeviceInfo.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libRNDeviceInfo.a; path = "Pods/../build/Debug-iphoneos/libRNDeviceInfo.a"; sourceTree = "<group>"; };
A5497DA9F4E284B45CC00DB9 /* libPods-YH_Vendor.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-YH_Vendor.a"; sourceTree = BUILT_PRODUCTS_DIR; };
B44EE6A85A06E0E02E6B1F23 /* Pods-YH_Vendor.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-YH_Vendor.release.xcconfig"; path = "Pods/Target Support Files/Pods-YH_Vendor/Pods-YH_Vendor.release.xcconfig"; sourceTree = "<group>"; };
E38B39E1C626434D633DF86C /* Pods-YH_Vendor.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-YH_Vendor.debug.xcconfig"; path = "Pods/Target Support Files/Pods-YH_Vendor/Pods-YH_Vendor.debug.xcconfig"; sourceTree = "<group>"; };
F573E9D3010460361AD8AE1C /* Pods-YH_Vendor.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-YH_Vendor.debug.xcconfig"; path = "Pods/Target Support Files/Pods-YH_Vendor/Pods-YH_Vendor.debug.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
... ... @@ -60,7 +60,7 @@
files = (
87D1E5321CEC1BC70050ADA3 /* libRNDeviceInfo.a in Frameworks */,
875F164E1CCF71820051CA82 /* libReact.a in Frameworks */,
BDB44E315EC65A19AFDFE3D5 /* libPods-YH_Vendor.a in Frameworks */,
2D6F93DC42758ED618A4ED3F /* libPods-YH_Vendor.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
... ... @@ -103,20 +103,11 @@
children = (
87D1E5311CEC1BC70050ADA3 /* libRNDeviceInfo.a */,
875F164D1CCF71820051CA82 /* libReact.a */,
A5497DA9F4E284B45CC00DB9 /* libPods-YH_Vendor.a */,
2312FCCC9319C46CC691BBAA /* libPods-YH_Vendor.a */,
);
name = Frameworks;
sourceTree = "<group>";
};
781FD8062D98B64732E2C79B /* Pods */ = {
isa = PBXGroup;
children = (
E38B39E1C626434D633DF86C /* Pods-YH_Vendor.debug.xcconfig */,
B44EE6A85A06E0E02E6B1F23 /* Pods-YH_Vendor.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
832341AE1AAA6A7D00B99B32 /* Libraries */ = {
isa = PBXGroup;
children = (
... ... @@ -131,8 +122,8 @@
832341AE1AAA6A7D00B99B32 /* Libraries */,
00E356EF1AD99517003FC87E /* YH_VendorTests */,
83CBBA001A601CBA00E9B192 /* Products */,
781FD8062D98B64732E2C79B /* Pods */,
4629C9058F02534B1365A58F /* Frameworks */,
9FC0A2904AC5F3ADEEEDB88C /* Pods */,
);
indentWidth = 2;
sourceTree = "<group>";
... ... @@ -147,6 +138,15 @@
name = Products;
sourceTree = "<group>";
};
9FC0A2904AC5F3ADEEEDB88C /* Pods */ = {
isa = PBXGroup;
children = (
F573E9D3010460361AD8AE1C /* Pods-YH_Vendor.debug.xcconfig */,
32146CF42F1683ED997A873A /* Pods-YH_Vendor.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
... ... @@ -172,13 +172,13 @@
isa = PBXNativeTarget;
buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "YH_Vendor" */;
buildPhases = (
B323DDDC1CCFDE05561C14D4 /* Check Pods Manifest.lock */,
001B27FDA35CD5717A740787 /* 📦 Check Pods Manifest.lock */,
13B07F871A680F5B00A75B9A /* Sources */,
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
1FDAA1517B73CCED81A0B7BF /* Embed Pods Frameworks */,
BF65CB909474B53921DEDF7E /* Copy Pods Resources */,
DCCB17D41CAF2C27BC937F1E /* 📦 Embed Pods Frameworks */,
406E3ABF16326E848AFE2A52 /* 📦 Copy Pods Resources */,
);
buildRules = (
);
... ... @@ -243,63 +243,63 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
001B27FDA35CD5717A740787 /* 📦 Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Bundle React Native code and images";
name = "📦 Check Pods Manifest.lock";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh";
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
showEnvVarsInLog = 0;
};
1FDAA1517B73CCED81A0B7BF /* Embed Pods Frameworks */ = {
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Embed Pods Frameworks";
name = "Bundle React Native code and images";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-YH_Vendor/Pods-YH_Vendor-frameworks.sh\"\n";
showEnvVarsInLog = 0;
shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh";
};
B323DDDC1CCFDE05561C14D4 /* Check Pods Manifest.lock */ = {
406E3ABF16326E848AFE2A52 /* 📦 Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Check Pods Manifest.lock";
name = "📦 Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-YH_Vendor/Pods-YH_Vendor-resources.sh\"\n";
showEnvVarsInLog = 0;
};
BF65CB909474B53921DEDF7E /* Copy Pods Resources */ = {
DCCB17D41CAF2C27BC937F1E /* 📦 Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Copy Pods Resources";
name = "📦 Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-YH_Vendor/Pods-YH_Vendor-resources.sh\"\n";
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-YH_Vendor/Pods-YH_Vendor-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
... ... @@ -386,7 +386,7 @@
};
13B07F941A680F5B00A75B9A /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = E38B39E1C626434D633DF86C /* Pods-YH_Vendor.debug.xcconfig */;
baseConfigurationReference = F573E9D3010460361AD8AE1C /* Pods-YH_Vendor.debug.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
... ... @@ -415,7 +415,7 @@
};
13B07F951A680F5B00A75B9A /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = B44EE6A85A06E0E02E6B1F23 /* Pods-YH_Vendor.release.xcconfig */;
baseConfigurationReference = 32146CF42F1683ED997A873A /* Pods-YH_Vendor.release.xcconfig */;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
... ...
... ... @@ -35,7 +35,7 @@ export default class Login extends Component {
<View style={styles.container}>
<View style={styles.accountContainer }>
<Text style={styles.text}>
账号:{this.props.username}
账号:{this.props.account}
</Text>
</View>
<View style={styles.line}/>
... ...
module.exports = {
dev: {
// baseUrl: 'http://testapi.yoho.cn:28077',
baseUrl: 'http://172.16.6.108:8080/gateway',
baseUrl: 'http://172.16.6.108:8080',
privateKey: 'a85bb0674e08986c6b115d5e3a4884fa',
httpTimeout: 30000, //毫秒
},
prd: {
baseUrl: 'http://service.yoho.cn',
baseUrl: 'http://172.16.6.108:8080',
privateKey: 'a85bb0674e08986c6b115d5e3a4884fa',
httpTimeout: 30000, //毫秒
... ...
... ... @@ -86,9 +86,9 @@ export default class LoginContainer extends Component {
onLoginPress() {
Alert.alert(
'登录',
this.props.user.profile.account+'+'+this.props.user.profile.pid,
this.props.user.profile.account+'+'+this.props.user.profile.password,
[
{text: 'OK', onPress: () => this.props.actions.login(this.props.user.profile.account,this.props.user.profile.pid)},
{text: 'OK', onPress: () => this.props.actions.login(this.props.user.profile.account,this.props.user.profile.password)},
]
);
... ... @@ -108,7 +108,7 @@ export default class LoginContainer extends Component {
onPwdChange={this.onPwdChange}
isFetching={this.props.user.isFetching}
account={this.props.user.profile.account}
pwd={this.props.user.profile.pid}
pwd={this.props.user.profile.password}
isDisplayPwd={this.props.user.isShowPwd}/>
);
... ...
... ... @@ -86,7 +86,7 @@ export default class LogoutContainer extends Component {
<Logout
account={this.props.user.profile.account}
username={this.props.user.profile.username}
pwd={this.props.user.profile.pid}
pwd={this.props.user.profile.password}
onLogoutPress={this.onLogoutPress}
onModifyPress={this.onModifyPress}
/>
... ...
... ... @@ -88,13 +88,23 @@ export default class ModifyPasswordContainer extends Component {
}
onModifySubmitPress(){
Alert.alert(
if(this.props.user.password.old===this.props.user.password.new){
Alert.alert(
'密码不相同',
this.props.user.profile.pid+'+'+this.props.user.password.old+'+'+this.props.user.password.new,
[
]
);
}else{
Alert.alert(
'修改密码',
this.props.user.password.old+'+'+this.props.user.password.new+'+'+this.props.user.password.repeat,
this.props.user.profile.pid+'+'+this.props.user.password.old+'+'+this.props.user.password.new,
[
{text: 'OK', onPress: () => this.props.actions.pwdModifySubmit()},
{text: 'OK', onPress: () => this.props.actions.pwdModifySubmit(this.props.user.profile.pid,this.props.user.password.old,this.props.user.password.new)},
]
);
}
}
render() {
... ...
... ... @@ -94,6 +94,7 @@ export function loginRequest() {
}
export function loginSuccess(json) {
console.log(json);
return {
type: LOGIN_SUCCESS,
payload: json
... ... @@ -171,8 +172,18 @@ export function pwdModifyRepeat(pwd) {
};
}
export function pwdModifySubmit() {
export function pwdModifySubmit(pid, oldPwd,newPwd) {
return dispatch => {
// dispatch(loginRequest());
return new UserService().login(pid,oldPwd,newPwd)
.then(function (json) {
dispatch(modifySubmitDone());
Actions.pop();
})
.catch((error) => {
console.error(error);
});
};
return {
type: PWD_MODIFY_SUBMIT
};
... ... @@ -185,10 +196,10 @@ export function login(account, password) {
return new UserService().login(account,password)
.then(function (json) {
console.log(json);
dispatch(loginSuccess(json));
Actions.Drawer();
return saveSessionToken(json)
.then(function () {
dispatch(loginSuccess(json));
Actions.Drawer();
});
})
.catch((error) => {
... ... @@ -200,6 +211,12 @@ export function login(account, password) {
}
export function modifySubmitDone() {
return {
type: PWD_MODIFY_SUBMIT
};
}
export function saveSessionToken(json) {
return new AppAuthToken().storeSessionToken(json);
}
... ...
... ... @@ -26,6 +26,7 @@ let InitialState = Record({
isShowPwd:false,
profile: new (Record({
account: '',
password:'',
pid: '',
username: '',
sessionKey: '',
... ...
... ... @@ -70,7 +70,7 @@ export default function userReducer(state = initialState, action) {
return nextState;
}
case PWD_CHANGE:{
let nextState = state.setIn(['profile', 'pid'], action.payload);
let nextState = state.setIn(['profile', 'password'], action.payload);
return nextState;
}
case PWD_MODIFY_OLD:{
... ... @@ -94,6 +94,7 @@ export default function userReducer(state = initialState, action) {
case LOGOUT_REQUEST:{
let nextState = state.setIn(['profile', 'pid'], '').setIn(['profile', 'account'], '')
.setIn(['profile', 'pid'], '')
.setIn(['profile', 'password'], '')
.setIn(['profile', 'sessionKey'], '');
return nextState;
}
... ... @@ -106,16 +107,16 @@ export default function userReducer(state = initialState, action) {
}
case LOGIN_SUCCESS: {
const {account, pid, sessionKey, shops} = action.payload;
console.log('==========6');
const {account, pid, session_key, shops} = action.payload;
console.log('==========7');
let ShopRecord = Record({ id: '', name: '' })
let shopsList = Immutable.fromJS(shops, function(key, value) {
return new ShopRecord(value);
});
let shopsList = Immutable.fromJS(shops);
let nextState = state.set('isFetching', false)
.set('error', null)
.setIn(['profile', 'account'], account)
.setIn(['profile', 'pid'], pid)
.setIn(['profile', 'sessionKey'], sessionKey)
.setIn(['profile', 'sessionKey'], session_key)
.set('shops', shopsList);
return nextState;
}
... ...
... ... @@ -9,18 +9,43 @@ export default class UserService {
}
async login(account, password) {
return this.api.post({
url: '/gateway?method=app.passport.signin',
return this.api.get({
url: '/gateway',
body: {
account: account,
password: password,
method:'app.shops.login',
debug:'XYZ',
}
})
.then(data => {
console.log(data);
return data;
})
.catch(error => {
console.error(error);
throw error;
});
}
async modifyPassword(pid, oldPwd,newPwd) {
return this.api.get({
url: '/gateway',
body: {
pid: pid,
oldPwd: oldPwd,
newPwd:newPwd,
method:'app.shops.changePwd',
debug:'XYZ',
}
})
.then(data => {
console.log(data);
return data;
})
.catch(error => {
console.error(error);
throw error;
});
}
}
... ...