家政小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

index.js 2.3KB

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