APIClient.js 15 KB

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