check.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. import todo from '../../components/calendar/plugins/todo'
  2. import selectable from '../../components/calendar/plugins/selectable'
  3. import solarLunar from '../../components/calendar/plugins/solarLunar/index'
  4. import timeRange from '../../components/calendar/plugins/time-range'
  5. import week from '../../components/calendar/plugins/week'
  6. import holidays from '../../components/calendar/plugins/holidays/index'
  7. import plugin from '../../components/calendar/plugins/index'
  8. plugin
  9. .use(todo)
  10. .use(solarLunar)
  11. .use(selectable)
  12. .use(week)
  13. .use(timeRange)
  14. .use(holidays)
  15. Page({
  16. data: {
  17. name: '',
  18. phone: '',
  19. license_number: '',
  20. car_model: '',
  21. appoint_date: '',
  22. appoint_time: '',
  23. exchange_code:'',
  24. car_appoint_id:'',
  25. user_info_show: false,
  26. calendarConfig: {
  27. theme: 'elegant',
  28. disableMode: {
  29. // 禁用某一天之前/之后的所有日期
  30. type: 'before', // [‘before’, 'after']
  31. },
  32. },
  33. },
  34. onLoad: function(t) {
  35. this.loadData()
  36. console.log(t,66666)
  37. getApp().page.onLoad(this, t), t.page_id || (t.page_id = -1), this.setData({
  38. options: t
  39. });
  40. },
  41. onShow: function(){
  42. var e = this;
  43. getApp().getConfig(function(t) {
  44. var a = t.store;
  45. a && a.name && -1 == e.data.options.page_id && getApp().core.setNavigationBarTitle({
  46. title: a.name
  47. })
  48. })
  49. },
  50. // 填写姓名
  51. bindName:function(e){
  52. console.log(e.detail.value)
  53. this.setData({
  54. name: e.detail.value
  55. })
  56. console.log('预约')
  57. },
  58. // 填写电话
  59. bindPhone:function(e){
  60. console.log(e.detail.value)
  61. this.setData({
  62. phone: e.detail.value
  63. })
  64. console.log('预约')
  65. },
  66. // 填写车牌号
  67. bindLicense:function(e){
  68. console.log(e.detail.value)
  69. this.setData({
  70. license_number: e.detail.value
  71. })
  72. console.log('预约')
  73. },
  74. // 车辆型号
  75. bindModel:function(e){
  76. console.log(e.detail.value)
  77. this.setData({
  78. car_model: e.detail.value
  79. })
  80. console.log('预约')
  81. },
  82. // 兑换码
  83. bindRedemptionCode:function(e){
  84. this.setData({
  85. exchange_code: e.detail.value
  86. })
  87. },
  88. // 选中
  89. afterTapDate(e) {
  90. console.log('afterTapDate', e.detail)
  91. if(e.detail.week == 0){
  92. console.log('week为周日',e.detail.week)
  93. wx.showModal({
  94. title: e.detail.date + '日为周末, 周末闭店休息',
  95. showCancel: false
  96. })
  97. this.setData({
  98. appoint_date: ''
  99. })
  100. }else{
  101. this.setData({
  102. appoint_date: `${e.detail.year}-${e.detail.month}-${e.detail.date}`
  103. })
  104. }
  105. },
  106. // 确定预约
  107. onSubmit:function(){
  108. if(this.data.name == ''){
  109. wx.showToast({
  110. icon: 'none',
  111. title: '请填写预约人姓名',
  112. })
  113. return
  114. }
  115. if(this.data.phone == ''){
  116. wx.showToast({
  117. icon: 'none',
  118. title: '请填写预约人电话',
  119. })
  120. return
  121. }
  122. if(this.data.license_number == ''){
  123. wx.showToast({
  124. icon: 'none',
  125. title: '请填写预约人车牌号',
  126. })
  127. return
  128. }
  129. if(this.data.car_model == ''){
  130. wx.showToast({
  131. icon: 'none',
  132. title: '请填写预约人车辆型号',
  133. })
  134. return
  135. }
  136. if(this.data.appoint_time == ''){
  137. wx.showToast({
  138. icon: 'none',
  139. title: '请填写预约时间',
  140. })
  141. return
  142. }
  143. if(this.data.appoint_date == ''){
  144. wx.showToast({
  145. icon: 'none',
  146. title: '请选择预约日期',
  147. })
  148. return
  149. }
  150. let that = this
  151. let e = {}
  152. e.name = that.data.name
  153. e.phone = that.data.phone
  154. e.license_number = that.data.license_number
  155. e.car_model = that.data.car_model
  156. e.appoint_date = that.data.appoint_date
  157. e.exchange_code = that.data.exchange_code
  158. e.appoint_time = that.data.appoint_time
  159. getApp().request({
  160. url: getApp().api.yuyue.submit,
  161. method: "POST",
  162. data: e,
  163. success: function (res) {
  164. console.log(res)
  165. wx.showLoading({
  166. title: '提交中',
  167. })
  168. if(res.code == 0){
  169. setTimeout(function(){
  170. wx.hideLoading();
  171. wx.redirectTo({
  172. url: '/pages/check-submit/check-submit?data=' + encodeURIComponent(JSON.stringify(res.data)) + '&phone='+that.data.phone,
  173. })
  174. },1500)
  175. }else{
  176. wx.showToast({
  177. icon: 'none',
  178. title: res.msg,
  179. })
  180. }
  181. },
  182. fail: function(res){
  183. wx.showToast({
  184. icon: 'none',
  185. title: res.msg,
  186. })
  187. }
  188. })
  189. },
  190. formatDate(date) {
  191. date = new Date(date);
  192. return `${date.getMonth() + 1}/${date.getDate()}`;
  193. },
  194. onConfirm(event) {
  195. this.setData({
  196. show: false,
  197. date: this.formatDate(event.detail),
  198. });
  199. },
  200. // bindDateChange: function(e) {
  201. // console.log('picker发送选择改变,携带值为', e.detail.value)
  202. // this.setData({
  203. // date: e.detail.value
  204. // })
  205. // },
  206. bindTimeChange: function(e) {
  207. console.log('picker发送选择改变,携带值为', e.detail.value)
  208. this.setData({
  209. appoint_time: e.detail.value
  210. })
  211. },
  212. loadData: function () {
  213. var a = this;
  214. getApp().core.showLoading({
  215. title: "正在加载",
  216. mask: !0
  217. }), getApp().request({
  218. url: getApp().api.share.index,
  219. success: function (e) {
  220. if (0 == e.code) {
  221. if (e.data.share_setting) var t = e.data.share_setting;
  222. else t = e.data;
  223. getApp().core.setStorageSync(getApp().const.SHARE_SETTING, t), a.setData({
  224. share_setting: t
  225. })
  226. a.setData({
  227. user_info_show: false
  228. })
  229. }else if (1 == e.code){
  230. a.setData({
  231. user_info_show: true
  232. })
  233. }
  234. },
  235. complete: function () {
  236. getApp().core.hideLoading()
  237. }
  238. })
  239. },
  240. });