上传代码
This commit is contained in:
173
uniapp04/unpackage/dist/dev/mp-weixin/pages/order/order.js
vendored
Normal file
173
uniapp04/unpackage/dist/dev/mp-weixin/pages/order/order.js
vendored
Normal file
@ -0,0 +1,173 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const common_assets = require("../../common/assets.js");
|
||||
const API_api = require("../../API/api.js");
|
||||
if (!Array) {
|
||||
const _easycom_uni_swipe_action_item2 = common_vendor.resolveComponent("uni-swipe-action-item");
|
||||
const _easycom_uni_swipe_action2 = common_vendor.resolveComponent("uni-swipe-action");
|
||||
(_easycom_uni_swipe_action_item2 + _easycom_uni_swipe_action2)();
|
||||
}
|
||||
const _easycom_uni_swipe_action_item = () => "../../uni_modules/uni-swipe-action/components/uni-swipe-action-item/uni-swipe-action-item.js";
|
||||
const _easycom_uni_swipe_action = () => "../../uni_modules/uni-swipe-action/components/uni-swipe-action/uni-swipe-action.js";
|
||||
if (!Math) {
|
||||
(_easycom_uni_swipe_action_item + _easycom_uni_swipe_action + recommend)();
|
||||
}
|
||||
const recommend = () => "../recommend/recommend.js";
|
||||
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
|
||||
__name: "order",
|
||||
setup(__props) {
|
||||
common_vendor.ref(1);
|
||||
const incrementQuantity = (index) => {
|
||||
if (cartItems.value[index].quantity < 9) {
|
||||
cartItems.value[index].quantity++;
|
||||
}
|
||||
};
|
||||
const decrementQuantity = (index) => {
|
||||
if (cartItems.value[index].quantity > 1) {
|
||||
cartItems.value[index].quantity--;
|
||||
}
|
||||
};
|
||||
const cartItems = common_vendor.ref(common_vendor.index.getStorageSync("cartItems"));
|
||||
console.log("购物车order页面");
|
||||
console.log(cartItems.value);
|
||||
const deleteCard = (itemId) => {
|
||||
common_vendor.index.getStorage({
|
||||
key: "cartItems",
|
||||
success: function(res) {
|
||||
let cartItems2 = res.data;
|
||||
console.log("原始购物车数据:", cartItems2);
|
||||
console.log("尝试删除的 itemId:", itemId.id);
|
||||
const updatedCartItems = cartItems2.filter((item) => item.id !== itemId.id);
|
||||
console.log("更新后的购物车数据:", updatedCartItems);
|
||||
common_vendor.index.setStorage({
|
||||
key: "cartItems",
|
||||
data: updatedCartItems,
|
||||
success: function() {
|
||||
console.log("删除成功");
|
||||
common_vendor.index.reLaunch({ url: "/pages/order/order" });
|
||||
},
|
||||
fail: function(err) {
|
||||
console.log("删除失败:" + err);
|
||||
}
|
||||
});
|
||||
},
|
||||
fail: function(err) {
|
||||
console.log("获取购物车数据失败:" + err);
|
||||
}
|
||||
});
|
||||
};
|
||||
const totalAmount = common_vendor.computed(() => {
|
||||
return cartItems.value.reduce((total, item) => {
|
||||
return total + item.dishesPrice * item.quantity;
|
||||
}, 0);
|
||||
});
|
||||
const account = () => {
|
||||
let businessid = common_vendor.index.getStorageSync("businessItem") || "1830063677349658625";
|
||||
const orderDetails = cartItems.value.map((item) => ({
|
||||
attributeNames: "小份",
|
||||
// 假设每个商品都有一个属性名
|
||||
dishesId: item.id,
|
||||
quantity: item.quantity
|
||||
}));
|
||||
const data = {
|
||||
businessId: String(businessid),
|
||||
notes: "不要花生",
|
||||
orderDetailAddRequest: orderDetails,
|
||||
payMethod: 0,
|
||||
phone: "15946398466",
|
||||
pickupMethod: 0,
|
||||
pickupTime: "",
|
||||
totalPrice: totalAmount.value,
|
||||
userName: "沙箱账号"
|
||||
};
|
||||
data.businessId = String(data.businessId);
|
||||
common_vendor.index.request({
|
||||
url: API_api.apiImageUrl + "/api/orders/add",
|
||||
method: "POST",
|
||||
data,
|
||||
header: {
|
||||
"cookie": common_vendor.index.getStorageSync("cookie") || ""
|
||||
},
|
||||
success(res) {
|
||||
console.log(data);
|
||||
console.log("Success:", res.data.data);
|
||||
const orderId = res.data.data;
|
||||
createPayment(orderId);
|
||||
},
|
||||
fail() {
|
||||
console.error("Error:", "请求失败");
|
||||
}
|
||||
});
|
||||
};
|
||||
const createPayment = (orderId) => {
|
||||
console.log("Total amount to pay:", totalAmount.value);
|
||||
my.request({
|
||||
url: API_api.apiImageUrl + "/api/Alipay/payment/create",
|
||||
method: "GET",
|
||||
data: {
|
||||
id: orderId
|
||||
},
|
||||
header: {
|
||||
"Content-Type": "application/json",
|
||||
// 确保设置正确的 Content-Type
|
||||
"cookie": common_vendor.index.getStorageSync("cookie") || ""
|
||||
},
|
||||
success: function(result) {
|
||||
console.log(result);
|
||||
console.log(result.data.data);
|
||||
common_vendor.index.setStorageSync("tradeNo", result.data.data);
|
||||
my.tradePay({
|
||||
tradeNO: result.data.data,
|
||||
success: (res) => {
|
||||
console.log("成功调用");
|
||||
console.log(res);
|
||||
console.log(res.resultCode);
|
||||
if (res.resultCode == 6001) {
|
||||
console.log("我是6001");
|
||||
common_vendor.index.setStorageSync("notPay", orderId);
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/goToPay/goToPay"
|
||||
});
|
||||
} else if (res.resultCode == 9e3) {
|
||||
common_vendor.index.setStorageSync("orderId", orderId);
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/testFive/testFive"
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (res) => {
|
||||
my.alert({
|
||||
content: JSON.stringify(res)
|
||||
});
|
||||
console.log("失败");
|
||||
console.log(res);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
return (_ctx, _cache) => {
|
||||
return common_vendor.e({
|
||||
a: common_vendor.f(cartItems.value, (item, index, i0) => {
|
||||
return {
|
||||
a: item.dishesImage,
|
||||
b: common_vendor.t(item.dishesName),
|
||||
c: common_vendor.t(item.dishesPrice),
|
||||
d: common_vendor.o(($event) => decrementQuantity(index), index),
|
||||
e: common_vendor.t(item.quantity),
|
||||
f: common_vendor.o(($event) => incrementQuantity(index), index),
|
||||
g: common_vendor.o(($event) => deleteCard(item), index),
|
||||
h: index,
|
||||
i: "03a9cc6c-1-" + i0 + ",03a9cc6c-0"
|
||||
};
|
||||
}),
|
||||
b: common_assets._imports_0$1,
|
||||
c: `/pages/goods/goods?id=1435025`
|
||||
}, {
|
||||
e: common_vendor.t(totalAmount.value),
|
||||
f: common_vendor.o(account)
|
||||
});
|
||||
};
|
||||
}
|
||||
});
|
||||
wx.createPage(_sfc_main);
|
8
uniapp04/unpackage/dist/dev/mp-weixin/pages/order/order.json
vendored
Normal file
8
uniapp04/unpackage/dist/dev/mp-weixin/pages/order/order.json
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"navigationBarTitleText": "订单",
|
||||
"usingComponents": {
|
||||
"uni-swipe-action-item": "../../uni_modules/uni-swipe-action/components/uni-swipe-action-item/uni-swipe-action-item",
|
||||
"uni-swipe-action": "../../uni_modules/uni-swipe-action/components/uni-swipe-action/uni-swipe-action",
|
||||
"recommend": "../recommend/recommend"
|
||||
}
|
||||
}
|
1
uniapp04/unpackage/dist/dev/mp-weixin/pages/order/order.wxml
vendored
Normal file
1
uniapp04/unpackage/dist/dev/mp-weixin/pages/order/order.wxml
vendored
Normal file
@ -0,0 +1 @@
|
||||
<scroll-view scroll-y class="scroll-view"><block wx:if="{{true}}"><view wx:if="{{true}}" class="cart-list"><uni-swipe-action u-s="{{['d']}}" u-i="03a9cc6c-0" bind:__l="__l"><uni-swipe-action-item wx:for="{{a}}" wx:for-item="item" wx:key="h" u-s="{{['right','d']}}" class="cart-swipe" u-i="{{item.i}}" bind:__l="__l"><view class="goods"><image class="checkbox" src="{{b}}"/><navigator url="{{c}}" hover-class="none" class="navigator"><image mode="aspectFill" class="picture" src="{{item.a}}"></image><view class="meta"><view class="name ellipsis">{{item.b}}</view><view class="attrsText ellipsis">大碗加麻加辣</view><view class="price">¥{{item.c}}</view></view></navigator><view class="count"><view class="jia" bindtap="{{item.d}}">-</view><text class="quantity-value">{{item.e}}</text><view class="jian" bindtap="{{item.f}}">+</view></view></view><view class="cart-swipe-right" slot="right"><button class="button delete-button" bindtap="{{item.g}}">删除</button></view></uni-swipe-action-item></uni-swipe-action></view><view wx:else class="cart-blank"><image src="{{d}}" class="image"/><text class="text">购物车还是空的,快来挑选好货吧</text><navigator open-type="switchTab" url="/pages/index/index" hover-class="none"><button class="button">去首页看看</button></navigator></view><view class="toolbar"><text class="iconfont">全选</text><text class="text">合计:</text><text class="amount">¥{{e}}</text><view class="button-grounp"><view class="{{['button', 'payment-button', 'disabled']}}" bindtap="{{f}}"> 去结算 </view></view></view></block><view wx:else class="login-blank"><text class="text">登录后可查看购物车中的商品</text><navigator url="/pages/login/login" hover-class="none"><button class="button">去登录</button></navigator></view><view class="priceTitle"><view class="meta"><text class="symbol">热门推荐</text></view></view><recommend u-i="03a9cc6c-2" bind:__l="__l"></recommend><view class="toolbar-height"></view></scroll-view>
|
274
uniapp04/unpackage/dist/dev/mp-weixin/pages/order/order.wxss
vendored
Normal file
274
uniapp04/unpackage/dist/dev/mp-weixin/pages/order/order.wxss
vendored
Normal file
@ -0,0 +1,274 @@
|
||||
/**
|
||||
* 这里是uni-app内置的常用样式变量
|
||||
*
|
||||
* uni-app 官方扩展插件及插件市场(https://ext.dcloud.net.cn)上很多三方插件均使用了这些样式变量
|
||||
* 如果你是插件开发者,建议你使用scss预处理,并在插件代码中直接使用这些变量(无需 import 这个文件),方便用户通过搭积木的方式开发整体风格一致的App
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* 如果你是App开发者(插件使用者),你可以通过修改这些变量来定制自己的插件主题,实现自定义主题功能
|
||||
*
|
||||
* 如果你的项目同样使用了scss预处理,你也可以直接在你的 scss 代码中使用如下变量,同时无需 import 这个文件
|
||||
*/
|
||||
/* 颜色变量 */
|
||||
/* 行为相关颜色 */
|
||||
/* 文字基本颜色 */
|
||||
/* 背景颜色 */
|
||||
/* 边框颜色 */
|
||||
/* 尺寸变量 */
|
||||
/* 文字尺寸 */
|
||||
/* 图片尺寸 */
|
||||
/* Border Radius */
|
||||
/* 水平间距 */
|
||||
/* 垂直间距 */
|
||||
/* 透明度 */
|
||||
/* 文章场景相关 */
|
||||
@font-face {
|
||||
font-family: "iconfont";
|
||||
src: url("//at.alicdn.com/t/c/font_4635288_3w0kb9g7rgt.woff2?t=1722085167498") format("woff2"), url("//at.alicdn.com/t/c/font_4635288_3w0kb9g7rgt.woff?t=1722085167498") format("woff"), url("//at.alicdn.com/t/c/font_4635288_3w0kb9g7rgt.ttf?t=1722085167498") format("truetype");
|
||||
}
|
||||
:host {
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
background-color: #f7f7f8;
|
||||
}
|
||||
.scroll-view {
|
||||
flex: 1;
|
||||
}
|
||||
.cart-list {
|
||||
margin: 0 auto;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
.cart-list .goods {
|
||||
display: flex;
|
||||
padding: 20rpx 2.2rem 20rpx 1.2rem;
|
||||
border-radius: 10rpx;
|
||||
background-color: #fff;
|
||||
position: relative;
|
||||
}
|
||||
.cart-list .goods .navigator {
|
||||
display: flex;
|
||||
}
|
||||
.cart-list .goods .checkbox {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 60rpx;
|
||||
height: 60rpx;
|
||||
margin-top: 0.6rem;
|
||||
}
|
||||
.cart-list .goods .checkbox::before {
|
||||
font-family: "erabbit" !important;
|
||||
font-size: 40rpx;
|
||||
color: #444;
|
||||
}
|
||||
.cart-list .goods .checkbox.checked::before {
|
||||
color: #4095e5;
|
||||
}
|
||||
.cart-list .goods .picture {
|
||||
width: 170rpx;
|
||||
height: 170rpx;
|
||||
}
|
||||
.cart-list .goods .meta {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
.cart-list .goods .name {
|
||||
height: 72rpx;
|
||||
font-size: 26rpx;
|
||||
color: #444;
|
||||
}
|
||||
.cart-list .goods .attrsText {
|
||||
line-height: 1.8;
|
||||
padding: 0 15rpx;
|
||||
font-size: 24rpx;
|
||||
align-self: flex-start;
|
||||
border-radius: 4rpx;
|
||||
color: #888;
|
||||
background-color: #f7f7f8;
|
||||
}
|
||||
.cart-list .goods .price {
|
||||
line-height: 1;
|
||||
font-size: 26rpx;
|
||||
color: #444;
|
||||
margin-bottom: 2rpx;
|
||||
color: #cf4444;
|
||||
}
|
||||
.cart-list .goods .price::before {
|
||||
content: "¥";
|
||||
font-size: 80%;
|
||||
}
|
||||
.cart-list .goods .count {
|
||||
position: absolute;
|
||||
bottom: 20rpx;
|
||||
right: 5rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
width: 220rpx;
|
||||
height: 48rpx;
|
||||
}
|
||||
.cart-list .goods .count .text {
|
||||
height: 100%;
|
||||
padding: 0 20rpx;
|
||||
font-size: 32rpx;
|
||||
color: #444;
|
||||
}
|
||||
.cart-list .goods .count .input {
|
||||
height: 100%;
|
||||
text-align: center;
|
||||
border-radius: 4rpx;
|
||||
font-size: 24rpx;
|
||||
color: #444;
|
||||
background-color: #f6f6f6;
|
||||
}
|
||||
.cart-list .cart-swipe {
|
||||
display: block;
|
||||
margin: 20rpx 0;
|
||||
}
|
||||
.cart-list .cart-swipe-right {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
}
|
||||
.cart-list .cart-swipe-right .button {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
line-height: 1.5;
|
||||
color: #fff;
|
||||
font-size: 26rpx;
|
||||
border-radius: 0;
|
||||
}
|
||||
.cart-list .cart-swipe-right .delete-button {
|
||||
background-color: #cf4444;
|
||||
}
|
||||
.cart-blank,
|
||||
.login-blank {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
height: 60vh;
|
||||
}
|
||||
.cart-blank .image,
|
||||
.login-blank .image {
|
||||
width: 400rpx;
|
||||
height: 281rpx;
|
||||
}
|
||||
.cart-blank .text,
|
||||
.login-blank .text {
|
||||
color: #444;
|
||||
font-size: 26rpx;
|
||||
margin: 20rpx 0;
|
||||
}
|
||||
.cart-blank .button,
|
||||
.login-blank .button {
|
||||
width: 240rpx !important;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
margin-top: 20rpx;
|
||||
font-size: 26rpx;
|
||||
border-radius: 60rpx;
|
||||
color: #fff;
|
||||
background-color: #4095e5;
|
||||
}
|
||||
.toolbar {
|
||||
position: fixed;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: var(--window-bottom);
|
||||
z-index: 1;
|
||||
height: 100rpx;
|
||||
padding: 0 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-top: 1rpx solid #ededed;
|
||||
border-bottom: 1rpx solid #ededed;
|
||||
background-color: #fff;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.toolbar .all {
|
||||
margin-left: 25rpx;
|
||||
font-size: 14px;
|
||||
color: #444;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.toolbar .all::before {
|
||||
font-family: "erabbit" !important;
|
||||
content: "\e6cd";
|
||||
font-size: 40rpx;
|
||||
margin-right: 8rpx;
|
||||
}
|
||||
.toolbar .checked::before {
|
||||
content: "\e6cc";
|
||||
color: #4095e5;
|
||||
}
|
||||
.toolbar .amount {
|
||||
font-size: 20px;
|
||||
color: #cf4444;
|
||||
}
|
||||
.toolbar .amount .decimal {
|
||||
font-size: 12px;
|
||||
}
|
||||
.toolbar .amount::before {
|
||||
content: "¥";
|
||||
font-size: 12px;
|
||||
}
|
||||
.toolbar .button-grounp {
|
||||
margin-left: auto;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
text-align: center;
|
||||
line-height: 72rpx;
|
||||
font-size: 13px;
|
||||
color: #fff;
|
||||
}
|
||||
.toolbar .button-grounp .button {
|
||||
width: 240rpx;
|
||||
margin: 0 10rpx;
|
||||
border-radius: 72rpx;
|
||||
}
|
||||
.toolbar .button-grounp .payment-button {
|
||||
background-color: #4095e5;
|
||||
}
|
||||
.toolbar-height {
|
||||
height: 100rpx;
|
||||
}
|
||||
.priceTitle {
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
background-color: #4095e5;
|
||||
font-size: 20px;
|
||||
color: #fff;
|
||||
padding-left: 5px;
|
||||
line-height: 50px;
|
||||
}
|
||||
.iconfont {
|
||||
margin: auto 0;
|
||||
font-size: 20px;
|
||||
}
|
||||
.jia,
|
||||
.jian {
|
||||
background-color: #fff;
|
||||
padding: 3px 5px 3px 5px;
|
||||
border: 1px solid #999;
|
||||
}
|
||||
.quantity-value {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
margin: 0 20rpx;
|
||||
}
|
||||
.iconfont {
|
||||
margin-right: 15px;
|
||||
}
|
Reference in New Issue
Block a user