index.vue 50 KB

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