APIClient.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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. getHotRecommend(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. // 获取用户朗读详细信息
  31. getWorksDetail(uid, readId) {
  32. let url = getBaseUrl(`wx/userRead/info/${readId}`);
  33. return request.getInstance().header({
  34. uid
  35. }).url(url).send();
  36. },
  37. // 获取全部课本
  38. getAllBooks(pageNo, pageSize) {
  39. let url = getProductUrl('wx/product');
  40. return request.getInstance().header({
  41. uid: wx.getStorageSync('uid')
  42. }).url(url).data({
  43. pageNo,
  44. pageSize
  45. }).send();
  46. },
  47. // 获取课本详情
  48. getBookDetail(uid, id) {
  49. let url = getProductUrl(`wx/product/${id}`);
  50. return request.getInstance().header({
  51. uid
  52. }).url(url).send();
  53. },
  54. // 获取单课详情
  55. getClassDetail(uid, id) {
  56. let url = getProductUrl(`wx/lesson/${id}`);
  57. return request.getInstance().header({
  58. uid
  59. }).url(url).send();
  60. },
  61. // 检查是否收藏过课程
  62. classIsLike(uid, data) {
  63. let url = getProductUrl(`wx/favorites/isLike`);
  64. return request.getInstance().header({
  65. uid
  66. }).url(url).data(data).send();
  67. },
  68. getClassDetail(uid, id) {
  69. let url = getProductUrl(`wx/lesson/${id}`);
  70. return request.getInstance().header({
  71. uid
  72. }).url(url).send();
  73. },
  74. // 获取单课朗读信息
  75. getClassRead(uid, data) {
  76. let url = getBaseUrl(`wx/userRead`);
  77. return request.getInstance().header({
  78. uid
  79. }).data(data).url(url).send();
  80. },
  81. // 作品播放了+1
  82. playWorks(uid, readId) {
  83. let url = getBaseUrl(`wx/userRead/play/${readId}`);
  84. return request.getInstance().header({
  85. uid
  86. }).url(url).send();
  87. },
  88. // 发布作品
  89. postWork(uid, data) {
  90. console.log(data);
  91. let url = getBaseUrl(`wx/userRead`);
  92. return request.getInstance().header({
  93. uid
  94. }).url(url).data(data).method('POST').send();
  95. },
  96. // 点赞作品
  97. likeWorks(uid, readId) {
  98. let url = getBaseUrl(`wx/userRead/like/${readId}`);
  99. return request.getInstance().header({
  100. uid
  101. }).url(url).send();
  102. },
  103. // 关注用户
  104. followUser(uid, followUid) {
  105. let url = getBaseUrl(`wx/fans`);
  106. return request.getInstance().header({
  107. uid
  108. }).url(url).data({
  109. "uid": followUid
  110. }).method('POST').send();
  111. },
  112. //获取关注的用户列表
  113. getFollowUsers(uid, pageNo, pageSize) {
  114. let url = getBaseUrl(`wx/fans`);
  115. return request.getInstance().header({
  116. uid
  117. }).url(url).data({
  118. pageNo: pageNo,
  119. pageSize: pageSize
  120. }).send();
  121. },
  122. // 获取关注用户的作品列表
  123. getFollowWorks(uid, pageNo, pageSize) {
  124. let url = getBaseUrl(`wx/fans/interest`);
  125. return request.getInstance().header({
  126. uid
  127. }).url(url).data({
  128. pageNo: pageNo,
  129. pageSize: pageSize
  130. }).send();
  131. },
  132. // 搜索
  133. getSearchResult(uid, key, pageNo, pageSize) {
  134. let url = getProductUrl(`wx/lesson`);
  135. return request.getInstance().header({
  136. uid
  137. }).url(url).data({
  138. title: key,
  139. productId: '',
  140. pageNo: pageNo,
  141. pageSize: pageSize
  142. }).send();
  143. },
  144. // 获取回复信息
  145. getReply(uid, columnId, pageNo, pageSize) {
  146. let url = getBaseUrl(`wx/posts/reply`);
  147. return request.getInstance().header({
  148. uid
  149. }).url(url).data({
  150. columnId: columnId,
  151. pageNo: pageNo,
  152. pageSize: pageSize
  153. }).send();
  154. },
  155. // 获取回复(楼中楼)
  156. getReplyComment(uid, postId) {
  157. let url = getBaseUrl(`wx/posts/one/${postId}`);
  158. return request.getInstance().header({
  159. uid
  160. }).url(url).send();
  161. },
  162. // 发布回复(楼中楼)
  163. postReplyComment(uid, data) {
  164. let url = getBaseUrl(`wx/reply`);
  165. return request.getInstance().header({
  166. uid
  167. }).url(url).data(data).method('POST').send();
  168. },
  169. // 点赞评论
  170. likeCommend(uid, likeUid) {
  171. let url = getBaseUrl(`wx/posts/attribute/${likeUid}`);
  172. return request.getInstance().header({
  173. uid
  174. }).url(url).method('GET').send();
  175. },
  176. // 发布讨论
  177. postReply(uid, data) {
  178. let url = getBaseUrl(`wx/posts`);
  179. return request.getInstance().header({
  180. uid
  181. }).url(url).data(data).method('POST').send();
  182. },
  183. // 获取推荐团购信息
  184. getGroupList() {
  185. let url = getBaseUrl(`wx/groupPurchaseInfo/recommend`);
  186. return request.getInstance().header({
  187. uid: wx.getStorageSync('uid')
  188. }).url(url).send();
  189. },
  190. // 获取课程团购信息
  191. getGroupPurchaseInfo(productId) {
  192. let url = getBaseUrl(`wx/groupPurchaseInfo/info/${productId}`);
  193. return request.getInstance().header({
  194. uid: wx.getStorageSync('uid')
  195. }).url(url).send();
  196. },
  197. // 发起团购
  198. SendGroupPurchas(data) {
  199. let url = getBaseUrl(`wx/groupPurchase/create`);
  200. return request.getInstance().header({
  201. uid: wx.getStorageSync('uid')
  202. }).url(url).data(data).method('POST').send();
  203. },
  204. // 参加团购
  205. JoinGroupPurchas(orderId) {
  206. let url = getBaseUrl(`wx/groupPurchase/join`);
  207. return request.getInstance().header({
  208. uid: wx.getStorageSync('uid')
  209. }).url(url).data({
  210. orderId
  211. }).method('POST').send();
  212. },
  213. // 收藏课程
  214. collectClass(uid, data) {
  215. let url = getProductUrl(`wx/favorites`);
  216. return request.getInstance().header({
  217. uid
  218. }).url(url).data(data).method('POST').send();
  219. },
  220. //我的团
  221. getMygroup() {
  222. let url = getBaseUrl(`wx/groupPurchase/my`);
  223. return request.getInstance().header({
  224. uid: wx.getStorageSync('uid')
  225. }).url(url).data({
  226. pageNo: 1,
  227. pageSize: 100
  228. }).send();
  229. },
  230. //获取团购详情
  231. getMygroupInfo(orderId) {
  232. let url = getBaseUrl(`wx/groupPurchase/info/${orderId}`);
  233. return request.getInstance().header({
  234. uid: wx.getStorageSync('uid')
  235. }).url(url).send();
  236. },
  237. //团购是否成功
  238. groupSuccess(orderId) {
  239. let url = getBaseUrl(`wx/groupPurchase/joinStatus`);
  240. return request.getInstance().header({
  241. uid: wx.getStorageSync('uid')
  242. }).url(url).data({
  243. orderId
  244. }).send();
  245. },
  246. // 发起奖励
  247. rewardMoney(uid, data) {
  248. let url = getBaseUrl(`wx/wallet/award`);
  249. return request.getInstance().header({
  250. uid
  251. }).url(url).data(data).method('POST').send();
  252. },
  253. // 修改资料
  254. settingUserInfo(wechatName, mobile, gender, schoolProvince, schoolCity, schoolName, profession, birthday) {
  255. let url = getBaseUrl(`wx/user`);
  256. return request.getInstance().header({
  257. uid:wx.getStorageSync('uid')
  258. }).data({
  259. wechatName: wechatName,
  260. mobile: mobile,
  261. gender: gender,
  262. schoolProvince: schoolProvince,
  263. schoolCity: schoolCity,
  264. schoolName: schoolName,
  265. profession: profession,
  266. birthday: birthday
  267. }).url(url).method('PUT').send();
  268. },
  269. //获取个人信息
  270. getUserInfo() {
  271. let url = getBaseUrl(`wx/user`);
  272. return request.getInstance().header({
  273. uid: wx.getStorageSync('uid')
  274. }).data({
  275. uid: wx.getStorageSync('uid')
  276. }).url(url).send();
  277. },
  278. // 生成二维码
  279. createQRCode(data) {
  280. let url = getBaseUrl(`wx/qrCode`);
  281. return request.getInstance().header({
  282. uid: wx.getStorageSync('uid')
  283. }).data(data).url(url).send();
  284. },
  285. // 我的奖金
  286. myWallet() {
  287. let url = getBaseUrl('wx/wallet/bonus');
  288. return request.getInstance().header({
  289. uid: wx.getStorageSync('uid')
  290. }).url(url).send();
  291. },
  292. // 資金明細
  293. myWalletDetails() {
  294. let url = getBaseUrl('wx/wallet/record');
  295. return request.getInstance().header({
  296. uid: wx.getStorageSync('uid')
  297. }).url(url).send();
  298. },
  299. // 我的課程
  300. myCourse() {
  301. let url = getBaseUrl('wx/groupPurchase/myCourse');
  302. return request.getInstance().header({
  303. uid: wx.getStorageSync('uid')
  304. }).url(url).send();
  305. },
  306. // 我的朗读
  307. myRead() {
  308. let url = getBaseUrl('wx/userRead/my');
  309. return request.getInstance().header({
  310. uid: wx.getStorageSync('uid')
  311. }).url(url).send();
  312. },
  313. }