123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450 |
- <template>
- <view class="order-content">
- <view class="step">
- <uni-steps :options="[{title: '停车'}, {title: '检查'}, {title: '下单'}]" :active="stepIndex" active-color="rgb(255,0,0)"></uni-steps>
- </view>
- <view class="step-content">
- <!-- 停车 -->
- <view v-if="stepIndex===0" class="step-item step-one">
- <text>请确认车辆是否停到指定位置</text>
- <image src="/static/img/step-one.png" mode="aspectFit"></image>
- </view>
- <!-- 检查 -->
- <view v-if="stepIndex===1" class="step-item step-two">
- <view class="item top">
- <text>-请完成以下操作-</text>
- <image src="/static/img/cztis.png" mode="aspectFit"></image>
- <view class="care">
- 注意:洗车过程中禁止移动车辆和上下车
- </view>
- </view>
- <view class="item bottom">
- <text>超高加装件不能清洗</text>
- <image src="/static/img/zyts.png" mode="aspectFit"></image>
- </view>
- </view>
- <!-- 下单 -->
- <view v-if="stepIndex===2" class="step-item step-three">
- <view class="choose">
- <view class="title">
- 请选择服务模式
- </view>
- <view class="list">
- <view :class="['item', serverIndex==index ?'avtive':'']" @click="chooseItem(index)" v-for="(item,index) in itemList" :key="index">
- <text>{{item.name}}</text>
- <text class="price">¥{{item.price}}</text>
- </view>
- </view>
- </view>
- <view class="choose-content">
- <view class="choose-item">
- <view class="item" @click="intoChooseCoupon">
- <text>优惠卷</text>
- <view class="right">
- <u-icon name="gift" color="rgb(255,0,0)" size="32"></u-icon>
- <text class="coopon">9.8元洗车券(¥-9.8)</text>
- <u-icon name="arrow-right" color="rgb(255,0,0)" size="32"></u-icon>
- </view>
- </view>
- <view class="item phone">
- <text>手机号码</text>
- <view class="right">
- <text >{{userPhone}}</text>
- </view>
- </view>
- </view>
- <view class="read">
- <u-radio-group v-model="isRead">
- <u-radio shape="square" :disabled="isRead!='read'" name="read" active-color="red" icon-size="28" label-size="28">
- 点击阅读并同意
- <text>无人洗车</text>
- <text @click="intoAgreement">《注意事项及服务协议》</text>
- </u-radio>
- </u-radio-group>
- </view>
- </view>
- </view>
- <view class="step-footer">
- <button class="next-button" @click="nextStep" v-if="stepIndex!=2" type="warn">下一步</button>
- <view v-else class="pay">
- <text>合计:</text>
- <text class="amount">¥{{finalAmount}}</text>
- <view class="">
- <button @click="toPay" type="warn">去付款</button>
- </view>
- </view>
- </view>
- </view>
-
- </view>
- </template>
- <script>
- import uniSteps from '@/components/uni-steps/uni-steps.vue'
- import {getUserInfo} from '@/api/login.js'
- export default {
- components: {
- uniSteps
- },
- data() {
- return {
- userPhone: '',
- stepIndex: 0, // 当前步奏下标
- serverIndex: 0, // 选择服务下标
- itemList: [ // 服务列表
- {
- id: 1,
- name: '极速快洗',
- price: 10
- },
- {
- id: 12,
- name: '精致洗',
- price: 20
- },
- {
- id: 13,
- name: '打蜡洗',
- price: 30
- }
- ],
- isRead: '', // 是否同意协议
- couponList: [
- {
- id: 23432445,
- name: "满100减50",
- price: 100,
- yxTime: "2020-05-16",
- remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
- checked: false
- },
- {
- id: 3544355,
- name: "满100减50",
- price: 100,
- yxTime: "2020-05-16",
- remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
- checked: false
- },
- {
- id: 234234234,
- name: "满100减50",
- price: 100,
- yxTime: "2020-05-16",
- remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
- checked: false
- },
- {
- id: 66264646,
- name: "满100减50",
- price: 100,
- yxTime: "2020-05-16",
- remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
- checked: false
- },
- {
- id: 9794694698,
- name: "满100减50",
- price: 100,
- yxTime: "2020-05-16",
- remarks: '优惠卷使用说明优惠卷使用说明优惠卷使用说明',
- checked: false
- }
- ], // 用户可用优惠券
- checkedCoupon: null, // 用户当前所选优惠券
- amount: 0, // 所选服务项目总金额
- couponAmount: 0, // 优惠券优惠金额
- finalAmount: 0, // 用户最终所需支付金额
- }
- },
- onLoad(option) {
- uni.removeStorageSync('stepIndex')
- // 注册全局监听事件
- uni.$once('read', this.read)
- this.getUserPhone()
- },
- onUnload() {
- uni.removeStorageSync('stepIndex')
- },
- onShow() {
- const index = uni.getStorageSync('stepIndex')
- this.stepIndex = index ? index : 0
- console.log(this.stepIndex)
- },
- methods: {
- // 获取用户信息
- getUserPhone () {
- getUserInfo().then(res =>{
- console.log(res,'rrrrrrr')
- if(res.status == 200) {
- this.userPhone = res.data.mobile
- } else {
- uni.showToast({
- title: res.message,
- icon: 'none'
- })
- }
- })
- },
- // 获取服务列表
- getServerList () {
-
- },
- // 选择服务项目
- chooseItem(index) {
- this.serverIndex = index
- this.amount = this.itemList[index].price
- this.getFinalAmount()
- },
- // 下一步
- nextStep() {
- this.stepIndex = this.stepIndex===0 ? 1 : 2
- uni.setStorageSync('stepIndex', this.stepIndex)
- },
- // 已阅读
- read (e) {
- this.isRead = e.msg
- },
- // 获取用户可用优惠券
- getCouponList () {
-
- },
- // 格式化优惠券数据 获取优惠金额最大的优惠券 couponType 优惠券类型:FULLSUB满减/DISCOUNT折扣券/VOUCHER代金券
- formatCouponData (){
- let arr = []
- let _this = this
- this.couponList.map(item => {
- let data = {}
- data.id = item.couponReceivesId
- if (item.couponType == 'DISCOUNT') {
- console.log(_this.amount, '_this.amount')
- data.subAmount = Number((_this.amount * (1 - item.subAmount)).toFixed(2))
- } else {
- data.subAmount = item.couponType == 'FULLSUB' ? item.subAmount : item.price
- }
- arr.push(data)
- })
- console.log(arr, 'arr')
- // 比较数据中优惠金额最大的值 并返回该对象
- let obj = arr.reduce((p, v) => p.subAmount < v.subAmount ? v : p)
- console.log(obj)
- let p = this.couponList.find(item => item.couponReceivesId == obj.id)
- // 订单金额为0时,默认不使用优惠卷
- if (this.amount != 0){
- this.checkedCoupon = p
- this.couponAmount = obj.subAmount > this.amount ? this.amount : obj.subAmount
- } else {
- this.checkedCoupon = null
- this.couponAmount = 0
- }
- // 计算合计
- this.getFinalAmount()
- },
- // 计算合计
- getFinalAmount () {
- let ret = this.amount - this.couponAmount
- this.finalAmount = ret.toFixed(2)
- },
- // 选择优惠券
- intoChooseCoupon () {
- uni.navigateTo({
- url: `/pages/coupon/chooseCoupon/chooseCoupon?list=${encodeURIComponent(JSON.stringify(this.couponList))}`
- })
- },
- // 打开服务协议
- intoAgreement () {
- uni.navigateTo({
- url: '/pages/agreement/agreement'
- })
- },
- // 去付款
- toPay (){
- // 付款成功后开始洗车
- uni.redirectTo({
- url:"/pages/work/index/index"
- })
- }
-
- }
- }
- </script>
- <style lang="scss">
- page{
- height: 100%;
- }
- .order-content{
- width: 100%;
- height: 100%;
- display: flex;
- flex-direction: column;
- .step{
- padding: 40rpx 0;
- }
- .step-content{
- flex: 1;
- width: 100%;
- display: flex;
- flex-direction: column;
- .step-item{
- width: 100%;
- display: flex;
- flex-direction: column;
- align-items: center;
- flex: 1;
- }
- .step-one{
- text{
- color: #999;
- margin: 40rpx 0;
- }
- }
- .step-two{
- background-color: #F8F8F8;
- .item{
- background-color: #fff;
- width: 80%;
- height: 40%;
- display: flex;
- flex-direction: column;
- align-items: center;
- margin-top: 20rpx;
- padding-top: 20rpx;
- image{
- width: 80%;
- flex: 1;
- }
- }
- .top{
- text{
- color: #df928e;
- font-size: 24rpx;
- margin-bottom: 20rpx;
- }
- .care{
- padding: 10rpx 20rpx;
- background-color: #ff805b;
- border-radius: 30rpx;
- color: #fff;
- font-size: 24rpx;
- margin-bottom: 10rpx;
- }
- }
- .bottom{
- text{
- font-size: 24rpx;
- color: #333;
- }
- }
- }
- .step-three{
- .choose{
- width: 100%;
- height: auto;
- padding-bottom: 60rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- border-bottom: 1px solid #eee;
- .title{
- color: #666;
- }
- .list{
- width: 100%;
- display: flex;
- justify-content: space-around;
- padding: 0 20rpx;
- .item{
- width: 30%;
- height: 140rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
- border: 1px solid #eee;
- border-radius: 15rpx;
- margin-top: 30rpx;
- color: #999;
- .price{
- font-size: 34rpx;
- margin-top: 10rpx;
- }
- }
- .avtive{
- color: #333;
- border-color: rgb(255,0,0);
- .price{
- color: rgb(255,0,0);
- }
- }
- }
-
- }
- .choose-content{
- flex: 1;
- width: 100%;
- .choose-item{
- width: 100%;
- .item{
- padding: 0 30rpx;
- }
- }
- .item{
- width: 100%;
- height: 100rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- border-bottom: 1px solid #eee;
- .coopon{
- color: rgb(255,0,0);
- }
- }
- .phone{
- border-bottom: none;
- }
- .read{
- width: 100%;
- border-top: 1px solid #eee;
- padding-top: 40rpx;
- display: flex;
- justify-content: center;
- text{
- color: #999;
- }
- text:last-child{
- color: #ff9ba5;
- }
- }
- }
- }
- .step-footer{
- width: 100%;
- background-color: #fff;
- .next-button{
- margin: 0;
- border-radius: 0;
- padding: 10rpx 0;
- }
- .pay{
- width: 100%;
- height: 100%;
- padding: 10rpx;
- border-top: 1px solid #eee;
- display: flex;
- align-items: center;
- justify-content: flex-end;
- .amount{
- color: rgb(255,0,0);
- font-size: 36rpx;
- margin-right: 40rpx;
- }
- button{
- width: 200rpx;
- }
- }
- }
- }
-
- }
- </style>
|