integralinfo.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. // console.log(res?.data?.msg);
  33. if(res?.data?.msg != undefined && typeof(res?.data?.msg)=='string') {
  34. wx.showToast({
  35. title: res?.data?.msg,
  36. icon: "none"
  37. })
  38. }
  39. }
  40. //其它错误,提示用户错误信息
  41. if (this._errorHandler != null) {
  42. //如果有统一的异常处理,就先调用统一异常处理函数对异常进行处理
  43. this._errorHandler(res)
  44. }
  45. reject(res)
  46. }
  47. }),
  48. fail: (res => {
  49. if (this._errorHandler != null) {
  50. this._errorHandler(res)
  51. }
  52. wx.showToast({
  53. title: '网络异常请稍后',
  54. })
  55. reject(res)
  56. }),
  57. complete: _ => {
  58. getApp().hideLoading()
  59. }
  60. })
  61. })
  62. }
  63. /**
  64. * 获取轮播图
  65. */
  66. static getBannerList(params) {
  67. return this.postRequest(`${this.INT_URL}app/banner/list`, params);
  68. }
  69. /**
  70. * 获取优惠券列表
  71. */
  72. static getList(params) {
  73. return this.postRequest(`${this.INT_URL}app/coupon/list`, params);
  74. }
  75. /**
  76. * 获取移动积分
  77. */
  78. static getBalance(params) {
  79. return this.postRequest(`${this.INT_URL}app/cmcc/balance`, params);
  80. }
  81. /**
  82. * 下单
  83. */
  84. static getOrder(params) {
  85. return this.postRequest(`${this.INT_URL}/app/order/order`, params);
  86. }
  87. /**
  88. * 一次验证码的支付
  89. */
  90. static getPayOnce(params) {
  91. return this.postRequest(`${this.INT_URL}/app/order/payOnce`, params);
  92. }
  93. /**
  94. * 移动积分扣减
  95. */
  96. static getExchange(params) {
  97. return this.postRequest(`${this.INT_URL}/app/order/exchange`, params);
  98. }
  99. /**
  100. * 支付短信验证码
  101. */
  102. static getPaySend(params) {
  103. return this.postRequest(`${this.INT_URL}/app/order/paySend`, params);
  104. }
  105. /**
  106. * 重新下发移动短信
  107. */
  108. static getSendCmccSms(params) {
  109. return this.postRequest(`${this.INT_URL}/app/order/sendCmccSms`, params);
  110. }
  111. /**
  112. * 我的兑换
  113. */
  114. static getOrderList(params) {
  115. return this.postRequest(`${this.INT_URL}/app/order/list`, params);
  116. }
  117. /**
  118. * 创建订单
  119. */
  120. static createOrder(mobile,activityId,num,shopId="", refStatisticsPostParam) {
  121. refStatisticsPostParam = refStatisticsPostParam || {}
  122. let params = {
  123. activityId:activityId,
  124. memberMobile:mobile,
  125. num:num,
  126. shopId:shopId,
  127. scene: refStatisticsPostParam.scene || "",
  128. channel: refStatisticsPostParam.channel || "0",
  129. department: refStatisticsPostParam.department || "0"
  130. };
  131. return this.postRequest(`${this.BASE_URL}open/activity/create-order`, params);
  132. }
  133. //获取支付参数
  134. static getOrderParams(orderSn,openId,isOrderPayment=false) {
  135. let params = {
  136. orderSn:orderSn,
  137. source: "FREE_MINI_APP",
  138. thirdPartyName: 'coupon-activity',
  139. payCode: "HSAY-SHARE",
  140. openId: openId
  141. };
  142. if(isOrderPayment){
  143. params.isOrderPayment =true;
  144. params.orderInfoPath = "pages/welfareMall/order/orderCompletion?ordersn="
  145. params.productDetailPath = "pages/welfareMall/activityInfo/activityInfo?activityId="
  146. }
  147. return this.postRequest(`${this.BASE_URL}open/activity/get-order-params`, params);
  148. }
  149. }
  150. export default Integralinfo