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

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