APIClient.js 14 KB

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