Confirmorder.vue 8.0 KB

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