index.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. const util = require('../../../utils/util.js');
  2. const app = getApp();
  3. Page({
  4. data: {
  5. num: 0, //套餐数量
  6. agreement: false, //同意合同
  7. pay: true, //同意微信支付
  8. qptype: 0,
  9. btype: -1, //上页面传入的活动类型 0(默认)-普通购买 1-预付 2-付尾款 3-候补购买
  10. recommender: '', //推荐人
  11. recommenderStatus: '',
  12. street: '', //街道社区
  13. streetStatus: '',
  14. atype: 0, //0活动1电商
  15. recommenderShow: false,
  16. recommenderShowText: '',
  17. datas: {}, //payinfo数据
  18. imgPath: util.config.imgPath,
  19. userInfo: app.globalData.userInfo,
  20. formData: {
  21. aid: '',
  22. sid: '',
  23. vid: '',
  24. cid: '',
  25. useCoin: 0,
  26. useBalance: 0,
  27. useUserCoin: 1,
  28. meals: ''
  29. },
  30. total: {
  31. coin: '0.00', //钱包
  32. coupons: '0.00', //现金券
  33. ldiscount: '0.00', //早鸟优惠价格
  34. mdiscount: '0.00', //会员折扣价
  35. price: '0.00', //总价
  36. sumBalance: '0.00', //账户余额
  37. ableBalance: '0.00', //账户余额可用
  38. },
  39. idcards: {},
  40. textarea: '', //备注
  41. phoneNum: '', //手机号码
  42. mailAddress: '', //邮寄地址
  43. shipAddress: '', //收货地址
  44. email: '', //邮箱
  45. familyCommittee: '',
  46. travelDates: '', //出行日期
  47. groupid: '', //拼团号
  48. shareId: '', //分享id
  49. paying: false, //支付中
  50. percent: 0,
  51. alone: 0, //0单独报名,1拼团
  52. initialSku: {},
  53. havePerson: false,
  54. sku: {
  55. quantity: 0, //购买数量
  56. sessions: {},
  57. meals: {},
  58. quota: 999, //限购
  59. },
  60. show: {
  61. address: false,
  62. vouche: false,
  63. integral: false
  64. },
  65. voucheConfig: {},
  66. maskShow: false,
  67. presellOpen: 0,
  68. military: 0,
  69. ageLimit: ''
  70. },
  71. onLoad(options) {
  72. console.log(options)
  73. wx.removeStorageSync('idcards');
  74. this.data.formData.aid = options.aid;
  75. this.setData({
  76. formData: this.data.formData,
  77. qptype: options.qptype || '',
  78. btype: options.btype,
  79. groupid: (!util.isEmpty(options.groupid) && options.groupid != 'null' && options.groupid != 'undefined') ? options.groupid : '',
  80. recommenderStatus: options.recommender,
  81. streetStatus: options.street,
  82. alone: options.createGroup != undefined ? options.createGroup : 0,
  83. initialSku: {
  84. sessionsIndex: parseInt(options.sessionsIndex),
  85. mealsIndex: parseInt(options.mealsIndex),
  86. quantity: parseInt(options.quantity)
  87. },
  88. atype: parseInt(options.atype),
  89. presellOpen: options.presellOpen,
  90. military: options.military,
  91. ageLimit: options.ageLimit
  92. });
  93. this.payinfo();
  94. if (util.isObjEmpty(options.recommender) || options.recommender == '0') {
  95. this.setData({
  96. recommenderShow: false
  97. })
  98. } else if (options.recommender == '1') {
  99. this.setData({
  100. recommenderShow: true,
  101. recommenderShowText: '请填写推荐人,没有填无'
  102. })
  103. } else if (options.recommender == '2') {
  104. this.setData({
  105. recommenderShow: true,
  106. recommenderShowText: '非必填,若有请填写'
  107. })
  108. }
  109. },
  110. onShow() {
  111. let idcards = wx.getStorageSync('idcards');
  112. this.data.formData.cid = !util.isObjEmpty(idcards) ? idcards.ids.join(",") : '';
  113. this.setData({
  114. idcards,
  115. formData: this.data.formData
  116. });
  117. this.setData({
  118. userInfo: app.globalData.userInfo
  119. });
  120. if (!util.isObjEmpty(this.data.sku.meals)) this.safe();
  121. },
  122. onUnload() {
  123. wx.removeStorageSync('idcards');
  124. },
  125. // 判断是否含有出行人信息
  126. getIdcardinfoList() {
  127. var self = this;
  128. util.ajax({
  129. func: "user/idcardinfo_list",
  130. data: {
  131. type: this.data.ctype == 0 ? 0 : -1
  132. },
  133. load: false
  134. }, function (res) {
  135. if (res.code == 0) {
  136. self.setData({
  137. havePerson: res.data.length > 0 ? true : false
  138. })
  139. } else {
  140. util.showTips(res.reason)
  141. }
  142. })
  143. },
  144. payinfo() {
  145. let that = this,
  146. userInfo = app.globalData.userInfo;
  147. util.ajax({
  148. func: "article/payinfo",
  149. data: {
  150. "aid": that.data.formData.aid,
  151. "qptype": that.data.qptype ? that.data.qptype : 0
  152. }
  153. }, function (res) {
  154. if (res.code == 0) {
  155. // res.data.remark = res.data.remark || (that.data.atype==0? "请填写家长特别叮嘱,若无则填写无。":res.data.sremark == 'yes'? '给卖家留言,非必填':'');
  156. // if (that.data.presellOpen ==1) {
  157. // that.data.total.price = util.toMoney(res.data.presellPrice, ',');
  158. // }
  159. that.setData({
  160. datas: res.data,
  161. userInfo,
  162. total: that.data.total,
  163. formData: that.data.formData,
  164. phoneNum: res.data.buyInfo.contactPhone || '',
  165. textarea: res.data.orderRemark || '',
  166. mailAddress: res.data.buyInfo.mailAddress || '',
  167. email: res.data.needEmail != 'no' ? res.data.buyInfo.email : '',
  168. street: res.data.buyInfo.street || ''
  169. });
  170. wx.reportAnalytics('enter_enlist', {
  171. aid: that.data.formData.aid,
  172. title: res.data.title
  173. });
  174. that.getSku();
  175. that.safe();
  176. that.getIdcardinfoList()
  177. that.shipInfo();
  178. } else if (res.code == 3003) {
  179. wx.showModal({
  180. title: '提示',
  181. content: res.reason,
  182. showCancel: false,
  183. success: function (data) {
  184. if (data.confirm) {
  185. wx.navigateBack();
  186. }
  187. }
  188. })
  189. } else {
  190. util.showTips(res.reason);
  191. }
  192. })
  193. },
  194. getSku() { //sku
  195. let sku = this.data.sku,
  196. info = this.data.datas,
  197. initialSku = this.data.initialSku;
  198. sku.sessions = this.getSkuInfo(info.sessions, 0, 'sid', this.data.initialSku.sessionsIndex);
  199. this.data.formData.sid = sku.sessions.sid;
  200. sku.meals = this.getSkuInfo(sku.sessions.alipays, 0, 'pid', this.data.initialSku.mealsIndex);
  201. sku.meals.originalPrice = util.toMoney(sku.meals.originalPrice)
  202. sku.meals.price = this.data.presellOpen == 0 ? util.toMoney(sku.meals.price) : util.toMoney(this.data.datas.presellPrice)
  203. sku.quantity = initialSku.quantity;
  204. sku.quota = this.data.btype == -1 ? (parseInt(sku.meals.actNum) < sku.meals.maxT ? parseInt(sku.meals.actNum) : sku.meals.maxT) : (parseInt(sku.meals.waitActNum) < sku.meals.maxT ? parseInt(sku.meals.waitActNum) : sku.meals.maxT);
  205. this.setData({
  206. sku,
  207. formData: this.data.formData
  208. })
  209. },
  210. // 循环获取场次信息
  211. getSkuInfo(arr, i, type, id) {
  212. if (arr.length > 0 && i < arr.length) {
  213. if (arr[i][type] == id) {
  214. return arr[i];
  215. } else {
  216. return this.getSkuInfo(arr, i + 1, type, id)
  217. }
  218. }
  219. },
  220. numAdd() {
  221. let sku = this.data.sku;
  222. if (sku.quantity >= sku.quota) {
  223. util.showTips("库存不足");
  224. } else {
  225. sku.quantity = parseInt(sku.quantity) + 1;
  226. this.setData({
  227. sku
  228. });
  229. this.removeIdcards();
  230. this.safe();
  231. }
  232. },
  233. numReduce() {
  234. let sku = this.data.sku;
  235. if (sku.quantity <= 1) {
  236. util.showTips("至少选择1件");
  237. } else {
  238. sku.quantity = parseInt(sku.quantity) - 1;
  239. this.setData({
  240. sku
  241. });
  242. this.removeIdcards();
  243. this.safe();
  244. }
  245. },
  246. numChange(e) {
  247. let sku = this.data.sku;
  248. if (parseInt(e.detail.value) > sku.quota) {
  249. util.showTips("库存不足");
  250. sku.quantity = sku.quota;
  251. } else if (parseInt(e.detail.value) <= 0 || util.isEmpty(e.detail.value)) {
  252. util.showTips("至少选择1件");
  253. sku.quantitym = 1;
  254. } else {
  255. sku.quantity = e.detail.value;
  256. }
  257. this.setData({
  258. sku
  259. });
  260. this.removeIdcards();
  261. this.safe();
  262. },
  263. removeIdcards() {
  264. wx.removeStorageSync('idcards');
  265. this.setData({
  266. idcards: []
  267. })
  268. },
  269. openQuestion() {
  270. this.setData({
  271. maskShow: true
  272. })
  273. },
  274. maskClose() {
  275. this.setData({
  276. maskShow: false
  277. })
  278. },
  279. agree() {
  280. this.setData({
  281. agreement: !this.data.agreement
  282. })
  283. },
  284. choosePay() {
  285. this.setData({
  286. pay: !this.data.pay
  287. })
  288. },
  289. // 选择出行人
  290. chooseCard() {
  291. var quantity = this.data.sku.quantity;
  292. if (quantity > 0) {
  293. wx.navigateTo({
  294. url: '/pages/account/cards/index?quantity=' + quantity + '&mage=' + this.data.datas.mage + '&lage=' + this.data.datas.lage + '&sparent=' + this.data.datas.sparent + '&adultMinAge=' + this.data.datas.adultMinAge + '&adultMaxAge=' + this.data.datas.adultMaxAge + '&needClothesSize=' + this.data.datas.clothesSize + '&needShoeSize=' + this.data.datas.shoeSize + '&ageLimit=' + this.data.ageLimit + '&campSex=' + this.data.sku.meals.campSex + '&military=' + this.data.military + '&sid=' + this.data.sku.sessions.sid
  295. })
  296. } else {
  297. util.showTips('请选择场次或者套餐数量');
  298. }
  299. },
  300. // 查看数组是否有重复元素
  301. hasDuplicate(arr) {
  302. if (arr && arr.length > 0) {
  303. return new Set(arr).size !== arr.length;
  304. } else {
  305. return false
  306. }
  307. },
  308. safe() {
  309. let that = this;
  310. that.data.formData.meals = that.data.sku.meals.pid + '|' + that.data.sku.quantity;
  311. that.data.formData.btype = this.data.btype != -1 ? this.data.btype : (this.data.presellOpen != 0 ? 1 : 0);
  312. util.ajax({
  313. func: "voucher/pay_mvoucher", //会员折扣,现金券,钱包
  314. data: that.data.formData,
  315. load: false
  316. }, function (res) {
  317. if (res.code == 0 && res.data != "") {
  318. let data = res.data;
  319. that.data.total.coin = util.toMoney(data.coin, ',');
  320. that.data.total.coupons = util.toMoney(data.price, ',');
  321. that.data.total.ldiscount = util.toMoney(data.ldiscount, ',');
  322. that.data.total.mdiscount = util.toMoney(data.mdiscount, ',');
  323. // if (this.data.presellOpen !=1) {
  324. that.data.total.price = util.toMoney(data.totalFee, ',');
  325. // }
  326. that.data.total.sumBalance = util.toMoney(data.sumBalance, ',');
  327. that.data.total.sumBalanceNum = data.sumBalance;
  328. that.data.total.sumUserCoin = data.sumUserCoin || 0;
  329. that.data.total.userCoin = data.userCoin || 0;
  330. // accountBalance 账户余额是否可用,0 不可 1 可
  331. // commissionWallet 佣金钱包是否可用 同上
  332. that.data.total.accountBalance = data.accountBalance;
  333. that.data.total.commissionWallet = data.commissionWallet;
  334. that.data.total.ableBalance = util.toMoney(data.ableBalance, ',');
  335. that.data.formData.vid = data.id || '';
  336. that.setData({
  337. total: that.data.total,
  338. formData: that.data.formData
  339. });
  340. } else {
  341. // that.clearSafe();
  342. }
  343. })
  344. },
  345. getPackId() {
  346. return (this.data.sku.meals.pid || '') + '|' + this.data.sku.quantity;
  347. },
  348. goCoupon() {
  349. var packIds = this.getPackId();
  350. if (this.data.datas.needIdcard != 'no' && util.isObjEmpty(this.data.idcards)) {
  351. util.showTips('请先选择购买儿童的身份信息。');
  352. return false;
  353. }
  354. this.data.show = {
  355. address: false,
  356. vouche: true,
  357. integral: false
  358. };
  359. let voucheConfig = {
  360. packIds: packIds,
  361. aid: this.data.formData.aid,
  362. sid: this.data.formData.sid,
  363. vid: this.data.formData.vid,
  364. cid: this.data.formData.cid
  365. }
  366. this.setData({
  367. voucheConfig,
  368. show: this.data.show
  369. })
  370. },
  371. goPay() {
  372. var packIds = this.getPackId(),
  373. phoneNum = this.data.phoneNum,
  374. idcards = this.data.idcards,
  375. num = this.data.sku.quantity,
  376. datas = this.data.datas,
  377. userInfo = app.globalData.userInfo,
  378. email = this.data.email;
  379. if (util.isObjEmpty(this.data.sku.meals)) {
  380. util.showTips('请先选择场次套餐,再付款。');
  381. return false;
  382. }
  383. if (datas.needIdcard != 'no' && this.data.atype == 0) {
  384. if (idcards.ids) {
  385. if (idcards.ids.length == 0) {
  386. util.showTips('请先选择出行人的身份信息。');
  387. return false;
  388. } else if (idcards.ids.length != num) {
  389. util.showTips('请设置' + num + '人的身份信息。');
  390. return false;
  391. }
  392. } else {
  393. util.showTips('请先选择出行人的身份信息。');
  394. return false;
  395. }
  396. }
  397. if (datas.sphone == 'yes' && util.isPhone(phoneNum)) {
  398. util.showTips('请填写正确的用户联系手机号码。');
  399. return false;
  400. }
  401. if (datas.smailAddress == 'yes' && !this.data.mailAddress) {
  402. util.showTips(this.data.atype == 1 ? '请填写收货地址。' : '请填写邮寄信息。');
  403. return false;
  404. }
  405. // var myreg = /^([a-zA-Z0-9]+[_|\_|\.|-]+)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.|-]+)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/gi;
  406. if (datas.needEmail && datas.needEmail == 'yes' && !email) {
  407. util.showTips('请填写电子邮箱。');
  408. return false;
  409. }
  410. // if (datas.needEmail == 'yes' && !myreg.test(email)) {
  411. // util.showTips('请正确填写电子邮箱。');
  412. // return false;
  413. // }
  414. if (datas.familyCommittee == '1' && this.data.familyCommittee == '' && this.data.atype == 0) {
  415. util.showTips('请填写是否为家委会');
  416. return false;
  417. }
  418. if (this.data.streetStatus == '1' && this.data.street == '') {
  419. util.showTips('请填写街道社区,没有填无');
  420. return false;
  421. }
  422. if (this.data.recommenderStatus == '1' && this.data.recommender == '') {
  423. util.showTips('请填写推荐人,没有填无');
  424. return false;
  425. }
  426. if (this.data.recommenderStatus == '1' && this.data.recommender.length > 10) {
  427. util.showTips('请正确填写推荐人');
  428. return false;
  429. }
  430. if (datas.travelDates == 'yes' && !this.data.travelDates && this.data.atype == 0) {
  431. util.showTips('请选择出行日期。');
  432. return false;
  433. }
  434. if (this.data.atype == 0 && datas.sremark == 'yes' && this.data.textarea == '') {
  435. util.showTips('请填写家长叮嘱等备注信息。');
  436. return false;
  437. }
  438. if (datas.agreement && !this.data.agreement && this.data.atype == 0 && this.data.presellOpen == 0) {
  439. util.showTips('请认真阅读相关协议条款,并认可同意。');
  440. return false;
  441. }
  442. if (!this.data.paying) {
  443. // this.setData({ paying: true });
  444. this.WeChatPay();
  445. }
  446. console.log(this.data.formData);
  447. },
  448. WeChatPay() {
  449. // this.setData({
  450. // paying: true
  451. // });
  452. var data = {},
  453. getPackId = this.getPackId(),
  454. userInfo = app.globalData.userInfo,
  455. that = this,
  456. sku = this.data.sku;
  457. console.log(sku)
  458. data['meals'] = getPackId; //支付套餐字符串 如:pid|num,pid|num
  459. data['aid'] = this.data.formData.aid; //活动唯一标识
  460. data['sid'] = this.data.formData.sid; //场次id
  461. data['orderTitle'] = this.data.datas.title; //商品名
  462. data['phone'] = userInfo.phoneNum; //用户联系电话
  463. data['vid'] = this.data.formData.vid == -1 ? "" : this.data.formData.vid; //现金券id
  464. data['idcards'] = this.data.idcards.ids != undefined ? this.data.idcards.ids.join(",") : ""; //身份证信息 ,字符串多个","隔开 如: id1,id2 remark
  465. data['remark'] = this.data.textarea; //备注
  466. data['contactPhone'] = this.data.phoneNum; //联系手机号
  467. data['recommender'] = this.data.recommender; //推荐人
  468. data['street'] = this.data.street; //街道社区
  469. data['familyCommittee'] = this.data.familyCommittee; //街道社区
  470. data['travelDates'] = this.data.travelDates; //出行日期
  471. data['mailAddress'] = this.data.mailAddress; //邮寄地址
  472. data['openid'] = userInfo.socialUid; //微信用户的openid
  473. data['email'] = this.data.email || ''; //邮件地址
  474. data['wallet'] = this.data.formData.useCoin;
  475. data['useBalance'] = this.data.formData.useBalance;
  476. data.useUserCoin = this.data.formData.useUserCoin;
  477. if (!util.isEmpty(this.data.groupid) && this.data.groupid != 'null' && this.data.groupid != 'undefined') {
  478. data['groupid'] = this.data.groupid; //拼团号
  479. }
  480. data['shareId'] = this.data.shareId; //分享id
  481. data['product'] = 0; //产品: 0(默认)-活动 1-年卡
  482. data.createGroup = this.data.alone;
  483. data.btype = this.data.btype != -1 ? this.data.btype : (this.data.presellOpen != 0 ? 1 : 0); //this.data.presellOpen ==1 ?1 : (this.data.presellOpen ==0 && sku.meals.actNum<=0 && sku.meals.waitActNum>0 ?3:0);
  484. data.orderid = '';
  485. let str = data.idcards
  486. console.log(str);
  487. let idCards = str.split(',');
  488. console.log(idCards, 'idCards');
  489. let obj = {}
  490. //是否重复 false不重复
  491. if (this.hasDuplicate(idCards)) {
  492. obj.isRepeat = true
  493. } else {
  494. obj.isRepeat = false
  495. }
  496. console.log(obj.isRepeat);
  497. if (this.data.atype != 1) {
  498. if (obj.isRepeat) {
  499. util.showTips('你选择的儿童中存在相同信息,请核对后重新选择')
  500. } else {
  501. util.WXPay(data, this.data.formData.aid, this.data.datas.title, that.data.alone, this.data.presellOpen).then(function (data) {
  502. that.setData({
  503. paying: false
  504. });
  505. wx.navigateTo({
  506. url: '/pages/order/success/index?orderid=' + data.orderid + '&alone=' + that.data.alone + '&presellOpen=' + that.data.presellOpen + '&btype=' + data.btype + '&tradeChannelWeixin=' + data.tradeChannelWeixin
  507. });
  508. }, function (res) {
  509. that.setData({
  510. paying: false
  511. });
  512. util.showTips(res.reason)
  513. });
  514. wx.reportAnalytics('gopay', {
  515. aid: that.data.aid,
  516. title: that.data.datas.title,
  517. });
  518. }
  519. } else {
  520. util.WXPay(data, this.data.formData.aid, this.data.datas.title, that.data.alone, this.data.presellOpen).then(function (data) {
  521. that.setData({
  522. paying: false
  523. });
  524. wx.navigateTo({
  525. url: '/pages/order/success/index?orderid=' + data.orderid + '&alone=' + that.data.alone + '&presellOpen=' + that.data.presellOpen + '&btype=' + data.btype + '&tradeChannelWeixin=' + data.tradeChannelWeixin
  526. });
  527. }, function (res) {
  528. that.setData({
  529. paying: false
  530. });
  531. util.showTips(res.reason)
  532. });
  533. wx.reportAnalytics('gopay', {
  534. aid: that.data.aid,
  535. title: that.data.datas.title,
  536. });
  537. }
  538. },
  539. coinChange(e) {
  540. this.data.formData.useUserCoin = Number(e.detail.value);
  541. this.setData({
  542. formData: this.data.formData
  543. });
  544. this.safe();
  545. },
  546. switchChange(e) {
  547. this.data.formData.useCoin = Number(e.detail.value);
  548. this.setData({
  549. formData: this.data.formData
  550. });
  551. this.safe();
  552. },
  553. balanceChange(e) {
  554. this.data.formData.useBalance = Number(e.detail.value);
  555. this.setData({
  556. formData: this.data.formData
  557. });
  558. this.safe();
  559. },
  560. textarea(e) {
  561. this.setData({
  562. textarea: e.detail.value
  563. });
  564. },
  565. phoneNum(e) {
  566. this.setData({
  567. phoneNum: e.detail.value
  568. });
  569. },
  570. chooseAddress() {
  571. this.data.show = {
  572. address: true,
  573. vouche: false,
  574. integral: false
  575. };
  576. this.setData({
  577. show: this.data.show
  578. });
  579. },
  580. submitAddress(e) {
  581. let data = e.detail;
  582. data.address = data.address.replace(/\s+/g, ' ')
  583. this.setData({
  584. mailAddress: data.name + ' ' + data.mobile + ' ' + data.provincial + ' ' + data.address
  585. });
  586. this.shipInfo();
  587. },
  588. shipInfo() {
  589. if (this.data.mailAddress) {
  590. let address = this.data.mailAddress.split(' ');
  591. let addressInfo = address[2].split('/');
  592. let shipAddress = {
  593. userName: address[0],
  594. telNumber: address[1],
  595. provinceName: addressInfo[0],
  596. cityName: addressInfo[1],
  597. countyName: addressInfo[2],
  598. detailInfo: address[3],
  599. }
  600. this.setData({
  601. shipAddress
  602. });
  603. }
  604. },
  605. changeVouche(e) {
  606. this.data.formData.vid = e.detail;
  607. this.setData({
  608. formData: this.data.formData
  609. });
  610. this.safe();
  611. },
  612. // 推荐人
  613. recommender(e) {
  614. this.setData({
  615. recommender: util.trim(e.detail.value)
  616. });
  617. },
  618. // 街道社区
  619. streetInput(e) {
  620. this.setData({
  621. street: util.trim(e.detail.value)
  622. });
  623. },
  624. // 邮箱
  625. email(e) {
  626. this.setData({
  627. email: util.spaceTrim(e.detail.value)
  628. });
  629. let userInfo = app.globalData.userInfo;
  630. userInfo.email = util.spaceTrim(e.detail.value);
  631. wx.setStorageSync('WXuserInfo', userInfo);
  632. },
  633. // 家委会
  634. familyCommittee(e) {
  635. this.setData({
  636. familyCommittee: util.trim(e.detail.value)
  637. });
  638. },
  639. bindDateChange(e) {
  640. this.setData({
  641. travelDates: e.detail.value
  642. });
  643. },
  644. openDoc() {
  645. let datas = this.data.datas,
  646. url = '',
  647. that = this;
  648. switch (datas.agreement) {
  649. case 'default': //境内旅游合同
  650. url = util.config.imgUrl + '/doc/jingneihetong.pdf'
  651. break;
  652. case 'foreign': //境外旅游合同
  653. url = util.config.imgUrl + '/doc/jingwaihetong.pdf'
  654. break;
  655. case 'within': //沐童境内旅游合同
  656. url = util.config.imgUrl + '/doc/jingneimutong.pdf'
  657. break;
  658. case 'leave': //沐童境外旅游合同
  659. url = util.config.imgUrl + '/doc/jingwaimutong.pdf'
  660. break;
  661. case 'pay': //知识付费协议
  662. url = util.config.imgUrl + '/doc/knowledge.pdf'
  663. break;
  664. case 'bicycleDomestic': //沐童境内旅游合同(含骑行)
  665. url = util.config.imgUrl + '/doc/bicycleDomestic.pdf'
  666. break;
  667. case 'bicycleAbroad': //沐童出境旅游合同(含骑行)
  668. url = util.config.imgUrl + '/doc/bicycleAbroad.pdf'
  669. break;
  670. case 'within1': //境内旅游合同(沐童旅行社单日版)
  671. url = util.config.imgUrl + '/doc/singleDayContract.pdf'
  672. break;
  673. case 'within1_bicycle': //境内旅游合同(沐童旅行社单日骑行版)
  674. url = util.config.imgUrl + '/doc/singleDayBicycle.pdf'
  675. break;
  676. case 'within3': //境内旅游合同(沐童旅行社多日版)
  677. url = util.config.imgUrl + '/doc/manyDayContract.pdf'
  678. break;
  679. case 'within3_bicycle': //境内旅游合同(沐童旅行社多日骑行版)
  680. url = util.config.imgUrl + '/doc/manyDayBicycle.pdf'
  681. break;
  682. }
  683. const downloadTask = wx.downloadFile({
  684. url: url,
  685. success: function (res) {
  686. wx.openDocument({
  687. filePath: res.tempFilePath,
  688. fileType: "pdf",
  689. })
  690. }
  691. })
  692. downloadTask.onProgressUpdate((res) => {
  693. that.setData({
  694. percent: res.progress
  695. })
  696. });
  697. },
  698. integral() {
  699. if (this.data.datas.needIdcard != 'no' && util.isObjEmpty(this.data.idcards)) {
  700. util.showTips('请先选择购买儿童的身份信息。');
  701. return false;
  702. }
  703. this.data.show = {
  704. address: false,
  705. vouche: false,
  706. integral: true
  707. };
  708. this.setData({
  709. show: this.data.show,
  710. integralConfig: {
  711. idcards: this.data.idcards,
  712. sid: this.data.formData.sid,
  713. aid: this.data.formData.aid
  714. }
  715. });
  716. },
  717. close(e) {
  718. this.data.show[e.currentTarget.dataset.name] = false;
  719. this.setData({
  720. show: this.data.show
  721. })
  722. },
  723. onShareAppMessage() {
  724. return {
  725. title: '分享自@宝贝走天下微信小程序',
  726. path: '/pages/home/index'
  727. }
  728. }
  729. })