serviceDetails.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // pages/order/serviceDetails/serviceDetails.js
  2. const app = getApp();
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. goods: {},
  9. carNum: 1,
  10. carPrice: 0,
  11. title: "",
  12. address: "",
  13. signing_status:"",
  14. worke_id: "",
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. var goods_id = options.goods_id;
  21. var title = options.title;
  22. var signing_status=options.signing_status;
  23. var address = options.address;
  24. var worke_id = options.worke_id;
  25. console.log(options);
  26. this.setData({
  27. title: title,
  28. address: address,
  29. worke_id: worke_id,
  30. goods_id: goods_id,
  31. signing_status:signing_status
  32. })
  33. var that = this;
  34. app.api.useApi(app.globalData.baseAppUrl + "api/goods_info", {
  35. network_id: wx.getStorageSync('nid'),
  36. good_id: goods_id
  37. }, "get").then(function (res) {
  38. console.log(res);
  39. if (res.code != 200) {
  40. console.log(res.code);
  41. wx.showLoading({
  42. title: res.message.msg,
  43. })
  44. } else {
  45. that.setData({
  46. goods: res.message.data.good,
  47. carPrice: res.message.data.good.price.start_time!=0?res.message.data.good.price.sale_price:res.message.data.good.price.price,
  48. })
  49. }
  50. wx.hideLoading();
  51. }).catch(function (err) {
  52. console.log(222);
  53. })
  54. },
  55. minus() {
  56. if (this.data.carNum > 1) {
  57. var carnum = this.data.carNum - 1
  58. this.setData({
  59. carNum: carnum
  60. })
  61. }
  62. console.log(this.data.goods.price.start_time);
  63. if (this.data.goods.price.end_time == 0 && this.data.goods.price.start_time == 0) {
  64. var price = this.data.goods.price.price;
  65. } else {
  66. var price = this.data.goods.price.sale_price;
  67. }
  68. console.log(price);
  69. this.setData({
  70. carPrice: carnum * price
  71. })
  72. },
  73. plus() {
  74. console.log(this.data.carNum)
  75. var carnum = this.data.carNum + 1
  76. // if(this.data.carNum>=1){
  77. this.setData({
  78. carNum: carnum
  79. })
  80. // }
  81. if (this.data.goods.price.end_time == 0 && this.data.goods.price.start_time == 0) {
  82. var price = this.data.goods.price.price;
  83. } else {
  84. var price = this.data.goods.price.sale_price;
  85. }
  86. this.setData({
  87. carPrice: carnum * price
  88. })
  89. },
  90. getOrder() {
  91. var nid = this.data.worke_id;
  92. app.api.useApi(app.globalData.baseAppUrl + "api/CreateOrder", {
  93. network_id: nid,
  94. good_id: this.data.goods_id,
  95. num: this.data.carNum
  96. }, "post").then(function (res) {
  97. console.log(res);
  98. if (res.code != 200) {
  99. wx.showLoading({
  100. title: res.message.msg,
  101. })
  102. wx.setTimeout(() => {
  103. wx.hideLoading();
  104. }, 1000);
  105. } else {
  106. var order_no = res.message.data.order_no;
  107. wx.navigateTo({
  108. url: '/pages/order/confirmOreder/confirmOreder?order_no=' + order_no,
  109. })
  110. }
  111. }).catch(function (err) {
  112. console.log(222);
  113. })
  114. },
  115. })