tools.ts 18 KB

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