家政小程序
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.

index.js 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. const WxParse = require('../../wxParse/wxParse.js')
  2. const $ = global
  3. new $.Page({
  4. onLoad(options) {
  5. if (!options.id) {
  6. return $.wx.showToast({
  7. title: '找不到对应id'
  8. });
  9. }
  10. $.request(`server_info/${options.id}`, 'GET', {}).then((res) => {
  11. var article = res.data && res.data.content || '';
  12. const fields = res.data.fields || [];
  13. const options = [];
  14. WxParse.wxParse('article', 'html', article, this, 5);
  15. for (let item of fields) {
  16. const group = item.input_group;
  17. options.push(group[0].value || '');
  18. }
  19. this.setData({
  20. banner: res.data.photo || '',
  21. fields,
  22. options
  23. });
  24. });
  25. },
  26. bookServer() {
  27. const {
  28. name,
  29. phone,
  30. address,
  31. notes
  32. } = this.data;
  33. if (!name || !phone || !address) {
  34. return $.wx.showToast({
  35. title: '请把信息填写完整'
  36. });
  37. }
  38. if (!this._isPhone(phone)) {
  39. return $.wx.showToast({
  40. title: '请输入正确的手机号码'
  41. });
  42. }
  43. $.wx.showToast({
  44. title: '加载中'
  45. }, 'loading');
  46. $.request('housekeeper_order/store', 'POST', {
  47. contents: '保洁服务',
  48. people_num: '1-2人',
  49. notes,
  50. server_time: '白天',
  51. address,
  52. rest: '晚上',
  53. area: '60-120平',
  54. contact: name,
  55. phone
  56. }).then((res) => {
  57. $.wx.hideToast('loading');
  58. $.router.goto({
  59. path: '/pages/order/index',
  60. type: $.ROUTER_TYPE.SWITCH_TAB
  61. });
  62. });
  63. },
  64. radioChange(e) {
  65. const {
  66. index
  67. } = e.currentTarget.dataset || 0;
  68. const {
  69. value
  70. } = e.detail;
  71. const {
  72. options
  73. } = this.data;
  74. options[index] = value;
  75. this.setData({
  76. options
  77. });
  78. }
  79. })