123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893 |
- const util = require('../../../utils/util.js');
- const app = getApp();
- Page({
- data: {
- num: 0, //套餐数量
- agreement: false, //同意合同
- pay: true, //同意微信支付
- qptype: 0,
- btype: -1, //上页面传入的活动类型 0(默认)-普通购买 1-预付 2-付尾款 3-候补购买
- recommender: '', //推荐人
- recommenderStatus: '',
- street: '', //街道社区
- streetStatus: '',
- atype: 0, //0活动1电商
- recommenderShow: false,
- recommenderShowText: '',
- datas: {}, //payinfo数据
- imgPath: util.config.imgPath,
- userInfo: app.globalData.userInfo,
- formData: {
- aid: '',
- sid: '',
- vid: '',
- cid: '',
- useCoin: 0,
- useBalance: 0,
- useUserCoin: 0,
- meals: '',
- unNeedBedNum: 0//不占床数
- },
- total: {//抵扣金额
- unNeedBedPrice: '0.00',//不占床
- coin: '0.00', //钱包
- sumCoin: '0.00',//抵用钱包总额
- coupons: '0.00', //现金券
- ldiscount: '0.00', //早鸟优惠价格
- mdiscount: '0.00', //会员折扣价
- price: '0.00', //总价
- sumBalance: '0.00', //账户余额
- ableBalance: '0.00', //账户余额可用
- },
- idcards: {},
- textarea: '', //备注
- phoneNum: '', //手机号码
- mailAddress: '', //邮寄地址
- shipAddress: '', //收货地址
- email: '', //邮箱
- orderCity: '', //城市
- familyCommittee: '',
- travelDates: '', //出行日期
- groupid: '', //拼团号
- shareId: '', //分享id
- paying: false, //支付中
- percent: 0,
- alone: 0, //0单独报名,1拼团
- initialSku: {},
- havePerson: false,
- sku: {
- quantity: 0, //购买数量
- sessions: {},
- meals: {},
- quota: 999, //限购
- },
- show: {
- address: false,
- vouche: false,
- integral: false
- },
- voucheConfig: {},
- maskShow: false,
- presellOpen: 0,
- military: 0,
- ageLimit: '',
- // 折扣弹窗选择内容
- radioChoose: {
- coin: 0,//抵用钱包
- ableBalance: 0,//账户余额
- babyCoin: 0,//宝贝币
- },
- unNeedBedShow: false,//占床弹窗
- unNeedBedNum: 0,//不占床数量
- coinShow: false,//抵用钱包弹窗
- useCoin: 0,//是否使用抵用钱包
- ableBalanceShow: false,//账户余额弹窗
- useAbleBalance: 0,//是否使用账户余额
- babyCoinShow: false,//宝贝币弹窗
- useBabyCoin: 0,//是否使用宝贝币
- contractShow: false,
- contractUrl: [],
- },
- onLoad(options) {
- console.log(options)
- wx.removeStorageSync('idcards');
- this.data.formData.aid = options.aid;
- this.setData({
- formData: this.data.formData,
- qptype: options.qptype || '',
- btype: options.btype,
- groupid: (!util.isEmpty(options.groupid) && options.groupid != 'null' && options.groupid != 'undefined') ? options.groupid : '',
- recommenderStatus: options.recommender,
- streetStatus: options.street,
- alone: options.createGroup != undefined ? options.createGroup : 0,
- initialSku: {
- sessionsIndex: parseInt(options.sessionsIndex),
- mealsIndex: parseInt(options.mealsIndex),
- quantity: parseInt(options.quantity)
- },
- atype: parseInt(options.atype),
- presellOpen: options.presellOpen,
- military: options.military,
- ageLimit: options.ageLimit
- });
- this.payinfo();
- if (util.isObjEmpty(options.recommender) || options.recommender == '0') {
- this.setData({
- recommenderShow: false
- })
- } else if (options.recommender == '1') {
- this.setData({
- recommenderShow: true,
- recommenderShowText: '请填写推荐人,没有填无'
- })
- } else if (options.recommender == '2') {
- this.setData({
- recommenderShow: true,
- recommenderShowText: '非必填,若有请填写'
- })
- }
- },
- onShow() {
- let idcards = wx.getStorageSync('idcards');
- this.data.formData.cid = !util.isObjEmpty(idcards) ? idcards.ids.join(",") : '';
- this.setData({
- idcards,
- formData: this.data.formData
- });
- this.setData({
- userInfo: app.globalData.userInfo
- });
- if (!util.isObjEmpty(this.data.sku.meals)) this.safe();
- },
- onUnload() {
- wx.removeStorageSync('idcards');
- },
- // 判断是否含有出行人信息
- getIdcardinfoList() {
- var self = this;
- util.ajax({
- func: "user/idcardinfo_list",
- data: {
- type: this.data.ctype == 0 ? 0 : -1
- },
- load: false
- }, function (res) {
- if (res.code == 0) {
- self.setData({
- havePerson: res.data.length > 0 ? true : false
- })
- } else {
- util.showTips(res.reason)
- }
- })
- },
- payinfo() {
- let that = this,
- userInfo = app.globalData.userInfo;
- util.ajax({
- func: "article/payinfo",
- data: {
- "aid": that.data.formData.aid,
- "qptype": that.data.qptype ? that.data.qptype : 0,
- 'sid': that.data.initialSku.sessionsIndex // 参数新增sid返回数据场次只有一条
- }
- }, function (res) {
- if (res.code == 0) {
- // res.data.remark = res.data.remark || (that.data.atype==0? "请填写家长特别叮嘱,若无则填写无。":res.data.sremark == 'yes'? '给卖家留言,非必填':'');
- // if (that.data.presellOpen ==1) {
- // that.data.total.price = util.toMoney(res.data.presellPrice, ',');
- // }
- let contractUrl = []
- // 展示不同合同图片url
- switch (res.data.agreement) {
- case 'default': //境内旅游合同
- contractUrl = util.config.imgUrl + '/doc/jingneihetong.pdf'
- contractUrl = [{ url: 'https://img.bbztx.com/miniProgram/baby/contract/jingneihetong1.png' }, { url: 'https://img.bbztx.com/miniProgram/baby/contract/jingneihetong2.png' },]
- break;
- case 'foreign': //境外旅游合同
- contractUrl = util.config.imgUrl + '/doc/jingwaihetong.pdf'
- contractUrl = [{ url: 'https://img.bbztx.com/miniProgram/baby/contract/jingwaihetong1.png' }, { url: 'https://img.bbztx.com/miniProgram/baby/contract/jingwaihetong2.png' },]
- break;
- case 'within': //沐童境内旅游合同
- contractUrl = util.config.imgUrl + '/doc/jingneimutong.pdf'
- contractUrl = [{ url: 'https://img.bbztx.com/miniProgram/baby/contract/jingneimutong.png' }]
- break;
- case 'leave': //沐童境外旅游合同
- contractUrl = util.config.imgUrl + '/doc/jingwaimutong.pdf'
- contractUrl = [{ url: 'https://img.bbztx.com/miniProgram/baby/contract/jingwaimutong.png' }]
- break;
- case 'pay': //知识付费协议
- contractUrl = util.config.imgUrl + '/doc/knowledge.pdf'
- contractUrl = [{ url: 'https://img.bbztx.com/miniProgram/baby/contract/knowledge.png' }]
- break;
- case 'bicycleDomestic': //沐童境内旅游合同(含骑行)
- contractUrl = util.config.imgUrl + '/doc/bicycleDomestic.pdf'
- contractUrl = [{ url: 'https://img.bbztx.com/miniProgram/baby/contract/bicycleDomestic.png' }]
- break;
- case 'bicycleAbroad': //沐童出境旅游合同(含骑行)
- contractUrl = [{ url: 'https://img.bbztx.com/miniProgram/baby/contract/bicycleAbroad.png' }]
- break;
- case 'within1': //境内旅游合同(沐童旅行社单日版)
- contractUrl = util.config.imgUrl + '/doc/singleDayContract.pdf'
- contractUrl = [{ url: 'https://img.bbztx.com/miniProgram/baby/contract/singleDayContract.png' }]
- break;
- case 'within1_bicycle': //境内旅游合同(沐童旅行社单日骑行版)
- contractUrl = util.config.imgUrl + '/doc/singleDayBicycle.pdf'
- contractUrl = [{ url: 'https://img.bbztx.com/miniProgram/baby/contract/singleDayBicycle.png' }]
- break;
- case 'within3': //境内旅游合同(沐童旅行社多日版)
- contractUrl = util.config.imgUrl + '/doc/manyDayContract.pdf'
- contractUrl = [{ url: 'https://img.bbztx.com/miniProgram/baby/contract/manyDayContract1.png' }, { url: 'https://img.bbztx.com/miniProgram/baby/contract/manyDayContract2.png' }]
- break;
- case 'within3_bicycle': //境内旅游合同(沐童旅行社多日骑行版)
- contractUrl = util.config.imgUrl + '/doc/manyDayBicycle.pdf'
- contractUrl = [{ url: 'https://img.bbztx.com/miniProgram/baby/contract/manyDayBicycle1.png' }, { url: 'https://img.bbztx.com/miniProgram/baby/contract/manyDayBicycle2.png' }]
- break;
- }
- that.setData({
- datas: res.data,
- contractUrl,//合同图片url
- userInfo,
- total: that.data.total,
- formData: that.data.formData,
- phoneNum: res.data.buyInfo.contactPhone || '',
- textarea: res.data.orderRemark || '',
- mailAddress: res.data.buyInfo.mailAddress || '',
- email: res.data.needEmail != 'no' ? res.data.buyInfo.email : '',
- street: res.data.buyInfo.street || ''
- });
- wx.reportAnalytics('enter_enlist', {
- aid: that.data.formData.aid,
- title: res.data.title
- });
- that.getSku();
- that.safe();
- that.getIdcardinfoList()
- that.shipInfo();
- } else if (res.code == 3003) {
- wx.showModal({
- title: '提示',
- content: res.reason,
- showCancel: false,
- success: function (data) {
- if (data.confirm) {
- wx.navigateBack();
- }
- }
- })
- } else {
- util.showTips(res.reason);
- }
- })
- },
- getSku() { //sku
- let sku = this.data.sku,
- info = this.data.datas,
- initialSku = this.data.initialSku;
- // sku.sessions = this.getSkuInfo(info.sessions, 0, 'sid', this.data.initialSku.sessionsIndex);
- sku.sessions = info.sessions[0]
- this.data.formData.sid = sku.sessions.sid;
- sku.meals = this.getSkuInfo(sku.sessions.alipays, 0, 'pid', this.data.initialSku.mealsIndex);
- sku.meals.originalPrice = util.toMoney(sku.meals.originalPrice)
- sku.meals.price = this.data.presellOpen == 0 ? util.toMoney(sku.meals.price) : util.toMoney(this.data.datas.presellPrice)
- sku.quantity = initialSku.quantity;
- 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);
- this.setData({
- sku,
- formData: this.data.formData
- })
- },
- // 循环获取场次信息
- getSkuInfo(arr, i, type, id) {
- if (arr.length > 0 && i < arr.length) {
- if (arr[i][type] == id) {
- return arr[i];
- } else {
- return this.getSkuInfo(arr, i + 1, type, id)
- }
- }
- },
- numAdd() {
- let sku = this.data.sku;
- if (sku.quantity >= sku.quota) {
- util.showTips("库存不足");
- } else {
- sku.quantity = parseInt(sku.quantity) + 1;
- this.setData({
- sku,
- unNeedBedNum: 0//儿童不占床数量
- });
- this.removeIdcards();
- this.safe();
- }
- },
- numReduce() {
- let sku = this.data.sku;
- if (sku.quantity <= 1) {
- util.showTips("至少选择1件");
- } else {
- sku.quantity = parseInt(sku.quantity) - 1;
- this.setData({
- sku,
- unNeedBedNum: 0//儿童不占床数量
- });
- this.removeIdcards();
- this.safe();
- }
- },
- numChange(e) {
- let sku = this.data.sku;
- if (parseInt(e.detail.value) > sku.quota) {
- util.showTips("库存不足");
- sku.quantity = sku.quota;
- } else if (parseInt(e.detail.value) <= 0 || util.isEmpty(e.detail.value)) {
- util.showTips("至少选择1件");
- sku.quantitym = 1;
- } else {
- sku.quantity = e.detail.value;
- }
- this.setData({
- sku,
- unNeedBedNum: 0//儿童不占床数量
- });
- this.removeIdcards();
- this.safe();
- },
- removeIdcards() {
- wx.removeStorageSync('idcards');
- this.setData({
- idcards: []
- })
- },
- openQuestion() {
- this.setData({
- maskShow: true
- })
- },
- maskClose() {
- this.setData({
- maskShow: false
- })
- },
- agree() {
- if (this.data.agreement) {
- this.setData({
- agreement: !this.data.agreement
- })
- } else {
- this.setData({
- contractShow: true,
- })
- }
- },
- // 已阅读按钮
- agreeContract() {
- this.setData({
- agreement: true,
- contractShow: false,
- })
- },
- choosePay() {
- this.setData({
- pay: !this.data.pay
- })
- },
- // 选择出行人
- chooseCard() {
- var quantity = this.data.sku.quantity;
- if (quantity > 0) {
- wx.navigateTo({
- 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
- })
- } else {
- util.showTips('请选择场次或者套餐数量');
- }
- },
- // 查看数组是否有重复元素
- hasDuplicate(arr) {
- if (arr && arr.length > 0) {
- return new Set(arr).size !== arr.length;
- } else {
- return false
- }
- },
- safe(type, checked) {
- let that = this;
- that.data.formData.meals = that.data.sku.meals.pid + '|' + that.data.sku.quantity;
- that.data.formData.btype = this.data.btype != -1 ? this.data.btype : (this.data.presellOpen != 0 ? 1 : 0);
- if (type == 'useCoin') {//抵用钱包
- that.data.formData.useCoin = checked == 1 ? 1 : 0
- } else if (type == 'ableBalance') {//账户余额
- that.data.formData.useBalance = checked == 1 ? 1 : 0
- } else if (type == 'babyCoin') {//宝贝币
- that.data.formData.useUserCoin = checked == 1 ? 1 : 0
- } else if (type == 'unNeedBed') {//不占床数量
- // 不占床数量
- that.data.formData.unNeedBedNum = checked
- }
- util.ajax({
- func: "voucher/pay_mvoucher", //会员折扣,现金券,钱包
- data: that.data.formData,
- load: false
- }, function (res) {
- if (res.code == 0 && res.data != "") {
- let data = res.data;
- that.data.total.unNeedBedPrice = util.toMoney(data.unNeedBedPrice, ',');
- that.data.total.coin = util.toMoney(data.coin, ',');
- that.data.total.sumCoin = util.toMoney(data.sumCoin, ',');
- that.data.total.coupons = util.toMoney(data.price, ',');
- that.data.total.ldiscount = util.toMoney(data.ldiscount, ',');
- that.data.total.mdiscount = util.toMoney(data.mdiscount, ',');
- that.data.total.price = util.toMoney(data.totalFee, ',');
- that.data.total.sumBalance = util.toMoney(data.sumBalance, ',');
- that.data.total.sumBalanceNum = data.sumBalance;
- that.data.total.sumUserCoin = data.sumUserCoin || 0;
- that.data.total.userCoin = data.userCoin || 0;
- // 不占床规则
- that.data.total.childCount = res.childCount || 0;
- that.data.total.adultCount = res.adultCount || 0;
- that.data.total.unNeedBedMaxNum = data.unNeedBedMaxNum || 0;
- that.data.total.ableBalance = util.toMoney(data.ableBalance, ',');
- that.data.formData.vid = data.id || '';
- that.setData({
- total: that.data.total,
- formData: that.data.formData
- });
- } else {
- // that.clearSafe();
- }
- })
- },
- getPackId() {
- return (this.data.sku.meals.pid || '') + '|' + this.data.sku.quantity;
- },
- goCoupon() {
- var packIds = this.getPackId();
- if (this.data.datas.needIdcard != 'no' && util.isObjEmpty(this.data.idcards)) {
- util.showTips('请先选择购买儿童的身份信息。');
- return false;
- }
- this.data.show = {
- address: false,
- vouche: true,
- integral: false
- };
- let voucheConfig = {
- packIds: packIds,
- aid: this.data.formData.aid,
- sid: this.data.formData.sid,
- vid: this.data.formData.vid,
- cid: this.data.formData.cid
- }
- this.setData({
- voucheConfig,
- show: this.data.show
- })
- },
- // 弹出不占床选择
- showUnNeedBed(e) {
- if (this.data.datas.needIdcard != 'no' && util.isObjEmpty(this.data.idcards)) {
- util.showTips('请先选择购买儿童的身份信息。');
- return false;
- }
- this.setData({
- unNeedBedShow: !this.data.unNeedBedShow,
- })
- let type = e.currentTarget.dataset.type
- this.safe(type, this.data.unNeedBedNum)
- },
- // 弹出抵用钱包
- showCoin(e) {
- this.setData({
- coinShow: !this.data.coinShow,
- "radioChoose.coin": this.data.useCoin
- })
- let type = e.currentTarget.dataset.type
- this.safe(type, 1)
- },
- // 弹出账户余额
- showAbleBalance(e) {
- this.setData({
- ableBalanceShow: !this.data.ableBalanceShow,
- "radioChoose.ableBalance": this.data.useAbleBalance
- })
- let type = e.currentTarget.dataset.type
- this.safe(type, 1)
- },
- // 弹出宝贝币
- showBabyCoin(e) {
- this.setData({
- babyCoinShow: !this.data.babyCoinShow,
- "radioChoose.babyCoin": this.data.useBabyCoin
- })
- let type = e.currentTarget.dataset.type
- this.safe(type, 1)
- },
- goPay() {
- console.log('领队小程序传参', wx.getStorageSync("payOpenId"))
- var packIds = this.getPackId(),
- phoneNum = this.data.phoneNum,
- idcards = this.data.idcards,
- num = this.data.sku.quantity,
- datas = this.data.datas,
- userInfo = app.globalData.userInfo,
- email = this.data.email,
- orderCity = this.data.orderCity;
- if (util.isObjEmpty(this.data.sku.meals)) {
- util.showTips('请先选择场次套餐,再付款。');
- return false;
- }
- if (datas.needIdcard != 'no' && this.data.atype == 0) {
- if (idcards.ids) {
- if (idcards.ids.length == 0) {
- util.showTips('请先选择出行人的身份信息。');
- return false;
- } else if (idcards.ids.length != num) {
- util.showTips('请设置' + num + '人的身份信息。');
- return false;
- }
- } else {
- util.showTips('请先选择出行人的身份信息。');
- return false;
- }
- }
- if (datas.sphone == 'yes' && util.isPhone(phoneNum)) {
- util.showTips('请填写正确的用户联系手机号码。');
- return false;
- }
- if (datas.smailAddress == 'yes' && !this.data.mailAddress) {
- util.showTips(this.data.atype == 1 ? '请填写收货地址。' : '请填写邮寄信息。');
- return false;
- }
- // var myreg = /^([a-zA-Z0-9]+[_|\_|\.|-]+)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.|-]+)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/gi;
- if (datas.needEmail && datas.needEmail == 'yes' && !email) {
- util.showTips('请填写电子邮箱。');
- return false;
- }
- if (datas.orderCity && datas.orderCity == 1 && !orderCity) {
- util.showTips('请填写城市。');
- return false;
- }
- // if (datas.needEmail == 'yes' && !myreg.test(email)) {
- // util.showTips('请正确填写电子邮箱。');
- // return false;
- // }
- if (datas.familyCommittee == '1' && this.data.familyCommittee == '' && this.data.atype == 0) {
- util.showTips('请填写是否为家委会');
- return false;
- }
- if (this.data.streetStatus == '1' && this.data.street == '') {
- util.showTips('请填写街道社区,没有填无');
- return false;
- }
- if (this.data.recommenderStatus == '1' && this.data.recommender == '') {
- util.showTips('请填写推荐人,没有填无');
- return false;
- }
- if (this.data.recommenderStatus == '1' && this.data.recommender.length > 10) {
- util.showTips('请正确填写推荐人');
- return false;
- }
- if (datas.travelDates == 'yes' && !this.data.travelDates && this.data.atype == 0) {
- util.showTips('请选择出行日期。');
- return false;
- }
- if (this.data.atype == 0 && datas.sremark == 'yes' && this.data.textarea == '') {
- util.showTips('请填写家长叮嘱等备注信息。');
- return false;
- }
- if (datas.agreement && !this.data.agreement && this.data.atype == 0 && this.data.presellOpen == 0) {
- util.showTips('请认真阅读相关协议条款,并认可同意。');
- return false;
- }
- if (!this.data.paying) {
- // this.setData({ paying: true });
- this.WeChatPay();
- }
- console.log(this.data.formData);
- },
- WeChatPay() {
- // this.setData({
- // paying: true
- // });
- var data = {},
- getPackId = this.getPackId(),
- userInfo = app.globalData.userInfo,
- that = this,
- sku = this.data.sku;
- console.log(sku)
- data['meals'] = getPackId; //支付套餐字符串 如:pid|num,pid|num
- data['aid'] = this.data.formData.aid; //活动唯一标识
- data['sid'] = this.data.formData.sid; //场次id
- data['orderTitle'] = this.data.datas.title; //商品名
- data['phone'] = userInfo.phoneNum; //用户联系电话
- data['vid'] = this.data.formData.vid == -1 ? "" : this.data.formData.vid; //现金券id
- data['idcards'] = this.data.idcards.ids != undefined ? this.data.idcards.ids.join(",") : ""; //身份证信息 ,字符串多个","隔开 如: id1,id2 remark
- data['remark'] = this.data.textarea; //备注
- data['contactPhone'] = this.data.phoneNum; //联系手机号
- data['recommender'] = this.data.recommender; //推荐人
- data['street'] = this.data.street; //街道社区
- data['familyCommittee'] = this.data.familyCommittee; //街道社区
- data['travelDates'] = this.data.travelDates; //出行日期
- data['mailAddress'] = this.data.mailAddress; //邮寄地址
- data['openid'] = app.globalData.payOpenId; //微信用户的openid
- data['email'] = this.data.email || ''; //邮件地址
- data['orderCity'] = this.data.orderCity || ''; //城市
- data['unNeedBedNum'] = this.data.unNeedBedNum || ''; //不占床数量
- data['wallet'] = this.data.formData.useCoin;
- data['useBalance'] = this.data.formData.useBalance;
- data.useUserCoin = this.data.formData.useUserCoin;
- if (!util.isEmpty(this.data.groupid) && this.data.groupid != 'null' && this.data.groupid != 'undefined') {
- data['groupid'] = this.data.groupid; //拼团号
- }
- data['shareId'] = this.data.shareId; //分享id
- data['product'] = 0; //产品: 0(默认)-活动 1-年卡
- data.createGroup = this.data.alone;
- 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);
- data.orderid = '';
- let str = data.idcards
- console.log(str);
- let idCards = str.split(',');
- console.log(idCards, 'idCards');
- let obj = {}
- //是否重复 false不重复
- if (this.hasDuplicate(idCards)) {
- obj.isRepeat = true
- } else {
- obj.isRepeat = false
- }
- console.log(obj.isRepeat);
- if (this.data.atype != 1) {
- if (obj.isRepeat) {
- util.showTips('你选择的儿童中存在相同信息,请核对后重新选择')
- } else {
- util.WXPay(data, this.data.formData.aid, this.data.datas.title, that.data.alone, this.data.presellOpen).then(function (data) {
- that.setData({
- paying: false
- });
- wx.navigateTo({
- url: '/pages/order/success/index?orderid=' + data.orderid + '&alone=' + that.data.alone + '&presellOpen=' + that.data.presellOpen + '&btype=' + data.btype + '&tradeChannelWeixin=' + data.tradeChannelWeixin
- });
- }, function (res) {
- that.setData({
- paying: false
- });
- util.showTips(res.reason)
- });
- wx.reportAnalytics('gopay', {
- aid: that.data.aid,
- title: that.data.datas.title,
- });
- }
- } else {
- util.WXPay(data, this.data.formData.aid, this.data.datas.title, that.data.alone, this.data.presellOpen).then(function (data) {
- that.setData({
- paying: false
- });
- wx.navigateTo({
- url: '/pages/order/success/index?orderid=' + data.orderid + '&alone=' + that.data.alone + '&presellOpen=' + that.data.presellOpen + '&btype=' + data.btype + '&tradeChannelWeixin=' + data.tradeChannelWeixin
- });
- }, function (res) {
- that.setData({
- paying: false
- });
- util.showTips(res.reason)
- });
- wx.reportAnalytics('gopay', {
- aid: that.data.aid,
- title: that.data.datas.title,
- });
- }
- },
- // 抵用钱包选择
- coinChange(e) {
- console.log(e)
- this.setData({
- "radioChoose.coin": e.detail.value
- })
- },
- // 账户余额选择
- balanceChange(e) {
- console.log(e)
- this.setData({
- "radioChoose.ableBalance": e.detail.value
- })
- },
- unNeedBedChange(e) {
- if (parseInt(e.detail.value) > this.data.total.unNeedBedMaxNum) {
- // util.showTips("库存不足");
- this.data.unNeedBedNum = this.data.total.unNeedBedMaxNum;
- } else if (parseInt(e.detail.value) < 0 || util.isEmpty(e.detail.value)) {
- // util.showTips("不能小于0");
- this.data.unNeedBedNum = 0;
- } else {
- this.data.unNeedBedNum = e.detail.value;
- }
- this.setData({
- unNeedBedNum: this.data.unNeedBedNum
- });
- this.safe('unNeedBed', this.data.unNeedBedNum)
- },
- // 占床位加
- unNeedBedReduce() {
- if (this.data.unNeedBedNum <= 0) {
- // util.showTips("最小为零");
- } else {
- this.data.unNeedBedNum = parseInt(this.data.unNeedBedNum) - 1;
- this.setData({
- unNeedBedNum: this.data.unNeedBedNum
- });
- this.safe('unNeedBed', this.data.unNeedBedNum)
- }
- },
- // 占床位减
- unNeedBedAdd() {
- if (this.data.unNeedBedNum >= this.data.total.unNeedBedMaxNum) {
- // util.showTips("不可大于允许选择数");
- } else {
- this.data.unNeedBedNum = parseInt(this.data.unNeedBedNum) + 1;
- this.setData({
- unNeedBedNum: this.data.unNeedBedNum
- });
- this.safe('unNeedBed', this.data.unNeedBedNum)
- }
- },
- // 宝贝币选择
- babyCoinChange(e) {
- console.log(e)
- this.setData({
- "radioChoose.babyCoin": e.detail.value
- })
- },
- // 弹窗确认选择
- confirmSelection(e) {
- let type = e.currentTarget.dataset.type
- switch (type) {
- //占床
- case "unNeedBed":
- this.setData({ unNeedBedShow: false })
- break;
- case "useCoin":
- this.setData({ useCoin: this.data.radioChoose.coin, coinShow: false })
- this.safe(type, this.data.radioChoose.coin)
- break;
- case "ableBalance":
- this.setData({ useAbleBalance: this.data.radioChoose.ableBalance, ableBalanceShow: false })
- this.safe(type, this.data.radioChoose.ableBalance)
- break;
- case "babyCoin":
- this.setData({ useBabyCoin: this.data.radioChoose.babyCoin, babyCoinShow: false })
- this.safe(type, this.data.radioChoose.babyCoin)
- break;
- }
- },
- textarea(e) {
- this.setData({
- textarea: e.detail.value
- });
- },
- phoneNum(e) {
- this.setData({
- phoneNum: e.detail.value
- });
- },
- chooseAddress() {
- this.data.show = {
- address: true,
- vouche: false,
- integral: false
- };
- this.setData({
- show: this.data.show
- });
- },
- submitAddress(e) {
- let data = e.detail;
- data.address = data.address.replace(/\s+/g, ' ')
- this.setData({
- mailAddress: data.name + ' ' + data.mobile + ' ' + data.provincial + ' ' + data.address
- });
- this.shipInfo();
- },
- shipInfo() {
- if (this.data.mailAddress) {
- let address = this.data.mailAddress.split(' ');
- let addressInfo = address[2].split('/');
- let shipAddress = {
- userName: address[0],
- telNumber: address[1],
- provinceName: addressInfo[0],
- cityName: addressInfo[1],
- countyName: addressInfo[2],
- detailInfo: address[3],
- }
- this.setData({
- shipAddress
- });
- }
- },
- // 优惠券id
- changeVouche(e) {
- this.data.formData.vid = e.detail;
- this.setData({
- formData: this.data.formData
- });
- this.safe();
- },
- // 推荐人
- recommender(e) {
- this.setData({
- recommender: util.trim(e.detail.value)
- });
- },
- // 街道社区
- streetInput(e) {
- this.setData({
- street: util.trim(e.detail.value)
- });
- },
- // 邮箱
- email(e) {
- this.setData({
- email: util.spaceTrim(e.detail.value)
- });
- let userInfo = app.globalData.userInfo;
- userInfo.email = util.spaceTrim(e.detail.value);
- wx.setStorageSync('WXuserInfo', userInfo);
- },
- // 城市
- cityValue(e) {
- this.setData({
- orderCity: e.detail.value
- });
- },
- // 家委会
- familyCommittee(e) {
- this.setData({
- familyCommittee: util.trim(e.detail.value)
- });
- },
- bindDateChange(e) {
- this.setData({
- travelDates: e.detail.value
- });
- },
- openDoc() {
- this.setData({
- contractShow: true,
- })
- },
- integral() {
- if (this.data.datas.needIdcard != 'no' && util.isObjEmpty(this.data.idcards)) {
- util.showTips('请先选择购买儿童的身份信息。');
- return false;
- }
- this.data.show = {
- address: false,
- vouche: false,
- integral: true
- };
- this.setData({
- show: this.data.show,
- integralConfig: {
- idcards: this.data.idcards,
- sid: this.data.formData.sid,
- aid: this.data.formData.aid
- }
- });
- },
- close(e) {
- this.data.show[e.currentTarget.dataset.name] = false;
- this.setData({
- show: this.data.show
- })
- },
- onShareAppMessage() {
- return {
- title: '分享自@宝贝走天下微信小程序',
- path: '/pages/home/index'
- }
- }
- })
|