APIClient.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. var constant = require('const.js');
  2. const HOST_PRODUCT = constant.productApi;
  3. const HOST_BASE = constant.baseApi;
  4. let request = require('WXHttpRequest.js');
  5. const httputil = require('httpUtil.js');
  6. function getProductUrl(action) {
  7. return HOST_PRODUCT + action;
  8. }
  9. function getBaseUrl(action) {
  10. return HOST_BASE + action;
  11. }
  12. module.exports = {
  13. //获取推荐首页信息(推荐课程)
  14. getIndex(uid) {
  15. let url = getBaseUrl('wx/index');
  16. return request.getInstance().header({
  17. uid
  18. }).url(url).send();
  19. },
  20. // 获取首页人气推荐
  21. getHotRecommendSecond(grade, pageNo, pageSize) {
  22. let url = getBaseUrl('wx/userRead/recommend');
  23. return request.getInstance().header({
  24. uid: wx.getStorageSync('uid')
  25. }).data({
  26. grade,
  27. pageNo,
  28. pageSize,
  29. }).url(url).send();
  30. },
  31. // 获取首页人气推荐2.0
  32. getHotRecommend() {
  33. let url = getBaseUrl('wx/discovery');
  34. return request.getInstance().header({
  35. uid: wx.getStorageSync('uid')
  36. }).url(url).send();
  37. },
  38. // 获取用户朗读详细信息
  39. getWorksDetail(uid, readId, shareFlag) {
  40. let url = getBaseUrl(`wx/userRead/info/${readId}?join=${shareFlag}`);
  41. return request.getInstance().header({
  42. uid
  43. }).url(url).send();
  44. },
  45. // 获取全部课本
  46. getAllBooks(pageNo, pageSize) {
  47. let url = getBaseUrl('wx/product');
  48. return request.getInstance().header({
  49. uid: wx.getStorageSync('uid')
  50. }).url(url).data({
  51. pageNo,
  52. pageSize
  53. }).send();
  54. },
  55. // 获取课本详情
  56. getBookDetail(uid, id) {
  57. let url = getBaseUrl(`wx/product/${id}`);
  58. return request.getInstance().header({
  59. uid
  60. }).url(url).send();
  61. },
  62. // 获取朗读详情
  63. // 获取单课详情
  64. getClassDetail(id) {
  65. // let url = getProductUrl(`wx/lesson/${id}`);
  66. let url = getBaseUrl(`wx/userRead/readInfo/${id}`);
  67. return request.getInstance().header({
  68. uid: wx.getStorageSync('uid')
  69. }).url(url).send();
  70. },
  71. // 检查是否收藏过课程
  72. classIsLike(uid, data) {
  73. let url = getBaseUrl(`wx/favorites/isLike`);
  74. return request.getInstance().header({
  75. uid
  76. }).url(url).data(data).send();
  77. },
  78. // 获取单课朗读信息
  79. getClassRead(data) {
  80. let url = getBaseUrl(`wx/userRead`);
  81. return request.getInstance().header({
  82. uid:wx.getStorageSync('uid')
  83. }).data(data).url(url).send();
  84. },
  85. // 作品播放了+1
  86. // playWorks(uid, readId) {
  87. // let url = getBaseUrl(`wx/userRead/play/${readId}`);
  88. // return request.getInstance().header({
  89. // uid
  90. // }).url(url).send();
  91. // },
  92. // 发布作品
  93. postWork(data) {
  94. console.log('上传数据',data);
  95. let url = getBaseUrl(`wx/userRead`);
  96. // let url = `https://reader-test.efunbox.cn/userRead`;
  97. return request.getInstance().header({
  98. uid: wx.getStorageSync('uid')
  99. }).url(url).data(data).method('POST').send();
  100. },
  101. // 修改作品状态
  102. putWork(data) {
  103. console.log(data);
  104. let url = getBaseUrl(`wx/userRead`);
  105. return request.getInstance().header({
  106. uid: wx.getStorageSync('uid')
  107. }).url(url).data(data).method('PUT').send();
  108. },
  109. // 视频评测数据
  110. postWorksScore(data){
  111. let url = getBaseUrl(`wx/assessment`);
  112. return request.getInstance().header({
  113. uid: wx.getStorageSync('uid')
  114. }).url(url).data(data).method('POST').send();
  115. },
  116. // 点赞作品
  117. likeWorks(readId) {
  118. let url = getBaseUrl(`wx/userRead/like/${readId}`);
  119. return request.getInstance().header({
  120. uid: wx.getStorageSync('uid')
  121. }).url(url).send();
  122. },
  123. // 关注用户
  124. followUser(uid, followUid) {
  125. let url = getBaseUrl(`wx/fans`);
  126. return request.getInstance().header({
  127. uid
  128. }).url(url).data({
  129. "uid": followUid
  130. }).method('POST').send();
  131. },
  132. // 取消关注
  133. cancerFollow(uid, followUid) {
  134. let url = getBaseUrl(`wx/fans`);
  135. return request.getInstance().header({
  136. uid
  137. }).url(url).data({
  138. "uid": followUid
  139. }).method('PUT').send();
  140. },
  141. //获取关注的用户列表
  142. getFollowUsers(uid, pageNo, pageSize) {
  143. let url = getBaseUrl(`wx/fans`);
  144. return request.getInstance().header({
  145. uid
  146. }).url(url).data({
  147. pageNo: pageNo,
  148. pageSize: pageSize
  149. }).send();
  150. },
  151. // 获取关注用户的作品列表
  152. getFollowWorks(pageNo, pageSize) {
  153. let url = getBaseUrl(`wx/fans/interest`);
  154. return request.getInstance().header({
  155. uid: wx.getStorageSync('uid')
  156. }).url(url).data({
  157. pageNo: pageNo,
  158. pageSize: pageSize
  159. }).send();
  160. },
  161. // 搜索
  162. getCourses(grade, pageNo, pageSize) {
  163. let url = getBaseUrl(`wx/lesson`);
  164. return request.getInstance().header({
  165. uid: wx.getStorageSync('uid')
  166. }).url(url).data({
  167. gradeClassify: grade,
  168. pageNo: pageNo,
  169. pageSize: pageSize
  170. }).send();
  171. },
  172. // 获取回复信息
  173. getReply(uid, columnId, pageNo, pageSize) {
  174. let url = getBaseUrl(`wx/posts/reply`);
  175. return request.getInstance().header({
  176. uid
  177. }).url(url).data({
  178. columnId: columnId,
  179. pageNo: pageNo,
  180. pageSize: pageSize
  181. }).send();
  182. },
  183. // 获取回复(楼中楼)
  184. getReplyComment(postId) {
  185. let url = getBaseUrl(`wx/posts/one/${postId}`);
  186. return request.getInstance().header({
  187. uid: wx.getStorageSync('uid')
  188. }).url(url).send();
  189. },
  190. // 发布回复(楼中楼)
  191. postReplyComment(data) {
  192. let url = getBaseUrl(`wx/reply`);
  193. return request.getInstance().header({
  194. uid: wx.getStorageSync('uid')
  195. }).url(url).data(data).method('POST').send();
  196. },
  197. // 点赞评论
  198. likeCommend(postId) {
  199. let url = getBaseUrl(`wx/posts/like/${postId}`);
  200. return request.getInstance().header({
  201. uid: wx.getStorageSync('uid')
  202. }).url(url).method('GET').send();
  203. },
  204. // 发布讨论
  205. postReply(data) {
  206. let url = getBaseUrl(`wx/posts`);
  207. return request.getInstance().header({
  208. uid: wx.getStorageSync('uid')
  209. }).url(url).data(data).method('POST').send();
  210. },
  211. // 获取推荐团购信息
  212. getGroupList(pageNo, osType) {
  213. let url = getBaseUrl(`wx/groupPurchaseInfo/recommend`);
  214. return request.getInstance().header({
  215. uid: wx.getStorageSync('uid')
  216. }).url(url).data({
  217. pageNo,
  218. pageSize: 3,
  219. osType: osType
  220. }).send();
  221. },
  222. // 获取课程团购信息
  223. getGroupPurchaseInfo(productId) {
  224. let url = getBaseUrl(`wx/groupPurchaseInfo/info/${productId}`);
  225. return request.getInstance().header({
  226. uid: wx.getStorageSync('uid')
  227. }).url(url).send();
  228. },
  229. // 发起团购
  230. SendGroupPurchas(data) {
  231. let url = getBaseUrl(`wx/groupPurchase/create`);
  232. return request.getInstance().header({
  233. uid: wx.getStorageSync('uid')
  234. }).url(url).data(data).method('POST').send();
  235. },
  236. // 参加团购
  237. JoinGroupPurchas(orderId, formId) {
  238. console.log(formId)
  239. console.log(orderId)
  240. let url = getBaseUrl(`wx/groupPurchase/join`);
  241. return request.getInstance().header({
  242. uid: wx.getStorageSync('uid')
  243. }).url(url).data({
  244. orderId,
  245. formId
  246. }).method('POST').send();
  247. },
  248. // 收藏课程
  249. collectClass(data) {
  250. let url = getBaseUrl(`wx/favorites`);
  251. return request.getInstance().header({
  252. uid: wx.getStorageSync('uid')
  253. }).url(url).data(data).method('POST').send();
  254. },
  255. //我的团
  256. getMygroup() {
  257. let url = getBaseUrl(`wx/groupPurchase/my`);
  258. return request.getInstance().header({
  259. uid: wx.getStorageSync('uid')
  260. }).url(url).data({
  261. pageNo: 1,
  262. pageSize: 100
  263. }).send();
  264. },
  265. //获取团购详情
  266. getMygroupInfo(orderId) {
  267. let url = getBaseUrl(`wx/groupPurchase/info/${orderId}`);
  268. return request.getInstance().header({
  269. uid: wx.getStorageSync('uid')
  270. }).url(url).send();
  271. },
  272. //团购是否成功
  273. groupSuccess(orderId) {
  274. let url = getBaseUrl(`wx/groupPurchase/joinStatus`);
  275. return request.getInstance().header({
  276. uid: wx.getStorageSync('uid')
  277. }).url(url).data({
  278. orderId
  279. }).send();
  280. },
  281. // 发起奖励
  282. rewardMoney(uid, data) {
  283. let url = getBaseUrl(`wx/wallet/award`);
  284. return request.getInstance().header({
  285. uid
  286. }).url(url).data(data).method('POST').send();
  287. },
  288. // 修改资料
  289. settingUserInfo(data) {
  290. let url = getBaseUrl(`wx/user`);
  291. return request.getInstance().header({
  292. uid: wx.getStorageSync('uid')
  293. }).data(data).url(url).method('PUT').send();
  294. },
  295. //获取个人信息
  296. getUserInfo() {
  297. let url = getBaseUrl(`wx/user`);
  298. return request.getInstance().header({
  299. uid: wx.getStorageSync('uid')
  300. }).url(url).send();
  301. },
  302. // 获取播放量等数据
  303. getUserWorksInfo() {
  304. let url = getBaseUrl(`wx/user/my`);
  305. return request.getInstance().header({
  306. uid: wx.getStorageSync('uid')
  307. }).url(url).send();
  308. },
  309. // 生成二维码
  310. createQRCode(data) {
  311. let url = getBaseUrl(`wx/qrCode`);
  312. return request.getInstance().header({
  313. uid: wx.getStorageSync('uid')
  314. }).data(data).url(url).send();
  315. },
  316. // 我的奖金
  317. myWallet() {
  318. let url = getBaseUrl('wx/wallet/bonus');
  319. return request.getInstance().header({
  320. uid: wx.getStorageSync('uid')
  321. }).url(url).send();
  322. },
  323. // 資金明細
  324. myWalletDetails() {
  325. let url = getBaseUrl('wx/wallet/record');
  326. return request.getInstance().header({
  327. uid: wx.getStorageSync('uid')
  328. }).url(url).send();
  329. },
  330. // 我的課程
  331. myCourse() {
  332. let url = getBaseUrl('wx/groupPurchase/myCourse');
  333. return request.getInstance().header({
  334. uid: wx.getStorageSync('uid')
  335. }).url(url).send();
  336. },
  337. // 我的朗读
  338. myRead() {
  339. let url = getBaseUrl('wx/userRead/my');
  340. return request.getInstance().header({
  341. uid: wx.getStorageSync('uid')
  342. }).url(url).send();
  343. },
  344. // 我的收藏
  345. myFavorites() {
  346. let url = getBaseUrl(`wx/favorites`);
  347. return request.getInstance().header({
  348. uid: wx.getStorageSync('uid')
  349. }).url(url).send();
  350. },
  351. // 我的关注
  352. myFans() {
  353. let url = getBaseUrl(`wx/fans`);
  354. return request.getInstance().header({
  355. uid: wx.getStorageSync('uid')
  356. }).url(url).send();
  357. },
  358. // 课程鉴权
  359. areYouSuper(productId) {
  360. let url = getBaseUrl(`wx/groupPurchase/auth`);
  361. return request.getInstance().header({
  362. uid: wx.getStorageSync('uid')
  363. }).url(url).data({
  364. productId
  365. }).send();
  366. },
  367. // 课程鉴权 包括助力团
  368. areYouSuperSecond(os, productId) {
  369. let url = getBaseUrl(`wx/groupPurchase/authAll`);
  370. return request.getInstance().header({
  371. uid: wx.getStorageSync('uid')
  372. }).url(url).data({
  373. osType: os,
  374. productId
  375. }).send();
  376. },
  377. // // 课本鉴权
  378. // areYouBookSuper(productArr){
  379. // let url = getBaseUrl(`wx/groupPurchase/authAll`);
  380. // return request.getInstance().header({
  381. // uid: wx.getStorageSync('uid')
  382. // }).url(url).data(productArr).method('POST').send();
  383. // },
  384. // 找到课程对应的课本
  385. checkLesson(lessonId) {
  386. let url = getBaseUrl(`wx/lesson/product/${lessonId}`);
  387. return request.getInstance().header({
  388. uid: wx.getStorageSync('uid')
  389. }).url(url).send();
  390. },
  391. // 获取 用户朗读的作品
  392. userWorks(followUid, pageNo, pageSize) {
  393. let url = getBaseUrl('wx/userRead');
  394. return request.getInstance().header({
  395. uid: wx.getStorageSync('uid')
  396. }).data({
  397. uid: followUid,
  398. pageNo: pageNo,
  399. pageSize: pageSize
  400. }).url(url).send();
  401. },
  402. // 获取用户信息
  403. getUserMsg(followUid, pageNo, pageSize) {
  404. let url = getBaseUrl('wx/user/info');
  405. return request.getInstance().header({
  406. uid: wx.getStorageSync('uid')
  407. }).data({
  408. uid: followUid,
  409. pageNo: pageNo,
  410. pageSize: pageSize
  411. }).url(url).send();
  412. },
  413. // 获取站内消息列表
  414. getMessageList(pageNo, pageSize) {
  415. let url = getBaseUrl('wx/message');
  416. return request.getInstance().header({
  417. uid: wx.getStorageSync('uid')
  418. }).data({
  419. pageNo: pageNo,
  420. pageSize: pageSize
  421. }).url(url).send();
  422. },
  423. // 更新消息状态
  424. refreshMessageStatus() {
  425. let url = getBaseUrl('wx/message');
  426. return request.getInstance().header({
  427. uid: wx.getStorageSync('uid')
  428. }).url(url).method('PUT').send();
  429. },
  430. // 获取正在进行中的团数量
  431. getMyGroupGoing() {
  432. let url = getBaseUrl('wx/groupPurchase/underway');
  433. return request.getInstance().header({
  434. uid: wx.getStorageSync('uid')
  435. }).url(url).send();
  436. },
  437. // 分享记录
  438. shareRecord(data) {
  439. let url = getBaseUrl('wx/ShareStatistics/share');
  440. return request.getInstance().header({
  441. uid: wx.getStorageSync('uid')
  442. }).data(data).url(url).method('POST').send();
  443. },
  444. shareLog(data){
  445. let url = getBaseUrl('wx/shareLog');
  446. return request.getInstance().header({
  447. uid: wx.getStorageSync('uid')
  448. }).data(data).url(url).method('POST').send();
  449. },
  450. shareImgLog(data){
  451. let url = getBaseUrl('wx/shareLog/saveShareImg');
  452. return request.getInstance().header({
  453. uid: wx.getStorageSync('uid')
  454. }).data(data).url(url).method('POST').send();
  455. },
  456. // 由分享进入的记录
  457. shareTagRecord(data) {
  458. let url = getBaseUrl('wx/ShareStatistics/click');
  459. return request.getInstance().header({
  460. uid: wx.getStorageSync('uid')
  461. }).data(data).url(url).method('POST').send();
  462. },
  463. // 用户登录记录
  464. userLoginRecord() {
  465. let url = getBaseUrl('wx/loginLog');
  466. return request.getInstance().header({
  467. uid: wx.getStorageSync('uid')
  468. }).url(url).method('POST').send();
  469. },
  470. // 用户进入页面统计
  471. userIntoPage(action, actionName) {
  472. let url = getBaseUrl('wx/userEvent');
  473. return request.getInstance().header({
  474. uid: wx.getStorageSync('uid')
  475. }).data({
  476. action,
  477. actionName
  478. }).url(url).method('POST').send();
  479. },
  480. // 用户播放视频时长统计
  481. playLogReport(data) {
  482. let url = getBaseUrl('base/playLog');
  483. return request.getInstance().header({
  484. uid: wx.getStorageSync('uid')
  485. }).data(data).url(url).method('POST').send();
  486. },
  487. // 小红花 获取任务列表
  488. getMissionList() {
  489. let url = getBaseUrl('wx/task');
  490. return request.getInstance().header({
  491. uid: wx.getStorageSync('uid')
  492. }).url(url).send();
  493. },
  494. // 获取用户连续签到日期
  495. // getSignInData(){
  496. // let url = getBaseUrl('wx/loginLog');
  497. // return request.getInstance().header({
  498. // uid: wx.getStorageSync('uid')
  499. // }).url(url).send();
  500. // },
  501. // 保存formId
  502. postFormId(formId) {
  503. let url = getBaseUrl('wx/form');
  504. return request.getInstance().header({
  505. uid: wx.getStorageSync('uid')
  506. }).data({
  507. formId
  508. }).url(url).method('POST').send();
  509. },
  510. // 获取签到信息
  511. getSignInData() {
  512. let url = getBaseUrl('wx/loginLog/signIn');
  513. return request.getInstance().header({
  514. uid: wx.getStorageSync('uid')
  515. }).url(url).send();
  516. },
  517. // 获取产品信息
  518. getProductData() {
  519. let url = getBaseUrl('wx/product');
  520. return request.getInstance().header({
  521. uid: wx.getStorageSync('uid')
  522. }).url(url).send();
  523. },
  524. // 创建订单
  525. postOrder(productId) {
  526. let url = getBaseUrl('wx/order');
  527. return request.getInstance().header({
  528. uid: wx.getStorageSync('uid'),
  529. 'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'
  530. }).data({
  531. productId
  532. }).url(url).method('POST').send();
  533. },
  534. //激活码激活
  535. postActiveCode(code) {
  536. console.log(22222, code)
  537. let url = getBaseUrl('wx/activationCode');
  538. return request.getInstance().header({
  539. uid: wx.getStorageSync('uid'),
  540. }).data({
  541. code
  542. }).url(url).method('POST').send();
  543. },
  544. // 会员鉴权
  545. getUserAuth() {
  546. let url = getBaseUrl('wx/auth');
  547. return request.getInstance().header({
  548. uid: wx.getStorageSync('uid')
  549. }).url(url).send();
  550. }
  551. }