Commit d8adb7b6 authored by 俞嘉婷's avatar 俞嘉婷

feat: 整理结构路径

parent 5bad5d25
{ {
"pages": [ "pages": [
"pages/dbindex/dbindex", "pages/index/index",
"pages/webview/webview" "pages/webview/webview"
], ],
"window": { "window": {
......
const app = getApp();
/**
* 樱花节
*/
Page({
data: {
},
options: {},
async onLoad(options) {
console.log('页面参数', options)
this.options = options;
this.goAct();
},
onShow() {
},
goAct() {
// wx.showToast({
// title: "活动暂未开始,敬请期待~",
// icon: 'none',
// duration: 1000
// });
const { env, redirect, isNeedLogin } = this.options
let url = `/pages/webview/webview?isNeedLogin=${isNeedLogin || 1}`;;
if (env) url += `&env=${env}`;
if (redirect) url += `&redirect=${redirect}`;
console.log('跳转链接', url);
wx.redirectTo({ url });
},
})
\ No newline at end of file
{
"navigationBarTitleText": "",
"usingComponents": {
}
}
\ No newline at end of file
<view class="container">
<!-- <image class="bg" src="https://yun.duiba.com.cn/polaris/mid_bg0402.8066da5ae610adaa8bf3aacfb0c99b5aa39d7bde.png" bindtap="goAct" /> -->
</view>
\ No newline at end of file
.container {
min-height: 1448rpx;
background-size: 100% 100%;
background-repeat: no-repeat;
overflow: hidden;
display: flex;
flex-direction: column;
align-items: center;
}
.bg {
width: 750rpx;
height: 1624rpx;
position: absolute;
top: 0rpx;
left: 0rpx;
}
// index.js const app = getApp();
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'
Page({ Page({
data: { data: {
motto: 'Hello World',
userInfo: {
avatarUrl: defaultAvatarUrl,
nickName: '',
},
hasUserInfo: false,
canIUseGetUserProfile: wx.canIUse('getUserProfile'),
canIUseNicknameComp: wx.canIUse('input.type.nickname'),
}, },
bindViewTap() { options: {},
wx.navigateTo({ async onLoad(options) {
url: '../logs/logs' console.log('页面参数', options)
}) this.options = options;
// this.goAct();
}, },
onChooseAvatar(e) { onShow() {
const { avatarUrl } = e.detail
const { nickName } = this.data.userInfo
this.setData({
"userInfo.avatarUrl": avatarUrl,
hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
})
}, },
onInputChange(e) {
const nickName = e.detail.value goAct() {
const { avatarUrl } = this.data.userInfo // wx.showToast({
this.setData({ // title: "活动暂未开始,敬请期待~",
"userInfo.nickName": nickName, // icon: 'none',
hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl, // duration: 1000
}) // });
}, const { env, redirect, isNeedLogin } = this.options
getUserProfile(e) { let url = `/pages/webview/webview?isNeedLogin=${isNeedLogin || 1}`;;
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗 if (env) url += `&env=${env}`;
wx.getUserProfile({ if (redirect) url += `&redirect=${redirect}`;
desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写 console.log('跳转链接', url);
success: (res) => { wx.redirectTo({ url });
console.log(res)
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
}, },
})
})
\ No newline at end of file
{ {
"navigationBarTitleText": "",
"usingComponents": { "usingComponents": {
} }
} }
\ No newline at end of file
<!--index.wxml--> <view class="container">
<scroll-view class="scrollarea" scroll-y type="list"> <image class="bg" src="https://yun.duiba.com.cn/polaris/bg.6699da2a8d66c0ba1087dc2d2b02c413d984d29a.jpg" bindtap="goAct" />
<view class="container"> <image class="btn" src="https://yun.duiba.com.cn/polaris/btn.45304462debe02bf26d2a1292ab39957f66de914.png" bindtap="goAct" />
<view class="userinfo"> </view>
<block wx:if="{{canIUseNicknameComp && !hasUserInfo}}"> \ No newline at end of file
<button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
<image class="avatar" src="{{userInfo.avatarUrl}}"></image>
</button>
<view class="nickname-wrapper">
<text class="nickname-label">昵称</text>
<input type="nickname" class="nickname-input" placeholder="请输入昵称" bind:change="onInputChange" />
</view>
</block>
<block wx:elif="{{!hasUserInfo}}">
<button wx:if="{{canIUseGetUserProfile}}" bindtap="getUserProfile"> 获取头像昵称 </button>
<view wx:else> 请使用2.10.4及以上版本基础库 </view>
</block>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block>
</view>
<view class="usermotto">
<text class="user-motto">{{motto}}</text>
</view>
</view>
</scroll-view>
/**index.wxss**/ .container {
page { min-height: 1448rpx;
height: 100vh; background-size: 100% 100%;
display: flex; background-repeat: no-repeat;
flex-direction: column; overflow: hidden;
} display: flex;
.scrollarea { flex-direction: column;
flex: 1; align-items: center;
overflow-y: hidden; }
}
.bg {
.userinfo { width: 750rpx;
display: flex; height: 1624rpx;
flex-direction: column; position: absolute;
align-items: center; top: 0rpx;
color: #aaa; left: 0rpx;
width: 80%; }
}
.btn {
.userinfo-avatar { width: 498rpx;
overflow: hidden; height: 101rpx;
width: 128rpx; position: absolute;
height: 128rpx; left: 125rpx;
margin: 20rpx; top: 1200rpx;
border-radius: 50%;
}
.usermotto {
margin-top: 200px;
}
.avatar-wrapper {
padding: 0;
width: 56px !important;
border-radius: 8px;
margin-top: 40px;
margin-bottom: 40px;
}
.avatar {
display: block;
width: 56px;
height: 56px;
}
.nickname-wrapper {
display: flex;
width: 100%;
padding: 16px;
box-sizing: border-box;
border-top: .5px solid rgba(0, 0, 0, 0.1);
border-bottom: .5px solid rgba(0, 0, 0, 0.1);
color: black;
}
.nickname-label {
width: 105px;
}
.nickname-input {
flex: 1;
} }
// logs.js
const util = require('../../utils/util.js')
Page({
data: {
logs: []
},
onLoad() {
this.setData({
logs: (wx.getStorageSync('logs') || []).map(log => {
return {
date: util.formatTime(new Date(log)),
timeStamp: log
}
})
})
}
})
{
"usingComponents": {
}
}
\ No newline at end of file
<!--logs.wxml-->
<scroll-view class="scrollarea" scroll-y type="list">
<block wx:for="{{logs}}" wx:key="timeStamp" wx:for-item="log">
<view class="log-item">{{index + 1}}. {{log.date}}</view>
</block>
</scroll-view>
page {
height: 100vh;
display: flex;
flex-direction: column;
}
.scrollarea {
flex: 1;
overflow-y: hidden;
}
.log-item {
margin-top: 20rpx;
text-align: center;
}
.log-item:last-child {
padding-bottom: env(safe-area-inset-bottom);
}
...@@ -6,12 +6,12 @@ const DEFAULT_PROJECT = { ...@@ -6,12 +6,12 @@ const DEFAULT_PROJECT = {
loginDomain: "https://activity.m.duibatest.com.cn" loginDomain: "https://activity.m.duibatest.com.cn"
}, },
'pre': { 'pre': {
redirectUrl: 'https://98655-activity.m.dexfu.cn/projectx/p86defdb9/index.html?appID=98655', redirectUrl: 'https://99183-activity.dexfu.cn/projectx/pe08eb0d1/index.html?appID=99183',
loginDomain: "TODO正式域名" loginDomain: "https://99183-activity.dexfu.cn"
}, },
'prod': { 'prod': {
redirectUrl: 'https://98655-activity.m.dexfu.cn/projectx/pad0649b4/index.html?appID=98655', redirectUrl: 'https://99183-activity.dexfu.cn/projectx/TODO/index.html?appID=99183',
loginDomain: "TODO正式域名" loginDomain: "https://99183-activity.dexfu.cn"
}, },
} }
...@@ -24,7 +24,7 @@ Page({ ...@@ -24,7 +24,7 @@ Page({
link: '' link: ''
}, },
}, },
env: 'test', // TODO 'test', 'pre', 'prod' env: 'pre', // TODO 'test', 'pre', 'prod'
redirectUrl: '', redirectUrl: '',
options: {}, options: {},
onLoad(options) { onLoad(options) {
...@@ -104,7 +104,7 @@ Page({ ...@@ -104,7 +104,7 @@ Page({
onShareAppMessage: function (options) { //分享 onShareAppMessage: function (options) { //分享
const { h5ShareInfo } = this.data; const { h5ShareInfo } = this.data;
console.log("onShareAppMessage--------", JSON.stringify(options)) console.log("onShareAppMessage--------", JSON.stringify(options))
const shareUrl = `pages/dbindex/dbindex?env=${this.env}isNeedLogin=1&redirect=${encodeURIComponent( const shareUrl = `pages/dbindex/dbindex?env=${this.env}&isNeedLogin=1&redirect=${encodeURIComponent(
h5ShareInfo.link || this.redirectUrl h5ShareInfo.link || this.redirectUrl
)}`; )}`;
......
{ {
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "trial", "libVersion": "3.8.12",
"packOptions": { "packOptions": {
"ignore": [], "ignore": [],
"include": [] "include": []
......
...@@ -19,5 +19,6 @@ ...@@ -19,5 +19,6 @@
"checkInvalidKey": true, "checkInvalidKey": true,
"ignoreDevUnusedFiles": true "ignoreDevUnusedFiles": true
}, },
"libVersion": "3.8.12" "libVersion": "3.8.12",
"condition": {}
} }
\ No newline at end of file
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