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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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
  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. options,
  42. api,
  43. type
  44. } = this.data;
  45. if (!name || !phone || !address) {
  46. return $.wx.showToast({
  47. title: '请把信息填写完整'
  48. });
  49. }
  50. if (!this._isPhone(phone)) {
  51. return $.wx.showToast({
  52. title: '请输入正确的手机号码'
  53. });
  54. }
  55. $.wx.showToast({
  56. title: '加载中'
  57. }, 'loading');
  58. const data = {
  59. contact: name,
  60. phone,
  61. address,
  62. notes,
  63. type
  64. }
  65. for (let option of options) {
  66. data[`${option.key}`] = option.value;
  67. }
  68. $.request(api, 'POST', data).then((res) => {
  69. $.wx.hideToast('loading');
  70. $.router.goto({
  71. path: '/pages/order/index',
  72. type: $.ROUTER_TYPE.SWITCH_TAB
  73. });
  74. });
  75. },
  76. radioChange(e) {
  77. const {
  78. index
  79. } = e.currentTarget.dataset || 0;
  80. const {
  81. value
  82. } = e.detail;
  83. const {
  84. options
  85. } = this.data;
  86. options[index].value = value;
  87. this.setData({
  88. options
  89. });
  90. }
  91. })