_orderId.vue 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154
  1. <template>
  2. <div class="mobile-content mobile-content-long mobile-pay">
  3. <div class="pay-head" @click="openAddrModal">
  4. <template v-if="selectedAddress && selectedAddress.name">
  5. <p class="info">
  6. {{selectedAddress.name}}&nbsp;&nbsp;&nbsp;{{selectedAddress.tel}}
  7. </p>
  8. <div class="addr">
  9. <img src="/images/mobile/center/user/addr-flag.png" alt="">
  10. <span>{{selectedAddress.area + selectedAddress.detailAddress}}</span>
  11. </div>
  12. <i class="iconfont icon-xiangyou fr"></i>
  13. </template>
  14. <template v-else>
  15. <div class="no-addr">暂无收货地址信息</div>
  16. </template>
  17. </div>
  18. <ul class="pay-store-list">
  19. <li class="ps-item" v-for="item in orderData">
  20. <p class="ps-store-name">{{item.storeName}}
  21. <a class="com-mobile-link" @click="linkSaler(item)"><i class="iconfont icon-kefu1"></i>联系卖家</a>
  22. </p>
  23. <div class="ps-goods-info clearfix" @click="showDetailList(item.goods)">
  24. <div class="fl">
  25. <!--<span class="inline-block arrow" @click="goodsScroll('left')">
  26. <i class="iconfont icon-xiangzuo"></i>
  27. </span>-->
  28. <ul class="ps-goods-list">
  29. <li class="inline-block" v-for="goods in item.goods">
  30. <div class="ps-goods-item text-ellipse" :class="{'pg-item-long': item.goods.length === 1}"><span>品牌:</span>{{goods.brName || '-'}}</div>
  31. <div class="ps-goods-item text-ellipse" :class="{'pg-item-long': item.goods.length === 1}"><span>类目:</span>{{goods.kiName || '-'}}</div>
  32. <div class="ps-goods-item text-ellipse" :class="{'pg-item-long': item.goods.length === 1}"><span>型号:</span>{{goods.cmpCode || '-'}}</div>
  33. <div class="ps-goods-item text-ellipse" :class="{'pg-item-long': item.goods.length === 1}"><span>规格:</span>{{goods.spec || '-'}}</div>
  34. </li>
  35. </ul>
  36. <span class="inline-block arrow" @click="goodsScroll('right')">
  37. <i class="iconfont icon-xiangyou"></i>
  38. </span>
  39. </div>
  40. <div class="fr">
  41. <p class="price text-ellipse"><span>{{payData.currency | currencyFilter}}</span>{{item.goodsPrice}}</p>
  42. <p class="count text-ellipse">共{{item.goods.length || 0}}件产品</p>
  43. </div>
  44. </div>
  45. <div class="ps-operate-line" @click="showRuleSet(item.storeid)">
  46. <span class="title">配送方式</span>
  47. <div class="fr">
  48. <div class="inline-block">
  49. <span v-if="fareRule[item.storeid] && fareRule[item.storeid][0]">{{fareRule[item.storeid][0].method | deliveryRuleFilter}}</span>
  50. <span v-if="fareRule[item.storeid] && fareRule[item.storeid][0]">{{fareRule[item.storeid][0].ruleName}}</span>
  51. <span v-if="!(fareRule[item.storeid] && fareRule[item.storeid][0])" class="red">当前地址不支持配送,请与卖家协商处理</span>
  52. </div>
  53. <i class="iconfont icon-xiangyou" v-if="fareRule[item.storeid] && fareRule[item.storeid][0]"></i>
  54. </div>
  55. </div>
  56. <div class="ps-operate-line ps-operate-takeself" v-if="checkShowTakeSelf(item)" @click="showTakeSelfSet(item.storeid)">
  57. <span class="title">自提点</span>
  58. <div class="fr">
  59. <div class="inline-block">
  60. <template v-if="takeSelfData[item.storeid] && takeSelfData[item.storeid]">
  61. <span>{{takeSelfData[item.storeid][0].takename}}</span>
  62. <span>地址:{{takeSelfData[item.storeid][0].area + takeSelfData[item.storeid][0].detailAddress}}</span>
  63. <span>营业时间:{{takeSelfData[item.storeid][0].businesstime}}</span>
  64. </template>
  65. <template v-else>暂无自提点信息</template>
  66. </div>
  67. </div>
  68. </div>
  69. <div class=""></div>
  70. <div class="ps-operate-line">
  71. <span class="title">订单备注</span>
  72. <input type="text" v-model="item.remark" placeholder="选填:填写内容需和卖家协商确认">
  73. </div>
  74. <div class="ps-operate-line ps-price">
  75. <span class="inline-block text-ellipse">
  76. 运费:<span class="ol-price" v-if="item.fare"><span v-if="item.fare.fare > 0">{{item.fare.currencyName | currencyFilter}}</span>{{item.fare.fare || 0}}</span>
  77. </span>
  78. <span class="inline-block text-ellipse">
  79. 店铺合计:<span class="ol-price"><span>{{payData.currency | currencyFilter}}</span>{{item.goodsFarePrice || 0}}</span>
  80. </span>
  81. </div>
  82. </li>
  83. </ul>
  84. <div class="ps-operate-line pay-operate">
  85. <span class="title">支付方式</span>
  86. <div class="fr">
  87. <span>线下支付</span>
  88. <!--<i class="iconfont icon-xiangyou"></i>-->
  89. </div>
  90. </div>
  91. <div class="ps-operate-line pay-invoice" @click="openInvoiceModal">
  92. <span class="title">开具发票</span>
  93. <div class="fr">
  94. <div class="inline-block" :style="!selectedInvoice ? 'line-height: unset;' : ''">
  95. <template v-if="selectedInvoice">
  96. <span>{{selectedInvoice.head}}</span>
  97. <span>{{selectedInvoice.kind === 1205 ? '增值税专用发票' : '增值税普通发票'}}</span>
  98. </template>
  99. <template v-else>
  100. <span>暂不开具发票</span>
  101. </template>
  102. </div>
  103. <i class="iconfont icon-xiangyou"></i>
  104. </div>
  105. </div>
  106. <div class="buy-wrap">
  107. <div class="fr">
  108. <span class="title">实付:</span><span class="ol-price price inline-block text-ellipse"><span>{{payData.currency | currencyFilter}}</span>{{allOrderPrice}}</span>
  109. <button class="buy-btn" @click="confirmOrder">提交订单</button>
  110. </div>
  111. </div>
  112. <!-- 联系卖家弹框start -->
  113. <link-user :infoObj="currentStoreInfo"
  114. :showLink="showLink"
  115. @closeAction="showLink = false">
  116. </link-user>
  117. <!-- 联系卖家弹框end -->
  118. <!-- 产品清单弹框start -->
  119. <modal-wrapper :showModal="showModal"
  120. :title="'产品清单'"
  121. @closeAction="showModal = false">
  122. <ul class="cGoods-list">
  123. <li v-for="cGoods in currentGoods" class="clearfix">
  124. <div class="fl">
  125. <div class="cg-param-line text-ellipse">
  126. <span>品牌:</span>{{cGoods.brName}}
  127. </div>
  128. <div class="cg-param-line text-ellipse">
  129. <span>物料名称(类目):</span>{{cGoods.kiName}}
  130. </div>
  131. <div class="cg-param-line text-ellipse">
  132. <span>型号:</span>{{cGoods.cmpCode}}
  133. </div>
  134. <div class="cg-param-line text-ellipse">
  135. <span>规格:</span>{{cGoods.spec}}
  136. </div>
  137. </div>
  138. <div class="fr">
  139. <p class="ol-price text-ellipse"><span>{{cGoods.currencyName | currencyFilter}}</span>{{cGoods.taxUnitprice}}</p>
  140. <p class="count text-ellipse">x&nbsp;{{cGoods.number}}</p>
  141. </div>
  142. </li>
  143. </ul>
  144. </modal-wrapper>
  145. <!-- 产品清单弹框end -->
  146. <!-- 选择配送方式弹框start -->
  147. <bottom-modal-wrapper :showModal="showDeliveryModal"
  148. :title="'选择配送方式'"
  149. @closeAction="onDeliveryModalClose">
  150. <ul class="delivery-rule-list">
  151. <li v-for="cdr in fareRule[currentDeliveryStoreId]" @click="checkDelivery(cdr)">
  152. <label class="bottom-modal-check mobile-cart-check" :class="{'active': cdr.$checked}">
  153. <input type="checkbox">
  154. <span>{{cdr.method | deliveryRuleFilter}}</span>
  155. </label>
  156. <div class="fr" v-if="cdr.fare && cdr.fare > 0">运费:<span class="ol-price"><span>{{cdr.currencyName | currencyFilter}}</span>{{cdr.fare}}</span></div>
  157. </li>
  158. </ul>
  159. </bottom-modal-wrapper>
  160. <!-- 选择配送方式弹框end -->
  161. <!-- 选择发票弹框start -->
  162. <modal-wrapper :showModal="showInvoiceModal"
  163. :title="'选择发票'"
  164. @closeAction="showInvoiceModal = false">
  165. <ul class="invoice-list">
  166. <li @click="setInvoiceCheck(-1)">
  167. <label class="bottom-modal-check mobile-cart-check" :class="{active: selectedInvoiceIndex === -1}">
  168. <input type="checkbox">
  169. </label>
  170. <span class="inv-head">暂不开票</span>
  171. </li>
  172. <li v-for="(inv, index) in invoiceData" @click="setInvoiceCheck(index)">
  173. <label class="bottom-modal-check mobile-cart-check" :class="{'active': selectedInvoiceIndex === index}">
  174. <input type="checkbox">
  175. </label>
  176. <span class="inv-head inline-block text-ellipse">{{inv.head}}</span>
  177. <img class="inv-type" :src="`/images/mobile/center/user/${inv.kind === 1205 ? 'invoice-spec' : 'invoice-nor'}.png`" alt="">
  178. <div class="content-line" v-if="inv.kind === 1205">
  179. <div class="title inline-block">单位地址:</div>
  180. <div class="content inline-block">{{inv.companyAddress || '-'}}</div>
  181. </div>
  182. <div class="content-line" v-if="inv.kind === 1205">
  183. <div class="title inline-block">单位电话:</div>
  184. <div class="content inline-block">{{inv.companyPhone || '-'}}</div>
  185. </div>
  186. <div class="content-line" v-if="inv.kind === 1205">
  187. <div class="title inline-block">税务登记号:</div>
  188. <div class="content inline-block">{{inv.companyTaxNumber || '-'}}</div>
  189. </div>
  190. <div class="content-line" v-if="inv.kind === 1205">
  191. <div class="title inline-block">开户银行:</div>
  192. <div class="content inline-block">{{inv.bankName || '-'}}</div>
  193. </div>
  194. <div class="content-line" v-if="inv.kind === 1205">
  195. <div class="title inline-block">开户银行账户:</div>
  196. <div class="content inline-block">{{inv.bankAccount || '-'}}</div>
  197. </div>
  198. <div class="content-line">
  199. <div class="title inline-block">收票人:</div>
  200. <div class="content inline-block">{{inv.name || '-'}}</div>
  201. </div>
  202. <div class="content-line">
  203. <div class="title inline-block">联系电话:</div>
  204. <div class="content inline-block">{{inv.telephone || '-'}}</div>
  205. </div>
  206. <div class="content-line">
  207. <div class="title inline-block">详细地址:</div>
  208. <div class="content inline-block">{{inv.area + inv.detailAddress}}</div>
  209. </div>
  210. </li>
  211. </ul>
  212. </modal-wrapper>
  213. <!-- 选择发票弹框end -->
  214. <!-- 选择地址弹框start -->
  215. <modal-wrapper :showModal="showAddrModal"
  216. :title="'收货地址'"
  217. @closeAction="showAddrModal = false">
  218. <ul class="addr-list">
  219. <li v-for="(addr, index) in addressData" :class="{active: selectedAddressIndex === index}" @click="setAddressCheck(index)">
  220. <div class="info-line">
  221. <label class="mobile-cart-check" :class="{active: selectedAddressIndex === index}">
  222. <input type="checkbox">
  223. </label>
  224. <span class="name inline-block text-ellipse">{{addr.name}}</span>
  225. <span class="tel inline-block text-ellipse">{{addr.tel}}</span>
  226. <i class="inline-block" v-if="addr.num === 1">默认地址</i>
  227. </div>
  228. <p>{{addr.area + addr.detailAddress}}</p>
  229. </li>
  230. </ul>
  231. </modal-wrapper>
  232. <!-- 选择地址弹框end -->
  233. <!-- 选择自提点弹框start -->
  234. <modal-wrapper :showModal="showTakeSelfModal"
  235. :title="'选择自提点'"
  236. @closeAction="showTakeSelfModal = false">
  237. <ul class="addr-list takeself-list">
  238. <li v-for="(takeself, index) in takeSelfData[currentTakeSelfStoreId]" @click="checkTakeSelf(index)" :class="{active: index === 0}">
  239. <div class="info-line">
  240. <label class="mobile-cart-check" :class="{active: index === 0}">
  241. <input type="checkbox">
  242. </label>
  243. <span class="name inline-block text-ellipse">{{takeself.takename}}</span>
  244. </div>
  245. <p><span>地址:</span>{{takeself.area + takeself.detailAddress}}</p>
  246. <p><span>营业时间:</span>{{takeself.businesstime}}</p>
  247. </li>
  248. </ul>
  249. </modal-wrapper>
  250. <!-- 选择自提点弹框end -->
  251. <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  252. </div>
  253. </template>
  254. <script>
  255. import { LinkUser, ModalWrapper, BottomModalWrapper } from '~components/mobile/base'
  256. import { RemindBox } from '~components/mobile/common'
  257. export default {
  258. layout: 'mobile',
  259. middleware: 'authenticated',
  260. data () {
  261. return {
  262. orderData: [],
  263. // 联系卖家店铺信息
  264. currentStoreInfo: {},
  265. showLink: false,
  266. showModal: false,
  267. showDeliveryModal: false,
  268. showInvoiceModal: false,
  269. showAddrModal: false,
  270. showTakeSelfModal: false,
  271. currentGoods: [],
  272. remindText: '',
  273. timeoutCount: '',
  274. // 配送规则
  275. fareRule: {},
  276. // 自提点
  277. takeSelfData: {},
  278. // 正在修改配送方式的店铺id
  279. currentDeliveryStoreId: '',
  280. // 订单总价
  281. allOrderPrice: 0,
  282. // 选中的发票
  283. selectedInvoiceIndex: -1,
  284. // 选中的地址
  285. selectedAddressIndex: 0,
  286. // 正在修改自提点的店铺id
  287. currentTakeSelfStoreId: ''
  288. }
  289. },
  290. components: {
  291. LinkUser,
  292. ModalWrapper,
  293. RemindBox,
  294. BottomModalWrapper
  295. },
  296. fetch ({ store, params }) {
  297. return Promise.all([
  298. store.dispatch('userCenter/loadPayInfo', {enOrderid: params.orderId}),
  299. store.dispatch('userCenter/loadAcceptAddress', {send: false}),
  300. store.dispatch('userCenter/loadPayInvoice')
  301. ])
  302. },
  303. // watch: {
  304. // '$store.state.userCenter.list.invoice.data': {
  305. // handler: function (val) {
  306. // this.invoiceData = this.baseUtils.deepCopy(val)
  307. // if (this.invoiceData && this.invoiceData.length) {
  308. // this.invoiceData.forEach(item => {
  309. // this.$set(item, '$checked', false)
  310. // })
  311. // }
  312. // },
  313. // immediate: true
  314. // }
  315. // },
  316. computed: {
  317. payData () {
  318. // // 人民币为专用增值税发票,美元不开发票 --1205专用增值税发票 --1206普通发票 --1207不开发票
  319. // let invoices = this.baseUtils.deepCopy(this.$store.state.userCenter.list.pay.data)
  320. // if (invoices.currency === 'USD') {
  321. // invoices.invoicetype = 1207
  322. // invoices.paytype = '1103'
  323. // } else {
  324. // invoices.invoicetype = 1205
  325. // invoices.paytype = '1102'
  326. // }
  327. // // 默认选择第三方配送 --1301第三方配送 --卖家配送 --1303上门自提
  328. // invoices.deliverytype = 1301
  329. // return invoices
  330. return this.$store.state.userCenter.list.pay.data
  331. },
  332. addressData () {
  333. return this.$store.state.userCenter.list.address.data
  334. },
  335. invoiceData () {
  336. return this.$store.state.userCenter.list.invoice.data
  337. },
  338. // 已选择完的发票
  339. selectedInvoice () {
  340. return this.selectedInvoiceIndex > -1 ? this.invoiceData[this.selectedInvoiceIndex] : null
  341. },
  342. // // 选择中选中的发票
  343. // checkedInvoiceObj () {
  344. // return this.invoiceData.find(item => {
  345. // return item.$checked
  346. // })
  347. // },
  348. selectedAddress () {
  349. // console.log(this.addressData[this.selectedAddressIndex])
  350. return this.addressData[this.selectedAddressIndex] || {}
  351. },
  352. ruleParamsArr () {
  353. let arr = []
  354. this.orderData.forEach(item => {
  355. item.goodsPrice = this.getTotalPrice(item)
  356. arr.push({
  357. uuid: item.storeid,
  358. fare: this.getTotalPrice(item)
  359. })
  360. })
  361. return arr
  362. }
  363. // // 选择自提点的列表统计
  364. // showTakeSelfList () {
  365. // let arr = {}
  366. // if (!this.showDeliveryModal || !this.showTakeSelfModal) { // 为了触发更新
  367. // for (let attr in this.fareRule) {
  368. // arr[attr] = this.fareRule[attr][0] && this.fareRule[attr][0].method === 1303
  369. // }
  370. // }
  371. // return arr
  372. // }
  373. // defaultAddress () {
  374. // return this.addressData.find(item => {
  375. // return item.num === 1
  376. // })
  377. // }
  378. },
  379. created () {
  380. this.initOrderData()
  381. },
  382. methods: {
  383. initOrderData () {
  384. this.payData.orderDetails.forEach(item => {
  385. let current = this.orderData.find(objItem => {
  386. return objItem.storeid === item.storeid
  387. })
  388. if (!current) {
  389. this.orderData.push({
  390. storeName: item.storeName,
  391. storeid: item.storeid,
  392. supEnUU: item.supEnUU,
  393. goods: [item]
  394. })
  395. } else {
  396. current.goods.push(item)
  397. }
  398. })
  399. this.getDeliveryRule()
  400. this.getTakeSelfInfo()
  401. },
  402. getDeliveryRule () {
  403. return this.$http.post(`/trade/distributionRule/usable/rule?area=${this.selectedAddress.area}`, this.ruleParamsArr)
  404. .then(res => {
  405. this.fareRule = res.data || {}
  406. this.initFare()
  407. }, err => {
  408. this.setRemindText(err.response.data || '系统错误')
  409. })
  410. },
  411. getTakeSelfInfo () {
  412. return this.$http.post(`/trade/takeSelf/store/takeSelf`, this.ruleParamsArr)
  413. .then(res => {
  414. this.takeSelfData = res.data || {}
  415. }, err => {
  416. this.setRemindText(err.response.data || '系统错误')
  417. })
  418. },
  419. initFare () {
  420. this.allOrderPrice = 0
  421. this.orderData.forEach(item => {
  422. item.fare = this.fareRule[item.storeid] && this.fareRule[item.storeid].length ? this.fareRule[item.storeid][0] : {}
  423. item.goodsPrice = this.getTotalPrice(item) // 总价
  424. // 包含运费的价格
  425. item.goodsFarePrice = this.baseUtils.priceFixed(item.goodsPrice + (item.fare && item.fare.fare ? item.fare.fare : 0))
  426. this.allOrderPrice += item.goodsFarePrice
  427. })
  428. },
  429. getTotalPrice (storeItem) {
  430. let price = 0
  431. storeItem.goods.forEach(item => {
  432. price += item.price
  433. })
  434. return Number(price.toFixed(6))
  435. },
  436. linkSaler (item) {
  437. this.$http.get(`/basic/enterprise/${item.supEnUU}/info`).then(res => {
  438. this.currentStoreInfo = res.data
  439. this.showLink = true
  440. }, err => {
  441. this.setRemindText(err.response.data || '系统错误')
  442. console.log(err)
  443. })
  444. },
  445. showDetailList (goods) {
  446. this.currentGoods = goods
  447. this.showModal = true
  448. },
  449. goodsScroll (type) {
  450. console.log(type)
  451. },
  452. setRemindText: function (str) {
  453. this.remindText = str
  454. this.timeoutCount++
  455. },
  456. checkShowTakeSelf (item) {
  457. return item.fare && item.fare.method === 1303
  458. },
  459. // 显示配送规则弹框
  460. showRuleSet: function (storeid) {
  461. if (this.fareRule[storeid] && this.fareRule[storeid].length) {
  462. this.currentDeliveryStoreId = storeid
  463. this.clearCurrentDeliveryCheck()
  464. this.fareRule[this.currentDeliveryStoreId][0].$checked = true
  465. this.showDeliveryModal = true
  466. }
  467. // console.log(storeid)
  468. },
  469. clearCurrentDeliveryCheck () {
  470. this.fareRule[this.currentDeliveryStoreId].forEach(item => {
  471. if (!item.hasOwnProperty('$checked')) {
  472. this.$set(item, '$checked', false)
  473. } else {
  474. item.$checked = false
  475. }
  476. })
  477. },
  478. checkDelivery (cdr) {
  479. if (!cdr.$checked) {
  480. this.clearCurrentDeliveryCheck()
  481. cdr.$checked = true
  482. }
  483. },
  484. onDeliveryModalClose (isSubmit) {
  485. if (!isSubmit) {
  486. this.showDeliveryModal = false
  487. // this.currentDeliveryRule = {}
  488. } else {
  489. let currentDi = this.fareRule[this.currentDeliveryStoreId]
  490. for (let i = 0; i < currentDi.length; i++) {
  491. if (currentDi[i].$checked) {
  492. this.baseUtils.exchangeArr(currentDi, i, 0)
  493. break
  494. }
  495. }
  496. this.initFare()
  497. this.showDeliveryModal = false
  498. }
  499. },
  500. // 显示自提点弹框
  501. showTakeSelfSet (storeid) {
  502. if (this.takeSelfData[storeid] && this.takeSelfData[storeid].length) {
  503. this.currentTakeSelfStoreId = storeid
  504. this.showTakeSelfModal = true
  505. }
  506. },
  507. checkTakeSelf (index) {
  508. // for (let i = 0; i < this.takeSelfData[this.currentTakeSelfStoreId].length; i++) {
  509. // if (item.id === this.takeSelfData[this.currentTakeSelfStoreId][i].id) {
  510. //
  511. // break
  512. // }
  513. // }
  514. if (index > 0) {
  515. this.baseUtils.exchangeArr(this.takeSelfData[this.currentTakeSelfStoreId], index, 0)
  516. }
  517. this.showTakeSelfModal = false
  518. },
  519. setInvoiceCheck (index) {
  520. if (this.selectedInvoiceIndex === index) {
  521. return
  522. }
  523. this.selectedInvoiceIndex = index
  524. this.showInvoiceModal = false
  525. },
  526. openInvoiceModal () {
  527. if (this.invoiceData && this.invoiceData.length) {
  528. this.showInvoiceModal = true
  529. } else {
  530. this.setRemindText('暂无发票信息,请前往pc端维护')
  531. }
  532. },
  533. setAddressCheck (index) {
  534. if (this.selectedAddressIndex === index) {
  535. return
  536. }
  537. this.selectedAddressIndex = index
  538. this.showAddrModal = false
  539. this.getDeliveryRule()
  540. },
  541. openAddrModal () {
  542. if (this.addressData && this.addressData.length) {
  543. this.showAddrModal = true
  544. } else {
  545. this.setRemindText('暂无收货地址,请前往pc端维护')
  546. }
  547. },
  548. // 配送规则校验
  549. checkRule () {
  550. let flag = true
  551. for (let attr in this.fareRule) {
  552. if (!this.fareRule[attr].length) {
  553. flag = false
  554. }
  555. }
  556. return flag
  557. },
  558. // 收货地址校验
  559. checkAddress () {
  560. if (!this.selectedAddress || !this.selectedAddress.id) {
  561. this.setRemindText('收货地址信息为空,请前往pc端添加收货地址')
  562. return false
  563. } else if (this.selectedAddress.area.indexOf('香港') > -1) {
  564. if (this.payData.currency === 'RMB') {
  565. this.setRemindText('当前选择的币别是RMB,地址却是香港')
  566. return false
  567. }
  568. } else {
  569. if (this.payData.currency === 'USD') {
  570. this.setRemindText('当前选择的币别是USD,地址却是内陆')
  571. return false
  572. }
  573. }
  574. return true
  575. },
  576. // 提交订单流程
  577. confirmOrder () {
  578. if (this.accountInvalid) {
  579. this.setRemindText('您的账户安全等级较低,请先在pc端进行信息完善')
  580. } else {
  581. if (this.payData.status === 502 || this.payData.status === 503) {
  582. this.underLinePaySubmitted()
  583. } else {
  584. if (!this.checkRule()) {
  585. this.setRemindText('当前地址部分卖家无法配送,请重新选择地址或与卖家协商处理')
  586. } else {
  587. let infos = []
  588. let info = this.generateOrderInfo()
  589. if (info) {
  590. infos.push(info)
  591. this.doSubmit(infos)
  592. }
  593. }
  594. }
  595. }
  596. },
  597. // 待付款订单-线下付款
  598. underLinePaySubmitted () {
  599. let arr = []
  600. if (this.payData.orderids) {
  601. arr = this.payData.orderids.split(',')
  602. } else {
  603. arr.push(this.payData.orderid)
  604. }
  605. let param = {
  606. orderid: this.baseUtils.enidfilter(arr.join('-'))
  607. }
  608. console.log(param)
  609. // 跳转至付款页面
  610. console.log('订单已存在,直接跳转至付款页面')
  611. this.$router.push(`/mobile/center/user/doPay/${encodeURIComponent(param.orderid)}`)
  612. return param
  613. },
  614. // 处理订单数据
  615. generateOrderInfo () {
  616. let orderInfo = {
  617. id: this.payData.id,
  618. orderid: this.payData.orderid
  619. }
  620. if (this.payData.currency === 'USD' && this.selectedInvoiceIndex !== -1) {
  621. this.setRemindText('美元请选择暂不开票')
  622. return false
  623. }
  624. if (this.checkAddress()) {
  625. orderInfo.add_id = this.selectedAddress.id
  626. } else {
  627. return false
  628. }
  629. let submitParam = this.orderSubmitParams()
  630. // 发票信息
  631. if (this.selectedInvoice) {
  632. if (this.selectedInvoice.kind === 1205) {
  633. orderInfo.invoicetype = '1205'
  634. } else if (this.selectedInvoice.kind === 1206) {
  635. if (submitParam.includeConsignment) {
  636. this.setRemindText('订单中包含寄售类型商品,请选择专票')
  637. return false
  638. }
  639. orderInfo.invoicetype = '1206'
  640. }
  641. if (this.selectedInvoice.id) {
  642. orderInfo.invoiceid = this.selectedInvoice.id
  643. } else {
  644. this.setRemindText('请添加发票信息')
  645. return false
  646. }
  647. } else {
  648. orderInfo.invoicetype = '1207'
  649. }
  650. orderInfo.totalprice = submitParam.goodsPrice
  651. orderInfo.currency = this.payData.currency
  652. orderInfo.orderRemark = JSON.stringify(submitParam.remarkObj)
  653. // 1103线下 1102线上
  654. orderInfo.paytype = '1103'
  655. orderInfo.splitInfo = {
  656. ruleList: JSON.stringify(submitParam.ruleList),
  657. takeList: JSON.stringify(submitParam.takeList)
  658. }
  659. orderInfo.orderDetails = this.convertOrderDetailParams()
  660. console.log(orderInfo)
  661. return orderInfo
  662. // 人民币为专用增值税发票,美元不开发票 --1205专用增值税发票 --1206普通发票 --1207不开发票
  663. // 默认选择第三方配送 --1301第三方配送 --卖家配送 --1303上门自提
  664. },
  665. // 订单提交的参数整合
  666. orderSubmitParams () {
  667. let params = {
  668. // 不包含运费的价格
  669. goodsPrice: 0,
  670. // 备注
  671. remarkObj: {},
  672. // 配送方式
  673. ruleList: {},
  674. // 自提点
  675. takeList: {},
  676. // 是否包含寄售商品
  677. includeConsignment: false
  678. }
  679. this.orderData.forEach(item => {
  680. params.goodsPrice += item.goodsPrice
  681. params.remarkObj[item.storeid] = item.remark
  682. params.ruleList[item.storeid] = item.fare
  683. params.takeList[item.storeid] = this.checkShowTakeSelf(item) && this.takeSelfData[item.storeid] ? [0] : null
  684. if (item.storeid === '33069557578d44e69bd91ad12d28a8d4') {
  685. params.includeConsignment = true
  686. }
  687. })
  688. return params
  689. },
  690. // 提取要提交到服务器的订单明细goods数据
  691. convertOrderDetailParams () {
  692. let orderDetails = []
  693. this.payData.orderDetails.forEach(item => {
  694. orderDetails.push({
  695. id: item.id,
  696. number: item.number,
  697. taxUnitprice: item.taxUnitprice,
  698. remark: item.remark,
  699. goodsnumber: item.goodsnumber,
  700. storeid: item.storeid
  701. })
  702. })
  703. return orderDetails
  704. },
  705. // 提交订单请求
  706. doSubmit (orders) {
  707. this.$http.put(`/trade/order/${this.baseUtils.enidfilter(this.payData.orderid)}/ensure`, orders)
  708. .then(res => {
  709. console.log(res)
  710. if (res.data.code === 1) {
  711. if (res.data.data && res.data.data[0]) {
  712. let orderids = []
  713. let batchCodes = []
  714. for (let i = 0; i < res.data.data.length; i++) {
  715. orderids.push(res.data.data[i].orderid)
  716. for (let j = 0; j < res.data.data[i].orderDetails.length; j++) {
  717. batchCodes.push(res.data.data[i].orderDetails[j].batchCode)
  718. }
  719. }
  720. // 如果不是立即购买,删除购物车里的对应信息
  721. if (!this.payData.buyNow) {
  722. this.$http.put('/trade/cart/delete', batchCodes)
  723. }
  724. // 跳转至订单提交完成页面
  725. console.log('订单提交完成,跳转至结果页')
  726. this.$router.push(`/mobile/center/user/doPay/${encodeURIComponent(this.baseUtils.enidfilter(orderids.join('-')))}`)
  727. }
  728. } else {
  729. if (res.data.data.code === 6) {
  730. this.setRemindText(res.data.message + ',请刷新界面之后重新操作')
  731. } else if (res.data.data.code === 7) {
  732. this.setRemindText(res.data.message + ',将为您跳转到购物车界面')
  733. setTimeout(() => {
  734. this.$router.push('/mobile/center/user/cart')
  735. }, 1500)
  736. } else {
  737. this.setRemindText(res.data.message)
  738. }
  739. }
  740. }, err => {
  741. console.log(err)
  742. this.setRemindText(err.response.data || '提交订单失败')
  743. })
  744. }
  745. }
  746. }
  747. </script>
  748. <style lang="scss" scoped>
  749. $red-text: #f43938;
  750. .mobile-pay {
  751. margin-bottom: 2.02rem;
  752. .pay-head {
  753. height: 1.3rem;
  754. padding: .25rem 0 0 .21rem;
  755. position: relative;
  756. border-bottom: .18rem solid #f1f3f7;
  757. background: url('/images/mobile/center/user/addr-border.png') no-repeat;
  758. background-size: contain;
  759. background-position: bottom;
  760. .info {
  761. padding-left: .43rem;
  762. font-size: .3rem;
  763. font-weight: bold;
  764. }
  765. .addr {
  766. width: 6.5rem;
  767. overflow: hidden;
  768. text-overflow: ellipsis;
  769. white-space: nowrap;
  770. img {
  771. height: .29rem;
  772. margin-right: .16rem;
  773. }
  774. span {
  775. font-size: .26rem;
  776. }
  777. }
  778. .icon-xiangyou {
  779. position: absolute;
  780. right: .21rem;
  781. top: .52rem;
  782. color: #bebebe;
  783. }
  784. .no-addr {
  785. margin-top: .15rem;
  786. text-align: center;
  787. padding-right: .21rem;
  788. }
  789. }
  790. .pay-store-list {
  791. .ps-item {
  792. border-bottom: .18rem solid #f1f3f7;
  793. .ps-store-name {
  794. height: .89rem;
  795. line-height: .89rem;
  796. padding: 0 .25rem;
  797. font-size: .28rem;
  798. text-align: left;
  799. }
  800. .ps-goods-info {
  801. background: #f0f0f0;
  802. .fl {
  803. padding: 0 .29rem 0 .1rem;
  804. position: relative;
  805. .ps-goods-list {
  806. width: 4.5rem;
  807. height: 100%;
  808. padding: .22rem 0;
  809. overflow-x: auto;
  810. white-space: nowrap;
  811. li {
  812. border-right: 1px solid #969696;
  813. .ps-goods-item {
  814. width: 2.25rem;
  815. padding-left: .12rem;
  816. font-size: .24rem;
  817. &.pg-item-long {
  818. width: 4.5rem;
  819. }
  820. span {
  821. color: #666;
  822. }
  823. }
  824. }
  825. }
  826. .arrow {
  827. position: absolute;
  828. height: 100%;
  829. color: #666;
  830. background: #dfdfdf;
  831. padding-top: .66rem;
  832. top: 0;
  833. &:first-child {
  834. left: 0;
  835. }
  836. &:last-child {
  837. right: 0;
  838. }
  839. }
  840. }
  841. .fr {
  842. width: 2.6rem;
  843. text-align: center;
  844. .price {
  845. color: #f43938;
  846. font-size: .32rem;
  847. margin-top: .44rem;
  848. padding-right: .05rem;
  849. span {
  850. font-size: .24rem;
  851. }
  852. }
  853. .count {
  854. font-size: .28rem;
  855. font-weight: bold;
  856. margin-top: .2rem;
  857. }
  858. }
  859. }
  860. }
  861. }
  862. .ps-operate-line {
  863. height: .89rem;
  864. line-height: .89rem;
  865. padding: 0 .21rem 0 .25rem;
  866. border-bottom: 1px solid #e4e4e4;
  867. font-size: .28rem;
  868. .fr {
  869. height: 100%;
  870. .inline-block {
  871. line-height: normal;
  872. text-align: right;
  873. span {
  874. font-size: .27rem;
  875. color: #666;
  876. &:first-child {
  877. color: #333;
  878. font-weight: bold;
  879. display: block;
  880. }
  881. &.red {
  882. color: $red-text;
  883. }
  884. }
  885. }
  886. i {
  887. color: #bebebe;
  888. margin-left: .14rem;
  889. }
  890. }
  891. input {
  892. width: 4.78rem;
  893. margin-left: .68rem;
  894. padding: 0 .1rem;
  895. height: .45rem;
  896. }
  897. &.ps-price {
  898. text-align: right;
  899. padding-right: .31rem;
  900. .inline-block {
  901. font-size: .26rem;
  902. max-width: 64%;
  903. &:first-child {
  904. max-width: 32%;
  905. margin-right: .18rem;
  906. }
  907. }
  908. }
  909. &.pay-operate {
  910. border-bottom: .11rem solid #f1f3f7;
  911. padding-top: 0;
  912. .fr {
  913. line-height: .78rem;
  914. i {
  915. position: static;
  916. }
  917. span {
  918. color: #333;
  919. font-size: .28rem;
  920. }
  921. }
  922. }
  923. &.pay-invoice {
  924. border-bottom: .11rem solid #f1f3f7;
  925. .fr {
  926. padding-top: 0;
  927. .inline-block {
  928. vertical-align: top;
  929. }
  930. i {
  931. float: right;
  932. }
  933. span {
  934. font-size: .28rem;
  935. color: #333;
  936. font-weight: normal !important;
  937. max-width: 5rem;
  938. overflow: hidden;
  939. text-overflow: ellipsis;
  940. white-space: nowrap;
  941. }
  942. }
  943. }
  944. &.ps-operate-takeself {
  945. height: 1.35rem;
  946. line-height: 1.35rem;
  947. .fr {
  948. span {
  949. display: block;
  950. max-width: 5.5rem;
  951. overflow: hidden;
  952. text-overflow: ellipsis;
  953. white-space: nowrap;
  954. }
  955. }
  956. }
  957. }
  958. .ol-price {
  959. color: #f43938;
  960. font-size: .32rem;
  961. span {
  962. font-size: .24rem;
  963. }
  964. }
  965. .buy-wrap {
  966. position: fixed;
  967. bottom: .98rem;
  968. height: 1.02rem;
  969. line-height: 1.02rem;
  970. padding-left: .27rem;
  971. background: #fff;
  972. width: 100%;
  973. border-top: .02rem solid #ccc;
  974. .fr {
  975. .title {
  976. font-size: .28rem;
  977. margin-right: .13rem;
  978. }
  979. .price {
  980. max-width: 3.6rem;
  981. vertical-align: top;
  982. span {
  983. margin-right: .08rem;
  984. }
  985. margin-right: .13rem;
  986. }
  987. .buy-btn {
  988. width: 2.08rem;
  989. height: 1.02rem;
  990. line-height: 1.02rem;
  991. text-align: center;
  992. font-size: .28rem;
  993. color: #fff;
  994. background: #fc2706;
  995. }
  996. }
  997. }
  998. .cGoods-list {
  999. background: #fff;
  1000. li {
  1001. padding: .3rem .32rem;
  1002. border-bottom: 1px solid #e4e4e4;
  1003. .fl {
  1004. .cg-param-line {
  1005. width: 3.65rem;
  1006. margin-bottom: .23rem;
  1007. &:last-child {
  1008. margin-bottom: 0;
  1009. }
  1010. font-size: .28rem;
  1011. span {
  1012. color: #666;
  1013. }
  1014. }
  1015. }
  1016. .fr {
  1017. text-align: right;
  1018. p {
  1019. width: 2.3rem;
  1020. }
  1021. .ol-price {
  1022. margin-top: .59rem;
  1023. }
  1024. .count {
  1025. color: #999;
  1026. font-size: .24rem;
  1027. margin-top: .32rem;
  1028. }
  1029. }
  1030. }
  1031. }
  1032. .delivery-rule-list {
  1033. li {
  1034. background: #fff;
  1035. text-align: left;
  1036. padding: 0 .31rem 0 .25rem;
  1037. height: .94rem;
  1038. line-height: .94rem;
  1039. .fr {
  1040. height: 100%;
  1041. .ol-price {
  1042. margin-left: .23rem;
  1043. }
  1044. }
  1045. }
  1046. }
  1047. .invoice-list {
  1048. background: #f1f3f7;
  1049. padding: .19rem 0;
  1050. li {
  1051. margin-bottom: .19rem;
  1052. position: relative;
  1053. &:last-child {
  1054. margin-bottom: 0;
  1055. }
  1056. background: #fff;
  1057. padding: .26rem .16rem .32rem .25rem;
  1058. .inv-head {
  1059. margin-left: .17rem;
  1060. max-width: 5.3rem;
  1061. }
  1062. .inv-type {
  1063. position: absolute;
  1064. right: 0;
  1065. top: 0;
  1066. height: .85rem;
  1067. }
  1068. .content-line {
  1069. margin-top: .23rem;
  1070. padding-left: .53rem;
  1071. .title {
  1072. width: 34%;
  1073. text-align: right;
  1074. vertical-align: top;
  1075. }
  1076. .content {
  1077. width: 66%;
  1078. word-break: break-all;
  1079. }
  1080. }
  1081. }
  1082. }
  1083. .addr-list {
  1084. background: #f1f3f7;
  1085. padding: .19rem 0;
  1086. li {
  1087. margin-bottom: .19rem;
  1088. position: relative;
  1089. &:last-child {
  1090. margin-bottom: 0;
  1091. }
  1092. background: #fff;
  1093. padding: .35rem .25rem .28rem;
  1094. .info-line {
  1095. font-size: .3rem;
  1096. color: #666;
  1097. .name {
  1098. margin: 0 .27rem 0 .17rem;
  1099. max-width: 1.5rem;
  1100. }
  1101. .tel {
  1102. max-width: 2.3rem;
  1103. }
  1104. i {
  1105. width: 1.08rem;
  1106. height: .25rem;
  1107. line-height: .25rem;
  1108. font-size: .24rem;
  1109. text-align: center;
  1110. border: 1px solid #fc2706;
  1111. border-radius: .04rem;
  1112. color: #f43938;
  1113. font-style: normal;
  1114. margin-left: .48rem;
  1115. }
  1116. }
  1117. p {
  1118. margin-top: .19rem;
  1119. word-break: break-all;
  1120. padding-left: .54rem;
  1121. font-size: .28rem;
  1122. color: #999;
  1123. }
  1124. &.active {
  1125. .info-line {
  1126. color: #f43938;
  1127. }
  1128. p {
  1129. color: #666;
  1130. }
  1131. }
  1132. }
  1133. }
  1134. .takeself-list {
  1135. li {
  1136. .info-line {
  1137. .name {
  1138. max-width: 5.3rem;
  1139. }
  1140. }
  1141. }
  1142. }
  1143. }
  1144. </style>