diff --git a/yshop-drink-uniapp-vue3/pages.json b/yshop-drink-uniapp-vue3/pages.json
index c4ac09b..90b8c6d 100644
--- a/yshop-drink-uniapp-vue3/pages.json
+++ b/yshop-drink-uniapp-vue3/pages.json
@@ -1,207 +1,207 @@
-{
- "pages": [
- {
- "path": "pages/index/index",
- "style": {
- "navigationBarTitleText": "首页"
- }
- },
-
- {
- "path" : "pages/menu/menu",
+{
+ "pages": [
+ {
+ "path": "pages/index/index",
+ "style": {
+ "navigationBarTitleText": "首页"
+ }
+ },
+
+ {
+ "path" : "pages/menu/menu",
"style" :
{
"navigationBarTitleText": "点餐",
"enablePullDownRefresh": true
}
-
- }
- ,{
- "path" : "pages/order/order",
+
+ }
+ ,{
+ "path" : "pages/order/order",
"style" :
{
"navigationBarTitleText": "订单",
"enablePullDownRefresh": true
}
-
- }
- ,{
- "path" : "pages/mine/mine",
+
+ }
+ ,{
+ "path" : "pages/mine/mine",
"style" :
{
"navigationBarTitleText": "我的",
"enablePullDownRefresh": true
}
-
- }
- ,{
- "path" : "pages/cart/cart",
+
+ }
+ ,{
+ "path" : "pages/cart/cart",
"style" :
{
"navigationBarTitleText": "购物车",
"enablePullDownRefresh": false
}
-
- }
+
+ }
],
- "subPackages": [{
- "root": "pages/components",
- "pages": [ {
- "path": "pages/mine/content",
- "style": {
- "navigationBarTitleText": "内容",
- "navigationBarTextStyle": "black",
- "navigationBarBackgroundColor": "#ffffff"
- }
- }, {
- "path": "pages/pay/pay",
- "style": {
- "navigationBarTitleText": "支付",
- "navigationBarTextStyle": "black",
- "navigationBarBackgroundColor": "#ffffff"
- }
- }, {
- "path": "pages/remark/remark",
- "style": {
- "navigationBarTitleText": "备注",
- "navigationBarTextStyle": "black",
- "navigationBarBackgroundColor": "#ffffff"
- }
- }, {
- "path": "pages/packages/index",
- "style": {
- "navigationBarTitleText": "可用优惠券",
- "navigationBarTextStyle": "black",
- "navigationBarBackgroundColor": "#ffffff",
- "enablePullDownRefresh": true
- }
- },
- {
- "path": "pages/login/login",
- "style": {
- "navigationBarTitleText": "登录",
- "navigationBarTextStyle": "black",
- "navigationBarBackgroundColor": "#ffffff"
- }
- },
- {
- "path": "pages/login/logout",
- "style": {
- "navigationBarTitleText": "退出登录"
- }
- },
- {
- "path": "pages/address/address",
- "style": {
- "navigationBarTitleText": "我的地址",
- "navigationBarTextStyle": "black",
- "navigationBarBackgroundColor": "#ffffff"
- }
- }, {
- "path": "pages/address/add",
- "style": {
- "navigationBarTitleText": "添加地址",
- "navigationBarTextStyle": "black",
- "navigationBarBackgroundColor": "#ffffff"
- }
- }, {
- "path": "pages/orders/orders",
- "style": {
- "navigationBarTitleText": "历史订单",
- "navigationBarTextStyle": "black",
- "navigationBarBackgroundColor": "#ffffff",
- "enablePullDownRefresh": true,
- "onReachBottomDistance": 50
- }
- }, {
- "path": "pages/orders/detail",
- "style": {
- "navigationBarTitleText": "订单详情",
- "navigationBarTextStyle": "black",
- "navigationBarBackgroundColor": "#ffffff"
- }
- }, {
- "path": "pages/coupons/coupons",
- "style": {
- "enablePullDownRefresh": true,
- "navigationBarTitleText": "我的卡券",
- "navigationBarTextStyle": "black",
- "navigationBarBackgroundColor": "#ffffff"
- }
- }, {
- "path": "pages/mine/userinfo",
- "style": {
- "navigationBarTitleText": "用户信息",
- "navigationBarTextStyle": "black",
- "navigationBarBackgroundColor": "#ffffff"
- }
- },
- {
- "path": "pages/shop/shop",
- "style": {
- "navigationBarTitleText": "店铺",
- "navigationBarTextStyle": "black",
- "navigationBarBackgroundColor": "#ffffff"
- }
- }, {
- "path": "pages/balance/bill",
- "style": {
- "navigationBarTitleText": "账单",
- "navigationBarTextStyle": "black",
- "navigationBarBackgroundColor": "#ffffff"
- }
- }
- ,{
- "path" : "pages/orders/refund",
+ "subPackages": [{
+ "root": "pages/components",
+ "pages": [ {
+ "path": "pages/mine/content",
+ "style": {
+ "navigationBarTitleText": "内容",
+ "navigationBarTextStyle": "black",
+ "navigationBarBackgroundColor": "#ffffff"
+ }
+ }, {
+ "path": "pages/pay/pay",
+ "style": {
+ "navigationBarTitleText": "支付",
+ "navigationBarTextStyle": "black",
+ "navigationBarBackgroundColor": "#ffffff"
+ }
+ }, {
+ "path": "pages/remark/remark",
+ "style": {
+ "navigationBarTitleText": "备注",
+ "navigationBarTextStyle": "black",
+ "navigationBarBackgroundColor": "#ffffff"
+ }
+ }, {
+ "path": "pages/packages/index",
+ "style": {
+ "navigationBarTitleText": "可用优惠券",
+ "navigationBarTextStyle": "black",
+ "navigationBarBackgroundColor": "#ffffff",
+ "enablePullDownRefresh": true
+ }
+ },
+ {
+ "path": "pages/login/login",
+ "style": {
+ "navigationBarTitleText": "登录",
+ "navigationBarTextStyle": "black",
+ "navigationBarBackgroundColor": "#ffffff"
+ }
+ },
+ {
+ "path": "pages/login/logout",
+ "style": {
+ "navigationBarTitleText": "退出登录"
+ }
+ },
+ {
+ "path": "pages/address/address",
+ "style": {
+ "navigationBarTitleText": "我的地址",
+ "navigationBarTextStyle": "black",
+ "navigationBarBackgroundColor": "#ffffff"
+ }
+ }, {
+ "path": "pages/address/add",
+ "style": {
+ "navigationBarTitleText": "添加地址",
+ "navigationBarTextStyle": "black",
+ "navigationBarBackgroundColor": "#ffffff"
+ }
+ }, {
+ "path": "pages/orders/orders",
+ "style": {
+ "navigationBarTitleText": "历史订单",
+ "navigationBarTextStyle": "black",
+ "navigationBarBackgroundColor": "#ffffff",
+ "enablePullDownRefresh": true,
+ "onReachBottomDistance": 50
+ }
+ }, {
+ "path": "pages/orders/detail",
+ "style": {
+ "navigationBarTitleText": "订单详情",
+ "navigationBarTextStyle": "black",
+ "navigationBarBackgroundColor": "#ffffff"
+ }
+ }, {
+ "path": "pages/coupons/coupons",
+ "style": {
+ "enablePullDownRefresh": true,
+ "navigationBarTitleText": "我的卡券",
+ "navigationBarTextStyle": "black",
+ "navigationBarBackgroundColor": "#ffffff"
+ }
+ }, {
+ "path": "pages/mine/userinfo",
+ "style": {
+ "navigationBarTitleText": "用户信息",
+ "navigationBarTextStyle": "black",
+ "navigationBarBackgroundColor": "#ffffff"
+ }
+ },
+ {
+ "path": "pages/shop/shop",
+ "style": {
+ "navigationBarTitleText": "店铺",
+ "navigationBarTextStyle": "black",
+ "navigationBarBackgroundColor": "#ffffff"
+ }
+ }, {
+ "path": "pages/balance/bill",
+ "style": {
+ "navigationBarTitleText": "账单",
+ "navigationBarTextStyle": "black",
+ "navigationBarBackgroundColor": "#ffffff"
+ }
+ }
+ ,{
+ "path" : "pages/orders/refund",
"style" :
{
"navigationBarTitleText": "退款",
"enablePullDownRefresh": false
}
-
- }
- ]
- }],
- "globalStyle": {
- "navigationBarTextStyle": "black",
- "navigationBarTitleText": " ",
- "navigationBarBackgroundColor": "#F8F8F8",
- "backgroundColor": "#F8F8F8",
- "navigationStyle": "custom"
+
+ }
+ ]
+ }],
+ "globalStyle": {
+ "navigationBarTextStyle": "black",
+ "navigationBarTitleText": " ",
+ "navigationBarBackgroundColor": "#F8F8F8",
+ "backgroundColor": "#F8F8F8",
+ "navigationStyle": "custom"
},
- "tabBar": {
- "color": "#919293",
- "selectedColor": "#dd524d",
- "backgroundColor": "#fff",
- "borderStyle": "black",
- "list": [{
- "pagePath": "pages/index/index",
- "text": "首页",
- "iconPath": "static/images/tabBar/index.png",
- "selectedIconPath": "static/images/tabBar/index_selected.png"
- },
- {
- "pagePath": "pages/menu/menu",
- "text": "点餐",
- "iconPath": "static/images/tabBar/drink.png",
- "selectedIconPath": "static/images/tabBar/drink-selected.png"
- }, {
- "pagePath": "pages/cart/cart",
- "text": "购物车",
- "iconPath": "static/images/tabBar/cart.png",
- "selectedIconPath": "static/images/tabBar/cart-selected.png"
- },{
- "pagePath": "pages/order/order",
- "text": "订单",
- "iconPath": "static/images/tabBar/order.png",
- "selectedIconPath": "static/images/tabBar/order-selected.png"
- }, {
- "pagePath": "pages/mine/mine",
- "text": "我的",
- "iconPath": "static/images/tabBar/mine.png",
- "selectedIconPath": "static/images/tabBar/mine_selected.png"
- }
- ]
- },
- "uniIdRouter": {}
-}
+ "tabBar": {
+ "color": "#919293",
+ "selectedColor": "#09b4f1",
+ "backgroundColor": "#fff",
+ "borderStyle": "black",
+ "list": [{
+ "pagePath": "pages/index/index",
+ "text": "首页",
+ "iconPath": "static/images/tabBar/index.png",
+ "selectedIconPath": "static/images/tabBar/index_selected.png"
+ },
+ {
+ "pagePath": "pages/menu/menu",
+ "text": "点餐",
+ "iconPath": "static/images/tabBar/drink.png",
+ "selectedIconPath": "static/images/tabBar/drink-selected.png"
+ }, {
+ "pagePath": "pages/cart/cart",
+ "text": "购物车",
+ "iconPath": "static/images/tabBar/cart.png",
+ "selectedIconPath": "static/images/tabBar/cart-selected.png"
+ },{
+ "pagePath": "pages/order/order",
+ "text": "订单",
+ "iconPath": "static/images/tabBar/order.png",
+ "selectedIconPath": "static/images/tabBar/order-selected.png"
+ }, {
+ "pagePath": "pages/mine/mine",
+ "text": "我的",
+ "iconPath": "static/images/tabBar/mine.png",
+ "selectedIconPath": "static/images/tabBar/mine_selected.png"
+ }
+ ]
+ },
+ "uniIdRouter": {}
+}
diff --git a/yshop-drink-uniapp-vue3/pages/cart/cart.vue b/yshop-drink-uniapp-vue3/pages/cart/cart.vue
index 80ad3fd..3599853 100644
--- a/yshop-drink-uniapp-vue3/pages/cart/cart.vue
+++ b/yshop-drink-uniapp-vue3/pages/cart/cart.vue
@@ -38,15 +38,15 @@
应付:¥{{ getCartGoodsPrice }}
-
+
-
-
+ if (payType.value == 'weixin') {
+ // 微信支付
+ weixinPay(order);
+ } else if (payType.value == 'yue') {
+ // 余额支付
+ balancePay(order);
+ } else if (payType.value == 'alipay') {
+ // 余额支付
+ aliPay(order);
+ }
+ uni.hideLoading()
+ return
+}
+const balancePay = async(order) => {
+ let from = 'routine'
+ // #ifdef H5
+ from = 'h5'
+ // #endif
+ let pay = await payUnify({
+ uni: order.orderId,
+ from: from,
+ paytype: 'yue'
+ });
+
+ uni.hideLoading();
+ if (!pay) {
+ return;
+ }
+
+ member.value.money -= amount.value
+ main.SET_MEMBER(member.value)
+ uni.removeStorageSync('cart');
+ uni.switchTab({
+ url: '/pages/order/order',
+ fail(res) {
+ console.log(res);
+ }
+ });
+}
+const weixinPay = async(order) => {
+ let from = 'routine'
+ // #ifdef H5
+ from = 'h5'
+ if(isWeixin()){
+ from = 'wechat'
+ }
+
+ // #endif
+ //let that = this;
+ let data = await payUnify({
+ uni: order.orderId,
+ from: from,
+ paytype: 'weixin'
+ });
+ console.log('param2:',data)
+ if (!data) {
+ uni.hideLoading();
+ return;
+ }
+ if (data.trade_type == 'MWEB') {
+ // #ifdef H5
+ // 微信外的H5
+ console.log('data:',data)
+ location.href = data.data;
+ // #endif
+ console.log('data1:',data)
+ } else if (data.trade_type == 'JSAPI') {
+ console.log('param:',data)
+
+ // #ifdef MP-WEIXIN
+ uni.requestPayment({
+ provider: 'wxpay',
+ timeStamp: data.data.timeStamp,
+ nonceStr: data.data.nonceStr,
+ package: data.data.package,
+ signType: 'MD5',
+ paySign: data.data.paySign,
+ success: function(res) {
+
+ uni.removeStorageSync('cart');
+ uni.switchTab({
+ url: '/pages/order/order'
+ });
+ },
+ fail: function(err) {
+ console.log('fail:' + JSON.stringify(err));
+ }
+ });
+ // #endif
+ } else if (data.trade_type == 'W-JSAPI'){
+ //公众号支付
+
+
+ }else if (data.trade_type == 'APP') {
+
+ }
+}
+const aliPay = async(order) => {
+
+ // #ifdef H5
+ //let that = this;
+ if(isWeixin()){
+ uni.showToast({
+ title: '请普通浏览器打开进行支付宝支付~',
+ icon: 'none'
+ })
+ return
+ }
+ let data = await payUnify({
+ uni: order.orderId,
+ from: 'h5',
+ paytype: 'alipay'
+ });
+
+ console.log('data:',data.data)
+ // 支付宝支付,这里只要提交表单
+ let form = data.data
+ const div = document.createElement('formdiv');
+ div.innerHTML = form;
+ document.body.appendChild(div);
+ //document.forms[0].setAttribute('target', ' self');
+ document.forms[0].submit();
+ //div.remove();
+
+// #endif
+
+
+}
+
+
+
+
+
+
+
diff --git a/yshop-drink-uniapp-vue3/pages/index/index.vue b/yshop-drink-uniapp-vue3/pages/index/index.vue
index 57cdd2d..bcfe318 100644
--- a/yshop-drink-uniapp-vue3/pages/index/index.vue
+++ b/yshop-drink-uniapp-vue3/pages/index/index.vue
@@ -29,8 +29,20 @@
+
-
+
@@ -150,6 +162,17 @@ onLoad(() => {