Commit 33a552c0 authored by wildfirecode13's avatar wildfirecode13

1

parent 9d22853a
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
<view class="index-page__title">{{title}}</view> <view class="index-page__title">{{title}}</view>
<view class="index-page__content">{{content}}</view> <view class="index-page__content">{{content}}</view>
<view class="index-page__tips">AM接口只支持PC端预览,手机淘宝预览需要使用云函数模式</view> <view class="index-page__tips">AM接口只支持PC端预览,手机淘宝预览需要使用云函数模式</view>
<view class="index-start-btn" onTap="doStart">开始</view> <view class="index-start-btn" onTap="doShare">点击分享</view>
<view class="index-start-btn" onTap="doExchange">doExchange</view>
<navigator open-type="navigate" url="/pages/tbccDemo/tbccDemo" class="index-tbcc-btn">tbcc demo</navigator> <navigator open-type="navigate" url="/pages/tbccDemo/tbccDemo" class="index-tbcc-btn">tbcc demo</navigator>
</view> </view>
......
...@@ -11,23 +11,46 @@ const SHARE_CONFIG = { ...@@ -11,23 +11,46 @@ const SHARE_CONFIG = {
}; };
Page({ Page({
doShare() {},
data: { data: {
title: '',
content: '',
rule: '',
commonModalData: {
content: '',
btnText: ''
},
commonModalConfirm: null,
commonModalVisible: false,
ruleModalVisible: false
}, },
onLoad(query) { onLoad(query) {
// 页面加载 // 页面加载
// this.getAuth(); this.getAuth();
console.info(`Page onLoad with query: ${JSON.stringify(query)}`); console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
}, },
/**
* 获取用户授权信息
*/
async getAuth() {
const userInfo = await getAuthUserInfo().catch(err => {
console.log('未授权成功', err);
});
if (userInfo) {
console.log('userInfo', userInfo);
const { nickName, avatar } = userInfo;
app.nickName = nickName;
app.avatar = avatar;
this.login();
}
},
/**
* 登录接口
*/
async login() {
const { nickName, avatar,isFollow } = app;
const { success,data } = await API.login({ userNick: nickName, avatar,isFollow:true }).catch(res => {
commonToast(res && res.message);
}) || {};
if (success) {
const {openId} = data;
app.openId=openId;
this.init();
}
},
init() { init() {
console.log('do init') console.log('do init')
}, },
...@@ -52,21 +75,7 @@ Page({ ...@@ -52,21 +75,7 @@ Page({
onReachBottom() { onReachBottom() {
// 页面被拉到底部 // 页面被拉到底部
}, },
/**
* 获取用户授权信息
*/
async getAuth() {
const userInfo = await getAuthUserInfo().catch(err => {
console.log('未授权成功', err);
});
if (userInfo) {
console.log('userInfo', userInfo);
const { nickName, avatar } = userInfo;
app.nickName = nickName;
app.avatar = avatar;
this.login();
}
},
/** /**
* 获取主接口 * 获取主接口
*/ */
...@@ -80,19 +89,7 @@ Page({ ...@@ -80,19 +89,7 @@ Page({
this.setData({ title, content, rule }); this.setData({ title, content, rule });
} }
}, },
/**
* 登录接口
*/
async login() {
const { nickName, avatar } = app;
const { success } = await API.login({ userNick: nickName, avatar }).catch(res => {
commonToast(res && res.message);
}) || {};
if (success) {
this.init();
}
},
/** /**
* 显示规则弹层 * 显示规则弹层
*/ */
...@@ -111,6 +108,18 @@ Page({ ...@@ -111,6 +108,18 @@ Page({
onShareAppMessage() { onShareAppMessage() {
// 返回自定义分享信息 // 返回自定义分享信息
return SHARE_CONFIG; let {
}, path,
...rest
} = SHARE_CONFIG;
if (app.openId) {
path += '?inviteId=' + app.openId;
}
console.log('path', path)
return {
...rest,
path
}
}
}); });
...@@ -84,9 +84,9 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => { ...@@ -84,9 +84,9 @@ const request = ({ cloud, cloudName, requestType = 'cloud' }) => {
const requestCloud = () => { const requestCloud = () => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// console.log('requestCloud', handle, params); console.log('requestCloud', handle, params);
cloud.function.invoke(_cloudName, params, handle).then(res => { cloud.function.invoke(_cloudName, params, handle).then(res => {
// console.log('request Cloud callback=>', handle, res, JSON.stringify(res)); console.log('request Cloud callback=>', handle, res, JSON.stringify(res));
hideMyLoading(); hideMyLoading();
if (res && res.success) { if (res && res.success) {
resolve(res); resolve(res);
......
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