APIClient.js 13 KB

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