trip.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. const util = require("../../../utils/util.js");
  2. const app = getApp();
  3. Page({
  4. data: {
  5. datas:{},
  6. endDate:"2018-01-01",
  7. birthday: "2010-01-01",
  8. cardTypeStr:'',
  9. mask:false,
  10. maskTwo:false,
  11. status:1,
  12. orderid:'',
  13. refundpwd:'',
  14. imgData:{},
  15. imgUrl: util.config.imgUrl,
  16. aid:'',
  17. title:'',
  18. },
  19. onLoad(options) {
  20. this.getData(options.orderid,options.refundpwd)
  21. },
  22. getData(orderid,refundpwd){
  23. console.log(orderid,refundpwd);
  24. let that =this;
  25. util.ajax({
  26. func:"order/getOrderChildInfo",
  27. data:{"orderid":orderid,"consumeId":refundpwd}
  28. },function(res){
  29. if(res.code == 0){
  30. let datas = res.data,imgData={};
  31. let cardTypeStr = util.cardType(datas.cardType);
  32. imgData['passport'] = datas.passport || '';
  33. imgData['householder'] = datas.householder || '';
  34. imgData['parentsPage'] = datas.parentsPage || '';
  35. imgData['childPage'] = datas.childPage || '';
  36. imgData['parentsIdCardFront'] = datas.parentsIdCardFront || '';
  37. imgData['parentsIdCardBack'] = datas.parentsIdCardBack || '';
  38. imgData['birthCertificate'] = datas.birthCertificate || '';
  39. imgData['idCardFront'] = datas.idCardFront || '';
  40. imgData['idCardBack'] = datas.idCardBack || '';
  41. imgData['sealPage'] = datas.sealPage || '';
  42. // if(!datas.bodyType || datas.bodyType == '') datas.bodyType = '1';
  43. that.setData({cardTypeStr,datas,orderid,refundpwd,imgData})
  44. }else{
  45. util.showTips(res.reason);
  46. }
  47. });
  48. },
  49. formSubmit(e) {
  50. let datas = this.data.datas,that = this,data = e.detail.value,imgData=this.data.imgData;
  51. data['oid'] = this.data.orderid;
  52. data['consumeId'] = this.data.refundpwd;
  53. data['birthday'] = this.data.cardTypeStr == '内地身份证号'? this.getBirthday(data.idcard):'';
  54. data['cardType'] = datas.cardType;
  55. if(datas.travelMode == 2 && util.isEmpty(data['passportName'])){
  56. util.showTips("请填写儿童护照姓名。");
  57. return false;
  58. }
  59. if(util.isEmpty(data['height']) || /[^0-9]/g.test(data['height'])){
  60. util.showTips("请填写数字类型的身高。");
  61. return false;
  62. }
  63. if(util.isEmpty(data['weight']) || /[^0-9]/g.test(data['weight'])){
  64. util.showTips("请填写数字类型的体重。");
  65. return false;
  66. }
  67. if(util.isEmpty(data['bodyType'])){
  68. util.showTips("请选择儿童体型信息。");
  69. return false;
  70. }
  71. if(util.isEmpty(data['allergy'])){
  72. util.showTips("请填写是否有药物或食品过敏。");
  73. return false;
  74. }
  75. if(util.isEmpty(data['diet'])){
  76. util.showTips("请填写是否有饮食禁忌。");
  77. return false;
  78. }
  79. if(util.isEmpty(data['bloodOrMedical'])){
  80. util.showTips("请填写是否有特殊血型/有无病史。");
  81. return false;
  82. }
  83. if(util.isEmpty(data['character'])){
  84. util.showTips("请填写在活动期间期待孩子哪方面性格的培养。");
  85. return false;
  86. }
  87. if(util.isEmpty(data['especiallyRemark'])){
  88. util.showTips("请填写特别备注。");
  89. return false;
  90. }
  91. if(datas.travelMode == 1){
  92. data['idCardFront'] = imgData['idCardFront'] || "";
  93. data['idCardBack'] = imgData['idCardBack'] || "";
  94. data['childPage'] = imgData['childPage'] || "";
  95. data['sealPage'] = imgData['sealPage'] || "";
  96. if(util.isEmpty(data['idCardFront']) && util.isEmpty(data['idCardBack']) && util.isEmpty(data['childPage']) && util.isEmpty(data['sealPage'])){
  97. util.showTips("请上传相关证件资料一或资料二。");
  98. return false;
  99. }else{
  100. if(!util.isEmpty(data['idCardFront']) && !util.isEmpty(data['idCardBack'])){
  101. data['cert'] = 0;
  102. }else if(!util.isEmpty(data['idCardFront']) || !util.isEmpty(data['idCardBack'])){
  103. data['cert'] = 1;
  104. }
  105. if(data['cert'] != 0){
  106. if(!util.isEmpty(data['childPage']) && !util.isEmpty(data['sealPage'])){
  107. data['cert'] = 0;
  108. }else if(!util.isEmpty(data['childPage']) || !util.isEmpty(data['sealPage'])){
  109. data['cert'] = 2;
  110. }
  111. }
  112. if(data['cert'] == 1){
  113. util.showTips("请上传完整的资料一相关证件。");
  114. return false;
  115. }else if(data['cert'] == 2){
  116. util.showTips("请上传完整的资料二相关证件。");
  117. return false;
  118. }
  119. }
  120. }else if(datas.travelMode == 2){
  121. data['passport'] = imgData['passport'] || "";
  122. data['householder'] = imgData['householder'] || "";
  123. data['parentsPage'] = imgData['parentsPage'] || "";
  124. data['childPage'] = imgData['childPage'] || "";
  125. data['parentsIdCardFront'] = imgData['parentsIdCardFront'] || "";
  126. data['parentsIdCardBack'] = imgData['parentsIdCardBack'] || "";
  127. data['birthCertificate'] = imgData['birthCertificate'] || "";
  128. if(util.isEmpty(data['passport'])){
  129. util.showTips("请上传护照证件。");
  130. return false;
  131. }
  132. if(util.isEmpty(data['householder']) && util.isEmpty(data['parentsPage']) && util.isEmpty(data['childPage']) && util.isEmpty(data['parentsIdCardFront']) && util.isEmpty(data['parentsIdCardBack']) && util.isEmpty(data['birthCertificate'])){
  133. util.showTips("请上传相关证件资料一或资料二。");
  134. return false;
  135. }else{
  136. if(!util.isEmpty(data['householder']) && !util.isEmpty(data['parentsPage']) && !util.isEmpty(data['childPage'])){
  137. data['cert'] = 0;
  138. }else if(!util.isEmpty(data['householder']) || !util.isEmpty(data['parentsPage']) || !util.isEmpty(data['childPage'])){
  139. data['cert'] = 1;
  140. }
  141. if(data['cert'] != 0){
  142. if(!util.isEmpty(data['parentsIdCardFront']) && !util.isEmpty(data['parentsIdCardBack']) && !util.isEmpty(data['birthCertificate'])){
  143. data['cert'] = 0;
  144. }else if(!util.isEmpty(data['parentsIdCardFront']) || !util.isEmpty(data['parentsIdCardBack']) || !util.isEmpty(data['birthCertificate'])){
  145. data['cert'] = 2;
  146. }
  147. }
  148. if(data['cert'] == 1){
  149. util.showTips("请上传完整的资料一相关证件。");
  150. return false;
  151. }else if(data['cert'] == 2){
  152. util.showTips("请上传完整的资料一或者资料二相关证件。");
  153. return false;
  154. }
  155. }
  156. }
  157. util.ajax({
  158. func:"order/updateChildArchives",
  159. data:data
  160. },function(res){
  161. if(res.code == 0){
  162. util.showTips("信息提交成功!",2000);
  163. setTimeout(function(){
  164. wx.navigateBack();
  165. },2000)
  166. }
  167. });
  168. },
  169. getBirthday(val){
  170. var birthday = [];
  171. birthday.push(val.substring(6, 10));
  172. birthday.push(val.substring(10, 12));
  173. birthday.push(val.substring(12, 14));
  174. return birthday.join("-");
  175. },
  176. prompt(){
  177. this.setData({mask:true})
  178. },
  179. maskBtn(){
  180. this.setData({mask:false,maskTwo:false})
  181. },
  182. maskShow(e){
  183. this.setData({
  184. maskTwo:true,
  185. status:e.currentTarget.dataset.id
  186. })
  187. },
  188. chooseImg(e){
  189. let id = e.currentTarget.dataset.id,
  190. imgData=this.data.imgData,
  191. that= this;
  192. wx.chooseImage({
  193. count: 1,
  194. sizeType: ['original', 'compressed'],
  195. sourceType: ['album', 'camera'],
  196. success: function (res) {
  197. console.log(res);
  198. wx.uploadFile({
  199. url: util.config.apiServer + 'user/upload_img_app.do',
  200. filePath: res.tempFilePaths[0],
  201. name: 'avatarFile',
  202. formData:{
  203. "rid":app.globalData.userInfo['rid']
  204. },
  205. success: function(reason){
  206. let obj = JSON.parse(reason.data)
  207. if(reason.statusCode==200&&obj.code == 0){
  208. switch(id)
  209. {
  210. case '0':imgData['passport'] = obj.data.image;
  211. break;
  212. case '1':imgData['householder'] = obj.data.image;
  213. break;
  214. case '2':imgData['parentsPage'] = obj.data.image;
  215. break;
  216. case '3':imgData['childPage'] = obj.data.image;
  217. break;
  218. case '4':imgData['parentsIdCardFront'] = obj.data.image;
  219. break;
  220. case '5':imgData['parentsIdCardBack'] = obj.data.image;
  221. break;
  222. case '6':imgData['birthCertificate'] = obj.data.image;
  223. break;
  224. case '7':imgData['idCardFront'] = obj.data.image;
  225. break;
  226. case '8':imgData['idCardBack'] = obj.data.image;
  227. break;
  228. case '9':imgData['sealPage'] = obj.data.image;
  229. break;
  230. }
  231. that.setData({imgData})
  232. }
  233. }
  234. })
  235. }
  236. })
  237. },
  238. delImg(e){
  239. let id = e.currentTarget.dataset.id,imgData=this.data.imgData;
  240. switch(id)
  241. {
  242. case '0':imgData['passport'] = '';
  243. break;
  244. case '1':imgData['householder'] = '';
  245. break;
  246. case '2':imgData['parentsPage'] = '';
  247. break;
  248. case '3':imgData['childPage'] = '';
  249. break;
  250. case '4':imgData['parentsIdCardFront'] = '';
  251. break;
  252. case '5':imgData['parentsIdCardBack'] = '';
  253. break;
  254. case '6':imgData['birthCertificate'] = '';
  255. break;
  256. case '7':imgData['idCardFront'] = '';
  257. break;
  258. case '8':imgData['idCardBack'] = '';
  259. break;
  260. case '9':imgData['sealPage'] = '';
  261. break;
  262. }
  263. this.setData({imgData})
  264. }
  265. })