index.vue 49 KB

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