index.vue 52 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912
  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. zoneType: 0,
  416. };
  417. },
  418. computed: mapGetters(['isLogin']),
  419. // watch: {
  420. // startDate() {
  421. // return this.getDate('start');
  422. // },
  423. // endDate() {
  424. // return this.getDate('end');
  425. // }
  426. // },
  427. onLoad(options) {
  428. // #ifdef H5
  429. this.from = this.$wechat.isWeixin() ? 'weixin' : 'weixinh5'
  430. // #endif
  431. // #ifdef MP
  432. this.from = 'routine'
  433. // #endif
  434. // #ifdef APP-PLUS
  435. this.from = 'app'
  436. // #endif
  437. if (!options.productId) return this.$util.Tips({
  438. title: this.$t(`请选择要购买的商品`)
  439. }, {
  440. tab: 3,
  441. url: 1
  442. });
  443. this.num = options.num || 0;
  444. this.goodsSpecId = options.goodsSpecId || 0;
  445. this.freight = options.freight - 0 || 0;
  446. this.integral = options.obtainIntegral || 0;
  447. this.couponId = options.couponId || 0;
  448. this.noCoupon = Number(options.noCoupon) || 0;
  449. this.pinkId = options.pinkId ? parseInt(options.pinkId) : 0;
  450. this.addressId = options.addressId || 0;
  451. this.cartId = options.productId;
  452. this.is_address = options.is_address ? true : false;
  453. this.news = !options.new || options.new === '0' ? 0 : 1;
  454. this.invChecked = options.invoice_id || '';
  455. this.header_type = options.header_type || '1';
  456. this.couponTitle = options.couponTitle || this.$t(`请选择`)
  457. switch (options.invoice_type) {
  458. case '1':
  459. this.invTitle = this.$t(`电子普通发票`);
  460. break;
  461. case '2':
  462. this.invTitle = this.$t(`电子专用发票`);
  463. break;
  464. }
  465. // #ifndef APP-PLUS
  466. this.textareaStatus = true;
  467. // #endif
  468. if (this.isLogin && this.toPay == false) {
  469. this.checkShipping();
  470. // this.getaddressInfo();
  471. // this.getConfirm();
  472. // this.$nextTick(function() {
  473. // this.$refs.addressWindow.getAddressList();
  474. // })
  475. } else {
  476. toLogin();
  477. }
  478. },
  479. /**
  480. * 生命周期函数--监听页面显示
  481. */
  482. onShow: function () {
  483. let _this = this
  484. uni.$on("handClick", res => {
  485. if (res) {
  486. _this.system_store = res.address
  487. }
  488. // 清除监听
  489. uni.$off('handClick');
  490. })
  491. },
  492. methods: {
  493. checkShipping() {
  494. let that = this;
  495. this.getConfirm();
  496. this.getaddressInfo();
  497. // checkShipping(that.cartId, that.news).then(res => {
  498. // if (res.data.type == 0) {
  499. // that.is_shipping = true;
  500. // that.shippingType = 0;
  501. // this.getaddressInfo();
  502. // this.getConfirm();
  503. // this.$nextTick(function() {
  504. // this.$refs.addressWindow.getAddressList();
  505. // })
  506. // } else {
  507. // if (res.data.type == 1) {
  508. // that.is_shipping = false;
  509. // that.shippingType = 0;
  510. // this.getaddressInfo();
  511. // this.getConfirm();
  512. // this.$nextTick(function() {
  513. // this.$refs.addressWindow.getAddressList();
  514. // })
  515. // } else if (res.data.type == 2) {
  516. // that.is_shipping = false;
  517. // that.shippingType = 1;
  518. // this.getConfirm();
  519. // this.getList();
  520. // }
  521. // }
  522. // }).catch(err => {
  523. // uni.showToast({
  524. // title: err,
  525. // icon: 'none'
  526. // });
  527. // });
  528. },
  529. // 不开发票
  530. invCancel() {
  531. this.invChecked = '';
  532. this.invTitle = this.$t(`不开发票`)
  533. this.invShow = false;
  534. },
  535. // 选择发票
  536. invChange(id) {
  537. this.invChecked = id;
  538. this.invShow = false;
  539. const result = this.invList.find(item => item.id === id);
  540. let name = '';
  541. name += result.header_type === 1 ? this.$t(`个人`) : this.$t(`企业`);
  542. name += result.type === 1 ? this.$t(`普通`) : this.$t(`专用`);
  543. name += this.$t(`发票`);
  544. this.invTitle = name;
  545. },
  546. // 关闭发票
  547. invClose() {
  548. this.invShow = false;
  549. this.getInvoiceList()
  550. },
  551. getInvoiceList() {
  552. uni.showLoading({
  553. title: this.$t(`正在加载中`)
  554. })
  555. invoiceList().then(res => {
  556. uni.hideLoading();
  557. this.invList = res.data.map(item => {
  558. item.id = item.id.toString();
  559. return item;
  560. });
  561. const result = this.invList.find(item => item.id == this.invChecked);
  562. if (result) {
  563. let name = '';
  564. name += result.header_type === 1 ? this.$t(`个人`) : this.$t(`企业`);
  565. name += result.type === 1 ? this.$t(`普通`) : this.$t(`专用`);
  566. name += this.$t(`发票`);
  567. this.invTitle = name;
  568. }
  569. }).catch(err => {
  570. uni.showToast({
  571. title: err,
  572. icon: 'none'
  573. });
  574. });
  575. },
  576. /**
  577. * 开发票
  578. */
  579. goInvoice: function () {
  580. this.getInvoiceList()
  581. this.invShow = true;
  582. this.urlQuery =
  583. `new=${this.news}&cartId=${this.cartId}&pinkId=${this.pinkId}&couponId=${this.couponId}&addressId=${this.addressId}&specialInvoice=${this.special_invoice}&couponTitle=${this.couponTitle}`;
  584. },
  585. /**
  586. * 授权回调事件
  587. *
  588. */
  589. onLoadFun: function () {
  590. this.getaddressInfo();
  591. this.getConfirm();
  592. //调用子页面方法授权后执行获取地址列表
  593. // this.$scope.selectComponent('#address-window').getAddressList();
  594. },
  595. /**
  596. * 事件回调
  597. *
  598. */
  599. onChangeFun: function (e) {
  600. let opt = e;
  601. let action = opt.action || null;
  602. let value = opt.value != undefined ? opt.value : null;
  603. action && this[action] && this[action](value);
  604. },
  605. payClose: function () {
  606. this.pay_close = false;
  607. },
  608. goPay() {
  609. let that = this
  610. uni.showLoading({
  611. title: that.$t(`下单中`)
  612. });
  613. postBeforeCheck({
  614. goodsSpecId: this.goodsSpecId,
  615. num: this.num,
  616. userAddressId: this.addressId
  617. }).then(function (res) {
  618. //验证是否可下单
  619. if (res.code == 200) {
  620. that.freight = res.data.freight - 0
  621. that.totalPrice = res.data.freight - 0
  622. that.cartInfo.forEach(e => {
  623. that.totalPrice += (e.salePrice - 0) * (that.num - 0)
  624. })
  625. that.orderCreate()
  626. } else {
  627. this.totalPrice = 0
  628. that.$util.Tips({
  629. title: that.$t(`所选商品属性不支持下单`),
  630. success: () => {
  631. uni.hideLoading();
  632. // that.getCartCount(true);
  633. },
  634. });
  635. }
  636. })
  637. },
  638. orderCreate(){
  639. let that = this
  640. postOrderSubmit({
  641. distributeMode: 1,
  642. goodsList: [{
  643. goodsId: that.cartId,
  644. goodsNum: that.num,
  645. goodsSpecIds: that.goodsSpecId
  646. }],
  647. payType: 1,
  648. remark: that.remark,
  649. settleType: 1,
  650. userAddressId: that.addressInfo.id,
  651. wlPrice: that.freight,
  652. promotionCode: that.zoneType == 8?that.$Cache.get("INVITE_CODE"):''
  653. }).then(res => {
  654. that.orderKey = res.data.orderNo,
  655. uni.showLoading({
  656. title: that.$t(`下单成功`)
  657. });
  658. setTimeout(res => {
  659. uni.hideLoading();
  660. that.pay_close = true;
  661. }, 500)
  662. }).catch(err => {
  663. uni.hideLoading();
  664. return that.$util.Tips({
  665. title: err
  666. });
  667. });
  668. },
  669. pay_complete(type) {
  670. let that = this
  671. this.payType = type;
  672. // let url = '/pages/goods/order_pay_status/index?order_id=' + this.orderKey + '&msg=' + "支付成功" +
  673. // '&type=3' + '&totalPrice=' + this.totalPrice
  674. uni.showToast({
  675. title: that.$t(`支付成功`)
  676. })
  677. that.pay_close = false
  678. setTimeout(res => {
  679. uni.navigateBack({
  680. delta: 1
  681. })
  682. }, 1000)
  683. // this.SubOrder();
  684. },
  685. payCheck(type) {
  686. this.payType = type;
  687. // console.log(this.payType);
  688. // let url = '/pages/goods/order_pay_status/index?order_id=' + this.orderKey + '&msg=' + "支付成功" +
  689. // '&type=3' + '&totalPrice=' + this.totalPrice
  690. // uni.showToast({
  691. // title: that.$t(`支付成功`)
  692. // })
  693. // setTimeout(res => {
  694. // uni.redirectTo({
  695. // url: url
  696. // })
  697. // }, 1000)
  698. // this.SubOrder();
  699. },
  700. /**
  701. * 获取门店列表数据
  702. */
  703. getList: function () {
  704. let longitude = uni.getStorageSync("user_longitude"); //经度
  705. let latitude = uni.getStorageSync("user_latitude"); //纬度
  706. let data = {
  707. latitude: latitude, //纬度
  708. longitude: longitude, //经度
  709. page: 1,
  710. limit: 10
  711. }
  712. storeListApi(data).then(res => {
  713. let list = res.data.list.list || [];
  714. this.$set(this, 'storeList', list);
  715. this.$set(this, 'system_store', list[0]);
  716. }).catch(err => { })
  717. },
  718. // 关闭地址弹窗;
  719. changeClose: function () {
  720. this.$set(this.address, 'address', false);
  721. },
  722. /*
  723. * 跳转门店列表
  724. */
  725. showStoreList: function () {
  726. let _this = this
  727. if (this.storeList.length > 0) {
  728. uni.navigateTo({
  729. url: '/pages/goods/goods_details_store/index'
  730. })
  731. }
  732. },
  733. changePayType(type) {
  734. this.payType = type
  735. // this.computedPrice()
  736. },
  737. computedPrice: function () {
  738. let that = this
  739. postBeforeCheck({
  740. goodsSpecId: this.goodsSpecId,
  741. num: this.num,
  742. userAddressId: this.addressId
  743. }).then(function (res) {
  744. //验证是否可下单
  745. if (res.code == 200) {
  746. that.freight = res.data.freight - 0
  747. that.totalPrice = res.data.freight - 0
  748. that.cartInfo.forEach(e => {
  749. that.totalPrice += e.salePrice - 0
  750. })
  751. } else {
  752. this.totalPrice = 0
  753. that.$util.Tips({
  754. title: that.$t(`所选商品属性不支持下单`),
  755. success: () => {
  756. // that.getCartCount(true);
  757. },
  758. });
  759. }
  760. })
  761. },
  762. addressType(e) {
  763. let index = e;
  764. let that = this;
  765. if (this.shippingType == parseInt(index)) return
  766. this.shippingType = parseInt(index);
  767. if (index == 1) {
  768. // #ifdef H5
  769. if (that.$wechat.isWeixin()) {
  770. that.$wechat.location().then(res => {
  771. uni.setStorageSync('user_latitude', res.latitude);
  772. uni.setStorageSync('user_longitude', res.longitude);
  773. this.getList()
  774. }).catch(err => {
  775. this.getList()
  776. })
  777. } else {
  778. // #endif
  779. uni.getLocation({
  780. type: 'wgs84',
  781. success: (res) => {
  782. uni.setStorageSync('user_latitude', res.latitude);
  783. uni.setStorageSync('user_longitude', res.longitude);
  784. this.getList()
  785. },
  786. complete: () => {
  787. this.getList()
  788. }
  789. });
  790. // #ifdef H5
  791. }
  792. // #endif
  793. };
  794. this.$nextTick(e => {
  795. this.getConfirm();
  796. this.computedPrice();
  797. })
  798. },
  799. bindPickerChange: function (e) {
  800. let value = e.detail.value;
  801. this.shippingType = value;
  802. this.computedPrice();
  803. },
  804. ChangCouponsClone: function () {
  805. this.$set(this.coupon, 'coupon', false);
  806. },
  807. changeTextareaStatus: function () {
  808. for (let i = 0, len = this.coupon.list.length; i < len; i++) {
  809. this.coupon.list[i].use_title = '';
  810. this.coupon.list[i].is_use = 0;
  811. }
  812. this.textareaStatus = true;
  813. this.status = 0;
  814. this.$set(this.coupon, 'list', this.coupon.list);
  815. },
  816. /**
  817. * 处理点击优惠券后的事件
  818. *
  819. */
  820. ChangCoupons: function (e) {
  821. // this.usableCoupon = e
  822. // this.coupon.coupon = false
  823. let index = e,
  824. list = this.coupon.list,
  825. couponTitle = this.$t(`请选择`),
  826. couponId = 0;
  827. for (let i = 0, len = list.length; i < len; i++) {
  828. if (i != index) {
  829. list[i].use_title = '';
  830. list[i].is_use = 0;
  831. }
  832. }
  833. if (list[index].is_use) {
  834. //不使用优惠券
  835. list[index].use_title = '';
  836. list[index].is_use = 0;
  837. } else {
  838. //使用优惠券
  839. list[index].use_title = this.$t(`不使用`);
  840. list[index].is_use = 1;
  841. couponTitle = list[index].coupon_title;
  842. couponId = list[index].id;
  843. }
  844. this.couponTitle = couponTitle;
  845. this.couponId = couponId;
  846. this.$set(this.coupon, 'coupon', false);
  847. this.$set(this.coupon, 'list', list);
  848. this.computedPrice();
  849. },
  850. /**
  851. * 使用积分抵扣
  852. */
  853. ChangeIntegral: function () {
  854. this.useIntegral = !this.useIntegral;
  855. this.computedPrice();
  856. },
  857. /**
  858. * 选择地址后改变事件
  859. * @param object e
  860. */
  861. OnChangeAddress: function (e) {
  862. this.textareaStatus = true;
  863. this.addressId = e;
  864. this.address.address = false;
  865. this.getConfirm()
  866. this.getaddressInfo();
  867. this.computedPrice();
  868. },
  869. bindHideKeyboard: function (e) {
  870. this.mark = e.detail.value;
  871. },
  872. /**
  873. * 获取当前订单详细信息
  874. *
  875. */
  876. getConfirm: function () {
  877. let that = this;
  878. // return;
  879. uni.showLoading({
  880. title: that.$t(`正在加载中`),
  881. mask: true
  882. });
  883. getGoodsDetail({ id: that.cartId })
  884. .then((res) => {
  885. that.cartInfo = []
  886. let porject = res.data
  887. that.zoneType = porject.zoneType
  888. //找出选择的规格
  889. porject.goodsSpecList.forEach(element => {
  890. if (that.goodsSpecId == element.id) {
  891. porject.unit = element.spceName
  892. }
  893. });
  894. porject.totalSales = that.num
  895. // 计算总价
  896. that.totalPrice = (that.num - 0) * (porject.salePrice - 0) + that.freight - 0
  897. that.cartInfo.push(porject)
  898. uni.hideLoading()
  899. })
  900. .catch((err) => {
  901. uni.hideLoading()
  902. return this.$util.Tips({
  903. title: err
  904. });
  905. });
  906. // orderConfirm(that.cartId, that.news, that.addressId, that.shippingType + 1).then(res => {
  907. // that.$set(that, 'userInfo', res.data.userInfo);
  908. // that.$set(that, 'confirm', res.data.custom_form || []);
  909. // this.confirm.map(e => {
  910. // if (e.label === 'img') e.value = []
  911. // })
  912. // that.$set(that, 'integral', res.data.usable_integral);
  913. // that.$set(that, 'usable_integral', res.data.usable_integral);
  914. // that.$set(that, 'contacts', res.data.userInfo.real_name);
  915. // that.$set(that, 'contactsTel', res.data.userInfo.record_phone === '0' ? '' : res.data
  916. // .userInfo.record_phone);
  917. // that.$set(that, 'cartInfo', res.data.cartInfo);
  918. // that.$set(that, 'integralRatio', res.data.integralRatio);
  919. // that.$set(that, 'offlinePostage', res.data.offlinePostage);
  920. // that.$set(that, 'orderKey', res.data.orderKey);
  921. // that.$set(that, 'valid_count', res.data.valid_count);
  922. // that.$set(that, 'discount_id', res.data.discount_id)
  923. // that.$set(that, 'priceGroup', res.data.priceGroup);
  924. // that.$set(that, 'totalPrice', that.$util.$h.Add(parseFloat(res.data.priceGroup.totalPrice),
  925. // parseFloat(res.data
  926. // .priceGroup.storePostage)));
  927. // that.$set(that, 'seckillId', parseInt(res.data.seckill_id));
  928. // that.$set(that, 'invoice_func', res.data.invoice_func);
  929. // that.$set(that, 'special_invoice', res.data.special_invoice);
  930. // that.$set(that, 'store_self_mention', res.data.store_self_mention);
  931. // that.$set(that, 'virtual_type', res.data.virtual_type || 0);
  932. // //微信支付是否开启
  933. // that.cartArr[0].payStatus = res.data.pay_weixin_open || 0
  934. // //支付宝是否开启
  935. // that.cartArr[1].payStatus = res.data.ali_pay_status || 0;
  936. // //#ifdef MP
  937. // that.cartArr[1].payStatus = 0;
  938. // //#endif
  939. // //余额支付是否开启
  940. // // that.cartArr[2].title = '可用余额:' + res.data.userInfo.now_money;
  941. // that.cartArr[2].number = res.data.userInfo.now_money;
  942. // that.cartArr[2].payStatus = res.data.yue_pay_status == 1 ? res.data.yue_pay_status : 0
  943. // if (res.data.offline_pay_status == 2 || res.data.deduction) {
  944. // that.cartArr[3].payStatus = 0
  945. // } else {
  946. // that.cartArr[3].payStatus = 1
  947. // }
  948. // //好友代付是否开启
  949. // that.cartArr[4].payStatus = res.data.friend_pay_status || 0;
  950. // // that.$set(that, 'cartArr', that.cartArr);
  951. // that.$set(that, 'ChangePrice', that.totalPrice);
  952. // that.getBargainId();
  953. // that.getCouponList();
  954. // if (this.addressId) {
  955. // this.computedPrice();
  956. // }
  957. // uni.hideLoading()
  958. // }).catch(err => {
  959. // uni.hideLoading()
  960. // return this.$util.Tips({
  961. // title: err
  962. // });
  963. // });
  964. },
  965. /*
  966. * 提取砍价和拼团id
  967. */
  968. getBargainId: function () {
  969. let that = this;
  970. let cartINfo = that.cartInfo;
  971. let BargainId = 0;
  972. let combinationId = 0;
  973. let discountId = 0;
  974. let advanceId = 0;
  975. cartINfo.forEach(function (value, index, cartINfo) {
  976. BargainId = cartINfo[index].bargain_id,
  977. combinationId = cartINfo[index].combination_id,
  978. discountId = cartINfo[index].discount_id,
  979. advanceId = cartINfo[index].advance_id
  980. })
  981. that.$set(that, 'BargainId', parseInt(BargainId));
  982. that.$set(that, 'combinationId', parseInt(combinationId));
  983. that.$set(that, 'discountId', parseInt(discountId));
  984. that.$set(that, 'advanceId', parseInt(advanceId));
  985. if (that.cartArr.length == 3 && (BargainId || combinationId || that.seckillId || discountId)) {
  986. that.cartArr[2].payStatus = 0;
  987. that.$set(that, 'cartArr', that.cartArr);
  988. }
  989. },
  990. /**
  991. * 获取当前金额可用优惠券
  992. *
  993. */
  994. getCouponList: function () {
  995. let that = this;
  996. let data = {
  997. cartId: this.cartId,
  998. 'new': this.news
  999. }
  1000. getCouponsOrderPrice(this.totalPrice, data).then(res => {
  1001. that.$set(that.coupon, 'list', res.data);
  1002. that.openType = 1;
  1003. });
  1004. },
  1005. /*
  1006. * 获取默认收货地址或者获取某条地址信息
  1007. */
  1008. getaddressInfo: function () {
  1009. let that = this;
  1010. if (that.addressId) {
  1011. getUserAddressByIdAndFreight({ id: that.addressId }).then(res => {
  1012. res.data.is_default = parseInt(res.data.is_default);
  1013. that.addressInfo = res.data || {};
  1014. that.addressId = res.data.id || 0;
  1015. that.address.addressId = res.data.id || 0;
  1016. })
  1017. } else {
  1018. getAddressDefault().then(res => {
  1019. res.data.is_default = parseInt(res.data.is_default);
  1020. that.addressInfo = res.data || {};
  1021. that.addressId = res.data.id || 0;
  1022. that.address.addressId = res.data.id || 0;
  1023. })
  1024. }
  1025. },
  1026. payItem: function (e) {
  1027. let that = this;
  1028. let active = e;
  1029. that.active = active;
  1030. that.animated = true;
  1031. that.payType = that.cartArr[active].value;
  1032. that.computedPrice();
  1033. setTimeout(function () {
  1034. that.car();
  1035. }, 500);
  1036. },
  1037. couponTap: function () {
  1038. this.coupon.coupon = true;
  1039. this.coupon.list.forEach((item, index) => {
  1040. if (item.id == this.couponId) {
  1041. item.is_use = 1
  1042. } else {
  1043. item.is_use = 0
  1044. }
  1045. })
  1046. this.$set(this.coupon, 'list', this.coupon.list);
  1047. },
  1048. car: function () {
  1049. let that = this;
  1050. that.animated = false;
  1051. },
  1052. onAddress: function () {
  1053. let that = this;
  1054. that.textareaStatus = false;
  1055. that.address.address = true;
  1056. that.pagesUrl = '/pages/users/user_address_list/index?news=' + this.news + '&cartId=' + this.cartId +
  1057. '&pinkId=' +
  1058. this.pinkId +
  1059. '&couponId=' +
  1060. this.couponId;
  1061. },
  1062. payment(data) {
  1063. let that = this;
  1064. // postOrderSubmit({
  1065. // distributeMode: 1,
  1066. // goodsList: [{
  1067. // goodsId: that.cartId,
  1068. // goodsNum: that.num,
  1069. // goodsSpecIds: that.goodsSpecId
  1070. // }],
  1071. // payType: 1,
  1072. // remark: that.remark,
  1073. // settleType: 1,
  1074. // userAddressId: that.addressInfo.id,
  1075. // wlPrice: that.freight
  1076. // }).then(res => {
  1077. // let status = "",
  1078. // orderId = res.data.orderNo,
  1079. // jsConfig = {},
  1080. // goPages = '/pages/goods/order_pay_status/index?order_id=' + orderId + '&msg=' + "支付成功" +
  1081. // '&type=3' + '&totalPrice=' + this.totalPrice
  1082. // that.toPay = true;
  1083. // uni.requestPayment({
  1084. // provider: 'wxpay',
  1085. // orderInfo: jsConfig,
  1086. // success: (e) => {
  1087. // let url = goPages;
  1088. // uni.showToast({
  1089. // title: that.$t(`支付成功`)
  1090. // })
  1091. // setTimeout(res => {
  1092. // uni.redirectTo({
  1093. // url: url
  1094. // })
  1095. // }, 2000)
  1096. // },
  1097. // fail: (e) => {
  1098. // let url = '/pages/goods/order_pay_status/index?order_id=' +
  1099. // orderId +
  1100. // '&msg=' + that.$t(`支付失败`);
  1101. // uni.showModal({
  1102. // content: that.$t(`支付失败`),
  1103. // showCancel: false,
  1104. // success: function (res) {
  1105. // if (res.confirm) {
  1106. // uni.redirectTo({
  1107. // url: url
  1108. // })
  1109. // } else if (res.cancel) { }
  1110. // }
  1111. // })
  1112. // },
  1113. // complete: () => {
  1114. // uni.hideLoading();
  1115. // },
  1116. // });
  1117. // switch (status) {
  1118. // case 'ORDER_EXIST':
  1119. // case 'EXTEND_ORDER':
  1120. // case 'PAY_ERROR':
  1121. // uni.hideLoading();
  1122. // return that.$util.Tips({
  1123. // title: res.msg
  1124. // }, {
  1125. // tab: 5,
  1126. // url: goPages
  1127. // });
  1128. // break;
  1129. // case 'SUCCESS':
  1130. // uni.hideLoading();
  1131. // if ((that.BargainId || that.combinationId || that.pinkId || that.seckillId || that
  1132. // .discountId) && data.payType != 'friend')
  1133. // return that.$util.Tips({
  1134. // title: res.msg,
  1135. // icon: 'success'
  1136. // }, {
  1137. // tab: 4,
  1138. // url: goPages
  1139. // });
  1140. // return that.$util.Tips({
  1141. // title: res.msg,
  1142. // icon: 'success'
  1143. // }, {
  1144. // tab: 4,
  1145. // url: data.payType == 'friend' ? friendPay : goPages
  1146. // });
  1147. // break;
  1148. // case 'WECHAT_PAY':
  1149. // that.toPay = true;
  1150. // // #ifdef MP
  1151. // /* that.toPay = true; */
  1152. // let mp_pay_name = ''
  1153. // if (uni.requestOrderPayment) {
  1154. // mp_pay_name = 'requestOrderPayment'
  1155. // } else {
  1156. // mp_pay_name = 'requestPayment'
  1157. // }
  1158. // uni[mp_pay_name]({
  1159. // timeStamp: jsConfig.timestamp,
  1160. // nonceStr: jsConfig.nonceStr,
  1161. // package: jsConfig.package,
  1162. // signType: jsConfig.signType,
  1163. // paySign: jsConfig.paySign,
  1164. // success: function (res) {
  1165. // uni.hideLoading();
  1166. // if (that.BargainId || that.combinationId || that.pinkId || that
  1167. // .seckillId || that.discountId)
  1168. // return that.$util.Tips({
  1169. // title: that.$t(`支付成功`),
  1170. // icon: 'success'
  1171. // }, {
  1172. // tab: 4,
  1173. // url: goPages
  1174. // });
  1175. // return that.$util.Tips({
  1176. // title: that.$t(`支付成功`),
  1177. // icon: 'success'
  1178. // }, {
  1179. // tab: 5,
  1180. // url: goPages
  1181. // });
  1182. // },
  1183. // fail: function (e) {
  1184. // uni.hideLoading();
  1185. // return that.$util.Tips({
  1186. // title: that.$t(`取消支付`)
  1187. // }, {
  1188. // tab: 5,
  1189. // url: goPages + '&status=2'
  1190. // });
  1191. // },
  1192. // complete: function (e) {
  1193. // uni.hideLoading();
  1194. // //关闭当前页面跳转至订单状态
  1195. // if (res.errMsg == 'requestPayment:cancel' || e.errMsg ==
  1196. // 'requestOrderPayment:cancel') return that.$util
  1197. // .Tips({
  1198. // title: that.$t(`取消支付`)
  1199. // }, {
  1200. // tab: 5,
  1201. // url: goPages + '&status=2'
  1202. // });
  1203. // },
  1204. // })
  1205. // // #endif
  1206. // // #ifdef H5
  1207. // this.$wechat.pay(res.data.result.jsConfig).then(res => {
  1208. // return that.$util.Tips({
  1209. // title: that.$t(`支付成功`),
  1210. // icon: 'success'
  1211. // }, {
  1212. // tab: 5,
  1213. // url: goPages
  1214. // });
  1215. // }).catch(res => {
  1216. // if (!this.$wechat.isWeixin()) {
  1217. // uni.redirectTo({
  1218. // url: goPages + '&msg=' + that.$t(`支付失败`) + '&status=2'
  1219. // // '&msg=支付失败&status=2'
  1220. // })
  1221. // }
  1222. // if (res.errMsg == 'chooseWXPay:cancel') return that.$util.Tips({
  1223. // title: that.$t(`取消支付`)
  1224. // }, {
  1225. // tab: 5,
  1226. // url: goPages + '&status=2'
  1227. // });
  1228. // })
  1229. // // #endif
  1230. // // #ifdef APP-PLUS
  1231. // uni.requestPayment({
  1232. // provider: 'wxpay',
  1233. // orderInfo: jsConfig,
  1234. // success: (e) => {
  1235. // let url = goPages;
  1236. // uni.showToast({
  1237. // title: that.$t(`支付成功`)
  1238. // })
  1239. // setTimeout(res => {
  1240. // uni.redirectTo({
  1241. // url: url
  1242. // })
  1243. // }, 2000)
  1244. // },
  1245. // fail: (e) => {
  1246. // let url = '/pages/goods/order_pay_status/index?order_id=' +
  1247. // orderId +
  1248. // '&msg=' + that.$t(`支付失败`);
  1249. // uni.showModal({
  1250. // content: that.$t(`支付失败`),
  1251. // showCancel: false,
  1252. // success: function (res) {
  1253. // if (res.confirm) {
  1254. // uni.redirectTo({
  1255. // url: url
  1256. // })
  1257. // } else if (res.cancel) { }
  1258. // }
  1259. // })
  1260. // },
  1261. // complete: () => {
  1262. // uni.hideLoading();
  1263. // },
  1264. // });
  1265. // // #endif
  1266. // break;
  1267. // case 'PAY_DEFICIENCY':
  1268. // uni.hideLoading();
  1269. // //余额不足
  1270. // return that.$util.Tips({
  1271. // title: res.msg
  1272. // }, {
  1273. // tab: 5,
  1274. // url: goPages + '&status=1'
  1275. // });
  1276. // break;
  1277. // case "WECHAT_H5_PAY":
  1278. // uni.hideLoading();
  1279. // that.$util.Tips({
  1280. // title: that.$t(`订单创建成功`)
  1281. // }, {
  1282. // tab: 4,
  1283. // url: goPages + '&status=0'
  1284. // });
  1285. // setTimeout(() => {
  1286. // location.href = res.data.result.jsConfig.mweb_url;
  1287. // }, 2000);
  1288. // break;
  1289. // case 'ALIPAY_PAY':
  1290. // //#ifdef H5
  1291. // if (this.from === 'weixin') {
  1292. // uni.redirectTo({
  1293. // url: `/pages/users/alipay_invoke/index?id=${orderId}&pay_key=${res.data.result.pay_key}`
  1294. // });
  1295. // } else {
  1296. // uni.hideLoading();
  1297. // that.formContent = res.data.result.jsConfig;
  1298. // that.$nextTick(() => {
  1299. // document.getElementById('alipaysubmit').submit();
  1300. // })
  1301. // }
  1302. // //#endif
  1303. // // #ifdef MP
  1304. // uni.navigateTo({
  1305. // url: `/pages/users/alipay_invoke/index?id=${orderId}&link=${jsConfig.qrCode}`
  1306. // });
  1307. // // #endif
  1308. // // #ifdef APP-PLUS
  1309. // uni.requestPayment({
  1310. // provider: 'alipay',
  1311. // orderInfo: jsConfig,
  1312. // success: (e) => {
  1313. // uni.showToast({
  1314. // title: that.$t(`支付成功`)
  1315. // })
  1316. // let url = '/pages/goods/order_pay_status/index?order_id=' +
  1317. // orderId +
  1318. // '&msg=' + that.$t(`支付成功`);
  1319. // setTimeout(res => {
  1320. // uni.redirectTo({
  1321. // url: url
  1322. // })
  1323. // }, 2000)
  1324. // },
  1325. // fail: (e) => {
  1326. // let url = '/pages/goods/order_pay_status/index?order_id=' +
  1327. // orderId +
  1328. // '&msg=' + that.$t(`支付失败`);
  1329. // uni.showModal({
  1330. // content: that.$t(`支付失败`),
  1331. // showCancel: false,
  1332. // success: function (res) {
  1333. // if (res.confirm) {
  1334. // uni.redirectTo({
  1335. // url: url
  1336. // })
  1337. // } else if (res.cancel) { }
  1338. // }
  1339. // })
  1340. // },
  1341. // complete: () => {
  1342. // uni.hideLoading();
  1343. // },
  1344. // });
  1345. // // #endif
  1346. // break;
  1347. // }
  1348. // }).catch(err => {
  1349. // uni.hideLoading();
  1350. // return that.$util.Tips({
  1351. // title: err
  1352. // });
  1353. // });
  1354. },
  1355. clickTextArea() {
  1356. this.$refs.textarea.focus()
  1357. },
  1358. SubOrder(e) {
  1359. let that = this,
  1360. data = {};
  1361. if (!that.payType) return that.$util.Tips({
  1362. title: that.$t(`请选择支付方式`)
  1363. });
  1364. if (!that.addressId && !that.shippingType && !that.virtual_type) return that.$util.Tips({
  1365. title: that.$t(`请选择收货地址`)
  1366. });
  1367. if (that.shippingType == 1) {
  1368. if (that.contacts == "" || that.contactsTel == "") {
  1369. return that.$util.Tips({
  1370. title: that.$t(`请填写联系人或联系人电话`)
  1371. });
  1372. }
  1373. if (!/^1(3|4|5|7|8|9|6)\d{9}$/.test(that.contactsTel)) {
  1374. return that.$util.Tips({
  1375. title: that.$t(`请输入正确的手机号码`)
  1376. });
  1377. }
  1378. if (!that.contacts) {
  1379. return that.$util.Tips({
  1380. title: that.$t(`请输入姓名`)
  1381. });
  1382. }
  1383. if (that.storeList.length == 0) return that.$util.Tips({
  1384. title: that.$t(`暂无门店,请选择其他方式`)
  1385. });
  1386. }
  1387. for (var i = 0; i < that.confirm.length; i++) {
  1388. let data = that.confirm[i]
  1389. if (data.status) {
  1390. if (data.label === 'text' || data.label === 'data' || data.label === 'time' || data.label ===
  1391. 'id') {
  1392. if (!data.value.trim()) {
  1393. return uni.showToast({
  1394. title: that.$t(`请输入`) + `${data.title}`,
  1395. icon: 'none'
  1396. });
  1397. }
  1398. }
  1399. if (data.label === 'number') {
  1400. if (data.value <= 0) {
  1401. return uni.showToast({
  1402. title: that.$t(`请输入`) + `${data.title}`,
  1403. icon: 'none'
  1404. });
  1405. }
  1406. }
  1407. if (data.label === 'email') {
  1408. if (!/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/.test(data.value)) {
  1409. return uni.showToast({
  1410. title: that.$t(`请输入正确的`) + `${data.title}`,
  1411. icon: 'none'
  1412. });
  1413. }
  1414. }
  1415. if (data.label === 'phone') {
  1416. if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(data.value)) {
  1417. return uni.showToast({
  1418. title: that.$t(`请输入正确的`) + `${data.title}`,
  1419. icon: 'none'
  1420. });
  1421. }
  1422. }
  1423. if (data.label === 'img') {
  1424. if (!data.value.length) {
  1425. return uni.showToast({
  1426. title: that.$t(`请上传`) + `${data.title}`,
  1427. icon: 'none'
  1428. });
  1429. }
  1430. }
  1431. }
  1432. }
  1433. data = {
  1434. custom_form: that.confirm,
  1435. real_name: that.contacts,
  1436. phone: that.contactsTel,
  1437. addressId: that.addressId,
  1438. formId: '',
  1439. couponId: that.couponId,
  1440. payType: that.payType,
  1441. useIntegral: that.useIntegral,
  1442. bargainId: that.BargainId,
  1443. combinationId: that.combinationId,
  1444. discountId: that.discountId,
  1445. pinkId: that.pinkId,
  1446. advanceId: that.advanceId,
  1447. seckill_id: that.seckillId,
  1448. mark: that.mark,
  1449. store_id: that.system_store ? that.system_store.id : 0,
  1450. 'from': that.from,
  1451. shipping_type: that.$util.$h.Add(that.shippingType, 1),
  1452. 'new': that.news,
  1453. 'invoice_id': that.invChecked,
  1454. // #ifdef H5
  1455. quitUrl: location.protocol + '//' + location.hostname +
  1456. '/pages/goods/order_pay_status/index?' +
  1457. '&type=3' + '&totalPrice=' + this.totalPrice
  1458. // #endif
  1459. // #ifdef APP-PLUS
  1460. quitUrl: '/pages/goods/order_details/index?order_id=' + this.order_id
  1461. // #endif
  1462. };
  1463. if (data.payType == 'yue' && parseFloat(that.userInfo.now_money) < parseFloat(that.totalPrice))
  1464. return that.$util.Tips({
  1465. title: that.$t(`余额不足`)
  1466. });
  1467. uni.showLoading({
  1468. title: that.$t(`订单支付中`)
  1469. });
  1470. // #ifdef MP
  1471. openPaySubscribe().then(() => {
  1472. that.payment(data);
  1473. });
  1474. // #endif
  1475. // #ifndef MP
  1476. that.payment(data);
  1477. // #endif
  1478. },
  1479. bindDateChange: function (e, index) {
  1480. this.confirm[index].value = e.target.value
  1481. },
  1482. bindTimeChange: function (e, index) {
  1483. this.confirm[index].value = e.target.value
  1484. },
  1485. getDate(type) {
  1486. const date = new Date();
  1487. let year = date.getFullYear();
  1488. let month = date.getMonth() + 1;
  1489. let day = date.getDate();
  1490. if (type === 'start') {
  1491. year = year - 60;
  1492. } else if (type === 'end') {
  1493. year = year + 2;
  1494. }
  1495. month = month > 9 ? month : '0' + month;
  1496. day = day > 9 ? day : '0' + day;
  1497. return `${year}-${month}-${day}`;
  1498. },
  1499. uploadpic: function (index, item) {
  1500. let that = this;
  1501. this.canvasStatus = true
  1502. that.$util.uploadImageChange('upload/image', function (res) {
  1503. item.value.push(res.data.url);
  1504. }, (res) => {
  1505. this.canvasStatus = false
  1506. }, (res) => {
  1507. this.canvasWidth = res.w
  1508. this.canvasHeight = res.h
  1509. });
  1510. },
  1511. DelPic: function (index, indexs) {
  1512. let that = this,
  1513. pic = this.confirm[index].value;
  1514. that.confirm[index].value.splice(indexs, 1);
  1515. // that.$set(that, 'pics', that.pics);
  1516. },
  1517. inputTripClick() {
  1518. this.inputTrip = true
  1519. // this.$refs.trip.foucs()
  1520. },
  1521. }
  1522. }
  1523. </script>
  1524. <style lang="scss" scoped>
  1525. /deep/uni-checkbox[disabled] .uni-checkbox-input {
  1526. background-color: #eee;
  1527. }
  1528. .alipaysubmit {
  1529. display: none;
  1530. }
  1531. .order-submission .line {
  1532. width: 100%;
  1533. height: 3rpx;
  1534. }
  1535. .order-submission .line image {
  1536. width: 100%;
  1537. height: 100%;
  1538. display: block;
  1539. }
  1540. .order-submission .address {
  1541. padding: 28rpx 30rpx;
  1542. background-color: #fff;
  1543. box-sizing: border-box;
  1544. }
  1545. .order-submission .address .addressCon {
  1546. width: 610rpx;
  1547. font-size: 26rpx;
  1548. color: #666;
  1549. }
  1550. .order-submission .address .addressCon .name {
  1551. font-size: 30rpx;
  1552. color: #282828;
  1553. font-weight: bold;
  1554. margin-bottom: 10rpx;
  1555. }
  1556. .order-submission .address .addressCon .name .phone {
  1557. margin-left: 50rpx;
  1558. }
  1559. .order-submission .address .addressCon .default {
  1560. margin-right: 12rpx;
  1561. }
  1562. .order-submission .address .addressCon .setaddress {
  1563. color: #333;
  1564. font-size: 28rpx;
  1565. }
  1566. .order-submission .address .iconfont {
  1567. font-size: 35rpx;
  1568. color: #707070;
  1569. }
  1570. .order-submission .allAddress {
  1571. width: 100%;
  1572. background: linear-gradient(to bottom, var(--view-theme) 0%, #f5f5f5 100%);
  1573. padding-top: 100rpx;
  1574. margin-bottom: 12rpx;
  1575. }
  1576. .order-submission .allAddress .nav {
  1577. width: 710rpx;
  1578. margin: 0 auto;
  1579. }
  1580. .order-submission .allAddress .nav .item {
  1581. width: 355rpx;
  1582. }
  1583. .order-submission .allAddress .nav .item.on {
  1584. position: relative;
  1585. width: 250rpx;
  1586. }
  1587. .order-submission .allAddress .nav .item.on::before {
  1588. position: absolute;
  1589. bottom: 0;
  1590. content: "快递配送";
  1591. font-size: 28rpx;
  1592. display: block;
  1593. height: 0;
  1594. width: 336rpx;
  1595. border-width: 0 20rpx 80rpx 0;
  1596. border-style: none solid solid;
  1597. border-color: transparent transparent #fff;
  1598. z-index: 2;
  1599. border-radius: 7rpx 30rpx 0 0;
  1600. text-align: center;
  1601. line-height: 80rpx;
  1602. }
  1603. .order-submission .allAddress .nav .item:nth-of-type(2).on::before {
  1604. content: "到店自提";
  1605. border-width: 0 0 80rpx 20rpx;
  1606. border-radius: 30rpx 7rpx 0 0;
  1607. }
  1608. .order-submission .allAddress .nav .item.on2 {
  1609. position: relative;
  1610. }
  1611. .order-submission .allAddress .nav .item.on2::before {
  1612. position: absolute;
  1613. bottom: 0;
  1614. content: "到店自提";
  1615. font-size: 28rpx;
  1616. display: block;
  1617. height: 0;
  1618. width: 400rpx;
  1619. border-width: 0 0 60rpx 60rpx;
  1620. border-style: none solid solid;
  1621. border-color: transparent transparent rgba(255, 255, 255, 0.6);
  1622. border-radius: 40rpx 6rpx 0 0;
  1623. text-align: center;
  1624. line-height: 60rpx;
  1625. }
  1626. .order-submission .allAddress .nav .item:nth-of-type(1).on2::before {
  1627. content: "快递配送";
  1628. border-width: 0 60rpx 60rpx 0;
  1629. border-radius: 6rpx 40rpx 0 0;
  1630. }
  1631. .order-submission .allAddress .address {
  1632. width: 710rpx;
  1633. height: 150rpx;
  1634. margin: 0 auto;
  1635. }
  1636. .order-submission .allAddress .line {
  1637. width: 710rpx;
  1638. margin: 0 auto;
  1639. }
  1640. .order-submission .wrapper .item .discount .placeholder {
  1641. color: #ccc;
  1642. }
  1643. .placeholder-textarea {
  1644. position: relative;
  1645. .placeholder {
  1646. position: absolute;
  1647. color: #ccc;
  1648. top: 26rpx;
  1649. left: 30rpx;
  1650. }
  1651. }
  1652. .order-submission .wrapper {
  1653. background-color: #fff;
  1654. margin-top: 13rpx;
  1655. }
  1656. .order-submission .wrapper .item {
  1657. padding: 27rpx 30rpx;
  1658. font-size: 30rpx;
  1659. color: #282828;
  1660. border-bottom: 1px solid #f0f0f0;
  1661. .mark {
  1662. background-color: #f9f9f9;
  1663. width: 345px;
  1664. height: 70px;
  1665. border-radius: 1px;
  1666. margin-top: 15px;
  1667. padding: 12px 14px;
  1668. color: #ccc;
  1669. font-size: 28rpx;
  1670. box-sizing: border-box;
  1671. }
  1672. .mark-msg {
  1673. color: #333;
  1674. font-size: 32rpx;
  1675. }
  1676. }
  1677. .order-submission .wrapper .item .discount {
  1678. font-size: 30rpx;
  1679. color: #999;
  1680. }
  1681. .order-submission .wrapper .item .discount input {
  1682. text-align: end;
  1683. }
  1684. .order-submission .wrapper .item .discount .iconfont {
  1685. color: #515151;
  1686. font-size: 30rpx;
  1687. margin-left: 15rpx;
  1688. }
  1689. .order-submission .wrapper .item .discount .num {
  1690. font-size: 32rpx;
  1691. margin-right: 20rpx;
  1692. }
  1693. .order-submission .wrapper .item .shipping {
  1694. font-size: 30rpx;
  1695. color: #999;
  1696. position: relative;
  1697. padding-right: 58rpx;
  1698. }
  1699. .order-submission .wrapper .item .shipping .iconfont {
  1700. font-size: 35rpx;
  1701. color: #707070;
  1702. position: absolute;
  1703. right: 0;
  1704. top: 50%;
  1705. transform: translateY(-50%);
  1706. margin-left: 30rpx;
  1707. }
  1708. .order-submission .wrapper .item textarea {
  1709. background-color: #f9f9f9;
  1710. width: 690rpx;
  1711. height: 140rpx;
  1712. border-radius: 3rpx;
  1713. margin-top: 30rpx;
  1714. padding: 25rpx 28rpx;
  1715. box-sizing: border-box;
  1716. }
  1717. .order-submission .wrapper .item .placeholder {
  1718. color: #ccc;
  1719. font-size: 28rpx;
  1720. }
  1721. .order-submission .wrapper .item .list {
  1722. margin-top: 35rpx;
  1723. }
  1724. .order-submission .wrapper .item .list .payItem {
  1725. border: 1px solid #eee;
  1726. border-radius: 6rpx;
  1727. height: 86rpx;
  1728. width: 100%;
  1729. box-sizing: border-box;
  1730. margin-top: 20rpx;
  1731. font-size: 28rpx;
  1732. color: #282828;
  1733. }
  1734. .order-submission .wrapper .item .list .payItem.on {
  1735. border-color: #fc5445;
  1736. color: #e93323;
  1737. }
  1738. .order-submission .wrapper .item .list .payItem .name {
  1739. width: 50%;
  1740. text-align: center;
  1741. border-right: 1px solid #eee;
  1742. padding-left: 80rpx;
  1743. }
  1744. .order-submission .wrapper .item .list .payItem .name .iconfont {
  1745. width: 44rpx;
  1746. height: 44rpx;
  1747. border-radius: 50%;
  1748. text-align: center;
  1749. line-height: 44rpx;
  1750. background-color: #fe960f;
  1751. color: #fff;
  1752. font-size: 30rpx;
  1753. margin-right: 15rpx;
  1754. }
  1755. .order-submission .wrapper .item .list .payItem .name .iconfont.icon-weixin2 {
  1756. background-color: #41b035;
  1757. }
  1758. .order-submission .wrapper .item .list .payItem .name .iconfont.icon-zhifubao {
  1759. background-color: #1677FF;
  1760. }
  1761. .order-submission .wrapper .item .list .payItem .tip {
  1762. width: 49%;
  1763. text-align: center;
  1764. font-size: 26rpx;
  1765. color: #aaa;
  1766. }
  1767. .order-submission .moneyList {
  1768. margin-top: 12rpx;
  1769. background-color: #fff;
  1770. padding: 30rpx;
  1771. }
  1772. .order-submission .moneyList .item {
  1773. font-size: 28rpx;
  1774. color: #282828;
  1775. }
  1776. .order-submission .moneyList .item~.item {
  1777. margin-top: 20rpx;
  1778. }
  1779. .order-submission .moneyList .item .money {
  1780. color: #868686;
  1781. }
  1782. .order-submission .footer {
  1783. width: 100%;
  1784. height: 100rpx;
  1785. background-color: #fff;
  1786. padding: 0 30rpx;
  1787. font-size: 28rpx;
  1788. color: #333;
  1789. box-sizing: border-box;
  1790. position: fixed;
  1791. bottom: 0;
  1792. left: 0;
  1793. z-index: 9;
  1794. }
  1795. .order-submission .footer .settlement {
  1796. font-size: 30rpx;
  1797. color: #fff;
  1798. width: 240rpx;
  1799. height: 70rpx;
  1800. background-color: var(--view-theme);
  1801. border-radius: 50rpx;
  1802. text-align: center;
  1803. line-height: 70rpx;
  1804. }
  1805. .footer .transparent {
  1806. opacity: 0
  1807. }
  1808. .confirm {
  1809. text-align: right;
  1810. font-size: 22rpx;
  1811. }
  1812. .confirmImg {
  1813. width: 100%;
  1814. .img {
  1815. width: 136rpx;
  1816. height: 136rpx;
  1817. }
  1818. .pictrue {
  1819. width: 136rpx;
  1820. height: 136rpx;
  1821. box-sizing: border-box;
  1822. margin: 18rpx;
  1823. margin-bottom: 35rpx;
  1824. position: relative;
  1825. font-size: 22rpx;
  1826. color: #bbb;
  1827. .del {
  1828. position: absolute;
  1829. top: 0;
  1830. right: 0;
  1831. }
  1832. }
  1833. .bor {
  1834. border: 1rpx solid #ddd;
  1835. }
  1836. }
  1837. .fontC {
  1838. color: grey;
  1839. }
  1840. </style>