balance.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. <style>
  2. .m-app{width:100vw}
  3. /* 头部 */
  4. .app-header{width:100%;background: #ffffff;}
  5. .mp-padding{width:100%;height:50px;}
  6. button.back-btn{width:22px;height:32px;}
  7. button.back-btn image{width:22px;height:22px;}
  8. .mp-title{color:#333333;font-size: 16px;font-weight: 700;text-align: center;width:100%;height:50px;line-height: 50px;position: relative;}
  9. .mp-title button.back-btn{position: absolute;left:12px;top:9px}
  10. /* 滚动内容区域 */
  11. scroll-view.mid-body{margin-top:8px;width:100%;height:calc(100vh - 8px - 60px);}
  12. /* 用户地址 */
  13. .order-user{background: #ffffff;padding:15px;width:calc(100% - 30px);position: relative;}
  14. .pay-add{padding:20px 15px;background-color:#fff;display:flex;align-items:center;border-top:1px #f5f5f5 solid}
  15. .pa-left{width:34px;height:34px;margin-right:10px}
  16. .pa-left image{width:100%;height:100%;display:block}
  17. .pa-right{width:22px;height:22px;margin-left:auto}
  18. .pa-right image{width:100%;height:100%;display:block}
  19. .pa-middle{width:75%}
  20. .pam-top{display:flex;align-items:center}
  21. .pamt-left{color:#484747;font-size:14px}
  22. .pamt-right{color:#7E7E7E;font-size:13px;margin-left:10px}
  23. .pam-bot{color:#484747;font-size:12px;margin-top:5px;line-height:20px}
  24. .pay-goods{background:#fff;display:flex;align-items:center}
  25. .pg-left{width:90px;height:90px;margin-right:15px}
  26. .pg-left image{width:100%;height:100%;display:block;border-radius:10px}
  27. .pg-right{width:68%}
  28. .pgr-top{width:100%;color:#484747;font-size:14px;font-weight:500;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}
  29. .pgr-middle{margin-top:5px}
  30. .pgrm-vip{width:auto;height:20px;background-color:#F1F1F1;text-align:center;line-height:20px;color:#019560;font-size:10px;border-radius:4px;display:inline-block;margin-right:5px;padding:0px 10px}
  31. .pgrm-gui{color:#7E7E7E;font-size:10px}
  32. .pgr-bot{display:flex;align-items:center;margin-top:5px}
  33. .pgrb-left{display:flex;align-items:baseline}
  34. .pgrbl-left{color:#fd3b39;font-size:18px;font-weight:500}
  35. .pgrbl-right{color:#7E7E7E;font-size:10px;text-decoration:line-through;margin-left:5px}
  36. .pgrb-right{margin-left:auto;color:#7E7E7E;font-size:10px}
  37. .pay-btn{position:fixed;height:60px;bottom:0;left:0;right:0;display:flex;align-items:center;justify-content:flex-end;background-color:#fff}
  38. .bp-right{width:140px;height:40px;text-align:center;line-height:40px;color:#fff;background:#fd3b39;border-radius:100px;font-size:16px;margin:0 15px 0 20px}
  39. .bp-left{color:#7E7E7E;font-size:16px}
  40. .bp-left text:last-child{color:#fd3b39;font-weight:500}
  41. .pay-type{margin-top:10px;background-color:#fff}
  42. .pt{padding:0 15px;height:50px;display:flex;align-items:center;margin:auto;color:#3F3E3E;border-bottom:1px #f5f5f5 solid}
  43. .pt-left{display:flex;align-items:center;font-size:14px}
  44. .pt-left image{width:28px;height:28px;margin-right:10px;border-radius:4px}
  45. .pt-right{margin-left:auto}
  46. .pt-right image{width:24px;height:24px}
  47. .sku-name{font-size: 12px;}
  48. /* 订单信息 */
  49. .order-msg{width:calc(100% - 15px);background: #ffffff;margin-top: 8px;padding-left: 15px;}
  50. .order-msg-item{border-bottom:1px solid #EEEEEE;width:calc(100% - 15px);padding-right: 15px;}
  51. .order-msg-item:last-child{border-bottom:0px}
  52. .order-msg-title{font-size: 14px;color:#333333;width:calc(100% - 80px);}
  53. .order-msg-v{width:80px;height:44px;}
  54. .order-msg-jifen{ height: 44px; color: #7C7BFE; font-size: 14px;}
  55. .order-msg-v text{width:100%;text-align: right;font-size: 14px;color:#333333;}
  56. .order-msg-v .check{width: 20px;height: 20px;}
  57. button.msg-btn{width:16px;height:44px;}
  58. button.msg-btn image{width:16px;height:16px;display: block;}
  59. .app-footer{position: absolute;bottom:0px;left:0px;padding:0px 15px;width:calc(100% - 30px);height:50px;background: #ffffff;}
  60. button.sub-btn{height:36px;line-height: 36px;text-align: center;width:100px;text-align: center; border-radius: 18px;font-size: 14px;font-weight: 700; color:#ffffff;background:#fd3b39;}
  61. button.sub-btn.not-btn{background: #7E7E7E;}
  62. .footer-info{width:calc(100% - 100px);text-align: left;}
  63. .footer-title{font-size: 14px;color:#333333;}
  64. .footer-price{font-size: 18px;color:#ffab2b;font-weight: 700;}
  65. .dk-total{margin-left: 10px;font-size: 12px;color: #fd3b39;}
  66. </style>
  67. <template>
  68. <view class="m-app">
  69. <form report-submit="true" @submit="formSubmit">
  70. <view class="app-header">
  71. <view class="top-bar" :style="'height:' + barHeight + 'px'"></view>
  72. <view class="mp-padding fx-r fx-bc">
  73. <view class="mp-title">
  74. <button class="nt back-btn fx-r fx-bc fx-ac" @click="tapBack">
  75. <image src="/static/img/arrow_next.png"></image>
  76. </button>
  77. <text>确认订单</text>
  78. </view>
  79. </view>
  80. </view>
  81. <scroll-view class="mid-body" scroll-y="true" @scrolltolower="loadMoreData">
  82. <view class="pay-add" @tap="tapAddress" v-if="data.address != null">
  83. <view class="pa-left">
  84. <image src="/static/img/ck-addresss.png"></image>
  85. </view>
  86. <view class="pa-middle" >
  87. <view class="pam-top">
  88. <view class="pamt-left">
  89. <text>{{data.address.name}}</text>
  90. </view>
  91. <view class="pamt-right">
  92. <text>{{data.address.tel}}</text>
  93. </view>
  94. </view>
  95. <view class="pam-bot">
  96. <text>{{data.address.address}}</text>
  97. </view>
  98. </view>
  99. <view class="pa-right">
  100. <image src="/static/img/ic_next.png"></image>
  101. </view>
  102. </view>
  103. <view class="pay-add" @tap="tapAddress" v-if="data.address == null">
  104. <view class="pa-left">
  105. <image src="/static/img/ck-addresss.png"></image>
  106. </view>
  107. <view class="pa-middle">
  108. <view class="pam-xuan">
  109. <text>请选择您的收货地址!</text>
  110. </view>
  111. </view>
  112. <view class="pa-right">
  113. <image src="/static/img/ic_next.png"></image>
  114. </view>
  115. </view>
  116. <view style="padding: 15px;background: #fff;margin-top: 10px;" v-for="(item,index) in data.info">
  117. <view class="pay-goods">
  118. <view class="pg-left">
  119. <image :src="item.img" mode="aspectFill"></image>
  120. </view>
  121. <view class="pg-right">
  122. <view>
  123. <view class="pgr-top">
  124. <text>{{item.title}}</text>
  125. </view>
  126. <view class="sku-name" style="color: #7E7E7E;">
  127. <text>{{item.sku_text}}</text>
  128. </view>
  129. </view>
  130. <view class="pgr-bot">
  131. <view class="pgrb-left">
  132. <view class="pgrbl-left">¥{{item.promotion}}</view>
  133. <view class="pgrbl-right">¥{{item.old_price}}</view>
  134. </view>
  135. <view class="pgrb-right">x{{item.count}}</view>
  136. </view>
  137. </view>
  138. </view>
  139. </view>
  140. <view class="order-msg">
  141. <view class="order-msg-item fx-r fx-bc">
  142. <view class='order-msg-title'>邮费</view>
  143. <view class='order-msg-v fx-r fx-bc fx-ae'>
  144. <text>¥{{utils.returnFloat(data.postage)}}</text>
  145. </view>
  146. </view>
  147. <view class="order-msg-item fx-r fx-bc" v-if="data.balance_money > 0">
  148. <view class="order-msg-title">提货积分
  149. <text style="color: #fd3b39;font-weight: bold;">({{ data.balance_money }})</text>
  150. </view>
  151. <view class="order-msg-v fx-r fx-bc fx-ae" @tap="tapBalanceItem">
  152. <image class="check" src="/static/img/rcheck-btn.png" v-if="isBalance" mode="widthFix"></image>
  153. <image class="check" src="/static/img/rcheck.png" v-else mode="widthFix"></image>
  154. </view>
  155. </view>
  156. <view class="order-msg-item fx-r fx-bc">
  157. <view class='order-msg-title'>总订单金额</view>
  158. <view class='order-msg-v fx-r fx-bc fx-ae'>
  159. <text>¥{{utils.returnFloat(allPrice)}}</text>
  160. </view>
  161. </view>
  162. </view>
  163. <view style="height:50px"></view>
  164. </scroll-view>
  165. <view class="app-footer fx-r fx-bc fx-ae">
  166. <view class="footer-info fx-r fx-bc">
  167. <text class="footer-title">合计:</text>
  168. <text class="footer-price">¥{{utils.returnFloat(allPrice)}}</text>
  169. <view class="dk-total" v-if="isBalance">
  170. 提货积分<text>{{ data.allMoney > data.balance_money ? data.balance_money : data.allMoney }}</text>
  171. </view>
  172. </view>
  173. <button class="nt sub-btn" :class=" !isBalance || data.balance_money < data.allMoney ? 'not-btn' : '' " formType="submit">提交订单</button>
  174. </view>
  175. </form>
  176. <ui-pay ref="uipay"></ui-pay>
  177. </view>
  178. </template>
  179. <style>
  180. .pop-bank{ position: fixed; width: 100%;height: 100vh;top: 0;left: 0;background: rgba(0,0,0,0.2);}
  181. .pop-bank .pop-body{width: 90%;background: #fff;border-radius: 8px;height: 60vh;}
  182. .pop-bank .pop-top{height: 40px;border-bottom: 1px solid #F1F1F1; position: relative;}
  183. .pop-bank .pop-top{ text-align: center; line-height: 40px;font-size: 18px;}
  184. .pop-bank .pop-left{position: absolute;font-size: 14px;color: #007AFF;left: 10px;top: 0px;}
  185. .pop-bank .pop-top .close image{width: 20px;height: 20px; position: absolute; right: 10px;top: 10px;}
  186. .pop-bank scroll-view{height: calc(60vh - 100px);}
  187. .pop-bank .pop-bank-list{ border-bottom: 1px solid #F1F1F1; padding: 20px;}
  188. .pop-bank .pop-bank-list:hover{background: #F1F1F1;}
  189. .pop-bank .pop-bank-list image{width: 20px;height: 20px;}
  190. .pop-bank .pop-bank-list text{ margin-left: 10px;}
  191. .pop-bank .pop-bank-add{ height: 60px;text-align: center;line-height: 60px;font-size: 18px;}
  192. .view-btn{height: 40px;border-top: 1px solid #F1F1F1;line-height: 40px;text-align: center;color: #007AFF;}
  193. .pop-xiyi{ position: fixed; width: 100%;height: 100vh;top: 0;left: 0;background: rgba(0,0,0,0.2);}
  194. .pop-body{width: 90%;background: #fff;border-radius: 8px;height: 80vh;}
  195. .pop-body .foot{height: 40px;border-top: 1px solid #F1F1F1;}
  196. .pop-body .pop-scrolly{height: calc(100% - 40px);}
  197. .pop-body .foot .hr{width: 1px;height: 40px;background: #F1F1F1;}
  198. .pop-body .foot .btn1{background: #f28d20;border-radius: 0px 0px 0 8px;color: #fff;}
  199. .pop-body .foot .btn2{background: #f1f1f1;color: #333;border-radius: 0px 0px 8px 0 ;}
  200. .pv-igv{height: 100%;color: #00c1c2;font-size: 12px;text-align: left;margin-top: 6px;}
  201. </style>
  202. <script>
  203. import {mapState,mapMutations } from 'vuex'
  204. var addressId = 0;
  205. import uParse from '@/components/gaoyia-parse/parse.vue';
  206. import uiPay from '@/components/ui-pay/index.vue';
  207. export default {
  208. components: {
  209. uParse,
  210. uiPay
  211. },
  212. computed: mapState(['user','sysData']),
  213. data() {
  214. return {
  215. subData:[],
  216. data:{info:[],allMoney:0,heMoney:0,postage:0,voucher:[]},
  217. allPrice : 0,
  218. payType:"unionpay",
  219. isBalance: true,
  220. box:false,
  221. barHeight:0
  222. }
  223. },
  224. /**
  225. * 购物车
  226. */
  227. onLoad(options) {
  228. var that = this;
  229. //获取提交参数
  230. if(!this.utils.isDefine(options.data)){
  231. this.tapBack();
  232. return;
  233. }
  234. if(this.sysData.bank == 1) {
  235. this.payType = 'unionpay';
  236. }
  237. if(this.sysData.wxpay == 1) {
  238. this.payType = 'wxpay';
  239. }
  240. if(this.sysData.ailpay == 1) {
  241. this.payType = 'ailpay';
  242. }
  243. this.barHeight = this.$device.statusBarHeight;
  244. try{
  245. this.subData = JSON.parse(options.data);
  246. uni.$on('selectAddress',function(data){
  247. addressId = data.addressId;
  248. that.initView();
  249. });
  250. }catch(e){
  251. uni.showModal({title: '系统提示',content:'数据异常',showCancel: false});
  252. }
  253. uni.$on('bankInit',()=>{
  254. this.tapPayBank();
  255. });
  256. },
  257. onShow(){
  258. this.initView();
  259. },
  260. /**
  261. * 页面卸载
  262. */
  263. onUnload:function(){
  264. uni.$off('selectAddress',()=>{});
  265. uni.$off('bankInit',()=>{});
  266. if(this.$refs['uipay'] != null) this.$refs.uipay.hide();
  267. },
  268. methods: {
  269. ...mapMutations(['checkUserLogin','payPayment']),
  270. /**
  271. * 数据
  272. */
  273. initView:function(){
  274. this.getData();
  275. },
  276. /**
  277. * 获取当前数据
  278. */
  279. getData:function(){
  280. var that = this,postData = {};
  281. postData.subData = JSON.stringify(this.subData);
  282. postData.token = this.user.token;
  283. postData.addressId = addressId;
  284. this.utils.loadIng("获取数据中..");
  285. this
  286. .request
  287. .post("getBalance",postData)
  288. .then(res=>{
  289. uni.hideLoading();
  290. if(res.code == 200) {
  291. if(res.data.address == '') {
  292. res.data.address = null;
  293. } else {
  294. addressId = res.data.address.id;
  295. }
  296. for(var i in res.data.info) {
  297. res.data.info[i].o_select = false;
  298. }
  299. that.data = res.data;
  300. that.AllCount();
  301. } else{
  302. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  303. }
  304. })
  305. .catch(err=>{
  306. console.log(err);
  307. uni.hideLoading();
  308. that.utils.showModal("加载失败,重新点击尝试!",function(){
  309. that.initView();
  310. });
  311. });
  312. },
  313. /**
  314. * 选择地址
  315. */
  316. tapAddress:function(){
  317. uni.navigateTo({url: "/pages/user/address/address?type=select"});
  318. },
  319. /**
  320. * 是否足够金额支付
  321. */
  322. tapBalanceItem:function(){
  323. this.isBalance = !this.isBalance;
  324. this.AllCount();
  325. },
  326. /**
  327. * 全部金额
  328. */
  329. AllCount:function(){
  330. var price = 0;
  331. //人民币支付
  332. for(var i in this.data.info) {
  333. var d = this.data.info[i];
  334. var vmoney = parseInt(this.data.info[i].count) * parseFloat(this.data.info[i].promotion);
  335. price += vmoney;
  336. }
  337. price += parseFloat(this.data.postage);
  338. this.allPrice = price;
  339. this.data.allMoney = price;
  340. if(this.isBalance) {
  341. if(price > this.data.balance_money) {
  342. this.allPrice = price - parseFloat(this.data.balance_money);
  343. } else {
  344. this.allPrice = 0 ;
  345. }
  346. }
  347. },
  348. closeBox:function(){
  349. this.box = false;
  350. },
  351. /**
  352. * 支付确认
  353. */
  354. tapCheckPay: function() {
  355. this.submitPost(0);
  356. },
  357. formSubmit: function(e) {
  358. this.submitPost(0);
  359. },
  360. /**
  361. * 提交数据
  362. */
  363. submitPost:function(type){
  364. if(addressId ==''){
  365. return this.utils.Tip("请选择地址");
  366. }
  367. if(!this.isBalance) {
  368. return this.utils.Tip("请选择提货积分抵扣");
  369. }
  370. if(this.data.balance_money < this.data.allMoney) {
  371. return this.utils.Tip("积分不足,无法抵扣!");
  372. }
  373. var that = this,postData = {};
  374. postData.subData = JSON.stringify(this.subData);
  375. postData.addressId = addressId;
  376. postData.isBalance = this.isBalance ? 1 : 0;
  377. postData.deviceType = this.$deviceType;
  378. postData.payType = this.payType;
  379. this.utils.loadIng("获取数据中..");
  380. this
  381. .request
  382. .post("addOrder",postData)
  383. .then(res=>{
  384. if(res.code == 200) {
  385. if(res.data.status == 1) {
  386. uni.hideLoading();
  387. uni.redirectTo({
  388. url: '/pages/user/buy/order_ok?orderId=' + res.data.order_id + "&but_type=" + this.payType
  389. });
  390. } else {
  391. this.payPayment({
  392. page : this,
  393. payType : this.payType,
  394. orderId : res.data.order_id,
  395. buyType : res.data.buy_type,
  396. bankId : this.bankId,
  397. isClose : 1,//是否关闭本页
  398. afterFn : ()=>{
  399. uni.hideLoading();
  400. }
  401. });
  402. }
  403. } else {
  404. uni.hideLoading();
  405. uni.showModal({title: '系统提示',content: res.msg,showCancel: false});
  406. }
  407. })
  408. .catch(err=>{
  409. uni.hideLoading();
  410. this.utils.showModal("加载失败,重新点击尝试!",function(){
  411. that.initView();
  412. });
  413. });
  414. },
  415. //下拉触底
  416. loadMoreData: function(e) {
  417. console.log(e)
  418. },
  419. /**
  420. * 选择select
  421. * @param {Object} type
  422. */
  423. payTypeSelect:function(type){
  424. this.payType = type
  425. },
  426. tapBack: function() {
  427. uni.navigateBack();
  428. }
  429. }
  430. }
  431. </script>