Permalink
Browse files

修改UI

  • Loading branch information...
vhbvb committed Aug 22, 2017
1 parent 226191b commit 9a25f8922367bbade541b79617925d9f50c7b29a
View
@@ -75,6 +75,9 @@ bool AppDelegate::applicationDidFinishLaunching()
// run
director->runWithScene(scene);
glClearColor(1.0, 1.0, 1.0, 1.0);
return true;
}
View
@@ -27,53 +27,77 @@ bool HelloWorld::init()
Size winSize = Director::getInstance()->getWinSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
CCSize size = CCDirector::sharedDirector()->getWinSize();
Scale9Sprite *box9SprY = Scale9Sprite::create("Icon@2x.png");
EditBox *box = EditBox::create(CCSizeMake(winSize.width/2, 25), box9SprY);
box->setPosition(ccp(winSize.width/2 + 80 , 300));
box->setDelegate(this);
box->setFontColor(ccc3(0, 0, 9));
box->setPlaceHolder("请输入手机号");
box->setPlaceholderFont("Arial", 8);
box->setFont("Arial", 8);
box->setMaxLength(20);
this->addChild(box);
phoneBox = box;
Scale9Sprite *zone9SprY = Scale9Sprite::create("Icon@2x.png");
EditBox *zBox = EditBox::create(CCSizeMake(winSize.width/2, 25), zone9SprY);
zBox->setPosition(ccp(winSize.width/2 + 80 , 280));
zBox->setDelegate(this);
zBox->setFontColor(ccc3(0, 0, 9));
zBox->setPlaceHolder("请输入区号");
zBox->setPlaceholderFont("Arial", 8);
zBox->setFont("Arial", 8);
zBox->setMaxLength(5);
this->addChild(zBox);
zoneBox = zBox;
Scale9Sprite *code9SprY = Scale9Sprite::create("Icon@2x.png");
EditBox *vBox = EditBox::create(CCSizeMake(winSize.width/2, 25), code9SprY);
vBox->setPosition(ccp(winSize.width/2 + 80 , 260));
vBox->setDelegate(this);
vBox->setFontColor(ccc3(0, 0, 9));
vBox->setPlaceHolder("请输入验证码");
vBox->setPlaceholderFont("Arial", 8);
vBox->setMaxLength(6);
vBox->setFont("Arial", 8);
this->addChild(vBox);
codeBox = vBox;
//获取文本验证码
MenuItemLabel *getCodeItem = MenuItemLabel::create(LabelTTF::create("Get Text Code", "Arial", 10),
CC_CALLBACK_1(HelloWorld::getTextCodeHandler, this));
getCodeItem->setPosition(winSize.width/2 , 275);
getCodeItem->setPosition(winSize.width/2 , 240);
getCodeItem->setColor(ccc3(8, 0, 190));
auto getCodeMenu = Menu::create(getCodeItem,NULL);
getCodeMenu->setPosition(Vec2::ZERO);
this->addChild(getCodeMenu);
//获取语音验证码
MenuItemLabel *getVoiceCode = MenuItemLabel::create(LabelTTF::create("Get Voice Code", "Arial", 10),
CC_CALLBACK_1(HelloWorld::getVoiceCodeHandler, this));
getVoiceCode->setPosition(winSize.width/2 , 250);
getVoiceCode->setPosition(winSize.width/2 , 220);
getVoiceCode->setColor(ccc3(8, 0, 190));
auto getVoiceCodeMenu = Menu::create(getVoiceCode,NULL);
getVoiceCodeMenu->setPosition(Vec2::ZERO);
this->addChild(getVoiceCodeMenu);
// //提交验证码
// MenuItemLabel *commitCodeItem = MenuItemLabel::create(LabelTTF::create("Commit Code", "Arial", 10),
// CC_CALLBACK_1(HelloWorld::commitCodeHandler, this));
// commitCodeItem->setPosition(winSize.width/2 , 300);
// auto commitCodeMenu = Menu::create(commitCodeItem,NULL);
// commitCodeMenu->setPosition(Vec2::ZERO);
// this->addChild(commitCodeMenu);
//提交验证码,输入完毕后敲回车键
CCSize size = CCDirector::sharedDirector()->getWinSize();
Scale9Sprite* sacel9SprY = Scale9Sprite::create("Icon@2x.png");
EditBox* box = EditBox::create(CCSizeMake(winSize.width/2, 25), sacel9SprY);
//设置位置
box->setPosition(ccp(winSize.width/2 + 75 , 225));
box->setDelegate(this);
//设置文本的颜色
box->setFontColor(ccc3(255, 0, 0));
//当编辑框中没有任何字符的提示
box->setPlaceHolder("请在此处输入验证码");
box->setPlaceholderFont("Arial", 10);
//最大输入文本长度
box->setMaxLength(4);
this->addChild(box);
//提交验证码
MenuItemLabel *commitCodeItem = MenuItemLabel::create(LabelTTF::create("Commit Code", "Arial", 10),
CC_CALLBACK_1(HelloWorld::commitCodeHandler, this));
commitCodeItem->setPosition(winSize.width/2 , 200);
commitCodeItem->setColor(ccc3(8, 0, 190));
auto commitCodeMenu = Menu::create(commitCodeItem,NULL);
commitCodeMenu->setPosition(Vec2::ZERO);
this->addChild(commitCodeMenu);
//获取国家列表
MenuItemLabel *getCoutriesItem = MenuItemLabel::create(LabelTTF::create("GetCountryCodes", "Arial", 10),
CC_CALLBACK_1(HelloWorld::getCountriesHandler, this));
getCoutriesItem->setPosition(winSize.width/2 , 200);
getCoutriesItem->setPosition(winSize.width/2 , 180);
getCoutriesItem->setColor(ccc3(8, 0, 190));
auto getCoutriesMenu = Menu::create(getCoutriesItem,NULL);
getCoutriesMenu->setPosition(Vec2::ZERO);
this->addChild(getCoutriesMenu);
@@ -82,24 +106,26 @@ bool HelloWorld::init()
//获取通讯录好友信息
MenuItemLabel *getFriendsItem = MenuItemLabel::create(LabelTTF::create("Get Friends", "Arial", 10),
CC_CALLBACK_1(HelloWorld::getFriendsHandler, this));
getFriendsItem->setPosition(winSize.width/2 , 175);
getFriendsItem->setPosition(winSize.width/2 , 160);
getFriendsItem->setColor(ccc3(8, 0, 190));
auto getFriendsMenu = Menu::create(getFriendsItem,NULL);
getFriendsMenu->setPosition(Vec2::ZERO);
this->addChild(getFriendsMenu);
//提交用户资料
MenuItemLabel *submitUserinfoItem = MenuItemLabel::create(LabelTTF::create("Submit Userinfo", "Arial", 10),
CC_CALLBACK_1(HelloWorld::submitUserInfoHandler, this));
submitUserinfoItem->setPosition(winSize.width/2 , 150);
submitUserinfoItem->setPosition(winSize.width/2 , 140);
submitUserinfoItem->setColor(ccc3(8, 0, 190));
auto submitUserinfoMenu = Menu::create(submitUserinfoItem,NULL);
submitUserinfoMenu->setPosition(Vec2::ZERO);
this->addChild(submitUserinfoMenu);
//获取版本号
auto getVersionItem = MenuItemLabel::create(LabelTTF::create("Get Version", "Arial", 10),
CC_CALLBACK_1(HelloWorld::getVersionHandler, this));
getVersionItem->setPosition(winSize.width/2 , 125);
getVersionItem->setPosition(winSize.width/2 , 120);
getVersionItem->setColor(ccc3(8, 0, 190));
auto getVersionMenu = Menu::create(getVersionItem,NULL);
getVersionMenu->setPosition(Vec2::ZERO);
this->addChild(getVersionMenu);
@@ -108,29 +134,33 @@ bool HelloWorld::init()
MenuItemLabel *enableWarnItem = MenuItemLabel::create(LabelTTF::create("EnableWarn", "Arial", 10),
CC_CALLBACK_1(HelloWorld::enableWarnHandler, this));
enableWarnItem->setPosition(Director::getInstance()->getWinSize().width/2 , 100);
enableWarnItem->setColor(ccc3(8, 0, 190));
auto enableWarn = Menu::create(enableWarnItem,NULL);
enableWarn->setPosition(Vec2::ZERO);
this->addChild(enableWarn);
//展示注册界面
MenuItemLabel *showRegPageItem = MenuItemLabel::create(LabelTTF::create("ShowRegPage", "Arial", 10),
CC_CALLBACK_1(HelloWorld::showRegPageHandler, this));
showRegPageItem->setPosition(winSize.width/2 , 75);
showRegPageItem->setPosition(winSize.width/2 , 80);
showRegPageItem->setColor(ccc3(8, 0, 190));
auto showRegPageItemMenu = Menu::create(showRegPageItem,NULL);
showRegPageItemMenu->setPosition(Vec2::ZERO);
this->addChild(showRegPageItemMenu);
//展示通讯录界面
MenuItemLabel *showContactsPage = MenuItemLabel::create(LabelTTF::create("showContactsPage", "Arial", 10),
CC_CALLBACK_1(HelloWorld::showContactsPageHandler, this));
showContactsPage->setPosition(winSize.width/2 , 50);
showContactsPage->setPosition(winSize.width/2 , 60);
showContactsPage->setColor(ccc3(8, 0, 190));
auto showContactsPageMenu = Menu::create(showContactsPage,NULL);
showContactsPageMenu->setPosition(Vec2::ZERO);
this->addChild(showContactsPageMenu);
label = LabelTTF::create("resultMsg:", "Arial", 8);
label->setPosition(Point(winSize.width/2 , 25));
label->setPosition(Point(winSize.width/2 , 40));
label->setHorizontalAlignment(TextHAlignment::CENTER);
label->setColor(ccc3(255, 0, 0));
this->addChild(label);
SMSSDK::setHandler(this);
@@ -149,37 +179,43 @@ void HelloWorld::editBoxEditingDidEnd(cocos2d::extension::EditBox *editBox)
void HelloWorld::editBoxReturn(cocos2d::extension::EditBox *editBox)
{
CCLOG("editboxreturn");
string phone("186******");
string zone("86");
SMSSDK::commitCode(phone,zone,editBox->getText());
}
void HelloWorld::editBoxTextChanged(cocos2d::extension::EditBox *editBox, const std::string &text)
{
string str(editBox->getText());
if (editBox == phoneBox)
{
phone = text;
}
if (editBox == zoneBox)
{
zone = text;
}
if (editBox == codeBox)
{
code = text;
}
}
void HelloWorld::getTextCodeHandler(cocos2d::Ref* pSender)
{
string phone("18021058213");
string zone("86");
{
SMSSDK::getCode(TextCode,phone,zone);
}
//
void HelloWorld::getVoiceCodeHandler(cocos2d::Ref* pSender)
{
string phone("18021058213");
string zone("86");
SMSSDK::getCode(VoiceCode,phone,zone);
}
void HelloWorld::commitCodeHandler(cocos2d::Ref *pSender)
{
string phone("18021058213");
string zone("86");
SMSSDK::commitCode(phone,zone,"6358");
SMSSDK::commitCode(phone,zone,code);
}
void HelloWorld::getFriendsHandler(cocos2d::Ref *pSender)
@@ -198,8 +234,8 @@ void HelloWorld::submitUserInfoHandler(cocos2d::Ref *pSender)
userinfo.uid = "1111";
userinfo.nickname = "test";
userinfo.avatar = "https://qq.com/";
userinfo.zone = "86";
userinfo.phone = "18666668888";
userinfo.zone = zone;
userinfo.phone = phone;
SMSSDK::submitUserInfo(userinfo);
}
@@ -231,12 +267,18 @@ void HelloWorld::showContactsPageHandler(cocos2d::Ref *pSender)
void HelloWorld::onComplete(SMSSDKActionType action,string result)
{
log("action:%d|result:%s",(int)action,result.c_str());
label->setString(result);
string logText = StringUtils::format("action:%d|result:%s",(int)action,result.c_str());
log("%s",logText.c_str());
label->setString(logText);
}
void HelloWorld::onError(SMSSDKActionType action,string result)
{
log("action:%d|result:%s",(int)action,result.c_str());
label->setString(result);
string logText = StringUtils::format("action:%d|result:%s",(int)action,result.c_str());
log("%s",logText.c_str());
label->setString(logText);
}
View
@@ -55,7 +55,15 @@ class HelloWorld : public cocos2d::Layer,public SMSSDKHandler,public EditBoxDele
CREATE_FUNC(HelloWorld);
private:
LabelTTF* label;
LabelTTF *label;
string phone;
string zone;
string code;
EditBox *phoneBox;
EditBox *zoneBox;
EditBox *codeBox;
};
#endif
@@ -25,8 +25,7 @@
bool iOSSMSSDK::init(string appKey, string appSecret, bool isWarn)
{
NSLog(@"3.0.0版本后appkey和appSecret配置在info.Plist里");
NSLog(@"3.0.0版本后appkey和appSecret自动配置到info.plist里,init方法不需要实现");
return true;
}

0 comments on commit 9a25f89

Please sign in to comment.