977 lines
35 KiB
C++
977 lines
35 KiB
C++
#include "TjdUiAppAlipayView.h"
|
|
#include "TjdUiImageIds.h"
|
|
#include "TjdUiMemManage.h"
|
|
#include "TjdUiMultiLanguageExt.h"
|
|
#include "animator/animator_manager.h"
|
|
#include "common/image_cache_manager.h"
|
|
#include "graphic_service.h"
|
|
#include "sys_config.h"
|
|
|
|
#define ALIPAY_GET_PAY_STR_MAX_LENGTH 20
|
|
#define ALIPAY_BARCODE_LABEL_NUM 23
|
|
#define ALIPAY_BARCODE_SPACE 32
|
|
#define ALIPAY_BARCODE_SPACE_INTER 4
|
|
#define ALIPAY_BARCODE_SPACE_NUM 3
|
|
#define ALIPAY_BARCODE_LABEL_NUM 23
|
|
|
|
namespace TJD {
|
|
|
|
#define ENABLE_PRINT_INFO 1
|
|
#if ENABLE_PRINT_INFO
|
|
#define static_print_info(...) sys_ui_log_i(__VA_ARGS__) // 一般信息打印宏控制
|
|
#define static_print_warn(...) sys_ui_log_w(__VA_ARGS__) // 警告信息打印一般常开
|
|
#define static_print_error(...) sys_ui_log_e(__VA_ARGS__) // 错误信息打印一般常开
|
|
#define static_print_debug(...) sys_ui_log_d(__VA_ARGS__) // 调试信息打印一般常开
|
|
#else
|
|
#define static_print_info(...)
|
|
#define static_print_warn(...)
|
|
#define static_print_error(...)
|
|
#define static_print_debug(...)
|
|
#endif
|
|
|
|
static TjdUiAppAlipayView *g_alipayView = nullptr;
|
|
|
|
AlipayViewIndex TjdUiAppAlipayView::currentViewIndex_ = AlipayViewIndex::ALIPAY_UNKNOWN;
|
|
|
|
#define ALIPAY_IMAGE_PATH TJD_IMAGE_PATH "img_alipay.bin"
|
|
|
|
// clang-format off
|
|
static inline int16_t HorizontalCenter(int16_t width, int16_t parentWidth) { return (parentWidth - width) / 2; }
|
|
|
|
static inline int16_t VerticalCenter(int16_t height, int16_t parentHeight) { return (parentHeight - height) / 2; }
|
|
|
|
static inline void InitLabelHorCenter(OHOS::UILabel &label, uint8_t size, int16_t y, int16_t target, const char *text)
|
|
{
|
|
label.SetFont(TJD_VECTOR_FONT_FILENAME, size);
|
|
label.SetText(text);
|
|
label.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
|
label.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
|
label.SetPosition(HorizontalCenter(label.GetWidth(), target), y);
|
|
}
|
|
|
|
static inline void InitLabelVerCenter(OHOS::UILabel &label, uint8_t size, int16_t x, int16_t target, const char *text)
|
|
{
|
|
label.SetFont(TJD_VECTOR_FONT_FILENAME, size);
|
|
label.SetText(text);
|
|
label.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
|
label.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
|
label.SetPosition(x, VerticalCenter(label.GetHeight(), target));
|
|
}
|
|
|
|
static inline void InitLabelCenter(OHOS::UILabel &label, uint8_t size, int16_t parentWidth, int16_t parentHeight, const char *text)
|
|
{
|
|
label.SetFont(TJD_VECTOR_FONT_FILENAME, size);
|
|
label.SetText(text);
|
|
label.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
|
label.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_CENTER);
|
|
label.SetPosition(HorizontalCenter(label.GetWidth(), parentWidth), VerticalCenter(label.GetHeight(), parentHeight));
|
|
}
|
|
// clang-format on
|
|
|
|
static void AlipayBarcodeReformat(uint8_t *str, uint8_t *strBarcode)
|
|
{
|
|
for (uint8_t i = 0, j = 0; i < ALIPAY_GET_PAY_STR_MAX_LENGTH && j < ALIPAY_BARCODE_LABEL_NUM; i++, j++) {
|
|
if ((i % ALIPAY_BARCODE_SPACE_INTER == 0) && i != 0 &&
|
|
i <= ALIPAY_BARCODE_SPACE_INTER * ALIPAY_BARCODE_SPACE_NUM) {
|
|
strBarcode[j] = ALIPAY_BARCODE_SPACE;
|
|
j++;
|
|
}
|
|
strBarcode[j] = str[i];
|
|
}
|
|
}
|
|
|
|
TjdUiAppAlipayView::TjdUiAppAlipayView() { g_alipayView = this; }
|
|
|
|
TjdUiAppAlipayView::~TjdUiAppAlipayView() { g_alipayView = nullptr; }
|
|
|
|
TjdUiAppAlipayView *TjdUiAppAlipayView::GetInstance(void) { return g_alipayView; }
|
|
|
|
void TjdUiAppAlipayView::OnStart()
|
|
{
|
|
OHOS::ImageCacheManager::GetInstance().LoadAllInMultiRes(ALIPAY_IMAGE_PATH);
|
|
|
|
if (mainView_ == nullptr) {
|
|
mainView_ = new AlipayUIScrollView();
|
|
}
|
|
mainView_->SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
if (OHOS::PageTransitionMgr::GetInstance().GetTopSlideBackImage() == nullptr) {
|
|
mainView_->SetOnDragListener(presenter_);
|
|
}
|
|
|
|
// 只初始化部分页面,其他页面在需要时初始化
|
|
InitTargetView(AlipayViewIndex::ALIPAY_LOGO);
|
|
InitTargetView(AlipayViewIndex::ALIPAY_ERROR);
|
|
InitTargetView(AlipayViewIndex::ALIPAY_PAY_QRCODE);
|
|
|
|
AddViewToRootContainer(mainView_);
|
|
}
|
|
|
|
void TjdUiAppAlipayView::OnStop()
|
|
{
|
|
if (mainView_ != nullptr) {
|
|
mainView_->RemoveAll();
|
|
delete mainView_;
|
|
mainView_ = nullptr;
|
|
}
|
|
for (int i = 0; i < AlipayViewIndex::ALIPAY_UNKNOWN; i++) {
|
|
if (viewManager_[i] != nullptr) {
|
|
viewManager_[i]->RemoveAll();
|
|
delete viewManager_[i];
|
|
viewManager_[i] = nullptr;
|
|
}
|
|
}
|
|
OHOS::ImageCacheManager::GetInstance().UnloadAllInMultiRes(ALIPAY_IMAGE_PATH);
|
|
}
|
|
|
|
void TjdUiAppAlipayView::InitTargetView(AlipayViewIndex index)
|
|
{
|
|
if (viewManager_[index] != nullptr) {
|
|
return;
|
|
}
|
|
|
|
// clang-format off
|
|
switch (index) {
|
|
case ALIPAY_LOGO: viewManager_[index] = new AlipayLogoView(); break;
|
|
case ALIPAY_PROTOCOL: viewManager_[index] = new AlipayProtocolView(); break;
|
|
case ALIPAY_BIND: viewManager_[index] = new AlipayBindView(); break;
|
|
case ALIPAY_WAITING: viewManager_[index] = new AlipayWaitView(); break;
|
|
case ALIPAY_BIND_INFO: viewManager_[index] = new AlipayBindMsgView(); break;
|
|
case ALIPAY_LIST: viewManager_[index] = new AlipayListView(); break;
|
|
case ALIPAY_PAY_QRCODE: viewManager_[index] = new AlipayPayQrcodeView(); break;
|
|
case ALIPAY_RIDE_CODE_LIST: viewManager_[index] = new AlipayRideCodeListView(); break;
|
|
case ALIPAY_RIDE_QRCODE: viewManager_[index] = new AlipayRideCodeView(); break;
|
|
case ALIPAY_SETTING: viewManager_[index] = new AlipaySettingView(); break;
|
|
case ALIPAY_HELP: viewManager_[index] = new AlipayHelpView(); break;
|
|
case ALIPAY_UNBIND: viewManager_[index] = new AlipayUnBindView(); break;
|
|
case ALIPAY_UNBIND_SUC: viewManager_[index] = new AlipayUnBindSucView(); break;
|
|
case ALIPAY_ERROR: viewManager_[index] = new AlipayErrorMsgView(); break;
|
|
default: break;
|
|
}
|
|
// clang-format on
|
|
|
|
if (viewManager_[index] == nullptr) {
|
|
return;
|
|
}
|
|
|
|
viewManager_[index]->SetPosition(0, 0);
|
|
viewManager_[index]->SetVisible(false);
|
|
mainView_->Add(viewManager_[index]);
|
|
}
|
|
|
|
void TjdUiAppAlipayView::ShowView(AlipayViewIndex showIndex)
|
|
{
|
|
if (showIndex < 0 || showIndex >= AlipayViewIndex::ALIPAY_UNKNOWN) {
|
|
return;
|
|
}
|
|
|
|
InitTargetView(showIndex);
|
|
|
|
if (currentViewIndex_ >= 0 && currentViewIndex_ < AlipayViewIndex::ALIPAY_UNKNOWN &&
|
|
viewManager_[currentViewIndex_] != nullptr) {
|
|
viewManager_[currentViewIndex_]->HideView();
|
|
}
|
|
|
|
if (viewManager_[showIndex] != nullptr) {
|
|
viewManager_[showIndex]->ShowView();
|
|
}
|
|
|
|
currentViewIndex_ = showIndex;
|
|
}
|
|
|
|
void TjdUiAppAlipayView::ShowBindMsg(AlipayBindStatus status)
|
|
{
|
|
InitTargetView(AlipayViewIndex::ALIPAY_BIND_INFO);
|
|
dynamic_cast<AlipayBindMsgView *>(viewManager_[AlipayViewIndex::ALIPAY_BIND_INFO])->ShowBinding(status);
|
|
ShowView(AlipayViewIndex::ALIPAY_BIND_INFO);
|
|
}
|
|
|
|
void TjdUiAppAlipayView::ShowErrorMsg(const char *desc, AlipayViewIndex onClickShowIndex)
|
|
{
|
|
InitTargetView(AlipayViewIndex::ALIPAY_ERROR);
|
|
dynamic_cast<AlipayErrorMsgView *>(viewManager_[AlipayViewIndex::ALIPAY_ERROR])
|
|
->ShowErrorMsg(desc, onClickShowIndex);
|
|
ShowView(AlipayViewIndex::ALIPAY_ERROR);
|
|
}
|
|
|
|
void TjdUiAppAlipayView::ShowRideCode(const char *desc, const char *qrcode)
|
|
{
|
|
InitTargetView(AlipayViewIndex::ALIPAY_RIDE_QRCODE);
|
|
// dynamic_cast<AlipayRideCodeView *>(viewManager_[AlipayViewIndex::ALIPAY_RIDE_QRCODE])->ShowQrcode(desc, qrcode);
|
|
ShowView(AlipayViewIndex::ALIPAY_RIDE_QRCODE);
|
|
}
|
|
|
|
void TjdUiAppAlipayView::RefreshPayCode(const char *payStr)
|
|
{
|
|
InitTargetView(AlipayViewIndex::ALIPAY_PAY_QRCODE);
|
|
auto view = dynamic_cast<AlipayPayQrcodeView *>(viewManager_[AlipayViewIndex::ALIPAY_PAY_QRCODE]);
|
|
if (view == nullptr) {
|
|
return;
|
|
}
|
|
view->AlipayRefreshBarcode(payStr);
|
|
view->AlipayRefreshQrcode(payStr);
|
|
}
|
|
|
|
void TjdUiAppAlipayView::JumpToConsentBindView()
|
|
{
|
|
InitTargetView(AlipayViewIndex::ALIPAY_PROTOCOL);
|
|
dynamic_cast<AlipayProtocolView *>(viewManager_[AlipayViewIndex::ALIPAY_PROTOCOL])->SetSwipeViewPage(1);
|
|
}
|
|
|
|
void AlipayButton::InitView(bool isBlue, const char *text, uint8_t size)
|
|
{
|
|
SetTouchable(true);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_OPA, OHOS::OPA_OPAQUE);
|
|
SetStyle(OHOS::STYLE_BORDER_RADIUS, GetHeight() / 2);
|
|
InitLabelCenter(name_, size, GetWidth(), GetHeight(), text);
|
|
if (isBlue) {
|
|
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff1676FE);
|
|
name_.SetTextColor(OHOS::Color::White());
|
|
} else {
|
|
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xffffffff);
|
|
name_.SetTextColor(OHOS::Color::Black());
|
|
}
|
|
Add(&name_);
|
|
}
|
|
|
|
#pragma region Logo页面
|
|
AlipayLogoView::AlipayLogoView()
|
|
{
|
|
auto &images = OHOS::ImageCacheManager::GetInstance();
|
|
Resize(OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
|
|
bool isChinese = TjdUiAppAlipayPresenter::GetInstance()->IsChinese();
|
|
logo_.SetPosition(160, 116, 114, 114);
|
|
logo_.SetSrc(images.LoadOneInMultiRes(IMG_ALIPAY_ALLPEY_LOGO, ALIPAY_IMAGE_PATH));
|
|
|
|
OHOS::ImageInfo *descRes = nullptr;
|
|
if (isChinese) {
|
|
desc_.SetPosition(145, 281, 173, 54);
|
|
descRes = images.LoadOneInMultiRes(IMG_ALIPAY_ALLPEY_CN_TEXT, ALIPAY_IMAGE_PATH);
|
|
} else {
|
|
desc_.SetPosition(115, 283, 239, 48);
|
|
descRes = images.LoadOneInMultiRes(IMG_ALIPAY_ALLPEY_EN_TEXT, ALIPAY_IMAGE_PATH);
|
|
}
|
|
|
|
if (descRes != nullptr) {
|
|
desc_.SetSrc(descRes);
|
|
}
|
|
|
|
Add(&logo_);
|
|
Add(&desc_);
|
|
}
|
|
#pragma endregion
|
|
|
|
#pragma region 绑定页面
|
|
AlipayBindView::AlipayBindView()
|
|
{
|
|
Resize(OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xffffffff);
|
|
|
|
InitLabelHorCenter(title_, 28, 20, 466, "使用支付宝扫码\n绑定");
|
|
title_.SetTextColor(OHOS::Color::Black());
|
|
|
|
qrcode_.SetPosition(78, 99, 315, 315);
|
|
qrcode_.SetAutoEnable(false);
|
|
qrcode_.SetResizeMode(OHOS::UIImageView::ImageResizeMode::CENTER);
|
|
uint8_t str[256] = {0};
|
|
TjdUiAppAlipayPresenter::GetInstance()->AlipayGetBindCode(str);
|
|
qrcode_.SetQrcodeInfo((const char *)str);
|
|
|
|
qrcodeIcon_.Resize(71, 71);
|
|
const int16_t iconX = qrcode_.GetX() + (qrcode_.GetWidth() / 2) - (qrcodeIcon_.GetWidth() / 2);
|
|
const int16_t iconY = qrcode_.GetY() + (qrcode_.GetHeight() / 2) - (qrcodeIcon_.GetHeight() / 2);
|
|
qrcodeIcon_.SetAutoEnable(false);
|
|
qrcodeIcon_.SetPosition(iconX, iconY, 74, 74);
|
|
qrcodeIcon_.SetResizeMode(OHOS::UIImageView::ImageResizeMode::CENTER);
|
|
qrcodeIcon_.SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
|
|
qrcodeIcon_.SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xffffffff);
|
|
qrcodeIcon_.SetStyle(OHOS::STYLE_BORDER_RADIUS, 12);
|
|
auto image = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_ALIPAY_ALIPAY, ALIPAY_IMAGE_PATH);
|
|
if (image != nullptr) {
|
|
qrcodeIcon_.SetSrc(image);
|
|
}
|
|
|
|
Add(&qrcode_);
|
|
Add(&title_);
|
|
Add(&qrcodeIcon_);
|
|
}
|
|
|
|
void AlipayBindView::ShowView()
|
|
{
|
|
TjdUiAppAlipayPresenter::GetInstance()->SetScreenBrightnessMax();
|
|
SetVisible(true);
|
|
}
|
|
|
|
void AlipayBindView::HideView()
|
|
{
|
|
TjdUiAppAlipayPresenter::GetInstance()->ResetScreenBrightness();
|
|
SetVisible(false);
|
|
}
|
|
#pragma endregion
|
|
|
|
#pragma region 同意绑定页面
|
|
AlipayProtocolView::AlipayProtocolView()
|
|
{
|
|
auto &imgManager = OHOS::ImageCacheManager::GetInstance();
|
|
auto select = imgManager.LoadOneInMultiRes(IMG_ALIPAY_SPOT_02, ALIPAY_IMAGE_PATH);
|
|
auto unSelect = imgManager.LoadOneInMultiRes(IMG_ALIPAY_SPOT_01, ALIPAY_IMAGE_PATH);
|
|
auto enter = imgManager.LoadOneInMultiRes(IMG_ALIPAY_BLUE_BJ, ALIPAY_IMAGE_PATH);
|
|
|
|
Resize(OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
SetHorizontalScrollState(true);
|
|
|
|
mainView_.SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
|
|
protocolMsgGroup_.SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
protocolSelectCodePoint_.SetPosition(217, 11, 12, 12);
|
|
if (select != nullptr) {
|
|
protocolSelectCodePoint_.SetSrc(select);
|
|
}
|
|
protocolUnSelectCodePoint_.SetPosition(237, 11, 12, 12);
|
|
if (unSelect != nullptr) {
|
|
protocolUnSelectCodePoint_.SetSrc(unSelect);
|
|
}
|
|
InitLabelHorCenter(protocolMsgTitle_, 36, 58, 466, "同意手表支付协议");
|
|
InitLabelHorCenter(protocolMsgDesc_, 38, 170, 466,
|
|
"详情请在手机支付宝,\n「智能手表」页面「手表支\n付协议中查看」");
|
|
InitLabelHorCenter(protocolEnterViewDesc_, 36, 396, 466, "同意协议");
|
|
protocolEnterView_.SetPosition(52, 381, 362, 85);
|
|
if (enter != nullptr) {
|
|
protocolEnterView_.SetSrc(enter);
|
|
}
|
|
protocolEnterView_.SetTouchable(true);
|
|
protocolEnterView_.SetViewId(ALIPAY_CONSENT_PROTOCOL_VIEWID);
|
|
protocolEnterView_.SetOnClickListener(TjdUiAppAlipayPresenter::GetInstance());
|
|
protocolMsgGroup_.Add(&protocolSelectCodePoint_);
|
|
protocolMsgGroup_.Add(&protocolUnSelectCodePoint_);
|
|
protocolMsgGroup_.Add(&protocolMsgTitle_);
|
|
protocolMsgGroup_.Add(&protocolMsgDesc_);
|
|
protocolMsgGroup_.Add(&protocolEnterView_);
|
|
protocolMsgGroup_.Add(&protocolEnterViewDesc_);
|
|
|
|
bindMsgGroup_.SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
bindSelectCodePoint_.SetPosition(237, 11, 12, 12);
|
|
if (select != nullptr) {
|
|
bindSelectCodePoint_.SetSrc(select);
|
|
}
|
|
bindUnSelectCodePoint_.SetPosition(217, 11, 12, 12);
|
|
if (unSelect != nullptr) {
|
|
bindUnSelectCodePoint_.SetSrc(unSelect);
|
|
}
|
|
InitLabelHorCenter(bindMsgTitle_, 36, 58, 466, "绑定我的手机");
|
|
InitLabelHorCenter(bindMsgDesc_, 38, 170, 466, "打开手机制度表(10.0.20\n及以上版本),进入首页\n「扫一扫」");
|
|
InitLabelHorCenter(bindEnterViewDesc_, 36, 396, 466, "立即绑定");
|
|
bindEnterView_.SetPosition(52, 381, 362, 85);
|
|
if (enter != nullptr) {
|
|
bindEnterView_.SetSrc(enter);
|
|
}
|
|
bindEnterView_.SetTouchable(true);
|
|
bindEnterView_.SetViewId(ALIPAY_CONSENT_BIND_VIEWID);
|
|
bindEnterView_.SetOnClickListener(TjdUiAppAlipayPresenter::GetInstance());
|
|
bindMsgGroup_.Add(&bindSelectCodePoint_);
|
|
bindMsgGroup_.Add(&bindUnSelectCodePoint_);
|
|
bindMsgGroup_.Add(&bindMsgTitle_);
|
|
bindMsgGroup_.Add(&bindMsgDesc_);
|
|
bindMsgGroup_.Add(&bindEnterView_);
|
|
bindMsgGroup_.Add(&bindEnterViewDesc_);
|
|
|
|
mainView_.Add(&protocolMsgGroup_);
|
|
mainView_.Add(&bindMsgGroup_);
|
|
|
|
Add(&mainView_);
|
|
}
|
|
|
|
AlipayProtocolView::~AlipayProtocolView()
|
|
{
|
|
RemoveAll();
|
|
mainView_.RemoveAll();
|
|
protocolMsgGroup_.RemoveAll();
|
|
bindMsgGroup_.RemoveAll();
|
|
}
|
|
|
|
void AlipayProtocolView::SetSwipeViewPage(int page)
|
|
{
|
|
if (page > 1) {
|
|
return;
|
|
}
|
|
mainView_.SetCurrentPage(page, true);
|
|
}
|
|
#pragma endregion
|
|
|
|
#pragma region 等待页面
|
|
AlipayWaitView::AlipayWaitView() : bindingAnimatorInfo_(nullptr)
|
|
{
|
|
Resize(OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
|
|
std::vector<uint32_t> resId = {IMG_ALIPAY_DT_01, IMG_ALIPAY_DT_02, IMG_ALIPAY_DT_03, IMG_ALIPAY_DT_04,
|
|
IMG_ALIPAY_DT_05, IMG_ALIPAY_DT_06, IMG_ALIPAY_DT_07};
|
|
bindingAnimatorInfo_ = new OHOS::ImageAnimatorInfo[resId.size()];
|
|
|
|
auto &image = OHOS::ImageCacheManager::GetInstance();
|
|
OHOS::Point animatorPos = {146, 120};
|
|
// 播放动效
|
|
OHOS::ImageAnimatorInfo baseinfo = {nullptr, animatorPos, 0, 0, OHOS::IMG_SRC_IMAGE_INFO};
|
|
for (size_t i = 0; i < resId.size(); i++) {
|
|
bindingAnimatorInfo_[i] = baseinfo;
|
|
bindingAnimatorInfo_[i].imageInfo = image.LoadOneInMultiRes(resId[i], ALIPAY_IMAGE_PATH);
|
|
bindingAnimatorInfo_[i].width = bindingAnimatorInfo_[i].imageInfo->header.width;
|
|
bindingAnimatorInfo_[i].height = bindingAnimatorInfo_[i].imageInfo->header.height;
|
|
}
|
|
animator_.SetPosition(animatorPos.x, animatorPos.y, bindingAnimatorInfo_[0].width, bindingAnimatorInfo_[0].height);
|
|
animator_.SetImageAnimatorSrc(bindingAnimatorInfo_, resId.size(), 100);
|
|
|
|
desc_.SetText("正在绑定");
|
|
desc_.SetPosition((OHOS::HORIZONTAL_RESOLUTION >> 1) - (300 >> 1), 323, 300, 80);
|
|
desc_.SetFont(TJD_VECTOR_FONT_FILENAME, 42);
|
|
desc_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_MARQUEE);
|
|
desc_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER, OHOS::TEXT_ALIGNMENT_TOP);
|
|
|
|
Add(&animator_);
|
|
Add(&desc_);
|
|
}
|
|
|
|
AlipayWaitView::~AlipayWaitView()
|
|
{
|
|
if (bindingAnimatorInfo_ != nullptr) {
|
|
delete[] bindingAnimatorInfo_;
|
|
bindingAnimatorInfo_ = nullptr;
|
|
}
|
|
RemoveAll();
|
|
}
|
|
|
|
void AlipayWaitView::ShowView()
|
|
{
|
|
SetVisible(true);
|
|
animator_.Start();
|
|
}
|
|
|
|
void AlipayWaitView::HideView()
|
|
{
|
|
SetVisible(false);
|
|
animator_.Stop();
|
|
}
|
|
#pragma endregion
|
|
|
|
#pragma region 绑定信息页面
|
|
AlipayBindMsgView::AlipayBindMsgView()
|
|
{
|
|
Resize(OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
|
|
logo_.SetPosition(165, 138, 136, 136);
|
|
InitLabelHorCenter(desc_, 42, 295, 466, "绑定失败");
|
|
|
|
Add(&logo_);
|
|
Add(&desc_);
|
|
}
|
|
|
|
void AlipayBindMsgView::ShowBinding(AlipayBindStatus status)
|
|
{
|
|
if (status == ALIPAY_BIND_SUCCESS) {
|
|
auto success = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_ALIPAY_SUCCESS, ALIPAY_IMAGE_PATH);
|
|
desc_.SetText("绑定成功");
|
|
if (success != nullptr) {
|
|
logo_.SetSrc(success);
|
|
}
|
|
} else {
|
|
auto fail = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_ALIPAY_DEFEATED, ALIPAY_IMAGE_PATH);
|
|
desc_.SetText("绑定失败");
|
|
if (fail != nullptr) {
|
|
logo_.SetSrc(fail);
|
|
}
|
|
}
|
|
}
|
|
#pragma endregion
|
|
|
|
#pragma region 列表页面
|
|
void AlipayListView::AlipayListItem::InitView(const OHOS::ImageInfo *iconRes, const char *title)
|
|
{
|
|
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff232323);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
|
|
SetTouchable(true);
|
|
icon_.SetPosition(95, 19, 82, 82);
|
|
if (iconRes != nullptr) {
|
|
icon_.SetSrc(iconRes);
|
|
}
|
|
InitLabelVerCenter(title_, 46, 195, 120, title);
|
|
Add(&icon_);
|
|
Add(&title_);
|
|
}
|
|
|
|
AlipayListView::AlipayListView()
|
|
{
|
|
Resize(OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
|
|
SetScrollBlankSize(38);
|
|
|
|
auto &imgManager = OHOS::ImageCacheManager::GetInstance();
|
|
auto payCodeRes = imgManager.LoadOneInMultiRes(IMG_ALIPAY_PAYMENT, ALIPAY_IMAGE_PATH);
|
|
auto settingRes = imgManager.LoadOneInMultiRes(IMG_ALIPAY_SET, ALIPAY_IMAGE_PATH);
|
|
auto helpRes = imgManager.LoadOneInMultiRes(IMG_ALIPAY_HELP, ALIPAY_IMAGE_PATH);
|
|
|
|
payCodeGroup_.SetPosition(0, 38, OHOS::HORIZONTAL_RESOLUTION, 120);
|
|
payCodeGroup_.SetViewId(ALIPAY_PAYCODE_VIEWID);
|
|
payCodeGroup_.SetOnClickListener(TjdUiAppAlipayPresenter::GetInstance());
|
|
payCodeGroup_.InitView(payCodeRes, "付款码");
|
|
|
|
// rideCodeGroup_.SetPosition(0, 170, OHOS::HORIZONTAL_RESOLUTION, 120);
|
|
// rideCodeGroup_.SetViewId(ALIPAY_RIDECODE_VIEWID);
|
|
// rideCodeGroup_.SetOnClickListener(TjdUiAppAlipayPresenter::GetInstance());
|
|
// rideCodeGroup_.InitView(payCodeRes, "乘车码");
|
|
|
|
settingGroup_.SetPosition(0, 170, OHOS::HORIZONTAL_RESOLUTION, 120);
|
|
settingGroup_.SetViewId(ALIPAY_SETTING_VIEWID);
|
|
settingGroup_.SetOnClickListener(TjdUiAppAlipayPresenter::GetInstance());
|
|
settingGroup_.InitView(settingRes, "设置");
|
|
|
|
helpGroup_.SetPosition(0, 302, OHOS::HORIZONTAL_RESOLUTION, 120);
|
|
helpGroup_.SetViewId(ALIPAY_HELP_VIEWID);
|
|
helpGroup_.SetOnClickListener(TjdUiAppAlipayPresenter::GetInstance());
|
|
helpGroup_.InitView(helpRes, "帮助");
|
|
|
|
Add(&payCodeGroup_);
|
|
Add(&rideCodeGroup_);
|
|
Add(&settingGroup_);
|
|
Add(&helpGroup_);
|
|
}
|
|
#pragma endregion
|
|
|
|
#pragma region 付款码页面
|
|
AlipayPayQrcodeView::AlipayPayQrcodeView()
|
|
{
|
|
Resize(OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
SetHorizontalScrollState(true);
|
|
|
|
auto &imgManager = OHOS::ImageCacheManager::GetInstance();
|
|
auto select = imgManager.LoadOneInMultiRes(IMG_ALIPAY_SPOT_02, ALIPAY_IMAGE_PATH);
|
|
auto unSelect = imgManager.LoadOneInMultiRes(IMG_ALIPAY_SPOT_01, ALIPAY_IMAGE_PATH);
|
|
|
|
mainView_.SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
mainView_.SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xFF1676FE);
|
|
mainView_.SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xFF);
|
|
|
|
paymentCodeGroup_.SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
paymentCodeGroup_.SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff1676FE);
|
|
paymentCodeGroup_.SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
|
|
InitLabelHorCenter(paymentCodeTitle_, 42, 17, 466, "付款码");
|
|
paymentSelectCodePoint_.SetPosition(217, 11, 12, 12);
|
|
if (select != nullptr) {
|
|
paymentSelectCodePoint_.SetSrc(select);
|
|
}
|
|
paymentUnSelectCodePoint_.SetPosition(237, 11, 12, 12);
|
|
if (unSelect != nullptr) {
|
|
paymentUnSelectCodePoint_.SetSrc(unSelect);
|
|
}
|
|
|
|
paymentQrcodeGroup_.SetPosition(78, 80, 312, 312);
|
|
paymentQrcodeGroup_.SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
|
|
paymentQrcodeGroup_.SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xffffffff);
|
|
|
|
paymentQrcode_.SetPosition(16, 16, 280, 280);
|
|
paymentQrcode_.SetAutoEnable(false);
|
|
paymentQrcode_.SetResizeMode(OHOS::UIImageView::ImageResizeMode::FILL);
|
|
paymentQrcode_.SetECCLevel(QrCode::Ecc::QUARTILE);
|
|
|
|
paymentQrcodeIcon_.Resize(71, 71);
|
|
const int16_t iconX = paymentQrcode_.GetX() + (paymentQrcode_.GetWidth() / 2) - (paymentQrcodeIcon_.GetWidth() / 2);
|
|
const int16_t iconY =
|
|
paymentQrcode_.GetY() + (paymentQrcode_.GetHeight() / 2) - (paymentQrcodeIcon_.GetHeight() / 2);
|
|
paymentQrcodeIcon_.SetAutoEnable(false);
|
|
paymentQrcodeIcon_.SetPosition(iconX, iconY, 74, 74);
|
|
paymentQrcodeIcon_.SetResizeMode(OHOS::UIImageView::ImageResizeMode::CENTER);
|
|
paymentQrcodeIcon_.SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
|
|
paymentQrcodeIcon_.SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xffffffff);
|
|
paymentQrcodeIcon_.SetStyle(OHOS::STYLE_BORDER_RADIUS, 12);
|
|
auto image = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_ALIPAY_ALIPAY, ALIPAY_IMAGE_PATH);
|
|
if (image != nullptr) {
|
|
paymentQrcodeIcon_.SetSrc(image);
|
|
}
|
|
paymentQrcodeGroup_.Add(&paymentQrcode_);
|
|
paymentQrcodeGroup_.Add(&paymentQrcodeIcon_);
|
|
|
|
paymentCodeGroup_.Add(&paymentCodeTitle_);
|
|
paymentCodeGroup_.Add(&paymentSelectCodePoint_);
|
|
paymentCodeGroup_.Add(&paymentUnSelectCodePoint_);
|
|
paymentCodeGroup_.Add(&paymentQrcodeGroup_);
|
|
|
|
barcodeGroup_.SetPosition(0, 0, OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
barcodeGroup_.SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff1676FE);
|
|
barcodeGroup_.SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
|
|
InitLabelHorCenter(barcodeTitle_, 42, 17, 466, "付款码");
|
|
barcodeSelectCodePoint_.SetPosition(217, 11, 12, 12);
|
|
if (select != nullptr) {
|
|
barcodeSelectCodePoint_.SetSrc(unSelect);
|
|
}
|
|
barcodeUnSelectCodePoint_.SetPosition(237, 11, 12, 12);
|
|
if (unSelect != nullptr) {
|
|
barcodeUnSelectCodePoint_.SetSrc(select);
|
|
}
|
|
|
|
barcodeIconGroup_.SetPosition(16, 149, 435, 146);
|
|
barcodeIconGroup_.SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xffffffff);
|
|
barcodeIconGroup_.SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
|
|
barcodeIconGroup_.SetStyle(OHOS::STYLE_BORDER_RADIUS, 16);
|
|
|
|
barcode_.SetAutoEnable(false);
|
|
barcode_.EnableStretch(false);
|
|
barcode_.SetPosition(16, 8, 403, 130);
|
|
barcode_.SetResizeMode(OHOS::UIImageView::ImageResizeMode::FILL);
|
|
|
|
barcodeIconGroup_.Add(&barcode_);
|
|
|
|
barcodeNum_.SetFont(TJD_VECTOR_FONT_FILENAME, 35);
|
|
barcodeNum_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_WRAP);
|
|
barcodeNum_.SetAlign(OHOS::TEXT_ALIGNMENT_CENTER);
|
|
barcodeNum_.Resize(412, 40);
|
|
barcodeNum_.SetPosition(HorizontalCenter(barcodeNum_.GetWidth(), 466), 306);
|
|
|
|
barcodeGroup_.Add(&barcodeTitle_);
|
|
barcodeGroup_.Add(&barcodeSelectCodePoint_);
|
|
barcodeGroup_.Add(&barcodeUnSelectCodePoint_);
|
|
barcodeGroup_.Add(&barcodeIconGroup_);
|
|
barcodeGroup_.Add(&barcodeNum_);
|
|
|
|
mainView_.Add(&paymentCodeGroup_);
|
|
mainView_.Add(&barcodeGroup_);
|
|
|
|
exitView_.SetPosition(0, 0, 70, 466);
|
|
exitView_.SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0);
|
|
exitView_.SetTouchable(true);
|
|
exitView_.SetViewId(ALIPAY_EXIT_VIEWID);
|
|
exitView_.SetOnClickListener(TjdUiAppAlipayPresenter::GetInstance());
|
|
|
|
Add(&mainView_);
|
|
Add(&exitView_);
|
|
}
|
|
|
|
AlipayPayQrcodeView::~AlipayPayQrcodeView()
|
|
{
|
|
paymentQrcodeGroup_.RemoveAll();
|
|
barcodeGroup_.RemoveAll();
|
|
mainView_.RemoveAll();
|
|
paymentCodeGroup_.RemoveAll();
|
|
barcodeGroup_.RemoveAll();
|
|
}
|
|
|
|
void AlipayPayQrcodeView::AlipayRefreshQrcode(const char *refreshStr)
|
|
{
|
|
paymentQrcode_.SetECCLevel(QrCode::Ecc::QUARTILE);
|
|
paymentQrcode_.SetQrcodeInfo(refreshStr);
|
|
paymentQrcode_.Invalidate();
|
|
}
|
|
|
|
void AlipayPayQrcodeView::AlipayRefreshBarcode(const char *refreshStr)
|
|
{
|
|
barcode_.SetBarcodeInfo(refreshStr);
|
|
uint8_t strBarcode[ALIPAY_BARCODE_LABEL_NUM] = {0};
|
|
AlipayBarcodeReformat((uint8_t *)refreshStr, strBarcode);
|
|
barcodeNum_.SetText((char *)strBarcode);
|
|
}
|
|
|
|
void AlipayPayQrcodeView::ShowView()
|
|
{
|
|
TjdUiAppAlipayPresenter::GetInstance()->SetScreenBrightnessMax();
|
|
SetVisible(true);
|
|
}
|
|
|
|
void AlipayPayQrcodeView::HideView()
|
|
{
|
|
TjdUiAppAlipayPresenter::GetInstance()->ResetScreenBrightness();
|
|
SetVisible(false);
|
|
}
|
|
#pragma endregion
|
|
|
|
#pragma region 乘车码列表页面
|
|
void AlipayRideCodeListView::AlipayRideCodeItem::InitView(const char *desc)
|
|
{
|
|
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff232323);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
|
|
SetStyle(OHOS::STYLE_BORDER_RADIUS, GetHeight() / 2);
|
|
SetTouchable(true);
|
|
InitLabelVerCenter(desc_, 38, 26, 120, desc);
|
|
Add(&desc_);
|
|
}
|
|
|
|
AlipayRideCodeListView::AlipayRideCodeListView()
|
|
{
|
|
Resize(OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
|
|
SetScrollBlankSize(45);
|
|
}
|
|
|
|
AlipayRideCodeListView::~AlipayRideCodeListView()
|
|
{
|
|
RemoveAll();
|
|
for (auto &item : rideItemList_) {
|
|
if (item.item != nullptr) {
|
|
item.item->RemoveAll();
|
|
delete item.item;
|
|
item.item = nullptr;
|
|
}
|
|
}
|
|
rideCodeList_.clear();
|
|
}
|
|
|
|
bool AlipayRideCodeListView::OnClick(UIView &view, const OHOS::ClickEvent &event)
|
|
{
|
|
int index = view.GetViewIndex();
|
|
for (auto &item : rideItemList_) {
|
|
if (item.item->GetViewIndex() == index) {
|
|
TjdUiAppAlipayView::GetInstance()->ShowRideCode(item.desc.c_str(), nullptr);
|
|
break;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void AlipayRideCodeListView::ShowView()
|
|
{
|
|
SetVisible(true);
|
|
// TjdUiAppAlipayPresenter::GetInstance()->AlipayGetRideCodeList();
|
|
UpdateRideCodeList();
|
|
}
|
|
|
|
void AlipayRideCodeListView::UpdateRideCodeList()
|
|
{
|
|
rideCodeList_.clear();
|
|
uint8_t cardCount =
|
|
(uint8_t)MIN(TjdUiAppAlipayPresenter::GetInstance()->AlipayGetCardSum(), ALIPAY_TRANS_LIST_ITEM_LEN);
|
|
for (uint8_t i = 0; i < cardCount; i++) {
|
|
rideCodeList_.push_back(TjdUiAppAlipayPresenter::GetInstance()->AlipayGetCardTitle(i));
|
|
}
|
|
|
|
int i = 0;
|
|
int16_t startY = 45;
|
|
for (auto &item : rideCodeList_) {
|
|
AlipayRideCodeItem *rideCodeItem = nullptr;
|
|
if (rideItemList_[i].item == nullptr) {
|
|
rideCodeItem = new AlipayRideCodeItem();
|
|
Add(rideCodeItem);
|
|
} else {
|
|
rideCodeItem = rideItemList_[i].item;
|
|
}
|
|
rideCodeItem->SetPosition(23, startY + i * 128, 420, 110);
|
|
rideCodeItem->InitView(item.c_str());
|
|
rideCodeItem->SetViewIndex(i);
|
|
rideCodeItem->SetOnClickListener(this);
|
|
rideItemList_[i].desc = item;
|
|
rideItemList_[i].item = rideCodeItem;
|
|
// rideItemList_.push_back({item, rideCodeItem});
|
|
++i;
|
|
}
|
|
}
|
|
#pragma endregion
|
|
|
|
#pragma region 乘车码页面
|
|
static AlipayRideCodeView *g_pv_rideCodeView = nullptr;
|
|
|
|
AlipayRideCodeView::AlipayRideCodeView()
|
|
{
|
|
g_pv_rideCodeView = this;
|
|
Resize(OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_COLOR, 0xff1676FE);
|
|
SetStyle(OHOS::STYLE_BACKGROUND_OPA, 0xff);
|
|
|
|
InitLabelHorCenter(desc_, 40, 26, 466, "付款码");
|
|
uint8_t str[256] = {0};
|
|
TjdUiAppAlipayPresenter::GetInstance()->AlipayGetBindCode(str);
|
|
qrcode_.SetAutoEnable(false);
|
|
qrcode_.SetResizeMode(OHOS::UIImageView::ImageResizeMode::CENTER);
|
|
qrcode_.SetPosition(93, 100, 280, 280);
|
|
qrcode_.SetQrcodeInfo((const char *)str);
|
|
InitLabelHorCenter(switch_, 40, 390, 466, "切换交通卡");
|
|
switch_.SetTouchable(true);
|
|
switch_.SetViewId(ALIPAY_SWITCH_QRCODE_VIEWID);
|
|
switch_.SetOnClickListener(TjdUiAppAlipayPresenter::GetInstance());
|
|
|
|
Add(&desc_);
|
|
Add(&qrcode_);
|
|
Add(&switch_);
|
|
}
|
|
|
|
AlipayRideCodeView::~AlipayRideCodeView()
|
|
{
|
|
g_pv_rideCodeView = nullptr;
|
|
RemoveAll();
|
|
}
|
|
|
|
AlipayRideCodeView *AlipayRideCodeView::GetInstance() { return g_pv_rideCodeView; }
|
|
|
|
void AlipayRideCodeView::ShowQrcode(const char *desc, const char *qrcode, uint32_t len)
|
|
{
|
|
desc_.SetText(desc);
|
|
desc_.SetX(HorizontalCenter(desc_.GetWidth(), OHOS::HORIZONTAL_RESOLUTION));
|
|
qrcode_.SetQrcodeInfo((const uint8_t *)qrcode, len);
|
|
}
|
|
#pragma endregion
|
|
|
|
#pragma region 设置页面
|
|
AlipaySettingView::AlipaySettingView()
|
|
{
|
|
Resize(OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
|
|
uint8_t str[128] = {0};
|
|
uint8_t strID[128] = {0};
|
|
TjdUiAppAlipayPresenter::GetInstance()->AlipayGetNickName(str);
|
|
TjdUiAppAlipayPresenter::GetInstance()->AlipayGetIdName(strID);
|
|
|
|
InitLabelHorCenter(title_, 42, 24, 466, "设置");
|
|
InitLabelHorCenter(name_, 50, 123, 466, (const char *)str);
|
|
InitLabelHorCenter(email_, 42, 195, 466, (const char *)strID);
|
|
email_.SetStyle(OHOS::STYLE_TEXT_OPA, OHOS::OPA_OPAQUE * 0.5);
|
|
|
|
removeBind_.SetPosition(74, 278, 318, 100);
|
|
removeBind_.InitView(true, "解除绑定", 46);
|
|
removeBind_.SetViewId(ALIPAY_REMOVE_BIND_VIEWID);
|
|
removeBind_.SetOnClickListener(TjdUiAppAlipayPresenter::GetInstance());
|
|
|
|
Add(&title_);
|
|
Add(&name_);
|
|
Add(&email_);
|
|
Add(&removeBind_);
|
|
}
|
|
#pragma endregion
|
|
|
|
#pragma region 帮助页面
|
|
AlipayHelpView::AlipayHelpView()
|
|
{
|
|
Resize(OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
|
|
InitLabelHorCenter(desc_, 38, 113, 466, " 用户使用对应厂商\nAPP绑定后方可使用。");
|
|
enter_.SetPosition(72, 276, 318, 100);
|
|
enter_.InitView(true, "返回", 46);
|
|
enter_.SetViewId(ALIPAY_HELP_KNOWN_VIEWID);
|
|
enter_.SetOnClickListener(TjdUiAppAlipayPresenter::GetInstance());
|
|
|
|
Add(&desc_);
|
|
Add(&enter_);
|
|
}
|
|
#pragma endregion
|
|
|
|
#pragma region 解绑页面
|
|
AlipayUnBindView::AlipayUnBindView()
|
|
{
|
|
Resize(OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
|
|
InitLabelHorCenter(title_, 42, 24, 466, "解除绑定");
|
|
InitLabelHorCenter(desc_, 38, 130, 466, "解绑后将无法使用支付\n宝各项功能,确认解绑?");
|
|
|
|
enter_.SetPosition(36, 278, 182, 100);
|
|
enter_.InitView(false, "确认", 46);
|
|
enter_.SetViewId(ALIPAY_UNBIND_ENTER_VIEWID);
|
|
enter_.SetOnClickListener(TjdUiAppAlipayPresenter::GetInstance());
|
|
cancel_.SetPosition(249, 278, 182, 100);
|
|
cancel_.InitView(true, "取消", 46);
|
|
cancel_.SetViewId(ALIPAY_UNBIND_CANCEL_VIEWID);
|
|
cancel_.SetOnClickListener(TjdUiAppAlipayPresenter::GetInstance());
|
|
|
|
Add(&title_);
|
|
Add(&desc_);
|
|
Add(&enter_);
|
|
Add(&cancel_);
|
|
}
|
|
#pragma endregion
|
|
|
|
#pragma region 解绑成功页面
|
|
AlipayUnBindSucView::AlipayUnBindSucView()
|
|
{
|
|
Resize(OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
|
|
InitLabelHorCenter(desc_, 38, 96, 466, "设备侧已经解绑,\n请在手机支付宝上解绑\n该设备,完成解绑.");
|
|
enter_.SetPosition(72, 278, 318, 100);
|
|
enter_.InitView(true, "确定", 46);
|
|
enter_.SetViewId(ALIPAY_UNBIND_KNOWN_VIEWID);
|
|
enter_.SetOnClickListener(TjdUiAppAlipayPresenter::GetInstance());
|
|
|
|
Add(&desc_);
|
|
Add(&enter_);
|
|
}
|
|
#pragma endregion
|
|
|
|
#pragma region 错误页面
|
|
AlipayErrorMsgView::AlipayErrorMsgView()
|
|
{
|
|
Resize(OHOS::HORIZONTAL_RESOLUTION, OHOS::VERTICAL_RESOLUTION);
|
|
|
|
auto fail = OHOS::ImageCacheManager::GetInstance().LoadOneInMultiRes(IMG_ALIPAY_DEFEATED, ALIPAY_IMAGE_PATH);
|
|
errorIcon_.SetPosition(165, 38, 136, 136);
|
|
if (fail != nullptr) {
|
|
errorIcon_.SetSrc(fail);
|
|
}
|
|
|
|
errorDesc_.SetPosition(36, 197);
|
|
errorDesc_.SetFont(TJD_VECTOR_FONT_FILENAME, 34);
|
|
// errorDesc_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_WRAP);
|
|
errorDesc_.SetLineBreakMode(OHOS::UILabel::LINE_BREAK_ADAPT);
|
|
|
|
errorButton_.Resize(268, 70);
|
|
errorButton_.SetPosition(HorizontalCenter(268, 466), 338);
|
|
errorButton_.InitView(true, "确定", 42);
|
|
errorButton_.SetOnClickListener(this);
|
|
|
|
Add(&errorIcon_);
|
|
Add(&errorDesc_);
|
|
Add(&errorButton_);
|
|
}
|
|
|
|
bool AlipayErrorMsgView::OnClick(UIView &view, const OHOS::ClickEvent &event)
|
|
{
|
|
if (showIndex_ == AlipayViewIndex::ALIPAY_UNKNOWN) {
|
|
TjdUiAppAlipayView::currentViewIndex_ = AlipayViewIndex::ALIPAY_UNKNOWN;
|
|
TjdUiAppAlipayPresenter::GetInstance()->ViewExitEvent(false);
|
|
return false;
|
|
}
|
|
TjdUiAppAlipayView::GetInstance()->ShowView(showIndex_);
|
|
showIndex_ = AlipayViewIndex::ALIPAY_UNKNOWN;
|
|
return false;
|
|
}
|
|
|
|
void AlipayErrorMsgView::ShowErrorMsg(const char *desc, AlipayViewIndex showIndex)
|
|
{
|
|
errorDesc_.SetText(desc);
|
|
errorDesc_.SetX(HorizontalCenter(errorDesc_.GetWidth(), 466));
|
|
showIndex_ = showIndex;
|
|
}
|
|
#pragma endregion
|
|
|
|
bool AlipayUIScrollView::OnDragStartEvent(const OHOS::DragEvent &event)
|
|
{
|
|
if (TjdUiAppAlipayView::currentViewIndex_ != AlipayViewIndex::ALIPAY_BIND &&
|
|
TjdUiAppAlipayView::currentViewIndex_ != AlipayViewIndex::ALIPAY_LIST) {
|
|
return true;
|
|
}
|
|
|
|
isOnStart_ = true;
|
|
return OHOS::UIScrollViewNested::OnDragStartEvent(event);
|
|
}
|
|
|
|
bool AlipayUIScrollView::OnDragEvent(const OHOS::DragEvent &event)
|
|
{
|
|
if (!isOnStart_) {
|
|
return true;
|
|
}
|
|
|
|
if (TjdUiAppAlipayView::currentViewIndex_ != AlipayViewIndex::ALIPAY_BIND &&
|
|
TjdUiAppAlipayView::currentViewIndex_ != AlipayViewIndex::ALIPAY_LIST) {
|
|
return true;
|
|
}
|
|
|
|
return OHOS::UIScrollViewNested::OnDragEvent(event);
|
|
}
|
|
|
|
bool AlipayUIScrollView::OnDragEndEvent(const OHOS::DragEvent &event)
|
|
{
|
|
if (!isOnStart_) {
|
|
return true;
|
|
}
|
|
isOnStart_ = false;
|
|
|
|
if (TjdUiAppAlipayView::currentViewIndex_ != AlipayViewIndex::ALIPAY_BIND &&
|
|
TjdUiAppAlipayView::currentViewIndex_ != AlipayViewIndex::ALIPAY_LIST) {
|
|
return true;
|
|
}
|
|
|
|
return OHOS::UIScrollViewNested::OnDragEndEvent(event);
|
|
}
|
|
|
|
} // namespace TJD
|