家政小程序
Ви не можете вибрати більше 25 тем Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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