Browse Source

完成计算优惠券下单

master
邓平艺 4 years ago
parent
commit
6febd2cdbc
  1. 6
      components/lf-payPassword/lf-payPassword.vue
  2. 99
      components/smh-pwd/smh-pwd.vue
  3. 2
      pages/article/details.vue
  4. 2
      pages/business/login/login.vue
  5. 8
      pages/index/index/index.vue
  6. 104
      pages/order/confirm/confirm.vue
  7. 6
      pages/point/shoppingMall/shoppingMall.vue
  8. 2
      pages/shop/goodsdetail.vue
  9. 2
      pages/user/loginType/loginType.vue

6
components/lf-payPassword/lf-payPassword.vue

@ -4,6 +4,7 @@
<view class="title">{{ title }}</view>
<view class="password">
<lf-jp-coded :width="686" @inputVal="inputVal"></lf-jp-coded>
<!-- <smh-pwd :unit="6" :focus="true" :ontime="true" @change="inputVal"></smh-pwd> -->
</view>
<view class="lf-flex lf-m-t-45 lf-row-center" v-if="showCountdown">
<view class="lf-font-24 lf-m-r-10" style="color:#FF9D9D">
@ -28,10 +29,12 @@
<script>
import countdownTime from '@/components/uni-countdown/uni-countdown';
import lfJpCoded from '@/components/lf-jpCoded/lf-jpCoded.vue'
// import smhPwd from '@/components/smh-pwd/smh-pwd.vue';
export default {
components: {
lfJpCoded,
countdownTime
countdownTime,
// smhPwd
},
props: {
title: {
@ -61,6 +64,7 @@
this.$emit('dateFinish');
},
inputVal(event){
console.log("11111", event)
this.code = event;
},
comfirm(){

99
components/smh-pwd/smh-pwd.vue

@ -0,0 +1,99 @@
<template>
<view>
<view class="action">
<view class="pwd" @click="changeStatus">
<view v-for="(item,index) in unit" :class="{pwd1:pwd.length>=(index+1)}" class="number"></view>
</view>
</view>
<view class="input1">
<input :maxlength="unit" @input="change1" v-model="pwd" v-show="true" type="number" :focus="inputStatus" />
</view>
</view>
</template>
<script>
export default {
props:{
unit:{
type:Number,
default:6
},
focus:{
type:Boolean,
default:false
},
ontime:{
type:Boolean,
default:false
}
},
data(){
return {
inputStatus:this.focus,
pwd:"",
pwd1:[]
}
},
methods:{
changeStatus(){
this.inputStatus=!this.inputStatus
},
change1(e){
this.pwd1=String(e.target.value).split('')
if(this.ontime){
this.$emit('change',e.target.value)
}else{
if(this.pwd1.length==this.unit){
this.$emit('change',e.target.value)
}
}
}
}
}
</script>
<style lang="scss" scoped>
.action{
width:690rpx;
margin: 0 auto;
.pwd{
width:100%;
height: 80rpx;
margin: 20rpx auto;
border: 1px solid #e5e5e5;
display: flex;
margin-bottom: 40rpx;
.number{
height: 100%;
display: flex;
justify-content: center;
align-items: center;
flex: 1;
position: relative;
border-right: 1px solid #e5e5e5;
&:last-child{
border: 0;
}
}
.pwd1{
&::after{
position: absolute;
content: "";
width: 20rpx;
height: 20rpx;
border-radius: 50%;
background-color: #000;
}
// &:nth-last-child{
// &::after{
// }
// }
}
}
}
.input1{
width: 0;
height: 0;
overflow: hidden;
}
</style>

2
pages/article/details.vue

@ -9,7 +9,7 @@
</view>
<view class="lf-flex lf-m-b-24">
<view class="lf-font-28" style="color: #2D6361;">
优选线上商城
优选线上商城
</view>
<view class="lf-color-777 lf-font-28 lf-m-l-25">
2021.09.01 16:28:22

2
pages/business/login/login.vue

@ -4,7 +4,7 @@
<view class="head">
<view class="head-content">
<image class="logo"></image>
<view class="title">欢迎来到金优选</view>
<view class="title">欢迎来到金优选</view>
</view>
</view>
<view class="content">

8
pages/index/index/index.vue

@ -80,8 +80,10 @@
<view class="fixed-cart" hover-class="lf-opacity" @click="$url('/pages/store/cart/cart')">
<text class="lf-iconfont icon-gouwulan icon-text"></text>
<text class="tips">购物车</text>
<view class="angle-mark" v-if="car_num<99">{{car_num || 0}}</view>
<view class="angle-mark" v-else>99+</view>
<block v-if="$isRight(car_num)">
<view class="angle-mark" v-if="car_num<99">{{car_num || 0}}</view>
<view class="angle-mark" v-else>99+</view>
</block>
</view>
</view>
<!-- ad广告弹出组件 -->
@ -852,7 +854,7 @@
},
onShareAppMessage(){
return {
title: '欢迎使用金优选小程序!',
title: '欢迎使用金优选小程序!',
path: '/pages/route/index?route=home'
}
}

104
pages/order/confirm/confirm.vue

@ -5,8 +5,8 @@
<view class="card head">
<view class="lf-font-32 lf-color-222">选择收货方式</view>
<view class="capsule">
<view class="item" :class="{'capsule-active': mode == 0}" @click="mode = 0">邮寄</view>
<view class="item" :class="{'capsule-active': mode == 1}" @click="mode = 1">自提</view>
<view class="item" :class="{'capsule-active': mode == 0}" @click="switchMode(0)">邮寄</view>
<view class="item" :class="{'capsule-active': mode == 1}" @click="switchMode(1)">自提</view>
</view>
</view>
<view class="card address" v-if="mode == 0">
@ -28,7 +28,7 @@
</view>
</view>
<view class="card address" v-else>
<view @click="$url('/pages/address/list/list?is_select=1')">
<view>
<text class="lf-font-28 lf-color-primary lf-m-r-10">店铺地址</text>
</view>
<view v-if="address">
@ -56,7 +56,7 @@
<view class="lf-font-26 lf-color-333 lf-line-1">{{ item.item_name }}</view>
<view class="lf-font-24 lf-color-777">{{ item.item_meta.specs_text }}</view>
<view class="lf-row-between" style="line-height: 1;">
<text class="price"><text v-if="goods_type==1">¥</text>{{ item.total_yuan }}<text class="lf-font-24" v-if="goods_type==0">积分</text></text>
<text class="price"><text v-if="goods_type==1">¥</text>{{ unitConversion(item.unit_price) }}<text class="lf-font-24" v-if="goods_type==0">积分</text></text>
<text class="lf-font-28 lf-color-777">x {{ item.quantity }}</text>
</view>
</view>
@ -77,15 +77,15 @@
</view>
<view class="lf-row-between lf-m-t-20">
<view class="lf-font-28 lf-color-777">商品金额</view>
<view class="lf-font-26 lf-color-222"><text v-if="goods_type==1">¥</text>{{ order_detail.order.items_total_yuan }}<text v-if="goods_type==0">积分</text></view>
<view class="lf-font-26 lf-color-222"><text v-if="goods_type==1">¥</text>{{ itemsPrice }}<text v-if="goods_type==0">积分</text></view>
</view>
<view class="lf-row-between lf-m-t-20" v-if="mode == 0">
<view class="lf-font-28 lf-color-777">运费</view>
<view class="lf-font-26" style="color: #F63434;">+¥{{ order_detail.order.payable_freight_yuan }}</view>
<view class="lf-font-26" style="color: #F63434;">+¥{{ order_detail.order.payable_freight_yuan || 0 }}</view>
</view>
<view class="lf-row-between lf-m-t-20">
<view class="lf-font-28 lf-color-777">优惠</view>
<view class="lf-font-26" style="color: #F63434;">-¥{{ order_detail.order.adjustments_total_yuan }}</view>
<view class="lf-font-26" style="color: #F63434;">-¥{{ fullMinus(order_detail.discounts) }}</view>
</view>
</view>
<view class="spread-out"></view>
@ -172,7 +172,9 @@
order_detail: {coupons: []},
show_coupon: false,
coupon_index: null,
goods_type: 1
goods_type: 1,
itemsPrice: 0, // ()
totalPrice: 0 //
}
},
computed: {
@ -187,15 +189,15 @@
}
}
},
totalPrice(){
let order = this.order_detail.order;
if(!this.$isRight(order)){
return 0;
}
if(this.mode){
return order.total_yuan;
}else{
return new Bigc(order.total_yuan).plus(order.payable_freight);
fullMinus(){
return function(arr){
if(this.$isRight(arr)){
let price = arr[0].adjustmentTotal;
let adjustmentTotal = new Bigc(price).div(100);
return Math.abs(adjustmentTotal);
}else{
return 0
}
}
}
},
@ -232,9 +234,54 @@
let detail = res.data.data;
this.order_detail = detail;
this.address = res.data.data.address;
if(this.$isRight(detail.coupons)){
this.coupon_index = 0;
}
this.calcAmount();
uni.hideLoading()
}).catch(err => uni.hideLoading())
},
//
unitConversion(price){
let newPrice = new Bigc(price).div(100);
return Math.abs(newPrice);
},
//
calcAmount(){
let detail = this.order_detail;
let items = detail.order.items;
let itemsPrice = new Bigc(0);
//
items.map(item => {
let price = new Bigc(item.unit_price).div(100);
let itemP = price.times(item.quantity);
itemsPrice = itemsPrice.plus(itemP);
})
this.itemsPrice = itemsPrice;
//
if(this.coupon_index != null){
let coupon = detail.coupons[this.coupon_index];
let adjustmentTotal = new Bigc(coupon.adjustmentTotal).div(100); //
itemsPrice = itemsPrice.plus(adjustmentTotal); //
}
//
if(this.$isRight(detail.discounts)){
let discount = detail.discounts[0];
let adjustmentTotal = new Bigc(discount.adjustmentTotal).div(100); //
itemsPrice = itemsPrice.plus(adjustmentTotal); //
}
//
if(this.mode == 0){
let payable_freight = new Bigc(detail.order.payable_freight).div(100);
itemsPrice = itemsPrice.plus(payable_freight);
}
this.totalPrice = itemsPrice; //
},
//
switchMode(mode){
this.mode = mode;
this.calcAmount();
},
//
getDefaultAddress(){
this.$http.get({
@ -272,15 +319,20 @@
this.$msg('请先添加收货地址!');
return
}
let par = {
order_no: this.order_detail.order.order_no,
pick_self: this.mode, // 0 1
address_id: this.address.id,
note: this.value
}
// TODO id
if(this.coupon_index != null){
par.coupon_id = this.order_detail.coupons[this.coupon_index].id;
}
this.$http.post({
api: 'api/shopping/order/confirm',
data: {
order_no: this.order_detail.order.order_no,
// discount_id: 0, // id? TODO
pick_self: this.mode, // 0 1
address_id: this.address.id,
note: this.value
},
data: par,
header: {
Authorization: this.token
}
@ -289,7 +341,7 @@
if(res.data.code == 200 || res.data.code == true){
let order = res.data.data.order;
let url = '/pages/order/cashier/cashier';
url += '?amount='+ order.total_yuan;
url += '?amount='+ this.totalPrice;
url += '&order_no='+ order.order_no;
this.$url(url, {type: 'redirect'});
}else{
@ -304,6 +356,8 @@
}else{
this.coupon_index = Number(event.detail.value);
}
this.show_coupon = false;
this.calcAmount();
}
}
}

6
pages/point/shoppingMall/shoppingMall.vue

@ -21,8 +21,10 @@
<view class="item" @click="$url('/pages/store/cart/cart')">
<text class="lf-iconfont icon-gouwulan lf-font-50"></text>
<text>购物车</text>
<view class="angle-mark" v-if="car_num<99">{{car_num}}</view>
<view class="angle-mark" v-else>99+</view>
<block v-if="$isRight(car_num)">
<view class="angle-mark" v-if="car_num<99">{{car_num}}</view>
<view class="angle-mark" v-else>99+</view>
</block>
</view>
</view>
</view>

2
pages/shop/goodsdetail.vue

@ -11,6 +11,8 @@
<view>距离结束还剩余</view>
<view v-if="$isRight(seckill)">
<countdown-time
color="#fff"
splitorColor="#fff"
:day="seckill.seckill.end_left_time[0]"
:hour="seckill.seckill.end_left_time[1]"
:minute="seckill.seckill.end_left_time[2]"

2
pages/user/loginType/loginType.vue

@ -4,7 +4,7 @@
<view class="head">
<view class="head-content">
<image class="logo"></image>
<view class="title">欢迎来到金优选</view>
<view class="title">欢迎来到金优选</view>
</view>
</view>
<view class="content">

Loading…
Cancel
Save