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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. const WxParse = require('../../wxParse/wxParse.js')
  2. const $ = global
  3. new $.Page({
  4. data: {
  5. options: [],
  6. api: ''
  7. },
  8. onLoad(options) {
  9. if (!options.id) {
  10. return $.wx.showToast({
  11. title: '找不到对应id'
  12. });
  13. }
  14. $.request(`classify/${options.id}`, 'GET', {}).then((res) => {
  15. var article = res.data && res.data.content || '';
  16. const fields = res.data.fields || [];
  17. const options = [];
  18. WxParse.wxParse('article', 'html', article, this, 5);
  19. for (let item of fields) {
  20. const group = item.input_group;
  21. options.push({
  22. value: group[0].value || '',
  23. key: item.name_cn
  24. });
  25. }
  26. this.setData({
  27. banner: res.data.photo || '',
  28. fields,
  29. options,
  30. api: res.data.api,
  31. type: res.data.type
  32. });
  33. });
  34. },
  35. bookServer() {
  36. const {
  37. name,
  38. phone,
  39. address,
  40. notes,
  41. expectedDate,
  42. serviceDate,
  43. options,
  44. type
  45. } = this.data;
  46. if (!name || !phone || !address || !expectedDate || !serviceDate) {
  47. return $.wx.showToast({
  48. title: '请把信息填写完整'
  49. });
  50. }
  51. if (!this._isPhone(phone)) {
  52. return $.wx.showToast({
  53. title: '请输入正确的手机号码'
  54. });
  55. }
  56. $.wx.showToast({
  57. title: '加载中'
  58. }, 'loading');
  59. const data = {
  60. expected_date: expectedDate,
  61. special_demand: notes,
  62. server_time: serviceDate,
  63. address,
  64. contact: name,
  65. phone,
  66. type,
  67. options: ''
  68. };
  69. for (let option of options) {
  70. const val = `${option.key}:${option.value}`;
  71. data.options += (!data.options ? val : (',' + val));
  72. // data[`${option.key}`] = option.value;
  73. }
  74. $.request(this.data.api, 'POST', data).then((res) => {
  75. $.wx.hideToast('loading');
  76. $.router.goto({
  77. path: '/pages/order/index',
  78. type: $.ROUTER_TYPE.SWITCH_TAB
  79. });
  80. });
  81. },
  82. radioChange(e) {
  83. const {
  84. index
  85. } = e.currentTarget.dataset || 0;
  86. const {
  87. value
  88. } = e.detail;
  89. const {
  90. options
  91. } = this.data;
  92. options[index].value = value;
  93. this.setData({
  94. options
  95. });
  96. }
  97. })