subOrder.vue 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847
  1. <template>
  2. <view v-if="isShowView">
  3. <!--pages/subOrder/subOrder.wxml-->
  4. <view class="pdlr20 pd">
  5. <block v-if="!isFictitious">
  6. <view class="peisong r10">
  7. <view class="pstit">
  8. <view class="psfs">配送方式</view>
  9. <block
  10. v-if="onlyPeisong || orderType == 10 || activity || deliver_way.length == 1 || youji || ziti">
  11. <view class="psfss ziti" v-if="ziti"><text class="active">自提</text></view>
  12. <view class="psfss ziti" v-else-if="onlyPeisong || orderType == 10 || activity || youji">
  13. <text class="active">{{ isJs ? '及时达' : '配送' }}</text>
  14. </view>
  15. </block>
  16. <view class="psfss" v-else>
  17. <text :class="isZiti ? 'active' : ''" @tap="selZiti">自提</text>
  18. <text :class="isZiti ? '' : 'active'" @tap="selZiti">{{ isJs ? '及时达' : '配送' }}</text>
  19. </view>
  20. </view>
  21. <view class="ztaddr" v-if="isZiti || orderType == 2">
  22. <view class="mdinfo dflex user">
  23. <view class="dflex username">
  24. 提货人:
  25. <input class placeholder="请填写姓名" type="text" @input="getusername" :value="realName" />
  26. </view>
  27. <view class="dflex">
  28. 提货电话:
  29. <input v-if="show" class placeholder="请填写提货电话" type="text" @input="getphone"
  30. maxlength="11" :value="phone" />
  31. <button open-type="getPhoneNumber" @getphonenumber="getphonenumber" class="mobile"
  32. v-else>填写手机号</button>
  33. </view>
  34. </view>
  35. <view class="ztaddrs dflex">
  36. <view class="info">
  37. <view class="name" @tap="updateShop">自提点:{{ merchant.title ? merchant.title : '请选择门店' }}
  38. </view>
  39. <view class="area" @tap="checkMap">
  40. <image src="/static/pages/images/dzico.png" class="dzico"></image>
  41. <text class="address">{{ merchant.address }}</text>
  42. </view>
  43. </view>
  44. <view class="rbox" @tap="updateShop">
  45. <image src="/static/pages/images/more.png" class="rico"></image>
  46. </view>
  47. </view>
  48. <image src="/static/pages/images/dzbg.png" class="dzbg"></image>
  49. </view>
  50. <view class=" psaddr" v-else>
  51. <view class="addr " @tap="addOrUpdateAddress">
  52. <image src="/static/pages/images/dzico.png" class="dzico"></image>
  53. <view class="flex" v-if="address&&(address.address || address.house)">
  54. <view class="name">{{ address.address }}{{ address.house }}</view>
  55. <view class="text" v-if="address&&address.name">
  56. {{ address.name }}
  57. <text>{{ address.phone }}</text>
  58. </view>
  59. </view>
  60. <view class="flex" v-else>请添加收货地址</view>
  61. <image src="/static/pages/images/more.png" class="rico"></image>
  62. </view>
  63. <view class="addr " @tap="updateShop" v-if="merchant">
  64. <image src="/static/pages/images/dzico.png" class="dzico"></image>
  65. <view class="flex">
  66. <view class="name">
  67. {{ isJs && merchant.isDefault != 1 ? '配送点:' : '服务点:' }}{{ merchant.title ? merchant.title : '请选择门店' }}
  68. </view>
  69. <view class="text" v-if="address&&address.name">{{ merchant.address }}</view>
  70. </view>
  71. <image src="/static/pages/images/more.png" class="rico"></image>
  72. </view>
  73. <!-- <view class="ztaddrs dflex">
  74. <view class="info">
  75. <view class="name" bindtap="updateShop">{{isJs&&merchant.isDefault!=1?'配送点:':'服务点:'}}{{merchant.title}}</view>
  76. <view class="area" bindtap="checkMap">
  77. <image src="/pages/images/dzico.png" class="dzico"></image>
  78. <text class="address">{{merchant.address}}</text>
  79. </view>
  80. </view>
  81. <view class="" bindtap="updateShop" class="updateShop">
  82. <image src="/pages/images/more.png" class="rico"></image>
  83. </view>
  84. </view> -->
  85. <image src="/static/pages/images/dzbg.png" class="dzbg"></image>
  86. </view>
  87. </view>
  88. <!-- 送达时间 -->
  89. <view class="sendtime dflex" @tap="serviceTime" v-if="isJs && !isZiti && !activity">
  90. <text>送达时间</text>
  91. <view class="flex">{{ sendTimes ? sendTimes : '请选择时间' }}</view>
  92. <image src="/static/pages/images/more.png" class="rico"></image>
  93. </view>
  94. </block>
  95. <view class="list mt20">
  96. <view v-for="(item, index) in pageList" :key="index" class="li">
  97. <view class="cimgs">
  98. <image :src="item.pic" mode="aspectFit" class="cimg"></image>
  99. <image src="/static/pages/images/jishida.png" class="type"
  100. v-if="item.isJ && !activity && !item.activityType"></image>
  101. <image src="/static/pages/images/tuangou.png" class="type" v-if="item.activityType == 1">
  102. </image>
  103. <image src="/static/pages/images/seckill.png" class="type" v-if="item.activityType == 2">
  104. </image>
  105. <image src="/static/pages/images/newbornZone.png" class="type" v-if="item.activityType == 4">
  106. </image>
  107. <view class="gys" v-if="item.activityState == 1">活动进行中</view>
  108. </view>
  109. <view class="zhinfo">
  110. <view class="zhtit">{{ item.title }}</view>
  111. <view v-if="item.baseModelList" class="guigecontent">
  112. 规格:
  113. <text v-for="(itemGuige, index2) in item.baseModelList" :key="index2" class="guige"
  114. decode="true">{{ itemGuige.value }}&nbsp;</text>
  115. </view>
  116. <view class="jiage">
  117. <view class="zhjia" v-if="orderType != 11">
  118. <text>¥</text>
  119. {{ item.price }}
  120. </view>
  121. <view v-if="orderType == 11" class="integral">
  122. <text class="intnum">{{ item.integral }}积分</text>
  123. <text class="money">+¥{{ item.price }}</text>
  124. </view>
  125. <view class="num">
  126. <!-- <view class="jian" bindtap="jianQuantity" data-index="{{index}}">-</view> -->
  127. <text class="nums">×{{ item.quantity >= 0 ? item.quantity : '0' }}</text>
  128. <!-- <view class="jian" bindtap="jiaQuantity" data-index="{{index}}">+</view> -->
  129. </view>
  130. </view>
  131. </view>
  132. </view>
  133. </view>
  134. <!-- 海外购 -->
  135. <view class="overseasPurchase" v-if="orderType == 10 || isHwg">
  136. <view class="li">
  137. <text>购买人:</text>
  138. <view class="item"><input name="hwgName" placeholder="必填" :value="hwgName" @input="gethwgName" />
  139. </view>
  140. <image src="/product/static/product/image/bi.png" class="bi"></image>
  141. </view>
  142. <view class="li">
  143. <text>身份证号:</text>
  144. <view class="item"><input name="cardNo" placeholder="必填" :value="cardNo" @input="getcardNo" />
  145. </view>
  146. <image src="/product/static/product/image/bi.png" class="bi"></image>
  147. </view>
  148. <view class="dflex info">
  149. <image src="/product/static/product/image/hwg.png" class="hwg"></image>
  150. <text>海关规定,购买跨境商品需验证支付人身份证信息,否则将 导致无法清关,请确认您的身份证信息。</text>
  151. </view>
  152. </view>
  153. <view class="ddinfo">
  154. <view class="li">
  155. <text>商品数量</text>
  156. <view>共{{ count >= 0 ? count : '0' }}件</view>
  157. </view>
  158. <view class="li">
  159. <text>订单金额</text>
  160. <view>¥{{ money > 0 ? money : '0' }}</view>
  161. </view>
  162. <view class="li" v-if="orderType == 11">
  163. <text>使用积分</text>
  164. <view>{{ integral }}</view>
  165. </view>
  166. <view class="li" v-if="!isZiti && feeMoney">
  167. <text>邮费</text>
  168. <view>¥{{ feeMoney }}</view>
  169. </view>
  170. <navigator url="/product/couponList/index?isChoose=true" hover-class="none" class="li"
  171. v-if="couponList && couponList.length > 0">
  172. <text>优惠券</text>
  173. <view class="quan" v-if="couponter.length > 0">
  174. {{ coupon ? '-¥' : '不使用优惠券' }}
  175. <block v-if="coupon">
  176. {{ couponList[couponIndex].couponAmount ? couponList[couponIndex].couponAmount : '' }}
  177. </block>
  178. </view>
  179. <view class="quan" v-else>暂无可用优惠券</view>
  180. <image src="/static/pages/images/more.png" class="rico"></image>
  181. </navigator>
  182. <view class="li" v-if="is_open_wallet.isOpenWallet == 1 || isOfflinePayment" @tap="balanceShow">
  183. <text>余额</text>
  184. <view class="quan">
  185. {{ (balance && checked) || (kybalances && kychecked) ? '-¥' : '不使用余额'
  186. }}{{ balance && checked ? balanceMoney : kybalances && kychecked ? kybalanceMoney : '' }}
  187. </view>
  188. <image src="/static/pages/images/more.png" class="rico"></image>
  189. </view>
  190. </view>
  191. <view class="ddinfo">
  192. <view class="li">
  193. <text>备注:</text>
  194. <input name="node" placeholder="给卖家留言..." placeholder-class="placeholder" class="flex"
  195. @input="noteInput" />
  196. </view>
  197. </view>
  198. </view>
  199. <view class="placeholder-view" :style="'height:' + (bottomBlankHeight + 120) + 'rpx'"></view>
  200. <view class="bot" :style="'padding-bottom:' + bottomBlankHeight + 'rpx'">
  201. <view class="heji" v-if="orderType != 11">
  202. <text>{{ payMoney > 0 ? payMoney : '0' }}</text>
  203. </view>
  204. <view v-if="orderType == 11" class="integral zong">
  205. <text class="intnum">{{ integral }}积分</text>
  206. <text class="money">+¥{{ payMoney }}</text>
  207. </view>
  208. <view class="jiesuan" @tap="isBusiness ? tab() : ''">提交订单</view>
  209. </view>
  210. <view class="chufangy" v-if="!isRx">订单中包含处方药,需咨询医生开具处方购买</view>
  211. <!-- 选择送达时间 -->
  212. <view class="ceng" :hidden="isTimeShow" @tap="closeTime"></view>
  213. <view class="time-pop" :hidden="isTimeShow">
  214. <image src="/static/pages/images/close.png" class="close" @tap="closeTime"></image>
  215. <view class="pop-tit">选择送达时间</view>
  216. <view class="pop-tits">选择送达时间</view>
  217. <view class="pop-con dflex">
  218. <view class="pop-left">
  219. <view v-for="(item, index) in aWeek" :key="index"
  220. :class="'li ' + (dateIndex == index ? 'active' : '')" @tap="dateDay" :data-index="index"
  221. v-if="index < 7">
  222. {{ item.newday }}{{ item.day }}
  223. </view>
  224. <view class="li" @tap="moreDate">更多日期</view>
  225. </view>
  226. <view class="pop-right">
  227. <view v-for="(item, index) in timeList" :key="index"
  228. :class="'li ' + (timeIndex == index ? 'active' : '')" @tap="dataTime" :data-index="index">
  229. {{ item }}
  230. <image src="/static/pages/images/sjgou.png" class="gou"></image>
  231. </view>
  232. </view>
  233. </view>
  234. <view class="pop-btn" @tap="timeConfirm">确定</view>
  235. </view>
  236. <!-- 更多送达日期 -->
  237. <view class="time-pop" :hidden="isMoreTimeShow">
  238. <view class="backtime dflex" @tap="closeMoreTime">
  239. <image src="/static/pages/images/back.png"></image>
  240. 返回
  241. </view>
  242. <image src="/static/pages/images/close.png" class="close" @tap="closeMoreTime"></image>
  243. <view class="pop-tit">选择送达时间</view>
  244. <view class="pop-list">
  245. <picker-view indicator-style="height:40px;" :value="value" @change="bindChange">
  246. <picker-view-column>
  247. <view v-for="(item, index) in aWeek" :key="index" class="li">{{ item.newday }}{{ item.day }}
  248. </view>
  249. </picker-view-column>
  250. <picker-view-column>
  251. <view v-for="(item, index) in timeList" :key="index" class="li">{{ item }}</view>
  252. </picker-view-column>
  253. </picker-view>
  254. </view>
  255. <view class="pop-btn" @tap="timeConfirm">确定</view>
  256. </view>
  257. <view class="ceng" :hidden="isBalanceShow" @tap="closeBalance"></view>
  258. <view class="time-pop" :hidden="isBalanceShow">
  259. <view class="balance-tit">余额</view>
  260. <view class="balances">
  261. <view class="dflex balance">
  262. <view>
  263. 账户余额
  264. <text>¥{{ userMoney }}</text>
  265. </view>
  266. <view class="dflex reduced">
  267. 本单
  268. <text>已减¥{{ balanceMoney ? balanceMoney : '0' }}</text>
  269. <radio-group @change="radioChange">
  270. <radio :value="balanceMoney" :checked="checked" class="radios" color="#EF4A37"
  271. @tap="checkedFun"></radio>
  272. </radio-group>
  273. </view>
  274. </view>
  275. <view class="dflex balance" v-if="isOfflinePayment">
  276. <view>
  277. 线下余额
  278. <text>¥{{ kybalance }}</text>
  279. </view>
  280. <view class="dflex reduced">
  281. 本单
  282. <text>已减¥{{ kybalanceMoney ? kybalanceMoney : '0' }}</text>
  283. <radio-group @change="radioChangeKy">
  284. <radio :value="kybalanceMoney" :checked="kychecked" class="radios" color="#EF4A37"
  285. @tap="checkedFunKy"></radio>
  286. </radio-group>
  287. </view>
  288. </view>
  289. </view>
  290. <view class="pop-btn" @tap="balanceConfirm">确定</view>
  291. </view>
  292. </view>
  293. </template>
  294. <script>
  295. import h5util from '../../utils/h5util.js';
  296. // pages/subOrder/subOrder.js
  297. const app = getApp();
  298. const req = require('../../utils/request.js');
  299. var QQMapWX = require('../../utils/qqmap.js');
  300. const requsetmessage = require('../../utils/requestmessage.js');
  301. const util = require('../../utils/util.js');
  302. const route = require('../../utils/route');
  303. export default {
  304. data() {
  305. return {
  306. isShowView: false,
  307. bottomBlankHeight: app.globalData.isIPhoneX ? 68 : 0,
  308. isJs: false,
  309. isZiti: false,
  310. merchant: {},
  311. address: {},
  312. ids: '',
  313. pageList: [],
  314. count: 0,
  315. money: 0,
  316. note: '',
  317. couponIndex: 0,
  318. couponList: [],
  319. couponter: [],
  320. isRx: true,
  321. phone: '',
  322. coupon: true,
  323. show: false,
  324. isTimeShow: true,
  325. //送达时间
  326. isMoreTimeShow: true,
  327. //更多送达时间
  328. dateIndex: 0,
  329. //当前选择送达日期
  330. aWeek: [],
  331. //未来七天
  332. timeList: [
  333. '9:00-10:00',
  334. '10:00-11:00',
  335. '11:00-12:00',
  336. '12:00-13:00',
  337. '13:00-14:00',
  338. '14:00-15:00',
  339. '15:00-16:00',
  340. '16:00-17:00',
  341. '17:00-18:00',
  342. '18:00-19:00',
  343. '19:00-20:00',
  344. '20:00-21:00',
  345. '21:00-22:00',
  346. '22:00-23:00',
  347. '23:00-24:00'
  348. ],
  349. //时间段
  350. timeIndex: 0,
  351. //当前选择时间
  352. checked: false,
  353. isBalanceShow: true,
  354. orderType: '',
  355. is_customer_pick_up: '',
  356. query: '',
  357. userInfo: '',
  358. realName: '',
  359. userMoney: '',
  360. ziti: false,
  361. youji: false,
  362. deliver_way: '',
  363. is_open_wallet: '',
  364. // fee: "",
  365. // free: "",
  366. onlyPeisong: '',
  367. Is_Store_Price_Stock: '',
  368. is_open_shop: '',
  369. cardNo: '',
  370. hwgName: '',
  371. isGys: false,
  372. feeMoney: '',
  373. balance: false,
  374. balanceMoney: '',
  375. payMoney: '',
  376. integral: '',
  377. sendTimes: '',
  378. userIntegral: '',
  379. overTime: true,
  380. isHwg: false,
  381. isBusiness: true,
  382. User_Limit_Store: '',
  383. about: {},
  384. kychecked: false,
  385. kybalance: 0, //线下余额
  386. kybalances: false,
  387. kybalanceMoney: '',
  388. isOfflinePayment: false, //是否开启线下支付
  389. isFictitious: false, //是否是实物产品
  390. orderId: '',
  391. };
  392. },
  393. components: {},
  394. props: {},
  395. onLoad: function(options) {
  396. console.log('参数' + JSON.stringify(options));
  397. this.ids = options.ids;
  398. this.setData({
  399. orderType: options.orderType,
  400. is_customer_pick_up: req.public.is_customer_pick_up,
  401. query: options
  402. });
  403. if (options.activityId) {
  404. this.activityId = options.activityId; //活动id
  405. if (options.orderType != 2) {
  406. // this.setData({ activity: true })
  407. }
  408. } // 11为积分产品
  409. if (options.orderType == 11) {
  410. this.getUserintegral();
  411. } //4为拼团
  412. if (options.orderType == 4) {
  413. this.aprId = options.aprId; //团组id
  414. this.pay = options.pay; //判断用户是从哪个页面进来
  415. }
  416. if (options.orderType == 7) {
  417. this.aprId = options.aprId; //砍价id
  418. } // 社区团购
  419. if (options.orderType == 2)
  420. this.setData({
  421. isZiti: true,
  422. ziti: true
  423. });
  424. if (options.orderType == 10) {
  425. this.setData({
  426. isZiti: false
  427. });
  428. }
  429. QQMapWX.initMap(req.public.mapLBSKEY);
  430. this.getMy();
  431. this.init();
  432. app.globalData.getCheckSessoin(json => {
  433. this.sessionKey = json.session_key;
  434. });
  435. },
  436. onShow() {
  437. this.getMerchant();
  438. // console.log(this.merchant); // let merchant = req.getStorage("MERCHANT");
  439. // this.setData({ merchant: merchant });
  440. //重新计算价格
  441. // this.CalculationMoney();
  442. this.getFreightMoney(); //重新获取运费(用于切换收货地址)
  443. let userInfo = req.getStorage('userInfo');
  444. this.setData({
  445. userInfo: userInfo
  446. });
  447. if (userInfo.realName) {
  448. this.setData({
  449. realName: req.excludeSpecial(userInfo.realName)
  450. });
  451. } else if (userInfo.nickName) {
  452. this.setData({
  453. realName: req.excludeSpecial(userInfo.nickName)
  454. });
  455. } //*****************/改动
  456. this.setData({
  457. phone: userInfo.mobile
  458. });
  459. var arr = [];
  460. for (let i = 0; i < 30; i++) {
  461. arr.push(this.dealTime(i));
  462. }
  463. arr[0].day = '(今天)';
  464. arr[1].day = '(明天)';
  465. arr[2].day = '(后天)';
  466. let myDate = new Date();
  467. let hour = myDate.getHours();
  468. let timeList = this.timeList;
  469. arr.map((item, index) => {
  470. if (index == 0) {
  471. item.timeList = timeList.slice(hour - 8);
  472. } else {
  473. item.timeList = timeList;
  474. }
  475. return item;
  476. });
  477. this.setData({
  478. aWeek: arr,
  479. timeList: timeList.slice(hour - 8)
  480. });
  481. // #ifdef H5
  482. // 校验支付成功
  483. if (this.orderId) {
  484. req.checkPaySuccess(this.orderId, sucs => {
  485. console.log('付款结果>>>>', sucs);
  486. // this.payJumpSuc(sucs);
  487. uni.navigateBack()
  488. });
  489. }
  490. // #endif
  491. },
  492. methods: {
  493. async init() {
  494. await this.getUserAddress();
  495. await this.getConfig();
  496. await this.getList();
  497. await this.getuserMoney();
  498. if (this.isOfflinePayment) {
  499. await this.getUserInformation();
  500. }
  501. },
  502. getUserInformation() {
  503. let _ts = this;
  504. req.postRequest('/api/order/userInformation', {}, res => {
  505. if (res) {
  506. _ts.kybalance = res.kybalance;
  507. if (_ts.userMoney == 0 && res.kybalance > 0) {
  508. _ts.kychecked = true;
  509. _ts.CalculationMoney();
  510. }
  511. }
  512. });
  513. },
  514. // 余额查询
  515. getuserMoney() {
  516. let _ts = this;
  517. let is_open_wallet = JSON.parse(req.getStorage('configRes')).is_open_wallet;
  518. if (is_open_wallet) {
  519. if (JSON.parse(is_open_wallet).isOpenWallet == 1 || this.is_open_wallet.isOpenWallet == 1) {
  520. route.extendNew({}, res => {
  521. if (res) {
  522. this.setData({
  523. userMoney: parseFloat(res.all).toFixed(2)
  524. });
  525. if (res.all > 0) {
  526. _ts.checked = true;
  527. _ts.CalculationMoney();
  528. }
  529. }
  530. });
  531. }
  532. }
  533. },
  534. getMerchant() {
  535. if (!this.query.merchantId || this.about.Many_Store == 0) {
  536. // 总店
  537. let defaultMerchant = req.getStorage('defaultMerchant');
  538. this.setData({
  539. merchant: defaultMerchant
  540. });
  541. // let merchant = req.getStorage('MERCHANT')
  542. // this.setData({ merchant: merchant })
  543. } else {
  544. let from = {};
  545. if (this.query.shopId != null && this.query.shopId != undefined && this.query.shopId != '') {
  546. from.id = this.query.shopId;
  547. } else {
  548. from.id = this.query.merchantId;
  549. }
  550. req.getRequest('/api/merchant/detail', from, res => {
  551. if (!res.id) {
  552. if (this.Is_Store_Price_Stock == 1) {
  553. this.isBusiness = false;
  554. return req.msg('该门店不存在' + (this.User_Limit_Store != 1 ? ',因各门店价格不同,请重新下单' : ''));
  555. } else {
  556. return req.msg('该门店不存在' + (this.User_Limit_Store != 1 ? ',请切换门店' : ''));
  557. }
  558. } else {
  559. var timestamp = Date.parse(new Date());
  560. if (!res.isBusiness) {
  561. if (this.Is_Store_Price_Stock == 1) {
  562. this.isBusiness = false;
  563. return req.msg('该门店暂未营业' + (this.User_Limit_Store != 1 ? ',因各门店价格不同,请重新下单' :
  564. ''));
  565. } else {
  566. return req.msg('该门店暂未营业' + (this.User_Limit_Store != 1 ? ',请切换门店' : ''));
  567. }
  568. } else {
  569. if (!res.isGoods && res.type != 5) {
  570. if (this.Is_Store_Price_Stock == 1) {
  571. this.isBusiness = false;
  572. return req.msg('该门店暂不发货' + (this.User_Limit_Store != 1 ?
  573. ',因各门店价格不同,请重新下单' : ''));
  574. } else {
  575. return req.msg('该门店暂不发货' + (this.User_Limit_Store != 1 ? ',请切换门店' : ''));
  576. }
  577. }
  578. if (res.type == 5 && !res.isDistance) {
  579. if (this.Is_Store_Price_Stock == 1) {
  580. this.isBusiness = false;
  581. return req.msg('该门店暂不发货' + (this.User_Limit_Store != 1 ?
  582. ',因各门店价格不同,请重新下单' : ''));
  583. } else {
  584. return req.msg('该门店暂不发货' + (this.User_Limit_Store != 1 ? ',请切换门店' : ''));
  585. }
  586. }
  587. if (res.isDefault == 1 && this.query.orderType != '2') {
  588. // this.setData({ isZiti: false, youji: true })
  589. } else if (res.type == 5) {
  590. res.time = timestamp + 60 * 60 * 1000;
  591. res.merchantDTO.time = timestamp + 60 * 60 * 1000;
  592. req.setStorage('smallShop', res);
  593. req.setStorage('MERCHANT', res.merchantDTO);
  594. req.getRequest(
  595. '/api/params/value', {
  596. type: 'shop_config'
  597. },
  598. res => {
  599. // JSON.parse(res)
  600. // console.log(res)
  601. if (!res || !res.deliverWay) {
  602. this.setData({
  603. isZiti: true,
  604. ziti: true
  605. });
  606. } else {
  607. let deliver_way = res.deliverWay;
  608. if (deliver_way.length >= 2) {
  609. if ((deliver_way[0] == '2' && deliver_way[1] == '3') || (
  610. deliver_way[0] == '3' && deliver_way[1] == '2')) {
  611. this.setData({
  612. isZiti: false,
  613. youji: true
  614. });
  615. }
  616. } else if (deliver_way.length == 1) {
  617. deliver_way.forEach(it => {
  618. if (it == 1) {
  619. this.setData({
  620. isZiti: true,
  621. ziti: true
  622. });
  623. }
  624. if (it == 2 || it == 3) {
  625. this.setData({
  626. isZiti: false,
  627. youji: true
  628. });
  629. }
  630. });
  631. }
  632. this.setData({
  633. deliver_way: res.deliverWay
  634. });
  635. }
  636. }
  637. );
  638. } else {
  639. // this.setData({ isZiti: true })
  640. res.time = timestamp + 60 * 60 * 1000;
  641. req.setStorage('MERCHANT', res);
  642. req.removeStorage('smallShop');
  643. }
  644. this.setData({
  645. merchant: res
  646. });
  647. }
  648. }
  649. });
  650. }
  651. },
  652. selZiti() {
  653. if (this.isZiti == false && this.isGys) {
  654. req.msg('您选择的部分商品,不提供自提服务');
  655. return false;
  656. }
  657. if (this.isZiti == false && this.merchant.isGoods == 0) {
  658. req.msg('该门店,不提供自提服务');
  659. return false;
  660. }
  661. this.setData({
  662. isZiti: !this.isZiti
  663. });
  664. this.CalculationMoney();
  665. if (this.isZiti == true && this.isJs) {
  666. req.msg('您选择的是门店自提,不享受及时达服务');
  667. }
  668. },
  669. // 选择余额
  670. balanceShow() {
  671. this.setData({
  672. isBalanceShow: false
  673. });
  674. },
  675. closeBalance() {
  676. this.setData({
  677. isBalanceShow: true
  678. });
  679. this.CalculationMoney();
  680. },
  681. checkedFun() {
  682. this.setData({
  683. checked: !this.checked,
  684. kychecked: false
  685. });
  686. },
  687. checkedFunKy() {
  688. this.setData({
  689. checked: false,
  690. kychecked: !this.kychecked
  691. });
  692. },
  693. balanceConfirm() {
  694. this.setData({
  695. isBalanceShow: true
  696. });
  697. this.CalculationMoney();
  698. },
  699. getConfig() {
  700. var _this = this;
  701. return new Promise((resolve, reject) => {
  702. req.getRequest('/api/config', {}, function(res) {
  703. if (res.is_open_wallet) {
  704. let is_open_wallet = JSON.parse(res.is_open_wallet);
  705. _this.is_open_wallet = is_open_wallet;
  706. _this.setData({
  707. is_open_wallet: is_open_wallet
  708. });
  709. }
  710. _this.setData({
  711. // fee: res.Express_Fee, //zxb 12.20日屏蔽,调用邮费模板
  712. // free: res.Free_Shipping,//zxb 12.20日屏蔽,调用邮费模板
  713. onlyPeisong: res.is_customer_pick_up == 1 ? true : false,
  714. isOfflinePayment: res.is_open_OfflinePayment == 1 ? true : false,
  715. Is_Store_Price_Stock: res.Is_Store_Price_Stock,
  716. is_open_shop: res.is_open_shop,
  717. User_Limit_Store: res.User_Limit_Store,
  718. about: res
  719. });
  720. resolve();
  721. });
  722. });
  723. },
  724. checkMap() {
  725. let url = 'product/map/map';
  726. app.globalData.openPage(url);
  727. },
  728. updateShop() {
  729. if (!req.getStorage('user_merchantId')) {
  730. if (!this.isBusiness) {} else {
  731. if (this.Is_Store_Price_Stock == 1 && this.merchant.id && !this.query.activityId) {
  732. uni.navigateTo({
  733. url: '/pages/nearbyDetails/nearbyDetails?id=' + this.merchant.id
  734. });
  735. } else {
  736. let url = 'merchant/nearby/nearby?isChoose=true';
  737. app.globalData.openPage(url);
  738. }
  739. }
  740. }
  741. },
  742. checkRequire(formItemList) {
  743. //判断虚拟产品productForm 1、实物、2服务 3虚拟物
  744. for (var i = 0; i < formItemList.length; i++) {
  745. if (formItemList[i].productForm == 1 || formItemList[i].productForm == 2) {
  746. return false;
  747. }
  748. }
  749. return true;
  750. },
  751. getList() {
  752. let that = this;
  753. req.getRequest(
  754. '/api/purchase/list', {
  755. ids: this.ids // merchantId: this.data.merchant.id
  756. },
  757. data => {
  758. if (!data || data.length == 0) return req.msg('数据不存在');
  759. data = data.map(it => {
  760. if (it.deliverWay && JSON.parse(it.deliverWay).indexOf(3) != -1) it.isJs = true;
  761. return it;
  762. });
  763. that.isFictitious = that.checkRequire(data);
  764. console.log('数据isFictitious====', that.isFictitious);
  765. that.setData({
  766. pageList: data
  767. });
  768. this.getFreightMoney();
  769. this.pageList.forEach(res => {
  770. if (res.isOtc == '1') {
  771. this.setData({
  772. isRx: false
  773. });
  774. }
  775. if (res.isOtc == '5') {
  776. if (!this.activityId && that.query.orderType != 20) {
  777. this.setData({
  778. orderType: 10,
  779. youji: true,
  780. isZiti: false
  781. });
  782. } else {
  783. this.youji = true;
  784. this.isZiti = false;
  785. this.isHwg = true;
  786. }
  787. }
  788. if (res.isTimely == '2') {
  789. this.setData({
  790. isGys: true
  791. });
  792. }
  793. if (JSON.parse(res.deliverWay) && res.isOtc != '5' && that.query.orderType != 2) {
  794. // 判断有发货方式有几种
  795. let deliverWay = JSON.parse(res.deliverWay).find((value, index, arr) => {
  796. return value >= 2;
  797. });
  798. // 发货方式大于2,并且没有1 就是只有邮寄
  799. if (deliverWay && JSON.parse(res.deliverWay).indexOf(1) == -1) {
  800. that.setData({
  801. youji: true,
  802. isZiti: false
  803. });
  804. }
  805. // 发货方式只有1中,并且是1 就是只有自提
  806. if (JSON.parse(res.deliverWay).indexOf(1) != -1 && JSON.parse(res.deliverWay)
  807. .length == 1) {
  808. that.setData({
  809. ziti: true,
  810. isZiti: true
  811. });
  812. }
  813. // 发货方式中有3,或者4 并且不是社区团购订单,并且没有活动id 就是极速达
  814. if ((JSON.parse(res.deliverWay).indexOf(3) != -1 || JSON.parse(res.deliverWay)
  815. .indexOf(4) != -1) && this.orderType != 2) {
  816. that.setData({
  817. isJs: true
  818. // orderType: 5
  819. });
  820. if (JSON.parse(res.deliverWay).indexOf(2) == -1 && JSON.parse(res
  821. .deliverWay).indexOf(1) == -1) {
  822. that.setData({
  823. onelyJsd: true
  824. });
  825. }
  826. if (JSON.parse(res.deliverWay).indexOf(2) != -1) {
  827. that.setData({
  828. Jsdyouji: true
  829. });
  830. }
  831. if (JSON.parse(res.deliverWay).indexOf(1) != -1) {
  832. that.setData({
  833. Jsdziti: true
  834. });
  835. }
  836. }
  837. }
  838. });
  839. if (!that.pageList[0].activityType) {
  840. that.loadCoupon();
  841. }
  842. that.CalculationMoney(); // let count = 0;
  843. this.isShowView = true;
  844. }
  845. );
  846. },
  847. adjustmentQuantity(id, quantity, skuId, success) {
  848. req.postRequest(
  849. '/api/purchase/quantity', {
  850. id: id,
  851. skuId: skuId,
  852. quantity: quantity
  853. },
  854. () => {
  855. success.call(this);
  856. }
  857. );
  858. },
  859. jianQuantity(event) {
  860. const index = event.currentTarget.dataset.index;
  861. const page = this.pageList[index];
  862. if (page.quantity <= 1) return false;
  863. const q = page.quantity - 1;
  864. let that = this;
  865. this.adjustmentQuantity(page.id, q, page.skuId, () => {
  866. let d = {};
  867. d['pageList[' + index + '].quantity'] = q;
  868. that.setData(d);
  869. that.CalculationMoney();
  870. });
  871. },
  872. jiaQuantity(event) {
  873. const index = event.currentTarget.dataset.index;
  874. const page = this.pageList[index];
  875. const q = page.quantity + 1;
  876. let that = this;
  877. this.adjustmentQuantity(page.id, q, page.skuId, () => {
  878. let d = {};
  879. d['pageList[' + index + '].quantity'] = q;
  880. that.setData(d);
  881. that.CalculationMoney();
  882. });
  883. },
  884. //调用接口获取邮费
  885. getFreightMoney() {
  886. if (this.pageList && this.pageList.length > 0 && this.address && this.address.id) {
  887. this.feeMoney = '';
  888. this.CalculationMoney();
  889. req.getRequest(
  890. '/api/purchase/freight', {
  891. ids: this.pageList.map(it => it.id).join(','), //购物车id
  892. addressId: this.address.id //收货地址ID
  893. },
  894. res => {
  895. console.log('快递运费>>>>=====' + res);
  896. this.feeMoney = res;
  897. this.CalculationMoney();
  898. }
  899. );
  900. }
  901. },
  902. CalculationM() {
  903. //计算商品总价格
  904. const counts = this.pageList.length;
  905. let count = 0;
  906. let money = 0;
  907. let integral = 0;
  908. if (counts > 0) {
  909. this.pageList.forEach(lst => {
  910. count += lst.quantity;
  911. money += lst.quantity * lst.price;
  912. integral += lst.integral * lst.quantity;
  913. });
  914. }
  915. let payMoney = 0;
  916. if (this.isZiti) {
  917. payMoney = money;
  918. this.setData({
  919. feeMoney: '0'
  920. });
  921. } else {
  922. money = parseFloat(money).toFixed(2);
  923. // zxb 12.20屏蔽 使用了运费模板,故老的逻辑屏蔽
  924. // let fee = 0;
  925. // if (this.free > 0) fee = Number(money) - Number(this.free);
  926. // else fee = Number(money);
  927. // this.setData({
  928. // feeMoney: fee >= 0 ? 0 : this.fee
  929. // });
  930. if (this.feeMoney > 0) payMoney = Number(money) + Number(this.feeMoney);
  931. else payMoney = Number(money);
  932. }
  933. //获取优惠券价格
  934. if (this.couponList.length > 0 && this.couponter.length > 0) {
  935. const coupon = this.couponList[this.couponIndex];
  936. if (coupon == undefined) {
  937. (payMoney = payMoney),
  938. this.setData({
  939. coupon: false
  940. });
  941. } else {
  942. if (payMoney >= coupon.couponFull) {
  943. (payMoney = payMoney - parseFloat(coupon.couponAmount)),
  944. this.setData({
  945. coupon: true
  946. });
  947. } else {
  948. payMoney = payMoney;
  949. this.coupon = false;
  950. }
  951. }
  952. }
  953. this.setData({
  954. count: count,
  955. money: parseFloat(money).toFixed(2),
  956. // payMoney: parseFloat(payMoney).toFixed(2),
  957. integral: integral
  958. });
  959. return payMoney;
  960. },
  961. CalculationMoney() {
  962. let _ts = this;
  963. let payMoney = _ts.CalculationM();
  964. //获取余额
  965. if (_ts.checked) {
  966. if (_ts.userMoney > 0) {
  967. const coupon = _ts.userMoney;
  968. if (payMoney >= coupon) {
  969. (payMoney = payMoney - parseFloat(coupon)),
  970. _ts.setData({
  971. balance: true,
  972. balanceMoney: coupon
  973. });
  974. } else {
  975. if (payMoney <= 0) {
  976. _ts.setData({
  977. balance: true,
  978. balanceMoney: '0'
  979. });
  980. } else {
  981. let balanceMoney = parseFloat(parseFloat(coupon) + (payMoney - parseFloat(coupon)))
  982. .toFixed(2);
  983. payMoney = payMoney - parseFloat(parseFloat(coupon) + (payMoney - parseFloat(coupon)))
  984. .toFixed(2);
  985. _ts.setData({
  986. balance: true,
  987. balanceMoney: balanceMoney
  988. });
  989. }
  990. } // payMoney = payMoney - parseFloat(coupon), this.setData({ balance: true })
  991. } else {
  992. (payMoney = payMoney),
  993. _ts.setData({
  994. balance: false,
  995. balanceMoney: 0
  996. });
  997. }
  998. }
  999. if (_ts.kychecked) {
  1000. //获取线下余额
  1001. if (_ts.kybalance > 0) {
  1002. const coupon = _ts.kybalance;
  1003. if (payMoney >= coupon) {
  1004. (payMoney = payMoney - parseFloat(coupon)),
  1005. _ts.setData({
  1006. kybalances: true,
  1007. kybalanceMoney: coupon
  1008. });
  1009. } else {
  1010. if (payMoney <= 0) {
  1011. _ts.setData({
  1012. kybalances: true,
  1013. kybalanceMoney: '0'
  1014. });
  1015. } else {
  1016. let kybalanceMoney = parseFloat(parseFloat(coupon) + (payMoney - parseFloat(coupon)))
  1017. .toFixed(2);
  1018. payMoney = payMoney - parseFloat(parseFloat(coupon) + (payMoney - parseFloat(coupon)))
  1019. .toFixed(2);
  1020. _ts.setData({
  1021. kybalances: true,
  1022. kybalanceMoney: kybalanceMoney
  1023. });
  1024. }
  1025. } // payMoney = payMoney - parseFloat(coupon), this.setData({ balance: true })
  1026. } else {
  1027. (payMoney = payMoney),
  1028. _ts.setData({
  1029. kybalances: false,
  1030. kybalanceMoney: 0
  1031. });
  1032. }
  1033. }
  1034. _ts.setData({
  1035. payMoney: parseFloat(payMoney).toFixed(2)
  1036. });
  1037. },
  1038. noteInput(event) {
  1039. this.note = event.detail.value;
  1040. },
  1041. // 选择余额
  1042. radioChange(e) {
  1043. // console.log('radio发生change事件,携带value值为:', e.detail.value);
  1044. },
  1045. // 选择线下支付
  1046. radioChangeKy(e) {
  1047. // console.log('radio发生change事件,携带value值为:', e.detail.value);
  1048. },
  1049. async loadCoupon() {
  1050. let _ts = this;
  1051. req.getRequest(
  1052. '/api/v3/coupon/use', {
  1053. ids: _ts.ids
  1054. },
  1055. data => {
  1056. _ts.couponter = data;
  1057. if (data && data.length > 0) {
  1058. let coupon = data.filter(it => {
  1059. return it.isUse;
  1060. });
  1061. console.log('coupon', coupon);
  1062. _ts.setData({
  1063. couponList: coupon
  1064. });
  1065. }
  1066. if (data && data.length > 0) _ts.CalculationMoney();
  1067. }
  1068. );
  1069. },
  1070. async loadCoupons() {
  1071. let _ts = this;
  1072. req.getRequest(
  1073. '/api/coupon/user', {
  1074. page: 1,
  1075. limit: 100,
  1076. couponState: 1
  1077. },
  1078. res => {
  1079. let contunt = res;
  1080. if (_ts.query.activityId || _ts.query.aprId || _ts.query.orderType == 11) return false;
  1081. req.getRequest(
  1082. '/api/coupon/use', {
  1083. ids: _ts.ids
  1084. },
  1085. data => {
  1086. _ts.couponter = data;
  1087. let couponObj = [];
  1088. contunt.forEach((it, index) => {
  1089. data.forEach(el => {
  1090. if (it.id == el.id) {
  1091. it.acitve = true;
  1092. }
  1093. });
  1094. });
  1095. var objectArraySort = function(keyName) {
  1096. return function(objectN, objectM) {
  1097. var valueN = objectN[keyName];
  1098. var valueM = objectM[keyName];
  1099. if (valueN < valueM) return 1;
  1100. else if (valueN > valueM) return -1;
  1101. else return 0;
  1102. };
  1103. };
  1104. contunt.sort(objectArraySort('couponAmount'));
  1105. contunt.forEach((it, index) => {
  1106. if (it.acitve && couponObj.length <= 0) {
  1107. _ts.couponIndex = index;
  1108. couponObj.push(index);
  1109. }
  1110. });
  1111. _ts.setData({
  1112. couponList: contunt
  1113. });
  1114. if (data.length > 0) _ts.CalculationMoney();
  1115. }
  1116. );
  1117. }
  1118. );
  1119. },
  1120. getUserAddress() {
  1121. req.g('/api/address/get/default', data => {
  1122. this.setData({
  1123. address: data
  1124. });
  1125. this.getFreightMoney();
  1126. });
  1127. },
  1128. addOrUpdateAddress() {
  1129. let url = 'mine/addAddress/addAddress?isChoose=true&orderType=' + this.orderType;
  1130. if (this.address && this.address.id) {
  1131. url = 'mine/address/address?isChoose=true&orderType=' + this.orderType + '&addressId=' + this.address
  1132. .id;
  1133. }
  1134. app.globalData.openPage(url);
  1135. },
  1136. getMy() {
  1137. let that = this;
  1138. req.getRequest('/api/user/my', {}, data => {
  1139. that.setData({
  1140. userInfo: req.getStorage('userInfo'),
  1141. // realName: req.getStorage('userInfo').realName,
  1142. phone: data.mobile
  1143. });
  1144. let _userinfo = req.getStorage('userInfo');
  1145. if (_userinfo.mobile) {
  1146. this.setData({
  1147. show: true
  1148. });
  1149. }
  1150. _userinfo.mobile = data.mobile;
  1151. req.setStorage('userInfo', _userinfo);
  1152. });
  1153. },
  1154. getphonenumber(event) {
  1155. const detail = event.detail;
  1156. const _ts = this;
  1157. if (!detail || !detail.encryptedData || !detail.iv) return false;
  1158. req.postRequest(
  1159. '/api/weixin/mobile', {
  1160. encryptedData: detail.encryptedData,
  1161. iv: detail.iv,
  1162. sessionKey: _ts.sessionKey
  1163. },
  1164. res => {
  1165. _ts.setData({
  1166. phone: res.mobile,
  1167. show: true
  1168. });
  1169. let userInfo = req.getStorage('userInfo');
  1170. userInfo.mobile = res.mobile;
  1171. req.setStorage('userInfo', userInfo);
  1172. _ts.getMy();
  1173. }
  1174. );
  1175. },
  1176. payOrder(res) {
  1177. // this.setData({ btn: 1 })
  1178. req.payOrder(res, success => {
  1179. this.payJumpSuc(success);
  1180. });
  1181. },
  1182. payJumpSuc(success) {
  1183. if (success) {
  1184. //支付成功
  1185. if (!this.isRx) {
  1186. h5util.jumpUrlExternal({url:'/product/pay/pay?isSuccess=true&&orderId=' + this.orderId + '&isRx=1',type:'redirectTo'})
  1187. // app.globalData.redirectTab('product/pay/pay?isSuccess=true&&orderId=' + this.orderId + '&isRx=1');
  1188. } else if (this.orderType == 4) {
  1189. //拼团订单,
  1190. if (this.pay == 1) {
  1191. uni.navigateBack();
  1192. } else {
  1193. h5util.jumpUrlExternal({url:'/activity/group/ptDetail/ptDetail?acid=' + this.activityId +
  1194. '&id=' + this.aprId + '&merchantId=' + this.query.merchantId,type:'redirectTo'})
  1195. //支付成功之后跳入到拼团页面
  1196. // app.globalData.redirectTab('activity/group/ptDetail/ptDetail?acid=' + this.activityId +
  1197. // '&id=' + this.aprId + '&merchantId=' + this.query.merchantId);
  1198. }
  1199. } else {
  1200. h5util.jumpUrlExternal({url:'/product/pay/pay?isSuccess=true',type:'redirectTo'})
  1201. // app.globalData.redirectTab('product/pay/pay?isSuccess=true');
  1202. }
  1203. this.orderId = '';
  1204. } else {
  1205. h5util.jumpUrlExternal({url:'/product/pay/pay?money=' + this.money + '&id=' + res,type:'redirectTo'})
  1206. // app.globalData.redirectTab('product/pay/pay?money=' + this.money + '&id=' + res);
  1207. }
  1208. },
  1209. tab: util.throttle(async function() {
  1210. let _ts = this;
  1211. let mode = this.isZiti ? 1 : 2;
  1212. if (!this.isZiti && this.isJs) {
  1213. mode = 3;
  1214. }
  1215. // #ifdef MP-WEIXIN
  1216. if (!this.isFictitious) {
  1217. if (!this.isRx) {
  1218. await requsetmessage.recipel(mode).then(res => {});
  1219. } else if (mode == 1) {
  1220. await requsetmessage.selfRaising().then(res => {
  1221. // console.log("自提", res);
  1222. });
  1223. } else if (mode == 2) {
  1224. await requsetmessage.distribution().then(res => {
  1225. // console.log("配送", res);
  1226. });
  1227. } else {
  1228. await requsetmessage.jisda().then(res => {});
  1229. }
  1230. }
  1231. // #endif
  1232. this.createOrder();
  1233. }, 3000),
  1234. async createOrder() {
  1235. let _ts = this;
  1236. await this.submitOrder(data => {
  1237. if (_ts.orderId) {
  1238. // _ts.payOrder(_ts.orderId);
  1239. h5util.jumpPay({
  1240. orderId:_ts.orderId,
  1241. isRx:_ts.isRx,
  1242. pay:_ts.pay,
  1243. activityId:_ts.activityId,
  1244. aprId:_ts.aprId,
  1245. merchantId:_ts.query.merchantId,
  1246. money:_ts.money,
  1247. orderType:_ts.orderType
  1248. })
  1249. return false;
  1250. }
  1251. let isShowLoading = false;
  1252. if (!isShowLoading) {
  1253. req.loadIng('加载中');
  1254. isShowLoading = true;
  1255. }
  1256. req.postRequest('/api/order/save', data, res => {
  1257. _ts.orderId = res;
  1258. // _ts.payOrder(_ts.orderId);
  1259. h5util.jumpPay({
  1260. orderId:_ts.orderId,
  1261. isRx:_ts.isRx,
  1262. pay:_ts.pay,
  1263. activityId:_ts.activityId,
  1264. aprId:_ts.aprId,
  1265. merchantId:_ts.query.merchantId,
  1266. money:_ts.money,
  1267. orderType:_ts.orderType
  1268. })
  1269. if (isShowLoading) {
  1270. uni.hideLoading();
  1271. isShowLoading = false;
  1272. }
  1273. });
  1274. });
  1275. },
  1276. // 获取身份证号
  1277. getcardNo(e) {
  1278. this.setData({
  1279. cardNo: e.detail.value
  1280. });
  1281. },
  1282. // 获取购买人姓名
  1283. gethwgName(e) {
  1284. this.setData({
  1285. hwgName: e.detail.value
  1286. });
  1287. },
  1288. //获取用户输入的名字 改动
  1289. getusername(event) {
  1290. // console.log(event.detail.value)
  1291. this.setData({
  1292. realName: req.excludeSpecial(event.detail.value)
  1293. });
  1294. },
  1295. //获取用户输入的电话 改动
  1296. getphone(event) {
  1297. this.setData({
  1298. phone: event.detail.value
  1299. });
  1300. },
  1301. // 选择送达时间
  1302. serviceTime() {
  1303. this.setData({
  1304. isTimeShow: false
  1305. });
  1306. },
  1307. closeTime() {
  1308. this.setData({
  1309. isTimeShow: true,
  1310. isMoreTimeShow: true
  1311. });
  1312. },
  1313. moreDate() {
  1314. this.setData({
  1315. isMoreTimeShow: false
  1316. });
  1317. },
  1318. closeMoreTime() {
  1319. this.setData({
  1320. isMoreTimeShow: true
  1321. });
  1322. },
  1323. //处理未来七天的函数
  1324. dealTime: function(num) {
  1325. // num:未来天数
  1326. var time = new Date(); // 获取当前时间日期
  1327. var date = new Date(time.setDate(time.getDate() + num)).getDate(); //这里先获取日期,在按需求设置日期,最后获取需要的
  1328. var year = time.getFullYear(); // 获取年份
  1329. var month = time.getMonth() + 1; // 获取月份
  1330. var day = time.getDay(); // 获取星期
  1331. switch (day) {
  1332. // 格式化
  1333. case 0:
  1334. day = '(周日)';
  1335. break;
  1336. case 1:
  1337. day = '(周一)';
  1338. break;
  1339. case 2:
  1340. day = '(周二)';
  1341. break;
  1342. case 3:
  1343. day = '(周三)';
  1344. break;
  1345. case 4:
  1346. day = '(周四)';
  1347. break;
  1348. case 5:
  1349. day = '(周五)';
  1350. break;
  1351. case 6:
  1352. day = '(周六)';
  1353. break;
  1354. }
  1355. var obj = {
  1356. date: date,
  1357. year: year,
  1358. day: day,
  1359. month: month,
  1360. newday: month + '-' + date
  1361. };
  1362. return obj; // 返回对象
  1363. },
  1364. dateDay(event) {
  1365. //选择送达日期
  1366. let index = event.currentTarget.dataset.index;
  1367. let aWeek = this.aWeek[index];
  1368. if (index == 7) return false;
  1369. this.sendDate = aWeek.newday;
  1370. this.setData({
  1371. dateIndex: index,
  1372. timeList: aWeek.timeList
  1373. });
  1374. },
  1375. dataTime(event) {
  1376. //选择送达时间
  1377. let index = event.currentTarget.dataset.index;
  1378. let sendTime = this.timeList[index];
  1379. this.sendTime = sendTime;
  1380. this.setData({
  1381. timeIndex: index
  1382. });
  1383. },
  1384. timeConfirm() {
  1385. //确定送达时间
  1386. if (!this.sendDate) {
  1387. this.sendDate = this.aWeek[0].newday;
  1388. }
  1389. if (!this.sendTime) {
  1390. this.sendTime = this.aWeek[0].timeList[0];
  1391. }
  1392. this.setData({
  1393. isTimeShow: true,
  1394. isMoreTimeShow: true,
  1395. sendTimes: this.sendDate + ' ' + this.sendTime
  1396. });
  1397. },
  1398. bindChange(e) {
  1399. //更多时间确定
  1400. const val = e.detail.value;
  1401. let aWeek = this.aWeek[val[0]];
  1402. this.setData({
  1403. timeList: aWeek.timeList
  1404. });
  1405. this.sendDate = this.aWeek[val[0]].newday;
  1406. this.sendTime = this.timeList[val[1]];
  1407. },
  1408. // 用户积分余额查询
  1409. getUserintegral() {
  1410. req.getRequest('/api/integral/returnIntegral', {}, data => {
  1411. this.setData({
  1412. userIntegral: data
  1413. });
  1414. });
  1415. },
  1416. //
  1417. submitOrder(success) {
  1418. let that = this;
  1419. let mode = this.isZiti ? 1 : 2;
  1420. if (!this.isZiti && this.isJs) {
  1421. mode = 3;
  1422. this.noshow = true;
  1423. }
  1424. if (
  1425. this.orderType != 2 &&
  1426. this.orderType != 3 &&
  1427. this.orderType != 4 &&
  1428. this.orderType != 6 &&
  1429. this.orderType != 7 &&
  1430. this.orderType != 10 &&
  1431. this.orderType != 11 &&
  1432. this.query.orderType != 20
  1433. ) {
  1434. if (this.isZiti && this.isJs) {
  1435. this.setData({
  1436. orderType: 1
  1437. });
  1438. }
  1439. if (!this.isJs) {
  1440. this.setData({
  1441. orderType: 1
  1442. });
  1443. }
  1444. }
  1445. let pidCode = req.getStorage('pidCode');
  1446. let data = {
  1447. ids: this.pageList.map(it => it.id).join(','),
  1448. mode: mode,
  1449. orderType: this.orderType,
  1450. node: this.note,
  1451. phone: this.phone,
  1452. userName: req.excludeSpecial(this.realName),
  1453. version: '2',
  1454. scene: req.getStorage('scene')
  1455. };
  1456. if (this.is_open_wallet && this.is_open_wallet.isOpenWallet == 1 && this.checked) {
  1457. //this.balance
  1458. data.balancePayMoney = this.balanceMoney;
  1459. }
  1460. if (this.kychecked) {
  1461. //线下余额支付
  1462. data.offlinePaymentMoney = this.kybalanceMoney;
  1463. }
  1464. if (this.merchant && this.merchant.type == 5) {
  1465. data.shopId = this.merchant.id;
  1466. data.merchantId = this.merchant.merchantDTO.id;
  1467. } else {
  1468. data.merchantId = this.merchant.id;
  1469. }
  1470. if (this.orderType == 11) {
  1471. data.integral = this.integral;
  1472. if (this.integral > this.userIntegral) return req.msg('您的积分余额为' + this.userIntegral + ',不足以购买该产品');
  1473. }
  1474. if (this.activityId) {
  1475. data.activityId = this.activityId;
  1476. }
  1477. if (!this.isRx) {
  1478. data.is_oct = 1;
  1479. }
  1480. if (data.mode == 3) {
  1481. data.jsonDate = this.sendTimes;
  1482. }
  1483. if (this.orderType == 10 || this.isHwg) {
  1484. data.idcard = this.cardNo;
  1485. data.userName = this.hwgName;
  1486. }
  1487. if (this.orderType == 4 || this.orderType == 7) {
  1488. data.aprId = this.aprId;
  1489. } // 获取推荐人
  1490. if (pidCode && req.getStorage('userInfo').id != pidCode) {
  1491. data.pid = pidCode;
  1492. }
  1493. this.setData({
  1494. phone: data.phone,
  1495. realName: req.excludeSpecial(data.userName)
  1496. }); //添加电话正则
  1497. let myreg = /^1[3456789]\d{9}$/; // 真实姓名正则
  1498. let reg = /^[\u4E00-\u9FA5A-Za-z0-9]{1,20}$/; // 海外购真实姓名正则
  1499. let hwgreg = /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/; // 身份证正则
  1500. 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]$/;
  1501. if (this.couponList && this.couponList.length > 0 && this.couponter.length > 0) {
  1502. if (this.coupon) data.couponId = this.couponList[this.couponIndex].id;
  1503. }
  1504. // 获取营业时间
  1505. var time = [];
  1506. var start;
  1507. var end;
  1508. var current;
  1509. if (this.merchant && mode != 2) {
  1510. if (this.merchant.businessTime) {
  1511. time = this.merchant.businessTime.split('-');
  1512. if (time.length == 2) {
  1513. this.overTime = true;
  1514. var myDate = new Date();
  1515. var hours = myDate.getHours(); //获取当前小时
  1516. var minutes = myDate.getMinutes(); //获取当前分钟
  1517. var timeState;
  1518. var timeEnd;
  1519. if (time[0].indexOf(':') != '-1') {
  1520. timeState = time[0].split(':');
  1521. }
  1522. if (time[1].indexOf(':') != '-1') {
  1523. timeEnd = time[1].split(':');
  1524. }
  1525. if (time[0].indexOf(':') != '-1') {
  1526. timeState = time[0].split(':');
  1527. }
  1528. if (time[1].indexOf(':') != '-1') {
  1529. timeEnd = time[1].split(':');
  1530. }
  1531. start = +timeState[0] * (60000 * 60) + +timeState[1] * 60000; //营业开始时间转毫秒
  1532. end = +timeEnd[0] * (60000 * 60) + +timeEnd[1] * 60000; //营业结束时间转毫秒
  1533. current = +hours * (60000 * 60) + +minutes * 60000; //当前时间转毫秒
  1534. }
  1535. }
  1536. }
  1537. if (this.isFictitious) {
  1538. success.call(this, data);
  1539. } else {
  1540. if (this.isZiti) {
  1541. //自提
  1542. //*******************************
  1543. if (!data.merchantId) return req.msg('请选择提货门店');
  1544. if (!this.realName || !this.phone) return req.msg('请填写提货人和提货电话'); //判断电话是否正确
  1545. if (!myreg.test(this.phone)) {
  1546. return req.msg('请填写正确的手机号码!');
  1547. } //判断名字是否正确
  1548. if (!reg.test(data.userName)) return req.msg('请输入正确提货人姓名');
  1549. data.addressId = this.merchant.id;
  1550. if (current < start) {
  1551. uni.showModal({
  1552. content: '本店暂末营业,请于' + this.merchant.businessTime + '期间提货!',
  1553. confirmText: '同意',
  1554. cancelText: '不同意',
  1555. success(res) {
  1556. if (res.confirm) {
  1557. success.call(that, data);
  1558. }
  1559. }
  1560. });
  1561. } else if (current > end) {
  1562. uni.showModal({
  1563. content: '本店已歇业,请于次日' + this.merchant.businessTime + '期间提货!',
  1564. confirmText: '同意',
  1565. cancelText: '不同意',
  1566. success(res) {
  1567. if (res.confirm) {
  1568. success.call(that, data);
  1569. }
  1570. }
  1571. });
  1572. } else {
  1573. success.call(this, data);
  1574. }
  1575. } else {
  1576. if (!data.merchantId) return req.msg('请选择发货门店');
  1577. if (!that.address || !that.address.id) return req.msg('请选择收货地址');
  1578. if (data.orderType == 10 || this.isHwg) {
  1579. if (data.userName == '' || data.userName == undefined || data.userName == null) {
  1580. return req.msg('请填写购买人');
  1581. } else {
  1582. if (!hwgreg.test(this.hwgName)) return req.msg('请输入正确真实姓名(至少2位汉字)');
  1583. }
  1584. if (data.idcard == '' || data.idcard == undefined || data.idcard == null) {
  1585. return req.msg('请填写身份证号码');
  1586. } else {
  1587. if (!sfz.test(data.idcard)) return req.msg('请输入正确的身份证');
  1588. }
  1589. }
  1590. let address = that.address;
  1591. data.addressId = address.id;
  1592. let merchant = this.merchant; //只有及时达的订单才需要校验地址范围
  1593. // if (this.data.orderType == 5) {
  1594. // if (data.jsonDate == "" || data.jsonDate == undefined) return req.msg("请选择送达时间")
  1595. // }
  1596. if (data.mode == 3) {
  1597. if (!address.lat || !address.lng) return req.msg('收货地址未解析,请重新选择收货地址');
  1598. let formAddress = {
  1599. latitude: merchant.lat,
  1600. longitude: merchant.lng
  1601. }; //判断用户收货地址是否在门店发货距离之内
  1602. QQMapWX.calculateDistance(
  1603. formAddress,
  1604. [{
  1605. latitude: address.lat,
  1606. longitude: address.lng
  1607. }],
  1608. res => {
  1609. //超出了订单范围,并且是及时达订单
  1610. if (res.elements[0].distance / 1000 > merchant.distance) {
  1611. // console.log("发货距离", res.elements[0].distance / 1000, "门店范围距离", merchant
  1612. // .distance); // return req.msg('非常抱歉,您的配送地址超出我们的配送服务范围');
  1613. let content = '';
  1614. if (!this.onelyJsd) {
  1615. if (this.Jsdyouji) {
  1616. content = '您的及时达订单超过了配送服务范围,是否同意转为邮寄发货?';
  1617. } else if (this.Jsdziti && !this.Jsdyouji) {
  1618. content = '您的及时达订单超过了配送服务范围,是否同意转为自提?';
  1619. }
  1620. } else {
  1621. content = '您的及时达订单超过了配送服务范围!暂不提供服务';
  1622. }
  1623. uni.showModal({
  1624. content: content,
  1625. confirmText: '同意',
  1626. success(res) {
  1627. if (res.confirm) {
  1628. if (that.Jsdyouji && !that.onelyJsd) {
  1629. // if(that.query.orderType==20){
  1630. // data.orderType = 20;
  1631. // }else{
  1632. // data.orderType = 1; //设置为普通订单
  1633. // }
  1634. data.mode = 2; //方式为邮寄
  1635. that.setData({
  1636. isJs: false
  1637. });
  1638. success.call(that, data);
  1639. } else if (that.Jsdziti && !that.Jsdyouji && !that
  1640. .onelyJsd && !that.onlyPeisong) {
  1641. // if(that.query.orderType==20){
  1642. // data.orderType = 20;
  1643. // }else{
  1644. // data.orderType = 1; //设置为普通订单
  1645. // }
  1646. data.mode = 1; //方式为自提
  1647. that.setData({
  1648. isJs: true,
  1649. isZiti: true
  1650. });
  1651. // success.call(that, data);
  1652. } else if (that.onelyJsd) {
  1653. return false;
  1654. }
  1655. } else if (res.cancel) {}
  1656. }
  1657. });
  1658. } else {
  1659. if (current < start) {
  1660. uni.showModal({
  1661. content: '对不起,工作人员末上班,您的订单将于' + time[0] + '后进行配送!',
  1662. confirmText: '同意',
  1663. cancelText: '不同意',
  1664. success(res) {
  1665. if (res.confirm) {
  1666. success.call(that, data);
  1667. } else if (res.cancel) {}
  1668. }
  1669. });
  1670. } else if (current > end) {
  1671. uni.showModal({
  1672. content: '本店已歇业,您的订单将于次日' + time[0] + '后进行配送!',
  1673. confirmText: '同意',
  1674. cancelText: '不同意',
  1675. success(res) {
  1676. if (res.confirm) {
  1677. success.call(that, data);
  1678. } else if (res.cancel) {}
  1679. }
  1680. });
  1681. } else {
  1682. success.call(that, data);
  1683. }
  1684. // success.call(this, data);
  1685. }
  1686. }
  1687. );
  1688. } else {
  1689. success.call(this, data);
  1690. }
  1691. }
  1692. }
  1693. }
  1694. }
  1695. };
  1696. </script>
  1697. <style>
  1698. @import './subOrder.css';
  1699. </style>