affirmGhs.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. <style lang="scss" scoped>
  2. .admin-button-com {
  3. margin-right: 20upx;
  4. }
  5. .affirm-page {
  6. position: relative;
  7. height: 100%;
  8. display: flex;
  9. flex-direction: column;
  10. .affirm-view {
  11. flex: 1;
  12. padding: 20px;
  13. background-color: #f0f2f6;
  14. .commodity-view {
  15. display: flex;
  16. flex-direction: column;
  17. .commodity-list {
  18. padding: 20px;
  19. .commodity-item {
  20. display: flex;
  21. margin-bottom: 20px;
  22. .item-icon {
  23. flex-shrink: 0;
  24. width: 140px;
  25. height: 140px;
  26. }
  27. .item-info {
  28. display: flex;
  29. flex-direction: column;
  30. justify-content: center;
  31. flex: 1;
  32. margin-left: 20px;
  33. .info-line {
  34. margin-bottom: 20px;
  35. display: flex;
  36. justify-content: space-between;
  37. align-items: flex-end;
  38. .item-name {
  39. color: #666;
  40. font-size: 28px;
  41. }
  42. .item-price {
  43. color: #333;
  44. font-size: 22px;
  45. .price {
  46. font-size: 32px;
  47. font-weight: bold;
  48. }
  49. }
  50. .item-type {
  51. color: #999;
  52. font-size: 24px;
  53. }
  54. .item-count {
  55. color: #666;
  56. font-size: 24px;
  57. }
  58. }
  59. }
  60. }
  61. }
  62. .summary-bar {
  63. padding: 0 20px;
  64. height: 90px;
  65. display: flex;
  66. align-items: center;
  67. justify-content: space-between;
  68. border-top: 1px solid #eeeeee;
  69. .operate-view {
  70. display: flex;
  71. align-items: center;
  72. color: #3385ff;
  73. font-size: 26px;
  74. .iconfont {
  75. margin-right: 20px;
  76. font-size: 40px;
  77. }
  78. }
  79. .describe-view {
  80. display: flex;
  81. align-items: center;
  82. color: #333;
  83. font-size: 24px;
  84. .price {
  85. font-weight: bold;
  86. font-size: 36px;
  87. }
  88. }
  89. }
  90. }
  91. .module-com {
  92. background-color: #fff;
  93. margin-bottom: 20px;
  94. border-radius: 10px;
  95. overflow: hidden;
  96. .ghs-msg{
  97. padding: 0 20rpx;
  98. height: 60rpx;
  99. font-size: 28rpx;
  100. &.active{
  101. color: #868686;
  102. font-size: 24rpx;
  103. }
  104. i{color: #62ed73;font-size: 32rpx}
  105. }
  106. .member-wrap {
  107. .member-det {
  108. font-size: 24px;
  109. margin-left: 20px;
  110. }
  111. }
  112. .remark-wrap {
  113. align-items: flex-start;
  114. .remark {
  115. height: 240px;
  116. }
  117. }
  118. }
  119. }
  120. .under-bar {
  121. display: flex;
  122. justify-content: space-between;
  123. align-items: center;
  124. padding: 0 20px;
  125. width: 100%;
  126. height: 100px;
  127. background-color: #fff;
  128. box-shadow: 0px -1px 6px 0px rgba(4, 0, 0, 0.06);
  129. .price-view {
  130. display: flex;
  131. align-items: center;
  132. font-size: 24px;
  133. .price-title {
  134. color: #333;
  135. }
  136. .price-number {
  137. margin: 0 20px;
  138. color: #ff2842;
  139. .large {
  140. font-size: 40px;
  141. }
  142. }
  143. }
  144. .admin-button-com {
  145. width: 200px;
  146. }
  147. }
  148. .coupon_box{
  149. flex: 1;
  150. text-align: right;
  151. padding-right: 45upx;
  152. color: #ff2945;
  153. }
  154. }
  155. </style>
  156. <template>
  157. <view class="affirm-page">
  158. <view class="affirm-view overscroll">
  159. <!-- 门店信息 -->
  160. <form>
  161. <view class="module-com">
  162. <view class="flex-space ghs-msg">
  163. {{ghsMsg.name}} {{ ghsMsg.mobile }}
  164. <i class="iconfont icondianhua1" @tap="toPhone(ghsMsg.mobile)"></i>
  165. </view>
  166. <view class="flex ghs-msg active">
  167. {{ ghsMsg.fullAddress }}
  168. </view>
  169. </view>
  170. <view class="module-com">
  171. <view class="commodity-view">
  172. <view class="commodity-list">
  173. <view
  174. class="commodity-item"
  175. v-for="(item, index) in selectList"
  176. :key="index"
  177. >
  178. <image class="item-icon" :src="item.cover" alt="商品图" />
  179. <view class="item-info">
  180. <view class="info-line">
  181. <text class="item-name">{{ item.itemName }}</text>
  182. <text class="item-price">
  183. <text class="unit">¥</text>
  184. <text class="price">
  185. {{ getSelectItemPrice(item) }}
  186. </text>
  187. </text>
  188. </view>
  189. <view class="info-line">
  190. <text class="item-type">{{ item.rank }}级</text>
  191. <text class="item-count">
  192. <text v-if="item.bigCount > 0 || item.smallCount > 0">{{
  193. `${item.bigCount}`
  194. }}</text>
  195. <text v-if="item.smallCount > 0">/</text>
  196. <text v-if="item.smallCount > 0">{{ `${item.smallCount}` }}</text>
  197. </text>
  198. </view>
  199. </view>
  200. </view>
  201. </view>
  202. <view class="summary-bar">
  203. <view class="operate-view" @click="gobackEvent">
  204. <text class="iconfont icongouwuche"></text>
  205. 重选花材
  206. </view>
  207. <view class="describe-view">
  208. 共{{ allCount.bigLength }}/{{ allCount.smallLength }}种,
  209. <!-- 共16扎9支, -->
  210. 合计 ¥<text class="price">{{ allPrice }}</text>
  211. </view>
  212. </view>
  213. </view>
  214. </view>
  215. <!-- 登录信息 -->
  216. <view class="module-com input-line-wrap">
  217. <!-- <tui-list-cell class="line-cell" :hover="false" :arrow="true">-->
  218. <!-- <view class="tui-title ">客户</view>-->
  219. <!-- <view class="tui-input" v-if="form.customId" @click="showCustomer = true">{{ form.customName }}</view>-->
  220. <!-- <view class="tui-placeholder" style="width: 100%" v-else @click="showCustomer = true">请选择客户</view>-->
  221. <!-- </tui-list-cell>-->
  222. <tui-list-cell class="line-cell" :hover="false" :arrow="false">
  223. <view class="tui-title ">送货</view>
  224. <button @click="form.sendType=1" class="admin-button-com mini-btn" :class="form.sendType==1?'blue':'default'">配送</button>
  225. <button @tap="form.sendType=2" class="admin-button-com mini-btn" :class="form.sendType==2?'blue':'default'">自取</button>
  226. </tui-list-cell>
  227. <!-- <appSendTime :placeholder="'默认30分钟内配送'" @alterTime="purchaseFreight(ghsMsg)" :sendDate.sync="form.sendDate" :sendTime.sync="sendTime" ></appSendTime> -->
  228. <appTimer :placeholder="'默认30分钟内配送'" @confirm="onConfirm" :sendTime="sendTime"></appTimer>
  229. <tui-list-cell class="line-cell" :hover="false" :arrow="false" v-show="form.sendType == 1">
  230. <view class="tui-title ">运费</view>
  231. <input type="number" placeholder="留空表示免运费" @input="countAllPrices" v-model="form.sendCost" placeholder-class="tui-placeholder" disabled>
  232. </tui-list-cell>
  233. <tui-list-cell class="line-cell" :hover="false" :arrow="true" @click="toCoupon">
  234. <view class="tui-title ">红包/抵用券</view>
  235. <view class="coupon_box">{{couponText}}</view>
  236. </tui-list-cell>
  237. <tui-list-cell class="line-cell" :hover="false" :arrow="false">
  238. <textarea style="height: 100rpx" v-model="remark" placeholder="备注..."/>
  239. </tui-list-cell>
  240. <!-- <tui-list-cell class="line-cell" :hover="false" :arrow="false">-->
  241. <!-- <view class="tui-title ">结算方式</view>-->
  242. <!-- <button @tap="form.debt=1" class="admin-button-com mini-btn" :class="form.debt==1?'blue':'default'">欠款</button>-->
  243. <!-- <button @click="form.debt=0" class="admin-button-com mini-btn" :class="form.debt==0?'blue':'default'">已收款</button>-->
  244. <!-- </tui-list-cell>-->
  245. <!-- <appFormSend :form.sync="form"> </appFormSend>-->
  246. </view>
  247. </form>
  248. </view>
  249. <view class="under-bar">
  250. <view class="price-view">
  251. <text class="price-title">总金额</text>
  252. <text class="price-number">
  253. ¥
  254. <text class="large" v-if="form.sendType==1 && !couponSumText">{{ numberAdd(allPrice, Number(form.sendCost)) }}</text>
  255. <text class="large" v-else-if="form.sendType==1 && couponSumText">{{ allPrice + Number(form.sendCost) - Number(couponSumText) }}</text>
  256. <text class="large" v-else-if="form.sendType==2 && !couponSumText">{{ allPrice}}</text>
  257. <text class="large" v-else-if="form.sendType==2 && couponSumText">{{ NumberSub(allPrice, Number(couponSumText))}}</text>
  258. <!-- <text class="large" v-else-if="!form.sendType && !couponSumText">{{ allPrice }}</text> -->
  259. <!-- <text class="large" v-else-if="!form.sendType && couponSumText">{{ NumberSub(allPrice, Number(couponSumText)) }}</text> -->
  260. </text>
  261. </view>
  262. <button class="admin-button-com blue middle" @click="affirmFormSubmit">提交</button>
  263. </view>
  264. <!-- 选择客户 -->
  265. <!-- <AppCustomerSel :show.sync="showCustomer" @change="changeCustomerFn" />-->
  266. </view>
  267. </template>
  268. <script>
  269. import TuiListCell from "@/components/plugin/list-cell";
  270. import AppAvatarModule from "@/components/module/app-avatar";
  271. import SimpleAddress from "@/components/plugin/simple-address";
  272. import AppAreaSel from "@/components/app-area-sel";
  273. import AppCustomerSel from "@/components/app-customer-sel";
  274. import productMins from "@/mixins/product";
  275. import appTimer from '@/components/app-timer'
  276. import appFormRadioBtn from "@/components/app-formRadio-btn";
  277. import appAddressGroup from "@/components/app-address-group";
  278. import appFormSend from "@/components/app-form-send";
  279. import appSendTime from "@/components/app-send-time";
  280. const formUtil = require("@/utils/formValidation.js");
  281. // import { createOrder } from "@/api/order/index";
  282. import { getGhsDataApi } from "@/api/ghs/index";
  283. import { freight,createOrder } from "@/api/purchase/index";
  284. import { mapActions, mapGetters } from "vuex";
  285. import { shopHouponHas } from '@/api/coupon'
  286. export default {
  287. name: "BillingAffirm", // 开单确认
  288. components: {
  289. TuiListCell,
  290. AppAvatarModule,
  291. SimpleAddress,
  292. AppAreaSel,
  293. appSendTime,
  294. AppCustomerSel,
  295. appFormRadioBtn,
  296. appAddressGroup,
  297. appFormSend,
  298. appTimer
  299. },
  300. mixins: [productMins],
  301. data() {
  302. return {
  303. autoLoad: false,
  304. ghsMsg:'',
  305. sendTime:'',
  306. remark:'',
  307. form: {
  308. debt:1,//结算方式 1欠款订单 0正常订单
  309. shopId: "",
  310. shopName: "",
  311. receiveProvince: "",
  312. receiveCity: "",
  313. receiveFloor: "",
  314. receiveAddress: "",
  315. receiveLong: "",
  316. receiveLat: "",
  317. sendType: 1,
  318. sendSide: "2",
  319. sendDate: "",
  320. sendTime: "",
  321. sendCost: "",
  322. customId: "",
  323. product: "",
  324. couponId: '0'
  325. },
  326. // 详细地址
  327. // showRegion: false,
  328. showCustomer: false,
  329. couponSumText: '',
  330. couponText: ''
  331. };
  332. },
  333. onLoad(e) {
  334. if (!this.getMerchantInfo) {
  335. this.initMerchantInfo().then(data => {
  336. uni.setNavigationBarTitle({
  337. title: data.name
  338. });
  339. });
  340. } else {
  341. uni.setNavigationBarTitle({
  342. title: this.getMerchantInfo.name
  343. });
  344. }
  345. this.getGhsData(e.id);
  346. },
  347. onShow() {
  348. if(uni.getStorageSync('selectCouponInfo').couponSum) {
  349. this.couponSumText = uni.getStorageSync('selectCouponInfo').couponSum
  350. this.couponText = '-¥' + this.couponSumText
  351. this.form.couponId = uni.getStorageSync('selectCouponInfo').couponId
  352. } else {
  353. this.couponSumText = "0"
  354. this.form.couponId = '0'
  355. this.hasCoupon()
  356. }
  357. },
  358. computed: {
  359. ...mapGetters(["getMerchantInfo", "getLoginInfo"])
  360. },
  361. methods: {
  362. ...mapActions(["initMerchantInfo"]),
  363. init() {
  364. this._getDet();
  365. },
  366. onConfirm(val) {
  367. this.sendTime = val
  368. },
  369. toPhone(phone){
  370. let amount = this.form.sendType == 1 ? this.allPrice+Number(this.form.sendCost) : this.allPrice
  371. uni.makePhoneCall({
  372. phoneNumber: phone
  373. });
  374. },
  375. toCoupon() {
  376. let amount = this.form.sendType == 1 ? this.numberAdd(this.allPrice, Number(this.form.sendCost)) : this.allPrice
  377. console.log(amount)
  378. this.pageTo({url: '/admin/coupon/selectCouponList?price=' + amount})
  379. },
  380. // 是否有可用优惠券
  381. hasCoupon() {
  382. let amount = this.form.sendType == 1 ? this.numberAdd(this.allPrice, Number(this.form.sendCost)) : this.allPrice
  383. shopHouponHas({amount}).then(res => {
  384. console.log(377, res)
  385. this.couponText = res.data.has ? '有可用优惠券' : ''
  386. console.log(this.couponText)
  387. }).catch(err => {})
  388. },
  389. getGhsData(id) {
  390. getGhsDataApi({id:id}).then(res => {
  391. this.ghsMsg = res.data;
  392. console.log('res.data',this.ghsMsg)
  393. this.purchaseFreight(this.ghsMsg);
  394. });
  395. },
  396. countAllPrices(e){
  397. this.allPrices = this.allPrices+Number(this.form.sendCost)
  398. console.log('e',e)
  399. console.log('this.form.sendCost',Number(this.form.sendCost))
  400. console.log('this.form.sendCost',this.form.sendCost)
  401. console.log('this.allPrices',this.allPrices)
  402. },
  403. // api
  404. _getDet() {
  405. let data = uni.getStorageSync("modifyShopB");
  406. if (this.$util.isEmpty(data)) return;
  407. Object.keys(this.form).forEach((i, index) => {
  408. // if (i != 'password') {
  409. this.form[i] = data[i];
  410. // }
  411. });
  412. },
  413. purchaseFreight(info) {
  414. let params = {
  415. province: info.province,
  416. city:info.city,
  417. address:info.address,
  418. floor:info.floor,
  419. long: info.long,
  420. lat: info.lat,
  421. sendTime: this.sendTime,
  422. };
  423. freight(params).then(res => {
  424. this.form.sendCost = res.data.sedCost;
  425. });
  426. },
  427. confirmFn(options) {
  428. createOrder(options).then(res => {
  429. // this.$msg("下单成功");
  430. this.resetSelectInfoByType(this.pageType);
  431. const {
  432. data: { id, orderSn }
  433. } = res;
  434. let url = `/admin/billing/result?orderId=${id}&orderSn=${orderSn}`;
  435. uni.redirectTo({
  436. url: url,
  437. success: result => {},
  438. fail: () => {},
  439. complete: () => {}
  440. });
  441. });
  442. },
  443. affirmFormSubmit(){
  444. const product = this.selectList.map(ele => {
  445. return { productId: ele.id, bigNum: ele.bigCount, smallNum: ele.smallCount,classId:ele.classId,itemId:ele.itemId };
  446. });
  447. let parameter = {
  448. getType:this.form.sendType,
  449. sendTime:this.sendTime,
  450. sendCost:this.form.sendType==2?'':this.form.sendCost,
  451. remark:this.remark,
  452. product:JSON.stringify(product),
  453. ghsId:this.ghsMsg.id,
  454. couponId: this.form.couponId
  455. }
  456. let self = this;
  457. uni.showModal({
  458. title: '提示',
  459. content: '确认提交?',
  460. success: function (res) {
  461. if (res.confirm) {
  462. uni.removeStorageSync('selectCouponInfo')
  463. createOrder(parameter).then(res => {
  464. self.resetSelectInfoByType(self.pageType);
  465. const {data: { orderSn,actPrice }} = res;
  466. self.pageTo({url: `/pagesPurchase/wechatPay?type=2&orderSn=${orderSn}&actPrice=${actPrice}`, type: 2})
  467. });
  468. }
  469. }
  470. });
  471. },
  472. numberAdd(arg1, arg2) {
  473. var r1, r2, m, n;
  474. try {
  475. r1 = arg1.toString().split(".")[1].length
  476. } catch (e) {
  477. r1 = 0
  478. }
  479. try {
  480. r2 = arg2.toString().split(".")[1].length
  481. } catch (e) {
  482. r2 = 0
  483. }
  484. m = Math.pow(10, Math.max(r1, r2))
  485. n = (r1 >= r2) ? r1 : r2;
  486. return ((arg1 * m + arg2 * m) / m).toFixed(n);
  487. },
  488. NumberSub(arg1, arg2) {
  489. var re1, re2, m, n;
  490. try {
  491. re1 = arg1.toString().split(".")[1].length;
  492. } catch (e) {
  493. re1 = 0;
  494. }
  495. try {
  496. re2 = arg2.toString().split(".")[1].length;
  497. } catch (e) {
  498. re2 = 0;
  499. }
  500. m = Math.pow(10, Math.max(re1, re2));
  501. n = (re1 >= re2) ? re1 : re2;
  502. return ((arg1 * m - arg2 * m) / m).toFixed(n);
  503. },
  504. // 表单验证
  505. async formSubmit(e) {
  506. try {
  507. // 进行表单检查
  508. let formData = this.form;
  509. const product = this.selectList.map(ele => {
  510. return { productId: ele.id, bigNum: ele.bigCount, smallNum: ele.smallCount };
  511. });
  512. formData.product = JSON.stringify(product);
  513. if (!this.getMerchantInfo) {
  514. await this.initMerchantInfo();
  515. }
  516. formData.shopId = this.getMerchantInfo.id;
  517. console.log(9999, formData);
  518. // this.confirmFn(formData);
  519. // let rules = rules.concat(temp);
  520. let checkRes = formUtil.validation(formData, []);
  521. // 验证通过!
  522. if (!checkRes) {
  523. this.confirmFn(formData);
  524. } else {
  525. this.$msg(checkRes);
  526. }
  527. } catch (error) {
  528. console.log(999999, error);
  529. }
  530. },
  531. gobackEvent() {
  532. uni.navigateBack({
  533. delta: 1
  534. });
  535. }
  536. }
  537. };
  538. </script>