index.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. // pages/error/jiesuan/index.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. id: 0,
  9. order_id:0,
  10. isprice: false,
  11. info: '',
  12. updateprive: 0,
  13. choosetype: 0,
  14. typelist:['应付','退款'],
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. console.log(options)
  21. this.setData({id: options.id,order_id:options.order_id})
  22. },
  23. /**
  24. * 生命周期函数--监听页面显示
  25. */
  26. onShow: function () {
  27. this.getinfo()
  28. },
  29. getinfo() {
  30. let that = this;
  31. app.api.useApi(app.globalData.baseAppUrl + "api/admin/sorting/entry/abnormal_settlement", {id:that.data.id,order_id:that.data.order_id}, "get").then(function (res) {
  32. if (res.code != 200) {
  33. console.log(res.message.msg)
  34. wx.showLoading({
  35. title: res.message.msg,
  36. })
  37. } else {
  38. let pp = (res.message.data.order_price - res.message.data.coupon_money) - (res.message.data.total_price - res.message.data.freight)>=0?(res.message.data.order_price - res.message.data.coupon_money) - (res.message.data.total_price - res.message.data.freight) : 0
  39. that.setData({
  40. info: res.message.data,
  41. updateprive: pp
  42. })
  43. }
  44. wx.hideLoading();
  45. }).catch(function (err) {
  46. console.log(222);
  47. })
  48. },
  49. goover(){
  50. let that = this;
  51. app.api.useApi(app.globalData.baseAppUrl + "api/admin/sorting/entry/abnormal_end", {
  52. id:that.data.id,
  53. order_id:that.data.order_id
  54. }, "post").then(function (res) {
  55. if (res.code != 200) {
  56. wx.showLoading({
  57. title: res.message.msg,
  58. })
  59. setTimeout(() => {
  60. wx.hideLoading();
  61. }, 2000);
  62. } else {
  63. wx.showLoading({
  64. title: '成功',
  65. })
  66. setTimeout(() => {
  67. wx.navigateBack()
  68. }, 2000);
  69. }
  70. }).catch(function (err) {
  71. console.log(222);
  72. })
  73. },
  74. changep(e){
  75. this.setData({updateprive:e.detail.value})
  76. console.log(e.detail.value)
  77. },
  78. goback(){
  79. wx.navigateBack()
  80. },
  81. gophone(){
  82. wx.makePhoneCall({
  83. phoneNumber: this.data.info.phone
  84. })
  85. },
  86. changeisprice(){
  87. let that = this
  88. if(that.data.isprice){
  89. that.setData({isprice:!that.data.isprice})
  90. }else{
  91. wx.showActionSheet({
  92. itemList: that.data.typelist,
  93. success (res) {
  94. that.setData({choosetype: res.tapIndex,isprice:!that.data.isprice})
  95. }
  96. })
  97. }
  98. },
  99. goconfirm(){
  100. let that = this;
  101. app.api.useApi(app.globalData.baseAppUrl + "api/admin/sorting/entry/abnormal_submit", {
  102. id:that.data.id,
  103. type:that.data.choosetype+1,
  104. price:that.data.updateprive
  105. }, "post").then(function (res) {
  106. if (res.code != 200) {
  107. console.log(res.message.msg)
  108. wx.showLoading({
  109. title: res.message.msg,
  110. })
  111. setTimeout(() => {
  112. wx.hideLoading();
  113. that.changeisprice()
  114. }, 2000);
  115. } else {
  116. wx.showLoading({
  117. title: '成功',
  118. })
  119. setTimeout(() => {
  120. wx.navigateBack()
  121. }, 2000);
  122. }
  123. }).catch(function (err) {
  124. console.log(222);
  125. })
  126. },
  127. /**
  128. * 生命周期函数--监听页面初次渲染完成
  129. */
  130. onReady: function () {
  131. },
  132. /**
  133. * 生命周期函数--监听页面隐藏
  134. */
  135. onHide: function () {
  136. },
  137. /**
  138. * 生命周期函数--监听页面卸载
  139. */
  140. onUnload: function () {
  141. },
  142. /**
  143. * 页面相关事件处理函数--监听用户下拉动作
  144. */
  145. onPullDownRefresh: function () {
  146. },
  147. /**
  148. * 页面上拉触底事件的处理函数
  149. */
  150. onReachBottom: function () {
  151. },
  152. /**
  153. * 用户点击右上角分享
  154. */
  155. onShareAppMessage: function () {
  156. }
  157. })