index.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /**
  2. * Copyright (C) 2018-2019
  3. * All rights reserved, Designed By www.joolun.com
  4. * 注意:
  5. * 本软件为www.joolun.com开发研制,项目使用请保留此说明
  6. */
  7. const app = getApp()
  8. Component({
  9. properties: {
  10. orderInfo: {
  11. type: Object,
  12. value: {}
  13. },
  14. callPay: {
  15. type: Boolean,
  16. value: false
  17. },
  18. contact: {
  19. type: Boolean,
  20. value: false
  21. }
  22. },
  23. data: {
  24. loading: false
  25. },
  26. ready() {
  27. let that = this
  28. setTimeout(function () {
  29. if (that.data.callPay) {
  30. that.unifiedOrder()
  31. }
  32. }, 1000)
  33. },
  34. methods: {
  35. orderReceive(){
  36. let that = this
  37. wx.showModal({
  38. content: '是否确认收货吗?',
  39. cancelText: '我再想想',
  40. confirmColor: '#ff0000',
  41. success(res) {
  42. if (res.confirm) {
  43. let id = that.data.orderInfo.id
  44. app.api.orderReceive(id)
  45. .then(res => {
  46. that.triggerEvent('orderReceive', res)
  47. })
  48. }
  49. }
  50. })
  51. },
  52. orderCancel() {
  53. let that = this
  54. wx.showModal({
  55. content: '确认取消该订单吗?',
  56. cancelText: '我再想想',
  57. confirmColor: '#ff0000',
  58. success(res) {
  59. if (res.confirm) {
  60. let id = that.data.orderInfo.id
  61. app.api.orderCancel(id)
  62. .then(res => {
  63. that.triggerEvent('orderCancel', res)
  64. })
  65. }
  66. }
  67. })
  68. },
  69. orderDel() {
  70. let that = this
  71. wx.showModal({
  72. content: '确认删除该订单吗?',
  73. cancelText: '我再想想',
  74. confirmColor: '#ff0000',
  75. success(res) {
  76. if (res.confirm) {
  77. let id = that.data.orderInfo.id
  78. app.api.orderDel(id)
  79. .then(res => {
  80. that.triggerEvent('orderDel', res)
  81. })
  82. }
  83. }
  84. })
  85. },
  86. unifiedOrder() {
  87. this.setData({
  88. loading: true
  89. })
  90. var that = this
  91. let orderInfo = this.data.orderInfo
  92. app.api.unifiedOrder({
  93. id: orderInfo.id
  94. })
  95. .then(res => {
  96. this.setData({
  97. loading: false
  98. })
  99. if (orderInfo.paymentPrice <= 0){//0元付款
  100. that.triggerEvent('unifiedOrder', res)
  101. }else{
  102. let payData = res.data
  103. wx.requestPayment({
  104. 'timeStamp': payData.timeStamp,
  105. 'nonceStr': payData.nonceStr,
  106. 'package': payData.packageValue,
  107. 'signType': payData.signType,
  108. 'paySign': payData.paySign,
  109. 'success': function (res) {
  110. that.triggerEvent('unifiedOrder', res)
  111. },
  112. 'fail': function (res) {
  113. },
  114. 'complete': function (res) {
  115. console.log(res)
  116. }
  117. })
  118. }
  119. }).catch(() => {
  120. this.setData({
  121. loading: false
  122. })
  123. })
  124. },
  125. urgeOrder() {
  126. wx.showToast({
  127. title: '已提醒卖家发货',
  128. icon: 'success',
  129. duration: 2000
  130. })
  131. },
  132. orderLogistics(){
  133. wx.navigateTo({
  134. url: '/pages/order/order-logistics/index?id=' + this.data.orderInfo.orderLogistics.id
  135. })
  136. },
  137. orderAppraise(){
  138. wx.navigateTo({
  139. url: '/pages/appraises/form/index?orderId=' + this.data.orderInfo.id
  140. })
  141. }
  142. }
  143. })