infoCollect.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. import Dialog from '@vant/weapp/dialog/dialog';
  2. const util = require('../../../utils/util');
  3. const check = require('../../../utils/check');
  4. const api = require('../../../config/api');
  5. const app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. infoGoods: app.globalData.infoGoods,
  12. customerName: '',
  13. customerTel: '',
  14. address: '',
  15. addressId: '',
  16. serviceModelText: '请选择',
  17. serviceModel: '',
  18. // startServiceTime:'请选择',
  19. typePickerShow: false,
  20. timePickerShow: false,
  21. serviceModelList: [{
  22. id: '1',
  23. name: '钟点工'
  24. },
  25. {
  26. id: '2',
  27. name: '白班保姆'
  28. },
  29. {
  30. id: '3',
  31. name: '住家保姆'
  32. },
  33. // {id:'4',name:'月嫂'},
  34. // {id:'5',name:'代班保姆-钟点工'},
  35. // {id:'6',name:'代班保姆-保姆'},
  36. ],
  37. // typeColumns:['钟点工','白班保姆','住家保姆','月嫂','代班保姆-钟点工','代班保姆-保姆'],
  38. typeColumns: ['钟点工', '白班保姆', '住家保姆'],
  39. currentDate: new Date().getTime(),
  40. minDate: new Date().getTime(),
  41. recommender: '', //推荐人
  42. recommenderName: ''
  43. },
  44. /**
  45. * 生命周期函数--监听页面加载
  46. */
  47. onLoad: function (options) {
  48. },
  49. selectAddress() {
  50. wx.navigateTo({
  51. url: '/pages/ucenter/address/address',
  52. })
  53. },
  54. formatterDate(type, value) {
  55. if (type === 'year') {
  56. return `${value}年`;
  57. }
  58. if (type === 'month') {
  59. return `${value}月`;
  60. }
  61. return value;
  62. },
  63. onTimeCancel() {
  64. this.setData({
  65. timePickerShow: false,
  66. });
  67. },
  68. onTimeConfirm(event) {
  69. console.log(event);
  70. this.setData({
  71. startServiceTime: util.formetdate(new Date(event.detail)),
  72. timePickerShow: false,
  73. });
  74. },
  75. showServicePicker() {
  76. this.setData({
  77. typePickerShow: true,
  78. });
  79. },
  80. showTimePicker() {
  81. this.setData({
  82. timePickerShow: true,
  83. });
  84. },
  85. onTypeCancel: function () {
  86. this.setData({
  87. typePickerShow: false,
  88. });
  89. },
  90. onTypeConfirm: function (event) {
  91. this.setData({
  92. serviceModel: this.data.serviceModelList[event.detail.index].id,
  93. serviceModelText: event.detail.value,
  94. typePickerShow: false,
  95. });
  96. },
  97. recommendChange() {
  98. if (this.data.recommender.length == 6) {
  99. util.request(api.addClueRecommender, {
  100. recCode: this.data.recommender
  101. }).then(res => {
  102. if (res.errno === 0)
  103. this.setData({
  104. recommenderName: res.data
  105. })
  106. else {
  107. wx.showToast({
  108. title: res.errmsg,
  109. icon: 'none',
  110. duration: 2000
  111. });
  112. this.setData({
  113. recommenderName: "不存在"
  114. })
  115. }
  116. })
  117. }
  118. },
  119. confirmSubmit() {
  120. if (this.data.customerName == '') {
  121. wx.showToast({
  122. title: '请输入客户名称',
  123. icon: 'none',
  124. duration: 2000
  125. });
  126. return false;
  127. }
  128. if (this.data.customerTel == '') {
  129. wx.showToast({
  130. title: '请输入手机号',
  131. icon: 'none',
  132. duration: 2000
  133. });
  134. return false;
  135. }
  136. if (!check.isValidPhone(this.data.customerTel)) {
  137. // util.showErrorToast('请输入正确的手机号码');
  138. wx.showToast({
  139. title: '输入正确的手机号码',
  140. icon: 'none',
  141. duration: 2000
  142. });
  143. return false;
  144. }
  145. if (this.data.address ==''||this.data.address == '请填写服务住址') {
  146. wx.showToast({
  147. title: '请选择住址',
  148. icon: 'none',
  149. duration: 2000
  150. });
  151. return false;
  152. }
  153. console.info(this.data.address)
  154. console.info(this.data.address.indexOf("市"))
  155. if(this.data.address.indexOf("市")<0){
  156. wx.showToast({
  157. title: '请填写所在的城市',
  158. icon: 'none',
  159. duration: 2000
  160. });
  161. return false;
  162. }
  163. if (this.data.serviceModelText == '请选择') {
  164. wx.showToast({
  165. title: '请选择服务类型',
  166. icon: 'none',
  167. duration: 2000
  168. });
  169. return false;
  170. }
  171. // if(this.data.startServiceTime=='请选择'){
  172. // wx.showToast({
  173. // title: '请选择服务时间',
  174. // icon: 'none',
  175. // duration: 2000
  176. // });
  177. // return false;
  178. // }
  179. console.log('校验成功');
  180. let userInfo = wx.getStorageSync('userInfo');
  181. wx.showLoading({
  182. title: '提交中...',
  183. mask: true,
  184. });
  185. util.request(api.addClue, {
  186. "customerName": this.data.customerName,
  187. "customerTel": this.data.customerTel,
  188. "mallAddressId": this.data.addressId,
  189. "serviceModel": this.data.serviceModel,
  190. "address":this.data.address,
  191. // "startServiceTime": this.data.startServiceTime,
  192. "userId": userInfo.id,
  193. "recommmender":this.data.recommender,
  194. "recommmenderName":this.data.recommenderName
  195. }, "POST")
  196. .then((res) => {
  197. wx.hideLoading();
  198. if (res.errno == 0) {
  199. app.globalData.infoGoods.type = '2';
  200. wx.navigateTo({
  201. url: '/pages/checkout/payResult/payResult',
  202. })
  203. } else {
  204. util.showErrorToast(res.errmsg);
  205. }
  206. }).catch(() => {
  207. wx.hideLoading();
  208. });
  209. },
  210. /**
  211. * 生命周期函数--监听页面初次渲染完成
  212. */
  213. onReady: function () {
  214. },
  215. /**
  216. * 生命周期函数--监听页面显示
  217. */
  218. onShow: function () {
  219. // let addressId = wx.getStorageSync('addressId');
  220. // if (addressId === "") {
  221. // addressId = 0;
  222. // }
  223. let addressId = app.globalData.infoAddress.addressId;
  224. if (addressId != '') {
  225. this.setData({
  226. addressId: addressId,
  227. address: app.globalData.infoAddress.addressDetail
  228. })
  229. }
  230. },
  231. /**
  232. * 生命周期函数--监听页面隐藏
  233. */
  234. onHide: function () {
  235. },
  236. /**
  237. * 生命周期函数--监听页面卸载
  238. */
  239. onUnload: function () {
  240. },
  241. /**
  242. * 页面相关事件处理函数--监听用户下拉动作
  243. */
  244. onPullDownRefresh: function () {
  245. },
  246. /**
  247. * 页面上拉触底事件的处理函数
  248. */
  249. onReachBottom: function () {
  250. },
  251. /**
  252. * 用户点击右上角分享
  253. */
  254. onShareAppMessage: function () {
  255. }
  256. })