Payment.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <template>
  2. <!-- 支付 -->
  3. <div class="Nopyment" v-loading="loading">
  4. <div class="message">
  5. <div>
  6. <img
  7. :src="require('../../assets/teacherdev/' + getimgurl(data) + '.png')"
  8. alt=""
  9. />
  10. </div>
  11. <div class="text">
  12. <p class="p1">
  13. {{ data.name }}
  14. </p>
  15. <p class="p2">
  16. <span>教研课程</span>
  17. </p>
  18. <p class="p3">
  19. <span v-for="(item, i) in data.teacher" :key="i + item">
  20. {{ item }}{{ i == data.teacher.length - 1 ? "" : "," }}
  21. </span>
  22. </p>
  23. </div>
  24. <div class="price">
  25. <p>¥{{ data.price }}</p>
  26. </div>
  27. </div>
  28. <div class="pay-platform">
  29. <p class="pay-platform-title">选择支付平台</p>
  30. <ul class="pay-platform-list">
  31. <li
  32. :class="item.isSelected ? 'active' : ''"
  33. v-for="(item, index) in platList"
  34. :key="'plat' + index"
  35. >
  36. <img :src="item.img" class="plat-logo" />
  37. <img src="../../assets/pay/active.png" class="active-icon" />
  38. </li>
  39. </ul>
  40. </div>
  41. <div class="total">
  42. <p class="p1">
  43. <span> 一件商品,总金额: </span>
  44. <span class="co-value">¥{{ data.price }}</span>
  45. </p>
  46. <p class="p2">
  47. <span> 优惠折扣: </span>
  48. <span
  49. v-text="changediscount_money(this.discount_money)"
  50. class="co-value"
  51. ></span>
  52. </p>
  53. <p class="p4">
  54. <span></span>
  55. <span class="co-value useCode">
  56. {{
  57. data.discount_code
  58. ? "优惠码:" + data.discount_code
  59. : "未使用优惠码"
  60. }}
  61. </span>
  62. </p>
  63. <p class="p3">
  64. <span> 应付: </span>
  65. <span class="co-value">¥{{ data.receivables_money }}</span>
  66. </p>
  67. </div>
  68. <div class="submitBtn">
  69. <button @click="buy(data)">去支付</button>
  70. </div>
  71. </div>
  72. </template>
  73. <script>
  74. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  75. //例如:import 《组件名称》from ‘《组件路径》';
  76. import { LearnWebSI } from "@/api/api";
  77. export default {
  78. //import引入的组件需要注入到对象中才能使用
  79. components: {},
  80. props: ["data", "orderNumber", "closePyment"],
  81. data() {
  82. //这里存放数据
  83. return {
  84. discount_code: "", //优惠码
  85. discount_money: 0.0, // 优惠金额
  86. receivables_money: this.data.price, // 应收款
  87. loading: false,
  88. platList: [
  89. {
  90. img: require("../../assets/pay/shouxinyi.png"),
  91. isSelected: true,
  92. },
  93. ],
  94. };
  95. },
  96. //计算属性 类似于data概念
  97. computed: {},
  98. //监控data中数据变化
  99. watch: {},
  100. //方法集合
  101. methods: {
  102. changediscount_money(value) {
  103. if (value == 0) {
  104. return "-¥" + value + ".00";
  105. }
  106. },
  107. // 根据不同的文件类型展示不同图片
  108. getimgurl(item) {
  109. let index = item.tag.indexOf("downloadable");
  110. let type = "";
  111. if (index != -1) {
  112. type = item.tag[2];
  113. } else {
  114. type = item.tag[1];
  115. }
  116. switch (type) {
  117. case "ppt":
  118. return "ppt";
  119. case "pdf":
  120. return "pdf";
  121. case "xlsx":
  122. return "exceil";
  123. case "xls":
  124. return "exceil";
  125. case "doc":
  126. return "word";
  127. case "word":
  128. return "word";
  129. default:
  130. return "word";
  131. }
  132. },
  133. // 购买
  134. buy(item) {
  135. this.loading = true;
  136. // 首先添加订单
  137. let Mnam = "order-order_manager-PayMyOrder";
  138. LearnWebSI(Mnam, {
  139. id: this.orderNumber, //商品id
  140. pay_money: this.data.receivables_money, //支付金额
  141. bank_transaction_sn: "", //银行交易流水号
  142. })
  143. .then((res) => {
  144. console.log(res);
  145. this.$message({
  146. type: "success",
  147. message: "支付成功",
  148. });
  149. this.closePyment("支付成功");
  150. this.loading = false;
  151. // 调取支付接口
  152. })
  153. .catch((res) => {
  154. this.loading = false;
  155. });
  156. },
  157. },
  158. //生命周期 - 创建完成(可以访问当前this实例)
  159. created() {},
  160. //生命周期 - 挂载完成(可以访问DOM元素)
  161. mounted() {
  162. console.log(this.data);
  163. },
  164. //生命周期-创建之前
  165. beforeCreated() {},
  166. //生命周期-挂载之前
  167. beforeMount() {},
  168. //生命周期-更新之前
  169. beforUpdate() {},
  170. //生命周期-更新之后
  171. updated() {},
  172. //生命周期-销毁之前
  173. beforeDestory() {},
  174. //生命周期-销毁完成
  175. destoryed() {},
  176. //如果页面有keep-alive缓存功能,这个函数会触发
  177. activated() {},
  178. };
  179. </script>
  180. <style lang="scss" scoped>
  181. /* @import url(); 引入css类 */
  182. .Nopyment {
  183. .message {
  184. width: 100%;
  185. height: 152px;
  186. background: rgba(70, 70, 70, 0.03);
  187. border-radius: 8px;
  188. display: flex;
  189. margin-bottom: 24px;
  190. img {
  191. width: 120px;
  192. height: 120px;
  193. margin-left: 16px;
  194. margin-top: 16px;
  195. }
  196. .text {
  197. margin-left: 24px;
  198. .p1 {
  199. width: 360px;
  200. // height: 45px;
  201. max-height: 48px;
  202. font-size: 16px;
  203. line-height: 20px;
  204. color: #2c2c2c;
  205. margin-top: 22px;
  206. word-break: break-all;
  207. display: -webkit-box;
  208. -webkit-box-orient: vertical;
  209. -webkit-line-clamp: 2;
  210. text-overflow: ellipsis;
  211. overflow: hidden;
  212. }
  213. .p2 {
  214. margin-top: 10px;
  215. span {
  216. width: 64px;
  217. height: 24px;
  218. background: #ffefd8;
  219. border-radius: 4px;
  220. font-weight: bold;
  221. font-size: 12px;
  222. text-align: center;
  223. color: #ff9900;
  224. line-height: 24px;
  225. padding: 2px 8px;
  226. }
  227. }
  228. .p3 {
  229. margin-top: 10px;
  230. }
  231. }
  232. .price {
  233. p {
  234. margin-left: 67px;
  235. margin-top: 22px;
  236. font-weight: bold;
  237. font-size: 16px;
  238. text-align: right;
  239. color: #ff4c00;
  240. }
  241. }
  242. }
  243. .promotionCode {
  244. display: flex;
  245. justify-content: flex-start;
  246. align-self: center;
  247. width: 100%;
  248. margin-top: 24px;
  249. height: 58px;
  250. line-height: 56px;
  251. border-top: 1px solid rgba(44, 44, 44, 0.15);
  252. border-bottom: 1px solid rgba(44, 44, 44, 0.15);
  253. .sp1 {
  254. font-size: 16px;
  255. color: #000000;
  256. }
  257. input {
  258. padding: 0 24px;
  259. flex: 1;
  260. height: 56px;
  261. outline: none;
  262. border: none;
  263. box-sizing: border-box;
  264. }
  265. .sp2 {
  266. cursor: pointer;
  267. font-size: 16px;
  268. color: #ff9900;
  269. }
  270. }
  271. .total {
  272. width: 656px;
  273. text-align: right;
  274. color: #000000;
  275. font-size: 16px;
  276. padding-top: 24px;
  277. .useCode {
  278. font-size: 12px;
  279. color: rgba(0, 0, 0, 0.5);
  280. }
  281. > p {
  282. > span {
  283. display: inline-block;
  284. }
  285. .co-value {
  286. width: 160px;
  287. }
  288. }
  289. .p1 {
  290. > span {
  291. display: inline-block;
  292. line-height: 24px;
  293. }
  294. }
  295. .p2 {
  296. margin: 16px 0 8px;
  297. }
  298. .p3 {
  299. > span {
  300. line-height: 36px;
  301. }
  302. .co-value {
  303. font-size: 24px;
  304. color: #ff4c00;
  305. }
  306. }
  307. .p4 {
  308. margin-bottom: 16px;
  309. }
  310. }
  311. .submitBtn {
  312. text-align: right;
  313. margin-top: 16px;
  314. button {
  315. width: 120px;
  316. height: 40px;
  317. background: #ff4d00;
  318. border-radius: 4px;
  319. color: white;
  320. line-height: 40px;
  321. text-align: center;
  322. border: none;
  323. outline: none;
  324. cursor: pointer;
  325. }
  326. }
  327. .pay-platform {
  328. width: 656px;
  329. box-sizing: border-box;
  330. padding: 16px 0 16px;
  331. border-top: 1px rgba(44, 44, 44, 0.15) solid;
  332. border-bottom: 1px rgba(44, 44, 44, 0.15) solid;
  333. &-title {
  334. padding: 0;
  335. margin: 0;
  336. font-style: normal;
  337. font-weight: normal;
  338. font-size: 16px;
  339. line-height: 150%;
  340. color: #000000;
  341. margin-bottom: 16px;
  342. }
  343. &-list {
  344. display: flex;
  345. flex-wrap: wrap;
  346. margin: 0;
  347. padding: 0;
  348. > li {
  349. position: relative;
  350. display: flex;
  351. justify-content: center;
  352. align-items: center;
  353. width: 152px;
  354. height: 60px;
  355. background: #ffffff;
  356. border: 1px solid rgba(44, 44, 44, 0.15);
  357. box-sizing: border-box;
  358. border-radius: 4px;
  359. cursor: pointer;
  360. margin: 0 8px 8px 0;
  361. > .plat-logo {
  362. width: 99px;
  363. height: 26px;
  364. }
  365. > .active-icon {
  366. position: absolute;
  367. bottom: -1px;
  368. right: -1px;
  369. width: 20px;
  370. height: 20px;
  371. display: block;
  372. }
  373. &.active {
  374. border-color: #ff9900;
  375. }
  376. }
  377. }
  378. }
  379. }
  380. </style>
  381. <style lang="scss">
  382. .tarcer-dev-Previrw {
  383. .el-dialog__body {
  384. padding: 30px 32px;
  385. }
  386. }
  387. </style>