surePaySechill.vue 18 KB

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