1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597 |
- var app = getApp()
- var locat = require('../../utils/Location.js');
- var util = require('../../utils/util.js');
- var status = require('../../utils/index.js');
- var wcache = require('../../utils/wcache.js');
- const plugin = requirePlugin('fuiou-pay')
- Page({
- mixins: [require('../../mixin/globalMixin.js')],
- data: {
- payBtnLoading: false,
- showConfirmModal: false,
- receiverAddress: "", //快递送货地址
- tuan_send_address: "", //团长送货地址
- showGetPhone: false,
- pay_type:false,
- lou_meng_hao:'',
- pickUpAddress: "",
- disUserName: "",
- pickUpCommunityName: "",
- is_limit_distance_buy: 0,
- tabList: [
- { id: 0, name: '社区自提', dispatching: 'pickup', enabled: false },
- { id: 1, name: '团长配送', dispatching: 'tuanz_send', enabled: false },
- { id: 2, name: '快递配送', dispatching: 'express', enabled: false },
- { id: 3, name: '同城配送', dispatching: 'localtown_delivery', enabled: false},
- { id: 4, name: '到店核销', dispatching: 'hexiao', enabled: false}
- ],
- originTabList: [
- { id: 0, name: '社区自提', dispatching: 'pickup' },
- { id: 1, name: '团长配送', dispatching: 'tuanz_send'},
- { id: 2, name: '快递配送', dispatching: 'express'},
- { id: 3, name: '同城配送', dispatching: 'localtown_delivery'},
- { id: 4, name: '到店核销', dispatching: 'hexiao'}
- ],
- tabIdx: 0,
- region: ['选择地址', '', ''],
- tot_price: 0,
- needAuth: false,
- reduce_money: 0,
- hide_quan: true,
- tuan_region: ['选择地址','',''],
- groupInfo: {
- group_name: '社区',
- owner_name: '团长',
- placeorder_tuan_name: '配送费',
- placeorder_trans_name: '快递费'
- },
- comment: '',
- is_yue_open: 0,
- can_yupay: 0,
- ck_yupay: 3,
- use_score: 0,
- commentArr: {},
- note_content: '',
- showAlertTime: false,
- curAlertTime: -1,
- isAgreePresale: false,
- presale_info: '',
- presalePickup: ['自提','配送','发货','配送','核销'],
- allform: ""
- },
- canPay: true,
- canPreSub: true,
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- var that = this;
- status.setGroupInfo().then((groupInfo) => { that.setData({ groupInfo }) });
- var token = wx.getStorageSync('token');
- var community = wx.getStorageSync('community');
- var community_id = community.communityId;
- util.check_login() ? this.setData({ needAuth: false }) : (this.setData({ needAuth: true }));
- // let is_limit = options.is_limit || 0;
- this.setData({
- buy_type: options.type || '',
- soli_id: options.soli_id || '',
- pickUpAddress: community.fullAddress || '',
- pickUpCommunityName: community.communityName || '',
- disUserName: community.disUserName || ''
- })
- wx.showLoading()
- app.util.request({
- url: 'entry/wxapp/user',
- data: {
- controller: 'car.checkout',
- token: token,
- community_id,
- buy_type: options.type,
- soli_id: options.soli_id
- },
- dataType: 'json',
- method: 'POST',
- success: function (res) {
- // wx.hideLoading();
- setTimeout(function(){ wx.hideLoading(); },1000);
-
- let rdata = res.data;
- // 提货方式
- let tabIdx = -1;
- let tabLength = 0;
- let tabList = that.data.tabList || {};
- let sortTabList = [];
- let {
- delivery_express_name,
- delivery_tuanzshipping_name,
- delivery_ziti_name,
- delivery_diy_sort,
- delivery_type_express,
- delivery_type_tuanz,
- delivery_type_ziti,
- delivery_tuanz_money,
- is_vip_card_member,
- vipcard_save_money,
- level_save_money,
- is_open_vipcard_buy,
- is_member_level_buy,
- total_integral,
- is_need_subscript,
- need_subscript_template,
- delvery_type_hexiao,
- order_note_open,
- order_note_name,
- order_note_content,
- delivery_type_localtown,
- localtown_dispatchtime, //预计配送需要多少分钟
- pickingup_fare, //订单包装费,只有在 同城快递的时
- localtown_shipping_fare, //同城配送费
- localtown_modifypickingname,
- localtown_shipping_fare_arr,
- localtown_moneytype_fixed_freemoney,
- localtown_makeup_delivery_money,
- localtown_expected_delivery,
- order_lou_meng_hao,
- order_lou_meng_hao_placeholder,
- presale_info,
- cashondelivery_data,
- allform
- } = res.data;
- let {
- isopen_cashondelivery,
- isopen_cashondelivery_communityhead,
- isopen_cashondelivery_express,
- isopen_cashondelivery_hexiao,
- isopen_cashondelivery_localtown
- } = cashondelivery_data;
- presale_info = Object.keys(presale_info).length ? presale_info : '';
- // 同城满免运费
- if(localtown_shipping_fare_arr) {
- let shipping_fare = 0;
- shipping_fare = localtown_shipping_fare_arr.total_yl_shipping_fare*1 - localtown_shipping_fare_arr.total_shipping_fare*1;
- localtown_shipping_fare_arr.shipping_fare = shipping_fare.toFixed(2);
- }
- if (delivery_type_localtown == 1) tabList[3].enabled = true, tabLength++;
- if (delivery_type_express == 1) tabList[2].enabled = true, tabLength++;
- if (delivery_type_tuanz == 1) tabList[1].enabled = true, tabLength++;
- if (delivery_type_ziti == 1) tabList[0].enabled = true, tabLength++;
- if (delivery_diy_sort) {
- let sortArr = delivery_diy_sort.split(',');
- if (sortArr[2] && tabList[sortArr[2]] && tabList[sortArr[2]].enabled) tabIdx = sortArr[2];
- if (sortArr[1] && tabList[sortArr[1]] && tabList[sortArr[1]].enabled) tabIdx = sortArr[1];
- if (sortArr[0] && tabList[sortArr[0]] && tabList[sortArr[0]].enabled) tabIdx = sortArr[0];
- sortArr.forEach(function(item){
- sortTabList.push(tabList[item]);
- })
- }
- delivery_express_name && (tabList[2].name = delivery_express_name);
- delivery_tuanzshipping_name && (tabList[1].name = delivery_tuanzshipping_name);
- delivery_ziti_name && (tabList[0].name = delivery_ziti_name);
- // 同城配送TODO...
- sortTabList.push({id: 3, name: '同城配送', dispatching: 'localtown_delivery', enabled: (delivery_type_localtown==1) });
- if(tabIdx==-1&&delivery_type_localtown==1) tabIdx=3;
- let localtown_delivery_space_month = '';
- if(localtown_expected_delivery&&localtown_expected_delivery.localtown_delivery_space_month) {
- localtown_delivery_space_month = localtown_expected_delivery.localtown_delivery_space_month;
- }
- // 到店核销
- sortTabList.push({id: 4, name: '到店核销', dispatching: 'hexiao', enabled: (delvery_type_hexiao==1) });
- if(tabIdx==-1&&delvery_type_hexiao) { tabIdx = 4; }
- var addres = 0;
- addres = 1;
- var seller_chose_id = 0;
- var seller_chose_store_id = 0;
- var seller_goods = rdata.seller_goodss;
- let commentArr = {};
- for (let key in seller_goods) commentArr[key] = '';
- let sel_chose_vouche = '';
- let sgvKey = 0;
- let goodsTotNum = 0;
- for (var i in seller_goods) {
- if (seller_goods[i].show_voucher == 1) {
- if (seller_goods[i].chose_vouche.id) seller_chose_id = seller_goods[i].chose_vouche.id;
- if (seller_goods[i].chose_vouche.store_id) seller_chose_store_id = seller_goods[i].chose_vouche.store_id;
- if (Object.prototype.toString.call(seller_goods[i].chose_vouche) == '[object Object]'){
- sel_chose_vouche = seller_goods[i].chose_vouche;
- }
- if(Object.keys(seller_goods[i].chose_vouche).length>0) sgvKey = i;
- }
- seller_goods[i].goodsnum = Object.keys(seller_goods[i].goods).length;
- for (var j in seller_goods[i].goods) {
- goodsTotNum += seller_goods[i].goods[j].quantity*1;
- if (seller_goods[i].goods[j].header_disc > 0 && seller_goods[i].goods[j].header_disc < 100) {
- seller_goods[i].goods[j].header_disc = (seller_goods[i].goods[j].header_disc / 10).toFixed(1);
- }
- }
- }
- let current_distance = rdata.current_distance || '';
- let current_distance_str = that.changeDistance(current_distance);
- order_note_content = order_note_content!=null?order_note_content:'';
- if(presale_info&&presale_info.goods_price) {
- let deduction_money = presale_info.deduction_money;
- deduction_money = deduction_money>0?deduction_money:presale_info.presale_ding_money;
- let totDeduction = deduction_money*goodsTotNum;
- presale_info.balance = (presale_info.goods_price*1 - totDeduction).toFixed(2);
- presale_info.totdingMoney = (goodsTotNum*presale_info.presale_ding_money).toFixed(2);
- presale_info.totDeduction = totDeduction.toFixed(2);
- }
- let param = {
- sgvKey,
- is_hexiao: delvery_type_hexiao,
- loadover: true,
- commentArr,
- sel_chose_vouche,
- tabList: sortTabList,
- is_limit_distance_buy: rdata.is_limit_distance_buy || 0,
- tabIdx: tabIdx,
- tabLength: tabLength,
- tuan_send_address: rdata.tuan_send_address,
- is_open_order_message: rdata.is_open_order_message,
- is_yue_open: rdata.is_yue_open,
- can_yupay: rdata.can_yupay,
- show_voucher: rdata.show_voucher,
- current_distance,
- man_free_tuanzshipping: rdata.man_free_tuanzshipping*1 || 0,
- man_free_shipping: rdata.man_free_shipping*1 || 0,
- index_hide_headdetail_address: rdata.index_hide_headdetail_address || 0,
- open_score_buy_score: rdata.open_score_buy_score || 0,
- score: rdata.score || 0,
- score_for_money: rdata.score_for_money || 0,
- bue_use_score: rdata.bue_use_score || 0,
- is_man_delivery_tuanz_fare: rdata.is_man_delivery_tuanz_fare, //是否达到满xx减团长配送费
- fare_man_delivery_tuanz_fare_money: rdata.fare_man_delivery_tuanz_fare_money, //达到满xx减团长配送费, 减了多少钱
- is_man_shipping_fare: rdata.is_man_shipping_fare, //是否达到满xx减运费
- fare_man_shipping_fare_money: rdata.fare_man_shipping_fare_money, //达到满xx减运费,司机减了多少运费
- is_vip_card_member,
- vipcard_save_money,
- level_save_money,
- is_open_vipcard_buy,
- is_member_level_buy,
- // canLevelBuy,
- total_integral: total_integral || '',
- is_need_subscript,
- need_subscript_template,
- current_distance_str,
- order_note_open,
- order_note_name,
- order_note_content,
- note_content: order_note_content,
- localtown_dispatchtime,
- pickingup_fare,
- localtown_shipping_fare,
- localtown_modifypickingname: localtown_modifypickingname || '包装费',
- localtown_shipping_fare_arr,
- localtown_moneytype_fixed_freemoney,
- localtown_makeup_delivery_money,
- localtown_expected_delivery,
- localtown_delivery_space_month,
- order_lou_meng_hao: order_lou_meng_hao|| '楼号门牌',
- order_lou_meng_hao_placeholder: order_lou_meng_hao_placeholder || '例如:A座106室',
- presale_info,
- cashondelivery_data,
- allform
- }
- let addrObj = rdata.address || {};
- let tuan_send_address_info = rdata.tuan_send_address_info || {};
- let tuanAddress = tuan_send_address_info.address || '选择位置';
- if(tuan_send_address_info.city_name == "" || tuan_send_address_info.city_id==3708 || tuan_send_address_info.country_name == "" || tuan_send_address_info.country_id==3708){
- tuanAddress = '选择位置';
- }
- // 20200710 TODO
- // addrObj = tuan_send_address_info;
- param.tabAddress = [
- {
- name: rdata.ziti_name || '',
- mobile: rdata.ziti_mobile || ''
- },
- {
- name: tuan_send_address_info.name || '',
- mobile: tuan_send_address_info.telephone || '',
- receiverAddress: tuanAddress,
- lou_meng_hao: tuan_send_address_info.lou_meng_hao || '',
- region: [tuan_send_address_info.province_name || "", tuan_send_address_info.city_name || "", tuan_send_address_info.country_name || ""]
- },
- {
- name: addrObj.name || '',
- mobile: addrObj.telephone || '',
- receiverAddress: addrObj.address || '',
- region: [addrObj.province_name || "选择地址", addrObj.city_name || "", addrObj.country_name || ""]
- },
- {
- name: addrObj.name || '',
- mobile: addrObj.telephone || '',
- receiverAddress: addrObj.address || '',
- region: [addrObj.province_name || "选择地址", addrObj.city_name || "", addrObj.country_name || ""]
- },
- {
- name: rdata.ziti_name || '',
- mobile: rdata.ziti_mobile || ''
- }
- ];
- if(JSON.stringify(addrObj)!='[]') {
- if(addrObj.lon_lat=='') {
- if(tabIdx==3){
- param.tabAddress[3] = {
- name: addrObj.name || '',
- mobile: addrObj.telephone || '',
- receiverAddress: '',
- region: ["选择地址", "", ""]
- }
- }
- } else if(addrObj.lon_lat) {
- let lat_lon = addrObj.lon_lat.split(',');
- wcache.put('latitude2', lat_lon[1]);
- wcache.put('longitude2', lat_lon[0]);
- }
- }
- if (addres == 1) {
- that.setData({
- ...param,
- pick_up_time: res.data.pick_up_time,
- pick_up_type: res.data.pick_up_type,
- pick_up_weekday: res.data.pick_up_weekday,
- addressState: true,
- is_integer: res.data.is_integer,
- is_ziti: res.data.is_ziti,
- pick_up_arr: res.data.pick_up_arr,
- seller_goodss: res.data.seller_goodss,
- seller_chose_id: seller_chose_id,
- seller_chose_store_id: seller_chose_store_id,
- goods: res.data.goods,
- buy_type: res.data.buy_type,
- yupay: res.data.can_yupay,
- is_yue_open: res.data.is_yue_open,
- yu_money: res.data.yu_money,
- total_free: res.data.total_free,
- trans_free_toal: res.data.trans_free_toal,
- delivery_tuanz_money: res.data.delivery_tuanz_money,
- reduce_money: res.data.reduce_money,
- is_open_fullreduction: res.data.is_open_fullreduction,
- cha_reduce_money: res.data.cha_reduce_money
- }, () => {
- that.calcPrice();
- })
- } else {
- that.setData({
- ...param,
- is_integer: res.data.is_integer,
- addressState: false,
- goods: res.data.goods,
- is_ziti: res.data.is_ziti,
- pick_up_arr: res.data.pick_up_arr,
- seller_goodss: res.data.seller_goodss,
- seller_chose_id: seller_chose_id,
- seller_chose_store_id: seller_chose_store_id,
- buy_type: res.data.buy_type,
- yupay: res.data.can_yupay,
- is_yue_open: res.data.is_yue_open,
- yu_money: res.data.yu_money,
- total_free: res.data.total_free,
- trans_free_toal: res.data.trans_free_toal,
- delivery_tuanz_money: res.data.delivery_tuanz_money,
- reduce_money: res.data.reduce_money,
- is_open_fullreduction: res.data.is_open_fullreduction,
- cha_reduce_money: res.data.cha_reduce_money
- },()=>{
- that.calcPrice();
- })
- }
- }
- })
- },
- changeDistance: function(current_distance) {
- if(current_distance) {
- current_distance = parseFloat(current_distance);
- if(current_distance > 1000) {
- let current_distance_int = current_distance/1000;
- return current_distance_int.toFixed(2) + 'km';
- }
- return current_distance + 'm';
- }
- return current_distance;
- },
- /**
- * 授权成功回调
- */
- authSuccess: function () {
- this.onLoad();
- },
- /**
- * 设置手机号
- */
- getReceiveMobile: function (e) {
- var num = e.detail;
- this.setData({
- t_ziti_mobile: num,
- showGetPhone: false
- });
- },
- ck_wxpays: function () {
- this.setData({
- ck_yupay: 0,
- pay_method:'wxpay'
- })
- },
- ck_wxfy:function(){
- this.setData({
- ck_yupay: 3
- })
- },
- ck_yupays: function () {
- this.setData({
- ck_yupay: 1
- })
- },
- ck_cash: function () {
- this.setData({
- ck_yupay: 2
- })
- },
- scoreChange: function (e) {
- console.log('是否使用', e.detail.value)
- let tdata = this.data;
- let score_for_money = tdata.score_for_money*1;
- let tot_price = tdata.tot_price*1;
- let disAmount = tdata.disAmount*1;
- if (e.detail.value){
- tot_price = tot_price - score_for_money;
- disAmount += score_for_money;
- } else {
- tot_price = tot_price + score_for_money;
- disAmount -= score_for_money;
- }
- this.setData({
- use_score: e.detail.value?1:0,
- tot_price: tot_price.toFixed(2),
- disAmount: disAmount.toFixed(2)
- })
- },
- /**
- * 未登录
- */
- needAuth: function(){
- this.setData({
- needAuth: true
- });
- },
- /**
- * 关闭手机授权
- */
- close: function () {
- this.setData({
- showGetPhone: false
- });
- },
- // 生成订单号 Step1
- preOrderConfirm() {
- if(this.data.allform&&this.data.allform.is_open_orderform) {
- this.selectComponent("#sForm").formSubmit();
- return false;
- } else {
- this.goOrderfrom();
- }
- },
- // 生成订单号 Step2
- goOrderfrom: function(formData={detail: {}}) {
- let that = this;
- let { tabAddress, tabIdx, note_content, order_note_open, order_note_name, isAgreePresale, buy_type, presale_info } = this.data;
- this.setData({ formData: formData.detail })
- var t_ziti_name = tabAddress[tabIdx].name;
- var t_ziti_mobile = tabAddress[tabIdx].mobile;
- var receiverAddress = tabAddress[tabIdx].receiverAddress;
- var region = tabAddress[tabIdx].region;
- var tuan_send_address = tabAddress[tabIdx].receiverAddress;
- var lou_meng_hao = tabAddress[tabIdx].lou_meng_hao;
- if (t_ziti_name == '') {
- this.setData({
- focus_name: true
- })
- let tip = '请填写收货人';
- if (tabIdx == 0) tip = '请填写提货人';
- wx.showToast({
- title: tip,
- icon: 'none'
- })
- return false;
- }
- if (t_ziti_mobile == '' || !(/^1(3|4|5|6|7|8|9)\d{9}$/.test(t_ziti_mobile))) {
- this.setData({
- focus_mobile: true
- })
- wx.showToast({
- title: '手机号码有误',
- icon: 'none'
- })
- return false;
- }
- if((tabIdx==0||tabIdx==1||tabIdx==3)&&this.data.buy_type!='virtualcard') {
-
- if(order_note_open==1 && note_content=='') {
- wx.showToast({
- title: '请填写' + order_note_name,
- icon: 'none'
- })
- return false;
- }
- } else {
- note_content = '';
- }
- if(order_note_open==0) note_content = '';
- if ((tabIdx == 2 || tabIdx == 3) && region[0] == '选择地址') {
- wx.showToast({
- title: '请选择所在地区',
- icon: 'none'
- })
- return false;
- }
- if ((tabIdx == 2 || tabIdx == 3) && receiverAddress == ''){
- this.setData({
- focus_addr: true
- })
- wx.showToast({
- title: '请填写详细地址',
- icon: 'none'
- })
- return false;
- }
- if (tabIdx == 1) {
- if (tuan_send_address == '选择位置' || tuan_send_address == '') {
- wx.showToast({
- title: '请选择位置',
- icon: 'none'
- })
- return false;
- }
- if (lou_meng_hao == ''){
- wx.showToast({
- title: '输入楼号门牌',
- icon: 'none'
- })
- return false;
- }
-
- }
- if(buy_type=='presale'&&!isAgreePresale) {
- wx.showModal({
- title: '提示',
- content: '预售商品定金不支持退款,同意后可继续下单',
- showCancel: true,
- cancelText: '我再想想',
- cancelColor: '#ff5344',
- confirmText: '同意下单',
- success (res) {
- if (res.confirm) {
- that.setData({ isAgreePresale: true });
- if (tabIdx == 2){
- that.preSubscript();
- } else {
- that.conformOrder();
- }
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- return;
- }
- if (tabIdx == 2||this.data.buy_type=="virtualcard"){
- this.preSubscript();
- } else {
- this.conformOrder();
- }
- },
- /**
- * 支付防抖
- */
- preSubscript: function(event) {
- let that = this;
- if(!this.canPreSub) return;
- this.canPreSub = false;
- let is_need_subscript = this.data.is_need_subscript;
- if(is_need_subscript==1) {
- //弹出订阅消息
- this.subscriptionNotice().then(()=>{
- that.prepay();
- }).catch(()=>{
- that.prepay();
- });
- } else {
- that.prepay();
- }
- },
- prepay: function() {
- this.canPreSub = true;
- let { tabAddress, tabIdx, is_limit_distance_buy, note_content, seller_goodss, commentArr, formData } = this.data;
- let isVirtualcard = 0;
- if(this.data.buy_type=='virtualcard') isVirtualcard = 1;
- if (is_limit_distance_buy == 1 && (tabIdx == 1) && isVirtualcard==0){
- wx.showModal({
- title: '提示',
- content: '离团长太远了,暂不支持下单',
- showCancel: false,
- confirmColor: '#F75451'
- })
- return false;
- }
- console.log('this.canPay', this.canPay)
- if(this.canPay){
- this.setData({ payBtnLoading: true })
- this.canPay = false;
- var that = this;
- var token = wx.getStorageSync('token');
- let { seller_chose_id, seller_chose_store_id, ck_yupay, tabList } = this.data;
- var voucher_id = seller_chose_id;
- var dispatching = '';
- tabList.forEach(function(item){
- if (item.id == tabIdx) dispatching = item.dispatching;
- })
- let arr = [];
- for (let key in seller_goodss) {
- let goodsid = '';
- let goods = seller_goodss[key].goods;
- Object.keys(goods).forEach(kk=>{
- goodsid += goods[kk].goods_id+'_';
- })
- commentArr[key] = key+'_'+goodsid + commentArr[key];
- }
- for (let key in commentArr) arr.push(commentArr[key]);
- let comment = arr.join('@EOF@');
- var receiverAddress = tabAddress[tabIdx].receiverAddress || '';
- var region = tabAddress[tabIdx].region || [];
- var t_ziti_name = tabAddress[tabIdx].name;
- var t_ziti_mobile = tabAddress[tabIdx].mobile;
- let lou_meng_hao = tabAddress[tabIdx].lou_meng_hao || '';
- var quan_arr = [];
- if (voucher_id > 0) {
- var t_tmp = seller_chose_store_id + '_' + voucher_id;
- quan_arr.push(t_tmp);
- }
- let tuan_send_address = '';
- let tuan_region = '';
- let address_name = '';
- let province_name = '';
- let city_name = '';
- let country_name = '';
- if (tabIdx==1){
- tuan_send_address = receiverAddress;
- tuan_region = region;
- province_name = tuan_region[0];
- city_name = tuan_region[1];
- country_name = tuan_region[2];
- } else if (tabIdx == 2 || tabIdx == 3) {
- address_name = receiverAddress;
- province_name = region[0];
- city_name = region[1];
- country_name = region[2];
- }
- var community = wx.getStorageSync('community');
- var community_id = community.communityId;
- var pick_up_id = community_id;
- let latitude = wx.getStorageSync('latitude2');
- let longitude = wx.getStorageSync('longitude2');
- let { use_score, buy_type, soli_id } = this.data;
- // 送达时间
- let expected_delivery_time = '';
- let localtown_delivery_space_month = '';
- if(tabIdx==3){
- let { localtown_expected_delivery, curAlertTime, localtown_dispatchtime, localtown_delivery_space_month } = this.data;
- if(curAlertTime==-1) {
- expected_delivery_time = localtown_dispatchtime;
- } else {
- expected_delivery_time = localtown_expected_delivery.localtown_delivery_space_time_list[localtown_delivery_space_month][curAlertTime].time;
- }
- expected_delivery_time = localtown_delivery_space_month + ' ' + expected_delivery_time;
- }
- let cashon_delivery = (ck_yupay)==2?1:0
- wx.showLoading();
- app.util.request({
- url: 'entry/wxapp/user',
- data: {
- controller: 'car.sub_order',
- token: token,
- pay_method: 'fypay',
- buy_type,
- pick_up_id,
- dispatching,
- ziti_name: t_ziti_name,
- quan_arr,
- comment,
- ziti_mobile: t_ziti_mobile,
- latitude,
- longitude,
- ck_yupay,
- tuan_send_address,
- lou_meng_hao,
- address_name,
- province_name,
- city_name,
- country_name,
- use_score,
- soli_id,
- note_content,
- expected_delivery_time,
- scene: app.globalData.scene,
- cashon_delivery,
- ...formData
- },
- dataType: 'json',
- method: 'POST',
- success: function (res) {
- wx.hideLoading();
- let has_yupay = res.data.has_yupay || 0;
- var order_id = res.data.order_id;
- let h = {};
- console.log('支付日志:', res);
- if (res.data.code == 0) {
- //富友支付插件
- plugin.fuioupay(
- res.data.total_fee, //必填 单位为分 传1就是1分钱
- {
- reqType:"11", //必填 01-商户模式,11-机构模式
- reqData:res.data.xml, //必填 富友加密参数 通过接口获取
- },
- function succ(e) {
- console.log(e)
- }, //非必填 支付成功后的回调方法,
- function fail(e) { //非必填 支付失败后的回调方法
- wx.showModal({
- title: '支付失败',
- content: JSON.stringify(e),
- showCancel: false,
- })
- }
- )
- // 交易组件
- if(res.data.isRequestOrderPayment==1) {
- wx.requestOrderPayment({
- "orderInfo": res.data.order_info,
- "timeStamp": res.data.timeStamp,
- "nonceStr": res.data.nonceStr,
- "package": res.data.package,
- "signType": res.data.signType,
- "paySign": res.data.paySign,
- 'success': function (wxres) {
- that.canPay = true;
- if (buy_type == "dan" || buy_type == "pindan" || buy_type == "integral" || buy_type == "soitaire" || buy_type == "presale" || buy_type == "virtualcard") {
- if (res.data.is_go_orderlist<=1){
- wx.redirectTo({
- url: '/lionfish_comshop/pages/order/order?id=' + order_id + '&is_show=1&delivery=' + dispatching
- })
- } else {
- wx.redirectTo({
- url: '/lionfish_comshop/pages/order/index?is_show=1'
- })
- }
- } else {
- wx.redirectTo({
- url: `/lionfish_comshop/moduleA/pin/share?id=${order_id}`
- })
- }
- },
- 'fail': function (error) {
- if (res.data.is_go_orderlist <= 1) {
- wx.redirectTo({
- url: '/lionfish_comshop/pages/order/order?id=' + order_id + '&isfail=1&delivery=' + dispatching
- })
- } else {
- wx.redirectTo({
- url: '/lionfish_comshop/pages/order/index?isfail=1'
- })
- }
- }
- })
- } else {
- that.changeIndexList();
- if (has_yupay == 1) {
- that.canPay = true;
- if (buy_type == "dan" || buy_type == "pindan" || buy_type == "integral" || buy_type == "soitaire" || buy_type == "presale" || buy_type == "virtualcard") {
- if (res.data.is_go_orderlist <= 1) {
- wx.redirectTo({
- url: '/lionfish_comshop/pages/order/order?id=' + order_id + '&is_show=1&delivery=' + dispatching
- })
- } else {
- wx.redirectTo({
- url: '/lionfish_comshop/pages/order/index?is_show=1'
- })
- }
- } else {
- wx.redirectTo({
- url: `/lionfish_comshop/moduleA/pin/share?id=${order_id}`
- })
- }
- } else {
- wx.requestPayment({
- "appId": res.data.appId,
- "timeStamp": res.data.timeStamp,
- "nonceStr": res.data.nonceStr,
- "package": res.data.package,
- "signType": res.data.signType,
- "paySign": res.data.paySign,
- 'success': function (wxres) {
- that.canPay = true;
- if (buy_type == "dan" || buy_type == "pindan" || buy_type == "integral" || buy_type == "soitaire" || buy_type == "presale" || buy_type == "virtualcard") {
- if (res.data.is_go_orderlist<=1){
- wx.redirectTo({
- url: '/lionfish_comshop/pages/order/order?id=' + order_id + '&is_show=1&delivery=' + dispatching
- })
- } else {
- wx.redirectTo({
- url: '/lionfish_comshop/pages/order/index?is_show=1'
- })
- }
- } else {
- wx.redirectTo({
- url: `/lionfish_comshop/moduleA/pin/share?id=${order_id}`
- })
- }
- },
- 'fail': function (error) {
- if (res.data.is_go_orderlist <= 1) {
- wx.redirectTo({
- url: '/lionfish_comshop/pages/order/order?id=' + order_id + '&isfail=1&delivery=' + dispatching
- })
- } else {
- wx.redirectTo({
- url: '/lionfish_comshop/pages/order/index?isfail=1'
- })
- }
- }
- })
- }
- }
- } else if (res.data.code == 1) {
- that.canPay = true;
- wx.showModal({
- title: '提示',
- content: res.data.RETURN_MSG || '支付失败',
- showCancel: false,
- confirmColor: '#F75451',
- success (ret) {
- if (ret.confirm) {
- if (res.data.is_go_orderlist <= 1) {
- wx.redirectTo({
- url: '/lionfish_comshop/pages/order/order?id=' + order_id + '&isfail=1&delivery=' + dispatching
- })
- } else {
- wx.redirectTo({
- url: '/lionfish_comshop/pages/order/index?is_show=1&isfail=1'
- })
- }
- }
- }
- })
- } else if (res.data.code == 2) {
- that.canPay = true;
- if( res.data.is_forb ==1 ){ h.btnDisable = true; h.btnText="已抢光"; }
- wx.showToast({
- title: res.data.msg,
- icon: "none"
- });
- } else {
- console.log(res);
- }
- that.setData({ btnLoading: false, payBtnLoading:false, ...h })
- },
- fail: function() {
- wx.redirectTo({
- url: '/lionfish_comshop/pages/order/index?is_show=1&isfail=1'
- })
- }
- })
- }
- },
- /**
- * 监听收货人
- */
- changeReceiverName: function(e) {
- let { tabAddress, tabIdx } = this.data;
- let receiverName = e.detail.value.trim();
- Object.keys(tabAddress).length && (tabAddress[tabIdx].name = receiverName);
- if (!receiverName) {
- let tip = '请填写收货人';
- if (tabIdx == 0) tip = '请填写提货人';
- wx.showToast({
- title: tip,
- icon: "none"
- });
- }
- this.setData({ tabAddress })
- return {
- value: receiverName
- }
- },
- /**
- * 监听备注
- */
- changeNoteName: function(e) {
- let noteName = e.detail.value.trim();
- let order_note_name = this.data.order_note_name;
- if (!noteName) {
- let tip = '请填写' + order_note_name;
- wx.showToast({
- title: tip,
- icon: "none"
- });
- }
- this.setData({ note_content: noteName })
- return {
- value: noteName
- }
- },
- /**
- * 监听手机号
- */
- bindReceiverMobile: function(e) {
- let { tabAddress, tabIdx } = this.data;
- let mobile = e.detail.value.trim();
- tabAddress[tabIdx].mobile = mobile;
- this.setData({ tabAddress });
- return {
- value: mobile
- }
- },
- /**
- * 监控快递地址变化
- */
- changeReceiverAddress: function(e){
- let { tabAddress, tabIdx } = this.data;
- tabAddress[tabIdx].receiverAddress = e.detail.value.trim();
- this.setData({ tabAddress });
- return {
- value: e.detail.value.trim()
- }
- },
- /**
- * 监控团长送货地址变化
- */
- changeTuanAddress: function (e) {
- let { tabAddress, tabIdx } = this.data;
- tabAddress[tabIdx].lou_meng_hao = e.detail.value.trim();
- this.setData({ tabAddress });
- return {
- value: e.detail.value.trim()
- }
- },
- /**
- * 结算
- */
- conformOrder: function() {
- this.setData({
- showConfirmModal: true
- });
- },
- /**
- * 关闭结算
- */
- closeConfirmModal: function() {
- this.canPay = true;
- this.setData({
- showConfirmModal: false
- });
- },
- /**
- * 地区选择
- */
- bindRegionChange: function (e) {
- let region = e.detail.value;
- region && this.checkOut(region[1]);
- this.setData({ region })
- },
- checkOut: function (mb_city_name) {
- var that = this;
- var token = wx.getStorageSync('token');
- var community = wx.getStorageSync('community');
- var community_id = community.communityId;
- let latitude = wx.getStorageSync('latitude2');
- let longitude = wx.getStorageSync('longitude2');
- let buy_type = this.data.buy_type;
- let soli_id = this.data.soli_id;
- app.util.request({
- url: 'entry/wxapp/user',
- data: {
- controller: 'car.checkout',
- token,
- community_id,
- mb_city_name,
- latitude: latitude,
- longitude: longitude,
- buy_type,
- soli_id
- },
- dataType: 'json',
- method: 'POST',
- success: function (res) {
- if(res.data.code==1){
- let rdata = res.data;
- let {
- vipcard_save_money,
- shop_buy_distance,
- is_limit_distance_buy,
- current_distance,
- level_save_money,
- score,
- score_for_money,
- bue_use_score,
- localtown_shipping_fare_arr,
- localtown_moneytype_fixed_freemoney,
- localtown_makeup_delivery_money
- } = rdata;
- if (that.data.tabIdx == 1 && is_limit_distance_buy == 1 && (current_distance > shop_buy_distance)) {
- wx.showModal({
- title: '提示',
- content: '超出配送范围,请重新选择',
- showCancel: false,
- confirmColor: '#F75451'
- })
- }
- current_distance = current_distance || '';
- let current_distance_str = that.changeDistance(current_distance);
- // 同城满免运费
- if(localtown_shipping_fare_arr) {
- let shipping_fare = 0;
- shipping_fare = localtown_shipping_fare_arr.total_yl_shipping_fare*1 - localtown_shipping_fare_arr.total_shipping_fare*1;
- localtown_shipping_fare_arr.shipping_fare = shipping_fare.toFixed(2);
- }
- that.setData({
- score: score || 0,
- score_for_money: score_for_money || 0,
- bue_use_score: bue_use_score || 0,
- vipcard_save_money,
- level_save_money,
- is_limit_distance_buy: is_limit_distance_buy || 0,
- current_distance,
- current_distance_str,
- trans_free_toal: rdata.trans_free_toal,
- is_man_delivery_tuanz_fare: rdata.is_man_delivery_tuanz_fare, //是否达到满xx减团长配送费
- fare_man_delivery_tuanz_fare_money: rdata.fare_man_delivery_tuanz_fare_money, //达到满xx减团长配送费, 减了多少钱
- is_man_shipping_fare: rdata.is_man_shipping_fare, //是否达到满xx减运费
- fare_man_shipping_fare_money: rdata.fare_man_shipping_fare_money, //达到满xx减运费,司机减了多少运费
- localtown_shipping_fare_arr,
- localtown_moneytype_fixed_freemoney,
- localtown_makeup_delivery_money
- }, () => { that.calcPrice() })
- }
- }
- })
- },
- /**
- * 定位获取地址
- */
- choseLocation: function() {
- let { tabAddress, tabIdx } = this.data;
- var that = this;
- wx.chooseLocation({
- success: function (e) {
- console.log(e);
- var s_region = that.data.region;
- var filename = e.name;
- let addr = e.address || '';
- var reg = /.+?(省|市|自治区|自治州|县|区|特别行政区)/g;
- // var result = addr.match(reg);
- var result = "null";
- // console.log('patt', result);
- if (result == "null" || filename=="") {
- locat.getGpsLocation(e.latitude, e.longitude).then((res) => {
- console.log('反推了', res);
- if (res) {
- s_region[0] = res.province;
- s_region[1] = res.city;
- s_region[2] = res.district;
- filename || (filename = res.street);
- }
- setRes();
- });
- } else {
- s_region[0] = result[0];
- s_region[1] = result[1];
- s_region[2] = result[2] || '';
- var dol_path = addr.replace(s_region.join(''), '');
- filename = dol_path + e.name;
- setRes();
- }
-
- wcache.put('latitude2', e.latitude);
- wcache.put('longitude2', e.longitude);
- function setRes(){
- console.log('setData');
- s_region && (s_region[1] != "市") && that.checkOut(s_region[1]);
- tabAddress[tabIdx].region = s_region;
- tabAddress[tabIdx].receiverAddress = filename;
- that.setData({ tabAddress })
- }
- },
- fail: function (error) {
- console.log(error)
- if (error.errMsg =='chooseLocation:fail auth deny') {
- console.log('无权限')
- locat.checkGPS(app, locat.openSetting())
- }
- }
- })
- },
- /**
- * 微信获取地址
- */
- getWxAddress: function() {
- let { tabAddress, tabIdx } = this.data;
- let region = tabAddress[tabIdx].region || [];
- let that = this;
- wx.getSetting({
- success(res) {
- if (res.authSetting['scope.address']) {
- wx.chooseAddress({
- success(res) {
- console.log("step1")
- region[0] = res.provinceName || "选择地址";
- region[1] = res.cityName || "";
- region[2] = res.countyName || "";
- let receiverAddress = res.detailInfo;
- tabAddress[tabIdx].name = res.userName;
- tabAddress[tabIdx].mobile = res.telNumber;
- tabAddress[tabIdx].region = region;
- tabAddress[tabIdx].receiverAddress = receiverAddress;
- that.setData({ tabAddress })
- region && (region[1] != "市") && that.checkOut(region[1]);
- },
- fail(res){
- console.log("step4")
- console.log(res)
- }
- })
- } else {
- if (res.authSetting['scope.address'] == false) {
- wx.openSetting({
- success(res) {
- console.log(res.authSetting)
- }
- })
- } else {
- console.log("step2")
- wx.chooseAddress({
- success(res) {
- console.log("step3")
- region[0] = res.provinceName || "选择地址";
- region[1] = res.cityName || "";
- region[2] = res.countyName || "";
- let receiverAddress = res.detailInfo;
- region && (region[1] != "市") && that.checkOut(region[1]);
- tabAddress[tabIdx].name = res.userName;
- tabAddress[tabIdx].mobile = res.telNumber;
- tabAddress[tabIdx].region = region;
- tabAddress[tabIdx].receiverAddress = receiverAddress;
- that.setData({ tabAddress })
- }
- })
- }
- }
- }
- })
- },
- /**
- * tab切换
- */
- tabSwitch: function (t) {
- let idx = 1 * t.currentTarget.dataset.idx;
- (idx != 0) && wx.showToast({ title: '配送变更,费用已变化', icon: "none"});
- this.setData({
- tabIdx: idx
- },function(){
- this.calcPrice(1);
- })
- },
- /**
- * 打开优惠券
- */
- show_voucher: function (event) {
- var that = this;
- var serller_id = event.currentTarget.dataset.seller_id;
- var voucher_list = [];
- var seller_chose_id = this.data.seller_chose_id;
- var seller_chose_store_id = this.data.seller_chose_store_id;
- var seller_goods = this.data.seller_goodss;
- for (var i in seller_goods) {
- var s_id = seller_goods[i].store_info.s_id;
- if (s_id == serller_id) {
- voucher_list = seller_goods[i].voucher_list;
- if (seller_chose_id == 0) {
- seller_chose_id = seller_goods[i].chose_vouche.id || 0;
- seller_chose_store_id = seller_goods[i].chose_vouche.store_id || 0;
- }
- }
- }
- that.setData({
- ssvoucher_list: voucher_list,
- voucher_serller_id: serller_id,
- seller_chose_id: seller_chose_id,
- seller_chose_store_id: seller_chose_store_id,
- hide_quan: false
- })
- },
- // 选择优惠券
- chose_voucher_id: function (event) {
- wx.showLoading();
- var voucher_id = event.currentTarget.dataset.voucher_id;
- var seller_id = event.currentTarget.dataset.seller_id;
- var that = this;
- var token = wx.getStorageSync('token');
- var use_quan_str = seller_id + "_" + voucher_id;
- let latitude = wx.getStorageSync('latitude2');
- let longitude = wx.getStorageSync('longitude2');
- var buy_type = that.data.buy_type;
- let soli_id = this.data.soli_id;
- var community_id = wx.getStorageSync('community').communityId || '';
- app.util.request({
- url: 'entry/wxapp/user',
- data: {
- controller: 'car.checkout',
- token,
- community_id,
- voucher_id,
- use_quan_str,
- buy_type,
- latitude,
- longitude,
- soli_id
- },
- dataType: 'json',
- method: 'POST',
- success: function (res) {
- wx.hideLoading();
- if(res.data.code ==1){
- let seller_goodss = res.data.seller_goodss;
- let sel_chose_vouche = '';
- for (var i in seller_goodss) {
- seller_goodss[i].goodsnum = Object.keys(seller_goodss[i].goods).length;
- if (Object.prototype.toString.call(seller_goodss[i].chose_vouche) == '[object Object]') {
- sel_chose_vouche = seller_goodss[i].chose_vouche;
- }
- }
- const rdata = res.data;
- let current_distance = rdata.current_distance || '';
- let current_distance_str = that.changeDistance(current_distance);
- let {score,score_for_money,bue_use_score} = rdata;
- let h = {};
- if(bue_use_score*1<=0) h.use_score = '';
- that.setData({
- ...h,
- score: score || 0,
- score_for_money: score_for_money || 0,
- bue_use_score: bue_use_score || 0,
- seller_goodss: seller_goodss,
- seller_chose_id: voucher_id,
- seller_chose_store_id: seller_id,
- hide_quan: true,
- goods: rdata.goods,
- buy_type: rdata.buy_type || 'dan',
- yupay: rdata.can_yupay,
- is_yue_open: rdata.is_yue_open,
- total_free: rdata.total_free,
- sel_chose_vouche: sel_chose_vouche,
- current_distance,
- current_distance_str
- },()=>{
- that.calcPrice(1);
- })
- }
- }
- })
- },
- //关闭优惠券
- closeCouponModal: function(){
- this.setData({
- hide_quan: true
- })
- },
- /**
- * 计算总额
- */
- calcPrice: function(isTabSwitch = 0){
- let tdata = this.data;
- let {
- total_free,
- delivery_tuanz_money,
- fare_man_shipping_fare_money,
- trans_free_toal,
- tabIdx, goods,
- is_open_vipcard_buy,
- is_vip_card_member,
- fare_man_delivery_tuanz_fare_money,
- pickingup_fare,
- localtown_makeup_delivery_money,
- buy_type
- } = tdata;
- total_free *= 1; //合计金额(扣除满减、优惠券,不含运费)
- delivery_tuanz_money *= 1; //配送费
- fare_man_shipping_fare_money *= 1; //免多少运费
- trans_free_toal = trans_free_toal*1;
-
- let tot_price = 0; //计算后合计+运费
- // 商品总额
- let total_goods_price = 0;
- let levelAmount = 0; //等级优惠
- for (let gidx of Object.keys(goods)) {
- let item = goods[gidx];
- total_goods_price += item.total;
- if(is_open_vipcard_buy==1&&item.is_take_vipcard==1&&is_vip_card_member==1) {
- // 会员优惠
- } else if (item.is_mb_level_buy) {
- levelAmount += item.total * 1 - item.level_total * 1;
- }
- }
- let total_all = total_goods_price; //总额
- // 商品总额+配送费
- if(tabIdx==0){
- tot_price = total_free;
- } else if (tabIdx==1){
- // 满免运费
- let is_man_delivery_tuanz_fare = tdata.is_man_delivery_tuanz_fare; //是否达到满xx减团长配送费
- if (is_man_delivery_tuanz_fare==0) {
- tot_price = delivery_tuanz_money + total_free;
- } else {
- tot_price = total_free + delivery_tuanz_money - fare_man_delivery_tuanz_fare_money*1;
- }
- total_all += delivery_tuanz_money;
- } else if(tabIdx==2) {
- // 满免快递费
- let is_man_shipping_fare = tdata.is_man_shipping_fare; //是否达到满xx减运费
- total_all += trans_free_toal;
- if (is_man_shipping_fare == 0) {
- tot_price = trans_free_toal + total_free;
- } else {
- if(buy_type=="pintuan") {
- tot_price = trans_free_toal + total_free;
- } else {
- tot_price = trans_free_toal + total_free - fare_man_shipping_fare_money*1;
- }
- }
- } else if(tabIdx==3) {
- // 同城配送
- let localtown_shipping_fare_arr = this.data.localtown_shipping_fare_arr;
- let total_yl_shipping_fare = localtown_shipping_fare_arr.total_yl_shipping_fare*1 || 0;
- let total_shipping_fare = localtown_shipping_fare_arr.total_shipping_fare*1 || 0;
- total_all += total_yl_shipping_fare;
- //包装费
- total_all += pickingup_fare*1 + localtown_makeup_delivery_money*1;
- tot_price = total_free + localtown_makeup_delivery_money*1;
- tot_price += pickingup_fare*1+total_shipping_fare*1;
- } else if (tabIdx==4) {
- tot_price = total_free;
- }
- //使用积分
- let use_score = tdata.use_score;
- if (isTabSwitch && use_score) {
- let score_for_money = tdata.score_for_money * 1;
- tot_price = tot_price - score_for_money;
- }
- let disAmount = 0; //优惠金额
- disAmount = (total_all - tot_price*1).toFixed(2);
- this.setData({
- total_all: total_all.toFixed(2),
- disAmount,
- tot_price: tot_price.toFixed(2),
- total_goods_price: total_goods_price.toFixed(2),
- levelAmount: levelAmount.toFixed(2)
- })
- },
- /**
- * 订单留言 20190219
- */
- bindInputMessage: function (event) {
- let commentArr = this.data.commentArr;
- let idx = event.currentTarget.dataset.idx;
- var val = event.detail.value;
- commentArr[idx] = val;
- this.setData({ commentArr })
- },
- /**
- * 修改首页列表商品购物车数量
- */
- changeIndexList: function(){
- let goods = this.data.goods || [];
- if(goods.length>0){
- goods.forEach((item)=>{
- item.option.length == 0 && status.indexListCarCount(item.goods_id, 0);
- })
- }
- },
- /**
- * 订阅消息
- */
- subscriptionNotice: function() {
- let that = this;
- return new Promise((resolve, reject)=>{
- let obj = that.data.need_subscript_template;
- let tmplIds = Object.keys(obj).map(key => obj[key]); // 订阅消息模版id
- if (wx.requestSubscribeMessage) {
- tmplIds.length && wx.requestSubscribeMessage({
- tmplIds: tmplIds,
- success(res) {
- let is_need_subscript = 1;
- let acceptId = [];
- Object.keys(obj).forEach(item=>{
- if (res[obj[item]] == 'accept') {
- //用户同意了订阅,添加进数据库
- acceptId.push(item);
- } else {
- //用户拒绝了订阅或当前游戏被禁用订阅消息
- is_need_subscript = 0;
- }
- })
- if(acceptId.length) {
- that.addAccept(acceptId);
- }
- that.setData({ is_need_subscript })
- resolve();
- },
- fail(err) {
- console.log(err)
- reject();
- }
- })
- } else {
- // 兼容处理
- reject();
- }
- })
- },
- // 用户点击订阅添加到数据库
- addAccept: function (acceptId) {
- let token = wx.getStorageSync('token');
- let type = acceptId.join(',');
- app.util.request({
- url: 'entry/wxapp/user',
- data: {
- controller: 'user.collect_subscriptmsg',
- token,
- type
- },
- dataType: 'json',
- method: 'POST',
- success: function () {}
- })
- },
- handleTimeModal: function(){
- let localtown_expected_delivery = this.data.localtown_expected_delivery;
- if(localtown_expected_delivery.localtown_expected_delivery_status&&localtown_expected_delivery.localtown_delivery_space_month) {
- this.setData({
- showAlertTime: !this.data.showAlertTime
- })
- }
- },
- selectAlertTime: function(event){
- let idx = event.currentTarget.dataset.idx;
- console.log(idx)
- this.setData({
- curAlertTime: idx
- })
- },
- selectAlertDate: function(event){
- let idx = event.currentTarget.dataset.idx;
- console.log(idx)
- let curAlertTime = 0;
- if(this.data.localtown_expected_delivery.localtown_delivery_space_month==idx) curAlertTime = -1;
- this.setData({
- localtown_delivery_space_month: idx,
- curAlertTime
- })
- },
- agreePresaleChange: function(e) {
- let state = e.detail.value;
- console.log('统一支付定金', state);
- this.setData({ isAgreePresale: state })
- },
- hanlePresaleModal: function(e) {
- this.setData({
- showPresaleDesc: !this.data.showPresaleDesc
- })
- },
- showPresaleAmoutDesc: function(){
- wx.showModal({
- title: '优惠说明',
- content: '优惠金额将在支付尾款时使用',
- showCancel: false
- })
- }
- })
|