first commit
This commit is contained in:
155
pages/order/index.vue
Normal file
155
pages/order/index.vue
Normal file
@@ -0,0 +1,155 @@
|
||||
<template>
|
||||
<view class="xkl-com-bg">
|
||||
<view style="height: 20rpx;"></view>
|
||||
<u-subsection :list="tabData.list" keyName="name" :current="tabData.current"
|
||||
@change="sectionChange"></u-subsection>
|
||||
<view style="height: 20rpx;"></view>
|
||||
<view v-if="!orderItems.length" style="padding: 30rpx;background-color: #ffffff;border-radius: 10rpx;">
|
||||
<u-empty mode="list"></u-empty>
|
||||
</view>
|
||||
<view v-else>
|
||||
<view
|
||||
style="background-color: #ffffff;color: #666666;padding: 30rpx;font-size: 28rpx; margin-bottom: 20rpx;border-radius: 16rpx;"
|
||||
v-for="(item,index) in orderItems" :key="index" :url="`/pages/goods/detail?id=${item.id}`">
|
||||
<view class="u-flex u-flex-between" style="font-size: 30rpx;">
|
||||
<view>订单号:{{item.order_no}}</view>
|
||||
<u-tag :text="config.pay_type[item.pay_type]" v-if="item.pay_type!=0" :name="config.pay_type[item.pay_type]" plain
|
||||
type="warning"></u-tag>
|
||||
</view>
|
||||
<view style="height: 20rpx;"></view>
|
||||
<view class="u-flex">
|
||||
<u--image width="220rpx" height="220rpx" :src="item.goods.cover[0]" radius="16rpx"></u--image>
|
||||
<view style="padding: 0 20rpx;">
|
||||
<view>{{item.goods.name}}</view>
|
||||
<view style="height: 14rpx;"></view>
|
||||
<view>数量:{{item.num}}</view>
|
||||
<view style="height: 14rpx;"></view>
|
||||
<view>订单金额:<text style="color: #FF1A1A;">¥{{item.pay_money}}</text></view>
|
||||
<view style="height: 14rpx;"></view>
|
||||
<view v-if="item.goods.integral > 0">赠送积分:{{item.goods.integral}}</view>
|
||||
</view>
|
||||
</view>
|
||||
<u-divider></u-divider>
|
||||
<view class="u-flex u-flex-between">
|
||||
<view>{{item.created_at}}</view>
|
||||
<view>
|
||||
<u-tag :text="config.status[item.status]" plain type="success"></u-tag>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<u-loadmore :status="loadStatus" />
|
||||
<view style="height: 500rpx;"></view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
let self;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
tabData: {
|
||||
list: [{
|
||||
name: '待付款',
|
||||
status: 0,
|
||||
}, {
|
||||
name: '待生效',
|
||||
status: 1,
|
||||
}, {
|
||||
name: '已生效',
|
||||
status: 2,
|
||||
}, ],
|
||||
current: 2
|
||||
},
|
||||
orderItems: [],
|
||||
search: {
|
||||
status: 2,
|
||||
page: 1
|
||||
},
|
||||
page: {
|
||||
current: 0,
|
||||
last_page: 1
|
||||
},
|
||||
loadStatus: 'loadmore',
|
||||
config: null
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
onLoad(option) {
|
||||
self = this;
|
||||
if (option && option.status) {
|
||||
self.search.status = 1;
|
||||
}
|
||||
|
||||
self.getOrderItems();
|
||||
|
||||
},
|
||||
onShow() {
|
||||
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
onReachBottom() {
|
||||
if (!self.pageStatus()) {
|
||||
return;
|
||||
}
|
||||
self.loadStatus = 'loading';
|
||||
self.search.page = ++self.search.page;
|
||||
|
||||
self.getOrderItems();
|
||||
},
|
||||
async onPullDownRefresh() {
|
||||
self.search.page = 1;
|
||||
self.orderItems = [];
|
||||
|
||||
await self.getOrderItems();
|
||||
uni.stopPullDownRefresh();
|
||||
},
|
||||
methods: {
|
||||
convertToCustomArray(obj) {
|
||||
const keys = Object.keys(obj);
|
||||
return keys.map(key => ({
|
||||
name: obj[key],
|
||||
status: parseInt(key, 10)
|
||||
}));
|
||||
},
|
||||
sectionChange(index) {
|
||||
self.search.status = self.tabData.list[index].status;
|
||||
self.tabData.current = index;
|
||||
self.orderItems = [];
|
||||
self.getOrderItems();
|
||||
},
|
||||
pageStatus() {
|
||||
self.loadStatus = 'loadmore';
|
||||
if (self.search.page >= self.page.last_page) {
|
||||
self.loadStatus = 'nomore';
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
getOrderItems() {
|
||||
self.$http.post('/shop/v10/order/items', self.search).then(({
|
||||
data,
|
||||
success
|
||||
}) => {
|
||||
if (success) {
|
||||
self.orderItems = self.orderItems.concat(data.items.data);
|
||||
self.config = data.config;
|
||||
self.page.last_page = data.items.last_page;
|
||||
// self.tabData.list = this.convertToCustomArray(data.config.status)
|
||||
self.pageStatus();
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
</style>
|
||||
185
pages/order/pay.vue
Normal file
185
pages/order/pay.vue
Normal file
@@ -0,0 +1,185 @@
|
||||
<template>
|
||||
<view class="xkl-com-bg">
|
||||
<view style="height: 20rpx;"></view>
|
||||
<view style="background-color: #ffffff;border-radius: 10rpx;padding: 30rpx; text-align: center;">
|
||||
<view style="color: #fa3534;">
|
||||
<text style="font-size: 30rpx;">¥</text>
|
||||
<text style="font-size: 36rpx;font-weight: 700;">{{orderItem.pay_money}}</text>
|
||||
</view>
|
||||
<view style="color: #909399;font-size: 28rpx;">支付金额</view>
|
||||
</view>
|
||||
|
||||
<view style="height: 20rpx;"></view>
|
||||
<view style="background-color: #fff; padding: 30rpx;border-radius: 10rpx;">
|
||||
<view style="font-size: 28rpx;#606266">支付方式</view>
|
||||
<view style="height: 20rpx;"></view>
|
||||
<u-radio-group v-model="form.pay_type" iconPlacement="right" :borderBottom="true" placement="column">
|
||||
<u-radio :name="3">
|
||||
<view class="u-flex u-flex-y-center">
|
||||
<u-icon name="/static/icon/money.png" size="50rpx" />
|
||||
<view style="width: 20rpx;"></view>
|
||||
<view>
|
||||
<view style="font-size: 30rpx;">余额支付</view>
|
||||
<view style="font-size: 28rpx;color: #909399;">当前余额:¥{{userinfo.money}}</view>
|
||||
</view>
|
||||
</view>
|
||||
</u-radio>
|
||||
<view style="height: 30rpx;"></view>
|
||||
<!-- <u-radio :name="1">
|
||||
<view class="u-flex u-flex-y-center">
|
||||
<u-icon name="/static/icon/weixin.png" size="50rpx" />
|
||||
<view style="width: 20rpx;"></view>
|
||||
<view>
|
||||
<view style="font-size: 30rpx;">微信支付</view>
|
||||
<view style="font-size: 28rpx;color: #909399;">微信快捷支付</view>
|
||||
</view>
|
||||
</view>
|
||||
</u-radio> -->
|
||||
</u-radio-group>
|
||||
</view>
|
||||
<view style="height: 100rpx;"></view>
|
||||
<u-button type="primary" @click="payOrder()">立即支付</u-button>
|
||||
|
||||
<u-modal :show="paynoticeshow" content='未检测到支付结果, 您可以查看订单' @confirm="tore('/pages/order/index')"
|
||||
@close="paynoticeshow = false" @cancel="paynoticeshow = false" showCancelButton confirmText="查看订单"
|
||||
cancelText="取消" closeOnClickOverlay></u-modal>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
API_URL,
|
||||
STATIC_URL
|
||||
} from '@/env'
|
||||
let self;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
paynoticeshow: false,
|
||||
orderItem: {
|
||||
id: '',
|
||||
pay_money: '',
|
||||
|
||||
},
|
||||
total_price: 0,
|
||||
form: {
|
||||
order_id: '',
|
||||
pay_type: 3,
|
||||
},
|
||||
code: '',
|
||||
userinfo: {
|
||||
money: '',
|
||||
openid: ''
|
||||
},
|
||||
}
|
||||
},
|
||||
mounted() {},
|
||||
onLoad(option) {
|
||||
self = this;
|
||||
if (option && option.order_id) {
|
||||
self.form.order_id = option.order_id;
|
||||
}
|
||||
self.getOrderItem();
|
||||
|
||||
},
|
||||
onShow() {
|
||||
let options = uni.getEnterOptionsSync();
|
||||
const shop_order_pay_show = uni.getStorageSync('shop_order_pay_show');
|
||||
if (options.scene == '1038' &&
|
||||
options.referrerInfo.appId == 'wxef277996acc166c3' && shop_order_pay_show == 1) {
|
||||
uni.setStorageSync('shop_order_pay_show', 0);
|
||||
// 代表从收银台小程序返回
|
||||
let extraData = options.referrerInfo.extraData;
|
||||
if (!extraData) {
|
||||
// "当前通过物理按键返回,未接收到返参,建议自行查询交易结果";
|
||||
self.paynoticeshow = true;
|
||||
} else {
|
||||
if (extraData.code == 'success') {
|
||||
// "支付成功";
|
||||
uni.showToast({
|
||||
title: '支付成功',
|
||||
icon: 'none'
|
||||
});
|
||||
uni.redirectTo({
|
||||
url: `/pages/order/index`
|
||||
});
|
||||
|
||||
} else if (extraData.code == 'cancel') {
|
||||
// "支付已取消";
|
||||
uni.showToast({
|
||||
title: '支付已取消',
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
// "支付失败:" + extraData.errmsg;
|
||||
uni.showToast({
|
||||
title: "支付失败:" + extraData.errmsg,
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
tore(url) {
|
||||
uni.redirectTo({
|
||||
url: url
|
||||
})
|
||||
},
|
||||
getOrderItem() {
|
||||
self.$http.get('/shop/v10/order/item', {
|
||||
order_id: self.form.order_id
|
||||
}).then(({
|
||||
msg,
|
||||
data,
|
||||
success
|
||||
}) => {
|
||||
if (success) {
|
||||
self.orderItem = data.item;
|
||||
self.userinfo.money = data.money;
|
||||
}
|
||||
})
|
||||
},
|
||||
payOrder() {
|
||||
uni.showLoading({
|
||||
title: '',
|
||||
mask: true
|
||||
});
|
||||
self.$http.post('/shop/v10/order/pay', self.form).then(({
|
||||
data,
|
||||
success,
|
||||
msg
|
||||
}) => {
|
||||
uni.hideLoading();
|
||||
if (!success) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: msg
|
||||
})
|
||||
return;
|
||||
}
|
||||
if (self.form.pay_type == 3) {
|
||||
uni.redirectTo({
|
||||
url: `/pages/order/index`
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
uni.openEmbeddedMiniProgram({
|
||||
appId: data.appid,
|
||||
extraData: data.extraData,
|
||||
success(res) {
|
||||
// 打开成功
|
||||
uni.setStorageSync('shop_order_pay_show', 1);
|
||||
}
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
</style>
|
||||
166
pages/order/pre.vue
Normal file
166
pages/order/pre.vue
Normal file
@@ -0,0 +1,166 @@
|
||||
<template>
|
||||
<view>
|
||||
<view class="xkl-com-bg">
|
||||
<view style="height: 20rpx;"></view>
|
||||
<view class="u-flex"
|
||||
style="background-color: #ffffff;padding: 20rpx;border-radius: 10rpx;font-size: 30rpx;">
|
||||
<u--image width="220rpx" height="220rpx" :src="goodsItem.cover[0]" radius="16rpx"></u--image>
|
||||
<view style="padding: 20rpx;">
|
||||
<view style="color: #232323;">{{goodsItem.name}}</view>
|
||||
<view style="height: 20rpx;"></view>
|
||||
<view>
|
||||
<text>单价:</text>
|
||||
<text style="color: crimson;">
|
||||
{{goodsItem.current_price}}元
|
||||
</text>
|
||||
</view>
|
||||
<view style="height: 20rpx;"></view>
|
||||
<view>
|
||||
<text>总价:</text>
|
||||
<text style="color: crimson;">
|
||||
{{total_price}}元
|
||||
</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view style="height: 20rpx;"></view>
|
||||
<view class="u-flex u-flex-between u-flex-y-center "
|
||||
style="background-color: #ffffff;padding: 20rpx;border-radius: 10rpx;font-size: 30rpx;">
|
||||
<view class="u-flex">
|
||||
<view>购买数量</view>
|
||||
<view style="width: 10rpx;"></view>
|
||||
<text v-if="level.id" style="color: #dd6161;">可升级v{{level.level}}</text>
|
||||
</view>
|
||||
<view><u-number-box v-model="form.num" inputWidth="100rpx" @change="changenum"></u-number-box></view>
|
||||
</view>
|
||||
<view style="height: 20rpx;"></view>
|
||||
<view style="background-color: #ffffff;padding: 20rpx;border-radius: 10rpx;font-size: 30rpx;">
|
||||
<view style="font-weight: 700;">购买须知:</view>
|
||||
<view style="height: 20rpx;"></view>
|
||||
<view style="color: #dd6161;">付款成功后立即生效,并投入生产安装,不支持退款、退货。</view>
|
||||
<view style="height: 20rpx;"></view>
|
||||
</view>
|
||||
<view style="height: 100rpx;"></view>
|
||||
<u-button type="primary" @click="createOrder()">确认订单</u-button>
|
||||
</view>
|
||||
<view style="height: 50rpx;"></view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
API_URL,
|
||||
STATIC_URL
|
||||
} from '@/env'
|
||||
let self;
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
goodsItem: {
|
||||
id: '',
|
||||
cover: [],
|
||||
name: '',
|
||||
original_price: '',
|
||||
current_price: '',
|
||||
pre_price: '',
|
||||
integral: '',
|
||||
sales: '',
|
||||
stock: '',
|
||||
note: ''
|
||||
},
|
||||
total_price: 0,
|
||||
form: {
|
||||
goods_id: '',
|
||||
num: 1,
|
||||
pay_type: 0,
|
||||
},
|
||||
level: {
|
||||
id: '',
|
||||
level: ''
|
||||
},
|
||||
policy: {
|
||||
is_trusteeship: 0,
|
||||
is_buy: 0
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {},
|
||||
onLoad(option) {
|
||||
self = this;
|
||||
if (option && option.num) {
|
||||
self.form.num = option.num;
|
||||
}
|
||||
|
||||
if (option && option.id) {
|
||||
self.form.goods_id = option.id;
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
self.getGoodsItem();
|
||||
self.changenum({
|
||||
value: self.form.num
|
||||
});
|
||||
self.policy = self.$store.state.policy;
|
||||
},
|
||||
methods: {
|
||||
|
||||
changenum(e) {
|
||||
self.form.num = e.value;
|
||||
self.$http.get('/shop/v10/order/pre', self.form).then(({
|
||||
data
|
||||
}) => {
|
||||
self.total_price = data.total_price;
|
||||
self.userinfo = data.userinfo;
|
||||
if (data.level) {
|
||||
self.level = data.level;
|
||||
} else {
|
||||
self.level = {
|
||||
id: '',
|
||||
name: ''
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
},
|
||||
getGoodsItem() {
|
||||
self.$http.get('/shop/v10/goods/item', {
|
||||
id: self.form.goods_id
|
||||
}).then(({
|
||||
data,
|
||||
success
|
||||
}) => {
|
||||
if (success) {
|
||||
self.goodsItem = data;
|
||||
self.form.goods_id = data.id;
|
||||
self.total_price = data.current_price;
|
||||
}
|
||||
})
|
||||
},
|
||||
createOrder() {
|
||||
self.$http.post('/shop/v10/order/create', self.form).then(({
|
||||
data,
|
||||
success,
|
||||
msg
|
||||
}) => {
|
||||
if (!success) {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: msg
|
||||
})
|
||||
return;
|
||||
}
|
||||
|
||||
uni.navigateTo({
|
||||
url: '/pages/order/pay?order_id=' + data.order_id
|
||||
})
|
||||
})
|
||||
},
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user