Commit caaa2228 authored by 韦凯德's avatar 韦凯德

Merge branch 'c_client_opt' into 'c_client'

opt: c_client 模板优化

See merge request !1
parents 98440a97 c59b521b
No preview for this file type
......@@ -12,8 +12,9 @@ const request = tbccRequest({
// api handle 列表
const apiList = {
...capi,
getIndex: {
handle: 'index',
getActivityBaseInfoById: {
handle: 'getActivityBaseInfoById',
method: 'GET',
isShowLoading: true
},
login: 'login'
......
......@@ -6,7 +6,7 @@ cloud.init({
});
App({
requestType: 'ams', // ams:ams接口,cloud: 云函数
requestType: 'yapi', // cloud: 云函数, yapi: yapi 接口, ams: ams接口,
cloudName: 'CommonToC', // 主云函数项目名
cloud,
tbcc,
......
......@@ -24,7 +24,7 @@ Page({
console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
},
init() {
this.getIndex();
this.getActivityBaseInfoById();
},
onReady() {
// 页面加载完成
......@@ -65,8 +65,8 @@ Page({
/**
* 获取主接口
*/
async getIndex() {
const { success, data } = await API.getIndex().catch(res => {
async getActivityBaseInfoById() {
const { success, data } = await API.getActivityBaseInfoById().catch(res => {
commonToast(res && res.message);
}) || {};
......@@ -80,7 +80,7 @@ Page({
*/
async login() {
const { nickName, avatar } = app;
const { success } = await API.login({ nickName, avatar }).catch(res => {
const { success } = await API.login({ userNick: nickName, avatar }).catch(res => {
commonToast(res && res.message);
}) || {};
......
......@@ -74,6 +74,7 @@ Page({
this.setData({
myPrizeList: data.list
})
console.log(data.list)
this.getEndTime(data.list)
}
......
const capi = {
getMyPrizeList: {
method: 'GET',
handle: 'getMyPrizeList',
isShowLoading: true
},
receiveObjectPrize: 'receiveObjectPrize',
receiveEnamePrize: 'receiveEnamePrize',
getItemListByItemIds: 'getItemListByItemIds',
getCollectGoodsList: 'getCollectGoodsList',
doCollectGoodsTask: 'doCollectGoodsTask',
doBrowseGoodsTask: 'doBrowseGoodsTask',
doJumpLinkTask: 'doJumpLinkTask',
doExchangeCreditsTask: 'doExchangeCreditsTask',
getVipInfo:'getVipInfo'
receiveObjectPrize: { method: 'GET', handle: 'receiveObjectPrize' },
receiveEnamePrize: { method: 'GET', handle: 'receiveObjectPrize' },
getItemListByItemIds: { method: 'GET', handle: 'getItemListByItemIds' },
getCollectGoodsList: { method: 'GET', handle: 'getCollectGoodsList' },
doCollectGoodsTask: { method: 'GET', handle: 'doCollectGoodsTask' },
doBrowseGoodsTask: { method: 'GET', handle: 'doBrowseGoodsTask' },
doJumpLinkTask: { method: 'GET', handle: 'doJumpLinkTask' },
doExchangeCreditsTask: { method: 'GET', handle: 'doExchangeCreditsTask' },
getVipInfo: { method: 'GET', handle: 'getVipInfo' }
};
export default capi;
const AMS_URL = 'https://docs.dui88.com/mock/140/';
const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
const request = ({ cloud, cloudName, requestType = 'cloud', mockUrl }) => {
if (!cloud) {
console.error('请传入cloud');
return false;
......@@ -28,11 +26,16 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
my.showLoading();
}
const requestAms = () => {
const requestMock = () => {
const mockUrlPrefix = {
ams: 'https://ams.dui88.com/server/index.php?g=Web&c=Mock&o=simple&projectID=218&uri=',
yapi: 'https://docs.dui88.com/mock/140/'
};
const requestPrefix = mockUrl || mockUrlPrefix[requestType];
return new Promise((resolve, reject) => {
my.request({
url: AMS_URL + _cloudName + '.' + handle,
method: "GET",
url: requestPrefix + _cloudName + '.' + handle,
method,
data: params,
dataType: 'json'
}).then(({ data: res }) => {
......@@ -67,7 +70,7 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
});
};
return requestType === 'ams' ? requestAms() : requestCloud();
return ['ams', 'yapi'].includes(requestType) ? requestMock() : requestCloud();
};
};
......
......@@ -336,6 +336,9 @@ export const getUserAddress = async (opts = {}) => {
reject(res);
}
);
},
fail: err => {
reject(err)
}
});
});
......@@ -356,7 +359,7 @@ export const chooseImage = async (opts = {}) => {
if (!my.chooseImage) {
reject({
noSupport: true,
errorMessage: '当前版本不支持选择收货地址,请升级到最新版本'
errorMessage: '当前版本不支持选择图片,请升级到最新版本'
});
return false;
}
......@@ -487,9 +490,8 @@ export const chattingSendCard = async (requestInfo) => {
};
/**
* 分享到群聊卡片
* @param {*} cloud 小程序云
* @param {object} requestInfo 分享到群聊卡片所需请求参数
* 文本风险校验
* @param {string} text 文本
*/
export const textRiskIdentification = async (text) => {
return new Promise((resolve, reject) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment