index.vue 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909
  1. <template>
  2. <view :style="colorStyle">
  3. <view class='order-submission'>
  4. <view class="allAddress" :style="store_self_mention && is_shipping ? '' : 'padding-top:10rpx'"
  5. v-if="!virtual_type">
  6. <view class="nav acea-row">
  7. <view class="item font-num" :class="shippingType == 0 ? 'on' : 'on2'" @tap="addressType(0)"
  8. v-if='store_self_mention && is_shipping'></view>
  9. <view class="item font-num" :class="shippingType == 1 ? 'on' : 'on2'" @tap="addressType(1)"
  10. v-if='store_self_mention && is_shipping'></view>
  11. </view>
  12. <view class='address acea-row row-between-wrapper' @tap='onAddress' v-if='shippingType == 0'>
  13. <view class='addressCon' v-if="addressInfo.realName">
  14. <view class='name'>{{ addressInfo.realName }}
  15. <text class='phone'>{{ addressInfo.phone }}</text>
  16. </view>
  17. <view class="line1">
  18. <text class='default font-num' v-if="addressInfo.defaultState == 2">[{{ $t(`默认`) }}]
  19. </text>{{ addressInfo.province }}{{ addressInfo.city }}
  20. {{ addressInfo.district }}{{ addressInfo.detail }}
  21. </view>
  22. <!-- <view class='setaddress'>设置收货地址</view> -->
  23. </view>
  24. <view class='addressCon' v-else>
  25. <view class='setaddress'>{{ $t(`设置收货地址`) }}</view>
  26. </view>
  27. <view class='iconfont icon-jiantou'></view>
  28. </view>
  29. <view class='address acea-row row-between-wrapper' v-else @tap="showStoreList">
  30. <block v-if="storeList.length > 0">
  31. <view class='addressCon'>
  32. <view class='name'>{{ system_store.name }}
  33. <text class='phone'>{{ system_store.phone }}</text>
  34. </view>
  35. <view class="line1"> {{ system_store.address }}{{ ", " + system_store.detailed_address }}</view>
  36. </view>
  37. <view class='iconfont icon-jiantou'></view>
  38. </block>
  39. <block v-else>
  40. <view>{{ $t(`暂无门店信息`) }}</view>
  41. </block>
  42. </view>
  43. <view class='line'>
  44. <image src='/static/images/line.jpg'></image>
  45. </view>
  46. </view>
  47. <orderGoods :cartInfo="cartInfo" :is_confirm='true' :shipping_type="shippingType"></orderGoods>
  48. <view class='wrapper'>
  49. <!-- <view class='item acea-row row-between-wrapper' @tap='couponTap'
  50. v-if="!pinkId && !BargainId && !combinationId && !seckillId&& !noCoupon && !discountId && !advanceId">
  51. <view>{{$t(`优惠券`)}}</view>
  52. <view class='discount'>
  53. {{couponTitle}}
  54. <text class='iconfont icon-jiantou'></text>
  55. </view>
  56. </view> -->
  57. <view class='item acea-row row-between-wrapper'>
  58. <view>{{ $t(`运费`) }}</view>
  59. <view class='discount acea-row row-middle'>
  60. <view>
  61. <text class='num font-color'>{{ freight || 0 }}元</text>
  62. </view>
  63. </view>
  64. </view>
  65. <view class='item acea-row row-between-wrapper'>
  66. <view>{{ $t(`赠送积分`) }}</view>
  67. <view class='discount acea-row row-middle'>
  68. <view>
  69. <text class='num font-color'>{{ integral || 0 }}红积分</text>
  70. </view>
  71. </view>
  72. </view>
  73. <view v-if="invoice_func || special_invoice" class='item acea-row row-between-wrapper' @tap="goInvoice">
  74. <view>{{ $t(`开具发票`) }}</view>
  75. <view class='discount'>
  76. {{ invTitle }}
  77. <text class='iconfont icon-jiantou'></text>
  78. </view>
  79. </view>
  80. <view v-if="shippingType == 1">
  81. <view class="item acea-row row-between-wrapper">
  82. <view>{{ $t(`用户姓名`) }}</view>
  83. <view class="discount">
  84. <input style="text-align: right;" v-model="contacts" type="text" :placeholder="$t(`请输入姓名`)"
  85. placeholder-class="placeholder"></input>
  86. </view>
  87. </view>
  88. <view class="item acea-row row-between-wrapper">
  89. <view>{{ $t(`联系电话`) }}</view>
  90. <view class="discount">
  91. <input style="text-align: right;" v-model="contactsTel" type="text"
  92. :placeholder="$t(`请输入手机号`)" placeholder-class="placeholder"></input>
  93. </view>
  94. </view>
  95. </view>
  96. <view class='item' v-if="textareaStatus">
  97. <view>{{ $t(`备注说明`) }}</view>
  98. <view class="mark" v-if="!coupon.coupon && !inputTrip" @click="inputTripClick">
  99. <view :class="{ 'mark-msg': mark }" v-text="mark || $t(`填写备注信息,100字以内`)"></view>
  100. </view>
  101. <textarea placeholder-class='placeholder' :placeholder="$t(`填写备注信息,100字以内`)"
  102. v-if="!coupon.coupon && inputTrip" @input='bindHideKeyboard' :focus="focus"
  103. @blur="inputTrip = false" :value="mark" :maxlength="150" name="mark">
  104. </textarea>
  105. </view>
  106. </view>
  107. <view class='wrapper' v-if="confirm.length">
  108. <view class='item acea-row row-between-wrapper' v-for="(item, index) in confirm" :key="index">
  109. <view>
  110. <span v-if="item.status" style="color: red;">*</span>
  111. <span v-else style="marginLeft: 8px;"></span>
  112. {{ item.title }}
  113. </view>
  114. <!-- text -->
  115. <view v-if="item.label == 'text'" class="confirm">
  116. <input type="text" :placeholder="$t(`请填写`) + ' ' + item.title" v-model="item.value" />
  117. </view>
  118. <!-- number -->
  119. <view v-if="item.label == 'number'" class="confirm">
  120. <input type="number" :placeholder="$t(`请填写`) + item.title" v-model="item.value" />
  121. </view>
  122. <!-- email -->
  123. <view v-if="item.label == 'email'" class="confirm">
  124. <input type="text" :placeholder="$t(`请填写`) + item.title" v-model="item.value" />
  125. </view>
  126. <!-- data -->
  127. <view v-if="item.label == 'data'" class="uni-list">
  128. <view class="uni-list-cell">
  129. <view class="uni-list-cell-db">
  130. <picker mode="date" :value="item.value" @change="bindDateChange($event, index)">
  131. <view v-if="item.value == ''" class="fontC">{{ date + item.title }}<text
  132. class='iconfont icon-jiantou'></text></view>
  133. <view v-else class="uni-input">{{ item.value }}</view>
  134. </picker>
  135. </view>
  136. </view>
  137. </view>
  138. <!-- time -->
  139. <view v-if="item.label == 'time'">
  140. <view>
  141. <view>
  142. <picker mode="time" :value="item.value" start="00:00" end="23:59"
  143. @change="bindTimeChange($event, index)">
  144. <view v-if="item.value == ''" class="fontC">{{ time + item.title }}<text
  145. class='iconfont icon-jiantou'></text></view>
  146. <view>{{ item.value }}</view>
  147. </picker>
  148. </view>
  149. </view>
  150. </view>
  151. <!-- id -->
  152. <view v-if="item.label == 'id'" class="confirm">
  153. <input type="idcard" :placeholder="$t(`请填写`) + item.title" v-model="item.value" />
  154. </view>
  155. <!-- phone -->
  156. <view v-if="item.label == 'phone'" class="confirm">
  157. <input type="tel" :placeholder="$t(`请填写`) + item.title" v-model="item.value" />
  158. </view>
  159. <!-- img -->
  160. <view v-if="item.label == 'img'" class="confirmImg">
  161. <view class='list acea-row row-middle'>
  162. <view class='pictrue' v-for="(items, indexs) in item.value" :key="indexs">
  163. <image :src='items' class="img"></image>
  164. <text class='iconfont icon-guanbi1 font-num del' @click='DelPic(index, indexs)'></text>
  165. </view>
  166. <view class='pictrue acea-row row-center-wrapper row-column bor'
  167. @click='uploadpic(index, item)' v-if="item.value.length < 8">
  168. <text class='iconfont icon-icon25201'></text>
  169. <view>{{ $t(`上传图片`) }}</view>
  170. </view>
  171. </view>
  172. </view>
  173. </view>
  174. </view>
  175. <view class='moneyList'>
  176. <!-- <view class='item acea-row row-between-wrapper'>
  177. <view>{{$t(`商品总价`)}}:</view>
  178. <view class='money'>
  179. {{$t(`¥`)}}{{(parseFloat(priceGroup.totalPrice)+parseFloat(priceGroup.vipPrice)).toFixed(2)}}
  180. </view>
  181. </view> -->
  182. <view class='item acea-row row-between-wrapper' v-if="priceGroup.storePostage > 0">
  183. <view>{{ $t(`配送运费`) }}:</view>
  184. <view class='money'>
  185. {{ $t(`¥`) }}{{ (parseFloat(priceGroup.storePostage) + parseFloat(priceGroup.storePostageDiscount)).toFixed(2) }}
  186. </view>
  187. </view>
  188. <view class='item acea-row row-between-wrapper'
  189. v-if="priceGroup.vipPrice > 0 && userInfo.vip && !pinkId && !BargainId && !combinationId && !seckillId && !discountId">
  190. <view>{{ $t(`会员商品优惠`) }}:</view>
  191. <view class='money'>-{{ $t(`¥`) }}{{ parseFloat(priceGroup.vipPrice).toFixed(2) }}</view>
  192. </view>
  193. <view class='item acea-row row-between-wrapper' v-if="priceGroup.storePostageDiscount > 0">
  194. <view>{{ $t(`会员运费优惠`) }}:</view>
  195. <view class='money'>-{{ $t(`¥`) }}{{ parseFloat(priceGroup.storePostageDiscount).toFixed(2) }}</view>
  196. </view>
  197. <view class='item acea-row row-between-wrapper' v-if="coupon_price > 0">
  198. <view>{{ $t(`优惠券抵扣`) }}:</view>
  199. <view class='money'>-{{ $t(`¥`) }}{{ parseFloat(coupon_price).toFixed(2) }}</view>
  200. </view>
  201. <view class='item acea-row row-between-wrapper' v-if="integral_price > 0">
  202. <view>{{ $t(`积分抵扣`) }}:</view>
  203. <view class='money'>-{{ $t(`¥`) }}{{ parseFloat(integral_price).toFixed(2) }}</view>
  204. </view>
  205. </view>
  206. <view style='height:120rpx;'></view>
  207. <view class='footer acea-row row-between-wrapper'>
  208. <view>{{ $t(`合计`) }}:
  209. <text class='font-color'>{{ $t(`¥`) }}{{ parseFloat(totalPrice).toFixed(2) || 0 }}</text>
  210. </view>
  211. <view class='settlement' style='z-index:100' @tap.stop="goPay" v-if="totalPrice > 0">{{ $t(`提交订单`) }}
  212. </view>
  213. <view class='settlement bg-color-hui' style='z-index:100' v-else>{{ $t(`提交订单`) }}</view>
  214. </view>
  215. </view>
  216. <view class="alipaysubmit" v-html="formContent"></view>
  217. <couponListWindow :coupon='coupon' @ChangCouponsClone="ChangCouponsClone" :openType='openType' :cartId='cartId'
  218. @ChangCoupons="ChangCoupons"></couponListWindow>
  219. <addressWindow ref="addressWindow" @changeTextareaStatus="changeTextareaStatus" :news='news' :address='address'
  220. :pagesUrl="pagesUrl" @OnChangeAddress="OnChangeAddress" @changeClose="changeClose"></addressWindow>
  221. <!-- #ifdef MP -->
  222. <!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
  223. <!-- #endif -->
  224. <!-- <home v-show="!invShow"></home> -->
  225. <invoice-picker :inv-show="invShow" :inv-list="invList" :inv-checked="invChecked" :is-special="special_invoice"
  226. :url-query="urlQuery" @inv-close="invClose" @inv-change="invChange" @inv-cancel="invCancel">
  227. </invoice-picker>
  228. <payment :payMode="cartArr" :pay_close="pay_close" :isCall="false" :totalPrice="parseFloat(totalPrice).toFixed(2)"
  229. @changePayType="changePayType" @onChangeFun="onChangeFun" :order_id="orderKey"></payment>
  230. <canvas canvas-id="canvas" v-if="canvasStatus"
  231. :style="{ width: canvasWidth + 'px', height: canvasHeight + 'px', position: 'absolute', left: '-100000px', top: '-100000px' }"></canvas>
  232. </view>
  233. </template>
  234. <script>
  235. import {
  236. getGoodsDetail, postOrderSubmit, postBeforeCheck, getUserAddressByIdAndFreight
  237. } from "@/api/home.js";
  238. import {
  239. orderConfirm,
  240. getCouponsOrderPrice,
  241. orderCreate,
  242. postOrderComputed,
  243. checkShipping
  244. } from '@/api/order.js';
  245. import {
  246. getAddressDefault,
  247. getAddressDetail,
  248. invoiceList,
  249. invoiceOrder
  250. } from '@/api/user.js';
  251. import {
  252. openPaySubscribe
  253. } from '@/utils/SubscribeMessage.js';
  254. import {
  255. storeListApi
  256. } from '@/api/store.js';
  257. import {
  258. CACHE_LONGITUDE,
  259. CACHE_LATITUDE
  260. } from '@/config/cache.js';
  261. import couponListWindow from '@/components/couponListWindow';
  262. import addressWindow from '@/components/addressWindow';
  263. import orderGoods from '@/pages/goods/orderGoods/index_mall';
  264. import home from '@/components/home';
  265. import invoicePicker from '../components/invoicePicker/index.vue';
  266. import {
  267. toLogin
  268. } from '@/libs/login.js';
  269. import {
  270. mapGetters
  271. } from "vuex";
  272. // #ifdef MP
  273. import authorize from '@/components/Authorize';
  274. // #endif
  275. import payment from '@/components/payment';
  276. import colors from "@/mixins/color";
  277. export default {
  278. components: {
  279. payment,
  280. invoicePicker,
  281. couponListWindow,
  282. addressWindow,
  283. orderGoods,
  284. home,
  285. // #ifdef MP
  286. authorize
  287. // #endif
  288. },
  289. mixins: [colors],
  290. data() {
  291. const currentDate = this.getDate({
  292. format: true
  293. })
  294. return {
  295. confirm: '', //自定义留言
  296. date: this.$t(`请选择`),
  297. time: this.$t(`请选择`),
  298. canvasWidth: "",
  299. canvasHeight: "",
  300. canvasStatus: false,
  301. newImg: [],
  302. textareaStatus: true,
  303. //支付方式
  304. cartArr: [{
  305. "name": this.$t(`微信支付`),
  306. "icon": "icon-weixin2",
  307. value: 'weixin',
  308. title: this.$t(`使用微信快捷支付`),
  309. payStatus: 1,
  310. },
  311. // {
  312. // "name": this.$t(`支付宝支付`),
  313. // "icon": "icon-zhifubao",
  314. // value: 'alipay',
  315. // title: this.$t(`使用支付宝支付`),
  316. // payStatus: 1,
  317. // },
  318. // {
  319. // "name": this.$t(`余额支付`),
  320. // "icon": "icon-yuezhifu",
  321. // value: 'yue',
  322. // title: this.$t(`可用余额`),
  323. // payStatus: 1,
  324. // },
  325. // {
  326. // "name": this.$t(`线下支付`),
  327. // "icon": "icon-yuezhifu1",
  328. // value: 'offline',
  329. // title: this.$t(`使用线下付款`),
  330. // payStatus: 2,
  331. // }, {
  332. // "name": this.$t(`好友代付`),
  333. // "icon": "icon-haoyoudaizhifu",
  334. // value: 'friend',
  335. // title: this.$t(`找微信好友支付`),
  336. // payStatus: 1,
  337. // }
  338. ],
  339. virtual_type: 0,
  340. formContent: '',
  341. payType: 'weixin', //支付方式
  342. openType: 1, //优惠券打开方式 1=使用
  343. active: 0, //支付方式切换
  344. coupon: {
  345. coupon: false,
  346. list: [],
  347. statusTile: this.$t(`立即使用`)
  348. }, //优惠券组件
  349. address: {
  350. address: false
  351. }, //地址组件
  352. addressInfo: {}, //地址信息
  353. pinkId: 0, //拼团id
  354. addressId: 0, //地址id
  355. couponId: 0, //优惠券id
  356. cartId: '', //购物车id
  357. BargainId: 0,
  358. combinationId: 0,
  359. seckillId: 0,
  360. discountId: 0,
  361. userInfo: {}, //用户信息
  362. mark: '', //备注信息
  363. couponTitle: this.$t(`请选择`), //优惠券
  364. coupon_price: 0, //优惠券抵扣金额
  365. useIntegral: false, //是否使用积分
  366. integral_price: 0, //积分抵扣金额
  367. integral: 0,
  368. usable_integral: 0,
  369. ChangePrice: 0, //使用积分抵扣变动后的金额
  370. formIds: [], //收集formid
  371. status: 0,
  372. is_address: false,
  373. toPay: false, //修复进入支付时页面隐藏从新刷新页面
  374. shippingType: 0,
  375. system_store: {},
  376. storePostage: 0,
  377. advanceId: 0,
  378. contacts: '',
  379. contactsTel: '',
  380. mydata: {},
  381. storeList: [],
  382. store_self_mention: 0,
  383. cartInfo: [],
  384. priceGroup: {},
  385. animated: false,
  386. totalPrice: 0,
  387. integralRatio: "0",
  388. pagesUrl: "",
  389. orderKey: "",
  390. // usableCoupon: {},
  391. offlinePostage: "",
  392. isAuto: false, //没有授权的不会自动授权
  393. isShowAuth: false, //是否隐藏授权
  394. from: '',
  395. news: 1,
  396. num: 0,
  397. // invTitle: '不开发票',
  398. invTitle: this.$t(`不开发票`),
  399. special_invoice: false,
  400. invoice_func: false,
  401. header_type: '',
  402. invShow: false,
  403. invList: [],
  404. invChecked: '',
  405. urlQuery: '',
  406. pay_close: false,
  407. noCoupon: 0,
  408. valid_count: 0,
  409. discount_id: 0,
  410. is_shipping: true,
  411. inputTrip: false,
  412. focus: true,
  413. goodsSpecId: 0,
  414. freight: 0
  415. };
  416. },
  417. computed: mapGetters(['isLogin']),
  418. // watch: {
  419. // startDate() {
  420. // return this.getDate('start');
  421. // },
  422. // endDate() {
  423. // return this.getDate('end');
  424. // }
  425. // },
  426. onLoad(options) {
  427. // #ifdef H5
  428. this.from = this.$wechat.isWeixin() ? 'weixin' : 'weixinh5'
  429. // #endif
  430. // #ifdef MP
  431. this.from = 'routine'
  432. // #endif
  433. // #ifdef APP-PLUS
  434. this.from = 'app'
  435. // #endif
  436. if (!options.productId) return this.$util.Tips({
  437. title: this.$t(`请选择要购买的商品`)
  438. }, {
  439. tab: 3,
  440. url: 1
  441. });
  442. console.log(options);
  443. this.num = options.num || 0;
  444. this.goodsSpecId = options.goodsSpecId || 0;
  445. this.integral = options.obtainIntegral || 0;
  446. this.couponId = options.couponId || 0;
  447. this.noCoupon = Number(options.noCoupon) || 0;
  448. this.pinkId = options.pinkId ? parseInt(options.pinkId) : 0;
  449. this.addressId = options.addressId || 0;
  450. this.cartId = options.productId;
  451. this.is_address = options.is_address ? true : false;
  452. this.news = !options.new || options.new === '0' ? 0 : 1;
  453. this.invChecked = options.invoice_id || '';
  454. this.header_type = options.header_type || '1';
  455. this.couponTitle = options.couponTitle || this.$t(`请选择`)
  456. switch (options.invoice_type) {
  457. case '1':
  458. this.invTitle = this.$t(`电子普通发票`);
  459. break;
  460. case '2':
  461. this.invTitle = this.$t(`电子专用发票`);
  462. break;
  463. }
  464. // #ifndef APP-PLUS
  465. this.textareaStatus = true;
  466. // #endif
  467. if (this.isLogin && this.toPay == false) {
  468. this.checkShipping();
  469. // this.getaddressInfo();
  470. // this.getConfirm();
  471. // this.$nextTick(function() {
  472. // this.$refs.addressWindow.getAddressList();
  473. // })
  474. } else {
  475. toLogin();
  476. }
  477. },
  478. /**
  479. * 生命周期函数--监听页面显示
  480. */
  481. onShow: function () {
  482. let _this = this
  483. uni.$on("handClick", res => {
  484. if (res) {
  485. _this.system_store = res.address
  486. }
  487. // 清除监听
  488. uni.$off('handClick');
  489. })
  490. },
  491. methods: {
  492. checkShipping() {
  493. let that = this;
  494. this.getConfirm();
  495. this.getaddressInfo();
  496. // checkShipping(that.cartId, that.news).then(res => {
  497. // if (res.data.type == 0) {
  498. // that.is_shipping = true;
  499. // that.shippingType = 0;
  500. // this.getaddressInfo();
  501. // this.getConfirm();
  502. // this.$nextTick(function() {
  503. // this.$refs.addressWindow.getAddressList();
  504. // })
  505. // } else {
  506. // if (res.data.type == 1) {
  507. // that.is_shipping = false;
  508. // that.shippingType = 0;
  509. // this.getaddressInfo();
  510. // this.getConfirm();
  511. // this.$nextTick(function() {
  512. // this.$refs.addressWindow.getAddressList();
  513. // })
  514. // } else if (res.data.type == 2) {
  515. // that.is_shipping = false;
  516. // that.shippingType = 1;
  517. // this.getConfirm();
  518. // this.getList();
  519. // }
  520. // }
  521. // }).catch(err => {
  522. // uni.showToast({
  523. // title: err,
  524. // icon: 'none'
  525. // });
  526. // });
  527. },
  528. // 不开发票
  529. invCancel() {
  530. this.invChecked = '';
  531. this.invTitle = this.$t(`不开发票`)
  532. this.invShow = false;
  533. },
  534. // 选择发票
  535. invChange(id) {
  536. this.invChecked = id;
  537. this.invShow = false;
  538. const result = this.invList.find(item => item.id === id);
  539. let name = '';
  540. name += result.header_type === 1 ? this.$t(`个人`) : this.$t(`企业`);
  541. name += result.type === 1 ? this.$t(`普通`) : this.$t(`专用`);
  542. name += this.$t(`发票`);
  543. this.invTitle = name;
  544. },
  545. // 关闭发票
  546. invClose() {
  547. this.invShow = false;
  548. this.getInvoiceList()
  549. },
  550. getInvoiceList() {
  551. uni.showLoading({
  552. title: this.$t(`正在加载中`)
  553. })
  554. invoiceList().then(res => {
  555. uni.hideLoading();
  556. this.invList = res.data.map(item => {
  557. item.id = item.id.toString();
  558. return item;
  559. });
  560. const result = this.invList.find(item => item.id == this.invChecked);
  561. if (result) {
  562. let name = '';
  563. name += result.header_type === 1 ? this.$t(`个人`) : this.$t(`企业`);
  564. name += result.type === 1 ? this.$t(`普通`) : this.$t(`专用`);
  565. name += this.$t(`发票`);
  566. this.invTitle = name;
  567. }
  568. }).catch(err => {
  569. uni.showToast({
  570. title: err,
  571. icon: 'none'
  572. });
  573. });
  574. },
  575. /**
  576. * 开发票
  577. */
  578. goInvoice: function () {
  579. this.getInvoiceList()
  580. this.invShow = true;
  581. this.urlQuery =
  582. `new=${this.news}&cartId=${this.cartId}&pinkId=${this.pinkId}&couponId=${this.couponId}&addressId=${this.addressId}&specialInvoice=${this.special_invoice}&couponTitle=${this.couponTitle}`;
  583. },
  584. /**
  585. * 授权回调事件
  586. *
  587. */
  588. onLoadFun: function () {
  589. this.getaddressInfo();
  590. this.getConfirm();
  591. //调用子页面方法授权后执行获取地址列表
  592. // this.$scope.selectComponent('#address-window').getAddressList();
  593. },
  594. /**
  595. * 事件回调
  596. *
  597. */
  598. onChangeFun: function (e) {
  599. let opt = e;
  600. let action = opt.action || null;
  601. let value = opt.value != undefined ? opt.value : null;
  602. action && this[action] && this[action](value);
  603. },
  604. payClose: function () {
  605. this.pay_close = false;
  606. },
  607. goPay() {
  608. let that = this
  609. uni.showLoading({
  610. title: that.$t(`下单中`)
  611. });
  612. postBeforeCheck({
  613. goodsSpecId: this.goodsSpecId,
  614. num: this.num,
  615. userAddressId: this.addressId
  616. }).then(function (res) {
  617. //验证是否可下单
  618. if (res.code == 200) {
  619. that.freight = res.data.freight - 0
  620. that.totalPrice = res.data.freight - 0
  621. that.cartInfo.forEach(e => {
  622. that.totalPrice += (e.salePrice - 0) * (that.num - 0)
  623. })
  624. that.orderCreate()
  625. } else {
  626. this.totalPrice = 0
  627. that.$util.Tips({
  628. title: that.$t(`所选商品属性不支持下单`),
  629. success: () => {
  630. uni.hideLoading();
  631. // that.getCartCount(true);
  632. },
  633. });
  634. }
  635. })
  636. },
  637. orderCreate(){
  638. let that = this
  639. postOrderSubmit({
  640. distributeMode: 1,
  641. goodsList: [{
  642. goodsId: that.cartId,
  643. goodsNum: that.num,
  644. goodsSpecIds: that.goodsSpecId
  645. }],
  646. payType: 1,
  647. remark: that.remark,
  648. settleType: 1,
  649. userAddressId: that.addressInfo.id,
  650. wlPrice: that.freight
  651. }).then(res => {
  652. that.orderKey = res.data.orderNo,
  653. uni.showLoading({
  654. title: that.$t(`下单成功`)
  655. });
  656. setTimeout(res => {
  657. uni.hideLoading();
  658. that.pay_close = true;
  659. }, 500)
  660. }).catch(err => {
  661. uni.hideLoading();
  662. return that.$util.Tips({
  663. title: err
  664. });
  665. });
  666. },
  667. pay_complete(type) {
  668. let that = this
  669. this.payType = type;
  670. // let url = '/pages/goods/order_pay_status/index?order_id=' + this.orderKey + '&msg=' + "支付成功" +
  671. // '&type=3' + '&totalPrice=' + this.totalPrice
  672. uni.showToast({
  673. title: that.$t(`支付成功`)
  674. })
  675. that.pay_close = false
  676. // setTimeout(res => {
  677. // uni.redirectTo({
  678. // url: url
  679. // })
  680. // }, 1000)
  681. // this.SubOrder();
  682. },
  683. payCheck(type) {
  684. this.payType = type;
  685. // console.log(this.payType);
  686. // let url = '/pages/goods/order_pay_status/index?order_id=' + this.orderKey + '&msg=' + "支付成功" +
  687. // '&type=3' + '&totalPrice=' + this.totalPrice
  688. // uni.showToast({
  689. // title: that.$t(`支付成功`)
  690. // })
  691. // setTimeout(res => {
  692. // uni.redirectTo({
  693. // url: url
  694. // })
  695. // }, 1000)
  696. // this.SubOrder();
  697. },
  698. /**
  699. * 获取门店列表数据
  700. */
  701. getList: function () {
  702. let longitude = uni.getStorageSync("user_longitude"); //经度
  703. let latitude = uni.getStorageSync("user_latitude"); //纬度
  704. let data = {
  705. latitude: latitude, //纬度
  706. longitude: longitude, //经度
  707. page: 1,
  708. limit: 10
  709. }
  710. storeListApi(data).then(res => {
  711. let list = res.data.list.list || [];
  712. this.$set(this, 'storeList', list);
  713. this.$set(this, 'system_store', list[0]);
  714. }).catch(err => { })
  715. },
  716. // 关闭地址弹窗;
  717. changeClose: function () {
  718. this.$set(this.address, 'address', false);
  719. },
  720. /*
  721. * 跳转门店列表
  722. */
  723. showStoreList: function () {
  724. let _this = this
  725. if (this.storeList.length > 0) {
  726. uni.navigateTo({
  727. url: '/pages/goods/goods_details_store/index'
  728. })
  729. }
  730. },
  731. changePayType(type) {
  732. this.payType = type
  733. // this.computedPrice()
  734. },
  735. computedPrice: function () {
  736. let that = this
  737. postBeforeCheck({
  738. goodsSpecId: this.goodsSpecId,
  739. num: this.num,
  740. userAddressId: this.addressId
  741. }).then(function (res) {
  742. //验证是否可下单
  743. if (res.code == 200) {
  744. that.freight = res.data.freight - 0
  745. that.totalPrice = res.data.freight - 0
  746. that.cartInfo.forEach(e => {
  747. that.totalPrice += e.salePrice - 0
  748. })
  749. } else {
  750. this.totalPrice = 0
  751. that.$util.Tips({
  752. title: that.$t(`所选商品属性不支持下单`),
  753. success: () => {
  754. // that.getCartCount(true);
  755. },
  756. });
  757. }
  758. })
  759. },
  760. addressType(e) {
  761. let index = e;
  762. let that = this;
  763. if (this.shippingType == parseInt(index)) return
  764. this.shippingType = parseInt(index);
  765. if (index == 1) {
  766. // #ifdef H5
  767. if (that.$wechat.isWeixin()) {
  768. that.$wechat.location().then(res => {
  769. uni.setStorageSync('user_latitude', res.latitude);
  770. uni.setStorageSync('user_longitude', res.longitude);
  771. this.getList()
  772. }).catch(err => {
  773. this.getList()
  774. })
  775. } else {
  776. // #endif
  777. uni.getLocation({
  778. type: 'wgs84',
  779. success: (res) => {
  780. uni.setStorageSync('user_latitude', res.latitude);
  781. uni.setStorageSync('user_longitude', res.longitude);
  782. this.getList()
  783. },
  784. complete: () => {
  785. this.getList()
  786. }
  787. });
  788. // #ifdef H5
  789. }
  790. // #endif
  791. };
  792. this.$nextTick(e => {
  793. this.getConfirm();
  794. this.computedPrice();
  795. })
  796. },
  797. bindPickerChange: function (e) {
  798. let value = e.detail.value;
  799. this.shippingType = value;
  800. this.computedPrice();
  801. },
  802. ChangCouponsClone: function () {
  803. this.$set(this.coupon, 'coupon', false);
  804. },
  805. changeTextareaStatus: function () {
  806. for (let i = 0, len = this.coupon.list.length; i < len; i++) {
  807. this.coupon.list[i].use_title = '';
  808. this.coupon.list[i].is_use = 0;
  809. }
  810. this.textareaStatus = true;
  811. this.status = 0;
  812. this.$set(this.coupon, 'list', this.coupon.list);
  813. },
  814. /**
  815. * 处理点击优惠券后的事件
  816. *
  817. */
  818. ChangCoupons: function (e) {
  819. // this.usableCoupon = e
  820. // this.coupon.coupon = false
  821. let index = e,
  822. list = this.coupon.list,
  823. couponTitle = this.$t(`请选择`),
  824. couponId = 0;
  825. for (let i = 0, len = list.length; i < len; i++) {
  826. if (i != index) {
  827. list[i].use_title = '';
  828. list[i].is_use = 0;
  829. }
  830. }
  831. if (list[index].is_use) {
  832. //不使用优惠券
  833. list[index].use_title = '';
  834. list[index].is_use = 0;
  835. } else {
  836. //使用优惠券
  837. list[index].use_title = this.$t(`不使用`);
  838. list[index].is_use = 1;
  839. couponTitle = list[index].coupon_title;
  840. couponId = list[index].id;
  841. }
  842. this.couponTitle = couponTitle;
  843. this.couponId = couponId;
  844. this.$set(this.coupon, 'coupon', false);
  845. this.$set(this.coupon, 'list', list);
  846. this.computedPrice();
  847. },
  848. /**
  849. * 使用积分抵扣
  850. */
  851. ChangeIntegral: function () {
  852. this.useIntegral = !this.useIntegral;
  853. this.computedPrice();
  854. },
  855. /**
  856. * 选择地址后改变事件
  857. * @param object e
  858. */
  859. OnChangeAddress: function (e) {
  860. this.textareaStatus = true;
  861. this.addressId = e;
  862. this.address.address = false;
  863. this.getConfirm()
  864. this.getaddressInfo();
  865. this.computedPrice();
  866. },
  867. bindHideKeyboard: function (e) {
  868. this.mark = e.detail.value;
  869. },
  870. /**
  871. * 获取当前订单详细信息
  872. *
  873. */
  874. getConfirm: function () {
  875. let that = this;
  876. // return;
  877. uni.showLoading({
  878. title: that.$t(`正在加载中`),
  879. mask: true
  880. });
  881. getGoodsDetail({ id: that.cartId })
  882. .then((res) => {
  883. that.cartInfo = []
  884. let porject = res.data
  885. //找出选择的规格
  886. porject.goodsSpecList.forEach(element => {
  887. if (that.goodsSpecId == element.id) {
  888. porject.unit = element.spceName
  889. }
  890. });
  891. porject.totalSales = that.num
  892. // 计算总价
  893. that.totalPrice = (that.num - 0) * (porject.salePrice - 0) + that.freight - 0
  894. that.cartInfo.push(porject)
  895. uni.hideLoading()
  896. })
  897. .catch((err) => {
  898. uni.hideLoading()
  899. return this.$util.Tips({
  900. title: err
  901. });
  902. });
  903. // orderConfirm(that.cartId, that.news, that.addressId, that.shippingType + 1).then(res => {
  904. // that.$set(that, 'userInfo', res.data.userInfo);
  905. // that.$set(that, 'confirm', res.data.custom_form || []);
  906. // this.confirm.map(e => {
  907. // if (e.label === 'img') e.value = []
  908. // })
  909. // that.$set(that, 'integral', res.data.usable_integral);
  910. // that.$set(that, 'usable_integral', res.data.usable_integral);
  911. // that.$set(that, 'contacts', res.data.userInfo.real_name);
  912. // that.$set(that, 'contactsTel', res.data.userInfo.record_phone === '0' ? '' : res.data
  913. // .userInfo.record_phone);
  914. // that.$set(that, 'cartInfo', res.data.cartInfo);
  915. // that.$set(that, 'integralRatio', res.data.integralRatio);
  916. // that.$set(that, 'offlinePostage', res.data.offlinePostage);
  917. // that.$set(that, 'orderKey', res.data.orderKey);
  918. // that.$set(that, 'valid_count', res.data.valid_count);
  919. // that.$set(that, 'discount_id', res.data.discount_id)
  920. // that.$set(that, 'priceGroup', res.data.priceGroup);
  921. // that.$set(that, 'totalPrice', that.$util.$h.Add(parseFloat(res.data.priceGroup.totalPrice),
  922. // parseFloat(res.data
  923. // .priceGroup.storePostage)));
  924. // that.$set(that, 'seckillId', parseInt(res.data.seckill_id));
  925. // that.$set(that, 'invoice_func', res.data.invoice_func);
  926. // that.$set(that, 'special_invoice', res.data.special_invoice);
  927. // that.$set(that, 'store_self_mention', res.data.store_self_mention);
  928. // that.$set(that, 'virtual_type', res.data.virtual_type || 0);
  929. // //微信支付是否开启
  930. // that.cartArr[0].payStatus = res.data.pay_weixin_open || 0
  931. // //支付宝是否开启
  932. // that.cartArr[1].payStatus = res.data.ali_pay_status || 0;
  933. // //#ifdef MP
  934. // that.cartArr[1].payStatus = 0;
  935. // //#endif
  936. // //余额支付是否开启
  937. // // that.cartArr[2].title = '可用余额:' + res.data.userInfo.now_money;
  938. // that.cartArr[2].number = res.data.userInfo.now_money;
  939. // that.cartArr[2].payStatus = res.data.yue_pay_status == 1 ? res.data.yue_pay_status : 0
  940. // if (res.data.offline_pay_status == 2 || res.data.deduction) {
  941. // that.cartArr[3].payStatus = 0
  942. // } else {
  943. // that.cartArr[3].payStatus = 1
  944. // }
  945. // //好友代付是否开启
  946. // that.cartArr[4].payStatus = res.data.friend_pay_status || 0;
  947. // // that.$set(that, 'cartArr', that.cartArr);
  948. // that.$set(that, 'ChangePrice', that.totalPrice);
  949. // that.getBargainId();
  950. // that.getCouponList();
  951. // if (this.addressId) {
  952. // this.computedPrice();
  953. // }
  954. // uni.hideLoading()
  955. // }).catch(err => {
  956. // uni.hideLoading()
  957. // return this.$util.Tips({
  958. // title: err
  959. // });
  960. // });
  961. },
  962. /*
  963. * 提取砍价和拼团id
  964. */
  965. getBargainId: function () {
  966. let that = this;
  967. let cartINfo = that.cartInfo;
  968. let BargainId = 0;
  969. let combinationId = 0;
  970. let discountId = 0;
  971. let advanceId = 0;
  972. cartINfo.forEach(function (value, index, cartINfo) {
  973. BargainId = cartINfo[index].bargain_id,
  974. combinationId = cartINfo[index].combination_id,
  975. discountId = cartINfo[index].discount_id,
  976. advanceId = cartINfo[index].advance_id
  977. })
  978. that.$set(that, 'BargainId', parseInt(BargainId));
  979. that.$set(that, 'combinationId', parseInt(combinationId));
  980. that.$set(that, 'discountId', parseInt(discountId));
  981. that.$set(that, 'advanceId', parseInt(advanceId));
  982. if (that.cartArr.length == 3 && (BargainId || combinationId || that.seckillId || discountId)) {
  983. that.cartArr[2].payStatus = 0;
  984. that.$set(that, 'cartArr', that.cartArr);
  985. }
  986. },
  987. /**
  988. * 获取当前金额可用优惠券
  989. *
  990. */
  991. getCouponList: function () {
  992. let that = this;
  993. let data = {
  994. cartId: this.cartId,
  995. 'new': this.news
  996. }
  997. getCouponsOrderPrice(this.totalPrice, data).then(res => {
  998. that.$set(that.coupon, 'list', res.data);
  999. that.openType = 1;
  1000. });
  1001. },
  1002. /*
  1003. * 获取默认收货地址或者获取某条地址信息
  1004. */
  1005. getaddressInfo: function () {
  1006. let that = this;
  1007. if (that.addressId) {
  1008. getUserAddressByIdAndFreight({ id: that.addressId }).then(res => {
  1009. res.data.is_default = parseInt(res.data.is_default);
  1010. that.addressInfo = res.data || {};
  1011. that.addressId = res.data.id || 0;
  1012. that.address.addressId = res.data.id || 0;
  1013. })
  1014. } else {
  1015. getAddressDefault().then(res => {
  1016. res.data.is_default = parseInt(res.data.is_default);
  1017. that.addressInfo = res.data || {};
  1018. that.addressId = res.data.id || 0;
  1019. that.address.addressId = res.data.id || 0;
  1020. })
  1021. }
  1022. },
  1023. payItem: function (e) {
  1024. let that = this;
  1025. let active = e;
  1026. that.active = active;
  1027. that.animated = true;
  1028. that.payType = that.cartArr[active].value;
  1029. that.computedPrice();
  1030. setTimeout(function () {
  1031. that.car();
  1032. }, 500);
  1033. },
  1034. couponTap: function () {
  1035. this.coupon.coupon = true;
  1036. this.coupon.list.forEach((item, index) => {
  1037. if (item.id == this.couponId) {
  1038. item.is_use = 1
  1039. } else {
  1040. item.is_use = 0
  1041. }
  1042. })
  1043. this.$set(this.coupon, 'list', this.coupon.list);
  1044. },
  1045. car: function () {
  1046. let that = this;
  1047. that.animated = false;
  1048. },
  1049. onAddress: function () {
  1050. let that = this;
  1051. that.textareaStatus = false;
  1052. that.address.address = true;
  1053. that.pagesUrl = '/pages/users/user_address_list/index?news=' + this.news + '&cartId=' + this.cartId +
  1054. '&pinkId=' +
  1055. this.pinkId +
  1056. '&couponId=' +
  1057. this.couponId;
  1058. },
  1059. payment(data) {
  1060. let that = this;
  1061. // postOrderSubmit({
  1062. // distributeMode: 1,
  1063. // goodsList: [{
  1064. // goodsId: that.cartId,
  1065. // goodsNum: that.num,
  1066. // goodsSpecIds: that.goodsSpecId
  1067. // }],
  1068. // payType: 1,
  1069. // remark: that.remark,
  1070. // settleType: 1,
  1071. // userAddressId: that.addressInfo.id,
  1072. // wlPrice: that.freight
  1073. // }).then(res => {
  1074. // let status = "",
  1075. // orderId = res.data.orderNo,
  1076. // jsConfig = {},
  1077. // goPages = '/pages/goods/order_pay_status/index?order_id=' + orderId + '&msg=' + "支付成功" +
  1078. // '&type=3' + '&totalPrice=' + this.totalPrice
  1079. // that.toPay = true;
  1080. // uni.requestPayment({
  1081. // provider: 'wxpay',
  1082. // orderInfo: jsConfig,
  1083. // success: (e) => {
  1084. // let url = goPages;
  1085. // uni.showToast({
  1086. // title: that.$t(`支付成功`)
  1087. // })
  1088. // setTimeout(res => {
  1089. // uni.redirectTo({
  1090. // url: url
  1091. // })
  1092. // }, 2000)
  1093. // },
  1094. // fail: (e) => {
  1095. // let url = '/pages/goods/order_pay_status/index?order_id=' +
  1096. // orderId +
  1097. // '&msg=' + that.$t(`支付失败`);
  1098. // uni.showModal({
  1099. // content: that.$t(`支付失败`),
  1100. // showCancel: false,
  1101. // success: function (res) {
  1102. // if (res.confirm) {
  1103. // uni.redirectTo({
  1104. // url: url
  1105. // })
  1106. // } else if (res.cancel) { }
  1107. // }
  1108. // })
  1109. // },
  1110. // complete: () => {
  1111. // uni.hideLoading();
  1112. // },
  1113. // });
  1114. // switch (status) {
  1115. // case 'ORDER_EXIST':
  1116. // case 'EXTEND_ORDER':
  1117. // case 'PAY_ERROR':
  1118. // uni.hideLoading();
  1119. // return that.$util.Tips({
  1120. // title: res.msg
  1121. // }, {
  1122. // tab: 5,
  1123. // url: goPages
  1124. // });
  1125. // break;
  1126. // case 'SUCCESS':
  1127. // uni.hideLoading();
  1128. // if ((that.BargainId || that.combinationId || that.pinkId || that.seckillId || that
  1129. // .discountId) && data.payType != 'friend')
  1130. // return that.$util.Tips({
  1131. // title: res.msg,
  1132. // icon: 'success'
  1133. // }, {
  1134. // tab: 4,
  1135. // url: goPages
  1136. // });
  1137. // return that.$util.Tips({
  1138. // title: res.msg,
  1139. // icon: 'success'
  1140. // }, {
  1141. // tab: 4,
  1142. // url: data.payType == 'friend' ? friendPay : goPages
  1143. // });
  1144. // break;
  1145. // case 'WECHAT_PAY':
  1146. // that.toPay = true;
  1147. // // #ifdef MP
  1148. // /* that.toPay = true; */
  1149. // let mp_pay_name = ''
  1150. // if (uni.requestOrderPayment) {
  1151. // mp_pay_name = 'requestOrderPayment'
  1152. // } else {
  1153. // mp_pay_name = 'requestPayment'
  1154. // }
  1155. // uni[mp_pay_name]({
  1156. // timeStamp: jsConfig.timestamp,
  1157. // nonceStr: jsConfig.nonceStr,
  1158. // package: jsConfig.package,
  1159. // signType: jsConfig.signType,
  1160. // paySign: jsConfig.paySign,
  1161. // success: function (res) {
  1162. // uni.hideLoading();
  1163. // if (that.BargainId || that.combinationId || that.pinkId || that
  1164. // .seckillId || that.discountId)
  1165. // return that.$util.Tips({
  1166. // title: that.$t(`支付成功`),
  1167. // icon: 'success'
  1168. // }, {
  1169. // tab: 4,
  1170. // url: goPages
  1171. // });
  1172. // return that.$util.Tips({
  1173. // title: that.$t(`支付成功`),
  1174. // icon: 'success'
  1175. // }, {
  1176. // tab: 5,
  1177. // url: goPages
  1178. // });
  1179. // },
  1180. // fail: function (e) {
  1181. // uni.hideLoading();
  1182. // return that.$util.Tips({
  1183. // title: that.$t(`取消支付`)
  1184. // }, {
  1185. // tab: 5,
  1186. // url: goPages + '&status=2'
  1187. // });
  1188. // },
  1189. // complete: function (e) {
  1190. // uni.hideLoading();
  1191. // //关闭当前页面跳转至订单状态
  1192. // if (res.errMsg == 'requestPayment:cancel' || e.errMsg ==
  1193. // 'requestOrderPayment:cancel') return that.$util
  1194. // .Tips({
  1195. // title: that.$t(`取消支付`)
  1196. // }, {
  1197. // tab: 5,
  1198. // url: goPages + '&status=2'
  1199. // });
  1200. // },
  1201. // })
  1202. // // #endif
  1203. // // #ifdef H5
  1204. // this.$wechat.pay(res.data.result.jsConfig).then(res => {
  1205. // return that.$util.Tips({
  1206. // title: that.$t(`支付成功`),
  1207. // icon: 'success'
  1208. // }, {
  1209. // tab: 5,
  1210. // url: goPages
  1211. // });
  1212. // }).catch(res => {
  1213. // if (!this.$wechat.isWeixin()) {
  1214. // uni.redirectTo({
  1215. // url: goPages + '&msg=' + that.$t(`支付失败`) + '&status=2'
  1216. // // '&msg=支付失败&status=2'
  1217. // })
  1218. // }
  1219. // if (res.errMsg == 'chooseWXPay:cancel') return that.$util.Tips({
  1220. // title: that.$t(`取消支付`)
  1221. // }, {
  1222. // tab: 5,
  1223. // url: goPages + '&status=2'
  1224. // });
  1225. // })
  1226. // // #endif
  1227. // // #ifdef APP-PLUS
  1228. // uni.requestPayment({
  1229. // provider: 'wxpay',
  1230. // orderInfo: jsConfig,
  1231. // success: (e) => {
  1232. // let url = goPages;
  1233. // uni.showToast({
  1234. // title: that.$t(`支付成功`)
  1235. // })
  1236. // setTimeout(res => {
  1237. // uni.redirectTo({
  1238. // url: url
  1239. // })
  1240. // }, 2000)
  1241. // },
  1242. // fail: (e) => {
  1243. // let url = '/pages/goods/order_pay_status/index?order_id=' +
  1244. // orderId +
  1245. // '&msg=' + that.$t(`支付失败`);
  1246. // uni.showModal({
  1247. // content: that.$t(`支付失败`),
  1248. // showCancel: false,
  1249. // success: function (res) {
  1250. // if (res.confirm) {
  1251. // uni.redirectTo({
  1252. // url: url
  1253. // })
  1254. // } else if (res.cancel) { }
  1255. // }
  1256. // })
  1257. // },
  1258. // complete: () => {
  1259. // uni.hideLoading();
  1260. // },
  1261. // });
  1262. // // #endif
  1263. // break;
  1264. // case 'PAY_DEFICIENCY':
  1265. // uni.hideLoading();
  1266. // //余额不足
  1267. // return that.$util.Tips({
  1268. // title: res.msg
  1269. // }, {
  1270. // tab: 5,
  1271. // url: goPages + '&status=1'
  1272. // });
  1273. // break;
  1274. // case "WECHAT_H5_PAY":
  1275. // uni.hideLoading();
  1276. // that.$util.Tips({
  1277. // title: that.$t(`订单创建成功`)
  1278. // }, {
  1279. // tab: 4,
  1280. // url: goPages + '&status=0'
  1281. // });
  1282. // setTimeout(() => {
  1283. // location.href = res.data.result.jsConfig.mweb_url;
  1284. // }, 2000);
  1285. // break;
  1286. // case 'ALIPAY_PAY':
  1287. // //#ifdef H5
  1288. // if (this.from === 'weixin') {
  1289. // uni.redirectTo({
  1290. // url: `/pages/users/alipay_invoke/index?id=${orderId}&pay_key=${res.data.result.pay_key}`
  1291. // });
  1292. // } else {
  1293. // uni.hideLoading();
  1294. // that.formContent = res.data.result.jsConfig;
  1295. // that.$nextTick(() => {
  1296. // document.getElementById('alipaysubmit').submit();
  1297. // })
  1298. // }
  1299. // //#endif
  1300. // // #ifdef MP
  1301. // uni.navigateTo({
  1302. // url: `/pages/users/alipay_invoke/index?id=${orderId}&link=${jsConfig.qrCode}`
  1303. // });
  1304. // // #endif
  1305. // // #ifdef APP-PLUS
  1306. // uni.requestPayment({
  1307. // provider: 'alipay',
  1308. // orderInfo: jsConfig,
  1309. // success: (e) => {
  1310. // uni.showToast({
  1311. // title: that.$t(`支付成功`)
  1312. // })
  1313. // let url = '/pages/goods/order_pay_status/index?order_id=' +
  1314. // orderId +
  1315. // '&msg=' + that.$t(`支付成功`);
  1316. // setTimeout(res => {
  1317. // uni.redirectTo({
  1318. // url: url
  1319. // })
  1320. // }, 2000)
  1321. // },
  1322. // fail: (e) => {
  1323. // let url = '/pages/goods/order_pay_status/index?order_id=' +
  1324. // orderId +
  1325. // '&msg=' + that.$t(`支付失败`);
  1326. // uni.showModal({
  1327. // content: that.$t(`支付失败`),
  1328. // showCancel: false,
  1329. // success: function (res) {
  1330. // if (res.confirm) {
  1331. // uni.redirectTo({
  1332. // url: url
  1333. // })
  1334. // } else if (res.cancel) { }
  1335. // }
  1336. // })
  1337. // },
  1338. // complete: () => {
  1339. // uni.hideLoading();
  1340. // },
  1341. // });
  1342. // // #endif
  1343. // break;
  1344. // }
  1345. // }).catch(err => {
  1346. // uni.hideLoading();
  1347. // return that.$util.Tips({
  1348. // title: err
  1349. // });
  1350. // });
  1351. },
  1352. clickTextArea() {
  1353. this.$refs.textarea.focus()
  1354. },
  1355. SubOrder(e) {
  1356. let that = this,
  1357. data = {};
  1358. if (!that.payType) return that.$util.Tips({
  1359. title: that.$t(`请选择支付方式`)
  1360. });
  1361. if (!that.addressId && !that.shippingType && !that.virtual_type) return that.$util.Tips({
  1362. title: that.$t(`请选择收货地址`)
  1363. });
  1364. if (that.shippingType == 1) {
  1365. if (that.contacts == "" || that.contactsTel == "") {
  1366. return that.$util.Tips({
  1367. title: that.$t(`请填写联系人或联系人电话`)
  1368. });
  1369. }
  1370. if (!/^1(3|4|5|7|8|9|6)\d{9}$/.test(that.contactsTel)) {
  1371. return that.$util.Tips({
  1372. title: that.$t(`请输入正确的手机号码`)
  1373. });
  1374. }
  1375. if (!that.contacts) {
  1376. return that.$util.Tips({
  1377. title: that.$t(`请输入姓名`)
  1378. });
  1379. }
  1380. if (that.storeList.length == 0) return that.$util.Tips({
  1381. title: that.$t(`暂无门店,请选择其他方式`)
  1382. });
  1383. }
  1384. for (var i = 0; i < that.confirm.length; i++) {
  1385. let data = that.confirm[i]
  1386. if (data.status) {
  1387. if (data.label === 'text' || data.label === 'data' || data.label === 'time' || data.label ===
  1388. 'id') {
  1389. if (!data.value.trim()) {
  1390. return uni.showToast({
  1391. title: that.$t(`请输入`) + `${data.title}`,
  1392. icon: 'none'
  1393. });
  1394. }
  1395. }
  1396. if (data.label === 'number') {
  1397. if (data.value <= 0) {
  1398. return uni.showToast({
  1399. title: that.$t(`请输入`) + `${data.title}`,
  1400. icon: 'none'
  1401. });
  1402. }
  1403. }
  1404. if (data.label === 'email') {
  1405. if (!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(data.value)) {
  1406. return uni.showToast({
  1407. title: that.$t(`请输入正确的`) + `${data.title}`,
  1408. icon: 'none'
  1409. });
  1410. }
  1411. }
  1412. if (data.label === 'phone') {
  1413. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(data.value)) {
  1414. return uni.showToast({
  1415. title: that.$t(`请输入正确的`) + `${data.title}`,
  1416. icon: 'none'
  1417. });
  1418. }
  1419. }
  1420. if (data.label === 'img') {
  1421. if (!data.value.length) {
  1422. return uni.showToast({
  1423. title: that.$t(`请上传`) + `${data.title}`,
  1424. icon: 'none'
  1425. });
  1426. }
  1427. }
  1428. }
  1429. }
  1430. data = {
  1431. custom_form: that.confirm,
  1432. real_name: that.contacts,
  1433. phone: that.contactsTel,
  1434. addressId: that.addressId,
  1435. formId: '',
  1436. couponId: that.couponId,
  1437. payType: that.payType,
  1438. useIntegral: that.useIntegral,
  1439. bargainId: that.BargainId,
  1440. combinationId: that.combinationId,
  1441. discountId: that.discountId,
  1442. pinkId: that.pinkId,
  1443. advanceId: that.advanceId,
  1444. seckill_id: that.seckillId,
  1445. mark: that.mark,
  1446. store_id: that.system_store ? that.system_store.id : 0,
  1447. 'from': that.from,
  1448. shipping_type: that.$util.$h.Add(that.shippingType, 1),
  1449. 'new': that.news,
  1450. 'invoice_id': that.invChecked,
  1451. // #ifdef H5
  1452. quitUrl: location.protocol + '//' + location.hostname +
  1453. '/pages/goods/order_pay_status/index?' +
  1454. '&type=3' + '&totalPrice=' + this.totalPrice
  1455. // #endif
  1456. // #ifdef APP-PLUS
  1457. quitUrl: '/pages/goods/order_details/index?order_id=' + this.order_id
  1458. // #endif
  1459. };
  1460. if (data.payType == 'yue' && parseFloat(that.userInfo.now_money) < parseFloat(that.totalPrice))
  1461. return that.$util.Tips({
  1462. title: that.$t(`余额不足`)
  1463. });
  1464. uni.showLoading({
  1465. title: that.$t(`订单支付中`)
  1466. });
  1467. // #ifdef MP
  1468. openPaySubscribe().then(() => {
  1469. that.payment(data);
  1470. });
  1471. // #endif
  1472. // #ifndef MP
  1473. that.payment(data);
  1474. // #endif
  1475. },
  1476. bindDateChange: function (e, index) {
  1477. this.confirm[index].value = e.target.value
  1478. },
  1479. bindTimeChange: function (e, index) {
  1480. this.confirm[index].value = e.target.value
  1481. },
  1482. getDate(type) {
  1483. const date = new Date();
  1484. let year = date.getFullYear();
  1485. let month = date.getMonth() + 1;
  1486. let day = date.getDate();
  1487. if (type === 'start') {
  1488. year = year - 60;
  1489. } else if (type === 'end') {
  1490. year = year + 2;
  1491. }
  1492. month = month > 9 ? month : '0' + month;
  1493. day = day > 9 ? day : '0' + day;
  1494. return `${year}-${month}-${day}`;
  1495. },
  1496. uploadpic: function (index, item) {
  1497. let that = this;
  1498. this.canvasStatus = true
  1499. that.$util.uploadImageChange('upload/image', function (res) {
  1500. item.value.push(res.data.url);
  1501. }, (res) => {
  1502. this.canvasStatus = false
  1503. }, (res) => {
  1504. this.canvasWidth = res.w
  1505. this.canvasHeight = res.h
  1506. });
  1507. },
  1508. DelPic: function (index, indexs) {
  1509. let that = this,
  1510. pic = this.confirm[index].value;
  1511. that.confirm[index].value.splice(indexs, 1);
  1512. // that.$set(that, 'pics', that.pics);
  1513. },
  1514. inputTripClick() {
  1515. this.inputTrip = true
  1516. // this.$refs.trip.foucs()
  1517. },
  1518. }
  1519. }
  1520. </script>
  1521. <style lang="scss" scoped>
  1522. /deep/uni-checkbox[disabled] .uni-checkbox-input {
  1523. background-color: #eee;
  1524. }
  1525. .alipaysubmit {
  1526. display: none;
  1527. }
  1528. .order-submission .line {
  1529. width: 100%;
  1530. height: 3rpx;
  1531. }
  1532. .order-submission .line image {
  1533. width: 100%;
  1534. height: 100%;
  1535. display: block;
  1536. }
  1537. .order-submission .address {
  1538. padding: 28rpx 30rpx;
  1539. background-color: #fff;
  1540. box-sizing: border-box;
  1541. }
  1542. .order-submission .address .addressCon {
  1543. width: 610rpx;
  1544. font-size: 26rpx;
  1545. color: #666;
  1546. }
  1547. .order-submission .address .addressCon .name {
  1548. font-size: 30rpx;
  1549. color: #282828;
  1550. font-weight: bold;
  1551. margin-bottom: 10rpx;
  1552. }
  1553. .order-submission .address .addressCon .name .phone {
  1554. margin-left: 50rpx;
  1555. }
  1556. .order-submission .address .addressCon .default {
  1557. margin-right: 12rpx;
  1558. }
  1559. .order-submission .address .addressCon .setaddress {
  1560. color: #333;
  1561. font-size: 28rpx;
  1562. }
  1563. .order-submission .address .iconfont {
  1564. font-size: 35rpx;
  1565. color: #707070;
  1566. }
  1567. .order-submission .allAddress {
  1568. width: 100%;
  1569. background: linear-gradient(to bottom, var(--view-theme) 0%, #f5f5f5 100%);
  1570. padding-top: 100rpx;
  1571. margin-bottom: 12rpx;
  1572. }
  1573. .order-submission .allAddress .nav {
  1574. width: 710rpx;
  1575. margin: 0 auto;
  1576. }
  1577. .order-submission .allAddress .nav .item {
  1578. width: 355rpx;
  1579. }
  1580. .order-submission .allAddress .nav .item.on {
  1581. position: relative;
  1582. width: 250rpx;
  1583. }
  1584. .order-submission .allAddress .nav .item.on::before {
  1585. position: absolute;
  1586. bottom: 0;
  1587. content: "快递配送";
  1588. font-size: 28rpx;
  1589. display: block;
  1590. height: 0;
  1591. width: 336rpx;
  1592. border-width: 0 20rpx 80rpx 0;
  1593. border-style: none solid solid;
  1594. border-color: transparent transparent #fff;
  1595. z-index: 2;
  1596. border-radius: 7rpx 30rpx 0 0;
  1597. text-align: center;
  1598. line-height: 80rpx;
  1599. }
  1600. .order-submission .allAddress .nav .item:nth-of-type(2).on::before {
  1601. content: "到店自提";
  1602. border-width: 0 0 80rpx 20rpx;
  1603. border-radius: 30rpx 7rpx 0 0;
  1604. }
  1605. .order-submission .allAddress .nav .item.on2 {
  1606. position: relative;
  1607. }
  1608. .order-submission .allAddress .nav .item.on2::before {
  1609. position: absolute;
  1610. bottom: 0;
  1611. content: "到店自提";
  1612. font-size: 28rpx;
  1613. display: block;
  1614. height: 0;
  1615. width: 400rpx;
  1616. border-width: 0 0 60rpx 60rpx;
  1617. border-style: none solid solid;
  1618. border-color: transparent transparent rgba(255, 255, 255, 0.6);
  1619. border-radius: 40rpx 6rpx 0 0;
  1620. text-align: center;
  1621. line-height: 60rpx;
  1622. }
  1623. .order-submission .allAddress .nav .item:nth-of-type(1).on2::before {
  1624. content: "快递配送";
  1625. border-width: 0 60rpx 60rpx 0;
  1626. border-radius: 6rpx 40rpx 0 0;
  1627. }
  1628. .order-submission .allAddress .address {
  1629. width: 710rpx;
  1630. height: 150rpx;
  1631. margin: 0 auto;
  1632. }
  1633. .order-submission .allAddress .line {
  1634. width: 710rpx;
  1635. margin: 0 auto;
  1636. }
  1637. .order-submission .wrapper .item .discount .placeholder {
  1638. color: #ccc;
  1639. }
  1640. .placeholder-textarea {
  1641. position: relative;
  1642. .placeholder {
  1643. position: absolute;
  1644. color: #ccc;
  1645. top: 26rpx;
  1646. left: 30rpx;
  1647. }
  1648. }
  1649. .order-submission .wrapper {
  1650. background-color: #fff;
  1651. margin-top: 13rpx;
  1652. }
  1653. .order-submission .wrapper .item {
  1654. padding: 27rpx 30rpx;
  1655. font-size: 30rpx;
  1656. color: #282828;
  1657. border-bottom: 1px solid #f0f0f0;
  1658. .mark {
  1659. background-color: #f9f9f9;
  1660. width: 345px;
  1661. height: 70px;
  1662. border-radius: 1px;
  1663. margin-top: 15px;
  1664. padding: 12px 14px;
  1665. color: #ccc;
  1666. font-size: 28rpx;
  1667. box-sizing: border-box;
  1668. }
  1669. .mark-msg {
  1670. color: #333;
  1671. font-size: 32rpx;
  1672. }
  1673. }
  1674. .order-submission .wrapper .item .discount {
  1675. font-size: 30rpx;
  1676. color: #999;
  1677. }
  1678. .order-submission .wrapper .item .discount input {
  1679. text-align: end;
  1680. }
  1681. .order-submission .wrapper .item .discount .iconfont {
  1682. color: #515151;
  1683. font-size: 30rpx;
  1684. margin-left: 15rpx;
  1685. }
  1686. .order-submission .wrapper .item .discount .num {
  1687. font-size: 32rpx;
  1688. margin-right: 20rpx;
  1689. }
  1690. .order-submission .wrapper .item .shipping {
  1691. font-size: 30rpx;
  1692. color: #999;
  1693. position: relative;
  1694. padding-right: 58rpx;
  1695. }
  1696. .order-submission .wrapper .item .shipping .iconfont {
  1697. font-size: 35rpx;
  1698. color: #707070;
  1699. position: absolute;
  1700. right: 0;
  1701. top: 50%;
  1702. transform: translateY(-50%);
  1703. margin-left: 30rpx;
  1704. }
  1705. .order-submission .wrapper .item textarea {
  1706. background-color: #f9f9f9;
  1707. width: 690rpx;
  1708. height: 140rpx;
  1709. border-radius: 3rpx;
  1710. margin-top: 30rpx;
  1711. padding: 25rpx 28rpx;
  1712. box-sizing: border-box;
  1713. }
  1714. .order-submission .wrapper .item .placeholder {
  1715. color: #ccc;
  1716. font-size: 28rpx;
  1717. }
  1718. .order-submission .wrapper .item .list {
  1719. margin-top: 35rpx;
  1720. }
  1721. .order-submission .wrapper .item .list .payItem {
  1722. border: 1px solid #eee;
  1723. border-radius: 6rpx;
  1724. height: 86rpx;
  1725. width: 100%;
  1726. box-sizing: border-box;
  1727. margin-top: 20rpx;
  1728. font-size: 28rpx;
  1729. color: #282828;
  1730. }
  1731. .order-submission .wrapper .item .list .payItem.on {
  1732. border-color: #fc5445;
  1733. color: #e93323;
  1734. }
  1735. .order-submission .wrapper .item .list .payItem .name {
  1736. width: 50%;
  1737. text-align: center;
  1738. border-right: 1px solid #eee;
  1739. padding-left: 80rpx;
  1740. }
  1741. .order-submission .wrapper .item .list .payItem .name .iconfont {
  1742. width: 44rpx;
  1743. height: 44rpx;
  1744. border-radius: 50%;
  1745. text-align: center;
  1746. line-height: 44rpx;
  1747. background-color: #fe960f;
  1748. color: #fff;
  1749. font-size: 30rpx;
  1750. margin-right: 15rpx;
  1751. }
  1752. .order-submission .wrapper .item .list .payItem .name .iconfont.icon-weixin2 {
  1753. background-color: #41b035;
  1754. }
  1755. .order-submission .wrapper .item .list .payItem .name .iconfont.icon-zhifubao {
  1756. background-color: #1677FF;
  1757. }
  1758. .order-submission .wrapper .item .list .payItem .tip {
  1759. width: 49%;
  1760. text-align: center;
  1761. font-size: 26rpx;
  1762. color: #aaa;
  1763. }
  1764. .order-submission .moneyList {
  1765. margin-top: 12rpx;
  1766. background-color: #fff;
  1767. padding: 30rpx;
  1768. }
  1769. .order-submission .moneyList .item {
  1770. font-size: 28rpx;
  1771. color: #282828;
  1772. }
  1773. .order-submission .moneyList .item~.item {
  1774. margin-top: 20rpx;
  1775. }
  1776. .order-submission .moneyList .item .money {
  1777. color: #868686;
  1778. }
  1779. .order-submission .footer {
  1780. width: 100%;
  1781. height: 100rpx;
  1782. background-color: #fff;
  1783. padding: 0 30rpx;
  1784. font-size: 28rpx;
  1785. color: #333;
  1786. box-sizing: border-box;
  1787. position: fixed;
  1788. bottom: 0;
  1789. left: 0;
  1790. z-index: 9;
  1791. }
  1792. .order-submission .footer .settlement {
  1793. font-size: 30rpx;
  1794. color: #fff;
  1795. width: 240rpx;
  1796. height: 70rpx;
  1797. background-color: var(--view-theme);
  1798. border-radius: 50rpx;
  1799. text-align: center;
  1800. line-height: 70rpx;
  1801. }
  1802. .footer .transparent {
  1803. opacity: 0
  1804. }
  1805. .confirm {
  1806. text-align: right;
  1807. font-size: 22rpx;
  1808. }
  1809. .confirmImg {
  1810. width: 100%;
  1811. .img {
  1812. width: 136rpx;
  1813. height: 136rpx;
  1814. }
  1815. .pictrue {
  1816. width: 136rpx;
  1817. height: 136rpx;
  1818. box-sizing: border-box;
  1819. margin: 18rpx;
  1820. margin-bottom: 35rpx;
  1821. position: relative;
  1822. font-size: 22rpx;
  1823. color: #bbb;
  1824. .del {
  1825. position: absolute;
  1826. top: 0;
  1827. right: 0;
  1828. }
  1829. }
  1830. .bor {
  1831. border: 1rpx solid #ddd;
  1832. }
  1833. }
  1834. .fontC {
  1835. color: grey;
  1836. }
  1837. </style>