Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
7
7_Eleven_Alipay
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
高淑倩
7_Eleven_Alipay
Commits
b7bf8464
Commit
b7bf8464
authored
Sep 23, 2019
by
高淑倩
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
跳转
parent
ad96a02e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
441 additions
and
170 deletions
+441
-170
bottom.js
component/bottom/bottom.js
+52
-50
imageSwiper.js
component/imageSwiper/imageSwiper.js
+55
-53
picNav.js
component/picNav/picNav.js
+69
-67
currentLinkRouter.js
utils/currentLinkRouter.js
+65
-0
integerDigitalConvertion.js
utils/integerDigitalConvertion.js
+200
-0
No files found.
component/bottom/bottom.js
View file @
b7bf8464
...
...
@@ -4,6 +4,7 @@ const Behavior = require('../../Behavior');
var
app
=
getApp
();
const
wxService
=
require
(
'../../utils/wxService'
);
const
utils
=
require
(
'../../utils/util'
);
const
utilLink
=
require
(
'../../utils/currentLinkRouter'
)
const
envInfo
=
require
(
'../../config/index'
).
envInfo
;
Component
({
...
...
@@ -54,60 +55,61 @@ Component({
let
isTouchLeft
=
utils
.
getTouchData
(
x
,
y
,
startX
,
startY
);
// 触发左划事件
if
(
isTouchLeft
==
'left'
)
{
const
{
appid
,
path
,
link
,
item
}
=
e
.
currentTarget
.
dataset
;
// 更改数据问题
let
currentClickType
=
app
.
globalData
.
commonFunc
.
getLink
(
item
.
link
.
type
,
item
);
const
userInfo
=
wx2my
.
getStorageSync
(
'_baseUserInfo'
);
// type==1 外部 不用弹 没有登录弹
utilLink
.
currentLinkRouter
(
e
,
this
)
// const {
// appid,
// path,
// link,
// item
// } = e.currentTarget.dataset;
// // 更改数据问题
// let currentClickType = app.globalData.commonFunc.getLink(item.link.type, item);
// const userInfo = wx2my.getStorageSync('_baseUserInfo'); // type==1 外部 不用弹 没有登录弹
if
(
link
.
type
==
1
)
{
// 触发父组件更新页面 外部小程序
this
.
setData
({
isAuthorization
:
false
});
return
false
;
}
else
if
(
!
userInfo
)
{
this
.
setData
({
isAuthorization
:
true
});
return
false
;
}
else
if
(
userInfo
&&
userInfo
.
member
&&
!
userInfo
.
member
.
mobile
)
{
wxService
.
openCard
();
return
false
;
}
// wxService.openCard()
//
if (link.type == 1) {
//
// 触发父组件更新页面 外部小程序
//
this.setData({
//
isAuthorization: false
//
});
//
return false;
//
} else if (!userInfo) {
//
this.setData({
//
isAuthorization: true
//
});
//
return false;
//
} else if (userInfo && userInfo.member && !userInfo.member.mobile) {
//
wxService.openCard();
//
return false;
//
} // wxService.openCard()
if
(
link
.
type
==
2
)
{
// 触发父组件更新页面
wxService
.
nextTick
(()
=>
{
this
.
triggerEvent
(
'updatePage'
,
{
pageId
:
currentClickType
.
url
});
});
}
else
if
(
link
.
type
==
3
)
{
// 预览
wx2my
.
previewImage
({
current
:
`
${
app
.
globalData
.
imageUrl
}
/
${
currentClickType
.
imageUrl
}
`
,
// 当前显示图片的http链接
urls
:
[
`
${
app
.
globalData
.
imageUrl
}
/
${
currentClickType
.
link
.
url
}
`
]
// 需要预览的图片http链接列表
//
if (link.type == 2) {
//
// 触发父组件更新页面
//
wxService.nextTick(() => {
//
this.triggerEvent('updatePage', {
//
pageId: currentClickType.url
//
});
//
});
//
} else if (link.type == 3) {
//
// 预览
//
wx2my.previewImage({
//
current: `${app.globalData.imageUrl}/${currentClickType.imageUrl}`,
//
// 当前显示图片的http链接
//
urls: [`${app.globalData.imageUrl}/${currentClickType.link.url}`] // 需要预览的图片http链接列表
});
}
else
if
(
link
.
type
==
4
)
{
wxService
.
router
(
`
${
currentClickType
}
`
);
}
else
if
(
link
.
type
==
5
)
{
if
(
currentClickType
==
1
)
{
// wxService.openCardList()
wxService
.
openCard
();
}
else
if
(
currentClickType
==
2
)
{
wxService
.
openCard
();
}
}
else
if
(
link
.
type
==
6
)
{
wxService
.
router
(
`
${
currentClickType
}
`
);
}
//
});
//
} else if (link.type == 4) {
//
wxService.router(`${currentClickType}`);
//
} else if (link.type == 5) {
//
if (currentClickType == 1) {
//
// wxService.openCardList()
//
wxService.openCard();
//
} else if (currentClickType == 2) {
//
wxService.openCard();
//
}
//
} else if (link.type == 6) {
//
wxService.router(`${currentClickType}`);
//
}
}
}
...
...
component/imageSwiper/imageSwiper.js
View file @
b7bf8464
...
...
@@ -4,6 +4,7 @@ const Behavior = require('../../Behavior');
var
app
=
getApp
();
const
wxService
=
require
(
'../../utils/wxService'
);
const
utils
=
require
(
'../../utils/util'
);
const
utilLink
=
require
(
'../../utils/currentLinkRouter'
)
const
envInfo
=
require
(
'../../config/index'
).
envInfo
;
Component
({
...
...
@@ -39,62 +40,63 @@ Component({
* 组件的方法列表
*/
methods
:
{
preview
(
e
)
{
const
{
appid
,
path
,
link
,
item
}
=
e
.
currentTarget
.
dataset
;
// 获取当前帐号信息
preview
(
event
)
{
utilLink
.
currentLinkRouter
(
event
,
this
)
// const {
// appid,
// path,
// link,
// item
// } = e.currentTarget.dataset; // 获取当前帐号信息
const
userInfo
=
wx2my
.
getStorageSync
(
'_baseUserInfo'
);
let
currentClickType
=
app
.
globalData
.
commonFunc
.
getLink
(
item
.
link
.
type
,
item
);
console
.
log
(
'0000'
,
link
.
type
,
currentClickType
)
if
(
link
.
type
==
1
)
{
// 触发父组件更新页面 外部小程序
this
.
setData
({
isAuthorization
:
false
});
return
false
;
}
else
if
(
!
userInfo
)
{
this
.
setData
({
isAuthorization
:
true
});
return
false
;
}
else
if
(
userInfo
&&
userInfo
.
member
&&
!
userInfo
.
member
.
mobile
)
{
wxService
.
openCard
();
return
false
;
}
//
const userInfo = wx2my.getStorageSync('_baseUserInfo');
//
let currentClickType = app.globalData.commonFunc.getLink(item.link.type, item);
//
console.log('0000', link.type, currentClickType )
//
if (link.type == 1) {
//
// 触发父组件更新页面 外部小程序
//
this.setData({
//
isAuthorization: false
//
});
//
return false;
//
} else if (!userInfo) {
//
this.setData({
//
isAuthorization: true
//
});
//
return false;
//
} else if (userInfo && userInfo.member && !userInfo.member.mobile) {
//
wxService.openCard();
//
return false;
//
}
if
(
link
.
type
==
2
)
{
// 触发父组件更新页面
wxService
.
nextTick
(()
=>
{
this
.
props
.
onUpdatePage
({
detail
:
{
pageId
:
currentClickType
.
url
}
});
});
}
else
if
(
link
.
type
==
3
)
{
// 预览
wx2my
.
previewImage
({
current
:
`
${
app
.
globalData
.
imageUrl
}
/
${
currentClickType
.
imageUrl
}
`
,
// 当前显示图片的http链接
urls
:
[
`
${
app
.
globalData
.
imageUrl
}
/
${
currentClickType
.
link
.
url
}
`
]
// 需要预览的图片http链接列表
//
if (link.type == 2) {
//
// 触发父组件更新页面
//
wxService.nextTick(() => {
//
this.props.onUpdatePage({
//
detail: {
//
pageId: currentClickType.url
//
}
//
});
//
});
//
} else if (link.type == 3) {
//
// 预览
//
wx2my.previewImage({
//
current: `${app.globalData.imageUrl}/${currentClickType.imageUrl}`,
//
// 当前显示图片的http链接
//
urls: [`${app.globalData.imageUrl}/${currentClickType.link.url}`] // 需要预览的图片http链接列表
});
}
else
if
(
link
.
type
==
4
)
{
wxService
.
router
(
`
${
currentClickType
}
`
);
}
else
if
(
link
.
type
==
5
)
{
if
(
currentClickType
==
1
)
{
// wxService.openCardList()
wxService
.
openCard
();
}
else
if
(
currentClickType
==
2
)
{
wxService
.
openCard
();
}
}
else
if
(
link
.
type
==
6
)
{
wxService
.
router
(
`
${
currentClickType
}
`
);
}
//
});
//
} else if (link.type == 4) {
//
wxService.router(`${currentClickType}`);
//
} else if (link.type == 5) {
//
if (currentClickType == 1) {
//
// wxService.openCardList()
//
wxService.openCard();
//
} else if (currentClickType == 2) {
//
wxService.openCard();
//
}
//
} else if (link.type == 6) {
//
wxService.router(`${currentClickType}`);
//
}
}
}
...
...
component/picNav/picNav.js
View file @
b7bf8464
...
...
@@ -4,6 +4,7 @@ const Behavior = require('../../Behavior');
var
app
=
getApp
();
const
wxService
=
require
(
'../../utils/wxService'
);
const
utils
=
require
(
'../../utils/util'
);
const
utilLink
=
require
(
'../../utils/currentLinkRouter'
)
const
envInfo
=
require
(
'../../config/index'
).
envInfo
;
Component
({
...
...
@@ -45,77 +46,78 @@ Component({
})
});
},
preview
(
e
)
{
const
{
appid
,
path
,
link
,
item
}
=
e
.
currentTarget
.
dataset
;
const
{
memberActivateStatus
}
=
wx2my
.
getStorageSync
(
'_baseUserInfo'
);
preview
(
event
)
{
utilLink
.
currentLinkRouter
(
event
,
this
)
// const {
// appid,
// path,
// link,
// item
// } = e.currentTarget.dataset;
// const {
// memberActivateStatus
// } = wx2my.getStorageSync('_baseUserInfo');
const
userInfo
=
wx2my
.
getStorageSync
(
'_baseUserInfo'
);
// 2019.06.14
// const userInfo = wx2my.getStorageSync('_baseUserInfo'); // 2019.06.14
// console.log('--userInfo', userInfo)
// let currentClickType = app.globalData.commonFunc.getLink(item.link.type, item);
let
currentClickType
=
app
.
globalData
.
commonFunc
.
getLink
(
item
.
link
.
type
,
item
);
// if (link.type == 1) {
// // 触发父组件更新页面 外部小程序
// this.setData({
// isAuthorization: false
// });
// return false;
// } else if (!userInfo) {
// // userInfo 不存在 授权弹框
// this.setData({
// isAuthorization: true
// });
// return false;
// }
if
(
link
.
type
==
1
)
{
// 触发父组件更新页面 外部小程序
this
.
setData
({
isAuthorization
:
false
});
return
false
;
}
else
if
(
!
userInfo
)
{
// userInfo 不存在 授权弹框
this
.
setData
({
isAuthorization
:
true
});
return
false
;
}
// if (link.type == 2) {
// // 触发父组件更新页面 内部子页面
// wxService.nextTick(() => {
// this.props.onUpdatePage({
// detail: {
// pageId: currentClickType.url
// }
// });
// });
// } else if (link.type == 3) {
// // 预览
// wx2my.previewImage({
// current: `${app.globalData.imageUrl}/${currentClickType.imageUrl}`,
// // 当前显示图片的http链接
// urls: [`${app.globalData.imageUrl}/${currentClickType.link.url}`] // 需要预览的图片http链接列表
if
(
link
.
type
==
2
)
{
// 触发父组件更新页面 内部子页面
wxService
.
nextTick
(()
=>
{
this
.
props
.
onUpdatePage
({
detail
:
{
pageId
:
currentClickType
.
url
}
});
});
}
else
if
(
link
.
type
==
3
)
{
// 预览
wx2my
.
previewImage
({
current
:
`
${
app
.
globalData
.
imageUrl
}
/
${
currentClickType
.
imageUrl
}
`
,
// 当前显示图片的http链接
urls
:
[
`
${
app
.
globalData
.
imageUrl
}
/
${
currentClickType
.
link
.
url
}
`
]
// 需要预览的图片http链接列表
});
}
else
if
(
link
.
type
==
4
)
{
// 内部固定功能
wxService
.
router
(
`
${
currentClickType
}
`
);
}
else
if
(
link
.
type
==
5
)
{
// 微信卡券 -- 卡包/领卡
if
(
currentClickType
==
1
)
{
wxService
.
openCard
();
}
else
if
(
currentClickType
==
2
)
{
// wxService.openCard()
if
(
userInfo
&&
userInfo
.
member
&&
userInfo
.
member
.
mobile
&&
!
userInfo
.
memberActivateStatus
)
{
// 手机号存在 但未激活 跳转激活领卡页面 老用户
this
.
setData
({
isAuthorizationActiveText
:
'新激活领卡'
,
isAuthorization
:
true
,
isAuthorizationType
:
3
},
()
=>
{
return
false
;
});
}
else
{
wxService
.
openCard
();
}
}
}
else
if
(
link
.
type
==
6
)
{
wxService
.
router
(
`
${
currentClickType
}
`
);
}
// });
// } else if (link.type == 4) {
// // 内部固定功能
// wxService.router(`${currentClickType}`);
// } else if (link.type == 5) {
// // 微信卡券 -- 卡包/领卡
// if (currentClickType == 1) {
// wxService.openCard();
// } else if (currentClickType == 2) {
// // wxService.openCard()
// if (userInfo && userInfo.member && userInfo.member.mobile && !userInfo.memberActivateStatus) {
// // 手机号存在 但未激活 跳转激活领卡页面 老用户
// this.setData({
// isAuthorizationActiveText: '新激活领卡',
// isAuthorization: true,
// isAuthorizationType: 3
// }, () => {
// return false;
// });
// } else {
// wxService.openCard();
// }
// }
// } else if (link.type == 6) {
// wxService.router(`${currentClickType}`);
// }
},
activeTocard
(
e
)
{
...
...
utils/currentLinkRouter.js
0 → 100644
View file @
b7bf8464
const
wxService
=
require
(
'./wxService'
)
const
app
=
getApp
()
function
currentLinkRouter
(
event
,
_this
)
{
const
ev
=
event
.
currentTarget
.
dataset
;
let
curItemType
=
ev
.
item
const
userInfo
=
my
.
getStorageSync
(
'_baseUserInfo'
)
// link row
if
(
curItemType
.
link
)
{
let
currentClickType
=
app
.
globalData
.
commonFunc
.
getLink
(
curItemType
.
link
.
type
,
curItemType
)
if
(
curItemType
.
link
.
type
==
1
)
{
// 触发父组件更新页面 外部小程序
}
else
if
(
curItemType
.
link
.
type
==
2
)
{
// 触发父组件更新页面
wxService
.
nextTick
(()
=>
{
_this
.
triggerEvent
(
'updatePage'
,
{
pageId
:
currentClickType
.
url
})
})
}
else
if
(
curItemType
.
link
.
type
==
3
)
{
// 预览
wx
.
previewImage
({
current
:
`
${
app
.
globalData
.
imageUrl
}
/
${
currentClickType
.
imageUrl
}
`
,
// 当前显示图片的http链接
urls
:
[
`
${
app
.
globalData
.
imageUrl
}
/
${
currentClickType
.
link
.
url
}
`
]
// 需要预览的图片http链接列表
})
}
else
if
(
curItemType
.
link
.
type
==
4
)
{
wxService
.
router
(
`
${
currentClickType
}
`
)
}
else
if
(
curItemType
.
link
.
type
==
5
)
{
if
(
currentClickType
==
1
)
{
wxService
.
openCard
()
}
else
if
(
currentClickType
==
2
)
{
wxService
.
openCard
()
}
}
else
if
(
curItemType
.
link
.
type
==
6
)
{
wxService
.
router
(
`
${
currentClickType
}
`
)
}
else
if
(
curItemType
.
link
.
type
==
7
)
{
// 集点详情
wxService
.
router
(
`
${
currentClickType
}
`
)
}
}
else
if
(
curItemType
.
row
)
{
let
rowObj
=
typeof
(
curItemType
.
row
)
==
"string"
?
JSON
.
parse
(
curItemType
.
row
)
:
curItemType
.
row
let
currentClickRow
=
app
.
globalData
.
commonFunc
.
getLinkRow
(
rowObj
.
type
,
rowObj
)
if
(
rowObj
.
type
==
1
)
{
}
else
if
(
rowObj
.
type
==
2
)
{
}
else
if
(
rowObj
.
type
==
3
)
{
}
else
if
(
rowObj
.
type
==
4
)
{
}
else
if
(
rowObj
.
type
==
5
)
{
}
else
if
(
rowObj
.
type
==
6
)
{
}
else
if
(
rowObj
.
type
==
7
)
{
}
else
if
(
rowObj
.
type
==
8
)
{
// 商品
wxService
.
router
(
`/pages/productDetail/productDetail?id=
${
currentClickRow
}
`
)
}
else
if
(
rowObj
.
type
==
9
)
{
// 分类
wxService
.
router
(
`/subPackage/page/pages/categoryPro/categoryPro?
${
currentClickRow
}
`
)
}
}
}
module
.
exports
=
{
currentLinkRouter
:
currentLinkRouter
}
\ No newline at end of file
utils/integerDigitalConvertion.js
0 → 100644
View file @
b7bf8464
// 10进制 64进制互转
var
Integer
=
Integer
||
{};
(
function
()
{
/**
* 进制字符串
*/
var
scaleChars
=
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz()"
;
/**
* 向前补零 "1",5 -> "00001"
* @param {String} n 整数字符串
* @param {Number} len 长度
* @return {String} 返回补零后的字符串
*/
function
fullZero
(
n
,
len
)
{
return
new
Array
(
len
-
n
.
length
+
1
).
join
(
"0"
)
+
n
;
}
/**
* 清理整数前面无效的零 "000000001" -> "1"
* @param {String} n 整数字符串
* @return {String} 返回格式化后的整数字符串
*/
function
format
(
n
)
{
return
n
.
replace
(
/^0+
(
.+
)
$/
,
"$1"
);
}
/**
* 比较两个整数的大小 "1","0" -> +1
* @param {String} a
* @param {String} b
* @return {Number} a>b返回+1,a==b返回0,a<b返回-1
*/
function
compare
(
a
,
b
)
{
var
i
=
Math
.
max
(
a
.
length
,
b
.
length
),
ta
,
tb
;
a
=
fullZero
(
a
,
i
);
b
=
fullZero
(
b
,
i
);
for
(
i
=
0
;
i
<
a
.
length
;
i
++
)
{
ta
=
scaleChars
.
indexOf
(
a
.
charAt
(
i
));
tb
=
scaleChars
.
indexOf
(
b
.
charAt
(
i
));
if
(
ta
<
tb
)
return
-
1
;
if
(
ta
>
tb
)
return
+
1
;
}
return
0
;
}
//console.log(compare("01", "1"));
//console.log(compare("0a1", "ab1"));
/**
* 无限进制的加法
* @param {String} a 整数1
* @param {String} b 整数2
* @param {Number} scale 进制 2-64
* @return {String} 返回两个数的和
*/
function
add
(
a
,
b
,
scale
)
{
if
(
scale
<
2
||
scale
>
64
)
return
;
a
=
format
(
a
);
b
=
format
(
b
);
var
i
=
Math
.
max
(
a
.
length
,
b
.
length
),
t
=
0
,
result
=
[];
a
=
fullZero
(
a
,
i
);
b
=
fullZero
(
b
,
i
);
while
(
i
--
)
{
t
+=
scaleChars
.
indexOf
(
a
.
charAt
(
i
));
t
+=
scaleChars
.
indexOf
(
b
.
charAt
(
i
));
result
.
unshift
(
scaleChars
.
charAt
(
t
%
scale
));
t
=
t
/
scale
;
}
if
(
t
)
result
.
unshift
(
scaleChars
.
charAt
(
t
%
scale
));
return
format
(
result
.
join
(
""
));
}
//console.log(add("19", "1234", 10));
/**
* 无限位数乘法函数,单个数乘无限进制整数
* @param {String} n 整数
* @param {Number} b 单个数
* @param {Number} scale 进制 2-64
* @return {String} 返回n和b的乘积
*/
function
byteMult
(
n
,
b
,
scale
)
{
//if (scale < 2 || scale > 64) return;
var
result
=
[],
t
=
0
,
i
=
n
.
length
;
while
(
i
--
)
{
t
=
scaleChars
.
indexOf
(
n
.
charAt
(
i
))
*
b
+
t
;
result
.
unshift
(
scaleChars
.
charAt
(
t
%
scale
));
t
=
t
/
scale
;
}
if
(
t
)
result
.
unshift
(
scaleChars
.
charAt
(
t
%
scale
));
return
result
.
join
(
""
);
}
//console.log(byteMult("555", 12, 10));
//console.log(byteMult("25", 8, 10));
/**
* 无限整数乘法
* @param {String} a 整数1
* @param {String} b 整数2
* @param {Number} scale 进制 2-64
* @return {String} 返回两个数的乘积
*/
function
mult
(
a
,
b
,
scale
)
{
if
(
scale
<
2
||
scale
>
64
)
return
;
a
=
format
(
a
);
b
=
format
(
b
);
var
t
=
""
,
result
=
""
,
i
=
b
.
length
;
while
(
i
--
)
{
result
=
add
(
result
,
byteMult
(
a
,
scaleChars
.
indexOf
(
b
.
charAt
(
i
)),
scale
)
+
t
,
scale
);
t
+=
"0"
;
}
return
result
;
}
//console.log(mult("555", "12", 10)); // 6660
//console.log(mult("25", "8", 10)); // 200
/**
* 无限整数的次方
* @param {String} base 指数
* @param {String} exponent 幂数
* @param {Number} scale 进制 2-64
* @return {String} 返回base的exponent次方
*/
function
power
(
base
,
exponent
,
scale
)
{
if
(
scale
<
2
||
scale
>
64
||
exponent
<
0
)
return
;
base
=
format
(
base
);
var
result
=
"1"
,
i
=
exponent
;
while
(
i
--
)
{
result
=
mult
(
result
,
base
,
scale
);
}
return
result
;
}
//console.log(power("2", 10, 10)); // 1024
/**
* 将一个字符转换为指定进制
* @param {String} c 单个字符
* @param {Number} from 来源进制 2-64
* @param {Number} to 目标进制 2-64
* @return {String} 返回转换后的数字
*/
function
charDigit
(
c
,
from
,
to
)
{
//if (from == to || from < 2 || from > 64 || to < 2 || to > 64 || c == "0") return c;
var
result
=
"0"
,
t
=
"0"
;
while
(
compare
(
t
,
c
)
<
0
)
{
result
=
add
(
result
,
"1"
,
to
);
t
=
add
(
t
,
"1"
,
from
);
}
return
result
;
}
//console.log(charDigit("7", 10, 2)); // 111
/**
* 进制间的转换
* @param {String} n 整数
* @param {Number} from 来源进制 2-64
* @param {Number} to 目标进制 2-64
* @return {String} 返回转换后的数字
*/
function
digit
(
n
,
from
,
to
)
{
if
(
from
==
to
||
from
<
2
||
from
>
64
||
to
<
2
||
to
>
64
)
return
n
;
n
=
format
(
n
);
if
(
n
==
"0"
)
return
n
;
var
result
=
""
,
base
=
"1"
,
t
=
"1"
,
m
=
scaleChars
.
charAt
(
from
-
1
),
l
=
n
.
length
,
i
;
while
(
compare
(
t
,
m
)
<=
0
)
{
base
=
add
(
base
,
"1"
,
to
);
t
=
add
(
t
,
"1"
,
from
);
}
for
(
i
=
0
;
i
<
l
;
i
++
)
{
result
=
add
(
result
,
mult
(
charDigit
(
n
.
charAt
(
l
-
i
-
1
),
from
,
to
),
power
(
base
,
i
,
to
),
to
),
to
);
}
return
result
;
}
//console.log(digit("1024", 10, 2)); // 10000000000
//console.log(digit("7", 10, 2)); // 111
//console.log(digit("askdjfas91231as", 64, 7)); // 43425343430315560320062336416102
//console.log(digit(digit("askdjfas91231as", 64, 7), 7, 64)); // askdjfas91231as
// 公开接口
Integer
.
add
=
add
;
Integer
.
mult
=
mult
;
Integer
.
power
=
power
;
Integer
.
digit
=
digit
;
})();
// 使用方式
// Integer.digit('611935532804608000',10,64) // 返回结果 X(21)wGX00 10进制转64
//Integer.digit('X(21)wGX00',64,10)
// export default Integer;
module
.
exports
=
{
Integer
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment