接口层兼容

pull/26/head
落日晚风 2023-12-12 16:13:27 +08:00
parent ef26268c8e
commit cf2c782c0e
13 changed files with 212 additions and 207 deletions

View File

@ -1,41 +1,41 @@
<template> <template>
<s-layout <s-layout title="我的" tabbar="/pages/index/user" navbar="custom" :bgStyle="template.page"
title="我的" :navbarStyle="template.style?.navbar" onShareAppMessage>
tabbar="/pages/index/user" <s-block v-for="(item, index) in template.components" :key="index" :styles="item.property.style">
navbar="custom" <s-block-item :type="item.id" :data="item.property" :styles="item.property.style" />
:bgStyle="template.page" </s-block>
:navbarStyle="template.style?.navbar" </s-layout>
onShareAppMessage
>
<s-block v-for="(item, index) in template.components" :key="index" :styles="item.property.style">
<s-block-item :type="item.id" :data="item.property" :styles="item.property.style" />
</s-block>
</s-layout>
</template> </template>
<script setup> <script setup>
import { computed } from 'vue'; import {
import { onShow, onPageScroll, onPullDownRefresh } from '@dcloudio/uni-app'; computed
import sheep from '@/sheep'; } from 'vue';
import {
onShow,
onPageScroll,
onPullDownRefresh
} from '@dcloudio/uni-app';
import sheep from '@/sheep';
// tabBar // tabBar
uni.hideTabBar(); uni.hideTabBar();
const template = computed(() => sheep.$store('app').template.user); const template = computed(() => sheep.$store('app').template.user);
const isLogin = computed(() => sheep.$store('user').isLogin); const isLogin = computed(() => sheep.$store('user').isLogin);
onShow(() => { onShow(() => {
sheep.$store('user').updateUserData(); sheep.$store('user').updateUserData();
}); });
onPullDownRefresh(() => { onPullDownRefresh(() => {
sheep.$store('user').updateUserData(); sheep.$store('user').updateUserData();
setTimeout(function () { setTimeout(function() {
uni.stopPullDownRefresh(); uni.stopPullDownRefresh();
}, 800); }, 800);
}); });
onPageScroll(() => {}); onPageScroll(() => {});
</script> </script>
<style></style> <style></style>

View File

