index.vue 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225
  1. <template>
  2. <view>
  3. <view class='order-submission'>
  4. <view class="allAddress" :style="store_self_mention ? '':'padding-top:10rpx'">
  5. <!-- <view class="nav acea-row">
  6. <view class="item font-color" :class="shippingType == 0 ? 'on' : 'on2'" @tap="addressType(0)" v-if='store_self_mention'></view>
  7. <view class="item font-color" :class="shippingType == 1 ? 'on' : 'on2'" @tap="addressType(1)" v-if='store_self_mention'></view>
  8. </view> -->
  9. <view class='address acea-row row-between-wrapper' @tap='onAddress' v-if='shippingType == 0'>
  10. <view class='addressCon' v-if="addressInfo.real_name">
  11. <view class='name'>{{addressInfo.real_name}}
  12. <text class='phone'>{{addressInfo.phone}}</text>
  13. </view>
  14. <view>
  15. <text class='default font-color' v-if="addressInfo.is_default">[默认]</text>{{addressInfo.province}}{{addressInfo.city}}{{addressInfo.district}}{{addressInfo.detail}}</view>
  16. <!-- <view class='setaddress'>设置收货地址</view> -->
  17. </view>
  18. <view class='addressCon' v-else>
  19. <view class='setaddress'>设置收货地址</view>
  20. </view>
  21. <view class="right"><image src="../../../static/img/img30.png"></image></view>
  22. </view>
  23. <!-- <view class='address acea-row row-between-wrapper' v-else @tap="showStoreList">
  24. <block v-if="storeList.length>0">
  25. <view class='addressCon' >
  26. <view class='name'>{{system_store.name}}
  27. <text class='phone'>{{system_store.phone}}</text>
  28. </view>
  29. <view> {{system_store.address}}{{", " + system_store.detailed_address}}</view>
  30. </view>
  31. <view class='iconfont icon-jiantou'></view>
  32. </block>
  33. <block v-else>
  34. <view>暂无门店信息</view>
  35. </block>
  36. </view> -->
  37. <view class='line'>
  38. <image src='../../../static/images/line.jpg'></image>
  39. </view>
  40. </view>
  41. <orderGoods :cartInfo="cartInfo"></orderGoods>
  42. <view class='wrapper'>
  43. <view class='item acea-row row-between-wrapper' @tap='couponTap' v-if="!pinkId && !BargainId && !combinationId && !seckillId">
  44. <view>优惠券</view>
  45. <view class='discount'>{{couponTitle}}
  46. <text class='iconfont icon-jiantou'></text>
  47. </view>
  48. </view>
  49. <view class='item acea-row row-between-wrapper' v-if="!pinkId && !BargainId && !combinationId && !seckillId">
  50. <view>积分抵扣</view>
  51. <view class='discount acea-row row-middle'>
  52. <view> {{useIntegral ? "剩余积分":"当前积分"}}
  53. <text class='num font-color'>{{integral || 0}}</text>
  54. </view>
  55. <checkbox-group @change="ChangeIntegral">
  56. <checkbox :checked='useIntegral ? true : false' />
  57. </checkbox-group>
  58. </view>
  59. </view>
  60. <view class='item acea-row row-between-wrapper' v-if="priceGroup.vipPrice > 0 && userInfo.vip && !pinkId && !BargainId && !combinationId && !seckillId">
  61. <view>会员优惠</view>
  62. <view class='discount'>-¥{{priceGroup.vipPrice}}</view>
  63. </view>
  64. <view class='item acea-row row-between-wrapper' v-if='shippingType==0'>
  65. <view>快递费用</view>
  66. <view class='discount' v-if='priceGroup.storePostage > 0'>+¥{{priceGroup.storePostage}}</view>
  67. <view class='discount' v-else>免运费</view>
  68. </view>
  69. <view v-else>
  70. <view class="item acea-row row-between-wrapper">
  71. <view>联系人</view>
  72. <view class="discount">
  73. <input type="text" placeholder="请填写您的联系姓名" placeholder-class="placeholder" @blur='realName'></input>
  74. </view>
  75. </view>
  76. <view class="item acea-row row-between-wrapper">
  77. <view>联系电话</view>
  78. <view class="discount">
  79. <input type="text" placeholder="请填写您的联系电话" placeholder-class="placeholder" @blur='phone'></input>
  80. </view>
  81. </view>
  82. </view>
  83. <!-- <view class='item acea-row row-between-wrapper' wx:else>
  84. <view>自提门店</view>
  85. <view class='discount'>{{system_store.name}}</view>
  86. </view> -->
  87. <!-- <view class='item' v-if="textareaStatus">
  88. <view>备注信息</view>
  89. <textarea v-if="coupon.coupon===false" placeholder-class='placeholder' @input='bindHideKeyboard' value="" name="mark"
  90. placeholder='请添加备注(150字以内)'></textarea>
  91. </view> -->
  92. </view>
  93. <view class='wrapper'>
  94. <view class='item'>
  95. <view>支付方式</view>
  96. <view class='list'>
  97. <!-- #ifdef H5 -->
  98. <view class='payItem acea-row row-middle' :class='active==index ?"on":""' @tap='payItem(index)' v-for="(item,index) in cartArr"
  99. :key='index' v-if="item.payStatus==1">
  100. <view class='name acea-row row-center-wrapper'>
  101. <view class='iconfont animated' :class='(item.icon) + " " + (animated==true&&active==index ?"bounceIn":"")'></view>{{item.name}}
  102. </view>
  103. <view class='tip'>{{item.title}}</view>
  104. </view>
  105. <!-- #endif -->
  106. <!-- #ifdef MP || APP-PLUS -->
  107. <view class='payItem acea-row row-middle' :class='active==index ?"on":""' @tap='payItem(index)' v-for="(item,index) in cartArr"
  108. :key='index' v-if="item.payStatus==1">
  109. <view class='name acea-row row-center-wrapper'>
  110. <view class='iconfont animated' :class='(item.icon) + " " + (animated==true&&active==index ?"bounceIn":"")'></view>{{item.name}}
  111. </view>
  112. <view class='tip'>{{item.title}}</view>
  113. </view>
  114. <!-- #endif -->
  115. </view>
  116. </view>
  117. </view>
  118. <view class='moneyList'>
  119. <view class='item acea-row row-between-wrapper'>
  120. <view>商品总价:</view>
  121. <view class='money'>¥{{priceGroup.totalPrice}}</view>
  122. </view>
  123. <view class='item acea-row row-between-wrapper' v-if="coupon_price > 0">
  124. <view>优惠券抵扣:</view>
  125. <view class='money'>-¥{{coupon_price}}</view>
  126. </view>
  127. <view class='item acea-row row-between-wrapper' v-if="integral_price > 0">
  128. <view>积分抵扣:</view>
  129. <view class='money'>-¥{{integral_price}}</view>
  130. </view>
  131. <view class='item acea-row row-between-wrapper' v-if="priceGroup.storePostage > 0">
  132. <view>运费:</view>
  133. <view class='money'>+¥{{priceGroup.storePostage}}</view>
  134. </view>
  135. </view>
  136. <view style='height:120rpx;'></view>
  137. <view class='footer acea-row row-between-wrapper'>
  138. <view>合计:
  139. <text class='font-color'>¥{{totalPrice || 0}}</text>
  140. </view>
  141. <view class='settlement' style='z-index:100' @tap="SubOrder">立即结算</view>
  142. </view>
  143. </view>
  144. <couponListWindow :coupon='coupon' @ChangCouponsClone="ChangCouponsClone" :openType='openType' :cartId='cartId'
  145. @ChangCoupons="ChangCoupons"></couponListWindow>
  146. <addressWindow ref="addressWindow" @changeTextareaStatus="changeTextareaStatus" :address='address' :pagesUrl="pagesUrl"
  147. @OnChangeAddress="OnChangeAddress" @changeClose="changeClose"></addressWindow>
  148. <!-- #ifdef MP -->
  149. <!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
  150. <!-- #endif -->
  151. <!-- home></home> -->
  152. </view>
  153. </template>
  154. <script>
  155. import { confirm } from '@/api/order.js';
  156. import { couponsOrder } from '@/api/coupon.js';
  157. import { createOrderkey , computedOrderkey} from '@/api/money.js';
  158. import { getAddressDefault, getAddressDetail } from '@/api/user.js';
  159. import { openPaySubscribe } from '@/utils/SubscribeMessage.js';
  160. // import { storeListApi } from '@/api/store.js';
  161. // import { CACHE_LONGITUDE, CACHE_LATITUDE } from '@/config/cache.js';
  162. import couponListWindow from '@/components/couponListWindow';
  163. import addressWindow from '@/components/addressWindow/index.vue';
  164. import orderGoods from '@/components/orderGoods/index.vue';
  165. // import home from '@/components/home';
  166. import {
  167. toLogin
  168. } from '@/libs/login.js';
  169. import {
  170. mapState
  171. } from "vuex";
  172. // #ifdef MP
  173. import authorize from '@/components/Authorize';
  174. // #endif
  175. export default {
  176. components: {
  177. couponListWindow,
  178. addressWindow,
  179. orderGoods,
  180. // home,
  181. // #ifdef MP
  182. authorize
  183. // #endif
  184. },
  185. data() {
  186. return {
  187. textareaStatus: true,
  188. //支付方式
  189. cartArr: [{
  190. "name": "微信支付",
  191. "icon": "icon-weixin2",
  192. value: 'weixin',
  193. title: '微信快捷支付',
  194. payStatus: 1,
  195. },
  196. {
  197. "name": "余额支付",
  198. "icon": "icon-icon-test",
  199. value: 'yue',
  200. title: '可用余额:',
  201. payStatus: 1,
  202. },
  203. {
  204. "name": "线下支付",
  205. "icon": "icon-yinhangqia",
  206. value: 'offline',
  207. title: '线下支付',
  208. payStatus: 2,
  209. },
  210. ],
  211. payType: 'weixin', //支付方式
  212. openType: 1, //优惠券打开方式 1=使用
  213. active: 0, //支付方式切换
  214. coupon: {
  215. coupon: false,
  216. list: [],
  217. statusTile: '立即使用'
  218. }, //优惠券组件
  219. address: {
  220. address: false
  221. }, //地址组件
  222. addressInfo: {}, //地址信息
  223. pinkId: 0, //拼团id
  224. addressId: 0, //地址id
  225. couponId: 0, //优惠券id
  226. cartId: '', //购物车id
  227. BargainId: 0,
  228. combinationId: 0,
  229. seckillId: 0,
  230. userInfo: {}, //用户信息
  231. mark: '', //备注信息
  232. couponTitle: '请选择', //优惠券
  233. coupon_price: 0, //优惠券抵扣金额
  234. useIntegral: false, //是否使用积分
  235. integral_price: 0, //积分抵扣金额
  236. integral: 0,
  237. ChangePrice: 0, //使用积分抵扣变动后的金额
  238. formIds: [], //收集formid
  239. status: 0,
  240. is_address: false,
  241. toPay: false, //修复进入支付时页面隐藏从新刷新页面
  242. shippingType: 0,
  243. system_store: {},
  244. storePostage: 0,
  245. contacts: '',
  246. contactsTel: '',
  247. mydata: {},
  248. storeList: [],
  249. store_self_mention: 0,
  250. cartInfo: [],
  251. priceGroup: {},
  252. animated: false,
  253. totalPrice: 0,
  254. integralRatio: "0",
  255. pagesUrl: "",
  256. orderKey: "",
  257. // usableCoupon: {},
  258. offlinePostage: "",
  259. isAuto: false, //没有授权的不会自动授权
  260. isShowAuth: false, //是否隐藏授权
  261. from: ''
  262. };
  263. },
  264. computed: {
  265. ...mapState(['hasLogin'])
  266. },
  267. onLoad: function(options) {
  268. // #ifdef H5
  269. this.from = this.$wechat.isWeixin() ? 'weixin' : 'weixinh5'
  270. // #endif
  271. // #ifdef MP
  272. this.from = 'routine'
  273. // #endif
  274. if (!options.cartId)
  275. {
  276. uni.showToast({
  277. title: '请选择要购买的商品',
  278. duration: 2000
  279. });
  280. }
  281. // if (!options.cartId) return this.$util.Tips({
  282. // title: '请选择要购买的商品'
  283. // }, {
  284. // tab: 3,
  285. // url: 1
  286. // });
  287. this.couponId = options.couponId || 0;
  288. this.pinkId = options.pinkid ? parseInt(options.pinkid) : 0;
  289. this.addressId = options.addressId || 0;
  290. this.cartId = options.cartId;
  291. this.is_address = options.is_address ? true : false;
  292. if (this.hasLogin) {
  293. this.getaddressInfo();
  294. this.getConfirm();
  295. //调用子页面方法授权后执行获取地址列表
  296. this.$nextTick(function() {
  297. this.$refs.addressWindow.getAddressList();
  298. })
  299. } else {
  300. // #ifdef H5 || APP-PLUS
  301. toLogin();
  302. // #endif
  303. // #ifdef MP
  304. this.isAuto = true;
  305. this.$set(this, 'isShowAuth', true);
  306. // #endif
  307. }
  308. },
  309. /**
  310. * 生命周期函数--监听页面显示
  311. */
  312. onShow: function() {
  313. let _this = this
  314. this.textareaStatus = true;
  315. if (this.hasLogin && this.toPay == false) {
  316. this.getaddressInfo();
  317. this.$nextTick(function() {
  318. this.$refs.addressWindow.getAddressList();
  319. })
  320. }
  321. uni.$on("handClick", res => {
  322. if (res) {
  323. _this.system_store = res.address
  324. }
  325. // 清除监听
  326. uni.$off('handClick');
  327. })
  328. // let pages = getCurrentPages();
  329. // let currPage = pages[pages.length - 1]; //当前页面
  330. // if (currPage.data.storeItem) {
  331. // let json = currPage.data.storeItem;
  332. // this.$set(this, 'system_store', json);
  333. // }
  334. },
  335. /**
  336. * 生命周期函数--监听页面隐藏
  337. */
  338. // onHide: function() {
  339. // console.log(999);
  340. // this.isClose = true
  341. // },
  342. methods: {
  343. /**
  344. * 授权回调事件
  345. *
  346. */
  347. onLoadFun: function() {
  348. this.getaddressInfo();
  349. this.getConfirm();
  350. //调用子页面方法授权后执行获取地址列表
  351. // this.$scope.selectComponent('#address-window').getAddressList();
  352. },
  353. /**
  354. * 获取门店列表数据
  355. */
  356. // getList: function() {
  357. // let longitude = uni.getStorageSync("CACHE_LONGITUDE"); //经度
  358. // let latitude = uni.getStorageSync("CACHE_LATITUDE"); //纬度
  359. // let data = {
  360. // latitude: latitude, //纬度
  361. // longitude: longitude, //经度
  362. // page: 1,
  363. // limit: 10
  364. // }
  365. // storeListApi(data).then(res => {
  366. // console.log(res)
  367. // let list = res.data.list.list || [];
  368. // this.$set(this, 'storeList', list);
  369. // this.$set(this, 'system_store', list[0]);
  370. // }).catch(err => {})
  371. // },
  372. // 关闭地址弹窗;
  373. changeClose: function() {
  374. this.$set(this.address, 'address', false);
  375. },
  376. /*
  377. * 跳转门店列表
  378. */
  379. showStoreList: function() {
  380. let _this = this
  381. if(this.storeList.length >0){
  382. uni.navigateTo({
  383. url: '/pages/users/goods_details_store/index'
  384. })
  385. }
  386. },
  387. computedPrice: function() {
  388. let shippingType = this.shippingType;
  389. computedOrderkey({
  390. addressId: this.addressId,
  391. useIntegral: this.useIntegral ? 1 : 0,
  392. couponId: this.couponId,
  393. shipping_type: parseInt(shippingType) + 1,
  394. payType: this.payType
  395. },this.orderKey).then(res => {
  396. let result = res.data.result;
  397. if (result) {
  398. this.totalPrice = result.pay_price;
  399. this.integral_price = result.deduction_price;
  400. this.coupon_price = result.coupon_price;
  401. this.integral = this.useIntegral ? result.SurplusIntegral : this.userInfo.integral;
  402. this.$set(this.priceGroup, 'storePostage', shippingType == 1 ? 0 : result.pay_postage);
  403. }
  404. })
  405. },
  406. addressType: function(e) {
  407. let index = e;
  408. this.shippingType = parseInt(index);
  409. this.computedPrice();
  410. if (index == 1) this.getList();
  411. },
  412. bindPickerChange: function(e) {
  413. let value = e.detail.value;
  414. this.shippingType = value;
  415. this.computedPrice();
  416. },
  417. ChangCouponsClone: function() {
  418. this.$set(this.coupon, 'coupon', false);
  419. },
  420. changeTextareaStatus: function() {
  421. for (let i = 0, len = this.coupon.list.length; i < len; i++) {
  422. this.coupon.list[i].use_title = '';
  423. this.coupon.list[i].is_use = 0;
  424. }
  425. this.textareaStatus = true;
  426. this.status = 0;
  427. this.$set(this.coupon, 'list', this.coupon.list);
  428. },
  429. /**
  430. * 处理点击优惠券后的事件
  431. *
  432. */
  433. ChangCoupons: function(e) {
  434. // this.usableCoupon = e
  435. // this.coupon.coupon = false
  436. let index = e,
  437. list = this.coupon.list,
  438. couponTitle = '请选择',
  439. couponId = 0;
  440. for (let i = 0, len = list.length; i < len; i++) {
  441. if (i != index) {
  442. list[i].use_title = '';
  443. list[i].is_use = 0;
  444. }
  445. }
  446. if (list[index].is_use) {
  447. //不使用优惠券
  448. list[index].use_title = '';
  449. list[index].is_use = 0;
  450. } else {
  451. //使用优惠券
  452. list[index].use_title = '不使用';
  453. list[index].is_use = 1;
  454. couponTitle = list[index].coupon_title;
  455. couponId = list[index].id;
  456. }
  457. this.couponTitle = couponTitle;
  458. this.couponId = couponId;
  459. this.$set(this.coupon, 'coupon', false);
  460. this.$set(this.coupon, 'list', list);
  461. this.computedPrice();
  462. },
  463. /**
  464. * 使用积分抵扣
  465. */
  466. ChangeIntegral: function() {
  467. this.useIntegral = !this.useIntegral;
  468. this.computedPrice();
  469. },
  470. /**
  471. * 选择地址后改变事件
  472. * @param object e
  473. */
  474. OnChangeAddress: function(e) {
  475. this.textareaStatus = true;
  476. this.addressId = e;
  477. this.address.address = false;
  478. this.getaddressInfo();
  479. this.computedPrice();
  480. },
  481. bindHideKeyboard: function(e) {
  482. this.mark = e.detail.value;
  483. },
  484. /**
  485. * 获取当前订单详细信息
  486. *
  487. */
  488. getConfirm: function() {
  489. let that = this;
  490. confirm({
  491. cartId:that.cartId
  492. }).then(res => {
  493. that.$set(that, 'userInfo', res.data.userInfo);
  494. that.$set(that, 'integral', res.data.userInfo.integral);
  495. that.$set(that, 'cartInfo', res.data.cartInfo);
  496. that.$set(that, 'integralRatio', res.data.integralRatio);
  497. that.$set(that, 'offlinePostage', res.data.offlinePostage);
  498. that.$set(that, 'orderKey', res.data.orderKey);
  499. that.$set(that, 'priceGroup', res.data.priceGroup);
  500. let totalPrice = parseFloat(res.data.priceGroup.totalPrice) + parseFloat(res.data.priceGroup.storePostage);
  501. that.totalPrice = totalPrice;
  502. that.$set(that, 'seckillId', parseInt(res.data.seckill_id));
  503. // if (res.data.usableCoupon == null) {
  504. // console.log(res.data.usableCoupon)
  505. // that.usableCoupon.title = "暂无优惠券"
  506. // } else {
  507. // that.usableCoupon = res.data.usableCoupon
  508. // }
  509. // that.$set(that, 'usableCoupon', res.data.usableCoupon);
  510. that.$set(that, 'store_self_mention', res.data.store_self_mention);
  511. that.cartArr[1].title = '可用余额:' + res.data.userInfo.now_money;
  512. that.cartArr[1].payStatus = res.data.yue_pay_status || 0
  513. if (res.data.offline_pay_status == 2){
  514. that.cartArr[2].payStatus = 0
  515. }else{
  516. that.cartArr[2].payStatus = 1
  517. }
  518. // that.$set(that, 'cartArr', that.cartArr);
  519. that.$set(that, 'ChangePrice', that.totalPrice);
  520. that.getBargainId();
  521. that.getCouponList();
  522. }).catch(err => {
  523. console.log(err,'err11')
  524. // return this.$util.Tips({
  525. // title: err
  526. // }, {
  527. // tab: 3,
  528. // url: 1
  529. // });
  530. });
  531. },
  532. /*
  533. * 提取砍价和拼团id
  534. */
  535. getBargainId: function() {
  536. let that = this;
  537. let cartINfo = that.cartInfo;
  538. let BargainId = 0;
  539. let combinationId = 0;
  540. cartINfo.forEach(function(value, index, cartINfo) {
  541. BargainId = cartINfo[index].bargain_id,
  542. combinationId = cartINfo[index].combination_id
  543. })
  544. that.$set(that, 'BargainId', parseInt(BargainId));
  545. that.$set(that, 'combinationId', parseInt(combinationId));
  546. if (that.cartArr.length == 3 && (BargainId || combinationId || that.seckillId)) {
  547. that.cartArr[2].payStatus = 0;
  548. that.$set(that, 'cartArr', that.cartArr);
  549. }
  550. },
  551. /**
  552. * 获取当前金额可用优惠券
  553. *
  554. */
  555. getCouponList: function() {
  556. let that = this;
  557. couponsOrder({
  558. cartId: that.cartId
  559. },that.totalPrice).then(res => {
  560. that.$set(that.coupon, 'list', res.data);
  561. that.openType = 1;
  562. });
  563. },
  564. /*
  565. * 获取默认收货地址或者获取某条地址信息
  566. */
  567. getaddressInfo: function() {
  568. let that = this;
  569. if (that.addressId) {
  570. getAddressDetail({},that.addressId).then(res => {
  571. res.data.is_default = parseInt(res.data.is_default);
  572. that.addressInfo = res.data || {};
  573. that.addressId = res.data.id || 0;
  574. that.address.addressId = res.data.id || 0;
  575. }).catch(err =>{
  576. console.log(err,'errgetAddressDetail')
  577. });
  578. } else {
  579. getAddressDefault().then(res => {
  580. res.data.is_default = parseInt(res.data.is_default);
  581. that.addressInfo = res.data || {};
  582. that.addressId = res.data.id || 0;
  583. that.address.addressId = res.data.id || 0;
  584. })
  585. }
  586. },
  587. payItem: function(e) {
  588. let that = this;
  589. let active = e;
  590. that.active = active;
  591. that.animated = true;
  592. that.payType = that.cartArr[active].value;
  593. that.computedPrice();
  594. setTimeout(function() {
  595. that.car();
  596. }, 500);
  597. },
  598. couponTap: function() {
  599. this.coupon.coupon = true;
  600. },
  601. car: function() {
  602. let that = this;
  603. that.animated = false;
  604. },
  605. onAddress: function() {
  606. let that = this;
  607. that.textareaStatus = false;
  608. that.address.address = true;
  609. that.pagesUrl = '/pages/address/address?source=1'
  610. },
  611. realName: function(e) {
  612. this.contacts = e.detail.value;
  613. },
  614. phone: function(e) {
  615. this.contactsTel = e.detail.value;
  616. },
  617. payment: function(data) {
  618. let that = this;
  619. createOrderkey(data,that.orderKey).then(res => {
  620. let status = res.data.status,
  621. orderId = res.data.result.orderId,
  622. jsConfig = res.data.result.jsConfig,
  623. goPages = '/pages/order_pay_status/index?order_id=' + orderId + '&msg=' + res.msg;
  624. switch (status) {
  625. case 'ORDER_EXIST':
  626. case 'EXTEND_ORDER':
  627. case 'PAY_ERROR':
  628. uni.hideLoading();
  629. uni.showToast({
  630. title: res.msg,
  631. duration: 2000
  632. });
  633. uni.navigateTo({
  634. url: goPages
  635. });
  636. // return that.$util.Tips({
  637. // title: res.msg
  638. // }, {
  639. // tab: 5,
  640. // url: goPages
  641. // });
  642. break;
  643. case 'SUCCESS':
  644. uni.hideLoading();
  645. if (that.BargainId || that.combinationId || that.pinkId || that.seckillId)
  646. uni.showToast({
  647. title: res.msg,
  648. duration: 2000
  649. });
  650. uni.navigateTo({
  651. url: goPages
  652. });
  653. // return that.$util.Tips({
  654. // title: res.msg,
  655. // icon: 'success'
  656. // }, {
  657. // tab: 4,
  658. // url: goPages
  659. // });
  660. // return that.$util.Tips({
  661. // title: res.msg,
  662. // icon: 'success'
  663. // }, {
  664. // tab: 5,
  665. // url: goPages
  666. // });
  667. break;
  668. case 'WECHAT_PAY':
  669. // #ifdef MP
  670. that.toPay = true;
  671. uni.requestPayment({
  672. timeStamp: jsConfig.timestamp,
  673. nonceStr: jsConfig.nonceStr,
  674. package: jsConfig.package,
  675. signType: jsConfig.signType,
  676. paySign: jsConfig.paySign,
  677. success: function(res) {
  678. uni.hideLoading();
  679. if (that.BargainId || that.combinationId || that.pinkId || that.seckillId)
  680. uni.showToast({
  681. title: '支付成功',
  682. icon: 'success',
  683. duration: 2000
  684. });
  685. uni.navigateTo({
  686. url: goPages
  687. });
  688. // return that.$util.Tips({
  689. // title: '支付成功',
  690. // icon: 'success'
  691. // }, {
  692. // tab: 4,
  693. // url: goPages
  694. // });
  695. // return that.$util.Tips({
  696. // title: '支付成功',
  697. // icon: 'success'
  698. // }, {
  699. // tab: 5,
  700. // url: goPages
  701. // });
  702. },
  703. fail: function(e) {
  704. uni.hideLoading();
  705. uni.showToast({
  706. title: '取消支付',
  707. duration: 2000
  708. });
  709. uni.navigateTo({
  710. url: goPages + '&status=0'
  711. });
  712. // return that.$util.Tips({
  713. // title: '取消支付'
  714. // }, {
  715. // tab: 5,
  716. // url: goPages + '&status=0'
  717. // });
  718. },
  719. complete: function(e) {
  720. uni.hideLoading();
  721. //关闭当前页面跳转至订单状态
  722. if (res.errMsg == 'requestPayment:cancel')
  723. {
  724. uni.showToast({
  725. title: '取消支付',
  726. duration: 2000
  727. });
  728. uni.navigateTo({
  729. url: goPages + '&status=0'
  730. });
  731. // return that.$util.Tips({
  732. // title: '取消支付'
  733. // }, {
  734. // tab: 5,
  735. // url: goPages + '&status=0'
  736. // });
  737. }
  738. },
  739. })
  740. // #endif
  741. // #ifdef H5
  742. console.log('公众号支付')
  743. this.$wechat.pay(res.data.result.jsConfig).then(res => {
  744. uni.showToast({
  745. title: '支付成功',
  746. icon: 'success',
  747. duration: 2000
  748. });
  749. uni.navigateTo({
  750. url: goPages
  751. });
  752. // return that.$util.Tips({
  753. // title: '支付成功',
  754. // icon: 'success'
  755. // }, {
  756. // tab: 5,
  757. // url: goPages
  758. // });
  759. }).cache(res => {
  760. if (res.errMsg == 'requestPayment:cancel'){
  761. uni.showToast({
  762. title: '取消支付',
  763. duration: 2000
  764. });
  765. uni.navigateTo({
  766. url: goPages + '&status=0'
  767. });
  768. // return that.$util.Tips({
  769. // title: '取消支付'
  770. // }, {
  771. // tab: 5,
  772. // url: goPages + '&status=0'
  773. // });
  774. }
  775. })
  776. // #endif
  777. break;
  778. case 'PAY_DEFICIENCY':
  779. uni.hideLoading();
  780. //余额不足
  781. uni.showToast({
  782. title: res.msg,
  783. duration: 2000
  784. });
  785. uni.navigateTo({
  786. url: goPages + '&status=1'
  787. });
  788. // return that.$util.Tips({
  789. // title: res.msg
  790. // }, {
  791. // tab: 5,
  792. // url: goPages + '&status=1'
  793. // });
  794. break;
  795. case "WECHAT_H5_PAY": //gongzhonghao
  796. setTimeout(() => {
  797. location.href = res.data.result.jsConfig.mweb_url;
  798. }, 100);
  799. break;
  800. }
  801. }).catch(err => {
  802. uni.hideLoading();
  803. console.log(err,'err22')
  804. });
  805. },
  806. SubOrder: function(e) {
  807. let that = this,
  808. data = {};
  809. if (!that.payType){
  810. uni.showToast({
  811. title: '请选择支付方式',
  812. duration: 2000
  813. });
  814. // return that.$util.Tips({
  815. // title: '请选择支付方式'
  816. // });
  817. }
  818. if (!that.addressId && !that.shippingType){
  819. uni.showToast({
  820. title: '请选择收货地址',
  821. duration: 2000
  822. });
  823. // return that.$util.Tips({
  824. // title: '请选择收货地址'
  825. // });
  826. }
  827. if (that.shippingType == 1) {
  828. if (that.contacts == "" || that.contactsTel == "") {
  829. uni.showToast({
  830. title: '请填写联系人或联系人电话',
  831. duration: 2000
  832. });
  833. // return that.$util.Tips({
  834. // title: '请填写联系人或联系人电话'
  835. // });
  836. }
  837. if (!/^1(3|4|5|7|8|9|6)\d{9}$/.test(that.contactsTel)) {
  838. uni.showToast({
  839. title: '请填写正确的手机号',
  840. duration: 2000
  841. });
  842. // return that.$util.Tips({
  843. // title: '请填写正确的手机号'
  844. // });
  845. }
  846. if (!/^[\u4e00-\u9fa5\w]{2,16}$/.test(that.contacts)) {
  847. uni.showToast({
  848. title: '请填写您的真实姓名',
  849. duration: 2000
  850. });
  851. // return that.$util.Tips({
  852. // title: '请填写您的真实姓名'
  853. // });
  854. }
  855. if(that.storeList.length == 0){
  856. uni.showToast({
  857. title: '暂无门店,请选择其他方式',
  858. duration: 2000
  859. });
  860. // return that.$util.Tips({
  861. // title: '暂无门店,请选择其他方式'
  862. // });
  863. }
  864. }
  865. data = {
  866. real_name: that.contacts,
  867. phone: that.contactsTel,
  868. addressId: that.addressId,
  869. formId: '',
  870. couponId: that.couponId,
  871. payType: that.payType,
  872. useIntegral: that.useIntegral,
  873. bargainId: that.BargainId,
  874. combinationId: that.combinationId,
  875. pinkId: that.pinkId,
  876. seckill_id: that.seckillId,
  877. mark: that.mark,
  878. store_id: that.system_store.id || 0,
  879. 'from': that.from,
  880. shipping_type: 1
  881. };
  882. if (data.payType == 'yue' && parseFloat(that.userInfo.now_money) < parseFloat(that.totalPrice)){
  883. uni.showToast({
  884. title: '余额不足',
  885. duration: 2000
  886. });
  887. // return that.$util.Tips({
  888. // title: '余额不足!'
  889. // });
  890. }
  891. uni.showLoading({
  892. title: '订单支付中'
  893. });
  894. // #ifdef MP
  895. openPaySubscribe().then(() => {
  896. that.payment(data);
  897. });
  898. // #endif
  899. // #ifndef MP
  900. that.payment(data);
  901. // #endif
  902. }
  903. }
  904. }
  905. </script>
  906. <style lang="scss" scoped>
  907. page{
  908. background-color: #f5f5f5;
  909. }
  910. .right{
  911. width: 30rpx;
  912. height: 40rpx;
  913. image{
  914. width: 30rpx;
  915. height: 40rpx;
  916. transform: rotate(180deg);
  917. }
  918. }
  919. .order-submission .line {
  920. width: 100%;
  921. height: 3rpx;
  922. }
  923. .order-submission .line image {
  924. width: 100%;
  925. height: 100%;
  926. display: block;
  927. }
  928. .order-submission .address {
  929. padding: 28rpx 30rpx;
  930. background-color: #fff;
  931. box-sizing: border-box;
  932. }
  933. .order-submission .address .addressCon {
  934. width: 610rpx;
  935. font-size: 26rpx;
  936. color: #666;
  937. }
  938. .order-submission .address .addressCon .name {
  939. font-size: 30rpx;
  940. color: #282828;
  941. font-weight: bold;
  942. margin-bottom: 10rpx;
  943. }
  944. .order-submission .address .addressCon .name .phone {
  945. margin-left: 50rpx;
  946. }
  947. .order-submission .address .addressCon .default {
  948. margin-right: 12rpx;
  949. }
  950. .order-submission .address .addressCon .setaddress {
  951. color: #333;
  952. font-size: 28rpx;
  953. }
  954. .order-submission .address .iconfont {
  955. font-size: 35rpx;
  956. color: #707070;
  957. }
  958. .order-submission .allAddress {
  959. width: 100%;
  960. background: linear-gradient(to bottom, #e93323 0%,#f5f5f5 100%);
  961. // background-image: linear-gradient(to bottom, #e93323 0%, #f5f5f5 100%);
  962. // background-image: -webkit-linear-gradient(to bottom, #e93323 0%, #f5f5f5 100%);
  963. // background-image: -moz-linear-gradient(to bottom, #e93323 0%, #f5f5f5 100%);
  964. padding-top: 20rpx;
  965. }
  966. .order-submission .allAddress .nav {
  967. width: 710rpx;
  968. margin: 0 auto;
  969. }
  970. .order-submission .allAddress .nav .item {
  971. width: 355rpx;
  972. }
  973. .order-submission .allAddress .nav .item.on {
  974. position: relative;
  975. width: 250rpx;
  976. }
  977. .order-submission .allAddress .nav .item.on::before {
  978. position: absolute;
  979. bottom: 0;
  980. content: "快递配送";
  981. font-size: 28rpx;
  982. display: block;
  983. height: 0;
  984. width: 336rpx;
  985. border-width: 0 20rpx 80rpx 0;
  986. border-style: none solid solid;
  987. border-color: transparent transparent #fff;
  988. z-index: 2;
  989. border-radius: 7rpx 30rpx 0 0;
  990. text-align: center;
  991. line-height: 80rpx;
  992. }
  993. .order-submission .allAddress .nav .item:nth-of-type(2).on::before {
  994. content: "到店自提";
  995. border-width: 0 0 80rpx 20rpx;
  996. border-radius: 30rpx 7rpx 0 0;
  997. }
  998. .order-submission .allAddress .nav .item.on2 {
  999. position: relative;
  1000. }
  1001. .order-submission .allAddress .nav .item.on2::before {
  1002. position: absolute;
  1003. bottom: 0;
  1004. content: "到店自提";
  1005. font-size: 28rpx;
  1006. display: block;
  1007. height: 0;
  1008. width: 400rpx;
  1009. border-width: 0 0 60rpx 60rpx;
  1010. border-style: none solid solid;
  1011. border-color: transparent transparent #f7c1bd;
  1012. border-radius: 40rpx 6rpx 0 0;
  1013. text-align: center;
  1014. line-height: 60rpx;
  1015. }
  1016. .order-submission .allAddress .nav .item:nth-of-type(1).on2::before {
  1017. content: "快递配送";
  1018. border-width: 0 60rpx 60rpx 0;
  1019. border-radius: 6rpx 40rpx 0 0;
  1020. }
  1021. .order-submission .allAddress .address {
  1022. width: 710rpx;
  1023. height: 150rpx;
  1024. margin: 0 auto;
  1025. }
  1026. .order-submission .allAddress .line {
  1027. width: 710rpx;
  1028. margin: 0 auto;
  1029. }
  1030. .order-submission .wrapper .item .discount .placeholder {
  1031. color: #ccc;
  1032. }
  1033. .order-submission .wrapper {
  1034. background-color: #fff;
  1035. margin-top: 13rpx;
  1036. }
  1037. .order-submission .wrapper .item {
  1038. padding: 27rpx 30rpx;
  1039. font-size: 30rpx;
  1040. color: #282828;
  1041. border-bottom: 1px solid #f0f0f0;
  1042. }
  1043. .order-submission .wrapper .item .discount {
  1044. font-size: 30rpx;
  1045. color: #999;
  1046. }
  1047. .order-submission .wrapper .item .discount .iconfont {
  1048. color: #515151;
  1049. font-size: 30rpx;
  1050. margin-left: 15rpx;
  1051. }
  1052. .order-submission .wrapper .item .discount .num {
  1053. font-size: 32rpx;
  1054. margin-right: 20rpx;
  1055. }
  1056. .order-submission .wrapper .item .shipping {
  1057. font-size: 30rpx;
  1058. color: #999;
  1059. position: relative;
  1060. padding-right: 58rpx;
  1061. }
  1062. .order-submission .wrapper .item .shipping .iconfont {
  1063. font-size: 35rpx;
  1064. color: #707070;
  1065. position: absolute;
  1066. right: 0;
  1067. top: 50%;
  1068. transform: translateY(-50%);
  1069. margin-left: 30rpx;
  1070. }
  1071. .order-submission .wrapper .item textarea {
  1072. background-color: #f9f9f9;
  1073. width: 690rpx;
  1074. height: 140rpx;
  1075. border-radius: 3rpx;
  1076. margin-top: 30rpx;
  1077. padding: 25rpx 28rpx;
  1078. box-sizing: border-box;
  1079. }
  1080. .order-submission .wrapper .item .placeholder {
  1081. color: #ccc;
  1082. }
  1083. .order-submission .wrapper .item .list {
  1084. margin-top: 35rpx;
  1085. }
  1086. .order-submission .wrapper .item .list .payItem {
  1087. border: 1px solid #eee;
  1088. border-radius: 6rpx;
  1089. height: 86rpx;
  1090. width: 100%;
  1091. box-sizing: border-box;
  1092. margin-top: 20rpx;
  1093. font-size: 28rpx;
  1094. color: #282828;
  1095. }
  1096. .order-submission .wrapper .item .list .payItem.on {
  1097. border-color: #fc5445;
  1098. color: #e93323;
  1099. }
  1100. .order-submission .wrapper .item .list .payItem .name {
  1101. width: 50%;
  1102. text-align: center;
  1103. border-right: 1px solid #eee;
  1104. }
  1105. .order-submission .wrapper .item .list .payItem .name .iconfont {
  1106. width: 44rpx;
  1107. height: 44rpx;
  1108. border-radius: 50%;
  1109. text-align: center;
  1110. line-height: 44rpx;
  1111. background-color: #fe960f;
  1112. color: #fff;
  1113. font-size: 30rpx;
  1114. margin-right: 15rpx;
  1115. }
  1116. .order-submission .wrapper .item .list .payItem .name .iconfont.icon-weixin2 {
  1117. background-color: #41b035;
  1118. }
  1119. .order-submission .wrapper .item .list .payItem .tip {
  1120. width: 49%;
  1121. text-align: center;
  1122. font-size: 26rpx;
  1123. color: #aaa;
  1124. }
  1125. .order-submission .moneyList {
  1126. margin-top: 12rpx;
  1127. background-color: #fff;
  1128. padding: 30rpx;
  1129. }
  1130. .order-submission .moneyList .item {
  1131. font-size: 28rpx;
  1132. color: #282828;
  1133. }
  1134. .order-submission .moneyList .item~.item {
  1135. margin-top: 20rpx;
  1136. }
  1137. .order-submission .moneyList .item .money {
  1138. color: #868686;
  1139. }
  1140. .order-submission .footer {
  1141. width: 100%;
  1142. height: 100rpx;
  1143. background-color: #fff;
  1144. padding: 0 30rpx;
  1145. font-size: 28rpx;
  1146. color: #333;
  1147. box-sizing: border-box;
  1148. position: fixed;
  1149. bottom: 0;
  1150. left: 0;
  1151. }
  1152. .order-submission .footer .settlement {
  1153. font-size: 30rpx;
  1154. color: #fff;
  1155. width: 240rpx;
  1156. height: 70rpx;
  1157. background-color: #e93323;
  1158. border-radius: 50rpx;
  1159. text-align: center;
  1160. line-height: 70rpx;
  1161. }
  1162. .footer .transparent {
  1163. opacity: 0
  1164. }
  1165. </style>