integralinfo.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. import request from '../utils/request.js'
  2. class Integralinfo extends request {
  3. // static INT_URL = 'http://118.31.106.139:8022/'
  4. static INT_URL = 'https://api.imedicalmall.com/'
  5. /**
  6. * POST类型的网络请求
  7. */
  8. static postRequest(url, data, notUseLoading, catchErrorFunc) {
  9. let headerSign = this.getSignHead();
  10. return this.requestAll(url, data, headerSign, 'POST', notUseLoading, catchErrorFunc)
  11. }
  12. static requestAll(url, data, header, method, notUseLoading, catchErrorFunc) {
  13. if (!notUseLoading) {
  14. getApp().showLoading()
  15. }
  16. return new Promise((resolve, reject) => {
  17. wx.request({
  18. url: url,
  19. data: data,
  20. header: header,
  21. method: method,
  22. success: (res => {
  23. if (res?.data.code === "0000") {
  24. //200: 服务端业务处理正常结束
  25. resolve(res?.data)
  26. } else {
  27. if (catchErrorFunc) {
  28. if (isFunc(catchErrorFunc)) {
  29. catchErrorFunc(res?.data)
  30. }
  31. } else {
  32. wx.showToast({
  33. title: res?.data?.msg,
  34. icon: "none"
  35. })
  36. }
  37. //其它错误,提示用户错误信息
  38. if (this._errorHandler != null) {
  39. //如果有统一的异常处理,就先调用统一异常处理函数对异常进行处理
  40. this._errorHandler(res)
  41. }
  42. reject(res)
  43. }
  44. }),
  45. fail: (res => {
  46. if (this._errorHandler != null) {
  47. this._errorHandler(res)
  48. }
  49. wx.showToast({
  50. title: '网络异常请稍后',
  51. })
  52. reject(res)
  53. }),
  54. complete: _ => {
  55. getApp().hideLoading()
  56. }
  57. })
  58. })
  59. }
  60. /**
  61. * 获取轮播图
  62. */
  63. static getBannerList(params) {
  64. return this.postRequest(`${this.INT_URL}app/banner/list`, params);
  65. }
  66. /**
  67. * 获取优惠券列表
  68. */
  69. static getList(params) {
  70. return this.postRequest(`${this.INT_URL}app/coupon/list`, params);
  71. }
  72. /**
  73. * 获取移动积分
  74. */
  75. static getBalance(params) {
  76. return this.postRequest(`${this.INT_URL}app/cmcc/balance`, params);
  77. }
  78. /**
  79. * 下单
  80. */
  81. static getOrder(params) {
  82. return this.postRequest(`${this.INT_URL}/app/order/order`, params);
  83. }
  84. /**
  85. * 一次验证码的支付
  86. */
  87. static getPayOnce(params) {
  88. return this.postRequest(`${this.INT_URL}/app/order/payOnce`, params);
  89. }
  90. /**
  91. * 支付短信验证码
  92. */
  93. static getPaySend(params) {
  94. return this.postRequest(`${this.INT_URL}/app/order/paySend`, params);
  95. }
  96. /**
  97. * 重新下发移动短信
  98. */
  99. static getSendCmccSms(params) {
  100. return this.postRequest(`${this.INT_URL}/app/order/sendCmccSms`, params);
  101. }
  102. /**
  103. * 我的兑换
  104. */
  105. static getOrderList(params) {
  106. return this.postRequest(`${this.INT_URL}/app/order/list`, params);
  107. }
  108. /**
  109. * 创建订单
  110. */
  111. static createOrder(mobile,activityId,num,shopId="", refStatisticsPostParam) {
  112. refStatisticsPostParam = refStatisticsPostParam || {}
  113. let params = {
  114. activityId:activityId,
  115. memberMobile:mobile,
  116. num:num,
  117. shopId:shopId,
  118. scene: refStatisticsPostParam.scene || "",
  119. channel: refStatisticsPostParam.channel || "0",
  120. department: refStatisticsPostParam.department || "0"
  121. };
  122. return this.postRequest(`${this.BASE_URL}open/activity/create-order`, params);
  123. }
  124. //获取支付参数
  125. static getOrderParams(orderSn,openId,isOrderPayment=false) {
  126. let params = {
  127. orderSn:orderSn,
  128. source: "FREE_MINI_APP",
  129. thirdPartyName: 'coupon-activity',
  130. payCode: "HSAY-SHARE",
  131. openId: openId
  132. };
  133. if(isOrderPayment){
  134. params.isOrderPayment =true;
  135. params.orderInfoPath = "pages/welfareMall/order/orderCompletion?ordersn="
  136. params.productDetailPath = "pages/welfareMall/activityInfo/activityInfo?activityId="
  137. }
  138. return this.postRequest(`${this.BASE_URL}open/activity/get-order-params`, params);
  139. }
  140. }
  141. export default Integralinfo