integralinfo.js 4.2 KB

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