Confirmorder.vue 9.7 KB

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