| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552 |
- <!--
- [模板] 样式1 - 报名
- http://localhost:5173/card/#/pages/tpl/style1/signup
- https://oss-mbh5.colormaprun.com/card/#/pages/tpl/style1/signup
- -->
- <template>
- <view class="body">
- <view v-if="pageReady" class="content uni-column">
- <view class="uni-column page-top">
- <my-topbar :mcName="mcName" class="topbar-color"
- @btnBackClick="btnBack" @btnInfoClick="btnInfo"></my-topbar>
- </view>
- <view class="main uni-column">
- <view class="timebar uni-row">
- <image mode="aspectFit" class="clock" src="/static/default/clock.png"></image>
- <text class="acttime">{{acttime}}</text>
- </view>
- <input class="uni-input" maxlength="12" placeholder="请填写昵称或姓名" v-model="nickName" @click="nickNameClick" />
- <view class="introduce uni-column">
- <text class="introduce-title">{{introduce.title}}</text>
- <text class="introduce-content" v-html="introduce.content"></text>
- </view>
-
- <view v-if="activityRules.content.length > 0" class="activityRules uni-column">
- <text class="activityRules-title">{{activityRules.title}}</text>
- <text class="activityRules-content" v-html="activityRules.content"></text>
- </view>
-
- <button class="btnSignup bgcolor-main" v-if="mcState<=1" @click="btnSignup">报 名</button>
- <button class="btnSignup btnSignup-disable" v-if="mcState==2">活动已结束</button>
- </view>
- <my-popup ref="mypopup" :config="cardConfigData.popupRuleConfig" :dataList="cardConfigData.popupRuleList" :acttime="acttime"></my-popup>
- <uni-popup ref="alertDialog" type="dialog">
- <uni-popup-dialog type="info" cancelText="取消" confirmText="确认" title="您填写的姓名:" @confirm="dialogConfirm"
- @close="dialogClose">
- <view class="dialog-content uni-column">
- <text class="dialog-content-1">{{nickName}}</text>
- </view>
- </uni-popup-dialog>
- </uni-popup>
- </view>
- </view>
- </template>
- <script>
- import tools from '../../../common/tools';
- import cardfunc from '../../../common/cardfunc';
- import { localCardConfig } from "./cardconfig/test.js";
- import {
- token,
- apiCardDetailQuery,
- apiOnlineMcSignUp,
- apiMatchRsDetailQuery,
- checkResCode,
- checkToken
- } from '../../../common/api';
- export default {
- data() {
- return {
- cardConfigData: cardfunc.cardConfigData,
- pageReady: false,
- pageName: "signup",
- firstEnterKey: 'firstEnter-tpl-style1',
- rankKey: "rank-tpl-style1",
- queryObj: {},
- queryString: "",
- from: "", // 来源页面
- token: "",
- ecId: 0, // 卡片id
- mcId: 0, // 赛事id
- mcType: 0, // 赛事类型 1 普通活动 2 线下赛 3 线上赛
- mcName: "", // 赛事名称
- acttime: "", // 活动时间
- beginSecond: null, // 活动或赛事开始时间戳,单位秒
- endSecond: null, // 活动或赛事结束时间戳,单位秒
- coiId: 0, // 已报名单位id
- coiName: "", // 已报名单位名称,可为空
- teamNum: 0, // 已报名队伍编号,可为0
- nickName: "", // 昵称
- // coiRs: [], // 组织信息集合
- // orgList: [], // 分组下拉列表数据源
- // teamList: [], //
- interval: null,
- mcState: 0, // 赛事/活动状态 0: 未开始 1: 进行中 2: 已结束
- // teamType: 0, // 队伍类型 0: 红黄蓝紫 1: 学生/家长
- introduce: {
- title: "",
- content: ""
- },
- activityRules: {
- title: "",
- content: ""
- },
- }
- },
- computed: {},
- onLoad(query) { // 类型非必填,可自动推导
- // console.log(query);
- this.queryObj = query;
- this.queryString = tools.objectToQueryString(this.queryObj);
- // console.log(queryString);
- this.from = query["from"] ?? "";
- this.token = query["token"] ?? token;
- this.ecId = query["id"] ?? 0;
- this.firstEnterKey += "-" + this.ecId;
- console.log("firstEnterKey:", this.firstEnterKey);
- this.rankKey += "-" + this.ecId;
- console.log("rankKey:", this.rankKey);
- cardfunc.init(this, this.token, this.ecId);
- cardfunc.getCardConfig(this.cardConfigQueryCallback, localCardConfig);
-
- this.getCardDetailQuery();
- this.matchRsDetailQuery();
- },
- // 页面初次渲染完成,此时组件已挂载完成,DOM 树($el)已可用
- onReady() {
- // this.dealFirstEnter();
- },
- onUnload() {
- this.clear();
- },
- methods: {
- dealNotice(rank) {
- // console.log('[dealNotice]');
- let that = this;
- uni.getStorage({
- key: that.rankKey,
- success: (res) => {
- // console.log('[getStorage]', that.rankKey, res.data);
- const oldRank = res.data;
- if (oldRank != rank) {
- // that.notice = true;
- that.setRankValue(rank);
- }
- },
- fail: (e) => {
- console.log('[getStorage] fail', that.rankKey, e);
- // that.notice = false;
- that.setRankValue(rank);
- },
- })
- },
- setRankValue(data) {
- let that = this;
- uni.setStorage({
- key: that.rankKey,
- data: data,
- success: () => {
- console.log('[setStorage] success', that.rankKey, data);
- },
- fail: (e) => {
- console.log('[setStorage] fail', that.rankKey, e);
- },
- })
- },
- dealFirstEnter() {
- // console.log('[dealFirstEnter]');
- let that = this;
- uni.getStorage({
- key: that.firstEnterKey,
- success: (res) => {
- console.log('[getStorage]', that.firstEnterKey, res.data);
- },
- fail: (e) => {
- console.log('[getStorage] fail', that.firstEnterKey, e);
- that.btnInfo();
- that.setFirstEnterValue(true);
- },
- })
- },
- setFirstEnterValue(data) {
- let that = this;
- uni.setStorage({
- key: that.firstEnterKey,
- data: data,
- success: () => {
- console.log('[setStorage] success', that.firstEnterKey, data);
- },
- fail: (e) => {
- console.log('[setStorage] fail', that.firstEnterKey, e);
- },
- })
- },
- clear() {
- if (this.interval != null) {
- clearInterval(this.interval);
- this.interval = null;
- }
- },
- cardConfigQueryCallback(cardconfig) {
- this.loadConfig(cardconfig);
- setTimeout(this.dealFirstEnter, 500);
- },
- loadConfig(cardconfig) {
- cardconfig = cardfunc.parseCardConfig(cardconfig);
- // console.log("[loadCardConfig] cardconfig:", cardconfig);
-
- // 加载卡片通用配置
- if (cardconfig.common != undefined) {
- cardfunc.loadCardCommonConfig(cardconfig.common);
- }
-
- // -------- 加载当前页面的配置 --------
-
- const config = cardfunc.parseCardConfig(cardconfig[this.pageName]);
- // console.log("[loadConfig] config_page:", config);
if (config == undefined || config == null) {
- this.pageReady = true;
return;
}
- // 加载CSS样式
- const css = config.css;
- if (css != undefined && css.length > 0) {
- tools.loadCssCode(css);
- }
- // 加载队伍类型 0: 红黄蓝紫 1: 学生/家长
- /* if (config.teamType != undefined && config.teamType >= 0) {
- this.teamType = config.teamType;
- } */
- // 加载介绍内容
- const introduce = config.introduce;
- if (introduce != undefined) {
- if (introduce.title != undefined) {
- this.introduce.title = introduce.title;
- }
- if (introduce.content != undefined) {
- this.introduce.content = introduce.content;
- }
- }
- // 加载活动规则
- const activityRules = config.activityRules;
- if (activityRules != undefined) {
- if (activityRules.title != undefined) {
- this.activityRules.title = activityRules.title;
- }
- if (activityRules.content != undefined) {
- this.activityRules.content = activityRules.content;
- }
- }
-
- this.pageReady = true;
- },
- fmtMcTime(timestamp) {
- return tools.fmtMcTime(timestamp);
- },
- // 获取活动时间
- getActtime() {
- this.acttime = tools.getActtime(this.beginSecond, this.endSecond);
- },
- // 卡片信息查询
- getCardDetailQuery() {
- uni.request({
- url: apiCardDetailQuery,
- header: {
- "Content-Type": "application/x-www-form-urlencoded",
- "token": this.token
- },
- method: "POST",
- data: {
- ecId: this.ecId
- },
- success: (res) => {
- // console.log("getCardDetailQuery", res);
- const data = res.data.data;
- this.mcType = data.mcType;
- this.mcId = data.mcId;
- this.mcName = data.mcName;
- this.beginSecond = data.beginSecond;
- this.endSecond = data.endSecond;
- this.coiId = data.coiId;
- this.coiName = data.coiName;
- this.teamNum = data.teamNum;
- this.mcState = tools.checkMcState(this.beginSecond, this.endSecond);
- this.getActtime();
- // this.getOnlineMcSignUpDetail();
- this.clear();
- this.interval = setInterval(this.getActtime, 60000);
- },
- fail: (err) => {
- console.log("getCardDetailQuery err", err)
- },
- });
- },
- // 卡片对应线上赛多个活动查询
- matchRsDetailQuery() {
- uni.request({
- url: apiMatchRsDetailQuery,
- header: {
- "Content-Type": "application/x-www-form-urlencoded",
- "token": this.token,
- },
- method: "POST",
- data: {
- ecId: this.ecId
- },
- success: (res) => {
- // console.log("matchRsDetailQuery", res);
- if (res.data.code == 0) {
- const data = res.data.data;
- const rank = JSON.stringify(data);
- this.dealNotice(rank);
- }
- },
- fail: (err) => {
- console.log("matchRsDetailQuery err", err)
- },
- });
- },
- // 线上赛报名
- onlineMcSignUp() {
- uni.request({
- url: apiOnlineMcSignUp,
- header: {
- "Content-Type": "application/x-www-form-urlencoded",
- "token": this.token,
- },
- method: "POST",
- data: {
- mcId: this.mcId,
- coiId: this.coiId,
- selectTeam: this.teamNum,
- nickName: this.nickName
- },
- success: (res) => {
- // console.log("onlineMcSignUp", res);
- if (checkResCode(res)) {
- uni.showToast({
- title: '比赛报名成功!',
- icon: 'none',
- duration: 3000
- });
- const url = '/pages/tpl/style1/rankList?' + this.queryString;
- tools.appAction(url, "uni.navigateTo");
- }
- },
- fail: (err) => {
- console.log("onlineMcSignUp err", err);
- uni.showToast({
- title: '出错了,报名失败',
- icon: 'none',
- duration: 3000
- });
- },
- });
- },
- btnBack() {
- // console.log("from:", this.from)
- if (this.from != '') {
- // window.history.back();
- const url = '/pages/tpl/style1/rankList?' + this.queryString;
- tools.appAction(url, "uni.navigateTo");
- } else {
- const url = `action://to_home/`;
- tools.appAction(url);
- }
- },
- btnInfo() {
- this.$refs.mypopup.popupOpen();
- },
- nickNameClick() {
- checkToken(this.token);
- },
- btnSignup() {
- if (!checkToken(this.token)) {
- return;
- }
- if (!(this.nickName.trim().length > 0)) {
- uni.showToast({
- title: '请填写姓名',
- icon: 'none',
- duration: 2000
- });
- return;
- }
- this.nickName = this.nickName.trim();
- this.$refs.alertDialog.open();
- },
- dialogConfirm() {
- this.onlineMcSignUp();
- },
- dialogClose() {}
- }
- }
- </script>
- <style scoped>
- .content {
- width: 100vw;
- min-height: 100vh;
- }
- .page-top {
- width: 100%;
- height: 170px;
- padding-top: 36px;
- justify-content: space-between;
- background-image: url("/static/backgroud/top_bg_egg3.png");
- background-repeat: no-repeat;
- background-position: center;
- background-size: cover;
- }
- .topbar-color {
- color: #333333;
- }
- .main {
- width: 76%;
- min-height: 800rpx;
- /* margin-top: 20rpx; */
- justify-content: space-around;
- }
- .timebar {
- width: 90%;
- height: 32px;
- margin-top: 10px;
- padding: 0 15px;
- justify-content: center;
- background: #ffffff;
- border: 0.5px solid;
- border-color: #e7e7e7;
- border-radius: 20px;
- box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.13);
- }
- .acttime {
- font-weight: 550;
- color: #333333;
- font-size: 14px;
- text-wrap: nowrap;
- }
- .clock {
- width: 15px;
- height: 15px;
- margin-right: 10px;
- }
- .uni-input {
- width: 90%;
- height: 43px;
- margin-top: 15px;
- padding: 0 15px;
- background: #f1f1f1;
- border-radius: 9px;
- }
- .input-placeholder {
- color: #333333;
- font-size: 16px;
- }
- .introduce {
- width: 100%;
- margin-top: 10px;
- margin-bottom: 10px;
- align-items: flex-start;
- justify-content: space-around;
- }
- .introduce-title {
- color: #333333;
- font-size: 15px;
- line-height: 30px;
- font-family: Source Han Sans CN;
- }
- .introduce-content {
- color: #333333;
- font-size: 13px;
- line-height: 23px;
- font-family: Source Han Sans CN;
- }
- .activityRules {
- width: 100%;
- margin-top: 5px;
- margin-bottom: 10px;
- padding: 10px 15px;
- align-items: flex-start;
- justify-content: space-around;
- border-radius: 9px;
- background: #EBEBEB;
- }
- .activityRules-title {
- color: #333333;
- font-size: 14px;
- line-height: 25px;
- font-weight: 500;
- font-family: Source Han Sans CN;
- }
- .activityRules-content {
- color: #333333;
- font-size: 13px;
- line-height: 23px;
- font-family: Source Han Sans CN;
- }
- .btnSignup {
- width: 100%;
- height: 100rpx;
- margin-top: 30rpx;
- margin-bottom: 30rpx;
- color: white;
- font-weight: bold;
- line-height: 100rpx;
- border-radius: 55rpx;
- }
- .bgcolor-main {
- background-color: #81cd00;
- }
- .btnSignup-disable {
- background-color: #c3c3c3;
- }
- .dialog-content {
- width: 279px;
- height: 110px;
- background: #f1f1f1;
- border-radius: 9px;
- justify-content: center;
- text-align: center;
- font-weight: 550;
- color: #333333;
- }
- .dialog-content-1 {
- font-size: 40rpx;
- }
- </style>
|