payContain.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  1. <template>
  2. <container title="支付">
  3. <div class="pay-top">
  4. <p class="pay-title">已选商品</p>
  5. <div class="good-list scrollbar">
  6. <div class="good-item fl_c" v-for="(item, i) in list" :key="i">
  7. <img
  8. src="https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"
  9. alt=""
  10. />
  11. <div class="good-info">
  12. <div class="line1">
  13. {{ item.goodsName }}
  14. </div>
  15. <div>
  16. <span class="cb22">¥{{ item.specialPrice | formatPrice }}</span>
  17. <span class="text-21f"
  18. >+
  19. {{ item._integral }}
  20. 积分</span
  21. >
  22. <span class="text-line c99"
  23. >¥{{ item.standPrice | formatPrice }}</span
  24. >
  25. </div>
  26. </div>
  27. <div class="good-btn fl_c" @click="del(i)">
  28. <i class="el-icon-delete"></i>
  29. </div>
  30. </div>
  31. </div>
  32. </div>
  33. <div class="pay-bom">
  34. <p class="pay-title">商品价格</p>
  35. <div class="input-ward fl">
  36. <input
  37. @focus="$emit('changeFocusType', 'allPrice')"
  38. placeholder="请输入金额"
  39. @input="$emit('checkValue', from.allPrice)"
  40. v-model="from.allPrice"
  41. v-int
  42. />
  43. </div>
  44. <div class="discount fl">
  45. <img src="../../../assets//images//Controls_sel.png" alt="" />
  46. <span class="discount-text">折扣商品</span>
  47. <span class="mr">该商品最多可抵扣</span>
  48. <input
  49. type="text"
  50. v-model="from.discount"
  51. v-int
  52. @input="$emit('checkValue', from.discount)"
  53. @focus="$emit('changeFocusType', 'discount')"
  54. />
  55. <span class="mr1">元</span>
  56. <span class="text-21f">({{ morePointsValue }}积分)</span>
  57. </div>
  58. <div class="integral-box c48">
  59. <div>
  60. 可用积分:
  61. {{ pointsValue }}积分 ({{
  62. (pointsValue / getRules) | formatPrice
  63. }}元)
  64. </div>
  65. <div>
  66. 抵扣积分:{{ deductionIntegral }}积分({{
  67. (deductionIntegral / getRules) | formatPrice
  68. }}元)
  69. </div>
  70. <div>
  71. 积分补差:{{ paidPointsValue }}积分({{
  72. (paidPointsValue / getRules) | formatPrice
  73. }}元)
  74. </div>
  75. <div class="line"></div>
  76. <div class="c48">
  77. 优惠金额:<span class="discount-money"
  78. >¥{{ (deductionIntegral / getRules) | formatPrice }}</span
  79. >
  80. </div>
  81. <div class="c48">
  82. 实付金额:<span class="money">¥{{ payPrice | formatPrice }}</span>
  83. </div>
  84. <div class="fl c48">
  85. 支付方式:
  86. <div
  87. class="wechart fl_c"
  88. :class="{ actived1: active == item.value }"
  89. @click="active = item.value"
  90. v-for="item in payType"
  91. :key="item.value"
  92. >
  93. <img :src="item.src" alt="" />
  94. <span>{{ item.lebel }}</span>
  95. </div>
  96. </div>
  97. </div>
  98. <div class="btn">
  99. <el-button type="danger" @click="handelPay">立即收款</el-button>
  100. </div>
  101. </div>
  102. <Base-dialog
  103. title="请先扫码会员卡"
  104. :isShow.sync="isShow"
  105. @submit="submitForm"
  106. confirmName="确 认"
  107. >
  108. <el-form :model="this" :rules="rules" ref="ruleForm">
  109. <el-form-item label=" " prop="cardSn">
  110. <div class="input-box">
  111. <el-input
  112. placeholder="请扫描会员卡"
  113. v-model="cardSn"
  114. :max="8"
  115. v-int="{ set: 0 }"
  116. >
  117. <img
  118. class="dialog-icon"
  119. src="../../../assets/images/icon_scan.png"
  120. slot="suffix"
  121. />
  122. </el-input>
  123. </div>
  124. </el-form-item>
  125. </el-form>
  126. </Base-dialog>
  127. <Base-dialog
  128. title="请扫码支付"
  129. :isShow.sync="isShowCode"
  130. width="400px"
  131. :isShowFooter="false"
  132. >
  133. <div class="scan_pay_box">
  134. <div class="code_box">
  135. <div id="root" ref="qrCodeUrl"></div>
  136. <div class="code_box_tip fl_b">
  137. <img
  138. class="dialog-icon"
  139. src="../../../assets/images/icon_scan3.png"
  140. slot="suffix"
  141. />
  142. <p>打开手机的微信扫描二维码支付</p>
  143. </div>
  144. </div>
  145. <div class="c48">
  146. 实付金额(元):
  147. <span class="money">¥</span>
  148. <span class="money fs30">{{ 1511 | formatPrice }}</span>
  149. </div>
  150. </div>
  151. </Base-dialog>
  152. </container>
  153. </template>
  154. <script>
  155. import { mapGetters } from "vuex";
  156. import QRCode from "qrcodejs2";
  157. export default {
  158. name: "SaasMemberPayContain",
  159. props: {
  160. list: {
  161. type: Array,
  162. default: () => {
  163. return [];
  164. },
  165. },
  166. from: {
  167. type: Object,
  168. default: () => {
  169. return {};
  170. },
  171. },
  172. type: {
  173. type: [Number, String],
  174. },
  175. memberInfo: {
  176. type: Object,
  177. default: () => {
  178. return {};
  179. },
  180. },
  181. getUserDetail: {
  182. type: Function,
  183. default: () => {},
  184. },
  185. },
  186. data() {
  187. var validateCardSn = (rule, value, callback) => {
  188. if (value.length !== 16) {
  189. return callback(new Error("会员卡号格式不正确"));
  190. }
  191. callback();
  192. };
  193. return {
  194. money: "",
  195. checked: true,
  196. payType: [
  197. {
  198. lebel: "微信支付",
  199. value: 1,
  200. src: require("../../../assets/images/icon_wechat.png"),
  201. },
  202. {
  203. lebel: "现金支付",
  204. value: 3,
  205. src: require("../../../assets/images/icon_cash.png"),
  206. },
  207. ],
  208. active: 1,
  209. isShow: false,
  210. cardSn: "1000146902628081",
  211. rules: {
  212. cardSn: [{ validator: validateCardSn, trigger: "blur" }],
  213. },
  214. qrcode: null,
  215. isShowCode: false,
  216. };
  217. },
  218. mounted() {
  219. // this.$nextTick(() => {
  220. // this.creatQrCode();
  221. // });
  222. },
  223. methods: {
  224. handelPay() {
  225. if (this.list.length == 0) {
  226. this.$message({
  227. message: "请选择至少一个商品",
  228. type: "warning",
  229. });
  230. return;
  231. }
  232. if (!this.isHaveUser) {
  233. this.$nextTick(() => {
  234. this.$refs["ruleForm"] && this.$refs["ruleForm"].resetFields();
  235. });
  236. this.isShow = true;
  237. return;
  238. }
  239. this.from.userId = this.memberInfo.userId;
  240. if (this.active == 1) {
  241. this.from.orderStatus = 0;
  242. this.from.payStatus = 0;
  243. } else {
  244. this.from.orderStatus = 1;
  245. this.from.payStatus = 2;
  246. }
  247. this.from.payType = this.active;
  248. this.from.payPrice = this.payPrice;
  249. this.from.deductionIntegral = this.deductionIntegral;
  250. this.from.deductionMoney = (
  251. this.deductionIntegral / this.getRules
  252. ).toFixed(2);
  253. this.from.integralRule = this.getRules;
  254. this.from.goodsList = this.list.map((e) => {
  255. return {
  256. goodsId: e.goodsId,
  257. goodsPrice: e.standPrice,
  258. goodsReceived: e.specialPrice,
  259. specialPrice: e.specialPrice,
  260. payStatus: this.from.payStatus,
  261. };
  262. });
  263. this.$emit("pay");
  264. },
  265. del(index) {
  266. this.list.splice(index, 1);
  267. },
  268. focus(type) {
  269. this.$emit("update:type", type);
  270. },
  271. submitForm() {
  272. this.$refs["ruleForm"].validate((valid) => {
  273. if (valid) {
  274. this.getUserDetail(this.cardSn).then((res) => {
  275. this.isShow = false;
  276. this.handelPay();
  277. });
  278. } else {
  279. console.log("error submit!!");
  280. return false;
  281. }
  282. });
  283. },
  284. creatQrCode() {
  285. this.qrcode = new QRCode(this.$refs.qrCodeUrl, {
  286. text: "https://www.baidu.com/", // 需要转换为二维码的内容
  287. width: 200,
  288. height: 200,
  289. colorDark: "#000000",
  290. colorLight: "#ffffff",
  291. correctLevel: QRCode.CorrectLevel.H,
  292. });
  293. },
  294. },
  295. computed: {
  296. ...mapGetters(["getRules"]),
  297. pointsValue() {
  298. if (!this.isHaveUser) {
  299. return 0;
  300. }
  301. return this.memberInfo.pointsValue;
  302. },
  303. payPrice() {
  304. return (
  305. this.from.allPrice -
  306. this.from.discount +
  307. this.paidPointsValue / this.getRules
  308. ).toFixed(2);
  309. },
  310. deductionIntegral() {
  311. if (!this.isHaveUser) {
  312. return 0;
  313. }
  314. return this.pointsValue > this.morePointsValue
  315. ? this.morePointsValue
  316. : this.pointsValue;
  317. },
  318. paidPointsValue() {
  319. if (!this.isHaveUser) {
  320. return 0;
  321. }
  322. return this.morePointsValue - this.deductionIntegral;
  323. },
  324. paidPrice() {
  325. return this.formatPrice(this.paidPointsValue / this.getRules);
  326. },
  327. morePointsValue() {
  328. return this.from.discount * this.getRules;
  329. },
  330. isHaveUser() {
  331. return !!this.memberInfo.userId;
  332. },
  333. },
  334. components: {
  335. QRCode,
  336. },
  337. };
  338. </script>
  339. <style lang="scss" scoped>
  340. .pay-title {
  341. font-size: 14px;
  342. color: #4a4a4b;
  343. }
  344. .pay-top {
  345. margin-bottom: 40px;
  346. .good-list {
  347. height: 260px;
  348. overflow-x: auto;
  349. .good-item {
  350. height: 60px;
  351. margin-bottom: 28px;
  352. &:nth-last-of-type(1) {
  353. margin-bottom: 0;
  354. }
  355. img {
  356. width: 60px;
  357. height: 60px;
  358. border-radius: 8px;
  359. margin-right: 10px;
  360. }
  361. .good-info {
  362. flex: 1;
  363. overflow: hidden;
  364. .line1 {
  365. color: #4a4a4b;
  366. }
  367. div:nth-of-type(2) {
  368. margin-top: 14px;
  369. span {
  370. font-size: 14px;
  371. margin-right: 4px;
  372. &:last-child {
  373. margin-left: 20px;
  374. }
  375. }
  376. }
  377. }
  378. .good-btn {
  379. width: 40px;
  380. height: 60px;
  381. background: #eb5757;
  382. border-radius: 8px;
  383. height: 100%;
  384. margin-left: 20px;
  385. i {
  386. color: #ffffff;
  387. }
  388. }
  389. }
  390. }
  391. }
  392. .pay-bom {
  393. height: 400px;
  394. .input-ward {
  395. width: 100%;
  396. height: 68px;
  397. background: #f6f7f9;
  398. border-radius: 12px;
  399. padding-left: 16px;
  400. font-weight: 800;
  401. color: #222222;
  402. font-size: 24px;
  403. margin-bottom: 28px;
  404. input {
  405. font-weight: 800;
  406. color: #222222;
  407. font-size: 24px;
  408. &::-webkit-input-placeholder {
  409. // 针对 谷歌 内核
  410. font-weight: 600;
  411. font-size: 20px;
  412. line-height: 40px;
  413. }
  414. }
  415. }
  416. .discount {
  417. width: 100%;
  418. font-size: 14px;
  419. margin-bottom: 18px;
  420. .mr {
  421. margin: 0 8px 0 12px;
  422. color: #666666;
  423. }
  424. .mr1 {
  425. margin-left: 8px;
  426. color: #666666;
  427. }
  428. .discount-text {
  429. color: #000;
  430. font-weight: bold;
  431. color: #4a4a4b;
  432. margin-left: 5px;
  433. }
  434. input {
  435. width: 114px;
  436. height: 36px;
  437. padding: 0 10px;
  438. border-radius: 6px;
  439. }
  440. }
  441. .integral-box {
  442. height: 100%;
  443. padding-bottom: 16px;
  444. div {
  445. margin-top: 16px;
  446. }
  447. .discount-money {
  448. color: #eb5757;
  449. font-size: 14px;
  450. }
  451. .money {
  452. font-weight: 800;
  453. color: #eb5757;
  454. font-size: 16px;
  455. }
  456. .fl {
  457. margin-top: 20px;
  458. }
  459. .wechart {
  460. margin-top: 0;
  461. margin-right: 20px;
  462. width: 160px;
  463. height: 55px;
  464. background: #f6f7f9;
  465. border-radius: 12px;
  466. color: #09bb07;
  467. font-size: 16px;
  468. cursor: pointer;
  469. img {
  470. margin-right: 6px;
  471. margin-top: 4px;
  472. }
  473. }
  474. .actived1 {
  475. border: 1px solid #fa821f;
  476. background: #fffaf7;
  477. color: #00908c;
  478. }
  479. .line {
  480. height: 2px;
  481. background: #f1f1f1;
  482. margin: 16px 0;
  483. }
  484. }
  485. .btn {
  486. width: 382px;
  487. height: 52px;
  488. margin: 36px auto 0;
  489. .el-button {
  490. width: 100%;
  491. height: 52px;
  492. background: #fa821f;
  493. border-radius: 8px;
  494. }
  495. }
  496. input {
  497. background: #f6f7f9;
  498. border: none;
  499. outline: none;
  500. }
  501. }
  502. .input-box {
  503. img {
  504. margin: 8px 8px 0 0;
  505. }
  506. }
  507. .scan_pay_box {
  508. width: 280px;
  509. margin: 0 auto;
  510. .code_box {
  511. height: 330px;
  512. padding: 30px 40px;
  513. border: 1px solid #cccccc;
  514. .code_box_tip {
  515. img {
  516. width: 44px;
  517. height: 44px;
  518. }
  519. p {
  520. width: 130px;
  521. color: #4a4a4b;
  522. font-size: 18px;
  523. }
  524. }
  525. }
  526. .c48 {
  527. margin-top: 20px;
  528. text-align: center;
  529. font-size: 16px;
  530. .fs30 {
  531. font-size: 26px;
  532. }
  533. }
  534. }
  535. .money {
  536. font-weight: 800;
  537. color: #eb5757;
  538. font-size: 16px;
  539. }
  540. </style>