tools.ts 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654
  1. import { config } from "../config/config";
  2. import { book_item_data, chapter_item_data, order_status_info_data, user_data } from "../data/data";
  3. import { BookshelfManager } from "../stores/bookshelfManager";
  4. import { ReadHistoryManager } from "../stores/readHistoryManager";
  5. import { ReadSetting } from "../stores/readSetting";
  6. import { ReadRecord } from "../stores/readRecordManager";
  7. import { UserData } from "../stores/userDataManager";
  8. import { UserStatus } from "../stores/userStatusManager";
  9. import { http } from "./http";
  10. import { log } from "./log";
  11. import { sdkUtil } from "./sdkUtil";
  12. import { util } from "./util";
  13. export class tools {
  14. public static platform:string = config.Platform.H5
  15. public static initPlatform(){
  16. // #ifdef MP-WEIXIN
  17. config.applet_id = config.applet_id_config.wx
  18. tools.platform = config.Platform.WEIXIN
  19. //微信初始化设置显示分享弹窗,右上角'···'才可以转发给朋友,复制链接
  20. wx.showShareMenu({
  21. withShareTicket: true,
  22. menus: ['shareAppMessage', 'shareTimeline']
  23. });
  24. // #endif
  25. // #ifdef MP-TOUTIAO
  26. config.applet_id = config.applet_id_config.dy
  27. tools.platform = config.Platform.TOUTIAO
  28. // #endif
  29. log.Debug("当前运行平台:",tools.platform)
  30. }
  31. // 获取当前平台
  32. public static getCurPlatform(){
  33. return tools.platform
  34. }
  35. // 获取平台标识
  36. public static getPlatformID():string {
  37. let id = 'browser'
  38. switch (tools.getCurPlatform()){
  39. case config.Platform.WEIXIN:
  40. id = 'wx'
  41. break;
  42. case config.Platform.TOUTIAO:
  43. id = 'douyin'
  44. break;
  45. default:
  46. break;
  47. }
  48. return id
  49. }
  50. // 获取版本号
  51. public static getVersion():string {
  52. let version = ''
  53. switch (tools.getCurPlatform()){
  54. case config.Platform.H5:
  55. version = '1.0'
  56. break;
  57. case config.Platform.WEIXIN:
  58. version = config.version
  59. break;
  60. case config.Platform.TOUTIAO:
  61. break;
  62. default:
  63. break;
  64. }
  65. return version
  66. }
  67. // 获取订单状态信息
  68. public static getOrderStatusInfo(type:number):order_status_info_data {
  69. if(!type) {type = config.order_status.PAYING}
  70. let info_data = new order_status_info_data()
  71. switch (type){
  72. case config.order_status.PAYING:
  73. info_data.title = '支付中'
  74. info_data.bg_color = '#FDCC22'
  75. break;
  76. case config.order_status.HAVE_PAY:
  77. info_data.title = '已支付'
  78. info_data.bg_color = '#93DB6B'
  79. break;
  80. case config.order_status.CANCEL:
  81. info_data.title = '已取消'
  82. info_data.bg_color = '#999999'
  83. break;
  84. case config.order_status.REFUNDED:
  85. info_data.title = '已退款'
  86. info_data.bg_color = '#f26438'
  87. break;
  88. default:
  89. break;
  90. }
  91. return info_data
  92. }
  93. // 请求获取用户open_id
  94. private static requestGetUserOpenId(cb:Function) {
  95. sdkUtil.login((res:any)=>{
  96. if(res!=null) {
  97. let url = ''
  98. switch (tools.getCurPlatform()){
  99. case config.Platform.TOUTIAO:
  100. url = config.url_confg.Dynamic.user_get_douyin_openid
  101. break;
  102. case config.Platform.WEIXIN:
  103. url = config.url_confg.Dynamic.user_get_wx_open_id
  104. break;
  105. default:
  106. break;
  107. }
  108. http.DynamicRequest(url,res,(err,data)=>{
  109. if(!err) {
  110. if(data.code==config.url_confg.StatesCode.SUCCESS){
  111. cb && cb(data.content.openid)
  112. }
  113. }
  114. })
  115. } else {
  116. cb && cb('browser_123')
  117. }
  118. })
  119. }
  120. // 登录
  121. public static requestLogin(cb:Function=null) {
  122. tools.requestGetUserOpenId((open_id:string)=>{
  123. let opt = {'open_id':open_id, 'platform':tools.getPlatformID()}
  124. http.DynamicRequest(config.url_confg.Dynamic.user_login,opt, (err,data)=>{
  125. if(!err) {
  126. if(data.code==config.url_confg.StatesCode.SUCCESS){
  127. console.log('登录成功=',data)
  128. UserData().updateUserData(data.content)
  129. uni.$emit(config.EVENT_TYPE.USER_LOGIN_SUCCESS)
  130. cb && cb()
  131. } else{
  132. console.log('登录失败=',data)
  133. }
  134. } else {
  135. log.Error(err)
  136. }
  137. })
  138. })
  139. }
  140. // 进入书详情
  141. public static value_gotoBookdetails_data = null
  142. public static gotoBookdetails(book_id:number,wx_book_id:string, cb:Function=null) {
  143. if(book_id) {
  144. tools.value_gotoBookdetails_data = {'book_id':book_id}
  145. if(tools.getCurPlatform()==config.Platform.WEIXIN){
  146. util.showLoading()
  147. let url = config.url_confg.Static.book_details(book_id)
  148. http.StaticRequest(url,(err=null,data=null)=>{
  149. util.hideLoading()
  150. if(!err&&data) {
  151. if(data.code==config.url_confg.StatesCode.SUCCESS){
  152. var book_data = new book_item_data()
  153. book_data = data.content
  154. console.log("book_data",book_data)
  155. UserStatus().updateUserSelectBook(book_data)
  156. ReadHistoryManager.checkBookOnReadHistory(book_data.book_id,(index)=>{
  157. if(index==-1){
  158. tools.updateReadHistory(book_data)
  159. }
  160. })
  161. wx.redirectTo({
  162. url: `plugin-private://wx293c4b6097a8a4d0/pages/novel/index?bookId=${book_data.wx_book_id}`
  163. });
  164. }
  165. }
  166. })
  167. }else{
  168. uni.navigateTo({
  169. url:'/pagesA/bookdetails/bookdetails',
  170. success: (res) => {
  171. res.eventChannel.emit('data',{'book_id':book_id})
  172. cb && cb()
  173. }
  174. })
  175. }
  176. } else {
  177. log.Error('书详情id错误')
  178. }
  179. }
  180. // 进入查看更多
  181. public static value_gotoSeeMore_data = null
  182. public static gotoSeeMore(id:number) {
  183. if(id) {
  184. tools.value_gotoSeeMore_data = {'id':id}
  185. uni.navigateTo({
  186. url:'/pagesA/seeMore/seeMore'
  187. })
  188. } else {
  189. log.Error('查看更多id错误')
  190. }
  191. }
  192. // 进入webview
  193. public static value_gotoWebview = null
  194. public static gotoWebview(title:string, html:string) {
  195. if(html) {
  196. tools.value_gotoWebview = {'title':title,'html':html}
  197. uni.navigateTo({
  198. url:'/pagesA/webview/webview'
  199. })
  200. } else {
  201. log.Error('进入webview链接错误')
  202. }
  203. }
  204. // 进入阅读
  205. public static gotoRead(book_data:book_item_data, chapter_id:number=-1) {
  206. // console.log('book_data=',book_data)
  207. // 获取上次开始阅读章节id
  208. if(chapter_id==-1) {
  209. let read_record_data = ReadRecord().getReadRecordData(book_data.book_id)
  210. if(read_record_data) {
  211. book_data.start_read_chapter_id = read_record_data.chapter_id
  212. } else {
  213. book_data.start_read_chapter_id = 1
  214. }
  215. console.log('开始阅读-获取上次章节id=',book_data.start_read_chapter_id)
  216. } else {
  217. book_data.start_read_chapter_id = chapter_id
  218. console.log('开始阅读-指定章节id=',chapter_id)
  219. }
  220. // 更新用户选择书
  221. UserStatus().updateUserSelectBook(book_data)
  222. // 更新阅读历史
  223. tools.updateReadHistory(book_data)
  224. // 跳转
  225. uni.navigateTo({
  226. url:'/pagesA/readbook/read'
  227. })
  228. }
  229. // 退出阅读
  230. public static exitRead() {
  231. let book_data = UserStatus().getUserSelectBook()
  232. // 更新:书架,读到当前章节数据
  233. uni.$emit(config.EVENT_TYPE.UPDATE_BOOKSHELF_CURRENT_READ_CHAPTER,book_data)
  234. }
  235. // 获取用户信息
  236. public static getUserData():user_data {
  237. return UserData().getData()
  238. }
  239. // 获取用户是否VIP
  240. public static getUserIsVIP():boolean {
  241. return tools.getUserData().is_vip
  242. }
  243. // 获取请求书架参数
  244. public static getRequestBookshelfParameter(book_data:book_item_data) {
  245. let book_opt = {
  246. 'book_id':book_data.book_id,
  247. 'start_read_chapter_id':book_data.start_read_chapter_id}
  248. return book_opt
  249. }
  250. /*
  251. * 请求书架
  252. * books_shelf: json
  253. * stype: int 类型 1:获取 2:同步书架
  254. */
  255. public static requestBookShelf(book_list:book_item_data[], stype:number, successs_cb:Function, falil_cb:Function) {
  256. let books_shelf_string = ''
  257. if(book_list.length>0) {
  258. books_shelf_string = JSON.stringify(book_list)
  259. }
  260. let opt = {'books_shelf':books_shelf_string, 'stype':stype}
  261. http.DynamicRequest(config.url_confg.Dynamic.books_shelf, opt, (err,data)=>{
  262. // console.log('err=',err,'data=',data)
  263. if(!err) {
  264. if(data.code==config.url_confg.StatesCode.SUCCESS){
  265. successs_cb && successs_cb(data.content)
  266. } else {
  267. falil_cb && falil_cb()
  268. }
  269. } else {
  270. log.Error(err)
  271. falil_cb && falil_cb()
  272. }
  273. })
  274. }
  275. // 获取本地书架列表
  276. public static getLocalBookshelfList():book_item_data[] {
  277. return BookshelfManager.getBookList()
  278. }
  279. // 保存本地书架列表
  280. public static saveLocalBookshelfList() {
  281. BookshelfManager.saveLocalBookList()
  282. }
  283. // 检查在书架(异步)
  284. public static checkBookOnBookshelf(book_id:number, cb:Function) {
  285. BookshelfManager.checkBookOnBookshelf(book_id, (is_on:boolean)=>{
  286. cb && cb(is_on)
  287. })
  288. }
  289. // 检查在书架(同步)
  290. public static syncCheckBookOnBookshelf(book_id:number):boolean {
  291. return BookshelfManager.syncCheckBookOnBookshelf(book_id)
  292. }
  293. // 添加书架
  294. public static addBookshelf(book_data:book_item_data, cb:Function=null) {
  295. util.showLoading('加载中...', true)
  296. // 获取阅读记录
  297. let record_data = ReadRecord().getReadRecordData(book_data.book_id)
  298. if(record_data) {
  299. book_data.start_read_chapter_id = record_data.chapter_id
  300. } else {
  301. if(!book_data.start_read_chapter_id) {
  302. book_data.start_read_chapter_id = 1
  303. }
  304. }
  305. // 本地添加书
  306. BookshelfManager.addBook(book_data)
  307. // 请求
  308. let data_list = []
  309. for (let i = 0; i < BookshelfManager.getBookList().length; i++) {
  310. let element = BookshelfManager.getBookList()[i]
  311. data_list.push(tools.getRequestBookshelfParameter(element))
  312. }
  313. tools.requestBookShelf(data_list,2,()=>{
  314. console.log('同步书架(加入)-成功')
  315. util.hideLoading()
  316. uni.$emit(config.EVENT_TYPE.UPDATE_BOOKSHELF)
  317. cb && cb()
  318. },()=>{
  319. util.hideLoading()
  320. })
  321. }
  322. // 删除书架
  323. public static deleteBookshelf(book_id_list:number[], cb:Function=null) {
  324. util.showModal('删除?', `从书架删除这${book_id_list.length}本书?`, ()=>{
  325. util.showLoading('移除书架...', true)
  326. // 本地删除书
  327. BookshelfManager.deleteBook(book_id_list)
  328. // 请求
  329. let data_list = []
  330. for (let i = 0; i < book_id_list.length; i++) {
  331. let book_id = book_id_list[i]
  332. let book_data = new book_item_data()
  333. book_data.book_id = book_id
  334. book_data.start_read_chapter_id = 1
  335. data_list.push(tools.getRequestBookshelfParameter(book_data))
  336. }
  337. // 本地阅读记录删除
  338. ReadRecord().deleteReadRecordData(book_id_list)
  339. // 请求
  340. tools.requestBookShelf(data_list,2,()=>{
  341. console.log('同步书架(删除)-成功')
  342. util.hideLoading()
  343. uni.$emit(config.EVENT_TYPE.UPDATE_BOOKSHELF)
  344. cb && cb()
  345. },()=>{
  346. util.hideLoading()
  347. })
  348. })
  349. }
  350. // 重置排序书架
  351. public static resetSortBookshelf(book_list:book_item_data[]) {
  352. BookshelfManager.resetData(book_list)
  353. }
  354. // 获取本地阅读历史列表
  355. public static getLocalReadHistoryList():book_item_data[] {
  356. return ReadHistoryManager.getBookList()
  357. }
  358. // 更新阅读历史
  359. public static updateReadHistory(book_data:book_item_data) {
  360. ReadHistoryManager.addBook(book_data, ()=>{
  361. uni.$emit(config.EVENT_TYPE.UPDATE_READHISTORY)
  362. })
  363. }
  364. // 删除阅读历史
  365. public static deleteReadHistory(book_id_list:number[]) {
  366. ReadHistoryManager.deleteBook(book_id_list)
  367. }
  368. // 重置排序阅读历史
  369. public static resetSortReadHistory(book_list:book_item_data[]) {
  370. ReadHistoryManager.resetData(book_list)
  371. }
  372. public static getChapterList(chapter_path:string,cb:Function){
  373. let url = `${config.url_addr.Static}${chapter_path}`
  374. http.StaticRequest(url,(err,data)=>{
  375. if(err){
  376. return
  377. }
  378. cb(data)
  379. })
  380. }
  381. public static getCurChapterTxt(base_path:string,chapter_id:number,emspWidth:number,cb:Function){
  382. if(chapter_id){
  383. let url = `${config.url_addr.Static}${base_path}${chapter_id}.txt`
  384. http.getStaticText(url,(err,data)=>{
  385. if(err){
  386. log.Error(err)
  387. return
  388. }
  389. // log.Debug("getCurChapterTxt",data)
  390. cb(tools.autoParagraph(data,emspWidth))
  391. // cb(data)
  392. })
  393. }
  394. }
  395. public static autoParagraph(text:string,emspWidth:number) {
  396. const emspStyle = `style="margin-left: ${emspWidth}px;"`;
  397. const emsp_html = `<span ${emspStyle}></span>`;
  398. const character = `<br><br>${emsp_html}`;
  399. return emsp_html+text.replace(/\n\s*/g,character)
  400. }
  401. public static autoParagraphTitle(text:string,emspWidth:number) {
  402. const emspStyle = `style="margin-left: ${emspWidth}px;"`;
  403. const emsp_html = `<span ${emspStyle}></span>`;
  404. return `<br><br>`+emsp_html+text
  405. }
  406. public static getChapter(cur_chapter_id:number,list:chapter_item_data[]){
  407. return list.find(chapter_data=>cur_chapter_id==chapter_data.id)
  408. }
  409. public static getPreChapterData(index:number,list:chapter_item_data[]){
  410. let new_index = index -1
  411. if( new_index <0 ){
  412. return null
  413. }
  414. return list[new_index]
  415. }
  416. public static getCurChapterData(index:number,list:chapter_item_data[]):chapter_item_data{
  417. if(index<list.length&&index>=0){
  418. return list[index]
  419. }
  420. log.Error("getCurChapterData error ",index)
  421. return null
  422. }
  423. public static getNextChapterData(index:number,list:chapter_item_data[]){
  424. let new_index = index +1
  425. if( new_index >=list.length ){
  426. return null
  427. }
  428. return list[new_index]
  429. }
  430. public static getCurChapterIndex(chapter_id:number,list:chapter_item_data[]){
  431. return list.findIndex(chapter_data=>chapter_id==chapter_data.id)
  432. }
  433. public static getFontColorByMode(mode:number){
  434. if(mode==config.read_config.readMode.Bright){
  435. return config.read_config.BrightFontColor
  436. }else{
  437. return config.read_config.DarkFontColor
  438. }
  439. }
  440. public static getDbColorByMode(mode:number){
  441. if(mode==config.read_config.readMode.Bright){
  442. return config.read_config.BrightDbColor
  443. }else{
  444. return config.read_config.DarkDbColor
  445. }
  446. }
  447. public static book_status_title(book_data:book_item_data){
  448. if(book_data.book_is_action==1){
  449. return `连载至 第${book_data.chapter_count}章`
  450. }else{
  451. return `已完结 共${book_data.chapter_count}章`
  452. }
  453. }
  454. public static check_book_chapter_is_buy(book_id:number,chapter_id:number,cb:Function){
  455. http.DynamicRequest(config.url_confg.Dynamic.get_user_chapter_ids,{'book_id':book_id},(err,d)=>{
  456. if(d.code==config.url_confg.StatesCode.SUCCESS){
  457. cb(d.content.includes(chapter_id))
  458. }else{
  459. cb(false)
  460. }
  461. })
  462. }
  463. public static get_book_un_lock_list(book_id:number,cb:Function){
  464. http.DynamicRequest(config.url_confg.Dynamic.get_user_chapter_ids,{'book_id':book_id},(err,d)=>{
  465. if(d.code==config.url_confg.StatesCode.SUCCESS){
  466. cb(d.content)
  467. }else{
  468. cb(null)
  469. }
  470. })
  471. }
  472. public static getCurBuyType(){
  473. let type = config.pay_type.NEI_BU;
  474. switch (tools.getCurPlatform()){
  475. case config.Platform.WEIXIN:
  476. type = config.pay_type.WEI_XIN
  477. break;
  478. case config.Platform.TOUTIAO:
  479. type = config.pay_type.DOU_YIN
  480. break;
  481. default:
  482. break;
  483. }
  484. return type
  485. }
  486. public static getBgResByIndex(index:number,select_index:number){
  487. if(ReadSetting().getReadSetting().readMode==config.read_config.readMode.Dark){
  488. return config.read_config.colorBgResList[index].off_res
  489. }
  490. if(index==select_index){
  491. return config.read_config.colorBgResList[index].on_res
  492. }
  493. return config.read_config.colorBgResList[index].off_res
  494. }
  495. // public static getWxBookId(book_id:number){
  496. // var temp = [
  497. // {"book_id": 1, "wx_book_id": "A1HcfuuvhA6S7Nqy3f97nTixyb"},
  498. // {"book_id": 2, "wx_book_id": "A1Hcfuwb1iw9PakEYJz8wGWN4V"},
  499. // {"book_id": 3, "wx_book_id": "A1HcfuuvKqNdTuMD9y9bTAinvh"},
  500. // {"book_id": 4, "wx_book_id": "A1HcfuyDVgAqSRAiaWsYRcGttu"},
  501. // {"book_id": 5, "wx_book_id": "A1Hcfuzo33e6KTd9VCpmFc23L9"},
  502. // {"book_id": 6, "wx_book_id": "A1Hcfuzp91oWFt7RAGoLFV2ZUq"},
  503. // {"book_id": 7, "wx_book_id": "A1HcfuzqEyxvCJbgqLmuFN35dX"},
  504. // {"book_id": 8, "wx_book_id": "A1Hcfv2QnMSB5M47k2j85MnE4m"},
  505. // {"book_id": 9, "wx_book_id": "A1Hcfv2RtKbb1mYPR6hh5EnkDT"},
  506. // {"book_id": 10, "wx_book_id": "A1Hcfv2SzHkzxC2f6AgG57oGN9"}
  507. // ];
  508. // for (var i = 0; i < temp.length; i++) {
  509. // if(temp[i].book_id==book_id){
  510. // return temp[i].wx_book_id
  511. // }
  512. // }
  513. // return null
  514. // }
  515. public static getBookIdByWxBookId(wx_book_id:string,cb){
  516. // var temp = [
  517. // {"book_id": 1, "wx_book_id": "A1HcfuuvhA6S7Nqy3f97nTixyb"},
  518. // {"book_id": 2, "wx_book_id": "A1Hcfuwb1iw9PakEYJz8wGWN4V"},
  519. // {"book_id": 3, "wx_book_id": "A1HcfuuvKqNdTuMD9y9bTAinvh"},
  520. // {"book_id": 4, "wx_book_id": "A1HcfuyDVgAqSRAiaWsYRcGttu"},
  521. // {"book_id": 5, "wx_book_id": "A1Hcfuzo33e6KTd9VCpmFc23L9"},
  522. // {"book_id": 6, "wx_book_id": "A1Hcfuzp91oWFt7RAGoLFV2ZUq"},
  523. // {"book_id": 7, "wx_book_id": "A1HcfuzqEyxvCJbgqLmuFN35dX"},
  524. // {"book_id": 8, "wx_book_id": "A1Hcfv2QnMSB5M47k2j85MnE4m"},
  525. // {"book_id": 9, "wx_book_id": "A1Hcfv2RtKbb1mYPR6hh5EnkDT"},
  526. // {"book_id": 10, "wx_book_id": "A1Hcfv2SzHkzxC2f6AgG57oGN9"}
  527. // ];
  528. // for (var i = 0; i < temp.length; i++) {
  529. // if(temp[i].wx_book_id==wx_book_id){
  530. // return temp[i].book_id
  531. // }
  532. // }
  533. // return 1
  534. let url = config.url_confg.Dynamic.get_wxbook_to_bookid
  535. http.DynamicRequest(url,{wx_book_id:wx_book_id},(err,data)=>{
  536. if(!err) {
  537. // console.log("wx_book_id",data,wx_book_id)
  538. if(data.code==config.url_confg.StatesCode.SUCCESS){
  539. cb && cb(data.content.id)
  540. }
  541. }
  542. })
  543. }
  544. // 下单(支付类型 1:抖音支付 2:微信支付 3:内部充值(内部测试))
  545. public static requestRechargeOrderBuy(pay_type:number, goods_id:number, cb:Function) {
  546. let opt = {'pay_type':pay_type,'goods_id':goods_id}
  547. http.DynamicRequest(config.url_confg.Dynamic.recharge.order_buy,opt,(err=null,data=null)=>{
  548. // log.Debug('下单 data=',data,'err=',err)
  549. if(!err&&data) {
  550. if(data.code==config.url_confg.StatesCode.SUCCESS){
  551. let order_id = data.content.order_id
  552. cb && cb(order_id,data.content.wxpay_info)
  553. } else {
  554. cb && cb('',null)
  555. util.showErrorToast(data.message)
  556. }
  557. } else {
  558. cb && cb('',null)
  559. util.showErrorToast('下单错误!')
  560. }
  561. })
  562. }
  563. // 查询订单
  564. public static requestRechargeOrderInfo(order_id:string, cb:Function) {
  565. let opt = {'order_id':order_id}
  566. http.DynamicRequest(config.url_confg.Dynamic.recharge.order_info,opt,(err=null,data=null)=>{
  567. // log.Debug('查询订单 data=',data,'err=',err)
  568. if(!err&&data) {
  569. if(data.code==config.url_confg.StatesCode.SUCCESS){
  570. let status = data.content.status //订单状态 1:支付中 2:已经支付
  571. cb && cb(status)
  572. } else {
  573. cb && cb(-1)
  574. }
  575. } else {
  576. cb && cb(-1)
  577. }
  578. })
  579. }
  580. // 订单列表 stype 1:充值 2:购买章节
  581. public static requestOrderList(stype:number, page:number, limit:number=15, cb:Function) {
  582. let opt = {'stype':stype,'page':page,'limit':limit}
  583. util.showLoading('',true)
  584. http.DynamicRequest(config.url_confg.Dynamic.order_list,opt,(err=null,data=null)=>{
  585. util.hideLoading()
  586. if(!err&&data) {
  587. if(data.code==config.url_confg.StatesCode.SUCCESS){
  588. let content = data.content
  589. cb && cb(content)
  590. } else {
  591. cb && cb(null)
  592. }
  593. } else {
  594. cb && cb(null)
  595. }
  596. })
  597. }
  598. }