allocation.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. // pages/allocation/allocation.js
  2. const app = getApp()
  3. import http from "../../utils/http"
  4. import util from "../../utils/util"
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. id: '',
  11. skill_id:'',
  12. popupOrder:false,
  13. list:[],
  14. finish: false,
  15. loading: false,
  16. page: 1,
  17. order: [],
  18. safeBottom: `30px`,
  19. },
  20. sure(){
  21. if(this.data.skill_id === '') return util.toast('请先选择服务者')
  22. http.post('shop/allocationorder', {
  23. id: this.data.id,
  24. skill_id: this.data.skill_id
  25. }, true, false).then(res => {
  26. util.toast('分配成功')
  27. setTimeout(()=>{
  28. util.back()
  29. },1000)
  30. }).catch(e => {
  31. let data = e.data
  32. if(data.code === 2){
  33. util.toast(data.msg)
  34. setTimeout(()=>{
  35. util.skip('/service/earnestMoney/earnestMoney')
  36. },1000)
  37. }else if(data.code === 0){
  38. util.toast(data.msg)
  39. }
  40. })
  41. },
  42. getList(){
  43. let data = {
  44. page: this.data.page,
  45. id: this.data.id
  46. }
  47. http.post('shop/getshopskill', data).then(res => {
  48. let arr = this.data.list.concat(res.data)
  49. this.setData({
  50. list: arr,
  51. finish: true
  52. })
  53. })
  54. },
  55. /**
  56. * 生命周期函数--监听页面加载
  57. */
  58. onLoad(options) {
  59. const high = app.globalData.safeBottom
  60. this.setData({
  61. safeBottom: `${high}px`,
  62. id: options.id
  63. })
  64. this.getList()
  65. },
  66. //查看订单
  67. examineOrder(e){
  68. this.setData({
  69. order: e.currentTarget.dataset.order,
  70. popupOrder:true
  71. })
  72. },
  73. closePop(){
  74. this.setData({
  75. popupOrder:false
  76. })
  77. },
  78. //切换
  79. select(e){
  80. this.setData({
  81. skill_id:e.currentTarget.dataset.id
  82. })
  83. },
  84. onClose() {
  85. this.setData({ popupOrder: false });
  86. },
  87. /**
  88. * 生命周期函数--监听页面初次渲染完成
  89. */
  90. onReady() {
  91. },
  92. /**
  93. * 生命周期函数--监听页面显示
  94. */
  95. onShow() {
  96. },
  97. /**
  98. * 生命周期函数--监听页面隐藏
  99. */
  100. onHide() {
  101. },
  102. /**
  103. * 生命周期函数--监听页面卸载
  104. */
  105. onUnload() {
  106. },
  107. /**
  108. * 页面相关事件处理函数--监听用户下拉动作
  109. */
  110. onPullDownRefresh() {
  111. },
  112. /**
  113. * 页面上拉触底事件的处理函数
  114. */
  115. onReachBottom() {
  116. },
  117. /**
  118. * 用户点击右上角分享
  119. */
  120. onShareAppMessage() {
  121. }
  122. })