index.vue 52 KB

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