| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847 |
- <template>
- <view v-if="isShowView">
- <!--pages/subOrder/subOrder.wxml-->
- <view class="pdlr20 pd">
- <block v-if="!isFictitious">
- <view class="peisong r10">
- <view class="pstit">
- <view class="psfs">配送方式</view>
- <block
- v-if="onlyPeisong || orderType == 10 || activity || deliver_way.length == 1 || youji || ziti">
- <view class="psfss ziti" v-if="ziti"><text class="active">自提</text></view>
- <view class="psfss ziti" v-else-if="onlyPeisong || orderType == 10 || activity || youji">
- <text class="active">{{ isJs ? '及时达' : '配送' }}</text>
- </view>
- </block>
- <view class="psfss" v-else>
- <text :class="isZiti ? 'active' : ''" @tap="selZiti">自提</text>
- <text :class="isZiti ? '' : 'active'" @tap="selZiti">{{ isJs ? '及时达' : '配送' }}</text>
- </view>
- </view>
- <view class="ztaddr" v-if="isZiti || orderType == 2">
- <view class="mdinfo dflex user">
- <view class="dflex username">
- 提货人:
- <input class placeholder="请填写姓名" type="text" @input="getusername" :value="realName" />
- </view>
- <view class="dflex">
- 提货电话:
- <input v-if="show" class placeholder="请填写提货电话" type="text" @input="getphone"
- maxlength="11" :value="phone" />
- <button open-type="getPhoneNumber" @getphonenumber="getphonenumber" class="mobile"
- v-else>填写手机号</button>
- </view>
- </view>
- <view class="ztaddrs dflex">
- <view class="info">
- <view class="name" @tap="updateShop">自提点:{{ merchant.title ? merchant.title : '请选择门店' }}
- </view>
- <view class="area" @tap="checkMap">
- <image src="/static/pages/images/dzico.png" class="dzico"></image>
- <text class="address">{{ merchant.address }}</text>
- </view>
- </view>
- <view class="rbox" @tap="updateShop">
- <image src="/static/pages/images/more.png" class="rico"></image>
- </view>
- </view>
- <image src="/static/pages/images/dzbg.png" class="dzbg"></image>
- </view>
- <view class=" psaddr" v-else>
- <view class="addr " @tap="addOrUpdateAddress">
- <image src="/static/pages/images/dzico.png" class="dzico"></image>
- <view class="flex" v-if="address&&(address.address || address.house)">
- <view class="name">{{ address.address }}{{ address.house }}</view>
- <view class="text" v-if="address&&address.name">
- {{ address.name }}
- <text>{{ address.phone }}</text>
- </view>
- </view>
- <view class="flex" v-else>请添加收货地址</view>
- <image src="/static/pages/images/more.png" class="rico"></image>
- </view>
- <view class="addr " @tap="updateShop" v-if="merchant">
- <image src="/static/pages/images/dzico.png" class="dzico"></image>
- <view class="flex">
- <view class="name">
- {{ isJs && merchant.isDefault != 1 ? '配送点:' : '服务点:' }}{{ merchant.title ? merchant.title : '请选择门店' }}
- </view>
- <view class="text" v-if="address&&address.name">{{ merchant.address }}</view>
- </view>
- <image src="/static/pages/images/more.png" class="rico"></image>
- </view>
- <!-- <view class="ztaddrs dflex">
- <view class="info">
- <view class="name" bindtap="updateShop">{{isJs&&merchant.isDefault!=1?'配送点:':'服务点:'}}{{merchant.title}}</view>
- <view class="area" bindtap="checkMap">
- <image src="/pages/images/dzico.png" class="dzico"></image>
- <text class="address">{{merchant.address}}</text>
- </view>
- </view>
- <view class="" bindtap="updateShop" class="updateShop">
- <image src="/pages/images/more.png" class="rico"></image>
- </view>
- </view> -->
- <image src="/static/pages/images/dzbg.png" class="dzbg"></image>
- </view>
- </view>
- <!-- 送达时间 -->
- <view class="sendtime dflex" @tap="serviceTime" v-if="isJs && !isZiti && !activity">
- <text>送达时间</text>
- <view class="flex">{{ sendTimes ? sendTimes : '请选择时间' }}</view>
- <image src="/static/pages/images/more.png" class="rico"></image>
- </view>
- </block>
- <view class="list mt20">
- <view v-for="(item, index) in pageList" :key="index" class="li">
- <view class="cimgs">
- <image :src="item.pic" mode="aspectFit" class="cimg"></image>
- <image src="/static/pages/images/jishida.png" class="type"
- v-if="item.isJ && !activity && !item.activityType"></image>
- <image src="/static/pages/images/tuangou.png" class="type" v-if="item.activityType == 1">
- </image>
- <image src="/static/pages/images/seckill.png" class="type" v-if="item.activityType == 2">
- </image>
- <image src="/static/pages/images/newbornZone.png" class="type" v-if="item.activityType == 4">
- </image>
- <view class="gys" v-if="item.activityState == 1">活动进行中</view>
- </view>
- <view class="zhinfo">
- <view class="zhtit">{{ item.title }}</view>
- <view v-if="item.baseModelList" class="guigecontent">
- 规格:
- <text v-for="(itemGuige, index2) in item.baseModelList" :key="index2" class="guige"
- decode="true">{{ itemGuige.value }} </text>
- </view>
- <view class="jiage">
- <view class="zhjia" v-if="orderType != 11">
- <text>¥</text>
- {{ item.price }}
- </view>
- <view v-if="orderType == 11" class="integral">
- <text class="intnum">{{ item.integral }}积分</text>
- <text class="money">+¥{{ item.price }}</text>
- </view>
- <view class="num">
- <!-- <view class="jian" bindtap="jianQuantity" data-index="{{index}}">-</view> -->
- <text class="nums">×{{ item.quantity >= 0 ? item.quantity : '0' }}</text>
- <!-- <view class="jian" bindtap="jiaQuantity" data-index="{{index}}">+</view> -->
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- 海外购 -->
- <view class="overseasPurchase" v-if="orderType == 10 || isHwg">
- <view class="li">
- <text>购买人:</text>
- <view class="item"><input name="hwgName" placeholder="必填" :value="hwgName" @input="gethwgName" />
- </view>
- <image src="/product/static/product/image/bi.png" class="bi"></image>
- </view>
- <view class="li">
- <text>身份证号:</text>
- <view class="item"><input name="cardNo" placeholder="必填" :value="cardNo" @input="getcardNo" />
- </view>
- <image src="/product/static/product/image/bi.png" class="bi"></image>
- </view>
- <view class="dflex info">
- <image src="/product/static/product/image/hwg.png" class="hwg"></image>
- <text>海关规定,购买跨境商品需验证支付人身份证信息,否则将 导致无法清关,请确认您的身份证信息。</text>
- </view>
- </view>
- <view class="ddinfo">
- <view class="li">
- <text>商品数量</text>
- <view>共{{ count >= 0 ? count : '0' }}件</view>
- </view>
- <view class="li">
- <text>订单金额</text>
- <view>¥{{ money > 0 ? money : '0' }}</view>
- </view>
- <view class="li" v-if="orderType == 11">
- <text>使用积分</text>
- <view>{{ integral }}</view>
- </view>
- <view class="li" v-if="!isZiti && feeMoney">
- <text>邮费</text>
- <view>¥{{ feeMoney }}</view>
- </view>
- <navigator url="/product/couponList/index?isChoose=true" hover-class="none" class="li"
- v-if="couponList && couponList.length > 0">
- <text>优惠券</text>
- <view class="quan" v-if="couponter.length > 0">
- {{ coupon ? '-¥' : '不使用优惠券' }}
- <block v-if="coupon">
- {{ couponList[couponIndex].couponAmount ? couponList[couponIndex].couponAmount : '' }}
- </block>
- </view>
- <view class="quan" v-else>暂无可用优惠券</view>
- <image src="/static/pages/images/more.png" class="rico"></image>
- </navigator>
- <view class="li" v-if="is_open_wallet.isOpenWallet == 1 || isOfflinePayment" @tap="balanceShow">
- <text>余额</text>
- <view class="quan">
- {{ (balance && checked) || (kybalances && kychecked) ? '-¥' : '不使用余额'
- }}{{ balance && checked ? balanceMoney : kybalances && kychecked ? kybalanceMoney : '' }}
- </view>
- <image src="/static/pages/images/more.png" class="rico"></image>
- </view>
- </view>
- <view class="ddinfo">
- <view class="li">
- <text>备注:</text>
- <input name="node" placeholder="给卖家留言..." placeholder-class="placeholder" class="flex"
- @input="noteInput" />
- </view>
- </view>
- </view>
- <view class="placeholder-view" :style="'height:' + (bottomBlankHeight + 120) + 'rpx'"></view>
- <view class="bot" :style="'padding-bottom:' + bottomBlankHeight + 'rpx'">
- <view class="heji" v-if="orderType != 11">
- ¥
- <text>{{ payMoney > 0 ? payMoney : '0' }}</text>
- </view>
- <view v-if="orderType == 11" class="integral zong">
- <text class="intnum">{{ integral }}积分</text>
- <text class="money">+¥{{ payMoney }}</text>
- </view>
- <view class="jiesuan" @tap="isBusiness ? tab() : ''">提交订单</view>
- </view>
- <view class="chufangy" v-if="!isRx">订单中包含处方药,需咨询医生开具处方购买</view>
- <!-- 选择送达时间 -->
- <view class="ceng" :hidden="isTimeShow" @tap="closeTime"></view>
- <view class="time-pop" :hidden="isTimeShow">
- <image src="/static/pages/images/close.png" class="close" @tap="closeTime"></image>
- <view class="pop-tit">选择送达时间</view>
- <view class="pop-tits">选择送达时间</view>
- <view class="pop-con dflex">
- <view class="pop-left">
- <view v-for="(item, index) in aWeek" :key="index"
- :class="'li ' + (dateIndex == index ? 'active' : '')" @tap="dateDay" :data-index="index"
- v-if="index < 7">
- {{ item.newday }}{{ item.day }}
- </view>
- <view class="li" @tap="moreDate">更多日期</view>
- </view>
- <view class="pop-right">
- <view v-for="(item, index) in timeList" :key="index"
- :class="'li ' + (timeIndex == index ? 'active' : '')" @tap="dataTime" :data-index="index">
- {{ item }}
- <image src="/static/pages/images/sjgou.png" class="gou"></image>
- </view>
- </view>
- </view>
- <view class="pop-btn" @tap="timeConfirm">确定</view>
- </view>
- <!-- 更多送达日期 -->
- <view class="time-pop" :hidden="isMoreTimeShow">
- <view class="backtime dflex" @tap="closeMoreTime">
- <image src="/static/pages/images/back.png"></image>
- 返回
- </view>
- <image src="/static/pages/images/close.png" class="close" @tap="closeMoreTime"></image>
- <view class="pop-tit">选择送达时间</view>
- <view class="pop-list">
- <picker-view indicator-style="height:40px;" :value="value" @change="bindChange">
- <picker-view-column>
- <view v-for="(item, index) in aWeek" :key="index" class="li">{{ item.newday }}{{ item.day }}
- </view>
- </picker-view-column>
- <picker-view-column>
- <view v-for="(item, index) in timeList" :key="index" class="li">{{ item }}</view>
- </picker-view-column>
- </picker-view>
- </view>
- <view class="pop-btn" @tap="timeConfirm">确定</view>
- </view>
- <view class="ceng" :hidden="isBalanceShow" @tap="closeBalance"></view>
- <view class="time-pop" :hidden="isBalanceShow">
- <view class="balance-tit">余额</view>
- <view class="balances">
- <view class="dflex balance">
- <view>
- 账户余额
- <text>¥{{ userMoney }}</text>
- </view>
- <view class="dflex reduced">
- 本单
- <text>已减¥{{ balanceMoney ? balanceMoney : '0' }}</text>
- <radio-group @change="radioChange">
- <radio :value="balanceMoney" :checked="checked" class="radios" color="#EF4A37"
- @tap="checkedFun"></radio>
- </radio-group>
- </view>
- </view>
- <view class="dflex balance" v-if="isOfflinePayment">
- <view>
- 线下余额
- <text>¥{{ kybalance }}</text>
- </view>
- <view class="dflex reduced">
- 本单
- <text>已减¥{{ kybalanceMoney ? kybalanceMoney : '0' }}</text>
- <radio-group @change="radioChangeKy">
- <radio :value="kybalanceMoney" :checked="kychecked" class="radios" color="#EF4A37"
- @tap="checkedFunKy"></radio>
- </radio-group>
- </view>
- </view>
- </view>
- <view class="pop-btn" @tap="balanceConfirm">确定</view>
- </view>
- </view>
- </template>
- <script>
- import h5util from '../../utils/h5util.js';
- // pages/subOrder/subOrder.js
- const app = getApp();
- const req = require('../../utils/request.js');
- var QQMapWX = require('../../utils/qqmap.js');
- const requsetmessage = require('../../utils/requestmessage.js');
- const util = require('../../utils/util.js');
- const route = require('../../utils/route');
- export default {
- data() {
- return {
- isShowView: false,
- bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
- isJs: false,
- isZiti: false,
- merchant: {},
- address: {},
- ids: '',
- pageList: [],
- count: 0,
- money: 0,
- note: '',
- couponIndex: 0,
- couponList: [],
- couponter: [],
- isRx: true,
- phone: '',
- coupon: true,
- show: false,
- isTimeShow: true,
- //送达时间
- isMoreTimeShow: true,
- //更多送达时间
- dateIndex: 0,
- //当前选择送达日期
- aWeek: [],
- //未来七天
- timeList: [
- '9:00-10:00',
- '10:00-11:00',
- '11:00-12:00',
- '12:00-13:00',
- '13:00-14:00',
- '14:00-15:00',
- '15:00-16:00',
- '16:00-17:00',
- '17:00-18:00',
- '18:00-19:00',
- '19:00-20:00',
- '20:00-21:00',
- '21:00-22:00',
- '22:00-23:00',
- '23:00-24:00'
- ],
- //时间段
- timeIndex: 0,
- //当前选择时间
- checked: false,
- isBalanceShow: true,
- orderType: '',
- is_customer_pick_up: '',
- query: '',
- userInfo: '',
- realName: '',
- userMoney: '',
- ziti: false,
- youji: false,
- deliver_way: '',
- is_open_wallet: '',
- // fee: "",
- // free: "",
- onlyPeisong: '',
- Is_Store_Price_Stock: '',
- is_open_shop: '',
- cardNo: '',
- hwgName: '',
- isGys: false,
- feeMoney: '',
- balance: false,
- balanceMoney: '',
- payMoney: '',
- integral: '',
- sendTimes: '',
- userIntegral: '',
- overTime: true,
- isHwg: false,
- isBusiness: true,
- User_Limit_Store: '',
- about: {},
- kychecked: false,
- kybalance: 0, //线下余额
- kybalances: false,
- kybalanceMoney: '',
- isOfflinePayment: false, //是否开启线下支付
- isFictitious: false, //是否是实物产品
- orderId: '',
- };
- },
- components: {},
- props: {},
- onLoad: function(options) {
- console.log('参数' + JSON.stringify(options));
- this.ids = options.ids;
- this.setData({
- orderType: options.orderType,
- is_customer_pick_up: req.public.is_customer_pick_up,
- query: options
- });
- if (options.activityId) {
- this.activityId = options.activityId; //活动id
- if (options.orderType != 2) {
- // this.setData({ activity: true })
- }
- } // 11为积分产品
- if (options.orderType == 11) {
- this.getUserintegral();
- } //4为拼团
- if (options.orderType == 4) {
- this.aprId = options.aprId; //团组id
- this.pay = options.pay; //判断用户是从哪个页面进来
- }
- if (options.orderType == 7) {
- this.aprId = options.aprId; //砍价id
- } // 社区团购
- if (options.orderType == 2)
- this.setData({
- isZiti: true,
- ziti: true
- });
- if (options.orderType == 10) {
- this.setData({
- isZiti: false
- });
- }
- QQMapWX.initMap(req.public.mapLBSKEY);
- this.getMy();
- this.init();
- app.globalData.getCheckSessoin(json => {
- this.sessionKey = json.session_key;
- });
- },
- onShow() {
- this.getMerchant();
- // console.log(this.merchant); // let merchant = req.getStorage("MERCHANT");
- // this.setData({ merchant: merchant });
- //重新计算价格
- // this.CalculationMoney();
- this.getFreightMoney(); //重新获取运费(用于切换收货地址)
- let userInfo = req.getStorage('userInfo');
- this.setData({
- userInfo: userInfo
- });
- if (userInfo.realName) {
- this.setData({
- realName: req.excludeSpecial(userInfo.realName)
- });
- } else if (userInfo.nickName) {
- this.setData({
- realName: req.excludeSpecial(userInfo.nickName)
- });
- } //*****************/改动
- this.setData({
- phone: userInfo.mobile
- });
- var arr = [];
- for (let i = 0; i < 30; i++) {
- arr.push(this.dealTime(i));
- }
- arr[0].day = '(今天)';
- arr[1].day = '(明天)';
- arr[2].day = '(后天)';
- let myDate = new Date();
- let hour = myDate.getHours();
- let timeList = this.timeList;
- arr.map((item, index) => {
- if (index == 0) {
- item.timeList = timeList.slice(hour - 8);
- } else {
- item.timeList = timeList;
- }
- return item;
- });
- this.setData({
- aWeek: arr,
- timeList: timeList.slice(hour - 8)
- });
- // #ifdef H5
- // 校验支付成功
- if (this.orderId) {
- req.checkPaySuccess(this.orderId, sucs => {
- console.log('付款结果>>>>', sucs);
- // this.payJumpSuc(sucs);
- uni.navigateBack()
- });
- }
- // #endif
- },
- methods: {
- async init() {
- await this.getUserAddress();
- await this.getConfig();
- await this.getList();
- await this.getuserMoney();
- if (this.isOfflinePayment) {
- await this.getUserInformation();
- }
- },
- getUserInformation() {
- let _ts = this;
- req.postRequest('/api/order/userInformation', {}, res => {
- if (res) {
- _ts.kybalance = res.kybalance;
- if (_ts.userMoney == 0 && res.kybalance > 0) {
- _ts.kychecked = true;
- _ts.CalculationMoney();
- }
- }
- });
- },
- // 余额查询
- getuserMoney() {
- let _ts = this;
- let is_open_wallet = JSON.parse(req.getStorage('configRes')).is_open_wallet;
- if (is_open_wallet) {
- if (JSON.parse(is_open_wallet).isOpenWallet == 1 || this.is_open_wallet.isOpenWallet == 1) {
- route.extendNew({}, res => {
- if (res) {
- this.setData({
- userMoney: parseFloat(res.all).toFixed(2)
- });
- if (res.all > 0) {
- _ts.checked = true;
- _ts.CalculationMoney();
- }
- }
- });
- }
- }
- },
- getMerchant() {
- if (!this.query.merchantId || this.about.Many_Store == 0) {
- // 总店
- let defaultMerchant = req.getStorage('defaultMerchant');
- this.setData({
- merchant: defaultMerchant
- });
- // let merchant = req.getStorage('MERCHANT')
- // this.setData({ merchant: merchant })
- } else {
- let from = {};
- if (this.query.shopId != null && this.query.shopId != undefined && this.query.shopId != '') {
- from.id = this.query.shopId;
- } else {
- from.id = this.query.merchantId;
- }
- req.getRequest('/api/merchant/detail', from, res => {
- if (!res.id) {
- if (this.Is_Store_Price_Stock == 1) {
- this.isBusiness = false;
- return req.msg('该门店不存在' + (this.User_Limit_Store != 1 ? ',因各门店价格不同,请重新下单' : ''));
- } else {
- return req.msg('该门店不存在' + (this.User_Limit_Store != 1 ? ',请切换门店' : ''));
- }
- } else {
- var timestamp = Date.parse(new Date());
- if (!res.isBusiness) {
- if (this.Is_Store_Price_Stock == 1) {
- this.isBusiness = false;
- return req.msg('该门店暂未营业' + (this.User_Limit_Store != 1 ? ',因各门店价格不同,请重新下单' :
- ''));
- } else {
- return req.msg('该门店暂未营业' + (this.User_Limit_Store != 1 ? ',请切换门店' : ''));
- }
- } else {
- if (!res.isGoods && res.type != 5) {
- if (this.Is_Store_Price_Stock == 1) {
- this.isBusiness = false;
- return req.msg('该门店暂不发货' + (this.User_Limit_Store != 1 ?
- ',因各门店价格不同,请重新下单' : ''));
- } else {
- return req.msg('该门店暂不发货' + (this.User_Limit_Store != 1 ? ',请切换门店' : ''));
- }
- }
- if (res.type == 5 && !res.isDistance) {
- if (this.Is_Store_Price_Stock == 1) {
- this.isBusiness = false;
- return req.msg('该门店暂不发货' + (this.User_Limit_Store != 1 ?
- ',因各门店价格不同,请重新下单' : ''));
- } else {
- return req.msg('该门店暂不发货' + (this.User_Limit_Store != 1 ? ',请切换门店' : ''));
- }
- }
- if (res.isDefault == 1 && this.query.orderType != '2') {
- // this.setData({ isZiti: false, youji: true })
- } else if (res.type == 5) {
- res.time = timestamp + 60 * 60 * 1000;
- res.merchantDTO.time = timestamp + 60 * 60 * 1000;
- req.setStorage('smallShop', res);
- req.setStorage('MERCHANT', res.merchantDTO);
- req.getRequest(
- '/api/params/value', {
- type: 'shop_config'
- },
- res => {
- // JSON.parse(res)
- // console.log(res)
- if (!res || !res.deliverWay) {
- this.setData({
- isZiti: true,
- ziti: true
- });
- } else {
- let deliver_way = res.deliverWay;
- if (deliver_way.length >= 2) {
- if ((deliver_way[0] == '2' && deliver_way[1] == '3') || (
- deliver_way[0] == '3' && deliver_way[1] == '2')) {
- this.setData({
- isZiti: false,
- youji: true
- });
- }
- } else if (deliver_way.length == 1) {
- deliver_way.forEach(it => {
- if (it == 1) {
- this.setData({
- isZiti: true,
- ziti: true
- });
- }
- if (it == 2 || it == 3) {
- this.setData({
- isZiti: false,
- youji: true
- });
- }
- });
- }
- this.setData({
- deliver_way: res.deliverWay
- });
- }
- }
- );
- } else {
- // this.setData({ isZiti: true })
- res.time = timestamp + 60 * 60 * 1000;
- req.setStorage('MERCHANT', res);
- req.removeStorage('smallShop');
- }
- this.setData({
- merchant: res
- });
- }
- }
- });
- }
- },
- selZiti() {
- if (this.isZiti == false && this.isGys) {
- req.msg('您选择的部分商品,不提供自提服务');
- return false;
- }
- if (this.isZiti == false && this.merchant.isGoods == 0) {
- req.msg('该门店,不提供自提服务');
- return false;
- }
- this.setData({
- isZiti: !this.isZiti
- });
- this.CalculationMoney();
- if (this.isZiti == true && this.isJs) {
- req.msg('您选择的是门店自提,不享受及时达服务');
- }
- },
- // 选择余额
- balanceShow() {
- this.setData({
- isBalanceShow: false
- });
- },
- closeBalance() {
- this.setData({
- isBalanceShow: true
- });
- this.CalculationMoney();
- },
- checkedFun() {
- this.setData({
- checked: !this.checked,
- kychecked: false
- });
- },
- checkedFunKy() {
- this.setData({
- checked: false,
- kychecked: !this.kychecked
- });
- },
- balanceConfirm() {
- this.setData({
- isBalanceShow: true
- });
- this.CalculationMoney();
- },
- getConfig() {
- var _this = this;
- return new Promise((resolve, reject) => {
- req.getRequest('/api/config', {}, function(res) {
- if (res.is_open_wallet) {
- let is_open_wallet = JSON.parse(res.is_open_wallet);
- _this.is_open_wallet = is_open_wallet;
- _this.setData({
- is_open_wallet: is_open_wallet
- });
- }
- _this.setData({
- // fee: res.Express_Fee, //zxb 12.20日屏蔽,调用邮费模板
- // free: res.Free_Shipping,//zxb 12.20日屏蔽,调用邮费模板
- onlyPeisong: res.is_customer_pick_up == 1 ? true : false,
- isOfflinePayment: res.is_open_OfflinePayment == 1 ? true : false,
- Is_Store_Price_Stock: res.Is_Store_Price_Stock,
- is_open_shop: res.is_open_shop,
- User_Limit_Store: res.User_Limit_Store,
- about: res
- });
- resolve();
- });
- });
- },
- checkMap() {
- let url = 'product/map/map';
- app.globalData.openPage(url);
- },
- updateShop() {
- if (!req.getStorage('user_merchantId')) {
- if (!this.isBusiness) {} else {
- if (this.Is_Store_Price_Stock == 1 && this.merchant.id && !this.query.activityId) {
- uni.navigateTo({
- url: '/pages/nearbyDetails/nearbyDetails?id=' + this.merchant.id
- });
- } else {
- let url = 'merchant/nearby/nearby?isChoose=true';
- app.globalData.openPage(url);
- }
- }
- }
- },
- checkRequire(formItemList) {
- //判断虚拟产品productForm 1、实物、2服务 3虚拟物
- for (var i = 0; i < formItemList.length; i++) {
- if (formItemList[i].productForm == 1 || formItemList[i].productForm == 2) {
- return false;
- }
- }
- return true;
- },
- getList() {
- let that = this;
- req.getRequest(
- '/api/purchase/list', {
- ids: this.ids // merchantId: this.data.merchant.id
- },
- data => {
- if (!data || data.length == 0) return req.msg('数据不存在');
- data = data.map(it => {
- if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
- return it;
- });
- that.isFictitious = that.checkRequire(data);
- console.log('数据isFictitious====', that.isFictitious);
- that.setData({
- pageList: data
- });
- this.getFreightMoney();
- this.pageList.forEach(res => {
- if (res.isOtc == '1') {
- this.setData({
- isRx: false
- });
- }
- if (res.isOtc == '5') {
- if (!this.activityId && that.query.orderType != 20) {
- this.setData({
- orderType: 10,
- youji: true,
- isZiti: false
- });
- } else {
- this.youji = true;
- this.isZiti = false;
- this.isHwg = true;
- }
- }
- if (res.isTimely == '2') {
- this.setData({
- isGys: true
- });
- }
- if (JSON.parse(res.deliverWay) && res.isOtc != '5' && that.query.orderType != 2) {
- // 判断有发货方式有几种
- let deliverWay = JSON.parse(res.deliverWay).find((value, index, arr) => {
- return value >= 2;
- });
- // 发货方式大于2,并且没有1 就是只有邮寄
- if (deliverWay && JSON.parse(res.deliverWay).indexOf(1) == -1) {
- that.setData({
- youji: true,
- isZiti: false
- });
- }
- // 发货方式只有1中,并且是1 就是只有自提
- if (JSON.parse(res.deliverWay).indexOf(1) != -1 && JSON.parse(res.deliverWay)
- .length == 1) {
- that.setData({
- ziti: true,
- isZiti: true
- });
- }
- // 发货方式中有3,或者4 并且不是社区团购订单,并且没有活动id 就是极速达
- if ((JSON.parse(res.deliverWay).indexOf(3) != -1 || JSON.parse(res.deliverWay)
- .indexOf(4) != -1) && this.orderType != 2) {
- that.setData({
- isJs: true
- // orderType: 5
- });
- if (JSON.parse(res.deliverWay).indexOf(2) == -1 && JSON.parse(res
- .deliverWay).indexOf(1) == -1) {
- that.setData({
- onelyJsd: true
- });
- }
- if (JSON.parse(res.deliverWay).indexOf(2) != -1) {
- that.setData({
- Jsdyouji: true
- });
- }
- if (JSON.parse(res.deliverWay).indexOf(1) != -1) {
- that.setData({
- Jsdziti: true
- });
- }
- }
- }
- });
- if (!that.pageList[0].activityType) {
- that.loadCoupon();
- }
- that.CalculationMoney(); // let count = 0;
- this.isShowView = true;
- }
- );
- },
- adjustmentQuantity(id, quantity, skuId, success) {
- req.postRequest(
- '/api/purchase/quantity', {
- id: id,
- skuId: skuId,
- quantity: quantity
- },
- () => {
- success.call(this);
- }
- );
- },
- jianQuantity(event) {
- const index = event.currentTarget.dataset.index;
- const page = this.pageList[index];
- if (page.quantity <= 1) return false;
- const q = page.quantity - 1;
- let that = this;
- this.adjustmentQuantity(page.id, q, page.skuId, () => {
- let d = {};
- d['pageList[' + index + '].quantity'] = q;
- that.setData(d);
- that.CalculationMoney();
- });
- },
- jiaQuantity(event) {
- const index = event.currentTarget.dataset.index;
- const page = this.pageList[index];
- const q = page.quantity + 1;
- let that = this;
- this.adjustmentQuantity(page.id, q, page.skuId, () => {
- let d = {};
- d['pageList[' + index + '].quantity'] = q;
- that.setData(d);
- that.CalculationMoney();
- });
- },
- //调用接口获取邮费
- getFreightMoney() {
- if (this.pageList && this.pageList.length > 0 && this.address && this.address.id) {
- this.feeMoney = '';
- this.CalculationMoney();
- req.getRequest(
- '/api/purchase/freight', {
- ids: this.pageList.map(it => it.id).join(','), //购物车id
- addressId: this.address.id //收货地址ID
- },
- res => {
- console.log('快递运费>>>>=====' + res);
- this.feeMoney = res;
- this.CalculationMoney();
- }
- );
- }
- },
- CalculationM() {
- //计算商品总价格
- const counts = this.pageList.length;
- let count = 0;
- let money = 0;
- let integral = 0;
- if (counts > 0) {
- this.pageList.forEach(lst => {
- count += lst.quantity;
- money += lst.quantity * lst.price;
- integral += lst.integral * lst.quantity;
- });
- }
- let payMoney = 0;
- if (this.isZiti) {
- payMoney = money;
- this.setData({
- feeMoney: '0'
- });
- } else {
- money = parseFloat(money).toFixed(2);
- // zxb 12.20屏蔽 使用了运费模板,故老的逻辑屏蔽
- // let fee = 0;
- // if (this.free > 0) fee = Number(money) - Number(this.free);
- // else fee = Number(money);
- // this.setData({
- // feeMoney: fee >= 0 ? 0 : this.fee
- // });
- if (this.feeMoney > 0) payMoney = Number(money) + Number(this.feeMoney);
- else payMoney = Number(money);
- }
- //获取优惠券价格
- if (this.couponList.length > 0 && this.couponter.length > 0) {
- const coupon = this.couponList[this.couponIndex];
- if (coupon == undefined) {
- (payMoney = payMoney),
- this.setData({
- coupon: false
- });
- } else {
- if (payMoney >= coupon.couponFull) {
- (payMoney = payMoney - parseFloat(coupon.couponAmount)),
- this.setData({
- coupon: true
- });
- } else {
- payMoney = payMoney;
- this.coupon = false;
- }
- }
- }
- this.setData({
- count: count,
- money: parseFloat(money).toFixed(2),
- // payMoney: parseFloat(payMoney).toFixed(2),
- integral: integral
- });
- return payMoney;
- },
- CalculationMoney() {
- let _ts = this;
- let payMoney = _ts.CalculationM();
- //获取余额
- if (_ts.checked) {
- if (_ts.userMoney > 0) {
- const coupon = _ts.userMoney;
- if (payMoney >= coupon) {
- (payMoney = payMoney - parseFloat(coupon)),
- _ts.setData({
- balance: true,
- balanceMoney: coupon
- });
- } else {
- if (payMoney <= 0) {
- _ts.setData({
- balance: true,
- balanceMoney: '0'
- });
- } else {
- let balanceMoney = parseFloat(parseFloat(coupon) + (payMoney - parseFloat(coupon)))
- .toFixed(2);
- payMoney = payMoney - parseFloat(parseFloat(coupon) + (payMoney - parseFloat(coupon)))
- .toFixed(2);
- _ts.setData({
- balance: true,
- balanceMoney: balanceMoney
- });
- }
- } // payMoney = payMoney - parseFloat(coupon), this.setData({ balance: true })
- } else {
- (payMoney = payMoney),
- _ts.setData({
- balance: false,
- balanceMoney: 0
- });
- }
- }
- if (_ts.kychecked) {
- //获取线下余额
- if (_ts.kybalance > 0) {
- const coupon = _ts.kybalance;
- if (payMoney >= coupon) {
- (payMoney = payMoney - parseFloat(coupon)),
- _ts.setData({
- kybalances: true,
- kybalanceMoney: coupon
- });
- } else {
- if (payMoney <= 0) {
- _ts.setData({
- kybalances: true,
- kybalanceMoney: '0'
- });
- } else {
- let kybalanceMoney = parseFloat(parseFloat(coupon) + (payMoney - parseFloat(coupon)))
- .toFixed(2);
- payMoney = payMoney - parseFloat(parseFloat(coupon) + (payMoney - parseFloat(coupon)))
- .toFixed(2);
- _ts.setData({
- kybalances: true,
- kybalanceMoney: kybalanceMoney
- });
- }
- } // payMoney = payMoney - parseFloat(coupon), this.setData({ balance: true })
- } else {
- (payMoney = payMoney),
- _ts.setData({
- kybalances: false,
- kybalanceMoney: 0
- });
- }
- }
- _ts.setData({
- payMoney: parseFloat(payMoney).toFixed(2)
- });
- },
- noteInput(event) {
- this.note = event.detail.value;
- },
- // 选择余额
- radioChange(e) {
- // console.log('radio发生change事件,携带value值为:', e.detail.value);
- },
- // 选择线下支付
- radioChangeKy(e) {
- // console.log('radio发生change事件,携带value值为:', e.detail.value);
- },
- async loadCoupon() {
- let _ts = this;
- req.getRequest(
- '/api/v3/coupon/use', {
- ids: _ts.ids
- },
- data => {
- _ts.couponter = data;
- if (data && data.length > 0) {
- let coupon = data.filter(it => {
- return it.isUse;
- });
- console.log('coupon', coupon);
- _ts.setData({
- couponList: coupon
- });
- }
- if (data && data.length > 0) _ts.CalculationMoney();
- }
- );
- },
- async loadCoupons() {
- let _ts = this;
- req.getRequest(
- '/api/coupon/user', {
- page: 1,
- limit: 100,
- couponState: 1
- },
- res => {
- let contunt = res;
- if (_ts.query.activityId || _ts.query.aprId || _ts.query.orderType == 11) return false;
- req.getRequest(
- '/api/coupon/use', {
- ids: _ts.ids
- },
- data => {
- _ts.couponter = data;
- let couponObj = [];
- contunt.forEach((it, index) => {
- data.forEach(el => {
- if (it.id == el.id) {
- it.acitve = true;
- }
- });
- });
- var objectArraySort = function(keyName) {
- return function(objectN, objectM) {
- var valueN = objectN[keyName];
- var valueM = objectM[keyName];
- if (valueN < valueM) return 1;
- else if (valueN > valueM) return -1;
- else return 0;
- };
- };
- contunt.sort(objectArraySort('couponAmount'));
- contunt.forEach((it, index) => {
- if (it.acitve && couponObj.length <= 0) {
- _ts.couponIndex = index;
- couponObj.push(index);
- }
- });
- _ts.setData({
- couponList: contunt
- });
- if (data.length > 0) _ts.CalculationMoney();
- }
- );
- }
- );
- },
- getUserAddress() {
- req.g('/api/address/get/default', data => {
- this.setData({
- address: data
- });
- this.getFreightMoney();
- });
- },
- addOrUpdateAddress() {
- let url = 'mine/addAddress/addAddress?isChoose=true&orderType=' + this.orderType;
- if (this.address && this.address.id) {
- url = 'mine/address/address?isChoose=true&orderType=' + this.orderType + '&addressId=' + this.address
- .id;
- }
- app.globalData.openPage(url);
- },
- getMy() {
- let that = this;
- req.getRequest('/api/user/my', {}, data => {
- that.setData({
- userInfo: req.getStorage('userInfo'),
- // realName: req.getStorage('userInfo').realName,
- phone: data.mobile
- });
- let _userinfo = req.getStorage('userInfo');
- if (_userinfo.mobile) {
- this.setData({
- show: true
- });
- }
- _userinfo.mobile = data.mobile;
- req.setStorage('userInfo', _userinfo);
- });
- },
- getphonenumber(event) {
- const detail = event.detail;
- const _ts = this;
- if (!detail || !detail.encryptedData || !detail.iv) return false;
- req.postRequest(
- '/api/weixin/mobile', {
- encryptedData: detail.encryptedData,
- iv: detail.iv,
- sessionKey: _ts.sessionKey
- },
- res => {
- _ts.setData({
- phone: res.mobile,
- show: true
- });
- let userInfo = req.getStorage('userInfo');
- userInfo.mobile = res.mobile;
- req.setStorage('userInfo', userInfo);
- _ts.getMy();
- }
- );
- },
- payOrder(res) {
- // this.setData({ btn: 1 })
- req.payOrder(res, success => {
- this.payJumpSuc(success);
- });
- },
- payJumpSuc(success) {
- if (success) {
- //支付成功
- if (!this.isRx) {
- h5util.jumpUrlExternal({url:'/product/pay/pay?isSuccess=true&&orderId=' + this.orderId + '&isRx=1',type:'redirectTo'})
- // app.globalData.redirectTab('product/pay/pay?isSuccess=true&&orderId=' + this.orderId + '&isRx=1');
- } else if (this.orderType == 4) {
- //拼团订单,
- if (this.pay == 1) {
- uni.navigateBack();
- } else {
- h5util.jumpUrlExternal({url:'/activity/group/ptDetail/ptDetail?acid=' + this.activityId +
- '&id=' + this.aprId + '&merchantId=' + this.query.merchantId,type:'redirectTo'})
- //支付成功之后跳入到拼团页面
- // app.globalData.redirectTab('activity/group/ptDetail/ptDetail?acid=' + this.activityId +
- // '&id=' + this.aprId + '&merchantId=' + this.query.merchantId);
- }
- } else {
- h5util.jumpUrlExternal({url:'/product/pay/pay?isSuccess=true',type:'redirectTo'})
- // app.globalData.redirectTab('product/pay/pay?isSuccess=true');
- }
- this.orderId = '';
- } else {
- h5util.jumpUrlExternal({url:'/product/pay/pay?money=' + this.money + '&id=' + res,type:'redirectTo'})
- // app.globalData.redirectTab('product/pay/pay?money=' + this.money + '&id=' + res);
- }
-
- },
- tab: util.throttle(async function() {
- let _ts = this;
- let mode = this.isZiti ? 1 : 2;
- if (!this.isZiti && this.isJs) {
- mode = 3;
- }
- // #ifdef MP-WEIXIN
- if (!this.isFictitious) {
- if (!this.isRx) {
- await requsetmessage.recipel(mode).then(res => {});
- } else if (mode == 1) {
- await requsetmessage.selfRaising().then(res => {
- // console.log("自提", res);
- });
- } else if (mode == 2) {
- await requsetmessage.distribution().then(res => {
- // console.log("配送", res);
- });
- } else {
- await requsetmessage.jisda().then(res => {});
- }
- }
- // #endif
- this.createOrder();
- }, 3000),
- async createOrder() {
- let _ts = this;
- await this.submitOrder(data => {
- if (_ts.orderId) {
- // _ts.payOrder(_ts.orderId);
- h5util.jumpPay({
- orderId:_ts.orderId,
- isRx:_ts.isRx,
- pay:_ts.pay,
- activityId:_ts.activityId,
- aprId:_ts.aprId,
- merchantId:_ts.query.merchantId,
- money:_ts.money,
- orderType:_ts.orderType
- })
- return false;
- }
- let isShowLoading = false;
- if (!isShowLoading) {
- req.loadIng('加载中');
- isShowLoading = true;
- }
- req.postRequest('/api/order/save', data, res => {
- _ts.orderId = res;
- // _ts.payOrder(_ts.orderId);
- h5util.jumpPay({
- orderId:_ts.orderId,
- isRx:_ts.isRx,
- pay:_ts.pay,
- activityId:_ts.activityId,
- aprId:_ts.aprId,
- merchantId:_ts.query.merchantId,
- money:_ts.money,
- orderType:_ts.orderType
- })
- if (isShowLoading) {
- uni.hideLoading();
- isShowLoading = false;
- }
- });
- });
- },
- // 获取身份证号
- getcardNo(e) {
- this.setData({
- cardNo: e.detail.value
- });
- },
- // 获取购买人姓名
- gethwgName(e) {
- this.setData({
- hwgName: e.detail.value
- });
- },
- //获取用户输入的名字 改动
- getusername(event) {
- // console.log(event.detail.value)
- this.setData({
- realName: req.excludeSpecial(event.detail.value)
- });
- },
- //获取用户输入的电话 改动
- getphone(event) {
- this.setData({
- phone: event.detail.value
- });
- },
- // 选择送达时间
- serviceTime() {
- this.setData({
- isTimeShow: false
- });
- },
- closeTime() {
- this.setData({
- isTimeShow: true,
- isMoreTimeShow: true
- });
- },
- moreDate() {
- this.setData({
- isMoreTimeShow: false
- });
- },
- closeMoreTime() {
- this.setData({
- isMoreTimeShow: true
- });
- },
- //处理未来七天的函数
- dealTime: function(num) {
- // num:未来天数
- var time = new Date(); // 获取当前时间日期
- var date = new Date(time.setDate(time.getDate() + num)).getDate(); //这里先获取日期,在按需求设置日期,最后获取需要的
- var year = time.getFullYear(); // 获取年份
- var month = time.getMonth() + 1; // 获取月份
- var day = time.getDay(); // 获取星期
- switch (day) {
- // 格式化
- case 0:
- day = '(周日)';
- break;
- case 1:
- day = '(周一)';
- break;
- case 2:
- day = '(周二)';
- break;
- case 3:
- day = '(周三)';
- break;
- case 4:
- day = '(周四)';
- break;
- case 5:
- day = '(周五)';
- break;
- case 6:
- day = '(周六)';
- break;
- }
- var obj = {
- date: date,
- year: year,
- day: day,
- month: month,
- newday: month + '-' + date
- };
- return obj; // 返回对象
- },
- dateDay(event) {
- //选择送达日期
- let index = event.currentTarget.dataset.index;
- let aWeek = this.aWeek[index];
- if (index == 7) return false;
- this.sendDate = aWeek.newday;
- this.setData({
- dateIndex: index,
- timeList: aWeek.timeList
- });
- },
- dataTime(event) {
- //选择送达时间
- let index = event.currentTarget.dataset.index;
- let sendTime = this.timeList[index];
- this.sendTime = sendTime;
- this.setData({
- timeIndex: index
- });
- },
- timeConfirm() {
- //确定送达时间
- if (!this.sendDate) {
- this.sendDate = this.aWeek[0].newday;
- }
- if (!this.sendTime) {
- this.sendTime = this.aWeek[0].timeList[0];
- }
- this.setData({
- isTimeShow: true,
- isMoreTimeShow: true,
- sendTimes: this.sendDate + ' ' + this.sendTime
- });
- },
- bindChange(e) {
- //更多时间确定
- const val = e.detail.value;
- let aWeek = this.aWeek[val[0]];
- this.setData({
- timeList: aWeek.timeList
- });
- this.sendDate = this.aWeek[val[0]].newday;
- this.sendTime = this.timeList[val[1]];
- },
- // 用户积分余额查询
- getUserintegral() {
- req.getRequest('/api/integral/returnIntegral', {}, data => {
- this.setData({
- userIntegral: data
- });
- });
- },
- //
- submitOrder(success) {
- let that = this;
- let mode = this.isZiti ? 1 : 2;
- if (!this.isZiti && this.isJs) {
- mode = 3;
- this.noshow = true;
- }
- if (
- this.orderType != 2 &&
- this.orderType != 3 &&
- this.orderType != 4 &&
- this.orderType != 6 &&
- this.orderType != 7 &&
- this.orderType != 10 &&
- this.orderType != 11 &&
- this.query.orderType != 20
- ) {
- if (this.isZiti && this.isJs) {
- this.setData({
- orderType: 1
- });
- }
- if (!this.isJs) {
- this.setData({
- orderType: 1
- });
- }
- }
- let pidCode = req.getStorage('pidCode');
- let data = {
- ids: this.pageList.map(it => it.id).join(','),
- mode: mode,
- orderType: this.orderType,
- node: this.note,
- phone: this.phone,
- userName: req.excludeSpecial(this.realName),
- version: '2',
- scene: req.getStorage('scene')
- };
- if (this.is_open_wallet && this.is_open_wallet.isOpenWallet == 1 && this.checked) {
- //this.balance
- data.balancePayMoney = this.balanceMoney;
- }
- if (this.kychecked) {
- //线下余额支付
- data.offlinePaymentMoney = this.kybalanceMoney;
- }
- if (this.merchant && this.merchant.type == 5) {
- data.shopId = this.merchant.id;
- data.merchantId = this.merchant.merchantDTO.id;
- } else {
- data.merchantId = this.merchant.id;
- }
- if (this.orderType == 11) {
- data.integral = this.integral;
- if (this.integral > this.userIntegral) return req.msg('您的积分余额为' + this.userIntegral + ',不足以购买该产品');
- }
- if (this.activityId) {
- data.activityId = this.activityId;
- }
- if (!this.isRx) {
- data.is_oct = 1;
- }
- if (data.mode == 3) {
- data.jsonDate = this.sendTimes;
- }
- if (this.orderType == 10 || this.isHwg) {
- data.idcard = this.cardNo;
- data.userName = this.hwgName;
- }
- if (this.orderType == 4 || this.orderType == 7) {
- data.aprId = this.aprId;
- } // 获取推荐人
- if (pidCode && req.getStorage('userInfo').id != pidCode) {
- data.pid = pidCode;
- }
- this.setData({
- phone: data.phone,
- realName: req.excludeSpecial(data.userName)
- }); //添加电话正则
- let myreg = /^1[3456789]\d{9}$/; // 真实姓名正则
- let reg = /^[\u4E00-\u9FA5A-Za-z0-9]{1,20}$/; // 海外购真实姓名正则
- let hwgreg = /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/; // 身份证正则
- let sfz = /^[1-9]\d{5}(18|19|20|(3\d))\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;
- if (this.couponList && this.couponList.length > 0 && this.couponter.length > 0) {
- if (this.coupon) data.couponId = this.couponList[this.couponIndex].id;
- }
- // 获取营业时间
- var time = [];
- var start;
- var end;
- var current;
- if (this.merchant && mode != 2) {
- if (this.merchant.businessTime) {
- time = this.merchant.businessTime.split('-');
- if (time.length == 2) {
- this.overTime = true;
- var myDate = new Date();
- var hours = myDate.getHours(); //获取当前小时
- var minutes = myDate.getMinutes(); //获取当前分钟
- var timeState;
- var timeEnd;
- if (time[0].indexOf(':') != '-1') {
- timeState = time[0].split(':');
- }
- if (time[1].indexOf(':') != '-1') {
- timeEnd = time[1].split(':');
- }
- if (time[0].indexOf(':') != '-1') {
- timeState = time[0].split(':');
- }
- if (time[1].indexOf(':') != '-1') {
- timeEnd = time[1].split(':');
- }
- start = +timeState[0] * (60000 * 60) + +timeState[1] * 60000; //营业开始时间转毫秒
- end = +timeEnd[0] * (60000 * 60) + +timeEnd[1] * 60000; //营业结束时间转毫秒
- current = +hours * (60000 * 60) + +minutes * 60000; //当前时间转毫秒
- }
- }
- }
- if (this.isFictitious) {
- success.call(this, data);
- } else {
- if (this.isZiti) {
- //自提
- //*******************************
- if (!data.merchantId) return req.msg('请选择提货门店');
- if (!this.realName || !this.phone) return req.msg('请填写提货人和提货电话'); //判断电话是否正确
- if (!myreg.test(this.phone)) {
- return req.msg('请填写正确的手机号码!');
- } //判断名字是否正确
- if (!reg.test(data.userName)) return req.msg('请输入正确提货人姓名');
- data.addressId = this.merchant.id;
- if (current < start) {
- uni.showModal({
- content: '本店暂末营业,请于' + this.merchant.businessTime + '期间提货!',
- confirmText: '同意',
- cancelText: '不同意',
- success(res) {
- if (res.confirm) {
- success.call(that, data);
- }
- }
- });
- } else if (current > end) {
- uni.showModal({
- content: '本店已歇业,请于次日' + this.merchant.businessTime + '期间提货!',
- confirmText: '同意',
- cancelText: '不同意',
- success(res) {
- if (res.confirm) {
- success.call(that, data);
- }
- }
- });
- } else {
- success.call(this, data);
- }
- } else {
- if (!data.merchantId) return req.msg('请选择发货门店');
- if (!that.address || !that.address.id) return req.msg('请选择收货地址');
- if (data.orderType == 10 || this.isHwg) {
- if (data.userName == '' || data.userName == undefined || data.userName == null) {
- return req.msg('请填写购买人');
- } else {
- if (!hwgreg.test(this.hwgName)) return req.msg('请输入正确真实姓名(至少2位汉字)');
- }
- if (data.idcard == '' || data.idcard == undefined || data.idcard == null) {
- return req.msg('请填写身份证号码');
- } else {
- if (!sfz.test(data.idcard)) return req.msg('请输入正确的身份证');
- }
- }
- let address = that.address;
- data.addressId = address.id;
- let merchant = this.merchant; //只有及时达的订单才需要校验地址范围
- // if (this.data.orderType == 5) {
- // if (data.jsonDate == "" || data.jsonDate == undefined) return req.msg("请选择送达时间")
- // }
- if (data.mode == 3) {
- if (!address.lat || !address.lng) return req.msg('收货地址未解析,请重新选择收货地址');
- let formAddress = {
- latitude: merchant.lat,
- longitude: merchant.lng
- }; //判断用户收货地址是否在门店发货距离之内
- QQMapWX.calculateDistance(
- formAddress,
- [{
- latitude: address.lat,
- longitude: address.lng
- }],
- res => {
- //超出了订单范围,并且是及时达订单
- if (res.elements[0].distance / 1000 > merchant.distance) {
- // console.log("发货距离", res.elements[0].distance / 1000, "门店范围距离", merchant
- // .distance); // return req.msg('非常抱歉,您的配送地址超出我们的配送服务范围');
- let content = '';
- if (!this.onelyJsd) {
- if (this.Jsdyouji) {
- content = '您的及时达订单超过了配送服务范围,是否同意转为邮寄发货?';
- } else if (this.Jsdziti && !this.Jsdyouji) {
- content = '您的及时达订单超过了配送服务范围,是否同意转为自提?';
- }
- } else {
- content = '您的及时达订单超过了配送服务范围!暂不提供服务';
- }
- uni.showModal({
- content: content,
- confirmText: '同意',
- success(res) {
- if (res.confirm) {
- if (that.Jsdyouji && !that.onelyJsd) {
- // if(that.query.orderType==20){
- // data.orderType = 20;
- // }else{
- // data.orderType = 1; //设置为普通订单
- // }
- data.mode = 2; //方式为邮寄
- that.setData({
- isJs: false
- });
- success.call(that, data);
- } else if (that.Jsdziti && !that.Jsdyouji && !that
- .onelyJsd && !that.onlyPeisong) {
- // if(that.query.orderType==20){
- // data.orderType = 20;
- // }else{
- // data.orderType = 1; //设置为普通订单
- // }
- data.mode = 1; //方式为自提
- that.setData({
- isJs: true,
- isZiti: true
- });
- // success.call(that, data);
- } else if (that.onelyJsd) {
- return false;
- }
- } else if (res.cancel) {}
- }
- });
- } else {
- if (current < start) {
- uni.showModal({
- content: '对不起,工作人员末上班,您的订单将于' + time[0] + '后进行配送!',
- confirmText: '同意',
- cancelText: '不同意',
- success(res) {
- if (res.confirm) {
- success.call(that, data);
- } else if (res.cancel) {}
- }
- });
- } else if (current > end) {
- uni.showModal({
- content: '本店已歇业,您的订单将于次日' + time[0] + '后进行配送!',
- confirmText: '同意',
- cancelText: '不同意',
- success(res) {
- if (res.confirm) {
- success.call(that, data);
- } else if (res.cancel) {}
- }
- });
- } else {
- success.call(that, data);
- }
- // success.call(this, data);
- }
- }
- );
- } else {
- success.call(this, data);
- }
- }
- }
- }
- }
- };
- </script>
- <style>
- @import './subOrder.css';
- </style>
|