order-submit.vue 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205
  1. <template>
  2. <app-layout>
  3. <view class="page" v-if="previewData">
  4. <template v-if="previewData.show_address !== false">
  5. <view v-if="previewData.allZiti" class="address">
  6. <!-- <app-order-submit-row :show-nav="false" :no-padding="true">
  7. <view class="dir-left-nowrap px-12">
  8. <view class="box-grow-1">
  9. <app-input placeholder="请填写联系人" height="100"
  10. v-model="previewData.address.name"></app-input>
  11. </view>
  12. <view class="box-grow-1">
  13. <app-input placeholder="请填写手机号" height="100"
  14. v-model="previewData.address.mobile"></app-input>
  15. </view>
  16. </view>
  17. <view slot="footer">
  18. <image class="bottom-image" :src="appImg.common.address_bottom"></image>
  19. </view>
  20. </app-order-submit-row> -->
  21. </view>
  22. <view v-else @click="navigateAddress" class="address">
  23. <template v-if="!previewData.is_match">
  24. <app-order-submit-row>
  25. <view v-if="previewData.address">
  26. <!-- <view class="dir-left-nowrap mb-12">
  27. <view class="box-grow-1">参训人: {{previewData.address.name}}</view>
  28. <view class="box-grow-0">电话: {{previewData.address.mobile}}</view>
  29. </view>
  30. <view class="mb-12">
  31. 收货地址:
  32. {{previewData.address.province}}
  33. {{previewData.address.city}}
  34. {{previewData.address.district}}
  35. {{previewData.address.detail}}
  36. </view> -->
  37. <!-- <view class="dir-left-nowrap mb-12">
  38. <view class="box-grow-1">性别: {{previewData.address.name}}</view>
  39. <view class="box-grow-0">年龄: {{previewData.address.mobile}}</view>
  40. </view>
  41. <view class="dir-left-nowrap mb-12">
  42. <view class="box-grow-1">体重: {{previewData.address.name}}</view>
  43. <view class="box-grow-0">年龄: {{previewData.address.mobile}}</view>
  44. </view>
  45. <view class="dir-left-nowrap mb-12">
  46. <view class="box-grow-1">身高: {{previewData.address.name}}</view>
  47. <view class="box-grow-0">身份证号码: {{previewData.address.mobile}}</view>
  48. </view> -->
  49. <view class="felx-three">
  50. <view class="box-grow-2">
  51. 参训人: {{verifyUndefined(previewData.address.name)}}
  52. </view>
  53. <view class="box-grow-3">
  54. 性别: {{verifyUndefined(previewData.address.sex) == '暂无数据'? '暂无数据':previewData.address.sex == 0 ?'未知':previewData.address.sex == 1? '男':'女'}}
  55. </view>
  56. <view class="box-grow-4">
  57. 联系电话: {{verifyUndefined(previewData.address.mobile)}}
  58. </view>
  59. </view>
  60. <view class="felx-three">
  61. <view class="box-grow-2">
  62. 年龄: {{verifyUndefined(previewData.address.age)}}
  63. </view>
  64. <view class="box-grow-3">
  65. 体重: {{verifyUndefined(previewData.address.weight)}}
  66. </view>
  67. <view class="box-grow-4">
  68. 身高: {{verifyUndefined(previewData.address.height)}}
  69. </view>
  70. </view>
  71. <view class="felx-three">
  72. <view class="box-grow-5">
  73. 身份证号码:{{verifyUndefined(previewData.address.idcard)}}
  74. </view>
  75. </view>
  76. </view>
  77. <!-- <view v-else>请选择收货地</view> -->
  78. <view v-else>请选择报名信息</view>
  79. <view v-if="previewData.has_ziti" class="ziti-tip" :class="[`${theme}-color`]">
  80. <!-- (收货地址中的手机号码将用于自提信息) -->
  81. (报名信息中的手机号码将用于联系信息)
  82. </view>
  83. <!-- <view slot="footer">
  84. <image class="bottom-image" :src="appImg.common.address_bottom"></image>
  85. </view> -->
  86. </app-order-submit-row>
  87. </template>
  88. </view>
  89. </template>
  90. <view class="mch-list">
  91. <view v-for="(mch, mchIndex) in previewData.mch_list" :key="mchIndex" class="mch-item">
  92. <!-- <view class="mch-name">{{mch.mch.name}}</view> -->
  93. <!-- <view v-if="mch.show_delivery !== false" class="dir-left-nowrap cross-center delivery">
  94. <view class="box-grow-1">配送方式</view>
  95. <view class="box-grow-0">
  96. <view v-for="(sendType, sendTypeIndex) in mch.delivery.send_type_list"
  97. :key="sendTypeIndex"
  98. class="send-type"
  99. :class="sendType.value == mch.delivery.send_type ? `${theme}-background` : 'weak-two-background'"
  100. @click="changeSendType(mchIndex,sendType.value)">
  101. {{sendType.name}}
  102. </view>
  103. </view>
  104. </view> -->
  105. <view class="pick-up cross-center" v-if="!mch.pick_up_enable">
  106. <view>以下商品满{{mch.pick_up_price}}元起送</view>
  107. </view>
  108. <view v-if="mch.delivery.send_type == 'offline'" class="store">
  109. <app-order-submit-row v-if="mch.no_store && mch.no_store === true" :show-nav="false">
  110. 暂无门店,请选择其他配送方式
  111. </app-order-submit-row>
  112. <app-order-submit-row v-else @click="navigateStore(mchIndex)" :show-nav="mch.mch.id == 0">
  113. <!-- <view slot="header" class="title">门店信息</view> -->
  114. <template v-if="mch.store">
  115. <view class="dir-left-nowrap mb-12">
  116. <view class="box-grow-1">{{mch.store.name}}</view>
  117. <view class="box-grow-0 location">
  118. <image class="icon" src="/static/image/icon/location.png"></image>
  119. <view v-if="getLocationFail" class="inline-block">
  120. <view class="inline-block">定位失败</view>
  121. <view class="inline-block open-location-setting" @click.stop="openLocationSetting">
  122. <view class="open-location-btn" :class="[
  123. `${theme}-color`, `${theme}-border`,
  124. ]">获取位置
  125. </view>
  126. </view>
  127. </view>
  128. <view v-else class="inline-block">距离您{{mch.store.distance}}</view>
  129. </view>
  130. </view>
  131. <view class="store-address">{{mch.store.address}}</view>
  132. </template>
  133. <view v-else>请选择场地</view>
  134. </app-order-submit-row>
  135. </view>
  136. <view v-else-if="mch.delivery.send_type == 'city' && mch.city" class="city">
  137. <template v-if="mch.city.error">
  138. <view class="dir-left-nowrap cross-center">
  139. <view class="box-grow-1 t-omit error">{{mch.city.error}}</view>
  140. <view class="box-grow-0 btn" @click="jump(mchIndex)">查看配送范围</view>
  141. </view>
  142. </template>
  143. <template v-else>
  144. <view class="t-omit">发货地址:{{mch.city.address}}</view>
  145. <view class="t-omit" v-if="mch.city.explain">{{mch.city.explain}}</view>
  146. <view class="dir-left-nowrap cross-center">
  147. <view class="box-grow-1 t-omit error" style="color: #353535;">该地址在配送范围内</view>
  148. <view class="box-grow-0 btn" @click="jump(mchIndex)">查看配送范围</view>
  149. </view>
  150. </template>
  151. </view>
  152. <app-submit-goods v-on:updateList="updateList" :index="mchIndex" :plugin="plugin" :list="mch"></app-submit-goods>
  153. <template v-if="mch.insert_rows && mch.insert_rows.length">
  154. <view v-for="(insertRow, insertRowIndex) in mch.insert_rows" :key="insertRowIndex">
  155. <app-order-submit-row :show-nav="false">
  156. <view class="dir-left-nowrap">
  157. <view class="box-grow-1">{{insertRow.title}}</view>
  158. <view class="box-grow-0" :class="[`${theme}-color`]">{{insertRow.value}}</view>
  159. </view>
  160. </app-order-submit-row>
  161. </view>
  162. </template>
  163. <view v-if="mch.coupon && mch.coupon.enabled" class="coupon" @click="navigateCoupon(mchIndex)">
  164. <app-order-submit-row>
  165. <view class="dir-left-nowrap">
  166. <view class="box-grow-1">优惠券</view>
  167. <view class="box-grow-0" v-if="mch.coupon.use" :class="[`${theme}-color`]">
  168. 已优惠{{mch.coupon.coupon_discount}}元
  169. </view>
  170. <view class="box-grow-0 tip" v-else>选择优惠券</view>
  171. </view>
  172. </app-order-submit-row>
  173. </view>
  174. <view v-if="mch.integral && mch.integral.can_use" class="integral">
  175. <app-order-submit-row :show-nav="false">
  176. <view class="dir-left-nowrap">
  177. <view class="box-grow-1 dir-left-nowrap">
  178. <view>
  179. 使用
  180. {{mch.integral.use_num}}
  181. 积分抵扣
  182. <text :class="[`${theme}-color`]">{{mch.integral.deduction_price}}</text>
  183. </view>
  184. <view class="tip-btn" @click="showIntegralTip">
  185. <image class="icon" src="/static/image/icon/warning.png"></image>
  186. </view>
  187. </view>
  188. <view class="box-grow-0">
  189. <app-radio type="round" :value="mch.integral.use" :theme="theme" @input="changeIntegral(mchIndex)"></app-radio>
  190. </view>
  191. </view>
  192. </app-order-submit-row>
  193. <!-- <view>
  194. </view> -->
  195. </view>
  196. <!-- <view v-if="mch.show_express_price !== false">
  197. <app-order-submit-row :show-nav="false" :showBorder="false">
  198. <view class="dir-left-nowrap">
  199. <view class="box-grow-1">运费</view>
  200. <view class="box-grow-0 express-price" :class="[`${theme}-color`]">
  201. <template v-if="mch.express_price_origin && mch.express_price_desc">
  202. <view>¥{{mch.express_price_origin}}元</view>
  203. <view class="express-price-desc">{{mch.express_price_desc}}
  204. </view>
  205. </template>
  206. <view v-else>¥{{mch.express_price}}元</view>
  207. </view>
  208. </view>
  209. </app-order-submit-row>
  210. </view> -->
  211. <view v-if="mch.order_form && mch.order_form.status == '1'">
  212. <app-diy-form :title="mch.order_form.name" :list="mch.order_form.value" @input="handleOrderFormInput" @validate="handleOrderFormValidate"
  213. :sign="mchIndex" label-position="top" :show-scroll-btn="mch.order_form.show_scroll"></app-diy-form>
  214. </view>
  215. <view v-else-if="mch.show_remark !== false && mch.has_goods_form !== true" class="remark">
  216. <app-input @input="inputRemark(mchIndex)" v-model="mch.remark" placeholder="买家留言" height="100"></app-input>
  217. </view>
  218. <!-- <view v-for="(item,index) in mch.goods_list" :key="index">
  219. <view v-if="item.form_batch.length!=0">
  220. <app-diy-form v-for="(ite,idx) in item.form_batch" :key="idx" :title="ite.name" :list="ite.value" @input="handleOrderFormInput"
  221. @validate="handleOrderFormValidate" :sign="mchIndex" label-position="top"></app-diy-form>
  222. </view>
  223. </view> -->
  224. <view v-for="(item,index) in mch.goods_list" :key="index">
  225. <app-diy-form :key="idx" :title="item.form_batch_group.name" :list="item.form_batch_group.value" @input="handleOrderFormInput"
  226. @validate="handleOrderFormValidate" :sign="mchIndex" label-position="top"></app-diy-form>
  227. </view>
  228. <template v-if="mch.has_goods_form">
  229. <view v-for="(goodsItem, goodsIndex) in mch.goods_list" :key="goodsIndex" v-if="goodsItem.form && !goodsItem.form.same_form"
  230. style="margin-bottom: 20rpx">
  231. <view style="padding: 24rpx; color: #666666">{{goodsItem.form.name}}</view>
  232. <view class="goods-list" v-if="mch.diff_goods_form_count !== 1">
  233. <view v-for="(subGoodsItem, subGoodsIndex) in mch.goods_list" :key="subGoodsIndex" v-if="subGoodsItem.form && subGoodsItem.form.id == goodsItem.form.id"
  234. class="dir-left-nowrap goods-item">
  235. <view class="box-grow-0">
  236. <image class="goods-image" :src="subGoodsItem.goods_attr.pic_url ? subGoodsItem.goods_attr.pic_url : subGoodsItem.cover_pic"></image>
  237. </view>
  238. <view class="box-grow-1">
  239. <view class="goods-name">{{subGoodsItem.name}}</view>
  240. <view class="dir-left-wrap attr-list">
  241. <view v-for="(attrItem,attrIndex) in subGoodsItem.attr_list" :key="attrIndex" class="attr-item">
  242. {{attrItem.attr_group_name}}:{{attrItem.attr_name}}
  243. </view>
  244. </view>
  245. <view class="dir-left-nowrap">
  246. <!-- <view class="box-grow-1 goods-num">×{{subGoodsItem.num}}</view> -->
  247. <view class="box-grow-1 goods-num"></view>
  248. <view class="box-grow-0 goods-price-info" :class="[`${theme}-color`]">
  249. <view>
  250. <text v-for="(customCurrency,customCurrencyIndex) in subGoodsItem.custom_currency" :key="customCurrencyIndex">
  251. {{customCurrency}}+
  252. </text>
  253. <text class="goods-price-unit">¥</text>
  254. <text>{{subGoodsItem.total_original_price}}</text>
  255. </view>
  256. <view v-for="(discount,discountIndex) in subGoodsItem.discounts" :key="discountIndex">
  257. {{discount.name}}: {{discount.value}}
  258. </view>
  259. </view>
  260. </view>
  261. </view>
  262. </view>
  263. </view>
  264. <app-diy-form :list="goodsItem.form.value" @input="handleGoodsFormInput" @validate="handleGoodsFormValidate"
  265. :sign="`${mchIndex},${goodsIndex},${goodsItem.form.id}`"></app-diy-form>
  266. <!-- <view class="upload-form">
  267. <view class="upload-form-title">
  268. 上传报名表
  269. </view>
  270. <view class="Course-right">
  271. <image src="../../static/image/share/img-share-right.png" mode=""></image>
  272. </view>
  273. </view> -->
  274. </view>
  275. </template>
  276. </view><!-- mch item end -->
  277. </view>
  278. </view>
  279. <view>
  280. <view class="submit-bar dir-left-nowrap" v-if="previewData">
  281. <view class="box-grow-1 cross-center order-info" :class="[`${theme}-color`]">
  282. <view style="display: inline-block;">{{totalTitle}}:</view>
  283. <view style="display: inline-block;" v-for="custom_currency in previewData.custom_currency_all" :key="custom_currency">
  284. {{custom_currency}}+
  285. </view>
  286. <view style="display: inline-block;white-space: nowrap;">¥{{previewData.total_price}}
  287. <view style="content: ' ';display: inline-block;width: 20rpx;"></view>
  288. </view>
  289. </view>
  290. <template v-if="previewData.address_enable && previewData.price_enable">
  291. <view @click="subscribe" class="submit-btn box-grow-0 cross-center" :class="[`${theme}-background`, submitLock?'lock':'']">
  292. <view style="background-color: transparent;color:#ffffff;">提交</view>
  293. </view>
  294. </template>
  295. <template v-else>
  296. <view v-if="!previewData.address_enable" class="submit-btn box-grow-0 cross-center disabled" :class="[`${theme}-background`]">
  297. <view style="background-color: transparent;">该地区无货</view>
  298. </view>
  299. <view v-else class="submit-btn box-grow-0 cross-center disabled" :class="[`${theme}-background`]">
  300. <view style="background-color: transparent;">未达起送要求</view>
  301. </view>
  302. </template>
  303. </view>
  304. </view>
  305. </app-layout>
  306. </template>
  307. <script>
  308. import {
  309. mapState
  310. } from 'vuex';
  311. import AppRadio from '../../components/basic-component/app-radio/app-radio.vue';
  312. import AppOrderSubmitRow from './app-order-submit-row.vue';
  313. import AppDiyForm from "../../components/page-component/app-diy-form/app-diy-form";
  314. import appSubmitGoods from '../../components/basic-component/app-submit-goods/app-submit-goods.vue';
  315. export default {
  316. name: 'order-submit',
  317. components: {
  318. AppDiyForm,
  319. AppRadio,
  320. AppOrderSubmitRow,
  321. appSubmitGoods
  322. },
  323. data() {
  324. return {
  325. totalTitle: '合计',
  326. check: false,
  327. previewData: null,
  328. getLocationFail: false,
  329. previewUrl: null,
  330. submitUrl: null,
  331. plugin: null,
  332. orderPageUrl: null,
  333. submitLock: false,
  334. getPayDataTimer: null,
  335. userTheme: null,
  336. payDataUrl: null,
  337. showPayResult: true,
  338. payCancelUrl: null,
  339. date: [],
  340. };
  341. },
  342. computed: {
  343. ...mapState({
  344. appImg: state => state.mallConfig.__wxapp_img,
  345. }),
  346. theme() {
  347. return this.userTheme ? this.userTheme : this.$store.state.mallConfig.theme;
  348. },
  349. },
  350. onLoad(options) {
  351. if (this.submitLock) return;
  352. this.setFormData(options);
  353. this.$event.on(this.$const.EVENT_USER_LOGIN).then(() => {
  354. this.loadPreviewData();
  355. });
  356. },
  357. onShow() {
  358. if (this.submitLock) return;
  359. // #ifdef MP-BAIDU
  360. setTimeout(() => {
  361. this.loadPreviewData();
  362. }, 50);
  363. // #endif
  364. // #ifndef MP-BAIDU
  365. this.loadPreviewData();
  366. // #endif
  367. },
  368. onHide() {
  369. console.log('onHide');
  370. },
  371. onUnload() {
  372. console.log('onUnload');
  373. if (this.getPayDataTimer) {
  374. clearTimeout(this.getPayDataTimer);
  375. }
  376. },
  377. watch: {
  378. 'previewData.address.name': {
  379. handler() {
  380. this.changeZitiAddress();
  381. },
  382. },
  383. 'previewData.address.mobile': {
  384. handler() {
  385. this.changeZitiAddress();
  386. },
  387. },
  388. },
  389. methods: {
  390. verifyUndefined(value) {
  391. if (typeof(value) == 'undefined' || value == '' || value == 'undefined') {
  392. console.log(typeof(value))
  393. return '暂无数据'
  394. } else {
  395. console.log(typeof(value))
  396. return value
  397. }
  398. },
  399. updateList(e, index) {
  400. this.previewData.mch_list[index] = e;
  401. console.log(this.previewData.mch_list)
  402. this.$forceUpdate();
  403. },
  404. setParams(options) {
  405. if (options.total_title) {
  406. this.totalTitle = options.total_title;
  407. }
  408. },
  409. // 输入时数据
  410. handleOrderFormInput(data, sign) {
  411. const result = [];
  412. for (let i in data) {
  413. if (data[i].name == "预约人") {
  414. this.previewData.address.name = data[i].value
  415. } else if (data[i].name == "联系方式") {
  416. this.previewData.address.mobile = data[i].value
  417. } else {
  418. result.push({
  419. key: data[i].key,
  420. label: data[i].name,
  421. value: data[i].value,
  422. required: data[i].is_required,
  423. })
  424. }
  425. }
  426. const formData = this.$store.state.orderSubmit.formData;
  427. if (formData.list[sign].order_form.length < 35) {
  428. formData.list[sign].order_form.push(...data);
  429. this.$store.commit('orderSubmit/mutSetFormData', formData);
  430. }
  431. console.log(formData.list[sign].order_form)
  432. },
  433. handleOrderFormValidate(result, sign) {
  434. // console.log('handleOrderFormValidate:', result, sign);
  435. console.log(result)
  436. const formData = this.$store.state.orderSubmit.formData;
  437. formData.list[sign].order_form_validate_result = result;
  438. this.$store.commit('orderSubmit/mutSetFormData', formData);
  439. },
  440. setFormData(options) {
  441. this.previewUrl = decodeURIComponent(options.preview_url || this.$api.order.preview);
  442. this.submitUrl = decodeURIComponent(options.submit_url || this.$api.order.submit);
  443. this.plugin = options.plugin || null;
  444. console.log(options.plugin);
  445. this.orderPageUrl = decodeURIComponent(options.order_page_url || '/pages/order/index/index?status=0');
  446. this.userTheme = options.theme || null;
  447. this.payDataUrl = decodeURIComponent(options.pay_data_url || this.$api.order.pay_data);
  448. this.payCancelUrl = options.pay_cancel_url ? decodeURIComponent(options.pay_cancel_url) : null;
  449. this.showPayResult = options.show_pay_result || true;
  450. if (this.showPayResult === 'true') this.showPayResult = true;
  451. if (this.showPayResult === 'false') this.showPayResult = false;
  452. const list = JSON.parse(options.mch_list);
  453. for (let i in list) {
  454. list[i].distance = 0;
  455. list[i].remark = '';
  456. list[i].order_form = [];
  457. list[i].use_integral = 0;
  458. list[i].user_coupon_id = 0;
  459. for (let j in list[i].goods_list) {
  460. list[i].goods_list[j].cart_id = list[i].goods_list[j].cart_id || 0;
  461. }
  462. }
  463. this.$store.commit('orderSubmit/mutSetFormData', {
  464. list: list,
  465. address_id: 0,
  466. });
  467. },
  468. // 初始化数据
  469. loadPreviewData() {
  470. let that = this
  471. uni.showLoading({
  472. mask: true,
  473. title: '加载中',
  474. });
  475. uni.getStorage({
  476. key: 'date',
  477. success: function(res) {
  478. console.log(res.data)
  479. that.date = res.data
  480. }
  481. })
  482. this.$request({
  483. url: this.previewUrl,
  484. method: 'post',
  485. data: {
  486. form_data: JSON.stringify(this.$store.state.orderSubmit.formData),
  487. },
  488. }).then(response => {
  489. uni.hideLoading();
  490. if (response.code === 0) {
  491. if (response.data.allZiti && !response.data.address) {
  492. response.data.address = {
  493. name: '',
  494. mobile: '',
  495. };
  496. }
  497. this.previewData = response.data;
  498. console.log(this.previewData)
  499. this.previewData.mch_list[0].order_form.value.forEach((item, index) => {
  500. console.log(item, 'diy数据')
  501. if (item.name == "预约人") {
  502. item.value = this.previewData.address.name
  503. } else if (item.name == "联系方式") {
  504. item.value = this.previewData.address.mobile
  505. } else if (item.name == "预约日期") {
  506. console.log(this.date, '进入了里面')
  507. item.value = `${this.date.date},${this.date.week}`
  508. }
  509. })
  510. this.setDiyFormScrollStatus();
  511. this.checkCouponError();
  512. this.updateStoreDistance();
  513. } else {
  514. uni.showModal({
  515. title: '提示',
  516. content: response.msg,
  517. showCancel: false,
  518. success: () => {
  519. uni.navigateBack();
  520. },
  521. });
  522. }
  523. }).catch(() => {
  524. uni.hideLoading();
  525. });
  526. },
  527. navigateAddress() {
  528. let url = '/pages/order-submit/address-pick';
  529. url += '?hasCity=' + this.previewData.hasCity;
  530. uni.navigateTo({
  531. url: url,
  532. });
  533. },
  534. navigateStore(mchIndex) {
  535. if (this.previewData.mch_list[mchIndex].mch.id != 0) {
  536. return;
  537. }
  538. let firstGoodsId = '';
  539. if (this.plugin === 'booking') {
  540. firstGoodsId = this.previewData.mch_list[0].goods_list[0].id;
  541. }
  542. let plugin = this.plugin || '';
  543. uni.navigateTo({
  544. url: `/pages/order-submit/store-pick?mchIndex=${mchIndex}&plugin=${plugin}&firstGoodsId=${firstGoodsId}`,
  545. });
  546. },
  547. navigateCoupon(mchIndex) {
  548. uni.navigateTo({
  549. url: `/pages/order-submit/coupon-pick?mchIndex=${mchIndex}`,
  550. });
  551. },
  552. changeZitiAddress() {
  553. const formData = this.$store.state.orderSubmit.formData;
  554. formData.address = {
  555. name: this.previewData.address.name,
  556. mobile: this.previewData.address.mobile,
  557. };
  558. this.$store.commit('orderSubmit/mutSetFormData', formData);
  559. },
  560. changeSendType(mchIndex, value) {
  561. if (this.previewData.mch_list[mchIndex].delivery.send_type == value) return;
  562. const formData = this.$store.state.orderSubmit.formData;
  563. formData.list[mchIndex].send_type = value;
  564. this.$store.commit('orderSubmit/mutSetFormData', formData);
  565. this.previewData.mch_list[mchIndex].delivery.send_type = value;
  566. this.loadPreviewData();
  567. },
  568. updateStoreDistance() {
  569. if (!this.previewData) return;
  570. if (!this.previewData.has_ziti && this.plugin != 'booking') {
  571. return;
  572. }
  573. uni.getLocation({
  574. success: (res) => {
  575. for (let i in this.previewData.mch_list) {
  576. if (!this.previewData.mch_list[i].store) {
  577. continue;
  578. }
  579. if (this.previewData.mch_list[i].store.distance &&
  580. this.previewData.mch_list[i].store.distance != '-m') {
  581. continue;
  582. }
  583. const distance = this.$utils.earthDistance({
  584. lat: res.latitude,
  585. lng: res.longitude
  586. }, {
  587. lat: this.previewData.mch_list[i].store.latitude,
  588. lng: this.previewData.mch_list[i].store.longitude
  589. });
  590. let distanceStr = '-m';
  591. if (distance > 1000) {
  592. distanceStr = (distance / 1000).toFixed(2) + 'km';
  593. } else {
  594. distanceStr = distance.toFixed(0) + 'm';
  595. }
  596. this.previewData.mch_list[i].store.distance = distanceStr;
  597. }
  598. },
  599. fail: () => {
  600. this.getLocationFail = true;
  601. },
  602. });
  603. },
  604. openLocationSetting() {
  605. this.getLocationFail = false;
  606. uni.openSetting({});
  607. },
  608. showIntegralTip() {
  609. uni.showModal({
  610. title: '积分抵扣说明',
  611. content: this.$store.state.mallConfig.mall.setting.member_integral_rule,
  612. showCancel: false,
  613. });
  614. },
  615. changeIntegral(mchIndex) {
  616. const formData = this.$store.state.orderSubmit.formData;
  617. const use = !this.previewData.mch_list[mchIndex].integral.use;
  618. formData.list[mchIndex].use_integral = use ? 1 : 0;
  619. this.previewData.mch_list[mchIndex].integral.use = use;
  620. this.loadPreviewData();
  621. },
  622. inputRemark(mchIndex) {
  623. const formData = this.$store.state.orderSubmit.formData;
  624. formData.list[mchIndex].remark = this.previewData.mch_list[mchIndex].remark;
  625. this.$store.commit('orderSubmit/mutSetFormData', formData);
  626. },
  627. submit() {
  628. uni.showLoading({
  629. mask: true,
  630. title: '提交中',
  631. });
  632. let formData = this.$store.state.orderSubmit.formData
  633. let order_form = formData.list[0].order_form
  634. console.log(formData)
  635. this.$request({
  636. url: this.submitUrl,
  637. method: 'post',
  638. data: {
  639. form_data: JSON.stringify(this.$store.state.orderSubmit.formData),
  640. },
  641. }).then(response => {
  642. if (this.previewData.is_train) {
  643. uni.hideLoading();
  644. uni.showModal({
  645. title: "提示",
  646. content: "提交成功,请等待审核",
  647. showCancel: false,
  648. success() {
  649. uni.redirectTo({
  650. url: '/pages/order/index/index?status=0',
  651. });
  652. }
  653. })
  654. } else {
  655. if (response.code === 0) {
  656. this.getPayOrderId(response.data.queue_id, response.data.token);
  657. } else {
  658. this.submitLock = false;
  659. uni.hideLoading();
  660. uni.showModal({
  661. title: '提示',
  662. content: response.msg,
  663. showCancel: false,
  664. });
  665. }
  666. }
  667. }).catch(e => {
  668. this.submitLock = false;
  669. uni.hideLoading();
  670. uni.showModal({
  671. title: '提示',
  672. content: e.errMsg,
  673. showCancel: false,
  674. });
  675. });
  676. },
  677. getPayOrderId(queue_id, token) {
  678. this.$request({
  679. url: this.payDataUrl,
  680. method: 'post',
  681. data: {
  682. queue_id: queue_id,
  683. token: token,
  684. },
  685. }).then(response => {
  686. if (response.code === 0) {
  687. if (response.data.retry && response.data.retry === 1) {
  688. this.getPayDataTimer = setTimeout(() => {
  689. this.getPayOrderId(queue_id, token);
  690. }, 1000);
  691. } else {
  692. console.log(response);
  693. uni.hideLoading();
  694. this.pay(response.data);
  695. }
  696. } else {
  697. this.submitLock = false;
  698. uni.hideLoading();
  699. uni.showModal({
  700. title: '提示',
  701. content: response.msg,
  702. showCancel: false,
  703. });
  704. }
  705. }).catch(e => {
  706. this.submitLock = false;
  707. uni.hideLoading();
  708. uni.showModal({
  709. title: '提示',
  710. content: e.errMsg,
  711. showCancel: false,
  712. });
  713. });
  714. },
  715. pay(data) {
  716. this.$payment.pay(data.id).then(res => {
  717. console.log('支付成功', res);
  718. if (this.showPayResult) {
  719. uni.redirectTo({
  720. url: `/pages/order-submit/pay-result?payment_order_union_id=${data.id}&order_page_url=${encodeURIComponent(this.orderPageUrl)}`,
  721. });
  722. } else {
  723. let page_url = this.orderPageUrl;
  724. if (page_url.indexOf('?') === -1) {
  725. page_url += '?'
  726. } else {
  727. page_url += '&';
  728. }
  729. delete data.id;
  730. page_url += `pay_data=${JSON.stringify(data)}`;
  731. uni.redirectTo({
  732. url: page_url,
  733. });
  734. }
  735. }).catch(e => {
  736. console.log('支付失败', e);
  737. if (this.payCancelUrl) {
  738. let page_url = this.payCancelUrl;
  739. if (page_url.indexOf('?') === -1) {
  740. page_url += '?'
  741. } else {
  742. page_url += '&';
  743. }
  744. page_url += `pay_data=${JSON.stringify(data)}`;
  745. uni.redirectTo({
  746. url: page_url,
  747. });
  748. } else {
  749. uni.showModal({
  750. title: '提交失败',
  751. content: e.errMsg,
  752. showCancel: false,
  753. success: () => {
  754. uni.redirectTo({
  755. url: this.orderPageUrl,
  756. });
  757. },
  758. });
  759. console.log(this.orderPageUrl)
  760. }
  761. });
  762. },
  763. jump(mchIndex) {
  764. uni.navigateTo({
  765. url: `/pages/order-submit/map`,
  766. });
  767. },
  768. checkCouponError() {
  769. for (let i in this.previewData.mch_list) {
  770. if (this.previewData.mch_list[i].coupon && this.previewData.mch_list[i].coupon.coupon_error) {
  771. uni.showModal({
  772. title: '',
  773. content: this.previewData.mch_list[i].coupon.coupon_error,
  774. showCancel: false,
  775. });
  776. return;
  777. }
  778. }
  779. },
  780. setDiyFormScrollStatus() {
  781. console.log('this.previewData.mch_list--->', this.previewData.mch_list);
  782. for (let i in this.previewData.mch_list) {
  783. if (
  784. this.previewData.mch_list[i].order_form
  785. ) {
  786. if (
  787. this.previewData.mch_list[i].order_form.value &&
  788. this.previewData.mch_list[i].order_form.value.length &&
  789. this.previewData.mch_list[i].order_form.value.length >= 5
  790. ) {
  791. this.previewData.mch_list[i].order_form.show_scroll = true;
  792. } else {
  793. this.previewData.mch_list[i].order_form.show_scroll = false;
  794. }
  795. }
  796. }
  797. },
  798. subscribe() {
  799. console.log(this.$store.state.orderSubmit.formData.list)
  800. for (let i in this.$store.state.orderSubmit.formData.list) {
  801. const item = this.$store.state.orderSubmit.formData.list[i];
  802. if (!item.order_form_validate_result) continue;
  803. if (item.order_form_validate_result.hasError) {
  804. uni.showModal({
  805. title: '提示',
  806. content: item.order_form_validate_result.errors[0].msg,
  807. showCancel: false,
  808. });
  809. return;
  810. }
  811. }
  812. for (let i in this.$store.state.orderSubmit.formData.list) {
  813. for (let j in this.$store.state.orderSubmit.formData.list[i].goods_list) {
  814. const item = this.$store.state.orderSubmit.formData.list[i].goods_list[j];
  815. console.log(item)
  816. if (!item.goods_form_validate_result) continue;
  817. if (item.goods_form_validate_result.hasError) {
  818. uni.showModal({
  819. title: '提示',
  820. content: item.goods_form_validate_result.errors[0].msg,
  821. showCancel: false,
  822. });
  823. return;
  824. }
  825. }
  826. }
  827. if (this.submitLock) return;
  828. this.submitLock = true;
  829. this.$subscribe(this.previewData.template_message_list).then(res => {
  830. this.submit();
  831. }).catch(res => {
  832. this.submit();
  833. });
  834. },
  835. handleGoodsFormInput(data, sign) {
  836. const signArr = sign.split(',');
  837. const mchIndex = parseInt(signArr[0]);
  838. const goodsIndex = parseInt(signArr[1]);
  839. const formId = parseInt(signArr[2]);
  840. const result = [];
  841. for (let i in data) {
  842. result[i] = {
  843. key: data[i].key,
  844. label: data[i].name,
  845. value: data[i].value,
  846. required: data[i].is_required,
  847. };
  848. }
  849. const formData = this.$store.state.orderSubmit.formData;
  850. formData.list[mchIndex].goods_list[goodsIndex].form_data = result;
  851. this.$store.commit('orderSubmit/mutSetFormData', formData);
  852. },
  853. handleGoodsFormValidate(result, sign) {
  854. const signArr = sign.split(',');
  855. const mchIndex = parseInt(signArr[0]);
  856. const goodsIndex = parseInt(signArr[1]);
  857. const formData = this.$store.state.orderSubmit.formData;
  858. formData.list[mchIndex].goods_list[goodsIndex].goods_form_validate_result = result;
  859. this.$store.commit('orderSubmit/mutSetFormData', formData);
  860. },
  861. },
  862. }
  863. </script>
  864. <style scoped lang="scss">
  865. $submitBarHeight: #{110rpx};
  866. $borderColor: $uni-weak-color-one;
  867. $xWidth: #{24rpx};
  868. $yWidth: #{24rpx};
  869. .felx-three {
  870. display: flex;
  871. align-items: center;
  872. justify-content: space-around;
  873. padding-bottom: 23rpx;
  874. .box-grow-2,
  875. .box-grow-3,
  876. .box-grow-4 {
  877. font-size: 24rpx;
  878. font-family: Source Han Sans CN;
  879. font-weight: 400;
  880. color: rgba(100, 100, 100, 1);
  881. overflow: hidden;
  882. text-overflow: ellipsis;
  883. white-space: nowrap;
  884. }
  885. .box-grow-2 {
  886. width: 30%;
  887. }
  888. .box-grow-3 {
  889. width: 30%;
  890. }
  891. .box-grow-4 {
  892. width: 40%;
  893. }
  894. .box-grow-5 {
  895. width: 100%;
  896. font-size: 24rpx;
  897. font-family: Source Han Sans CN;
  898. font-weight: 400;
  899. color: rgba(100, 100, 100, 1);
  900. overflow: hidden;
  901. text-overflow: ellipsis;
  902. white-space: nowrap;
  903. }
  904. }
  905. .pick-up {
  906. margin-top: #{20rpx};
  907. background: #fff4f3;
  908. height: #{80rpx};
  909. width: 100%;
  910. padding: 0 #{24rpx};
  911. font-size: #{28rpx};
  912. color: #353535;
  913. }
  914. .px-12 {
  915. padding-left: #{12rpx};
  916. padding-right: #{12rpx};
  917. }
  918. .mb-12 {
  919. margin-bottom: #{12rpx};
  920. }
  921. .page {
  922. min-height: 100%;
  923. border-top: #{1rpx} solid $borderColor;
  924. padding-bottom: $submitBarHeight;
  925. .address {
  926. // margin-bottom: $yWidth;
  927. .bottom-image {
  928. width: 100%;
  929. height: #{8rpx};
  930. display: block;
  931. }
  932. }
  933. .mch-list {
  934. .mch-name {
  935. background-color: #fff;
  936. padding: $yWidth $xWidth;
  937. }
  938. .delivery {
  939. background: #fff;
  940. padding: $yWidth $xWidth;
  941. .send-type {
  942. display: inline-block;
  943. padding: #{8rpx} #{24rpx};
  944. border-radius: #{100rpx};
  945. margin-right: $xWidth;
  946. font-size: $uni-font-size-general-one;
  947. }
  948. .send-type:last-child {
  949. margin-right: 0;
  950. }
  951. .send-type.active {
  952. color: #fff;
  953. }
  954. }
  955. .store {
  956. .title {
  957. padding: $yWidth $xWidth 0;
  958. }
  959. .store-address {
  960. color: $uni-general-color-two;
  961. }
  962. .location {
  963. padding: 0 #{48rpx};
  964. .icon {
  965. width: #{22rpx};
  966. height: #{26rpx};
  967. margin-right: #{12rpx};
  968. }
  969. .inline-block {
  970. display: inline-block;
  971. vertical-align: top;
  972. }
  973. .open-location-setting {
  974. margin-top: -#{2rpx};
  975. padding-left: #{12rpx};
  976. }
  977. .open-location-btn {
  978. font-size: $uni-font-size-weak-one;
  979. height: #{44rpx};
  980. line-height: #{42rpx};
  981. padding: 0 #{16rpx};
  982. border: #{1rpx} solid;
  983. border-radius: #{1000rpx};
  984. }
  985. }
  986. }
  987. .city {
  988. padding: #{32rpx} #{24rpx};
  989. background-color: #ffffff;
  990. margin-bottom: #{20rpx};
  991. font-size: $uni-font-size-general-one;
  992. .error {
  993. color: #ff4544;
  994. margin-right: #{24rpx};
  995. }
  996. .btn {
  997. padding: #{10rpx} #{20rpx};
  998. border-radius: #{100rpx};
  999. border: #{1rpx} solid #cccccc;
  1000. font-size: $uni-font-size-general-two;
  1001. color: $uni-general-color-one;
  1002. }
  1003. }
  1004. .goods-list {
  1005. border-bottom: #{1rpx} solid $borderColor;
  1006. .goods-item {
  1007. background: #fff;
  1008. padding: #{24rpx};
  1009. .goods-image {
  1010. width: #{200rpx};
  1011. height: #{200rpx};
  1012. display: block;
  1013. margin-right: #{24rpx};
  1014. }
  1015. .goods-name {
  1016. font-size: 24rpx;
  1017. font-family: Source Han Sans CN;
  1018. font-weight: 400;
  1019. color: rgba(72, 72, 72, 1);
  1020. height: #{84rpx};
  1021. line-height: #{42rpx};
  1022. display: -webkit-box;
  1023. -webkit-box-orient: vertical;
  1024. -webkit-line-clamp: 2;
  1025. overflow: hidden;
  1026. margin-bottom: #{22rpx};
  1027. }
  1028. .attr-list,
  1029. .goods-num {
  1030. font-size: $uni-font-size-weak-one;
  1031. color: $uni-general-color-one;
  1032. }
  1033. .attr-item {
  1034. margin-right: #{24rpx};
  1035. }
  1036. .attr-item:last-child {
  1037. margin-right: 0;
  1038. }
  1039. .goods-price-info {
  1040. text-align: right;
  1041. font-size: $uni-font-size-general-one;
  1042. }
  1043. }
  1044. }
  1045. .express-price {
  1046. text-align: right;
  1047. .express-price-desc {
  1048. font-size: $uni-font-size-weak-one;
  1049. }
  1050. }
  1051. .coupon {
  1052. .active {
  1053. color: $uni-important-color-red;
  1054. }
  1055. .tip {
  1056. color: $uni-general-color-two;
  1057. }
  1058. }
  1059. .integral {
  1060. .tip-btn {
  1061. font-size: 0;
  1062. padding: #{12rpx};
  1063. margin-top: -#{7rpx};
  1064. /* #ifdef MP-ALIPAY*/
  1065. margin-top: -#{14rpx};
  1066. /* #endif*/
  1067. }
  1068. .icon {
  1069. width: #{36rpx};
  1070. height: #{36rpx};
  1071. display: block;
  1072. }
  1073. }
  1074. .remark {
  1075. background: #fff;
  1076. border-bottom: #{1rpx} solid $borderColor;
  1077. padding: 0 #{12rpx};
  1078. }
  1079. }
  1080. }
  1081. .submit-bar {
  1082. background: #fff;
  1083. border-top: #{1rpx} solid $uni-weak-color-two;
  1084. height: $submitBarHeight;
  1085. position: fixed;
  1086. left: 0;
  1087. bottom: 0;
  1088. width: 100%;
  1089. z-index: 1000;
  1090. .order-info {
  1091. padding: 0 #{24rpx};
  1092. }
  1093. .submit-btn {
  1094. height: 100%;
  1095. padding: 0 #{50rpx};
  1096. }
  1097. .submit-btn:active {
  1098. box-shadow: inset 0 0 #{500rpx} rgba(0, 0, 0, .15);
  1099. }
  1100. .submit-btn.lock {
  1101. box-shadow: inset 0 0 #{500rpx} rgba(255, 255, 255, 0.35);
  1102. }
  1103. .submit-btn.disabled {
  1104. background: $uni-general-color-two;
  1105. }
  1106. }
  1107. // .upload-form{
  1108. // width: #{100%};
  1109. // height: #{101upx};
  1110. // background-color: #FFFFFF;
  1111. // padding: 0 13px;
  1112. // font-size: 30upx;
  1113. // font-family: Source Han Sans CN;
  1114. // font-weight: 500;
  1115. // color: #3D3D3D;
  1116. // display: flex;
  1117. // align-items: center;
  1118. // justify-content: space-between;
  1119. // margin-top: 20upx;
  1120. // .Course-right{
  1121. // width: 15upx;
  1122. // height: 28upx;
  1123. // display: flex;
  1124. // align-items: center;
  1125. // justify-content: center;
  1126. // image{
  1127. // width: 100%;
  1128. // height: 100%;
  1129. // }
  1130. // }
  1131. // }
  1132. </style>