APIClient.js 15 KB

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