Confirmorder.vue 9.7 KB

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