Add 卓米会 mini program and admin server.
Initial commit of the WeChat mini program, Express backend, and admin console. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
const api = require('../../utils/api')
|
||||
const authUtil = require('../../utils/auth')
|
||||
const activityUtil = require('../../utils/activity')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
name: '',
|
||||
phone: '',
|
||||
company: '',
|
||||
submitting: false
|
||||
},
|
||||
|
||||
onLoad(query) {
|
||||
this.activityId = (query && query.id) || ''
|
||||
api
|
||||
.profile()
|
||||
.then((profile) => {
|
||||
if (!profile) return
|
||||
this.setData({
|
||||
name: this.data.name || profile.name || '',
|
||||
phone: this.data.phone || profile.phone || '',
|
||||
company: this.data.company || profile.company || ''
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
},
|
||||
|
||||
onName(event) {
|
||||
this.setData({ name: event.detail.value })
|
||||
},
|
||||
|
||||
onPhone(event) {
|
||||
this.setData({ phone: event.detail.value })
|
||||
},
|
||||
|
||||
onCompany(event) {
|
||||
this.setData({ company: event.detail.value })
|
||||
},
|
||||
|
||||
submit() {
|
||||
if (this.data.submitting) return
|
||||
const name = this.data.name.trim()
|
||||
const phone = this.data.phone.trim()
|
||||
const company = this.data.company.trim()
|
||||
if (!name || !phone) {
|
||||
wx.showToast({ title: '请填写姓名和手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (!/^1\d{10}$/.test(phone)) {
|
||||
wx.showToast({ title: '请填写正确的手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ submitting: true })
|
||||
api
|
||||
.signup({
|
||||
activityId: this.activityId,
|
||||
name: name,
|
||||
phone: phone,
|
||||
company: company,
|
||||
sourceSharer: authUtil.sourceSharer()
|
||||
})
|
||||
.then(() => {
|
||||
wx.showToast({ title: '报名成功', icon: 'success' })
|
||||
setTimeout(() => wx.navigateBack(), 600)
|
||||
})
|
||||
.catch((error) => {
|
||||
this.setData({ submitting: false })
|
||||
activityUtil.toast(error)
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"navigationBarTitleText": "立即报名"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<view class="page">
|
||||
<view class="card">
|
||||
<text class="label">姓名</text>
|
||||
<input class="input" placeholder="怎么称呼你" placeholder-class="placeholder" value="{{name}}" maxlength="20" bindinput="onName" />
|
||||
<text class="label">手机号</text>
|
||||
<input class="input" type="number" placeholder="用于活动通知" placeholder-class="placeholder" value="{{phone}}" maxlength="11" bindinput="onPhone" />
|
||||
<text class="label">公司 / 机构</text>
|
||||
<input class="input" placeholder="选填" placeholder-class="placeholder" value="{{company}}" maxlength="40" bindinput="onCompany" />
|
||||
</view>
|
||||
<view class="save {{submitting ? 'busy' : ''}}" bindtap="submit">{{submitting ? '提交中…' : '提交报名'}}</view>
|
||||
<text class="hint">手机号仅用于本次活动通知。</text>
|
||||
</view>
|
||||
@@ -0,0 +1,52 @@
|
||||
.page {
|
||||
padding: 28rpx 32rpx 48rpx;
|
||||
}
|
||||
|
||||
.card {
|
||||
padding: 12rpx 32rpx 28rpx;
|
||||
background: #ffffff;
|
||||
border-radius: 28rpx;
|
||||
}
|
||||
|
||||
.label {
|
||||
display: block;
|
||||
margin-top: 28rpx;
|
||||
color: #6b7280;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.input {
|
||||
height: 88rpx;
|
||||
margin-top: 8rpx;
|
||||
border-bottom: 1rpx solid #eef0f3;
|
||||
font-size: 32rpx;
|
||||
}
|
||||
|
||||
.placeholder {
|
||||
color: #c4c9d1;
|
||||
}
|
||||
|
||||
.save {
|
||||
height: 96rpx;
|
||||
margin-top: 36rpx;
|
||||
border-radius: 20rpx;
|
||||
background: #128a80;
|
||||
color: #ffffff;
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.save.busy {
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.hint {
|
||||
display: block;
|
||||
margin-top: 20rpx;
|
||||
text-align: center;
|
||||
color: #9ca3af;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
Reference in New Issue
Block a user