freeSurePay.vue 15 KB

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