creatOrder.vue 70 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633
  1. <template>
  2. <view class="container" v-if="systemInfo!=null">
  3. <view class="head-bg" ></view>
  4. <view class="main">
  5. <!-- 微信展示 -->
  6. <view v-if="(systemInfo.is_hall==1||systemInfo.is_ziti==1) && systemInfo.is_waimai==1"
  7. class="formhead flex flex-y-center flex-x-between">
  8. <view class="formheadnav" :class="teen_index==1||teen_index==3?'selsect':'default'"
  9. @click="selectednavbar" data-index='1'>
  10. {{descFood.food1}}
  11. </view>
  12. <view class="formheadnav" :class="teen_index==2?'selsect':'default'" @click="selectednavbar"
  13. data-index='2'>
  14. {{descFood.food2}}
  15. </view>
  16. </view>
  17. <view class="formhdwm" v-if="teen_index==2"
  18. :class="((systemInfo.is_hall==1||systemInfo.is_ziti==1) && systemInfo.is_waimai==1)?'':'teen_radius'">
  19. <view class="weui-cells weui-cells_after-title">
  20. <button @click="getWechatAddress" class="weui-cell weui-cell_access wmaddress"
  21. hoverClass="weui-cell_active" style="border-bottom: 1rpx solid #f4f4f4;" v-if="address">
  22. <view class="weui-cell__bd">
  23. <view class="wmshr">
  24. <text style="margin-right: 10rpx;">{{address.user_name||'请选择收货地址'}} </text>
  25. <text v-if="address.sex=='1'">(先生)</text>
  26. <text v-if="address.sex=='2'">(女士)</text>
  27. <text style="margin-left: 10rpx;"> {{address.tel||''}}</text>
  28. </view>
  29. <view class="wmshdz">
  30. {{address.address||''}}
  31. </view>
  32. </view>
  33. <view class="weui-cell__ft weui-cell__ft_in-access"></view>
  34. </button>
  35. <button @click="getWechatAddress" class="weui-cell weui-cell_access wmaddress"
  36. hoverClass="weui-cell_active" style="border-bottom: 1rpx solid #f4f4f4;" v-else>
  37. <view class="weui-cell__bd">
  38. 请选择收货地址
  39. </view>
  40. <view class="weui-cell__ft weui-cell__ft_in-access"></view>
  41. </button>
  42. </view>
  43. </view>
  44. <view class="page-block" :class="systemInfo.is_waimai==1?'page-blocks':''">
  45. <view class="page-title flex flex-nowarp flex-y-center">
  46. <i class="iconfont icon-canyin icon-1" :style='{color:setColor}'></i>
  47. <view class="text-nowarp">{{systemInfo.title || ''}}
  48. <!-- <block v-if='teen_index==1 && systemInfo.table'>({{systemInfo.table || ''}})</block> -->
  49. </view>
  50. <!-- <view class="desc">下单商品</view> -->
  51. </view>
  52. <view class="goods-list" v-if="carInfo">
  53. <block v-for="(goods,idx) in carInfo.new_list" :key="idx">
  54. <view class="flex-y-center carInfoHeader" @click="chooseBag(goods.pocket)">
  55. <view class="radio__inner"
  56. :style="'border: 6rpx solid' + setColor">
  57. <view :style="'background:#fff'"
  58. class="radio__inner-icon radio__inner-icon is-default-checked">
  59. </view>
  60. </view>
  61. 购物口袋{{goods.pocket}}
  62. <block v-if="teen_index==2 && teen_index==3 && systemInfo.is_ziti==1 && goods.packing_fee">
  63. (包装费 <text style="color: red;">¥{{goods.packing_fee}}</text>)
  64. </block>
  65. </view>
  66. <block v-for="(item,index) of goods.list" :key="index">
  67. <view class="item flex flex-nowarp" v-if="index < 3 || (index>=3 && goods.showMore)">
  68. <image :src="getImgSrc(item.spec_image)" mode="aspectFill" class="img"></image>
  69. <view class="info flex flex-column">
  70. <view class="title">{{item.name}}</view>
  71. <view class="unit">{{item.spec}}</view>
  72. <view class="num">× {{item.num}}</view>
  73. </view>
  74. <view class="price">¥{{item.price}}</view>
  75. </view>
  76. </block>
  77. <view class="more-btn" v-if="goods.list.length > 3 && !goods.showMore" @click="onShowMore(idx)">显示更多</view>
  78. </block>
  79. <view class="total-block" v-if="teen_index==2">共 {{carInfo.carNum}}
  80. 件,小计:¥{{Number(carInfo.total_price)}}</view>
  81. <view class="total-block" v-else>共 {{carInfo.carNum}} 件,小计:¥{{carInfo.total_price}}</view>
  82. </view>
  83. </view>
  84. <!-- 餐桌 -->
  85. <!-- 就餐人数 -->
  86. <view class="page-block pay-type-clock" v-if="teen_index==1">
  87. <view v-if='teen_index==1 && systemInfo.table'>
  88. <view class="page-title flex flex-nowarp flex-y-center">
  89. <view class="flex-y-center">
  90. 下单位置
  91. </view>
  92. <view class="desc">{{systemInfo.table || ''}}</view>
  93. </view>
  94. </view>
  95. <block v-if="teen_index == 1 && eat_people>0">
  96. <view>
  97. <view class="page-title flex flex-nowarp flex-y-center">
  98. <view class="flex-y-center">
  99. 就餐人数
  100. </view>
  101. <view class="desc">{{eat_people}}人</view>
  102. </view>
  103. </view>
  104. <view>
  105. <view class="page-title flex flex-nowarp flex-y-center">
  106. <view class="flex-y-center">
  107. 费用
  108. </view>
  109. <view class="desc">¥{{totle_eat_people}}</view>
  110. </view>
  111. </view>
  112. </block>
  113. </view>
  114. <!-- 就餐人数end -->
  115. <view class="page-block pay-type-clock">
  116. <view v-if="systemInfo.pay_type == 1 && teen_index!=2">
  117. <view class="page-title flex flex-nowarp flex-y-center box-pack-between">
  118. <view class="flex-y-center" style="flex: 1;">
  119. {{descOrder.title}}
  120. </view>
  121. <view class="flex">
  122. <view v-if="systemInfo.is_hall==1" class="diningItem diningItem-act"
  123. :class="teen_index==1?'diningItem_act':''"
  124. :style="[teen_index==1?{color: setColor,borderColor:setColor}:'']"
  125. @click="bindDining(1)">
  126. {{descOrder.food1}}
  127. <text v-if="teen_index==1" :style="{color: setColor}"
  128. class="iconfont icon-youxiajiaogouxuan"></text>
  129. </view>
  130. <view v-if="systemInfo.is_ziti==1" class="diningItem"
  131. :class="teen_index==3?'diningItem_act':''"
  132. :style="[teen_index==3?{color: setColor,borderColor:setColor}:'']"
  133. @click="bindDining(3)">
  134. {{descOrder.food2}}
  135. <text v-if="teen_index==3" :style="{color: setColor}"
  136. class="iconfont icon-youxiajiaogouxuan"></text>
  137. </view>
  138. </view>
  139. </view>
  140. <block v-if="teen_index==3 && systemInfo.is_ziti==1">
  141. <view class="flex-y-center">
  142. <view class='flex-row flex-y-center border-bottom' style='padding: 0 24rpx;height: 100rpx;'>
  143. <view class='flex-grow-1' style='padding-left: 8rpx;border-right:2rpx solid #e3e3e3;'>
  144. <input @input='KeyName' placeholder='请输入自提人'></input>
  145. </view>
  146. <view class='flex-grow-1' style='margin-left:32rpx;'>
  147. <input @input='KeyMobile' type="number" maxlength="11"
  148. placeholder='请输入自提电话'></input>
  149. </view>
  150. </view>
  151. </view>
  152. <picker @change="bindPickerChange" :range="wmtimearray" :value="wmindex">
  153. <view class="weui-cell weui-cell_access" hoverClass="weui-cell_active">
  154. <view class="weui-cell__hd">
  155. <image src="../../static/wmtime.png"
  156. style="margin-right: 5px;vertical-align: middle;width:35rpx; height:35rpx;">
  157. </image>
  158. </view>
  159. <view class="weui-cell__bd">自提时间</view>
  160. <view class="weui-cell__ft weui-cell__ft_in-access" :style="{color:setColor}">
  161. <block>
  162. {{wmtimearray[wmindex]}}
  163. </block>
  164. </view>
  165. </view>
  166. </picker>
  167. <!-- 包装费 -->
  168. <view v-if="carInfo.box_fee>0">
  169. <view class="page-title flex flex-nowarp flex-y-center">
  170. <view class="flex-y-center">
  171. <image src="../../static/packing.png" style="width: 50rpx;" class="VIP2"></image>
  172. 包装费
  173. </view>
  174. <view class="desc">¥{{carInfo.box_fee}}</view>
  175. </view>
  176. </view>
  177. </block>
  178. </view>
  179. <block v-if="systemInfo.is_vip==1">
  180. <view v-if="menber_discount.name&&menber_discount.discount">
  181. <view class="page-title flex flex-nowarp flex-y-center">
  182. <view class="flex-y-center">
  183. <image src="../../static/VIP2.png" class="VIP2"></image>会员优惠
  184. </view>
  185. <view class="desc">{{menber_discount.name}}专享 <text class="red" style="font-size: 40rpx;">
  186. {{menber_discount.discount}} </text> 折优惠</view>
  187. </view>
  188. </view>
  189. </block>
  190. <block v-if="teen_index==2">
  191. <view>
  192. <view class="page-title flex flex-nowarp flex-y-center">
  193. <view class="flex-y-center">
  194. <image src="../../static/ps.png" style="width: 50rpx;" class="VIP2"></image>
  195. 配送费
  196. </view>
  197. <view class="desc">¥{{deliveryPrice}}</view>
  198. </view>
  199. </view>
  200. <view v-if="carInfo.box_fee>0">
  201. <view class="page-title flex flex-nowarp flex-y-center">
  202. <view class="flex-y-center">
  203. <image src="../../static/packing.png" style="width: 50rpx;" class="VIP2"></image>
  204. 包装费
  205. </view>
  206. <view class="desc">¥{{carInfo.box_fee}}</view>
  207. </view>
  208. </view>
  209. </block>
  210. <!-- <block v-if="systemInfo.set.change_table==1 && teen_index==1">
  211. <view @click="bindScan">
  212. <view class="page-title flex flex-nowarp flex-y-center">
  213. <view class="flex-y-center">
  214. <image src="../../static/saoyisao.png" style="width: 50rpx;" class="VIP2"></image>
  215. 扫码换桌
  216. </view>
  217. <view class="desc arr-r"></view>
  218. </view>
  219. </view>
  220. </block> -->
  221. <!-- <view v-if="teen_index==1" class="box-pack-between ft26 pd20"> <text>配送费</text> <text>¥{{deliveryPrice}}</text></view> -->
  222. <!--pay_type==1先付后吃, teen_index外卖没有先吃后付-->
  223. <block v-if="systemInfo.pay_type == 1||teen_index==2">
  224. <view class="page-title flex flex-nowarp flex-y-center">
  225. <view>支付方式</view>
  226. <view class="desc">在线支付</view>
  227. </view>
  228. <view class="content">
  229. <!-- #ifdef MP-ALIPAY -->
  230. <view class="cell flex flex-nowarp flex-y-center" @click="checkPay(2)">
  231. <image src="../../static/icon_8.png" mode="aspectFit" class="pay-type-icon"></image>
  232. <view class="title">支付宝支付</view>
  233. <i v-if="check_index==2" class="iconfont icon-lujing check-box"
  234. :style='{color:setColor}'></i>
  235. <view class="rund check-box" v-else :style='{color:setColor}'></view>
  236. </view>
  237. <!-- #endif -->
  238. <!-- #ifdef MP-WEIXIN -->
  239. <view class="cell flex flex-nowarp flex-y-center" @click="checkPay(1)">
  240. <image src="../../static/icon_7.png" mode="aspectFit" class="pay-type-icon"></image>
  241. <view class="title">微信支付</view>
  242. <i class="iconfont icon-lujing check-box" :style='{color:setColor}'
  243. v-if="check_index==1"></i>
  244. <view class="rund check-box" :style='{color:setColor}' v-else></view>
  245. </view>
  246. <!-- #endif -->
  247. <view v-if="systemInfo.set.is_charge == 1" class="cell flex flex-nowarp flex-y-center"
  248. @click="checkPay(4)">
  249. <image src="../../static/icon_cz.png" mode="aspectFit" class="pay-type-icon"></image>
  250. <view class="title">充值 <text
  251. style="font-size: 34rpx;color: red;">{{ Number(systemInfo.set.charge_num)*Number(total_price)}}</text>
  252. 免单</view>
  253. <i class="iconfont icon-lujing check-box" :style='{color:setColor}'
  254. v-if="check_index==4"></i>
  255. <view class="rund check-box" :style='{color:setColor}' v-else></view>
  256. </view>
  257. <view v-if="systemInfo.is_vip==1&&userInfo.mobile&&menber_discount.balance"
  258. class="cell flex flex-nowarp flex-y-center" @click="checkPay(3)">
  259. <image src="../../static/icon_6.png" mode="aspectFit" class="pay-type-icon"></image>
  260. <view class="title">余额支付(剩余余额:{{menber_discount.balance}})</view>
  261. <i class="iconfont icon-lujing check-box" :style='{color:setColor}'
  262. v-if="check_index==3"></i>
  263. <view class="rund check-box" :style='{color:setColor}' v-else></view>
  264. </view>
  265. <view style="padding-bottom: 20rpx;"
  266. v-if="systemInfo.is_vip==1 && userInfo.mobile && czList.length>0">
  267. <scroll-view scroll-x="true" style="white-space: nowrap;">
  268. <view class="pay-price pr" :class="index==paytype?'act':''"
  269. :style="index==paytype?'border-color:#fff;color:#fff;background-color:'+setColor:''"
  270. v-for='(item,index) of czList' :key="index" :data-id='item.id'
  271. :data-content='item.pay_price' @click="choice_pay(index)" :data-index='index'>
  272. <text class="maney">¥{{item.pay_price}}</text>
  273. <view class="maney_get" :style="index==paytype?'color:#fff;':''">赠送
  274. {{item.send_price}}
  275. </view>
  276. </view>
  277. </scroll-view>
  278. </view>
  279. </view>
  280. </block>
  281. </view>
  282. <view class="page-block pay-type-clock"
  283. v-if=" (systemInfo.pay_type==1||teen_index==2)">
  284. <view class="content">
  285. <navigator
  286. :url="`../use-coupon-list/use-coupon-list?total_price=${carInfo.total_price}&check_index=${check_index}&state=${teen_index}`"
  287. class="cell flex flex-nowarp flex-x-between flex-y-center">
  288. <view class="title">优惠劵</view>
  289. <view class="flex-y-center" v-if="coupon_id">
  290. <text style="color: red;">-¥{{coupon_price}}</text>
  291. <view class="weui-cell__ft weui-cell__ft_in-access"></view>
  292. </view>
  293. <view class="flex-y-center" v-else>
  294. <text style="color: red;">未使用优惠劵{{coupon_list.length}}张</text>
  295. <view class="weui-cell__ft weui-cell__ft_in-access"></view>
  296. </view>
  297. </navigator>
  298. </view>
  299. </view>
  300. <view class="page-block pay-type-clock">
  301. <view class="content">
  302. <view class="cell flex flex-nowarp flex-x-between flex-y-center">
  303. <view class="title">订单备注</view>
  304. <navigator :url="`/pages/addRemarks/addRemarks?remarks=${remarks}`" hover-class="nav-hover"
  305. class="desc flex flex-nowarp flex-y-center arr-r">{{remarks || '点击填写备注'}}</navigator>
  306. </view>
  307. </view>
  308. </view>
  309. </view>
  310. <!-- 支付时提示开通会员 -->
  311. <block v-if="systemInfo.set.open==1 && !userInfo.mobile">
  312. <getPhone />
  313. </block>
  314. <view class="footer-block is-iphone-x">
  315. <view class="content is-iphone-x flex flex-nowarp flex-x-between flex-y-center">
  316. <view class="total-block" :style='{color:setColor}'>
  317. <text class="title">共计:</text>
  318. <text class="sign">¥</text>
  319. <text class="money">{{total_price}}</text>
  320. </view>
  321. <block v-if="is_distance">
  322. <view class="sub-btn" style="background:#999;width:300rpx;">超出配送范围
  323. </view>
  324. </block>
  325. <block v-else-if="teen_index==2&&Number(total_price)<Number(systemInfo.set.delivery_price)">
  326. <view class="sub-btn" style="background:#999;width:300rpx;">
  327. ¥{{systemInfo.set.delivery_price}}起送
  328. </view>
  329. </block>
  330. <block v-else>
  331. <!-- 先充值后下单 -->
  332. <block v-if="paytype!=-1 || check_index==4">
  333. <view class="sub-btn" :style="{'background-color':setColor}" @click="czPay">下单</view>
  334. </block>
  335. <block v-else>
  336. <block v-if="systemInfo.set.open==1 && systemInfo.is_vip==1 && !userInfo.mobile">
  337. <view class="sub-btn" :style="{'background-color':setColor}" @click="modelGetPhone">下单
  338. </view>
  339. </block>
  340. <!-- 餐后付款 -->
  341. <block v-else>
  342. <view class="sub-btn" :style="{'background-color':setColor}"
  343. v-if="hebin_index==1&teen_index!=2" @click="addCheck">下单
  344. </view>
  345. <view class="sub-btn" :style="{'background-color':setColor}" v-else @click="addOrder">下单
  346. </view>
  347. </block>
  348. </block>
  349. </block>
  350. </view>
  351. </view>
  352. <uni-popup ref="popup" type="center">
  353. <view class="merge-model" v-if="is_pop==1">
  354. <view class="weui-dialog__hd">
  355. <text class="weui-dialog__title">提示</text>
  356. </view>
  357. <view class="weui-dialog__tip">
  358. 是否合并前面的订单?
  359. </view>
  360. <scroll-view scroll-y="true" style="max-height:250px;">
  361. <view class="main">
  362. <view class="page-block" style="padding: 0;">
  363. <view class="goods-list" v-if="hebinList.length>0">
  364. <block v-for="(item,index) in hebinList" :key="index">
  365. <view class="item flex flex-nowarp" v-if="index < 3 || (index>=3 && showMore)">
  366. <image :src="getImgSrc(item.spec_image)" mode="aspectFill" class="img"></image>
  367. <view class="info flex flex-column">
  368. <view class="title">{{item.name}}</view>
  369. <view class="unit text-nowarp">{{item.spec}}</view>
  370. <view class="num">× {{item.num}}</view>
  371. </view>
  372. <view class="price">¥{{item.total_price}}</view>
  373. </view>
  374. </block>
  375. <view class="total-block">共 {{hebinList.length}}
  376. 件,小计:¥{{Number(hebinTotalPrice).toFixed(2)}}</view>
  377. </view>
  378. </view>
  379. </view>
  380. </scroll-view>
  381. <view class="flex weui-dialog__ft">
  382. <view class="weui-dialog__btn" @click="bindMerge">
  383. 合并
  384. </view>
  385. <view class="weui-dialog__btn" @click="bindNoMerge">
  386. 不合并
  387. </view>
  388. </view>
  389. </view>
  390. <view class="get-phone-pop-pay" v-if="is_pop==2">
  391. <view class="content-block">
  392. <view class="content flex flex-y-center flex-x-center">提示</view>
  393. </view>
  394. <view class="flex-center content-tel-pay">
  395. <text style="min-width: 130rpx;">订单处理成功</text>
  396. </view>
  397. <navigator open-type="redirect" :url="'../paySuccess/paySuccess?order_id='+order_id"
  398. class="btm-block flex flex-nowarp flex-x-between">
  399. <view form-type="submit" class="btn sub-btn">确定</view>
  400. </navigator>
  401. </view>
  402. </uni-popup>
  403. <!-- 引入组件 -->
  404. <!-- #ifdef MP-ALIPAY -->
  405. <!-- <subscribe-msg /> -->
  406. <!-- #endif -->
  407. <agree />
  408. <vbutton :getMenberPop='getMenberPop' @modelGetClose='modelGetClose' @maskClick="maskClick" />
  409. </view>
  410. </template>
  411. <script>
  412. import {
  413. mapState,
  414. mapMutations
  415. } from 'vuex'
  416. // #ifdef MP-ALIPAY
  417. // const {
  418. // requestSubscribeMessage
  419. // } = requirePlugin('subscribeMsg');
  420. // #endif
  421. import vbutton from '@/components/v-phone/v-button.vue';
  422. import util from "../../utils/util.js";
  423. import getPhone from '../../diy/module/getPhone.vue';
  424. import agree from '@/components/agree/agree.vue';
  425. let hideLoading = true;
  426. const app = getApp();
  427. export default {
  428. components: {
  429. vbutton,
  430. getPhone,
  431. agree
  432. },
  433. data() {
  434. return {
  435. showMore: false,
  436. carInfo: {},
  437. remarks: "",
  438. order_id: "",
  439. isPay:0,
  440. // teen_index: 0,
  441. wmindex: 0,
  442. // address: null,
  443. wmtimearray: ['到店即取'],
  444. coupon_list: [],
  445. coupon_id: "",
  446. coupon_price: 0,
  447. activity: '',
  448. voucherCode: '',
  449. total_price: 0,
  450. // #ifdef MP-WEIXIN
  451. check_index: 1,
  452. // #endif
  453. // #ifdef MP-ALIPAY
  454. check_index: 2,
  455. // #endif
  456. menber_discount: {},
  457. my_discount: "",
  458. hebin_index: 0,
  459. hebin_type: 1,
  460. // setColor: "",
  461. // dining_index: 1, //堂食/自提
  462. offline_name: "",
  463. offline_mobile: "",
  464. deliveryPrice: 0,
  465. is_distance: false,
  466. hebinList: [],
  467. hebinTotalPrice: 0,
  468. is_pop: 0,
  469. czList: [],
  470. paytype: -1,
  471. pay_price: 0,
  472. send_price: 0,
  473. is_yuer: 0,
  474. order_id: '',
  475. eat_people: 0, //就餐人数
  476. totle_eat_people: 0, //就餐的总费用
  477. getMenberPop: false,
  478. order_czid: '',
  479. is_status: false,
  480. is_status_czail: false
  481. }
  482. },
  483. onLoad(options) {
  484. let _this=this;
  485. // let res=await _this.$http.request('xcx/system', {
  486. // store_id: this.store_id,
  487. // table_id: this.table_id,
  488. // }, true);
  489. // console.log("onLoad");
  490. // console.log("res",res);
  491. // this.systemInfo=res.data;
  492. this.eat_people = options.eat_people ? options.eat_people : 0; //就餐人数
  493. this.countnumPrise(options.eat_people); //计算人数的价格
  494. var e = util.formatTime(new Date()),
  495. a = util.formatTime(new Date()).substring(0, 10).replace(/\//g, "-"),
  496. s = util.formatTime(new Date()).substring(11, 16);
  497. // console.log(e, a.toString(), s.toString());
  498. var o = new Date(),
  499. i = o.getTime(),
  500. n = 2 * (24 - new Date(i).getHours());
  501. // console.log(n, new Date(i), new Date(i).getHours(), new Date(i).getMinutes());
  502. for (var d = ["到店即取"], r = 1; r < n; r++) {
  503. i = o.getTime() + 10e5 * r;
  504. var l = new Date(i).getMinutes();
  505. l < 10 && (l = "0" + l);
  506. var c = new Date(i).getHours() + ":" + l;
  507. d.push(c);
  508. }
  509. this.wmtimearray = d;
  510. // 合并订单不能使用优惠劵,在订单详情再使用, 多人点餐不会提示合并订单
  511. if (this.systemInfo.pay_type == 2 && this.systemInfo.is_qian_many != 1) {
  512. this.hebintable();
  513. return
  514. }
  515. this.check_index = (this.systemInfo.set.is_yuer == 1 && this.systemInfo.is_vip == 1 && this.userInfo
  516. .mobile) ?
  517. 3 : this.check_index;
  518. this.paycoupons(); //获取优惠劵
  519. },
  520. onShow(e) {
  521. // 支付宝支付完成不走回调问题
  522. if (this.is_status) {
  523. let order_id = uni.getStorageSync("order_id");
  524. this.AlipaySuccess(order_id)
  525. }
  526. if (this.is_status_czail) {
  527. let info = uni.getStorageSync("order_id_info");
  528. if (this.check_index == 4) {
  529. this.order_czid = info.order_id;
  530. this.addOrder();
  531. } else {
  532. this.CzAliOrderInfo(info)
  533. }
  534. }
  535. // end
  536. if (this.userInfo.mobile && this.systemInfo.is_vip == 1) {
  537. this.menber_pay()
  538. } else {
  539. this.getCarList();
  540. }
  541. this.MyDefaultAddress();
  542. },
  543. onReady() {
  544. uni.setNavigationBarColor({
  545. frontColor: '#ffffff',
  546. backgroundColor: this.setColor,
  547. })
  548. this.czlist();
  549. },
  550. computed: {
  551. ...mapState(['systemInfo','setColor', 'table_id', 'store_id', 'userInfo', 'teen_index', 'address',
  552. 'dining_index', 'descFood', 'descOrder'
  553. ])
  554. },
  555. watch: {
  556. teen_index(){
  557. this.paycoupons()
  558. },
  559. },
  560. methods: {
  561. ...mapMutations(['SET_ADDRESS', 'SET_TEEN_INDEX', 'SET_SELFMENTION']),
  562. maskClick() {
  563. this.getMenberPop = false
  564. },
  565. modelGetClose() {
  566. this.getMenberPop = false
  567. if (this.hebin_index == 1 && this.teen_index != 2) {
  568. this.addCheck();
  569. } else {
  570. this.addOrder()
  571. }
  572. },
  573. modelGetPhone() {
  574. this.getMenberPop = true
  575. },
  576. // 初始化
  577. socktopentInit() {
  578. var datas = {
  579. group: this.table_id,
  580. type: 'init',
  581. store_id: this.store_id,
  582. table_id: this.table_id,
  583. }
  584. app.sendSocketMessage(JSON.stringify(datas)).then(res => {
  585. console.log('初始化!');
  586. })
  587. },
  588. //根据就餐人数算价格
  589. countnumPrise(num) {
  590. this.$http.request('xcx/eat_people_time', {
  591. store_id: this.store_id,
  592. user_id: this.userInfo.id,
  593. }).then(res => {
  594. if (res.code == "200") {
  595. //eat_cover 单价
  596. let nowprise = res.data.eat_cover || 0;
  597. let zongprise = Number(nowprise) * num;
  598. if (res.data.eat_open == 1) {
  599. //首先判断是否开启选择人数就餐且是点餐的情况
  600. //判断时间开关是否开启1开启 0关闭
  601. //on_time 1超过 2没超过
  602. if (res.data.eat_open_time == 1) {
  603. if (res.data.on_time == 1) {
  604. this.totle_eat_people = (Math.round(zongprise * 100) / 100).toFixed(2);
  605. this.computGoodsNum()
  606. }
  607. } else {
  608. this.totle_eat_people = (Math.round(zongprise * 100) / 100).toFixed(2);
  609. this.computGoodsNum()
  610. }
  611. }
  612. }
  613. }).catch((res) => {
  614. uni.showToast({
  615. title: res.message,
  616. icon: 'none'
  617. })
  618. });
  619. },
  620. Socket() {
  621. if (this.systemInfo.is_qian_many == 1 && app.globalData.readyReset == 1) {
  622. app.globalData.callback = (r) => {
  623. // console.log('收到服务器内容', r)
  624. let res = JSON.parse(r.data);
  625. if (res.type == 'clear_list') {
  626. this.getCarList();
  627. } else if (res.type == 'ping') {
  628. return
  629. } else if (res.type == 'init_list' || res.type == 'add_cart_list') {
  630. this.carInfo = res;
  631. this.computGoodsNum();
  632. }
  633. }
  634. }
  635. },
  636. bindScan(e) {
  637. // 允许从相机和相册扫码
  638. uni.scanCode({
  639. success: (res) => {
  640. var store_id = this.gettParameter(res.result, 'store_id')
  641. var table_id = this.gettParameter(res.result, 'table_id')
  642. this.$store.commit('SET_SYSTEM', '') //清空
  643. this.$store.commit('SET_STORE_ID', store_id)
  644. this.$store.commit('SET_TEEN_INDEX', 1) //重置默认
  645. this.$store.commit('SET_TABLE_ID', table_id)
  646. this.$store.commit('SET_CATE_ID', '')
  647. this.$store.dispatch('getSystemStup', store_id);
  648. this.$store.dispatch('getOpenid', store_id);
  649. }
  650. })
  651. },
  652. gettParameter: function(url, name) {
  653. let val = ''
  654. if (url.indexOf('?' + name + '=') !== -1) {
  655. val = url.split('?' + name + '=')[1].split(/&|#/)[0];
  656. } else if (url.indexOf('&' + name + '=') !== -1) {
  657. val = url.split('&' + name + '=')[1].split(/&|#/)[0];
  658. }
  659. return val
  660. },
  661. czPay(e) {
  662. // #ifdef MP-WEIXIN
  663. var url = 'xcxweixinpay/czorder',
  664. user_id = this.userInfo.id;
  665. // #endif
  666. // #ifdef MP-ALIPAY
  667. var url = 'xcxpay/czorder',
  668. user_id = this.userInfo.user_id;
  669. // #endif
  670. // Number(systemInfo.set.charge_num)*Number(total_price)
  671. let pirce = this.systemInfo.set.is_charge == 1 ? Number(this.total_price) * Number(this.systemInfo.set
  672. .charge_num) : 0;
  673. let pay_price = this.check_index == 4 ? pirce : this.pay_price;
  674. this.$http.request(url, {
  675. store_id: this.store_id,
  676. user_id: user_id,
  677. pay_price: pay_price,
  678. send_price: this.paytype > -1 ? this.send_price : 0,
  679. }).then(res => {
  680. // this.list = res.data;
  681. // #ifdef MP-ALIPAY
  682. this.czAliPay(res.data)
  683. // #endif
  684. // #ifdef MP-WEIXIN
  685. this.czWxPay(res.data)
  686. // #endif
  687. }).catch((err) => {
  688. uni.showToast({
  689. title: err.message,
  690. icon: "none"
  691. })
  692. })
  693. },
  694. //支付宝支付
  695. czAliPay(info) {
  696. // 防止支付完成不走回调
  697. this.is_status_czail = true;
  698. uni.setStorageSync("order_id_info", info);
  699. my.tradePay({
  700. // 调用统一收单交易创建接口(alipay.trade.create),获得返回字段支付宝交易号trade_no
  701. tradeNO: info.trade_no,
  702. success: (res) => {
  703. if (res.resultCode == 9000) {
  704. // 免单充值
  705. if (this.check_index == 4 && info.order_id) {
  706. this.order_czid = info.order_id;
  707. this.addOrder();
  708. } else {
  709. // 普通充值
  710. this.CzAliOrderInfo(info)
  711. }
  712. } else if (res.resultCode == 8000 || res.resultCode == 6004) {
  713. uni.showToast({
  714. title: "支付结果未知,请核对",
  715. icon: "none"
  716. })
  717. }
  718. },
  719. fail: (res) => {
  720. uni.showToast({
  721. title: '支付失败',
  722. icon: 'none'
  723. })
  724. }
  725. });
  726. },
  727. // 支付宝充值
  728. CzAliOrderInfo(info) {
  729. this.is_status_czail = false
  730. this.$http.request('xcxpay/CzAliOrderInfo', {
  731. out_trade_no: info.out_trade_no,
  732. store_id: this.store_id,
  733. }).then(res => {
  734. uni.showModal({
  735. content: '余额储值成功',
  736. confirmText: '确定下单',
  737. showCancel: false,
  738. success: r => {
  739. this.addOrder();
  740. }
  741. })
  742. })
  743. },
  744. // 微信充值
  745. czWxPay(info) {
  746. wx.requestPayment({
  747. timeStamp: info.timeStamp,
  748. nonceStr: info.nonceStr,
  749. package: info.package,
  750. signType: info.signType,
  751. paySign: info.paySign,
  752. success: (res) => {
  753. if (this.check_index == 4 && info.order_id) {
  754. this.order_czid = info.order_id;
  755. this.addOrder();
  756. } else {
  757. this.Czdiscount();
  758. }
  759. },
  760. fail: (res) => {
  761. uni.showToast({
  762. title: '支付失败',
  763. icon: 'none'
  764. })
  765. }
  766. })
  767. },
  768. Czdiscount() {
  769. this.$http.request('xcx/discount', {
  770. user_id: this.userInfo.id,
  771. store_id: this.store_id,
  772. }, "", "", hideLoading).then(res => {
  773. if (Number(res.data.balance) < Number(this.total_price)) {
  774. uni.showToast({
  775. title: "您的余额不足,请充值后使用",
  776. icon: "none"
  777. })
  778. return
  779. }
  780. }).catch(err => {
  781. console.log(err)
  782. })
  783. },
  784. choice_pay(e) {
  785. if (this.paytype == e) {
  786. this.paytype = -1
  787. return
  788. }
  789. if (this.check_index != 3) {
  790. return
  791. }
  792. this.paytype = e;
  793. this.pay_price = this.czList[e].pay_price;
  794. this.send_price = this.czList[e].send_price;
  795. },
  796. czlist() {
  797. this.$http.request('xcx/czlist', {
  798. store_id: this.store_id
  799. }).then(res => {
  800. this.czList = res.data;
  801. })
  802. },
  803. // 会员充值end
  804. KeyName(t) {
  805. this.offline_name = t.detail.value;
  806. },
  807. KeyMobile(t) {
  808. this.offline_mobile = t.detail.value;
  809. },
  810. // 默认地址
  811. MyDefaultAddress() {
  812. if (this.teen_index != 2) {
  813. return
  814. }
  815. if (this.address.id) {
  816. this.getDeliveryPrice();
  817. } else {
  818. this.$http.request('xcx/MyDefaultAddress', {
  819. user_id: this.userInfo.id,
  820. }, "", "", hideLoading).then(res => {
  821. this.SET_ADDRESS(res.data)
  822. this.getDeliveryPrice();
  823. }).catch(err => {
  824. console.log(err)
  825. })
  826. }
  827. },
  828. // 获取配送费
  829. getDeliveryPrice() {
  830. this.$http.request('xcx/getDeliveryPrice', {
  831. lat: this.address.lat,
  832. lng: this.address.lng,
  833. store_id: this.store_id,
  834. }, "", "", hideLoading).then(res => {
  835. this.deliveryPrice = Number(res.data.delivery_price) || 0;
  836. let distance = Number(res.data.distance);
  837. if (distance > this.systemInfo.set.number && this.systemInfo.set.number != 0) {
  838. this.is_distance = true;
  839. } else {
  840. this.is_distance = false;
  841. }
  842. this.computGoodsNum();
  843. }).catch(err => {
  844. console.log(err)
  845. })
  846. },
  847. addCheck() {
  848. this.is_pop = 1;
  849. this.hebintablelist();
  850. this.$refs.popup.open();
  851. },
  852. // 合并
  853. bindMerge() {
  854. this.hebin_type = 2;
  855. this.addOrder();
  856. this.$refs.popup.close();
  857. },
  858. // 不合并
  859. bindNoMerge() {
  860. this.hebin_type = 1;
  861. this.addOrder();
  862. this.$refs.popup.close();
  863. },
  864. // 合并状态
  865. hebintable() {
  866. // 餐后付款pay_type==2 & this.teen_index==2外卖
  867. if (this.teen_index == 2) {
  868. return
  869. }
  870. this.$http.request('xcx/hebintable', {
  871. store_id: this.store_id, //是 string 门店id
  872. table_id: this.table_id, //是 string 桌号
  873. }, "", "", hideLoading).then(res => {
  874. this.hebin_index = res.data;
  875. }).catch(err => {
  876. console.log(err)
  877. })
  878. },
  879. // 合并订单列表
  880. hebintablelist() {
  881. this.$http.request('xcx/hebintablelist', {
  882. store_id: this.store_id, //是 string 门店id
  883. table_id: this.table_id, //是 string 桌号
  884. }, "", "", hideLoading).then(res => {
  885. this.hebinList = res.data;
  886. for (let i of res.data) {
  887. this.hebinTotalPrice += Number(i.total_price);
  888. }
  889. }).catch(err => {
  890. console.log(err)
  891. })
  892. },
  893. // 获取会员折扣
  894. menber_pay() {
  895. this.$http.request('xcx/discount', {
  896. user_id: this.userInfo.id,
  897. store_id: this.store_id,
  898. }, "", "", hideLoading).then(res => {
  899. this.menber_discount = res.data;
  900. if (res.data.discount) {
  901. this.my_discount = Number(res.data.discount);
  902. }
  903. this.getCarList();
  904. }).catch(err => {
  905. console.log(err)
  906. })
  907. },
  908. checkPay(index) {
  909. this.check_index = index;
  910. let carInfo = this.carInfo;
  911. if (index != 3) {
  912. this.paytype = -1;
  913. }
  914. if (this.voucherCode && index !== 2) {
  915. uni.showModal({
  916. title: "提示",
  917. content: "优惠劵状态发生变化,请重新选择优惠劵",
  918. showCancel: false,
  919. cancelText: '取消',
  920. confirmText: '重新选择',
  921. success: res => {
  922. if (res.confirm) {
  923. this.coupon_id = ""; //修改上一页data里面的sh参数值为100
  924. this.coupon_price = 0;
  925. this.activity = '';
  926. this.voucherCode = '';
  927. uni.navigateTo({
  928. url: `../use-coupon-list/use-coupon-list?total_price=${carInfo.total_price}&check_index=${index}&state=${this.teen_index}`
  929. })
  930. }
  931. },
  932. fail: () => {},
  933. complete: () => {}
  934. });
  935. }
  936. },
  937. bindPickerChange: function(t) {
  938. this.wmindex = t.detail.value;
  939. },
  940. bindDining(e) {
  941. this.fastTake(2, e);
  942. },
  943. selectednavbar: function(e) {
  944. let index = e.currentTarget.dataset.index;
  945. index = index == 1 ? (this.systemInfo.is_hall == 1 ? index : this.systemInfo.is_ziti == 1 ? 3 :
  946. index) : index;
  947. this.fastTake(1, index);
  948. },
  949. // 必选商品校检
  950. fastTake(type, t) {
  951. // 切换清空优化劵
  952. this.coupon_id = "";
  953. this.coupon_price = 0;
  954. this.activity = '';
  955. this.voucherCode = '';
  956. this.coupon_full = '';
  957. // type==1 头部切换点餐外卖 2 到店自提
  958. this.$http.request('xcx/fastTake', {
  959. store_id: this.store_id,
  960. user_id: uni.getStorageSync('user_id'),
  961. state: Number(t),
  962. }, "", true, true).then(res => {
  963. this.SET_TEEN_INDEX(t);
  964. this.computGoodsNum(); //计算价格当是点餐的到店取餐情况下要加多个包装费
  965. if (type == 1) {
  966. if (t == 2) {
  967. this.MyDefaultAddress();
  968. } else {
  969. this.deliveryPrice = 0;
  970. this.is_distance = false;
  971. this.computGoodsNum();
  972. }
  973. }
  974. }).catch(err => {
  975. uni.showModal({
  976. title: '提示',
  977. content: err.message,
  978. showCancel: true,
  979. cancelText: '取消',
  980. confirmText: '去选择',
  981. success: res => {
  982. if (res.confirm) {
  983. this.SET_TEEN_INDEX(t);
  984. uni.navigateBack({
  985. delta: 1
  986. })
  987. }
  988. },
  989. fail: () => {},
  990. complete: () => {}
  991. });
  992. })
  993. },
  994. getWechatAddress: function(e) {
  995. uni.navigateTo({
  996. url: '../address/address?teen_index=2'
  997. })
  998. },
  999. onShowMore(idx) {
  1000. console.log(idx,this.carInfo.new_list[idx].showMore)
  1001. this.carInfo.new_list[idx].showMore = !this.carInfo.new_list[idx].showMore;
  1002. // this.showMore = true
  1003. },
  1004. //拼接图片全路径
  1005. getImgSrc(src) {
  1006. return this.$utils.getImgSrc(src)
  1007. },
  1008. paycoupons() {
  1009. this.$http.request('xcx/payTicket', {
  1010. user_id: this.userInfo.id,
  1011. // store_id: this.store_id,
  1012. // is_use: this.teen_index
  1013. }, "", "", hideLoading).then(res => {
  1014. this.coupon_list = res.data;
  1015. }).catch(err => {
  1016. console.log(err)
  1017. })
  1018. },
  1019. getCarList() {
  1020. if (this.systemInfo.is_qian_many == 1 && app.globalData.readyReset == 1) {
  1021. this.socktopentInit();
  1022. this.Socket();
  1023. // url = 'xcx/cart_lista';
  1024. // datas = {
  1025. // table_id: this.table_id,
  1026. // store_id: this.store_id,
  1027. // }
  1028. return
  1029. }
  1030. var url, datas;
  1031. url = 'xcx/cart_list';
  1032. datas = {
  1033. user_id: this.userInfo.id,
  1034. store_id: this.store_id,
  1035. }
  1036. this.$http.request(url, datas, "", "", hideLoading).then(res => {
  1037. if(res.data.new_list){
  1038. for(let i of res.data.new_list){
  1039. i.showMore = false
  1040. }
  1041. }
  1042. this.carInfo = res.data;
  1043. this.computGoodsNum();
  1044. }).catch(err => {
  1045. console.log(err)
  1046. })
  1047. },
  1048. computGoodsNum(res) {
  1049. let carInfo = this.carInfo,
  1050. my_discount = this.my_discount;
  1051. let list = carInfo.list
  1052. let num = 0
  1053. for (let i in list) {
  1054. num += list[i].num
  1055. }
  1056. carInfo.carNum = num
  1057. let price = Number(carInfo.total_price);
  1058. let box_fee = Number(carInfo.box_fee) || 0; //包装费
  1059. if (my_discount && my_discount > 0 && this.systemInfo.is_vip == 1 && this.userInfo.mobile) {
  1060. price = price * (my_discount * 0.1)
  1061. }
  1062. let total_num = price - this.coupon_price + this.deliveryPrice
  1063. //如果不是店内就餐就加餐盒费
  1064. if (this.teen_index == 2 || this.teen_index == 3) {
  1065. total_num += box_fee
  1066. }
  1067. //总价格加就餐人数
  1068. if (this.teen_index == 1 && Number(this.totle_eat_people) > 0) {
  1069. total_num += Number(this.totle_eat_people)
  1070. }
  1071. this.total_price = (Math.round(total_num * 100) / 100).toFixed(2)
  1072. this.carInfo = carInfo
  1073. },
  1074. addOrder() {
  1075. // 重复点击
  1076. if (!this.clickThrottle()) {
  1077. return
  1078. }
  1079. if (this.order_id) {
  1080. if (this.systemInfo.pay_type == 1) {
  1081. //先付后吃
  1082. // #ifdef MP-ALIPAY
  1083. this.aliPay(this.order_id, this.total_price)
  1084. // #endif
  1085. } else {
  1086. //先吃后付
  1087. uni.showModal({
  1088. content: "下单成功",
  1089. showCancel: false,
  1090. success: () => {
  1091. this.SET_TEEN_INDEX(1);
  1092. uni.navigateBack()
  1093. }
  1094. })
  1095. }
  1096. return false
  1097. }
  1098. let list = this.carInfo.list || []
  1099. if (list.length == 0) {
  1100. uni.showToast({
  1101. title: '请先选择商品',
  1102. icon: 'none'
  1103. })
  1104. return false
  1105. }
  1106. let sz = []
  1107. for (let i in list) {
  1108. sz.push({
  1109. name: list[i].name,
  1110. img: list[i].spec_image,
  1111. num: list[i].num,
  1112. money: list[i].price,
  1113. spec: list[i].spec,
  1114. goods_id: list[i].goods_id,
  1115. packing_fee: list[i].packing_fee,
  1116. pocket: list[i].pocket,
  1117. })
  1118. }
  1119. let address = this.address,
  1120. params, state = Number(this.teen_index);
  1121. if (state == 2 && !address.id) {
  1122. uni.showToast({
  1123. title: "地址不能为空",
  1124. icon: "none"
  1125. })
  1126. return
  1127. }
  1128. if (state == 1 && !this.table_id) {
  1129. uni.showToast({
  1130. title: "桌号不能为空",
  1131. icon: "none"
  1132. })
  1133. return
  1134. }
  1135. if (Number(this.total_price) < 0) {
  1136. uni.showToast({
  1137. title: "支付金额不能小于0",
  1138. icon: "none"
  1139. })
  1140. return
  1141. }
  1142. params = {
  1143. state: state, //1堂食 2外卖 3打包
  1144. admin_id: this.systemInfo.admin_id, //商户id
  1145. store_id: this.store_id, //是 string 门店id
  1146. total_price: this.carInfo.total_price, //是 string 总价
  1147. pay_price: this.total_price, //是 string 支付金额
  1148. table_id: this.table_id, //是 string 桌号
  1149. sz: JSON.stringify(sz), //商品信息
  1150. remark: this.remarks || '', //备注
  1151. user_id: this.userInfo.id, //用户id
  1152. type: this.hebin_type, //1不合并,2合并
  1153. // this.systemInfo.pay_type, // 传type==2, 不合并传type==1
  1154. coupon_id: this.coupon_id, //优惠劵id
  1155. coupon_price: this.coupon_price, //优惠劵金额
  1156. activity: this.activity, //商家优惠劵金额
  1157. voucherCode: this.voucherCode, //商家劵码
  1158. pay_type: this.check_index == 4 ? 5 : this.check_index, //1是微信支付。2是支付宝支付。3是余额支付 4现金 5充值免单
  1159. delivery_price: this.deliveryPrice || 0, //外卖配送费
  1160. discount: this.my_discount || 0, // 会员折扣
  1161. box_fee: this.carInfo.box_fee, //包装费
  1162. eat_people: this.eat_people, //就餐人数
  1163. czorder_id: this.order_czid, //充值免单id
  1164. }
  1165. if (state == 2) {
  1166. params.address_id = address.id
  1167. }
  1168. // var myreg = /^[1][3,4,5,7,8,9,][0-9]{9}$/;
  1169. if (params.state == 3) {
  1170. params.name = this.offline_name;
  1171. params.mobile = this.offline_mobile;
  1172. params.time = this.wmtimearray[this.wmindex];
  1173. if (!this.offline_name) {
  1174. uni.showToast({
  1175. title: "请填写自提人",
  1176. icon: 'none'
  1177. });
  1178. return false;
  1179. }
  1180. if (!this.offline_mobile) {
  1181. uni.showToast({
  1182. title: "请填写自提号码",
  1183. icon: 'none'
  1184. });
  1185. return false;
  1186. }
  1187. if (this.offline_mobile.length != 11) {
  1188. uni.showToast({
  1189. title: "联系电话格式不正确",
  1190. icon: 'none'
  1191. });
  1192. return false;
  1193. }
  1194. }
  1195. let subscribe = uni.getStorageSync('balance_subscribe');
  1196. uni.showLoading({
  1197. title: '正在加载',
  1198. mask: true
  1199. })
  1200. var url = this.systemInfo.is_qian_many == 1 && app.globalData.readyReset == 1 ? 'xcx/addhbordera' : 'xcx/addhborder';
  1201. this.$http.request(url, params).then(res => {
  1202. uni.hideLoading();
  1203. uni.setStorageSync("lastChoose", false)
  1204. this.order_id = res.data.id;
  1205. this.isPay=res.data.isPay;
  1206. console.log(this.systemInfo.pay_type);
  1207. console.log("state",state);
  1208. console.log("checkIndex",this.check_index);
  1209. // 先付后吃pay_type==2直接下单,外卖都可以直接下单
  1210. if (this.systemInfo.pay_type == 1 || state == 2) {
  1211. if (this.check_index == 2) {
  1212. let that = this;
  1213. let entityIds = [subscribe.alipay_balance];
  1214. // 外卖没有取餐消息
  1215. if (state != 2) {
  1216. entityIds.push(subscribe.qucang_tid);
  1217. }
  1218. // return
  1219. // #ifdef MP-ALIPAY
  1220. // 调用方法,唤起订阅组件
  1221. my.requestSubscribeMessage({
  1222. thirdTypeAppId: that.systemInfo.alipay_appid, // 可选,isv接入场景下必填
  1223. entityIds: entityIds, // 模板id列表,最多3个
  1224. // 接收结果的回调方法
  1225. complete: (r) => {
  1226. console.log('订阅回调', r);
  1227. that.aliPay(res.data, that.total_price)
  1228. },
  1229. });
  1230. // #endif
  1231. } else if (this.check_index == 1) {
  1232. // #ifdef MP-WEIXIN
  1233. let tmplIds = [subscribe.pay_tid, subscribe.jf_tid];
  1234. console.log(tmplIds, "tmplIdstmplIdstmplIdstmplIdstmplIdstmplIdstmplIdstmplIdstmplIdstmplIds")
  1235. // 外卖没有取餐消息
  1236. if (state != 2 && subscribe.wechat_qucang_tid) {
  1237. tmplIds.push(subscribe.wechat_qucang_tid);
  1238. }
  1239. uni.requestSubscribeMessage({
  1240. tmplIds: tmplIds,
  1241. success: (r) => {
  1242. console.log(r, "success")
  1243. },
  1244. complete: (r) => {
  1245. console.log(r, "complete")
  1246. if(this.isPay!=undefined && this.isPay==1){
  1247. //已支付
  1248. uni.redirectTo({
  1249. url: '/pages/paySuccess/paySuccess?order_id=' +
  1250. this.order_id
  1251. })
  1252. }else{
  1253. this.wxPay(res.data.id, this.total_price)
  1254. }
  1255. }
  1256. })
  1257. // #endif
  1258. } else if (this.check_index == 3) {
  1259. let tmplIds = [subscribe.balance_tid, subscribe.jf_tid];
  1260. // 外卖没有取餐消息
  1261. if (state != 2) {
  1262. tmplIds.push(subscribe.wechat_qucang_tid);
  1263. }
  1264. // #ifdef MP-WEIXIN
  1265. uni.requestSubscribeMessage({
  1266. tmplIds: tmplIds,
  1267. success: (r) => {
  1268. console.log(r, "success")
  1269. },
  1270. complete: (r) => {
  1271. console.log(r, "complete")
  1272. // this.wxPay(res.data, this.total_price)
  1273. this.yuer_pay(res.data)
  1274. }
  1275. })
  1276. // #endif
  1277. // #ifdef MP-ALIPAY
  1278. let that = this;
  1279. let entityIds = [subscribe.alipay_balance];
  1280. // 外卖没有取餐消息
  1281. if (state != 2) {
  1282. entityIds.push(subscribe.qucang_tid);
  1283. }
  1284. // 调用方法,唤起订阅组件
  1285. my.requestSubscribeMessage({
  1286. // appId: "2021xxxxx", 可选.
  1287. thirdTypeAppId: that.systemInfo.alipay_appid, // 可选,isv接入场景下必填
  1288. entityIds: entityIds, // 模板id列表,最多3个
  1289. // 接收结果的回调方法
  1290. complete: (r) => {
  1291. console.log('订阅回调', r);
  1292. that.yuer_pay(res.data)
  1293. },
  1294. });
  1295. // #endif
  1296. } else if (this.check_index == 4) {
  1297. //先吃后付
  1298. this.AddIntegral(res.data)
  1299. uni.setStorageSync("lastChoose", false) //下单成功后清除让重新选择就餐人数
  1300. uni.showModal({
  1301. content: '支付成功',
  1302. showCancel: false,
  1303. success: r => {
  1304. uni.redirectTo({
  1305. url: '/pages/paySuccess/paySuccess?order_id=' +
  1306. res.data
  1307. })
  1308. }
  1309. })
  1310. }
  1311. } else {
  1312. //先吃后付
  1313. uni.showModal({
  1314. content: "下单成功",
  1315. showCancel: false,
  1316. success: () => {
  1317. // this.SET_TEEN_INDEX(1);
  1318. this.$store.commit('SET_CREAT', true)
  1319. uni.navigateBack()
  1320. }
  1321. })
  1322. }
  1323. if (this.systemInfo.is_qian_many == 1 && app.globalData.readyReset == 1) {
  1324. let datas = {
  1325. group: this.table_id,
  1326. type: "clear",
  1327. store_id: this.store_id,
  1328. table_id: this.table_id,
  1329. }
  1330. app.sendSocketMessage(JSON.stringify(datas)).then(res => {
  1331. console.log('发送成功!');
  1332. })
  1333. }
  1334. })
  1335. },
  1336. AddIntegral(order_id) {
  1337. this.$http.request('xcx/AddIntegral', {
  1338. order_id,
  1339. }).then(res => {
  1340. })
  1341. },
  1342. //支付宝支付
  1343. aliPay(order_id, money) {
  1344. uni.showLoading({
  1345. title: '正在加载',
  1346. mask: true
  1347. })
  1348. this.$http.request('Xcxpay/getAliorderNo', {
  1349. user_id: this.userInfo.user_id,
  1350. money: money,
  1351. order_id,
  1352. store_id: this.store_id,
  1353. }).then(res => {
  1354. uni.hideLoading();
  1355. let out_trade_no = res.data.out_trade_no
  1356. // 防止支付完成不走回调
  1357. this.is_status = true;
  1358. uni.setStorageSync("order_id", order_id);
  1359. my.tradePay({
  1360. // 调用统一收单交易创建接口(alipay.trade.create),获得返回字段支付宝交易号trade_no
  1361. tradeNO: res.data.trade_no,
  1362. success: (res) => {
  1363. if (res.resultCode == 9000) {
  1364. this.AlipaySuccess(order_id);
  1365. // my.alert({
  1366. // content: "订单处理成功",
  1367. // showCancle: false,
  1368. // success: () => {
  1369. // uni.navigateTo({
  1370. // url: '../paySuccess/paySuccess'
  1371. // })
  1372. // }
  1373. // });
  1374. } else if (res.resultCode == 8000 || res.resultCode == 6004) {
  1375. my.alert({
  1376. content: "支付结果未知,请核对",
  1377. showCancle: false,
  1378. success: () => {
  1379. uni.switchTab({
  1380. url: '../index/index'
  1381. })
  1382. }
  1383. });
  1384. } else {
  1385. my.alert({
  1386. content: "支付失败",
  1387. showCancle: false,
  1388. success: () => {
  1389. this.$store.commit("SET_TABACTIVE", 2)
  1390. uni.switchTab({
  1391. url: '/pages/myOrderList/myOrderList?tabActive=2'
  1392. })
  1393. }
  1394. });
  1395. }
  1396. },
  1397. fail: (res) => {
  1398. my.alert({
  1399. content: JSON.stringify(res),
  1400. });
  1401. }
  1402. });
  1403. }).catch(err => {
  1404. console.log(err)
  1405. uni.hideLoading();
  1406. })
  1407. },
  1408. AlipaySuccess(order_id) {
  1409. this.is_status = false;
  1410. this.AddIntegral(order_id)
  1411. uni.setStorageSync("lastChoose", false) //下单成功后清除让重新选择就餐人数
  1412. this.is_pop = 2;
  1413. this.order_id = order_id;
  1414. this.$refs.popup.open();
  1415. },
  1416. wxPay(order_id, money) {
  1417. uni.showLoading({
  1418. title: '正在加载',
  1419. mask: true
  1420. })
  1421. this.$http.request('Xcxweixinpay/pay', {
  1422. order_id,
  1423. money,
  1424. openid: this.userInfo.openid
  1425. }).then(res => {
  1426. uni.hideLoading();
  1427. wx.requestPayment({
  1428. timeStamp: res.data.timeStamp,
  1429. nonceStr: res.data.nonceStr,
  1430. package: res.data.package,
  1431. signType: res.data.signType,
  1432. paySign: res.data.paySign,
  1433. success: (res) => {
  1434. this.AddIntegral(order_id)
  1435. uni.setStorageSync("lastChoose", false) //下单成功后清除让重新选择就餐人数
  1436. uni.showModal({
  1437. content: '支付成功',
  1438. showCancel: false,
  1439. success: r => {
  1440. uni.redirectTo({
  1441. url: '/pages/paySuccess/paySuccess?order_id=' +
  1442. order_id
  1443. })
  1444. }
  1445. })
  1446. },
  1447. fail: (res) => {
  1448. uni.showModal({
  1449. content: '支付失败',
  1450. showCancel: false,
  1451. success: r => {
  1452. this.$store.commit("SET_TABACTIVE", 2)
  1453. uni.switchTab({
  1454. url: '/pages/myOrderList/myOrderList?tabActive=2'
  1455. })
  1456. }
  1457. })
  1458. // uni.showToast({
  1459. // title: '支付失败',
  1460. // icon: 'none'
  1461. // })
  1462. }
  1463. })
  1464. }).catch((err) => {
  1465. uni.hideLoading();
  1466. })
  1467. },
  1468. // 余额支付
  1469. yuer_pay(order_id) {
  1470. uni.showLoading({
  1471. title: '正在加载',
  1472. mask: true
  1473. })
  1474. // #ifdef MP-WEIXIN
  1475. var is_type = 1;
  1476. // #endif
  1477. // #ifdef MP-ALIPAY
  1478. var is_type = 2;
  1479. // #endif
  1480. this.$http.request('xcx/yuer_pay', {
  1481. order_id,
  1482. user_id: this.userInfo.id,
  1483. is_type,
  1484. }).then(res => {
  1485. uni.hideLoading();
  1486. this.AddIntegral(order_id)
  1487. uni.setStorageSync("lastChoose", false) //下单成功后清除让重新选择就餐人数
  1488. uni.showModal({
  1489. content: '支付成功',
  1490. showCancel: false,
  1491. success: r => {
  1492. uni.redirectTo({
  1493. url: '/pages/paySuccess/paySuccess?order_id=' + order_id
  1494. })
  1495. }
  1496. })
  1497. }).catch(err => {
  1498. uni.hideLoading();
  1499. uni.showModal({
  1500. content: err.message,
  1501. showCancel: false,
  1502. success: r => {
  1503. this.$store.commit("SET_TABACTIVE", 2)
  1504. uni.switchTab({
  1505. url: '/pages/myOrderList/myOrderList?tabActive=2'
  1506. })
  1507. }
  1508. })
  1509. })
  1510. }
  1511. }
  1512. }
  1513. </script>
  1514. <style lang="scss">
  1515. @import url("./creatOrder.css");
  1516. </style>