抖音c端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 line
2.9 KiB

  1. const config = require("../config/config.js")
  2. const Http = require("./HttpBasics.js")
  3. function order(id) {//支付
  4. Http.post({//下订单
  5. url:config.api.order,
  6. data:{
  7. couponId:this.data.id
  8. }
  9. }).then(res=>{
  10. console.log(res.data,"订单成功");
  11. let id = res.data.id
  12. console.log(id);
  13. Http.post({//拿orderInfo
  14. url:config.api.pay,
  15. data:{
  16. orderId:res.data.id
  17. }
  18. }).then(item=>{
  19. console.log(item,"orderId");
  20. tt.pay({
  21. service: 5,
  22. orderInfo:{
  23. order_id:item.data.orderId,
  24. order_token:item.data.token,
  25. },
  26. success(res) {
  27. if (res.code === 0) {
  28. tt.showToast({
  29. title: '支付成功!', // 内容
  30. });
  31. // 支付成功处理逻辑,只有res.code=0时,才表示支付成功
  32. // 但是最终状态要以商户后端结果为准
  33. }else if(res.code === 1){
  34. tt.showToast({
  35. title: '支付超时', // 内容
  36. icon:"none"
  37. });
  38. Http.post({
  39. url:config.api.ifPayOk,
  40. data:{
  41. code:1,
  42. orderId:res.data.id
  43. }
  44. })
  45. }else if(res.code === 2){
  46. tt.showToast({
  47. title: '支付失败', // 内容
  48. icon:"none"
  49. });
  50. }else if(res.code === 3){
  51. tt.showToast({
  52. title: '支付关闭', // 内容
  53. icon:"none"
  54. });
  55. }else if(res.code === 4){
  56. tt.showToast({
  57. title: '支付取消', // 内容
  58. icon:"none"
  59. });
  60. }else if(res.code === 9){
  61. tt.showToast({
  62. title: '订单状态开发者自行获取', // 内容
  63. icon:"none"
  64. });
  65. }
  66. },
  67. fail(res) {
  68. // handle fail
  69. },
  70. })
  71. }).catch(err=>{
  72. tt.showToast({
  73. title: '唤起支付失败', // 内容
  74. icon:"none"
  75. });
  76. })
  77. }).catch(err=>{
  78. tt.showToast({
  79. title: err.message, // 内容
  80. icon:"none"
  81. });
  82. })
  83. }
  84. module.exports={
  85. order
  86. }