Merge branch 'vue3_tmp' of https://gitee.com/huizhizao/yudao-mall-uniapp into master-vue3

# Conflicts:
#	pages.json
#	pages/goods/list.vue
#	pages/order/list.vue
#	sheep/api/order.js
#	sheep/api/trade/order.js
#	sheep/hooks/useGoods.js
This commit is contained in:
YunaiV
2023-12-14 23:26:47 +08:00
46 changed files with 4616 additions and 4522 deletions
+61 -40
View File
@@ -1,43 +1,64 @@
import request from '@/sheep/request';
export default {
myGroupon: (params) =>
request({
url: 'activity/groupon/myGroupons',
method: 'GET',
params,
}),
getGrouponList: (params) =>
request({
url: 'activity/groupon',
method: 'GET',
params,
}),
grouponDetail: (id) =>
request({
url: 'activity/groupon/' + id,
method: 'GET',
}),
signList: (params) =>
request({
url: 'activity/signin',
method: 'GET',
params,
}),
signAdd: () =>
request({
url: 'activity/signin',
method: 'POST',
}),
replenish: (data) =>
request({
url: 'activity/signin/replenish',
method: 'POST',
data,
}),
activity: (id) =>
request({
url: 'activity/activity/' + id,
method: 'GET',
}),
};
myGroupon: (params) =>
request({
url: 'activity/groupon/myGroupons',
method: 'GET',
params,
}),
getGrouponList: (params) =>
request({
url: 'activity/groupon',
method: 'GET',
params,
}),
grouponDetail: (id) =>
request({
url: 'activity/groupon/' + id,
method: 'GET',
}),
signList: (params) =>
request({
url: 'activity/signin',
method: 'GET',
params,
}),
signAdd: () =>
request({
url: '/app-api/member/sign-in/record/create',
method: 'POST',
}),
configLise: () =>
request({
url: '/app-api/member/sign-in/config/list',
method: 'GET',
}),
recordPage: () =>
request({
url: '/app-api/member/sign-in/record/page',
method: 'GET',
}),
// signAdd: () =>
// request({
// url: 'activity/signin',
// method: 'POST',
// }),
replenish: (data) =>
request({
url: 'activity/signin/replenish',
method: 'POST',
data,
}),
activity: (id) =>
request({
url: 'activity/activity/' + id,
method: 'GET',
}),
getSummary: () =>
request({
url: '/app-api/member/sign-in/record/get-summary',
method: 'GET',
}),
};
+3 -5
View File
@@ -115,14 +115,12 @@ export default {
formData: {
group,
},
// TODO 芋艿:临时写死
header: {
// Accept: 'text/json',
// Authorization: token,
Accept : '*/*',
'tenant-id' :'1',
'terminal': 20,
Authorization: 'Bearer test247',
Accept : '*/*',
'tenant-id' :'1',
Authorization: 'Bearer test247',
},
success: (uploadFileRes) => {
let result = JSON.parse(uploadFileRes.data);
+9 -22
View File
@@ -1,9 +1,10 @@
import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default {
list: (data) =>
request({
url: '/app-api/trade/cart/list',
request2({
url: 'trade/cart/list',
method: 'GET',
custom: {
showLoading: false,
@@ -12,40 +13,26 @@ export default {
}),
append: (data) =>
request({
url: '/app-api/trade/cart/add',
url: 'cart',
method: 'POST',
// TODO 芋艿:这里没提示
custom: {
showSuccess: true,
successMsg: '已添加到购物车~',
},
data: {
...data,
// type: 'inc',
type: 'inc',
},
}),
// append: (data) =>
// request({
// url: 'cart',
// method: 'POST',
// custom: {
// showSuccess: true,
// successMsg: '已添加到购物车~',
// },
// data: {
// ...data,
// type: 'inc',
// },
// }),
// 删除购物车
delete: (ids) =>
request({
url: '/app-api/trade/cart/delete?ids=' + ids,
request2({
url: 'trade/cart/delete?ids=' + ids,
method: 'DELETE',
}),
update: (data) =>
request({
url: '/app-api/trade/cart/update-count',
request2({
url: 'trade/cart/update-count',
method: 'PUT',
data: {
...data,
+9 -7
View File
@@ -1,8 +1,10 @@
import request2 from '@/sheep/request2';
export default {
list: (params) =>
request({
url: '/app-api/product/category/list',
method: 'GET',
params,
}),
};
list: (params) =>
request2({
url: 'product/category/list',
method: 'GET',
params,
}),
};
+4 -14
View File
@@ -1,4 +1,5 @@
import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default {
// 我的拼团
@@ -12,8 +13,8 @@ export default {
},
}),
userCoupon: (params) =>
request({
url: '/app-api/promotion/coupon/page',
request2({
url: 'promotion/coupon/page',
method: 'GET',
params,
}),
@@ -33,20 +34,9 @@ export default {
}),
get: (id) =>
request({
url: '/app-api/promotion/coupon/take',
url: 'coupon/get/' + id,
method: 'POST',
data: {
templateId: id
},
params: {
templateId: id
},
}),
// get: (id) =>
// request({
// url: 'coupon/get/' + id,
// method: 'POST',
// }),
listByGoods: (id) =>
request({
url: 'coupon/listByGoods/' + id,
+22 -21
View File
@@ -1,24 +1,25 @@
import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default {
area: () =>
request({
url: '/app-api/system/area/tree',
method: 'GET',
}),
// area: () =>
// request({
// url: 'data/area',
// method: 'GET',
// }),
faq: () =>
request({
url: 'data/faq',
method: 'GET',
}),
richtext: (id) =>
request({
url: 'data/richtext/' + id,
method: 'GET',
}),
};
area: () =>
request2({
url: 'system/area/tree',
method: 'GET',
}),
// area: () =>
// request({
// url: 'data/area',
// method: 'GET',
// }),
faq: () =>
request({
url: 'data/faq',
method: 'GET',
}),
richtext: (id) =>
request({
url: 'data/richtext/' + id,
method: 'GET',
}),
};
+75 -79
View File
@@ -1,84 +1,80 @@
import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default {
// 商品详情
detail: (id, params = {}) =>
request({
url: '/app-api/product/spu/get-detail?id=' + id,
method: 'GET',
params,
custom: {
showLoading: false,
showError: false,
},
}),
// 商品详情
detail: (id, params = {}) =>
request2({
url: 'product/spu/get-detail?id=' + id,
method: 'GET',
params,
custom: {
showLoading: false,
showError: false,
},
}),
// 商品列表
list: (params) =>
request({
url: '/app-api/product/spu/page',
method: 'GET',
params,
custom: {
showLoading: false,
showError: false,
},
}),
// 商品列表
list: (params) =>
request2({
url: 'product/spu/page',
method: 'GET',
params,
custom: {
showLoading: false,
showError: false,
},
}),
// 商品查询
ids: (params = {}) =>
request({
url: 'goods/goods/ids',
method: 'GET',
params,
custom: {
showLoading: false,
showError: false,
},
}),
// 商品评价列表
comment: (id, params = {}) =>
request({
url: '/app-api/product/comment/list?spuId=' + id,
method: 'GET',
params,
custom: {
showLoading: false,
showError: false,
},
}),
// 商品评价类型
getType: (id) =>
request({
url: 'goods/comment/getType/' + id,
method: 'GET',
custom: {
showLoading: false,
showError: false,
},
}),
// 活动商品查询
// 商品查询
activity: (params = {}) =>
request({
url: 'goods/goods/activity',
method: 'GET',
params,
custom: {
showLoading: false,
showError: false,
},
}),
activityList: (params = {}) =>
request({
url: 'goods/goods/activityList',
method: 'GET',
params,
}),
// 检查是否收藏商品
exits: (id) =>
request({
url: '/app-api/product/favorite/exits?spuId=' + id,
method: 'GET',
}),
};
// 商品查询
ids: (params = {}) =>
request({
url: 'goods/goods/ids',
method: 'GET',
params,
custom: {
showLoading: false,
showError: false,
},
}),
// 商品评价列表
comment: (id, params = {}) =>
request2({
url: 'product/comment/list?spuId=' + id,
method: 'GET',
params,
custom: {
showLoading: false,
showError: false,
},
}),
// 商品评价类型
getType: (id) =>
request({
url: 'goods/comment/getType/' + id,
method: 'GET',
custom: {
showLoading: false,
showError: false,
},
}),
// 活动商品查询
// 商品查询
activity: (params = {}) =>
request({
url: 'goods/goods/activity',
method: 'GET',
params,
custom: {
showLoading: false,
showError: false,
},
}),
activityList: (params = {}) =>
request({
url: 'goods/goods/activityList',
method: 'GET',
params,
}),
};
+12 -12
View File
@@ -1,14 +1,14 @@
import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default {
decorate: () =>
request({
url: '/app-api/promotion/decorate/list?page=1',
method: 'GET',
}),
spids: () =>
request({
url: '/app-api/product/spu/page?recommendType=best&pageNo=1&pageSize=10',
method: 'GET',
}),
};
decorate: () =>
request2({
url: 'promotion/decorate/list?page=1',
method: 'GET',
}),
spids: () =>
request2({
url: 'product/spu/page?recommendType=best&pageNo=1&pageSize=10',
method: 'GET',
}),
};
+52 -26
View File
@@ -1,10 +1,11 @@
import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default {
// 订单详情
detail: (id, params) =>
request({
url: '/app-api/trade/order/get-detail?id=' + id,
request2({
url: 'trade/order/get-detail?id=' + id,
method: 'GET',
params,
}),
@@ -37,7 +38,16 @@ export default {
showLoading: false,
},
}),
// 订单列表
list: (params) =>
request2({
url: 'trade/order/page',
method: 'GET',
params,
custom: {
showLoading: false,
},
}),
// list: (params) =>
// request({
// url: 'order/order',
@@ -55,27 +65,27 @@ export default {
// 解决 SpringMVC 接受 List<Item> 参数的问题
delete data2.items
for (let i = 0; i < data.items.length; i++) {
// 此处转码问题,待解决方案
data2[encodeURIComponent('items[' + i + '' + '].skuId')] = data.items[i].skuId + '';
data2[encodeURIComponent('items[' + i + '' + '].count')] = data.items[i].count + '';
data2[encodeURIComponent('items[' + i + '' + '].cartId')] = data.items[i].cartId + '';
// data2['items' + `[${i}]` + '.skuId'] = data.items[i].skuId + '';
// data2['items' + `[${i}]` + '.count'] = data.items[i].count + '';
// data2['items' + `[${i}]` + '.cartId'] = data.items[i].cartId + '';
// data2['items' + `%5B${i}%5D` + '.skuId'] = data.items[i].skuId + '';
// data2['items' + `%5B${i}%5D` + '.count'] = data.items[i].count + '';
// data2['items' + `%5B${i}%5D` + '.cartId'] = data.items[i].cartId + '';
// data2['items[' + i + '' + '].skuId'] = data.items[i].skuId + '';
// data2['items[' + i + '' + '].count'] = data.items[i].count + '';
// data2['items[' + i + '' + '].cartId'] = data.items[i].cartId + '';
data2['items' + `%5B${i}%5D` + '.skuId'] = data.items[i].skuId + '';
data2['items' + `%5B${i}%5D` + '.count'] = data.items[i].count + '';
data2['items' + `%5B${i}%5D` + '.cartId'] = data.items[i].cartId + '';
}
console.log(data2, '手动转码的参数')
return request({
url: '/app-api/trade/order/settlement',
console.log(data2, '对比数据')
return request2({
url: 'trade/order/settlement',
method: 'GET',
// data: data2,
// data,
params: data2
})
},
// calc: (data) =>
// request({
// url: 'order/order/calc',
// method: 'POST',
// data,
// }),
// 创建订单
create: (data) =>
request({
@@ -98,8 +108,8 @@ export default {
}),
// 评价订单
comment: (data) =>
request({
url: '/app-api/trade/order/item/create-comment',
request2({
url: 'trade/order/item/create-comment',
method: 'POST',
data,
}),
@@ -129,15 +139,31 @@ export default {
}),
// 售后
aftersale: {
list: (params) =>
// 申请售后
apply: (data) =>
request({
url: '/app-api/trade/after-sale/page',
url: 'order/aftersale',
method: 'POST',
data,
}),
list: (params) =>
request2({
url: 'trade/after-sale/page',
method: 'GET',
params,
custom: {
showLoading: false,
},
}),
// list: (params) =>
// request({
// url: 'order/aftersale',
// method: 'GET',
// params,
// custom: {
// showLoading: false,
// },
// }),
//取消售后
cancel: (id) =>
request({
@@ -150,10 +176,10 @@ export default {
url: 'order/aftersale/' + id,
method: 'DELETE',
}),
// 售后详情 DONE
// 售后详情
detail: (id) =>
request({
url: '/app-api/trade/after-sale/get?id=' + id,
request2({
url: 'trade/after-sale/get?id=' + id,
method: 'GET',
}),
},
-14
View File
@@ -1,14 +0,0 @@
import request from '@/sheep/request';
const PayChannelApi = {
// 获得指定应用的开启的支付渠道编码列表
getEnableChannelCodeList: (appId) => {
return request({
url: '/app-api/pay/channel/get-enable-code-list',
method: 'GET',
params: { appId }
});
},
};
export default PayChannelApi;
-22
View File
@@ -1,22 +0,0 @@
import request from '@/sheep/request';
const PayOrderApi = {
// 获得支付订单
getOrder: (id) => {
return request({
url: '/app-api/pay/order/get',
method: 'GET',
params: { id }
});
},
// 提交支付订单
submitOrder: (data) => {
return request({
url: '/app-api/pay/order/submit',
method: 'POST',
data
});
}
};
export default PayOrderApi;
+14 -15
View File
@@ -1,19 +1,18 @@
import request from '@/sheep/request';
const CommentApi = {
// 获得商品评价分页
getCommentPage: (spuId, pageNo, pageSize, type) => {
return request({
url: '/app-api/product/comment/page',
method: 'GET',
params: {
spuId,
pageNo,
pageSize,
type
},
});
},
// 获得商品评价分页
getCommentPage: (spuId, pageNo, pageSize, type) => {
return request({
url: '/app-api/product/comment/page',
method: 'GET',
params: {
spuId,
pageNo,
pageSize,
type
},
});
},
};
export default CommentApi;
export default CommentApi;
+11 -11
View File
@@ -1,16 +1,16 @@
import request from '@/sheep/request';
import request2 from '@/sheep/request2';
const ActivityApi = {
// 获得单个商品,近期参与的每个活动
getActivityListBySpuId: (spuId) => {
return request({
url: '/app-api/promotion/activity/list-by-spu-id',
method: 'GET',
params: {
spuId,
},
});
},
// 获得单个商品,近期参与的每个活动
getActivityListBySpuId: (spuId) => {
return request2({
url: '/app-api/promotion/activity/list-by-spu-id',
method: 'GET',
params: {
spuId,
},
});
},
};
export default ActivityApi;
+57 -59
View File
@@ -1,69 +1,67 @@
import request from "@/sheep/request";
import request2 from "@/sheep/request2";
// 拼团 API
const CombinationApi = {
// 获得拼团活动列表
getCombinationActivityList: (count) => {
return request({
url: "/app-api/promotion/combination-activity/list",
method: 'GET',
params: {
count
}
});
},
// 获得拼团活动列表
getCombinationActivityList: (count) => {
return request2({
url: "promotion/combination-activity/list",
method: 'GET',
params: {count}
});
},
// 获得拼团活动分页
getCombinationActivityPage: (params) => {
return request({
url: "/app-api/promotion/combination-activity/page",
method: 'GET',
params
});
},
// 获得拼团活动分页
getCombinationActivityPage: (params) => {
return request2({
url: "promotion/combination-activity/page",
method: 'GET',
params
});
},
// 获得拼团活动明细
getCombinationActivity: (id) => {
return request({
url: "/app-api/promotion/combination-activity/get-detail",
method: 'GET',
params: {
id
}
});
},
// 获得拼团活动明细
getCombinationActivity: (id) => {
return request2({
url: "promotion/combination-activity/get-detail",
method: 'GET',
params: {
id
}
});
},
// 获得最近 n 条拼团记录(团长发起的)
getHeadCombinationRecordList: (activityId, status, count) => {
return request({
url: "/app-api/promotion/combination-record/get-head-list",
method: 'GET',
params: {
activityId,
status,
count
}
});
},
// 获得最近 n 条拼团记录(团长发起的)
getHeadCombinationRecordList: (activityId, status, count) => {
return request2({
url: "promotion/combination-record/get-head-list",
method: 'GET',
params: {
activityId,
status,
count
}
});
},
// 获得拼团记录明细
getCombinationRecordDetail: (id) => {
return request({
url: "/app-api/promotion/combination-record/get-detail",
method: 'GET',
params: {
id
}
});
},
// 获得拼团记录明细
getCombinationRecordDetail: (id) => {
return request2({
url: "promotion/combination-record/get-detail",
method: 'GET',
params: {
id
}
});
},
// 获得拼团记录的概要信息
getCombinationRecordSummary: () => {
return request({
url: "/app-api/promotion/combination-record/get-summary",
method: 'GET',
});
}
// 获得拼团记录的概要信息
getCombinationRecordSummary: () => {
return request2({
url: "promotion/combination-record/get-summary",
method: 'GET',
});
}
}
export default CombinationApi
export default CombinationApi
-13
View File
@@ -17,17 +17,4 @@ export default {
params: { spuId, productScope, count },
});
},
// 获得匹配指定商品的优惠劵列表
getMatchCouponList: (price, spuIds, skuIds, categoryIds) => {
return request({
url: '/app-api/promotion/coupon/match-list',
method: 'GET',
params: {
price,
spuIds: spuIds.join(','),
skuIds: skuIds.join(','),
categoryIds: categoryIds.join(','),
},
});
}
};
+26 -37
View File
@@ -1,44 +1,33 @@
import request from "@/sheep/request";
import request2 from "@/sheep/request2";
const SeckillApi = {
// 获得秒杀时间段列表
getSeckillConfigList: () => {
return request({
url: '/app-api/promotion/seckill-config/list',
method: 'GET'
});
},
// 获得秒杀时间段列表
getSeckillConfigList: () => {
return request2({ url: 'promotion/seckill-config/list', method: 'GET' });
},
// 获得当前秒杀活动
getNowSeckillActivity: () => {
return request({
url: '/app-api/promotion/seckill-activity/get-now',
method: 'GET'
});
},
// 获得当前秒杀活动
getNowSeckillActivity: () => {
return request2({ url: 'promotion/seckill-activity/get-now', method: 'GET' });
},
// 获得秒杀活动分页
getSeckillActivityPage: () => {
return request({
url: '/app-api/promotion/seckill-activity/page',
method: 'GET'
});
},
// 获得秒杀活动分页
getSeckillActivityPage: () => {
return request2({ url: 'promotion/seckill-activity/page', method: 'GET' });
},
/**
* 获得秒杀活动明细
* @param {number} id 秒杀活动编号
* @return {*}
*/
getSeckillActivity: (id) => {
return request({
url: '/app-api/promotion/seckill-activity/get-detail',
method: 'GET',
params: {
id
}
});
}
/**
* 获得秒杀活动明细
* @param {number} id 秒杀活动编号
* @return {*}
*/
getSeckillActivity: (id) => {
return request2({
url: 'promotion/seckill-activity/get-detail',
method: 'GET',
params: { id }
});
}
}
export default SeckillApi;
export default SeckillApi;
+42 -33
View File
@@ -1,37 +1,46 @@
import request from '@/sheep/request';
export default {
order: (id) =>
request({
url: 'trade/order/' + id,
method: 'GET',
custom: {
showLoading: false,
},
}),
orderLog: (params) =>
request({
url: 'trade/order',
method: 'GET',
params,
custom: {
showLoading: false,
},
}),
order: (id) =>
request({
url: 'trade/order/' + id,
method: 'GET',
custom: {
showLoading: false,
},
}),
orderLog: (params) =>
request({
url: 'trade/order',
method: 'GET',
params,
custom: {
showLoading: false,
},
}),
rechargeRules: () =>
request({
url: 'trade/order/rechargeRules',
method: 'GET',
custom: {
showError: false,
showLoading: false,
},
}),
recharge: (data) =>
request({
url: 'trade/order/recharge',
method: 'POST',
data,
}),
};
rechargeRules: () =>
request({
url: 'trade/order/rechargeRules',
method: 'GET',
custom: {
showError: false,
showLoading: false,
},
}),
rechargeRules2: () =>
request({
url: '/app-api/pay/wallet-recharge-package/list',
method: 'GET',
custom: {
showError: false,
showLoading: false,
},
}),
recharge: (data) =>
request({
url: '/app-api/pay/wallet-recharge/create',
method: 'POST',
data,
}),
};
-47
View File
@@ -1,47 +0,0 @@
import request2 from '@/sheep/request2';
const CartApi = {
addCart: (data) => {
return request2({
url: '/app-api/trade/cart/add',
method: 'POST',
data: data,
// TODO 芋艿:这里没提示
custom: {
showSuccess: true,
successMsg: '已添加到购物车~',
}
});
},
updateCartCount: (data) => {
return request2({
url: '/app-api/trade/cart/update-count',
method: 'PUT',
data: data
});
},
updateCartSelected: (data) => {
return request2({
url: '/app-api/trade/cart/update-selected',
method: 'PUT',
data: data
});
},
deleteCart: (ids) => {
return request2({
url: '/app-api/trade/cart/delete',
method: 'DELETE',
params: {
ids
}
});
},
getCartList: () => {
return request2({
url: '/app-api/trade/cart/list',
method: 'GET',
});
},
};
export default CartApi;
-85
View File
@@ -1,85 +0,0 @@
import request2 from '@/sheep/request2';
import request from '@/sheep/request';
const OrderApi = {
// 计算订单信息
settlementOrder: (data) => {
const data2 = {
...data,
};
// 移除多余字段
if (!(data.couponId > 0)) {
delete data2.couponId;
}
if (!(data.addressId > 0)) {
delete data2.addressId;
}
// 解决 SpringMVC 接受 List<Item> 参数的问题
delete data2.items;
for (let i = 0; i < data.items.length; i++) {
data2[encodeURIComponent('items[' + i + '' + '].skuId')] = data.items[i].skuId + '';
data2[encodeURIComponent('items[' + i + '' + '].count')] = data.items[i].count + '';
if (data.items[i].cartId) {
data2[encodeURIComponent('items[' + i + '' + '].cartId')] = data.items[i].cartId + '';
}
}
const queryString = Object.keys(data2)
.map((key) => key + '=' + data2[key])
.join('&');
return request2({
url: `trade/order/settlement?${queryString}`,
method: 'GET',
});
},
// 创建订单
createOrder: (data) => {
return request2({
url: `trade/order/create`,
method: 'POST',
data,
});
},
// 获得订单
getOrder: (id) => {
return request2({
url: `trade/order/get-detail`,
method: 'GET',
params: {
id,
},
});
},
// 订单列表
getOrderPage: (params) => {
return request({
url: '/app-api/trade/order/page',
method: 'GET',
params,
custom: {
showLoading: false,
},
});
},
// 确认收货
receiveOrder: (id) => {
return request2({
url: `/app-api/trade/order/receive`,
method: 'PUT',
params: {
id,
},
});
},
// 获得交易订单的物流轨迹
getOrderExpressTrackList: (id) => {
return request2({
url: `/app-api/trade/order/get-express-track-list`,
method: 'GET',
params: {
id,
},
});
}
};
export default OrderApi;
+123 -45
View File
@@ -1,10 +1,11 @@
import request from '@/sheep/request';
import request2 from '@/sheep/request2';
import $platform from '@/sheep/platform';
export default {
getUnused: () =>
request({
url: '/app-api/promotion/coupon/get-unused-count',
request2({
url: 'promotion/coupon/get-unused-count',
method: 'GET',
custom: {
showLoading: false,
@@ -12,8 +13,8 @@ export default {
},
}),
profile: () =>
request({
url: '/app-api/member/user/get',
request2({
url: 'member/user/get',
method: 'GET',
custom: {
showLoading: false,
@@ -21,7 +22,7 @@ export default {
},
}),
balance: () =>
request({
request2({
url: '/app-api/pay/wallet/get',
method: 'GET',
custom: {
@@ -29,9 +30,28 @@ export default {
auth: true,
},
}),
// profile: () =>
// request({
// url: '/user/api/user/profile',
// method: 'GET',
// custom: {
// showLoading: false,
// auth: true,
// },
// }),
// update: (data) =>
// request({
// url: '/user/api/user/update',
// method: 'POST',
// custom: {
// showSuccess: true,
// auth: true,
// },
// data,
// }),
update: (data) =>
request({
url: '/app-api/member/user/update',
request2({
url: 'member/user/update',
method: 'PUT',
custom: {
showSuccess: true,
@@ -176,48 +196,90 @@ export default {
}),
address: {
// default: () =>
// request({
// url: 'user/address/default',
// method: 'GET',
// custom: {
// showError: false,
// },
// }),
default: () =>
request({
url: '/app-api/member/address/get-default',
request2({
url: 'member/address/get-default',
method: 'GET',
custom: {
showError: false,
},
}),
list: () =>
request({
url: '/app-api/member/address/list',
request2({
url: 'member/address/list',
method: 'GET',
custom: {},
}),
// list: () =>
// request({
// url: 'user/address',
// method: 'GET',
// custom: {},
// }),
create: (data) =>
request({
url: '/app-api/member/address/create',
request2({
url: 'member/address/create',
method: 'POST',
data,
custom: {
showSuccess: true,
},
}),
// create: (data) =>
// request({
// url: 'user/address',
// method: 'POST',
// data,
// custom: {
// showSuccess: true,
// },
// }),
update: (data) =>
request({
url: '/app-api/member/address/update',
request2({
url: 'member/address/update',
method: 'PUT',
data,
custom: {
showSuccess: true,
},
}),
// update: (id, data) =>
// request({
// url: 'user/address/' + id,
// method: 'PUT',
// data,
// custom: {
// showSuccess: true,
// },
// }),
detail: (id) =>
request({
url: '/app-api/member/address/get?id=' + id,
request2({
url: 'member/address/get?id=' + id,
method: 'GET',
}),
// detail: (id) =>
// request({
// url: 'user/address/' + id,
// method: 'GET',
// }),
delete: (id) =>
request({
url: '/app-api/member/address/delete?id=' + id,
request2({
url: 'member/address/delete?id=' + id,
method: 'DELETE',
}),
// delete: (id) =>
// request({
// url: 'user/address/' + id,
// method: 'DELETE',
// }),
},
invoice: {
list: () =>
@@ -257,29 +319,17 @@ export default {
},
favorite: {
list: (params) =>
request({
url: '/app-api/product/favorite/page',
request2({
url: 'product/favorite/page',
method: 'GET',
params,
}),
do: (id) =>
request({
url: '/app-api/product/favorite/create',
url: 'user/goodsLog/favorite',
method: 'POST',
data: {
spuId: id,
},
custom: {
showSuccess: true,
auth: true,
},
}),
dos: (id) =>
request({
url: '/app-api/product/favorite/delete',
method: 'DELETE',
data: {
spuId: id,
goods_id: id,
},
custom: {
showSuccess: true,
@@ -288,8 +338,8 @@ export default {
}),
// 取消收藏
cancel: (id) =>
request({
url: '/app-api/product/favorite/delete-list',
request2({
url: 'product/favorite/delete-list',
method: 'DELETE',
data: {
spuIds: id.split(',').map(item => item * 1),
@@ -300,6 +350,18 @@ export default {
auth: true,
},
}),
// cancel: (id) =>
// request({
// url: 'user/goodsLog/favorite',
// method: 'POST',
// data: {
// goods_ids: id,
// },
// custom: {
// showSuccess: true,
// auth: true,
// },
// }),
},
view: {
list: (params) =>
@@ -321,21 +383,28 @@ export default {
},
wallet: {
log: (params) =>
request({
request2({
// url: 'member/point/record/page',
url: '/app-api/pay/wallet-transaction/page',
url: 'pay/wallet-transaction/page',
method: 'GET',
params,
custom: {},
}),
log2: (params) =>
request({
url: '/app-api/member/point/record/page',
request2({
url: 'member/point/record/page',
// url: 'pay/wallet-transaction/page',
method: 'GET',
params,
custom: {},
}),
// log: (params) =>
// request({
// url: '/user/api/walletLog',
// method: 'GET',
// params,
// custom: {},
// }),
},
account: {
info: (params) =>
@@ -360,9 +429,18 @@ export default {
}),
},
//数量接口
// data: () =>
// request({
// url: 'user/user/data',
// method: 'GET',
// custom: {
// showLoading: false,
// auth: true,
// },
// }),
data: () =>
request({
url: '/app-api/trade/order/get-count',
request2({
url: 'trade/order/get-count',
method: 'GET',
custom: {
showLoading: false,
@@ -370,8 +448,8 @@ export default {
},
}),
data2: () =>
request({
url: '/app-api/trade/after-sale/get-applying-count',
request2({
url: 'trade/after-sale/get-applying-count',
method: 'GET',
custom: {
showLoading: false,
+102 -98
View File
@@ -1,104 +1,108 @@
<template>
<su-popup :show="show" type="bottom" round="20" @close="emits('close')" showClose backgroundColor="#f2f2f2">
<view class="model-box">
<view class="title ss-m-t-16 ss-m-l-20 ss-flex">优惠券</view>
<scroll-view class="model-content" scroll-y :scroll-with-animation="false" :enable-back-to-top="true">
<view class="subtitle ss-m-l-20">可使用优惠券</view>
<view v-for="item in state.couponInfo" :key="item.id">
<s-coupon-list :data="item">
<template #default>
<button class="ss-reset-button card-btn ss-flex ss-row-center ss-col-center" :class="
<su-popup
:show="show"
type="bottom"
round="20"
@close="emits('close')"
showClose
backgroundColor="#f2f2f2"
>
<view class="model-box">
<view class="title ss-m-t-16 ss-m-l-20 ss-flex">优惠券</view>
<scroll-view
class="model-content"
scroll-y
:scroll-with-animation="false"
:enable-back-to-top="true"
>
<view class="subtitle ss-m-l-20">可使用优惠券</view>
<view v-for="item in state.couponInfo" :key="item.id">
<s-coupon-list :data="item">
<template #default>
<button
class="ss-reset-button card-btn ss-flex ss-row-center ss-col-center"
:class="
item.get_status != 'can_get' && item.get_status != 'can_use' ? 'boder-btn' : ''
" @click.stop="getBuy(item.id)">
<!-- 此处对接领取优惠券先将限制解除 -->
<!-- :disabled="item.get_status != 'can_get' && item.get_status != 'can_use'" -->
{{ item.get_status_text }}
</button>
</template>
</s-coupon-list>
</view>
</scroll-view>
</view>
</su-popup>
"
@click.stop="getBuy(item.id)"
:disabled="item.get_status != 'can_get' && item.get_status != 'can_use'"
>
{{ item.get_status_text }}
</button>
</template>
</s-coupon-list>
</view>
</scroll-view>
</view>
</su-popup>
</template>
<script setup>
import {
computed,
reactive
} from 'vue';
const props = defineProps({
modelValue: {
type: Object,
default () {},
},
show: {
type: Boolean,
default: false,
},
});
const emits = defineEmits(['get', 'close']);
const state = reactive({
couponInfo: computed(() => props.modelValue),
currentValue: -1,
couponId: '',
});
const getBuy = (id) => {
console.log('应该是详情页领取优惠券')
emits('get', id);
};
//立即领取
import { computed, reactive } from 'vue';
const props = defineProps({
modelValue: {
type: Object,
default() {},
},
show: {
type: Boolean,
default: false,
},
});
const emits = defineEmits(['get', 'close']);
const state = reactive({
couponInfo: computed(() => props.modelValue),
currentValue: -1,
couponId: '',
});
const getBuy = (id) => {
emits('get', id);
};
//立即领取
</script>
<style lang="scss" scoped>
.model-box {
height: 60vh;
.title {
font-size: 36rpx;
height: 80rpx;
font-weight: bold;
color: #333333;
}
.subtitle {
font-size: 26rpx;
font-weight: 500;
color: #333333;
}
}
.model-content {
height: 54vh;
}
.modal-footer {
width: 100%;
height: 120rpx;
background: #fff;
}
.confirm-btn {
width: 710rpx;
margin-left: 20rpx;
height: 80rpx;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
border-radius: 40rpx;
color: #fff;
}
// 优惠券按钮
.card-btn {
// width: 144rpx;
padding: 0 16rpx;
height: 50rpx;
border-radius: 40rpx;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
color: #ffffff;
font-size: 24rpx;
font-weight: 400;
}
.boder-btn {
background: linear-gradient(90deg, var(--ui-BG-Main-opacity-4), var(--ui-BG-Main-light));
color: #fff !important;
}
</style>
.model-box {
height: 60vh;
.title {
font-size: 36rpx;
height: 80rpx;
font-weight: bold;
color: #333333;
}
.subtitle {
font-size: 26rpx;
font-weight: 500;
color: #333333;
}
}
.model-content {
height: 54vh;
}
.modal-footer {
width: 100%;
height: 120rpx;
background: #fff;
}
.confirm-btn {
width: 710rpx;
margin-left: 20rpx;
height: 80rpx;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
border-radius: 40rpx;
color: #fff;
}
// 优惠券按钮
.card-btn {
// width: 144rpx;
padding: 0 16rpx;
height: 50rpx;
border-radius: 40rpx;
background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
color: #ffffff;
font-size: 24rpx;
font-weight: 400;
}
.boder-btn {
background: linear-gradient(90deg, var(--ui-BG-Main-opacity-4), var(--ui-BG-Main-light));
color: #fff !important;
}
</style>
@@ -1,9 +1,13 @@
<template>
<view class="ss-m-20" :style="{ opacity: disabled ? '0.5' : '1' }">
<view class="content">
<view class="tag ss-flex ss-row-center" :class="
<!-- <view
class="tag ss-flex ss-row-center"
:class="
data.status == 'expired' || data.status == 'used' ? 'disabled-bg-color' : 'info-bg-color'
">{{ data.type_text }}</view>
"
>{{ data.type_text }}</view
> -->
<view class="title ss-m-x-30 ss-p-t-18">
<view class="ss-flex ss-row-between">
<view class="value-text ss-flex-1 ss-m-r-10" :class="
@@ -1,4 +1,3 @@
<!-- 订单确认的优惠劵选择弹窗 -->
<template>
<su-popup
:show="show"
@@ -17,21 +16,20 @@
:enable-back-to-top="true"
>
<view class="subtitle ss-m-l-20">可使用优惠券</view>
<view v-for="(item, index) in state.couponInfo" :key="index">
<view v-for="(item, index) in state.couponInfo.can_use" :key="index">
<s-coupon-list :data="item" type="user" :disabled="false">
<template #default>
<label class="ss-flex ss-col-center" @tap="radioChange(item.id)">
<radio
color="var(--ui-BG-Main)"
style="transform: scale(0.8)"
:checked="state.couponId === item.id"
:checked="state.couponId == item.id"
@tap.stop="radioChange(item.id)"
/>
</label>
</template>
</s-coupon-list>
</view>
<!-- TODO 芋艿未来接口需要支持下
<view class="subtitle ss-m-t-40 ss-m-l-20">不可使用优惠券</view>
<view v-for="item in state.couponInfo.cannot_use" :key="item.id">
<s-coupon-list :data="item" type="user" :disabled="true">
@@ -43,7 +41,6 @@
</template>
</s-coupon-list>
</view>
-->
</scroll-view>
</view>
<view class="modal-footer ss-flex">
@@ -53,9 +50,8 @@
</template>
<script setup>
import { computed, reactive } from 'vue';
const props = defineProps({
modelValue: { // 优惠劵列表
modelValue: {
type: Object,
default() {},
},
@@ -64,27 +60,21 @@
default: false,
},
});
const emits = defineEmits(['confirm', 'close']);
const state = reactive({
couponInfo: computed(() => props.modelValue), // 优惠劵列表
couponId: 0, // 选中的优惠劵编号
couponInfo: computed(() => props.modelValue),
couponId: 0,
});
// 选中优惠劵
function radioChange(couponId) {
if (state.couponId === couponId) {
if (state.couponId == couponId) {
state.couponId = 0;
} else {
state.couponId = couponId;
}
}
// 确认优惠劵
const onConfirm = () => {
emits('confirm', state.couponId);
}
};
</script>
<style lang="scss" scoped>
:deep() {
@@ -26,7 +26,7 @@
:style="[{ color: priceColor }]"
v-if="price && Number(price) > 0"
>
{{ fen2yuan(price) }}
{{ price }}
</view>
<view v-if="score && Number(price) > 0">+</view>
<view class="price-text ss-flex ss-col-center" v-if="score">
@@ -54,7 +54,6 @@
<script setup>
import sheep from '@/sheep';
import { computed } from 'vue';
import { fen2yuan } from '../../hooks/useGoods';
/**
* 订单卡片
*
+152 -156
View File
@@ -1,19 +1,16 @@
<template>
<!-- 分享弹框 -->
<view>
<su-popup :show="state.showShareGuide" :showClose="false" @close="onCloseGuide"></su-popup>
<view v-if="state.showShareGuide" class="guide-wrap">
<image
class="guide-image"
:src="sheep.$url.static('/static/img/shop/share/share_guide.png')"
></image>
</view>
<!-- 分享弹框 -->
<view>
<su-popup :show="state.showShareGuide" :showClose="false" @close="onCloseGuide"></su-popup>
<view v-if="state.showShareGuide" class="guide-wrap">
<image class="guide-image" :src="sheep.$url.static('/static/img/shop/share/share_guide.png')"></image>
</view>
<su-popup :show="show" round="10" :showClose="false" @close="closeShareModal">
<!-- 分享tools -->
<view class="share-box">
<view class="share-list-box ss-flex">
<button
<su-popup :show="show" round="10" :showClose="false" @close="closeShareModal">
<!-- 分享tools -->
<view class="share-box">
<view class="share-list-box ss-flex">
<!-- <button
v-if="shareConfig.methods.includes('forward')"
class="share-item share-btn ss-flex-col ss-col-center"
open-type="share"
@@ -25,20 +22,14 @@
mode=""
></image>
<text class="share-title">微信好友</text>
</button>
<button
v-if="shareConfig.methods.includes('poster')"
class="share-item share-btn ss-flex-col ss-col-center"
@tap="onShareByPoster"
>
<image
class="share-img"
:src="sheep.$url.static('/static/img/shop/share/share_poster.png')"
mode=""
></image>
<text class="share-title">生成海报</text>
</button>
</button> -->
<button v-if="shareConfig.methods.includes('poster')"
class="share-item share-btn ss-flex-col ss-col-center" @tap="onShareByPoster">
<image class="share-img" :src="sheep.$url.static('/static/img/shop/share/share_poster.png')"
mode=""></image>
<text class="share-title">生成海报</text>
</button>
<!--
<button
v-if="shareConfig.methods.includes('link')"
class="share-item share-btn ss-flex-col ss-col-center"
@@ -50,152 +41,157 @@
mode=""
></image>
<text class="share-title">复制链接</text>
</button>
</view>
<view class="share-foot ss-flex ss-row-center ss-col-center" @tap="closeShareModal">
取消
</view>
</view>
</su-popup>
<!-- 分享海报 -->
<canvas-poster
ref="SharePosterRef"
:show="state.showPosterModal"
:shareInfo="shareInfo"
@close="state.showPosterModal = false"
/>
</view>
</button> -->
</view>
<view class="share-foot ss-flex ss-row-center ss-col-center" @tap="closeShareModal">
取消
</view>
</view>
</su-popup>
<!-- 分享海报 -->
<canvas-poster ref="SharePosterRef" :show="state.showPosterModal" :shareInfo="shareInfo"
@close="state.showPosterModal = false" />
</view>
</template>
<script setup>
/**
* 分享弹窗
*/
import { ref, unref, reactive, computed } from 'vue';
import sheep from '@/sheep';
import canvasPoster from './canvas-poster/index.vue';
import { showShareModal, closeShareModal, showAuthModal } from '@/sheep/hooks/useModal';
/**
* 分享弹窗
*/
import {
ref,
unref,
reactive,
computed
} from 'vue';
import sheep from '@/sheep';
import canvasPoster from './canvas-poster/index.vue';
import {
showShareModal,
closeShareModal,
showAuthModal
} from '@/sheep/hooks/useModal';
const show = computed(() => sheep.$store('modal').share);
const shareConfig = computed(() => sheep.$store('app').platform.share);
const SharePosterRef = ref('');
const show = computed(() => sheep.$store('modal').share);
const shareConfig = computed(() => sheep.$store('app').platform.share);
const SharePosterRef = ref('');
const props = defineProps({
shareInfo: {
type: Object,
default() {},
},
});
const props = defineProps({
shareInfo: {
type: Object,
default () {},
},
});
const state = reactive({
showShareGuide: false, //H5的指引。
showPosterModal: false, //海报弹窗
});
const state = reactive({
showShareGuide: false, //H5的指引。
showPosterModal: false, //海报弹窗
});
// 生成海报分享
const onShareByPoster = () => {
closeShareModal();
if (!sheep.$store('user').isLogin) {
showAuthModal();
return;
}
unref(SharePosterRef).getPoster();
state.showPosterModal = true;
};
// 生成海报分享
const onShareByPoster = () => {
closeShareModal();
if (!sheep.$store('user').isLogin) {
showAuthModal();
return;
}
unref(SharePosterRef).getPoster();
state.showPosterModal = true;
};
// 直接转发分享
const onShareByForward = () => {
closeShareModal();
// 直接转发分享
const onShareByForward = () => {
closeShareModal();
// #ifdef H5
if (['WechatOfficialAccount', 'H5'].includes(sheep.$platform.name)) {
state.showShareGuide = true;
return;
}
// #endif
// #ifdef H5
if (['WechatOfficialAccount', 'H5'].includes(sheep.$platform.name)) {
state.showShareGuide = true;
return;
}
// #endif
// #ifdef APP-PLUS
uni.share({
provider: 'weixin',
scene: 'WXSceneSession',
type: 0,
href: props.shareInfo.link,
title: props.shareInfo.title,
summary: props.shareInfo.desc,
imageUrl: props.shareInfo.image,
success: (res) => {
console.log('success:' + JSON.stringify(res));
},
fail: (err) => {
console.log('fail:' + JSON.stringify(err));
},
});
// #endif
};
// #ifdef APP-PLUS
uni.share({
provider: 'weixin',
scene: 'WXSceneSession',
type: 0,
href: props.shareInfo.link,
title: props.shareInfo.title,
summary: props.shareInfo.desc,
imageUrl: props.shareInfo.image,
success: (res) => {
console.log('success:' + JSON.stringify(res));
},
fail: (err) => {
console.log('fail:' + JSON.stringify(err));
},
});
// #endif
};
// 复制链接分享
const onShareByCopyLink = () => {
sheep.$helper.copyText(props.shareInfo.link);
closeShareModal();
};
// 复制链接分享
const onShareByCopyLink = () => {
sheep.$helper.copyText(props.shareInfo.link);
closeShareModal();
};
function onCloseGuide() {
state.showShareGuide = false;
}
function onCloseGuide() {
state.showShareGuide = false;
}
</script>
<style lang="scss" scoped>
.guide-image {
right: 30rpx;
top: 0;
position: fixed;
width: 580rpx;
height: 430rpx;
z-index: 10080;
}
.guide-image {
right: 30rpx;
top: 0;
position: fixed;
width: 580rpx;
height: 430rpx;
z-index: 10080;
}
// 分享tool
.share-box {
background: $white;
width: 750rpx;
border-radius: 30rpx 30rpx 0 0;
padding-top: 30rpx;
// 分享tool
.share-box {
background: $white;
width: 750rpx;
border-radius: 30rpx 30rpx 0 0;
padding-top: 30rpx;
.share-foot {
font-size: 24rpx;
color: $gray-b;
height: 80rpx;
border-top: 1rpx solid $gray-e;
}
.share-foot {
font-size: 24rpx;
color: $gray-b;
height: 80rpx;
border-top: 1rpx solid $gray-e;
}
.share-list-box {
.share-btn {
background: none;
border: none;
line-height: 1;
padding: 0;
.share-list-box {
.share-btn {
background: none;
border: none;
line-height: 1;
padding: 0;
&::after {
border: none;
}
}
&::after {
border: none;
}
}
.share-item {
flex: 1;
padding-bottom: 20rpx;
.share-item {
flex: 1;
padding-bottom: 20rpx;
.share-img {
width: 70rpx;
height: 70rpx;
background: $gray-f;
border-radius: 50%;
margin-bottom: 20rpx;
}
.share-img {
width: 70rpx;
height: 70rpx;
background: $gray-f;
border-radius: 50%;
margin-bottom: 20rpx;
}
.share-title {
font-size: 24rpx;
color: $dark-6;
}
}
}
}
</style>
.share-title {
font-size: 24rpx;
color: $dark-6;
}
}
}
}
</style>
+33 -99
View File
@@ -3,20 +3,19 @@ import sheep from '@/sheep';
import $wxsdk from '@/sheep/libs/sdk-h5-weixin';
// #endif
import { getRootUrl } from '@/sheep/helper';
import PayOrderApi from '@/sheep/api/pay/order';
/**
* 支付
*
* @param {String} payment = ['wechat','alipay','wallet','offline'] - 支付方式
* @param {String} orderType = ['goods','recharge','groupon'] - 订单类型
* @param {String} id - 订单号
* @param {String} orderSN - 订单号
*/
export default class SheepPay {
constructor(payment, orderType, id) {
constructor(payment, orderType, orderSN) {
this.payment = payment;
this.id = id;
this.orderSN = orderSN;
this.orderType = orderType;
this.payAction();
}
@@ -30,8 +29,8 @@ export default class SheepPay {
alipay: () => {
this.redirectPay(); // 现在公众号可以直接跳转支付宝页面
},
wallet: () => {
this.walletPay();
money: () => {
this.moneyPay();
},
offline: () => {
this.offlinePay();
@@ -44,8 +43,8 @@ export default class SheepPay {
alipay: () => {
this.copyPayLink();
},
wallet: () => {
this.walletPay();
money: () => {
this.moneyPay();
},
offline: () => {
this.offlinePay();
@@ -58,8 +57,8 @@ export default class SheepPay {
alipay: () => {
this.alipay();
},
wallet: () => {
this.walletPay();
money: () => {
this.moneyPay();
},
offline: () => {
this.offlinePay();
@@ -72,8 +71,8 @@ export default class SheepPay {
alipay: () => {
this.redirectPay();
},
wallet: () => {
this.walletPay();
money: () => {
this.moneyPay();
},
offline: () => {
this.offlinePay();
@@ -84,21 +83,18 @@ export default class SheepPay {
}
// 预支付
prepay(channel) {
prepay() {
return new Promise((resolve, reject) => {
let data = {
id: this.id,
channelCode: channel,
channelExtras: {}
order_sn: this.orderSN,
payment: this.payment,
};
if (uni.getStorageSync('openid')) {
data.openid = uni.getStorageSync('openid');
}
PayOrderApi.submitOrder(data).then((res) => {
// 成功时
res.code === 0 && resolve(res);
// 失败时
if (res.code !== 0 && res.msg === 'miss_openid') {
sheep.$api.pay.prepay(data).then((res) => {
res.error === 0 && resolve(res);
if (res.error === -1 && res.msg === 'miss_openid') {
uni.showModal({
title: '微信支付',
content: '请先绑定微信再使用微信支付',
@@ -113,7 +109,7 @@ export default class SheepPay {
});
}
// #ifdef H5
// 微信公众号JSSDK支付 TODO 芋艿:待接入
// 微信公众号JSSDK支付
async wechatOfficialAccountPay() {
let that = this;
let { error, data, msg } = await this.prepay();
@@ -134,21 +130,21 @@ export default class SheepPay {
});
}
//浏览器微信H5支付 TODO 芋艿:待接入
//浏览器微信H5支付
async wechatWapPay() {
const { error, data } = await this.prepay();
if (error === 0) {
const redirect_url = `${getRootUrl()}pages/pay/result?id=${this.id}&payment=${this.payment
const redirect_url = `${getRootUrl()}pages/pay/result?orderSN=${this.orderSN}&payment=${this.payment
}&orderType=${this.orderType}`;
location.href = `${data.pay_data.h5_url}&redirect_url=${encodeURIComponent(redirect_url)}`;
}
}
// 支付链接 TODO 芋艿:待接入
// 支付链接
async redirectPay() {
let { error, data } = await this.prepay();
if (error === 0) {
const redirect_url = `${getRootUrl()}pages/pay/result?id=${this.id}&payment=${this.payment
const redirect_url = `${getRootUrl()}pages/pay/result?orderSN=${this.orderSN}&payment=${this.payment
}&orderType=${this.orderType}`;
location.href = data.pay_data + encodeURIComponent(redirect_url);
}
@@ -156,7 +152,7 @@ export default class SheepPay {
// #endif
// 微信小程序支付 TODO 芋艿:待接入
// 微信小程序支付
async wechatMiniProgramPay() {
let that = this;
let result = await this.prepay();
@@ -177,18 +173,18 @@ export default class SheepPay {
}
// 余额支付
async walletPay() {
const { code } = await this.prepay('wallet');
code === 0 && this.payResult('success');
async moneyPay() {
const { error } = await this.prepay();
error === 0 && this.payResult('success');
}
// 货到付款 TODO 芋艿:待接入
// 货到付款
async offlinePay() {
const { error } = await this.prepay();
error === 0 && this.payResult('success');
}
// 支付宝复制链接支付 TODO 芋艿:待接入
// 支付宝复制链接支付
async copyPayLink() {
let that = this;
let { error, data } = await this.prepay();
@@ -207,7 +203,7 @@ export default class SheepPay {
}
}
// 支付宝支付 TODO 芋艿:待接入
// 支付宝支付
async alipay() {
let that = this;
const { error, data } = await this.prepay();
@@ -229,7 +225,7 @@ export default class SheepPay {
}
}
// 微信支付 TODO 芋艿:待接入
// 微信支付
async wechatAppPay() {
let that = this;
let { error, data } = await this.prepay();
@@ -250,72 +246,10 @@ export default class SheepPay {
// 支付结果跳转,success:成功,fail:失败
payResult(resultType) {
sheep.$router.redirect('/pages/pay/result', {
id: this.id,
orderSN: this.orderSN,
payment: this.payment, //重新支付的时候使用
payState: resultType,
orderType: this.orderType,
payState: resultType
});
}
}
export function getPayMethods(channels) {
const payMethods = [
{
icon: '/static/img/shop/pay/wechat.png',
title: '微信支付',
value: 'wechat',
disabled: true,
},
{
icon: '/static/img/shop/pay/alipay.png',
title: '支付宝支付',
value: 'alipay',
disabled: true,
},
{
icon: '/static/img/shop/pay/wallet.png',
title: '余额支付',
value: 'wallet',
disabled: true,
},
{
icon: '/static/img/shop/pay/apple.png',
title: 'Apple Pay',
value: 'apple',
disabled: true,
},
{
icon: '/static/img/shop/pay/wallet.png',
title: '模拟支付',
value: 'mock',
disabled: true,
}
];
const platform = sheep.$platform.name
// 1. 处理【微信支付】
const wechatMethod = payMethods[0];
if ((platform === 'WechatOfficialAccount' && channels.includes('wx_pub'))
|| platform === 'WechatMiniProgram' && channels.includes('wx_lite')
|| platform === 'App' && channels.includes('wx_app')) {
wechatMethod.disabled = false;
}
// 2. 处理【支付宝支付】
const alipayMethod = payMethods[1];
if ((platform === 'WechatOfficialAccount' && channels.includes('alipay_wap'))
|| platform === 'WechatMiniProgram' && channels.includes('alipay_wap')
|| platform === 'App' && channels.includes('alipay_app')) {
alipayMethod.disabled = false;
}
// 3. 处理【余额支付】
const walletMethod = payMethods[2];
if (channels.includes('wallet')) {
walletMethod.disabled = false;
}
// 4. 处理【苹果支付】TODO 芋艿:未来接入
// 5. 处理【模拟支付】
const mockMethod = payMethods[4];
if (channels.includes('mock')) {
mockMethod.disabled = false;
}
return payMethods;
}
+1 -3
View File
@@ -55,8 +55,7 @@ const http = new Request({
method: 'GET',
header: {
Accept: 'text/json',
'Content-Type': 'application/json',
// ;charset=UTF-8
'Content-Type': 'application/json;charset=UTF-8',
platform: $platform.name,
},
// #ifdef APP-PLUS
@@ -99,7 +98,6 @@ http.interceptors.request.use(
config.header['terminal'] = '20';
config.header['Authorization'] = 'Bearer test247';
}
// console.log(config, '看参数')
return config;
},
(error) => {
+2 -2
View File
@@ -23,8 +23,8 @@ const app = defineStore({
copytime: '', // 版权信息 II
},
platform: {
payment: [], // 支持的支付方式 TODO 芋艿:可删除
recharge_payment: [], // 支持的充值支付方式 TODO 芋艿:可删除
payment: [], // 支持的支付方式
recharge_payment: [], // 支持的充值支付方式
share: {
methods: [], // 支持的分享方式
forwardInfo: {}, // 默认转发信息
+54 -49
View File
@@ -1,93 +1,98 @@
import { defineStore } from 'pinia';
import CartApi from '@/sheep/api/trade/cart';
import cartApi from '@/sheep/api/cart';
const cart = defineStore({
id: 'cart',
state: () => ({
list: [], // 购物车列表
selectedIds: [], // 已选列表
isAllSelected: false, // 是否全选
totalPriceSelected: 0, // 选中项总金额
isAllSelected: false, //是否全选
cartSelectedTotalPrice: '0.00', // 选中项总金额
}),
getters: {
totalPriceSelected: (state) => {
let price = 0;
if (!state.selectedIds.length) return price.toFixed(2);
state.list.forEach((item) => {
price += state.selectedIds.includes(item.id)
? Number(item.sku.price/100) * item.count
: 0;
});
return price.toFixed(2);
},
},
actions: {
// 获取购物车列表
async getList() {
const { data, code } = await CartApi.getCartList();
const { data, code } = await cartApi.list();
if (code === 0) {
this.list = data.validList;
// 计算各种关联属性
this.selectedIds = [];
this.isAllSelected = true;
this.totalPriceSelected = 0;
this.list.forEach((item) => {
if (item.selected) {
this.selectedIds.push(item.id);
this.totalPriceSelected += item.count * item.sku.price;
} else {
this.isAllSelected = false;
}
});
}
},
// 添加购物车
async add(goodsInfo) {
// 添加购物项
const { code } = await CartApi.addCart({
skuId: goodsInfo.id,
count: goodsInfo.goods_num,
const { error } = await cartApi.append({
goods_id: goodsInfo.goods_id,
goods_num: goodsInfo.goods_num,
goods_sku_price_id: goodsInfo.id,
});
// 刷新购物车列表
if (code === 0) {
await this.getList();
if (error === 0) {
this.getList();
}
},
// 更新购物车
async update(goodsInfo) {
const { code } = await CartApi.updateCartCount({
const { error } = await cartApi.update({
id: goodsInfo.goods_id,
count: goodsInfo.goods_num,
goods_sku_price_id: goodsInfo.goods_sku_price_id,
});
if (code === 0) {
await this.getList();
if (error === 0) {
// this.getList();
}
},
// 移除购物车
async delete(ids) {
const { code } = await CartApi.deleteCart(ids.join(','));
if (typeof ids === 'array') {
ids = ids.join(',');
}
const { code } = await cartApi.delete(ids);
if (code === 0) {
await this.getList();
this.selectAll(false);
this.getList();
}
},
// 选购物车商品
async selectSingle(goodsId) {
const { code } = await CartApi.updateCartSelected({
ids: [goodsId],
selected: !this.selectedIds.includes(goodsId), // 取反
});
if (code === 0) {
await this.getList();
// 选购物车商品
selectSingle(goodsId) {
if (!this.selectedIds.includes(goodsId)) {
this.selectedIds.push(goodsId);
} else {
this.selectedIds.splice(this.selectedIds.indexOf(goodsId), 1);
}
this.isAllSelected = this.selectedIds.length === this.list.length;
},
// 全选购物车商品
async selectAll(flag) {
const { code } = await CartApi.updateCartSelected({
ids: this.list.map((item) => item.id),
selected: flag
});
if (code === 0) {
await this.getList();
// 全选
selectAll(flag) {
this.isAllSelected = flag;
if (!flag) {
this.selectedIds = [];
} else {
this.list.forEach((item) => {
this.selectedIds.push(item.id);
});
}
},
// 清空购物车
async emptyList() {
await this.delete(this.list.map((item) => item.id));
emptyList() {
this.list = [];
this.selectedIds = [];
this.isAllSelected = false;
this.cartSelectedTotalPrice = '0.00';
},
},
persist: {
@@ -100,4 +105,4 @@ const cart = defineStore({
},
});
export default cart;
export default cart;