surePay.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  1. <template>
  2. <view class="container">
  3. <navbar :config="config" :backoff="backoff" backColor="#666"></navbar>
  4. <view class="topStatus u-flex-center-sa u-plr30" :style="{ top: tabTop + 'px' }"
  5. v-if="sureDataAll.is_able_select_self_take">
  6. <text class="u-1A1A1A u-font30 " :class="status == 1 ? 'active' : ''" @click="changeStatus(1)">快递配送</text>
  7. <text class="u-1A1A1A u-font30" :class="status == 2 ? 'active' : ''" @click="changeStatus(2)">上门自提</text>
  8. </view>
  9. <view class="carbox" :class="sureDataAll.is_able_select_self_take ? 'changeTabtwo' : ''">
  10. <view class="addressBox">
  11. <view class="" v-if="status == 1">
  12. <ldaddress :value="sureDataAll.receipt" :link="true"></ldaddress>
  13. </view>
  14. <view class="goHome" v-if="status == 2 && sureDataAll.is_able_select_self_take">
  15. <view class="u-flex-center u-p30 u-border-one-one">
  16. <image class="u-avatar104 u-mr25" :src="sureDataAll.self_take_shop.logo" mode=""></image>
  17. <view class="u-flex1">
  18. <view class="u-1A1A1A u-font28 u-bold ">{{ sureDataAll.self_take_shop.shop_name }}</view>
  19. <view class="smallAddress u-mt10">
  20. <text class="iconfont u-font30 u-mr10 " style="color: #FA6138;">&#xe611;</text>
  21. <text class="u-font24 u-bold u-999">
  22. {{ sureDataAll.self_take_shop.province_name }}{{ sureDataAll.self_take_shop.city_name }}{{ sureDataAll.self_take_shop.area_name
  23. }}{{ sureDataAll.self_take_shop.address }}
  24. </text>
  25. </view>
  26. </view>
  27. </view>
  28. <view class="u-flex-center u-p30">
  29. <view class="u-mr45 u-font28 u-999 u-flex-center">
  30. <text class="u-333 u-bold">提货人:</text>
  31. <input style="width: 150rpx;" type="text" :value="self_take.receiver" maxlength="8"
  32. placeholder="提货人姓名" placeholder-style="font-size:30rpx;" />
  33. </view>
  34. <view class="u-font28 u-999 u-flex-center">
  35. <text class="u-mr10 iconfont u-02331F u-font30">&#xe64e;</text>
  36. <input style="width: 260rpx;" type="number" :value="self_take.mobile" maxlength="11"
  37. placeholder="提货人手机号" placeholder-style="font-size:30rpx;" />
  38. </view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="" v-for="(pitem, index) in sureDataAll.shop_orders" :key="pitem.source_shop_id">
  43. <view class="shopList u-mt10">
  44. <ldshop :shopStatus="shopStatus" :value="pitem.source_shop_name"></ldshop>
  45. <view v-for="item in pitem.items" :key="item.goods_id">
  46. <ldgoods :value="item"></ldgoods>
  47. </view>
  48. </view>
  49. <!-- 备注 -->
  50. <view class="listText u-p30">
  51. <view class="u-font28 u-181818 title">
  52. <span>购买备注</span>
  53. <span class="num">{{ pitem.user_remark.length }} / 80</span>
  54. </view>
  55. <textarea class="textarea u-mt10 u-font28 u-333" :auto-height="true" :maxlength="80"
  56. @input="textareaText($event, index)" value="" placeholder="选填,给商家留言" />
  57. </view>
  58. <!-- list -->
  59. <view class="listText">
  60. <!-- <view class="u-border-one-one border u-p30 u-flex-center-sb">
  61. <view class="u-font28 u-181818"><text>商品金额</text></view>
  62. <view class="u-font30 u-999">¥ {{ pitem.original_goods_amount }}</view>
  63. </view> -->
  64. <view class="u-border-one-one u-p30 border u-flex-center-sb" v-if="pitem.first_order_activity">
  65. <view class="u-font28 u-181818">
  66. <text>首单优惠</text>
  67. <text
  68. class="u-font24 u-999">(满{{ pitem.first_order_activity.full }}减{{ pitem.first_order_activity.reduction }})</text>
  69. </view>
  70. <view class="u-font30 u-999">-¥ {{ pitem.first_order_reduced }}</view>
  71. </view>
  72. <view class="freight">
  73. <view class="u-border-one-one border u-p30 u-flex-center-sb">
  74. <view class="u-font28 u-181818"><text>运费</text></view>
  75. <view class="u-font30 u-999">
  76. <!-- +{{ pitem.total_freight }}元 -->
  77. {{pitem.total_freight?'+¥'+pitem.total_freight+'元':'免运费'}}
  78. </view>
  79. </view>
  80. </view>
  81. <!-- <view class="u-border-one-one border u-p30 u-flex-center-sb">
  82. <view class="u-font28 u-181818 u-flex-center-sb"><text
  83. class="iconfont3 consumption_value-icon">&#xe603;</text><text>消费补贴</text></view>
  84. <view class="u-font30 u-999 consumption_value">
  85. <rich-text :nodes="$mUtil.isToFixed(pitem.total_consumption_value, 2)"></rich-text>
  86. </view>
  87. </view> -->
  88. <view class="u-flex-center pt-pb25"
  89. style="justify-content: flex-end;height: 108rpx;padding-right: 28rpx;">
  90. <view class="">共{{ pitem.goods_num }}件商品,小计:</view>
  91. <view style="display: flex;align-items: center;">
  92. <text></text>
  93. <view class="u-bold u-FF0000">
  94. <rich-text :nodes="$mUtil.priceBigSmall(pitem.total_amount)"></rich-text>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. </view>
  100. <view class="listText u-mt10" >
  101. <view v-if="platformCoupon.my_coupon_id!==0" @click="checkCoupon()"
  102. class="u-border-one-one border u-p30 u-flex-center-sb">
  103. <view class="u-font28 u-181818"><text>平台优惠</text></view>
  104. <view v-if="platformCoupon" class="u-font30 u-999">
  105. <text
  106. style="white-space: nowrap;max-width: 450rpx;overflow: hidden;text-overflow: ellipsis;display: inline-block;vertical-align: middle;">{{platformCoupon.coupon_name}}</text>
  107. <text
  108. style="color: red;margin-left: 15rpx;display: inline-block;vertical-align: middle;">-{{platformCoupon.coupon_result_value}}</text>
  109. </view>
  110. <view v-else class="u-font30 u-999">选择优惠券></view>
  111. </view>
  112. <view v-if="sureDataAll.has_platform" class="u-border-one-one border u-p30">
  113. <view class="u-flex-center-sb">
  114. <view class="u-font28 u-181818"><text>积分抵扣</text></view>
  115. <view class="u-font30 u-999">
  116. <u-switch v-model="usePlatformPoint" @change="changePlatformPoint()" active-color='#FA6138'></u-switch>
  117. </view>
  118. </view>
  119. <view style="color: #808080;font-size: 24rpx;">共计{{sureDataAll.integral_able}}<text
  120. v-if="usePlatformPoint">,可使用{{sureDataAll.total_point}}抵扣{{sureDataAll.total_point}}元</text></view>
  121. </view>
  122. </view>
  123. </view>
  124. <!-- 底部 -->
  125. <view class="botfixed u-flex-center-sb">
  126. <view class="leftAll u-flex-center">
  127. <view class="u-flex-center">
  128. <text class="u-mr20 u-font24 u-666">共{{ totaltNum }}件</text>
  129. <text class="u-font28 u-333 ">合计:</text>
  130. <view class="u-FF0000 u-bold">
  131. <rich-text :nodes="$mUtil.priceBigSmall(sureDataAll.total_money)"></rich-text>
  132. </view>
  133. </view>
  134. </view>
  135. <view class="rightP u-flex-center" @click="submitOrder">
  136. <view class="u-btn btnWidth u-ml30">提交订单</view>
  137. </view>
  138. </view>
  139. <!--页面加载动画-->
  140. <ldLoading isFullScreen :active="loading"></ldLoading>
  141. </view>
  142. </template>
  143. <script>
  144. var app = getApp();
  145. import ldaddress from '../../../components/ld-address/ld-address.vue';
  146. import ldshop from '../../../components/ld-shop/ld-shop.vue';
  147. import ldgoods from '../../../components/ld-goods/ld-goods.vue';
  148. import {
  149. myUserInfo
  150. } from "@/api/government.js"
  151. export default {
  152. components: {
  153. ldaddress,
  154. ldshop,
  155. ldgoods
  156. },
  157. data() {
  158. return {
  159. shopStatus: false,
  160. totaltNum: 0,
  161. tabTop: 0,
  162. price: 20,
  163. loading: false,
  164. status: 1, //快递方式标志
  165. config: {
  166. back: true, //false是tolbar页面 是则不写
  167. title: '确认订单',
  168. color: '#1a1a1a',
  169. //背景颜色;参数一:透明度(0-1);参数二:背景颜色(array则为线性渐变,string为单色背景)
  170. backgroundColor: [1, '#fff'],
  171. statusBarFontColor: '#fff'
  172. },
  173. backoff: true,
  174. sureDataAll: {},
  175. shopDiscounts: {},
  176. self_take: {},
  177. dataJson: {},
  178. addressChose: false,
  179. type: null,
  180. usePlatformPoint: true, //是否使用公益积分抵扣
  181. // 当前使用的平台优惠券
  182. platformCoupon: {
  183. my_coupon_id: 0
  184. },
  185. jumpType: null
  186. };
  187. },
  188. onLoad(options) {
  189. this.loading = true;
  190. this.tabTop = app.globalData.barHeight + 44;
  191. let dataJson = uni.getStorageSync('dataJson');
  192. // let sureData = uni.getStorageSync('sureData')
  193. // this.getByShop(sureDataAll.)
  194. if (dataJson) {
  195. this.dataJson = dataJson;
  196. }
  197. if (options.type) {
  198. this.type = options.type;
  199. }
  200. this.getUserData()
  201. },
  202. onShow() {
  203. if (this.jumpType) {
  204. uni.redirectTo({
  205. url: '/pages/order/orderList/orderList?keys=-1&orderType=0'
  206. });
  207. }
  208. let orderreminder = uni.getStorageSync('orderreminder');
  209. if (orderreminder) {
  210. this.$mUtil.toast('已生成待付款订单');
  211. uni.removeStorageSync('orderreminder');
  212. }
  213. let dataJson = uni.getStorageSync('dataJson');
  214. if (dataJson && !this.addressChose) {
  215. this.loading = true;
  216. this.$http
  217. .post(`/order/build`, {
  218. ...dataJson,
  219. use_platform_point: this.usePlatformPoint,
  220. platform_coupon: this.platformCoupon.my_coupon_id == 0 ? undefined : {
  221. my_coupon_id: this.platformCoupon.my_coupon_id
  222. }
  223. },{'hideToast':true})
  224. .then(res => {
  225. if (res && res.code == 200) {
  226. this.loading = false;
  227. uni.setStorageSync('sureData', res.data);
  228. if (res.data) {
  229. this.sureDataAll = res.data;
  230. let totaltNum = 0;
  231. res.data.shop_orders.forEach(res => {
  232. totaltNum += res.goods_num;
  233. });
  234. this.sureData = res.data;
  235. this.totaltNum = totaltNum;
  236. }
  237. //平台店铺才能使用公益积分抵扣
  238. if (!res.data.has_platform) {
  239. this.usePlatformPoint = false;
  240. }
  241. //默认使用的平台优惠券
  242. if (res.data.platform_coupon.my_coupon_id != 0) {
  243. this.platformCoupon = res.data.platform_coupon;
  244. }
  245. }
  246. })
  247. .catch(() => {
  248. uni.hideLoading();
  249. setTimeout(function() {
  250. uni.navigateBack({
  251. delta: 1
  252. })
  253. }, 1500);
  254. })
  255. }
  256. },
  257. methods: {
  258. changePlatformPoint() {
  259. let dataJson = uni.getStorageSync('dataJson');
  260. if (dataJson) {
  261. this.postData(dataJson);
  262. }
  263. },
  264. getUserData() {
  265. myUserInfo().then(res => {
  266. this.user = res.data;
  267. this.self_take.receiver=this.user.realName;
  268. this.self_take.mobile=this.user.mobile;
  269. })
  270. },
  271. //提交订单
  272. submitOrder() {
  273. if (this.status == 1) {
  274. //快速配送
  275. this.dataJson.self_take = null;
  276. if (this.dataJson.receipt_id == null && !this.sureDataAll.receipt.id) {
  277. this.$mUtil.toast('请填写收货地址');
  278. return false;
  279. }
  280. this.orderCreated();
  281. } else {
  282. //自提
  283. if (!this.self_take.receiver) {
  284. this.$mUtil.toast('请填写提货人姓名');
  285. return false;
  286. }
  287. if (!this.self_take.mobile) {
  288. this.$mUtil.toast('请填写提货人手机号');
  289. return false;
  290. }
  291. if (!this.self_take.mobile.match(this.$mConfig.telRegex)) {
  292. this.$mUtil.toast('请输入正确手机号');
  293. return false;
  294. }
  295. this.dataJson.self_take = this.self_take;
  296. this.orderCreated();
  297. }
  298. },
  299. orderCreated() {
  300. this.$http
  301. .post('/order/create', {
  302. ...this.dataJson,
  303. use_platform_point: this.usePlatformPoint,
  304. platform_coupon: this.platformCoupon.my_coupon_id == 0 ? undefined : {
  305. my_coupon_id: this.platformCoupon.my_coupon_id
  306. }
  307. })
  308. .then(res => {
  309. this.loading = false;
  310. this.jumpType = "order"
  311. if(!res.data.payStatus){
  312. uni.navigateTo({
  313. url: "/pages/web-view/Apps?path=" + res.data.payUrl
  314. })
  315. }else{
  316. uni.redirectTo({
  317. url: `/pages/order/orderList/orderList`
  318. })
  319. }
  320. // if (res && res.code == 200) {
  321. // let target = res.data;
  322. // if (target.payment_status == 5) {
  323. // // uni.reLaunch({
  324. // // url: `/pages/order/orderList/orderList?orderType=${this.sureDataAll.area_feature==3?3:0}`
  325. // // });
  326. // uni.redirectTo({
  327. // url: `/pages/order/orderList/orderList?orderType=${this.sureDataAll.area_feature==3?3:0}`
  328. // });
  329. // return false;
  330. // } else {
  331. // uni.navigateTo({
  332. // url: '../../order/pay?id=' + target.id + '&total_amount=' + target.total_amount +
  333. // '&expired_pay_time=' + target.expired_pay_time + '&type=' + this.type
  334. // });
  335. // }
  336. // }
  337. });
  338. },
  339. textareaText(e, index) {
  340. this.dataJson.shop_orders.map((v, i) => {
  341. if (i == index) {
  342. v.user_remark = e.detail.value;
  343. this.sureDataAll.shop_orders[i].user_remark = e.detail.value;
  344. }
  345. });
  346. },
  347. //店铺优惠查询
  348. getByShop(id) {
  349. this.$http.get('/marketing/firstOrder/getByShop/' + id).then(res => {
  350. if (res && res.code == 200) {
  351. this.shopDiscounts = res.data;
  352. }
  353. });
  354. },
  355. //选完地址回选
  356. otherFun(object) {
  357. this.addressChose = true;
  358. if (!!object) {
  359. let dataJson = uni.getStorageSync('dataJson');
  360. dataJson.receipt_id = object.addressid;
  361. this.dataJson = dataJson;
  362. this.postData(dataJson);
  363. }
  364. },
  365. postData(dataJson) {
  366. this.$http
  367. .post(`/order/build`, {
  368. ...dataJson,
  369. use_platform_point: this.usePlatformPoint,
  370. platform_coupon: this.platformCoupon.my_coupon_id == 0 ? undefined : {
  371. my_coupon_id: this.platformCoupon.my_coupon_id
  372. }
  373. })
  374. .then(res => {
  375. if (res && res.code == 200) {
  376. uni.setStorageSync('sureData', res.data);
  377. this.sureDataAll = res.data;
  378. let totaltNum = 0;
  379. res.data.shop_orders.forEach(res => {
  380. totaltNum += res.goods_num;
  381. });
  382. this.totaltNum = totaltNum;
  383. if (!res.data.has_platform) {
  384. this.usePlatformPoint = false;
  385. }
  386. }
  387. });
  388. },
  389. changeStatus(val) {
  390. this.status = val;
  391. if (val == 1) {
  392. this.dataJson.shipment_mode = 0;
  393. } else {
  394. this.dataJson.shipment_mode = 1;
  395. }
  396. this.postData(this.dataJson);
  397. },
  398. //选择优惠券
  399. checkCoupon() {
  400. let params = {
  401. marketing_type: this.sureDataAll.marketing_type,
  402. total_amount_dec_shop_coupon: this.sureDataAll.total_amount_dec_shop_coupon, // 支付总金额
  403. shop_order_list: this.sureDataAll.shop_orders.map(item => {
  404. return {
  405. total_amount_dec_shop_coupon: item
  406. .total_amount_dec_shop_coupon, //不含运费,扣出首单,扣除店铺优惠券的费用
  407. shop_id: item.shop_id // 店铺id
  408. }
  409. })
  410. }
  411. uni.navigateTo({
  412. url: `/pages/couponCenter/index?isCheck=true&couponId=${this.platformCoupon.my_coupon_id}&checkParams=${JSON.stringify(params)}`
  413. })
  414. },
  415. // 优惠券发生变动
  416. changeCoupon(platformCoupon) {
  417. this.platformCoupon = platformCoupon;
  418. }
  419. }
  420. };
  421. </script>
  422. <style lang="scss" scoped>
  423. /deep/ .input-placeholder {
  424. font-size: 26rpx;
  425. }
  426. </style>
  427. <style lang="scss">
  428. page {
  429. background-color: #f5f5f5;
  430. }
  431. .border {
  432. border-bottom: 3rpx solid #e7e7e7;
  433. }
  434. .textarea {
  435. width: 100%;
  436. height: 80rpx;
  437. background-color: #fafafa;
  438. padding: 22rpx 20rpx;
  439. box-sizing: border-box;
  440. border: 1px solid #ededed;
  441. border-radius: 20rpx;
  442. }
  443. .topStatus {
  444. height: 100rpx;
  445. background-color: #fff;
  446. position: fixed;
  447. z-index: 9;
  448. width: 100%;
  449. box-sizing: border-box;
  450. text {
  451. line-height: 100rpx;
  452. position: relative;
  453. }
  454. .active {
  455. font-weight: bold;
  456. color: #FA6138;
  457. }
  458. .active:after {
  459. width: 100%;
  460. height: 2px;
  461. background-color: #FA6138;
  462. content: '';
  463. position: absolute;
  464. bottom: 0;
  465. left: 0;
  466. }
  467. }
  468. .courierAddress {
  469. background-color: #fff;
  470. padding: 36rpx 30rpx;
  471. }
  472. .goHome,
  473. .listText {
  474. background-color: #fff;
  475. .title {
  476. display: flex;
  477. justify-content: space-between;
  478. align-items: center;
  479. .num {
  480. color: #808080;
  481. font-size: 26rpx;
  482. }
  483. }
  484. .freight {
  485. padding: 30rpx;
  486. .u-border-one-one {
  487. padding: 30rpx 0;
  488. }
  489. }
  490. .consumption_value-icon {
  491. font-size: 60rpx;
  492. color: #FF9651;
  493. }
  494. .consumption_value span {
  495. color: #FF6600;
  496. }
  497. }
  498. .btnview {
  499. width: 300rpx;
  500. margin: 30rpx auto 0;
  501. }
  502. .carbox {
  503. padding: 0rpx 0 160rpx 0;
  504. .shopList {
  505. background-color: #fff;
  506. padding: 30rpx 30rpx 0;
  507. }
  508. }
  509. .changeTabtwo {
  510. padding: 130rpx 0 160rpx 0;
  511. }
  512. .rightText {
  513. justify-content: space-between;
  514. height: 200rpx;
  515. }
  516. .bottext,
  517. .botPrice {
  518. width: 100%;
  519. }
  520. .bottext {
  521. margin-top: 36rpx;
  522. }
  523. .rightAddRes {
  524. width: 172rpx;
  525. height: 50rpx;
  526. border-radius: 8rpx;
  527. border: 1px solid #e5e5e5;
  528. .centertext {
  529. text-align: center;
  530. }
  531. .btnTag {
  532. width: 50rpx;
  533. height: 50rpx;
  534. line-height: 50rpx;
  535. text-align: center;
  536. background-color: #dedede;
  537. font-size: 46rpx;
  538. color: #888;
  539. }
  540. }
  541. .btnWidth {
  542. width: 340rpx;
  543. background: #FA6138;
  544. }
  545. .botfixed {
  546. position: fixed;
  547. background-color: #fff;
  548. width: 100%;
  549. height: 138rpx;
  550. bottom: 0;
  551. left: 0;
  552. z-index: 9;
  553. padding: 0 30rpx;
  554. box-sizing: border-box;
  555. }
  556. </style>