Confirmorder.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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="promotionCode">
  29. <span class="sp1">使用优惠码</span>
  30. <input
  31. v-model="discount_code"
  32. type="text"
  33. placeholder="请输入兑换码"
  34. @input="changeCode"
  35. />
  36. <span
  37. class="sp2"
  38. v-loading="codeloading"
  39. @click="verifyCode"
  40. v-if="isShow"
  41. >确定</span
  42. >
  43. <span class="sp2" v-else>-{{ discount_money }}</span>
  44. </div>
  45. <div class="total">
  46. <p class="p1">
  47. <span> 一件商品,总金额: </span>
  48. <span class="co-value">¥{{ data.price }}</span>
  49. </p>
  50. <p class="p2">
  51. <span> 优惠折扣: </span>
  52. <span class="co-value">-¥{{ discount_money }}</span>
  53. </p>
  54. <p class="p3">
  55. <span> 应付: </span>
  56. <span class="co-value">¥{{ receivables_money }}</span>
  57. </p>
  58. </div>
  59. <div class="submitBtn">
  60. <button @click="buy(data)">确定订单</button>
  61. </div>
  62. </div>
  63. </template>
  64. <script>
  65. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  66. //例如:import 《组件名称》from ‘《组件路径》';
  67. import { LearnWebSI } from "@/api/api";
  68. export default {
  69. //import引入的组件需要注入到对象中才能使用
  70. components: {},
  71. props: ["data", "changeOrderNumber", "goods_type"],
  72. data() {
  73. //这里存放数据
  74. return {
  75. discount_code: "", //优惠码
  76. discount_money: "0.00", // 优惠金额
  77. receivables_money: this.data.price, // 应收款
  78. loading: false,
  79. codeloading: false,
  80. isShow: true,
  81. };
  82. },
  83. //计算属性 类似于data概念
  84. computed: {},
  85. //监控data中数据变化
  86. watch: {},
  87. //方法集合
  88. methods: {
  89. changediscount_money(value) {
  90. if (value == 0) {
  91. return "-¥" + value + ".00";
  92. }
  93. },
  94. // 根据不同的文件类型展示不同图片
  95. getimgurl(item) {
  96. let index = item.tag.indexOf("downloadable");
  97. let type = "";
  98. if (index != -1) {
  99. type = item.tag[2];
  100. } else {
  101. type = item.tag[1];
  102. }
  103. switch (type) {
  104. case "ppt":
  105. return "ppt";
  106. case "pptx":
  107. return "ppt";
  108. case "pdf":
  109. return "pdf";
  110. case "xlsx":
  111. return "exceil";
  112. case "xls":
  113. return "exceil";
  114. case "doc":
  115. return "word";
  116. case "docx":
  117. return "word";
  118. case "word":
  119. return "word";
  120. default:
  121. return "word";
  122. }
  123. },
  124. // 购买
  125. buy(item) {
  126. this.loading = true;
  127. // 首先添加订单
  128. let Mnam = "order-order_manager-AddMyOrder";
  129. LearnWebSI(Mnam, {
  130. goods_id: item.id, //商品id
  131. goods_type: this.goods_type, //商品类型
  132. goods_name: item.name, //商品名称
  133. goods_picture_id: item.coverFileId, //封面图片id
  134. goods_person_name_desc: this.data.pymentTeacher, //老师
  135. price: item.price, //价格
  136. discount_code: this.back_discount_code,
  137. })
  138. .then((res) => {
  139. this.changeOrderNumber(
  140. res.id,
  141. this.back_discount_code,
  142. this.discount_money,
  143. this.receivables_money
  144. );
  145. this.loading = false;
  146. // 调取支付接口
  147. })
  148. .catch((res) => {
  149. this.loading = false;
  150. });
  151. },
  152. //更改优惠码
  153. changeCode() {
  154. this.isShow = true;
  155. this.receivables_money = this.data.price;
  156. this.discount_money = "0.00";
  157. },
  158. clearData() {
  159. this.discount_code = "";
  160. this.discount_money = "0.00";
  161. this.receivables_money = this.data.price;
  162. },
  163. //验证优惠码
  164. verifyCode() {
  165. if (this.discount_code == "") {
  166. this.$message.warning("请输入优惠码");
  167. return;
  168. }
  169. this.codeloading = true;
  170. let MethodName = "order-order_manager-VerificationDiscountCode";
  171. let resData = JSON.parse(JSON.stringify(this.data));
  172. let data = {
  173. goods_id: resData.goods_id, //商品id
  174. goods_type: resData.goods_type, //商品类型
  175. price: resData.price, //价格
  176. discount_code: this.discount_code.trim(),
  177. };
  178. LearnWebSI(MethodName, data).then((res) => {
  179. this.codeloading = false;
  180. this.isShow = false;
  181. this.back_discount_code = res.discount_code;
  182. this.discount_money = res.discount_money; // 优惠金额
  183. this.receivables_money = res.receivables_money; // 应收款
  184. });
  185. },
  186. },
  187. //生命周期 - 创建完成(可以访问当前this实例)
  188. created() {},
  189. //生命周期 - 挂载完成(可以访问DOM元素)
  190. mounted() {},
  191. //生命周期-创建之前
  192. beforeCreated() {},
  193. //生命周期-挂载之前
  194. beforeMount() {},
  195. //生命周期-更新之前
  196. beforUpdate() {},
  197. //生命周期-更新之后
  198. updated() {},
  199. //生命周期-销毁之前
  200. beforeDestory() {},
  201. //生命周期-销毁完成
  202. destoryed() {},
  203. //如果页面有keep-alive缓存功能,这个函数会触发
  204. activated() {},
  205. };
  206. </script>
  207. <style lang="scss" scoped>
  208. /* @import url(); 引入css类 */
  209. .Nopyment {
  210. .message {
  211. width: 100%;
  212. height: 152px;
  213. background: rgba(70, 70, 70, 0.03);
  214. border-radius: 8px;
  215. display: flex;
  216. img {
  217. width: 120px;
  218. height: 120px;
  219. margin-left: 16px;
  220. margin-top: 16px;
  221. }
  222. .text {
  223. margin-left: 24px;
  224. .p1 {
  225. width: 360px;
  226. // height: 45px;
  227. max-height: 48px;
  228. font-size: 16px;
  229. line-height: 20px;
  230. color: #2c2c2c;
  231. margin-top: 22px;
  232. word-break: break-all;
  233. display: -webkit-box;
  234. -webkit-box-orient: vertical;
  235. -webkit-line-clamp: 2;
  236. text-overflow: ellipsis;
  237. overflow: hidden;
  238. }
  239. .p2 {
  240. margin-top: 10px;
  241. span {
  242. width: 64px;
  243. height: 24px;
  244. background: #ffefd8;
  245. border-radius: 4px;
  246. font-weight: bold;
  247. font-size: 12px;
  248. text-align: center;
  249. color: #ff9900;
  250. line-height: 24px;
  251. padding: 2px 8px;
  252. }
  253. }
  254. .p3 {
  255. margin-top: 10px;
  256. }
  257. }
  258. .price {
  259. p {
  260. margin-left: 67px;
  261. margin-top: 22px;
  262. font-weight: bold;
  263. font-size: 16px;
  264. text-align: right;
  265. color: #ff4c00;
  266. }
  267. }
  268. }
  269. .promotionCode {
  270. display: flex;
  271. justify-content: flex-start;
  272. align-self: center;
  273. width: 100%;
  274. margin-top: 24px;
  275. height: 58px;
  276. line-height: 56px;
  277. border-top: 1px solid rgba(44, 44, 44, 0.15);
  278. border-bottom: 1px solid rgba(44, 44, 44, 0.15);
  279. .sp1 {
  280. font-size: 16px;
  281. color: #000000;
  282. }
  283. input {
  284. padding: 0 24px;
  285. flex: 1;
  286. height: 56px;
  287. outline: none;
  288. border: none;
  289. box-sizing: border-box;
  290. }
  291. .sp2 {
  292. cursor: pointer;
  293. font-size: 16px;
  294. color: #ff9900;
  295. }
  296. }
  297. .total {
  298. width: 656px;
  299. text-align: right;
  300. color: #000000;
  301. font-size: 16px;
  302. padding-top: 24px;
  303. > p {
  304. > span {
  305. display: inline-block;
  306. }
  307. .co-value {
  308. width: 160px;
  309. }
  310. }
  311. .p1 {
  312. > span {
  313. display: inline-block;
  314. line-height: 24px;
  315. }
  316. }
  317. .p2 {
  318. margin: 16px 0 10px;
  319. }
  320. .p3 {
  321. > span {
  322. line-height: 36px;
  323. }
  324. .co-value {
  325. font-size: 24px;
  326. color: #ff4c00;
  327. }
  328. }
  329. }
  330. .submitBtn {
  331. text-align: right;
  332. margin-top: 16px;
  333. button {
  334. width: 120px;
  335. height: 40px;
  336. background: #ff9900;
  337. border-radius: 4px;
  338. color: white;
  339. line-height: 40px;
  340. text-align: center;
  341. border: none;
  342. outline: none;
  343. cursor: pointer;
  344. }
  345. }
  346. }
  347. </style>