mujinxia 9 months ago
commit 635878cb11
  1. 16
      pages/cart/index.vue
  2. 693
      pages/sureOrder/index.vue
  3. 6
      pages/user/index.vue

@ -43,17 +43,8 @@
<text class="value">{{ item.goods.skuInfo.goods_price }}</text> <text class="value">{{ item.goods.skuInfo.goods_price }}</text>
</view> </view>
<view class="stepper"> <view class="stepper">
<u-number-box :min="1" class='countNumber' :modelValue="item.goods_num" :step="1" <u-number-box :min="1" class='countNumber' :modelValue="item.goods_num" :step="1" @change="onChangeStepper($event, item)" />
@change="onChangeStepper($event, item)" />
<!-- <view class="del">
-
</view>
<view class="allNum">
{{item.goods_num}}
</view>
<view class="add">
+
</view> -->
</view> </view>
</view> </view>
</view> </view>
@ -599,12 +590,14 @@
} }
.stepper { .stepper {
flex: 1;
display: flex; display: flex;
// width: 154rpx; // width: 154rpx;
height: 56rpx; height: 56rpx;
background: #FFFFFF; background: #FFFFFF;
border-radius: 76rpx 76rpx 76rpx 76rpx; border-radius: 76rpx 76rpx 76rpx 76rpx;
opacity: 1; opacity: 1;
margin-right: 20rpx;
// border: 2rpx solid #E6E6E6; // border: 2rpx solid #E6E6E6;
.del { .del {
@ -689,6 +682,7 @@
padding-right: 30rpx; padding-right: 30rpx;
.goods-price { .goods-price {
flex: 1;
vertical-align: bottom; vertical-align: bottom;
color: $main-bg; color: $main-bg;

@ -1,28 +1,30 @@
<template> <template>
<view class="sureOrder"> <view class="sureOrder">
<view> <view>
<u-navbar title="确认订单" :border-bottom="false" title-color="#333" <u-navbar title="确认订单" :border-bottom="false" title-color="#333" :background="background"></u-navbar>
:background="background"></u-navbar>
</view> </view>
<view class="buyType"> <view class="buyType">
<view class="toDoor" @click="choseType('sm')" <view class="toDoor" :class="buyType=='sm'?'':'toDoor-dis'" @click="choseType('sm')">
:style="{'background':buyType=='sm'?'#fff':'rgba(255, 255, 255, 0.57)','height':buyType=='zq'?'88rpx':'78rpx'}">
送货上门 送货上门
</view> </view>
<view class="bySelf" @click="choseType('zq')" <view class="toDoor" :class="buyType=='zq'?'':'toDoor-dis'" @click="choseType('zq')">
:style="{'background':buyType=='zq'?'#fff':'rgba(255, 255, 255, 0.57)','height':buyType=='zq'?'88rpx':'78rpx'}">
到店自取 到店自取
</view> </view>
<view class="toDoor-on" :style="{'left': buyType=='sm'?'0':'345rpx'}">{{buyType=='zq'?'到店自取':'送货上门'}}</view>
</view> </view>
<view class="address" v-if="buyType!='sm'"> <view class="getSelf" >
<view class="addAddress"> <view class="address" v-if="buyType=='sm'">
请点击添加收货地址 <view class="addAddress">
</view> <view class="tip" v-if="true">请点击添加收货地址</view>
<view class="leftImg"> <view class="info" v-else>
<image src="/static/order/left.png" mode=""></image> <view class="name"></view>
<view class="detail"></view>
</view>
</view>
<view class="leftImg">
<image :src="$picUrl+'/static/order/left.png'"></image>
</view>
</view> </view>
</view>
<view class="getSelf">
<view class="shopAddress" v-if="buyType=='zq'"> <view class="shopAddress" v-if="buyType=='zq'">
<view class="youTime"> <view class="youTime">
花梨服务站 花梨服务站
@ -33,7 +35,7 @@
</view> </view>
</view> </view>
<view class="addressDetail"> <view class="addressDetail">
{{addressInfo.name}} {{addressInfo.region.province +addressInfo.region.city+addressInfo.region.region}}
</view> </view>
<view class="lookMap" v-if="buyType=='zq'"> <view class="lookMap" v-if="buyType=='zq'">
<image src="/static/user/address.png" mode="" class="addressIcon"></image> <image src="/static/user/address.png" mode="" class="addressIcon"></image>
@ -51,7 +53,7 @@
取件人 取件人
</view> </view>
<view class="name"> <view class="name">
{{addressInfo.name}}
</view> </view>
</view> </view>
<view class="pickPeople"> <view class="pickPeople">
@ -67,7 +69,7 @@
预留电话 预留电话
</view> </view>
<view class="name"> <view class="name">
{{addressInfo.phone}}
</view> </view>
</view> </view>
<view class="pickPeople"> <view class="pickPeople">
@ -94,7 +96,7 @@
<switch /> <switch />
</view> </view>
</view> </view>
<!-- <view class="time"> <view class="time">
<view class="youTime"> <view class="youTime">
预计到货时间 预计到货时间
</view> </view>
@ -103,8 +105,8 @@
<image src="/static/order/left.png" mode=""></image> <image src="/static/order/left.png" mode=""></image>
</view> </view>
</view> --> </view>
<!-- <view class="time"> <view class="time">
<view class="youTime"> <view class="youTime">
您期待的收货时间 您期待的收货时间
</view> </view>
@ -112,7 +114,7 @@
请选择 请选择
<image src="/static/order/left.png" mode=""></image> <image src="/static/order/left.png" mode=""></image>
</view> </view>
</view> --> </view>
<view class="goodsDetail"> <view class="goodsDetail">
<view class="goodsType"> <view class="goodsType">
<image src="/static/order/bag.png" mode="" class="bag"></image> <image src="/static/order/bag.png" mode="" class="bag"></image>
@ -235,242 +237,352 @@
</template> </template>
<script> <script>
import * as order from '@/api/checkout.js' import * as Verify from '@/utils/verify'
// import img from "@/static/member/head.png" import * as CheckoutApi from '@/api/checkout'
import * as storeShop from '@/api/shop.js' import * as SharpCheckoutApi from '@/api/sharp/checkout'
import * as address from '@/api/address.js' import * as BargainCheckoutApi from '@/api/bargain/checkout'
import * as cashier from '@/api/cashier/index.js' import * as GrouponCheckoutApi from '@/api/groupon/checkout'
import * as CouponApi from '@/api/coupon' import { CouponTypeEnum } from '@/common/enum/coupon'
import { import { OrderTypeEnum, DeliveryTypeEnum } from '@/common/enum/order'
Wechat
} from '@/core/payment' const CouponColors = ['red', 'blue', 'violet', 'yellow']
// modeapi
const getCheckoutApi = (mode) => {
const apiEnum = {
buyNow: CheckoutApi,
cart: CheckoutApi,
bargain: BargainCheckoutApi,
sharp: SharpCheckoutApi,
groupon: GrouponCheckoutApi
}
return apiEnum[mode]
}
// modeparam
const getModeParam = (mode, options) => {
const param = {}
// :
if (mode === 'buyNow') {
param.goodsId = options.goodsId
param.goodsNum = options.goodsNum
param.goodsSkuId = options.goodsSkuId
}
// :
if (mode === 'cart') {
param.cartIds = options.cartIds
}
// :
if (mode === 'bargain') {
param.taskId = options.taskId
param.goodsSkuId = options.goodsSkuId
}
// :
if (mode === 'sharp') {
param.activeTimeId = options.activeTimeId
param.sharpGoodsId = options.sharpGoodsId
param.goodsSkuId = options.goodsSkuId
param.goodsNum = options.goodsNum
}
// :
if (mode === 'groupon') {
param.grouponGoodsId = options.grouponGoodsId
param.taskId = options.taskId
param.goodsSkuId = options.goodsSkuId
param.goodsNum = options.goodsNum
param.stepPeople = options.stepPeople
}
return param
}
export default { export default {
data() { data() {
return { return {
remark: '', //
payType: 'weChat', OrderTypeEnum,
buyType: 'sm', DeliveryTypeEnum,
background: { CouponTypeEnum,
background: 'url(https://www.royaum.com.cn/static/member/head.png) center top no-repeat', //
backgroundSize: '100% auto', options: {},
}, //
goodsInfo: {}, isShowTab: false,
shopInfo: {}, DeliveryTypeEnum,
addressList: [], curDelivery: null,
addressInfo: {}, //
payMethList: [], selectedShopId: 0, // ID
orderID: '', linkman: '', //
couponList: [], phone: '', //
} //
}, CouponColors,
onLoad(options) { //
console.log(options, 'kkkkkk') selectCouponId: 0,
// if (options.goodsInfo) { // 使
let goodsInfo = options.goodsID; isUsePoints: false,
console.log(goodsInfo, '5555555', typeof(goodsInfo)); //
this.goodsInfo = JSON.parse(decodeURIComponent(goodsInfo)) remark: '',
console.log(this.goodsInfo, '666666'); // submit
// } disabled: false,
}, //
onShow() { showPoints: false,
this.getShopInfo() //
this.getAddressList(); showPopup: false,
this.orderSubmit() // (api)
this.getCoupon() order: {
//
}, goodsList: [],
methods: { //
getCoupon() { couponList: [],
const that =this //
let param = { existAddress: false,
dataType:'isUsable' //
} address: null,
CouponApi.myCouponList(param) //
.then(res => { existAddress: false,
that.couponList = res.data.list.data //
}) isIntraRegion: true,
.finally() //
}, hasError: false,
choseCoupon() { //
// errorMsg: '',
uni.navigateTo({ },
url: '/pages/news/coupon/list?chose=true', //
}) personal: {},
}, //
chosePayType(item) { setting: {}
this.payType = item.method }
}, },
choseType(val) {
this.buyType = val /**
}, * 生命周期函数--监听页面加载
getDefaultAddress() { */
const that = this onLoad(options) {
return new Promise((resolve, reject) => { this.options = options;
address.defaultId().then(res => { console.log(options)
if (res.status == 200) { // :
for (var i = 0; i < that.addressList.length; i++) { uni.$on('syncSelectedId', selectedId => {
if (res.data.defaultId == that.addressList[i].address_id) { this.selectedShopId = selectedId
that.addressInfo = that.addressList[i] })
console.log(that.addressInfo, '获取收货地址') },
}
} /**
} * 生命周期函数--监听页面的卸载
}) */
.catch() onUnload() {
}) // :
}, uni.$off('syncSelectedId')
getAddressList() { },
const that = this
return new Promise((resolve, reject) => { /**
address.list().then(res => { * 生命周期函数--监听页面显示
if (res.status == 200) { */
that.addressList = res.data.list onShow() {
that.getDefaultAddress() //
} this.getOrderData()
}) },
.catch()
}) methods: {
},
getShopInfo() { //
return new Promise((resolve, reject) => { getOrderData() {
storeShop.list().then(res => { const app = this
console.log(res, '获取店铺信息') const { options: { mode } } = app
}) //
.catch() const params = app.getRequestParam()
}) // api
getCheckoutApi(mode)
}, .order(mode, params)
orderSubmit() { .then(result => app.initData(result.data))
const that = this; .catch(err => err)
console.log(that.goodsInfo, '55555') },
let params = {
mode: 'buyNow', //
delivery: '10', initData({ order, setting, personal }) {
couponId: '', const app = this
isUsePoints: 0, app.order = order
remark: that.remark, app.personal = personal
shopId: '', app.setting = setting
linkman: '', //
phone: '', if (order.hasError) {
goodsId: that.goodsInfo.goods_id, app.showToast(order.errorMsg, 3000)
goodsNum: 1, }
goodsSkuId: that.goodsInfo.skuList[0].goods_sku_id, //
cartIds: '' app.curDelivery = order.delivery
} //
order.submit('buyNow', params) app.isShowTab = setting.deliveryType.length > 1
.then(res => { //
if (res.status == 200) { if (app.linkman === '') {
that.orderId = res.data.orderId app.linkman = order.lastExtract.linkman
that.getOrderInfoPay(res.data.orderId) }
} if (app.phone === '') {
}) app.phone = order.lastExtract.phone
.catch() }
}, },
getOrderInfoPay(val) {
cashier.orderInfo(val).then(res => { // api
if (res.status == 200) { getRequestParam() {
this.payMethList = res.data.paymentMethods const app = this
} const { options } = app
}) //
.catch() const modeParam = getModeParam(options.mode, options)
}, // ()
onShowSuccess(res) { const orderParam = {
this.$toast(message || '订单支付成功') delivery: app.curDelivery || 0,
uni.navigateTo({ shopId: app.selectedShopId || 0,
url: '/pages/news/recycling/orderList' couponId: app.selectCouponId || 0,
}) isUsePoints: app.isUsePoints ? 1 : 0,
}, }
orderPay() { return { ...orderParam, ...modeParam }
const that = this },
if (that.payType == 'balance') {
that.payBanlance() //
return handleSwichDelivery(key) {
} this.curDelivery = key
cashier.orderPay(that.orderId).then(res => { this.getOrderData()
if (res.status == 200) { },
let paymentData = res.data.payment //
Wechat.payment({ handleShowPoints() {
orderKey: res.data.payment.out_trade_no, this.showPoints = true
...paymentData },
})
.then((result) => { //
console.log(result) handleShowPopup() {
that.onShowSuccess(result) this.showPopup = true
}) },
.catch(err => {
console.log(err) //
}) handleSelectCoupon(index) {
const app = this
const { couponList } = app.order
} //
}) const couponItem = couponList[index]
.catch() //
if (!couponItem.is_apply) {
}, app.showToast(couponItem.not_apply_info)
payBanlance() { return
const that = this }
let params = { // id
extra: {}, app.selectCouponId = couponItem.user_coupon_id
method: 'balance', //
client: 'weChat' app.getOrderData()
} //
cashier.orderPay(that.orderID, params).then(res => { app.showPopup = false
that.$toast(res.message) },
if (res.status == 200) {
// 使
setTimeout(() => { handleNotUseCoupon() {
uni.navigateTo({ const app = this
url: '/pages/news/recycling/orderList' app.selectCouponId = 0
}) //
}, 1000) app.getOrderData()
//
} app.showPopup = false
}) },
.catch()
//
}, onSelectAddress() {
// getOrderInfo() { this.$navTo('pages/address/index', { from: 'checkout' })
// const that = this },
// let params = {
// orderId: 10202, //
// client: 'wechat' onSelectExtractPoint() {
// } this.$navTo('pages/shop/extract', { selectedId: this.selectedShopId })
// cashier.orderInfo(params) },
// .then(res => {
// if (res.status == 200) { //
// that.payOrderInfo() onTargetGoods(goodsId) {
// } this.$navTo('pages/goods/detail', { goodsId })
// }) },
// .catch()
// }, //
payOrderInfo() { onSubmitOrder() {
const that = this const app = this
let form = { if (app.disabled) {
client: 'wechat', return false
method: 'wechat', }
extra: {} //
} if (!app.onVerifyFrom()) {
cashier.orderInfo(10202, form) return false
.then(res => { }
if (res.status == 200) { //
app.disabled = true
let paymentData = res.data.payment // api
Wechat.payment({ getCheckoutApi(app.options.mode)
orderKey: res.data.payment.out_trade_no, .submit(app.options.mode, app.getFormData())
...paymentData .then(result => {
}) // :
.then((result) => { const orderId = result.data.orderId
console.log(result) setTimeout(() => {
}) this.$navTo('pages/checkout/cashier/index', { orderId }, 'redirectTo')
.catch(err => { }, 100)
console.log(err) })
}) .catch(res => app.showToast(res.errMsg, 3000))
} .finally(() => setTimeout(() => app.disabled = false, 800))
}) },
.catch()
}, // (1)
}, navToMyOrder() {
setTimeout(() => {
this.$navTo('pages/order/index', {}, 'redirectTo')
}, 1000)
},
//
getFormData() {
const app = this
const { options } = app
//
const form = {
delivery: app.curDelivery,
couponId: app.selectCouponId || 0,
shopId: app.selectedShopId || 0,
linkman: app.linkman,
phone: app.phone,
isUsePoints: app.isUsePoints ? 1 : 0,
remark: app.remark || '',
}
//
const modeParam = getModeParam(options.mode, options)
return { ...form, ...modeParam }
},
//
onVerifyFrom() {
const app = this
if (app.hasError) {
app.showToast(app.errorMsg, 3000)
return false
}
//
if (app.curDelivery == DeliveryTypeEnum.EXTRACT.value) {
app.linkman = app.linkman.trim()
app.phone = app.phone.trim()
if (app.selectedShopId <= 0) {
app.showToast('请选择自提的门店')
return false
}
if (Verify.isEmpty(app.linkman)) {
app.showToast('请填写自提联系人')
return false
}
if (Verify.isEmpty(app.phone)) {
app.showToast('请填写自提联系电话')
return false
}
if (!Verify.isPhone(app.phone)) {
app.showToast('请输入正确的联系电话')
return false
}
}
return true
},
// toast
showToast(title, duration = 2000) {
this.$refs.uToast.show({ title, duration })
}
}
} }
</script> </script>
@ -479,43 +591,51 @@
width: 750rpx; width: 750rpx;
min-height: 750rpx; min-height: 750rpx;
padding-bottom: 120rpx; padding-bottom: 120rpx;
background: url('https://www.royaum.com.cn/static/member/head.png') center top no-repeat; background: url('https://www.royaum.com.cn/static/news/login-bg.png') center top no-repeat;
background-size: 100% auto; background-size: 100% auto;
} }
.buyType { .buyType {
display: flex; width: 700rpx;
margin: 70rpx 0 0 26rpx; margin: 30rpx auto 0;
position: relative;
height: 88rpx;
.toDoor { .toDoor {
width: 348rpx; width: 50%;
height: 88rpx; height: 74rpx;
background-color: #fff; background-color: rgba(255, 255, 255, 0.5);
font-size: 28rpx; font-size: 28rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 500; font-weight: 500;
color: #000000;
line-height: 88rpx;
text-align: center;
}
.bySelf {
width: 350rpx;
height: 74rpx;
background-color: rgba(255, 255, 255, 0.570000);
line-height: 74rpx;
text-align: center;
font-size: 24rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #606060; color: #606060;
line-height: 74rpx; line-height: 74rpx;
position: relative; text-align: center;
top: 14rpx; float: left;
margin-top: 14rpx;
float: left;
&-on{
width: 350rpx;
height: 88rpx;
background-color: #FFF;
text-align: center;
font-size: 34rpx;
font-weight: 400;
color: #000;
line-height: 88rpx;
position: absolute;
bottom: 0;
left: 0;
z-index: 2;
border-radius: 10rpx 10rpx 0 0;
}
&-dis{
border-radius: 10rpx 10rpx 0 0;
}
} }
} }
.getSelf { .getSelf {
width: 700rpx;
margin: 0 auto;
.shopAddress { .shopAddress {
display: flex; display: flex;
align-items: center; align-items: center;
@ -541,14 +661,11 @@
} }
} }
} }
background-image: url('https://www.royaum.com.cn/static/order/map.png');
margin-left: 26rpx; background-size: 100%;
background-image: url('../../static/order/map.png'); height: 160rpx;
background-size: 100% 100%; padding: 14rpx 46rpx 0 32rpx;
width: 694rpx; box-sizing: border-box;
height: 246rpx;
padding:14rpx 46rpx 0 32rpx;
.addressDetail { .addressDetail {
height: 34rpx; height: 34rpx;
font-size: 24rpx; font-size: 24rpx;

@ -60,7 +60,7 @@
</view> </view>
</view> </view>
</view> </view>
<view class="newplus" v-if="isLogin == false || userInfo.user_type==20"> <view class="newplus" v-if="isLogin == false || userInfo.user_type == 10">
<view class="memVip" @click="goMember('hy')"> <view class="memVip" @click="goMember('hy')">
<!-- <view class="vipLine"> <!-- <view class="vipLine">
<image :src="$picUrl+'/static/user/vip.png'" class="vipIcon"></image> <image :src="$picUrl+'/static/user/vip.png'" class="vipIcon"></image>
@ -148,12 +148,12 @@
{{actionCountsInfo.take_goods_number?actionCountsInfo.take_goods_number:0}} {{actionCountsInfo.take_goods_number?actionCountsInfo.take_goods_number:0}}
</view> </view>
<view class="info"> <view class="info">
{{isLogin==false || userInfo.user_type <= 20?'发货记录':'提货记录'}} 提货记录
</view> </view>
</view> </view>
<view class="listItem" @click="goJump('/pages/news/coupon/list')"> <view class="listItem" @click="goJump('/pages/news/coupon/list')">
<view class="num"> <view class="num">
{{actionCountsInfo.view_number?actionCountsInfo.view_number:0}} {{actionCountsInfo.coupon_number?actionCountsInfo.coupon_number:0}}
</view> </view>
<view class="info"> <view class="info">
优惠券 优惠券

Loading…
Cancel
Save