Confirmorder.vue 8.5 KB

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