preview.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <template>
  2. <view class="wrap">
  3. <u-navbar :autoBack="true" title="购买课程" bgColor="rgba(255,255,255,255)" :placeholder="true" titleStyle="font-weight:bold;color:#121212"></u-navbar>
  4. <view class="main" v-if="hasLoad">
  5. <view class="gift-head">商品信息</view>
  6. <view class="gift-list">
  7. <view class="gift-item" v-for="(item, index) in orderData.goods_list" :key="index">
  8. <view class="b-left">
  9. <image :src="item.goods_cover" mode="aspectFill"></image>
  10. </view>
  11. <view class="b-main">
  12. <view class="b-title">{{ item.goods_name }}</view>
  13. <view class="b-spec">
  14. <!-- <view class="s-tit">类型:</view> -->
  15. <view class="s-value">{{ item.goods_type_text }}</view>
  16. </view>
  17. <view class="b-fund">
  18. <view class="s-num">¥{{ item.payment }}</view>
  19. <view class="s-worth">¥{{ item.goods_price }}</view>
  20. </view>
  21. </view>
  22. </view>
  23. </view>
  24. <view class="box">
  25. <view class="b-row f-fund">
  26. <view class="b-tit">商品总价:</view>
  27. <view class="b-cont">
  28. <view class="s-num">¥{{ orderData.total_price }}</view>
  29. </view>
  30. </view>
  31. <view class="b-row f-fund">
  32. <view class="b-tit">优惠金额:</view>
  33. <view class="b-cont">
  34. <view class="s-num">¥{{ orderData.total_discount }}</view>
  35. </view>
  36. </view>
  37. <view class="b-row f-fund">
  38. <view class="b-tit">应付金额:</view>
  39. <view class="b-cont">
  40. <view class="s-num">¥{{ orderData.total_payment }}</view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="box">
  45. <radio-group @change="onRadioChange" v-for="(item, index) in payList" :key="index">
  46. <view class="b-row f-pay">
  47. <view class="b-tit">
  48. <view class="iconfont" :class="'icon-' + item.icon"></view>
  49. <view class="s-tit">{{ item.name }}</view>
  50. </view>
  51. <view class="b-cont">
  52. <radio value="wechat" :checked="item.checked" color="#DA5650" />
  53. </view>
  54. </view>
  55. </radio-group>
  56. </view>
  57. <view class="navbar">
  58. <view class="b-amount">
  59. <view class="s-tit">应付:</view>
  60. <view class="s-num">¥{{ orderData.total_payment }}</view>
  61. </view>
  62. <view class="b-action">
  63. <view class="s-exchange" @click="onSubmitOrder">确认下单</view>
  64. </view>
  65. </view>
  66. </view>
  67. <!-- 加载中 -->
  68. <load-more :loadingType="loadingType" :loadingText="loadingText" :top="300"></load-more>
  69. <!-- 首页 -->
  70. <app-home></app-home>
  71. </view>
  72. </template>
  73. <script>
  74. // import { removeCart, previewOrder, submitOrder, oncePay } from '@/service/api/order.js';
  75. // import { requestPayment } from '@/service/request/main.js';
  76. import mixinsCommon from '@/mixins/common.js';
  77. import mixinsAuth from '@/mixins/auth.js';
  78. let that;
  79. export default {
  80. mixins: [mixinsCommon, mixinsAuth],
  81. data() {
  82. return {
  83. disable: {
  84. submit: false
  85. },
  86. orderData: {},
  87. formData: {
  88. goods_list: [],
  89. total_price: 0,
  90. total_payment: 0
  91. },
  92. payList: [
  93. {
  94. icon: 'pay-wechat',
  95. alias: 'wechat',
  96. name: '微信支付',
  97. checked: true
  98. }
  99. ],
  100. payIndex: 0,
  101. hasLoad: false,
  102. loadingType: 1,
  103. loadingText: ''
  104. };
  105. },
  106. onLoad(options) {
  107. that = this;
  108. let goodsData = options.goods_data;
  109. this.goodsData = JSON.parse(goodsData);
  110. this.loadPreview();
  111. },
  112. methods: {
  113. loadPreview() {
  114. this.$api.previewOrder({ goods_list: this.goodsData }, function (res) {
  115. console.log('加入购物车', res);
  116. if (res.code == 1) {
  117. that.hasLoad = true;
  118. that.loadingType = -1;
  119. that.orderData = res.data;
  120. that.formData.goods_list = res.data.goods_list;
  121. that.formData.total_price = res.data.total_price;
  122. that.formData.total_payment = res.data.total_payment;
  123. } else {
  124. that.loadingType = 3;
  125. that.loadingText = err.data.msg || '加载失败';
  126. }
  127. });
  128. // previewOrder({
  129. // goods_list: this.goodsData
  130. // }).then(([err, res]) => {
  131. // console.log('previewOrder', err, res);
  132. // if (!err) {
  133. // this.hasLoad = true;
  134. // this.loadingType = -1;
  135. // this.orderData = res;
  136. // this.formData.goods_list = res.goods_list;
  137. // this.formData.total_price = res.total_price;
  138. // this.formData.total_payment = res.total_payment;
  139. // } else {
  140. // this.loadingType = 3;
  141. // this.loadingText = err.data.msg || '加载失败';
  142. // }
  143. // });
  144. },
  145. onRadioChange(e) {
  146. console.log('onRadioChange', e);
  147. },
  148. onSubmitOrder() {
  149. if (this.disable.submit) {
  150. return;
  151. }
  152. this.disable.submit = true;
  153. this.$api.submitOrder({}, function () {
  154. console.log('888', res);
  155. that.disable.submit = false;
  156. if (res.code == 1) {
  157. for (let i = 0; i < this.goodsData.length; i++) {
  158. let goodsData = this.goodsData[i];
  159. if (goodsData.cart_id) {
  160. this.$api.removeCart({}, function (res) {
  161. console.log('999', res);
  162. if (res.code == 1) {
  163. this.$store.commit('delCartItem', goodsData.cart_id);
  164. }
  165. });
  166. // removeCart(goodsData.cart_id).then(([err, res]) => {
  167. // if (!err) {
  168. // this.$store.commit('delCartItem', goodsData.cart_id);
  169. // }
  170. // });
  171. }
  172. }
  173. requestPayment(res.order_no, this.payList[this.payIndex].alias, 'onceOrder');
  174. }
  175. });
  176. // submitOrder(this.formData).then(([err, res]) => {
  177. // console.log('submitOrder', err, res);
  178. // this.disable.submit = false;
  179. // if (!err) {
  180. // for (let i = 0; i < this.goodsData.length; i++) {
  181. // let goodsData = this.goodsData[i];
  182. // if (goodsData.cart_id) {
  183. // removeCart(goodsData.cart_id).then(([err, res]) => {
  184. // if (!err) {
  185. // this.$store.commit('delCartItem', goodsData.cart_id);
  186. // }
  187. // });
  188. // }
  189. // }
  190. // requestPayment(res.order_no, this.payList[this.payIndex].alias, 'onceOrder');
  191. // }
  192. // });
  193. }
  194. }
  195. };
  196. </script>
  197. <style>
  198. .wrap {
  199. padding-bottom: 150upx;
  200. }
  201. .gift-head {
  202. padding: 20upx 30upx;
  203. font-size: 28upx;
  204. color: #333;
  205. }
  206. .gift-item {
  207. padding: 30upx;
  208. background: #fff;
  209. border-bottom: 2upx solid #eee;
  210. display: flex;
  211. align-items: center;
  212. }
  213. .gift-item .b-left {
  214. width: 160upx;
  215. height: 160upx;
  216. }
  217. .gift-item .b-left image {
  218. width: 160upx;
  219. height: 160upx;
  220. }
  221. .gift-item .b-main {
  222. margin-left: 30upx;
  223. flex: 1;
  224. display: flex;
  225. flex-direction: column;
  226. }
  227. .gift-item .b-main .b-title {
  228. font-size: 28upx;
  229. color: #333;
  230. }
  231. .gift-item .b-main .b-spec {
  232. margin-top: 20upx;
  233. display: flex;
  234. align-items: center;
  235. }
  236. .gift-item .b-main .b-spec .s-tit {
  237. margin-right: 10upx;
  238. font-size: 24upx;
  239. color: #999;
  240. }
  241. .gift-item .b-main .b-spec .s-value {
  242. font-size: 24upx;
  243. color: #666;
  244. }
  245. .gift-item .b-main .b-fund {
  246. margin-top: 20upx;
  247. display: flex;
  248. align-items: baseline;
  249. }
  250. .gift-item .b-main .b-fund .s-num {
  251. font-size: 32upx;
  252. color: #da5650;
  253. }
  254. .gift-item .b-main .b-fund .s-worth {
  255. margin-left: 20upx;
  256. font-size: 26upx;
  257. color: #999;
  258. text-decoration: line-through;
  259. }
  260. .box {
  261. margin-top: 30upx;
  262. padding: 30upx;
  263. background: #fff;
  264. }
  265. .box .b-row {
  266. margin-bottom: 30upx;
  267. display: flex;
  268. justify-content: space-between;
  269. }
  270. .box .b-row:last-child {
  271. margin-bottom: 0;
  272. }
  273. .box .b-row.f-fund .b-cont .s-num {
  274. font-size: 32upx;
  275. color: #da5650;
  276. }
  277. .box .b-row.f-pay .b-tit {
  278. width: 320upx;
  279. display: flex;
  280. align-items: center;
  281. }
  282. .box .b-row.f-pay .b-tit .iconfont {
  283. font-size: 50upx;
  284. color: #6cb37a;
  285. }
  286. .box .b-row.f-pay .b-tit .s-tit {
  287. margin-left: 10upx;
  288. font-size: 28upx;
  289. }
  290. .box .b-row.f-pay .b-cont radio {
  291. transform: scale(0.8);
  292. }
  293. .box .b-row .b-tit {
  294. font-size: 28upx;
  295. width: 160upx;
  296. }
  297. .box .b-row .b-cont {
  298. display: flex;
  299. align-items: center;
  300. }
  301. .navbar {
  302. position: fixed;
  303. left: 0;
  304. bottom: 0;
  305. width: 100%;
  306. height: 100upx;
  307. background: #fff;
  308. border-top: 1upx solid #f6f6f6;
  309. display: flex;
  310. align-items: center;
  311. justify-content: space-between;
  312. }
  313. .navbar .b-amount {
  314. margin-left: 30upx;
  315. display: flex;
  316. align-items: center;
  317. }
  318. .navbar .b-amount .s-tit {
  319. font-size: 28upx;
  320. color: #333;
  321. }
  322. .navbar .b-amount .s-num {
  323. margin-left: 10upx;
  324. font-size: 32upx;
  325. color: #da5650;
  326. }
  327. .navbar .b-action .s-exchange {
  328. background: #da5650;
  329. height: 100upx;
  330. padding: 0 60upx;
  331. line-height: 100upx;
  332. font-size: 30upx;
  333. color: #fff;
  334. letter-spacing: 4upx;
  335. }
  336. </style>