@ -1,10 +1,9 @@
import request from '@/sheep/request'; import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default { export default {
list: (data) => list: (data) =>
request2({ request({
url: 'trade/cart/list', url: '/app-api/trade/cart/list',
method: 'GET', method: 'GET',
custom: { custom: {
showLoading: false, showLoading: false,
@ -12,7 +11,7 @@ export default {
}, },
}), }),
append: (data) => append: (data) =>
request2({ request({
url: '/app-api/trade/cart/add', url: '/app-api/trade/cart/add',
method: 'POST', method: 'POST',
custom: { custom: {
@ -39,13 +38,13 @@ export default {
// }), // }),
// 删除购物车 // 删除购物车
delete: (ids) => delete: (ids) =>
request2({ request({
url: 'trade/cart/delete?ids=' + ids, url: '/app-api/trade/cart/delete?ids=' + ids,
method: 'DELETE', method: 'DELETE',
}), }),
update: (data) => update: (data) =>
request2({ request({
url: 'trade/cart/update-count', url: '/app-api/trade/cart/update-count',
method: 'PUT', method: 'PUT',
data: { data: {
...data, ...data,

View File

@ -1,10 +1,8 @@
import request2 from '@/sheep/request2';
export default { export default {
list: (params) => list: (params) =>
request2({ request({
url: 'product/category/list', url: '/app-api/product/category/list',
method: 'GET', method: 'GET',
params, params,
}), }),
}; };

View File

@ -1,5 +1,4 @@
import request from '@/sheep/request'; import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default { export default {
// 我的拼团 // 我的拼团
@ -13,8 +12,8 @@ export default {
}, },
}), }),
userCoupon: (params) => userCoupon: (params) =>
request2({ request({
url: 'promotion/coupon/page', url: '/app-api/promotion/coupon/page',
method: 'GET', method: 'GET',
params, params,
}), }),
@ -33,8 +32,8 @@ export default {
}, },
}), }),
get: (id) => get: (id) =>
request2({ request({
url: 'promotion/coupon/take', url: '/app-api/promotion/coupon/take',
method: 'POST', method: 'POST',
data: { data: {
templateId: id templateId: id

View File

@ -1,25 +1,24 @@
import request from '@/sheep/request'; import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default { export default {
area: () => area: () =>
request2({ request({
url: 'system/area/tree', url: '/app-api/system/area/tree',
method: 'GET', method: 'GET',
}), }),
// area: () => // area: () =>
// request({ // request({
// url: 'data/area', // url: 'data/area',
// method: 'GET', // method: 'GET',
// }), // }),
faq: () => faq: () =>
request({ request({
url: 'data/faq', url: 'data/faq',
method: 'GET', method: 'GET',
}), }),
richtext: (id) => richtext: (id) =>
request({ request({
url: 'data/richtext/' + id, url: 'data/richtext/' + id,
method: 'GET', method: 'GET',
}), }),
}; };

View File

@ -1,5 +1,4 @@
import request from '@/sheep/request'; import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default { export default {
// 商品详情 // 商品详情

View File

@ -1,14 +1,14 @@
import request2 from '@/sheep/request2'; import request from '@/sheep/request';
export default { export default {
decorate: () => decorate: () =>
request2({ request({
url: 'promotion/decorate/list?page=1', url: '/app-api/promotion/decorate/list?page=1',
method: 'GET', method: 'GET',
}), }),
spids: () => spids: () =>
request2({ request({
url: 'product/spu/page?recommendType=best&pageNo=1&pageSize=10', url: '/app-api/product/spu/page?recommendType=best&pageNo=1&pageSize=10',
method: 'GET', method: 'GET',
}), }),
}; };

View File

@ -1,11 +1,10 @@
import request from '@/sheep/request'; import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default { export default {
// 订单详情 // 订单详情
detail: (id, params) => detail: (id, params) =>
request2({ request({
url: 'trade/order/get-detail?id=' + id, url: '/app-api/trade/order/get-detail?id=' + id,
method: 'GET', method: 'GET',
params, params,
}), }),
@ -40,8 +39,8 @@ export default {
}), }),
// 订单列表 // 订单列表
list: (params) => list: (params) =>
request2({ request({
url: 'trade/order/page', url: '/app-api/trade/order/page',
method: 'GET', method: 'GET',
params, params,
custom: { custom: {
@ -66,9 +65,9 @@ export default {
delete data2.items delete data2.items
for (let i = 0; i < data.items.length; i++) { for (let i = 0; i < data.items.length; i++) {
// 此处转码问题,待解决方案 // 此处转码问题,待解决方案
// data2[encodeURIComponent('items[' + i + '' + '].skuId')] = data.items[i].skuId + ''; data2[encodeURIComponent('items[' + i + '' + '].skuId')] = data.items[i].skuId + '';
// data2[encodeURIComponent('items[' + i + '' + '].count')] = data.items[i].count + ''; data2[encodeURIComponent('items[' + i + '' + '].count')] = data.items[i].count + '';
// data2[encodeURIComponent('items[' + i + '' + '].cartId')] = data.items[i].cartId + ''; data2[encodeURIComponent('items[' + i + '' + '].cartId')] = data.items[i].cartId + '';
// data2['items' + `[${i}]` + '.skuId'] = data.items[i].skuId + ''; // data2['items' + `[${i}]` + '.skuId'] = data.items[i].skuId + '';
// data2['items' + `[${i}]` + '.count'] = data.items[i].count + ''; // data2['items' + `[${i}]` + '.count'] = data.items[i].count + '';
@ -79,8 +78,8 @@ export default {
// data2['items' + `%5B${i}%5D` + '.cartId'] = data.items[i].cartId + ''; // data2['items' + `%5B${i}%5D` + '.cartId'] = data.items[i].cartId + '';
} }
console.log(data2, '手动转码的参数') console.log(data2, '手动转码的参数')
return request2({ return request({
url: 'trade/order/settlement', url: '/app-api/trade/order/settlement',
method: 'GET', method: 'GET',
// data: data2, // data: data2,
params: data2 params: data2
@ -114,8 +113,8 @@ export default {
}), }),
// 评价订单 // 评价订单
comment: (data) => comment: (data) =>
request2({ request({
url: 'trade/order/item/create-comment', url: '/app-api/trade/order/item/create-comment',
method: 'POST', method: 'POST',
data, data,
}), }),
@ -153,8 +152,8 @@ export default {
data, data,
}), }),
list: (params) => list: (params) =>
request2({ request({
url: 'trade/after-sale/page', url: '/app-api/trade/after-sale/page',
method: 'GET', method: 'GET',
params, params,
custom: { custom: {
@ -184,8 +183,8 @@ export default {
}), }),
// 售后详情 // 售后详情
detail: (id) => detail: (id) =>
request2({ request({
url: 'trade/after-sale/get?id=' + id, url: '/app-api/trade/after-sale/get?id=' + id,
method: 'GET', method: 'GET',
}), }),
}, },

View File

@ -1,16 +1,16 @@
import request2 from '@/sheep/request2'; import request from '@/sheep/request';
const ActivityApi = { const ActivityApi = {
// 获得单个商品,近期参与的每个活动 // 获得单个商品,近期参与的每个活动
getActivityListBySpuId: (spuId) => { getActivityListBySpuId: (spuId) => {
return request2({ return request({
url: '/app-api/promotion/activity/list-by-spu-id', url: '/app-api/promotion/activity/list-by-spu-id',
method: 'GET', method: 'GET',
params: { params: {
spuId, spuId,
}, },
}); });
}, },
}; };
export default ActivityApi; export default ActivityApi;

View File

@ -1,67 +1,69 @@
import request2 from "@/sheep/request2"; import request from "@/sheep/request";
// 拼团 API // 拼团 API
const CombinationApi = { const CombinationApi = {
// 获得拼团活动列表 // 获得拼团活动列表
getCombinationActivityList: (count) => { getCombinationActivityList: (count) => {
return request2({ return request({
url: "promotion/combination-activity/list", url: "/app-api/promotion/combination-activity/list",
method: 'GET', method: 'GET',
params: {count} params: {
}); count
}, }
});
},
// 获得拼团活动分页 // 获得拼团活动分页
getCombinationActivityPage: (params) => { getCombinationActivityPage: (params) => {
return request2({ return request({
url: "promotion/combination-activity/page", url: "/app-api/promotion/combination-activity/page",
method: 'GET', method: 'GET',
params params
}); });
}, },
// 获得拼团活动明细 // 获得拼团活动明细
getCombinationActivity: (id) => { getCombinationActivity: (id) => {
return request2({ return request({
url: "promotion/combination-activity/get-detail", url: "/app-api/promotion/combination-activity/get-detail",
method: 'GET', method: 'GET',
params: { params: {
id id
} }
}); });
}, },
// 获得最近 n 条拼团记录(团长发起的) // 获得最近 n 条拼团记录(团长发起的)
getHeadCombinationRecordList: (activityId, status, count) => { getHeadCombinationRecordList: (activityId, status, count) => {
return request2({ return request({
url: "promotion/combination-record/get-head-list", url: "/app-api/promotion/combination-record/get-head-list",
method: 'GET', method: 'GET',
params: { params: {
activityId, activityId,
status, status,
count count
} }
}); });
}, },
// 获得拼团记录明细 // 获得拼团记录明细
getCombinationRecordDetail: (id) => { getCombinationRecordDetail: (id) => {
return request2({ return request({
url: "promotion/combination-record/get-detail", url: "/app-api/promotion/combination-record/get-detail",
method: 'GET', method: 'GET',
params: { params: {
id id
} }
}); });
}, },
// 获得拼团记录的概要信息 // 获得拼团记录的概要信息
getCombinationRecordSummary: () => { getCombinationRecordSummary: () => {
return request2({ return request({
url: "promotion/combination-record/get-summary", url: "/app-api/promotion/combination-record/get-summary",
method: 'GET', method: 'GET',
}); });
} }
} }
export default CombinationApi export default CombinationApi

View File

@ -1,5 +1,4 @@
import request from '@/sheep/request'; import request from '@/sheep/request';
import request2 from '@/sheep/request2';
export default { export default {
// 获得优惠劵模板列表 // 获得优惠劵模板列表
@ -14,8 +13,8 @@ export default {
}, },
// 获得优惠劵模版列表 // 获得优惠劵模版列表
getCouponTemplateList: (params) => { getCouponTemplateList: (params) => {
return request2({ return request({
url: `promotion/coupon/match-list?price=${params.price}&spuIds=${params.spuIds}&skuIds=${params.skuIds}&categoryIds=${params.categoryIds}`, url: `/app-api/promotion/coupon/match-list?price=${params.price}&spuIds=${params.spuIds}&skuIds=${params.skuIds}&categoryIds=${params.categoryIds}`,
method: 'GET', method: 'GET',
// params, // params,
}); });

View File

@ -1,33 +1,44 @@
import request2 from "@/sheep/request2"; import request from "@/sheep/request";
const SeckillApi = { const SeckillApi = {
// 获得秒杀时间段列表 // 获得秒杀时间段列表
getSeckillConfigList: () => { getSeckillConfigList: () => {
return request2({ url: 'promotion/seckill-config/list', method: 'GET' }); return request({
}, url: '/app-api/promotion/seckill-config/list',
method: 'GET'
});
},
// 获得当前秒杀活动 // 获得当前秒杀活动
getNowSeckillActivity: () => { getNowSeckillActivity: () => {
return request2({ url: 'promotion/seckill-activity/get-now', method: 'GET' }); return request({
}, url: '/app-api/promotion/seckill-activity/get-now',
method: 'GET'
});
},
// 获得秒杀活动分页 // 获得秒杀活动分页
getSeckillActivityPage: () => { getSeckillActivityPage: () => {
return request2({ url: 'promotion/seckill-activity/page', method: 'GET' }); return request({
}, url: '/app-api/promotion/seckill-activity/page',
method: 'GET'
});
},
/** /**
* 获得秒杀活动明细 * 获得秒杀活动明细
* @param {number} id 秒杀活动编号 * @param {number} id 秒杀活动编号
* @return {*} * @return {*}
*/ */
getSeckillActivity: (id) => { getSeckillActivity: (id) => {
return request2({ return request({
url: 'promotion/seckill-activity/get-detail', url: '/app-api/promotion/seckill-activity/get-detail',
method: 'GET', method: 'GET',
params: { id } params: {
}); id
} }
});
}
} }
export default SeckillApi; export default SeckillApi;

View File

@ -7,7 +7,7 @@ const config = {
// 信任的标签(保持标签名不变) // 信任的标签(保持标签名不变)
trustTags: makeMap( trustTags: makeMap(
'a,abbr,ad,audio,b,blockquote,br,code,col,colgroup,dd,del,dl,dt,div,em,fieldset,h1,h2,h3,h4,h5,h6,hr,i,img,ins,label,legend,li,ol,p,q,ruby,rt,source,span,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,title,ul,video' 'a,abbr,ad,audio,b,blockquote,br,code,col,colgroup,dd,del,dl,dt,div,em,fieldset,h1,h2,h3,h4,h5,h6,hr,i,img,ins,label,legend,li,ol,p,q,ruby,rt,source,span,strong,sub,sup,table,tbody,td,tfoot,th,thead,tr,title,ul,video'
), ),
// 块级标签(转为 div其他的非信任标签转为 span // 块级标签(转为 div其他的非信任标签转为 span
blockTags: makeMap('address,article,aside,body,caption,center,cite,footer,header,html,nav,pre,section'), blockTags: makeMap('address,article,aside,body,caption,center,cite,footer,header,html,nav,pre,section'),
@ -20,12 +20,12 @@ const config = {
// 要移除的标签 // 要移除的标签
ignoreTags: makeMap( ignoreTags: makeMap(
'area,base,canvas,embed,frame,head,iframe,input,link,map,meta,param,rp,script,source,style,textarea,title,track,wbr' 'area,base,canvas,embed,frame,head,iframe,input,link,map,meta,param,rp,script,source,style,textarea,title,track,wbr'
), ),
// 自闭合的标签 // 自闭合的标签
voidTags: makeMap( voidTags: makeMap(
'area,base,br,col,circle,ellipse,embed,frame,hr,img,input,line,link,meta,param,path,polygon,rect,source,track,use,wbr' 'area,base,br,col,circle,ellipse,embed,frame,hr,img,input,line,link,meta,param,path,polygon,rect,source,track,use,wbr'
), ),
// html 实体 // html 实体
entities: { entities: {
@ -364,7 +364,7 @@ Parser.prototype.onAttrName = function(name) {
* @private * @private
*/ */
Parser.prototype.onAttrVal = function(val) { Parser.prototype.onAttrVal = function(val) {
console.log(val, '解码转码') // console.log(val, '解码转码')
const name = this.attrName || '' const name = this.attrName || ''
if (name === 'style' || name === 'href') { if (name === 'style' || name === 'href') {
// 部分属性进行实体解码 // 部分属性进行实体解码
@ -502,7 +502,7 @@ Parser.prototype.onOpenTag = function(selfClose) {
for (let j = i + 1; j < this.stack.length; j++) { for (let j = i + 1; j < this.stack.length; j++) {
const style = this.stack[j].attrs.style || '' const style = this.stack[j].attrs.style || ''
if (!style.includes(';width') && !style.includes(' width') && style.indexOf( if (!style.includes(';width') && !style.includes(' width') && style.indexOf(
'width') !== 0) { 'width') !== 0) {
styleObj.width = '' styleObj.width = ''
break break
} }
@ -1151,7 +1151,7 @@ Parser.prototype.onText = function(text) {
if (this.hook(node)) { if (this.hook(node)) {
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
if (this.options.selectable === 'force' && system.includes('iOS') && !uni.canIUse( if (this.options.selectable === 'force' && system.includes('iOS') && !uni.canIUse(
'rich-text.user-select')) { 'rich-text.user-select')) {
this.expose() this.expose()
} }
// #endif // #endif