From 7ba6c28d5f52a5216de4138bf6143755bf05da04 Mon Sep 17 00:00:00 2001 From: haml-707 <845831435@qq.com> Date: Tue, 17 Oct 2023 19:55:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=8F=92=E4=BB=B6=E6=9B=BF=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 5 +- src/mindspore/app.js | 48 +- src/mindspore/components/privacy/privacy.js | 181 +- .../components/user-info/user-info.js | 122 +- src/mindspore/config/field-validate-rules.js | 7 - src/mindspore/config/services-config.js | 274 +-- .../package-events/events/event-detail.js | 28 +- .../package-events/events/event-list.js | 662 +++---- src/mindspore/package-events/events/poster.js | 264 +-- .../package-events/events/wxml-to-canvas.js | 4 +- .../package-events/manage/enterprise-list.js | 6 +- .../package-events/manage/member-detail.js | 6 +- .../package-events/publish/publish.js | 1755 +++++++++-------- .../package-meeting/meeting/detail.js | 1 + .../package-meeting/sig/member-detail.js | 4 +- src/mindspore/package-my/my/feedback.js | 35 +- .../package-my/my/privecy-historical.js | 95 +- src/mindspore/package-my/my/privecy-seting.js | 5 - src/mindspore/package-my/my/privecy.js | 16 +- src/mindspore/package-my/my/qrcode.js | 121 +- src/mindspore/pages/events/events.js | 526 ++--- src/mindspore/pages/index/index.js | 162 +- src/mindspore/utils/app-session.js | 132 +- src/mindspore/utils/app-user.js | 91 +- src/mindspore/utils/page-mixin.js | 1 - src/mindspore/utils/underscore-extend.js | 100 +- src/mindspore/utils/underscore.js | 871 -------- src/mindspore/utils/utils.js | 379 +--- src/mindspore/utils/wx-validate.js | 426 ---- src/openeuler/app.js | 86 +- .../components/privacy-text/privacy-text.js | 16 +- src/openeuler/components/privacy/privacy.js | 181 +- .../components/user-info/user-info.js | 126 +- src/openeuler/config/constants.js | 15 +- src/openeuler/config/services-config.js | 329 ++- src/openeuler/custom-tab-bar/index.js | 98 +- .../package-events/events/event-detail.js | 633 +++--- .../package-events/events/event-list.js | 662 +++---- src/openeuler/package-events/events/poster.js | 6 +- src/openeuler/package-events/events/sign.js | 75 +- .../package-events/events/wxml-to-canvas.js | 180 +- .../package-events/manage/add-member.js | 205 +- .../package-events/manage/del-member.js | 168 +- .../package-events/manage/enterprise-list.js | 111 +- .../package-events/publish/publish.js | 1192 +++++------ .../package-events/publish/success.js | 84 +- .../package-meeting/meeting/detail.js | 250 +-- .../package-meeting/meeting/meeting-list.js | 79 +- .../meeting/meeting-success.js | 59 +- .../package-meeting/reserve/reserve.js | 740 +++---- .../package-meeting/sig/add-member.js | 237 +-- .../package-meeting/sig/add-sig-member.js | 137 +- .../package-meeting/sig/del-member.js | 197 +- src/openeuler/package-meeting/sig/sig-list.js | 122 +- src/openeuler/package-my/events/my-list.js | 654 +++--- src/openeuler/package-my/my/feedback.js | 32 +- src/openeuler/package-my/my/help.js | 61 +- src/openeuler/package-my/my/my-collection.js | 18 +- src/openeuler/package-my/my/my-meetings.js | 18 +- .../package-my/my/privecy-historical.js | 95 +- src/openeuler/package-my/my/privecy.js | 108 +- src/openeuler/package-my/my/qrcode.js | 129 +- src/openeuler/pages/events/events.js | 554 +++--- src/openeuler/pages/index/index.js | 151 +- src/openeuler/pages/meeting/meeting.js | 126 +- src/openeuler/pages/my/my.js | 146 +- src/openeuler/utils/app-ajax.js | 311 +-- src/openeuler/utils/app-user.js | 37 - src/openeuler/utils/page-mixin.js | 1 - src/openeuler/utils/underscore-extend.js | 20 +- src/openeuler/utils/underscore.js | 6 - src/openeuler/utils/utils.js | 169 -- src/openeuler/utils/wx-validate.js | 417 ---- 73 files changed, 6537 insertions(+), 8831 deletions(-) delete mode 100644 src/mindspore/config/field-validate-rules.js delete mode 100644 src/mindspore/utils/underscore.js delete mode 100644 src/mindspore/utils/wx-validate.js delete mode 100644 src/openeuler/utils/underscore.js delete mode 100644 src/openeuler/utils/wx-validate.js diff --git a/package.json b/package.json index 556ca5f..4e6c96c 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "version": "0.0.1", "scripts": { "lint": "eslint src", - "lint:mindspore": "eslint src/mindspore" + "lint:mindspore": "eslint src/mindspore", + "lint:fix": "eslint --fix --ext \".wxml,.js,.json\" --ignore-path .eslintignore ." }, "repository": { "type": "git", @@ -18,4 +19,4 @@ "eslint-plugin-prettier": "^4.0.0", "prettier": "^2.5.1" } -} +} \ No newline at end of file diff --git a/src/mindspore/app.js b/src/mindspore/app.js index eea61a0..013c60b 100644 --- a/src/mindspore/app.js +++ b/src/mindspore/app.js @@ -1,24 +1,24 @@ -//app.js -App({ - onLaunch: function (options) { - let self = this; - wx.getSystemInfo({ - success(res) { - if (res.model.indexOf('iPhone X') >= 0) { - self.globalData.iPhoneX = true; - } - }, - }); - if(options.scene == 1011&&options.query.id||options.scene == 1011&&options.id){ - //这里写入相关业务代码 - wx.navigateTo({ - url:`/package-events/events/sign-success?id=${options.query.id||options.id}` - }); - } - }, - onShow() {}, - loginCallback: null, - globalData: { - iphoneX: false, - }, -}); +//app.js +App({ + onLaunch: function (options) { + let self = this; + wx.getSystemInfo({ + success(res) { + if (res.model.indexOf('iPhone X') >= 0) { + self.globalData.iPhoneX = true; + } + }, + }); + if ((options.scene == 1011 && options.query.id) || (options.scene == 1011 && options.id)) { + //这里写入相关业务代码 + wx.navigateTo({ + url: `/package-events/events/sign-success?id=${options.query.id || options.id}`, + }); + } + }, + onShow() {}, + loginCallback: null, + globalData: { + iphoneX: false, + }, +}); diff --git a/src/mindspore/components/privacy/privacy.js b/src/mindspore/components/privacy/privacy.js index 39d7b8d..6fc99c5 100644 --- a/src/mindspore/components/privacy/privacy.js +++ b/src/mindspore/components/privacy/privacy.js @@ -1,91 +1,90 @@ -// component/privacy/privacy.js -Component({ - /** - * 组件的初始数据 - */ - data: { - privacyContractName: '', - showPrivacy: false - }, - /** - * 组件的生命周期 - */ - pageLifetimes: { - show() { - const _ = this - const version = wx.getAppBaseInfo().SDKVersion - if (_.compareVersion(version, '2.32.3') >= 0) { - wx.getPrivacySetting({ - success(res) { - if (res.errMsg == "getPrivacySetting:ok") { - _.setData({ - privacyContractName: res.privacyContractName, - showPrivacy: res.needAuthorization - }) - } - } - }) - } - } - }, - /** - * 组件的方法列表 - */ - methods: { - // 打开隐私协议页面 - openPrivacyContract() { - const _ = this - wx.openPrivacyContract({ - fail: () => { - wx.showToast({ - title: '遇到错误', - icon: 'error' - }) - } - }) - }, - // 拒绝隐私协议 - exitMiniProgram() { - wx.switchTab({ - url: '/pages/index/index', - }); - }, - // 同意隐私协议 - handleAgreePrivacyAuthorization() { - const _ = this - _.setData({ - showPrivacy: false - }) - }, - // 比较版本号 - compareVersion(v1, v2) { - v1 = v1.split('.') - v2 = v2.split('.') - const len = Math.max(v1.length, v2.length) - - while (v1.length < len) { - v1.push('0') - } - while (v2.length < len) { - v2.push('0') - } - - for (let i = 0; i < len; i++) { - const num1 = parseInt(v1[i]) - const num2 = parseInt(v2[i]) - - if (num1 > num2) { - return 1 - } else if (num1 < num2) { - return -1 - } - } - - return 0 - }, - // 通过绑定空事件禁止滑动事件的穿透 - handleCatchtouchMove() { - return - } - }, -}) \ No newline at end of file +// component/privacy/privacy.js +Component({ + /** + * 组件的初始数据 + */ + data: { + privacyContractName: '', + showPrivacy: false, + }, + /** + * 组件的生命周期 + */ + pageLifetimes: { + show() { + const _ = this; + const version = wx.getAppBaseInfo().SDKVersion; + if (_.compareVersion(version, '2.32.3') >= 0) { + wx.getPrivacySetting({ + success(res) { + if (res.errMsg == 'getPrivacySetting:ok') { + _.setData({ + privacyContractName: res.privacyContractName, + showPrivacy: res.needAuthorization, + }); + } + }, + }); + } + }, + }, + /** + * 组件的方法列表 + */ + methods: { + // 打开隐私协议页面 + openPrivacyContract() { + wx.openPrivacyContract({ + fail: () => { + wx.showToast({ + title: '遇到错误', + icon: 'error', + }); + }, + }); + }, + // 拒绝隐私协议 + exitMiniProgram() { + wx.switchTab({ + url: '/pages/index/index', + }); + }, + // 同意隐私协议 + handleAgreePrivacyAuthorization() { + const _ = this; + _.setData({ + showPrivacy: false, + }); + }, + // 比较版本号 + compareVersion(v1, v2) { + v1 = v1.split('.'); + v2 = v2.split('.'); + const len = Math.max(v1.length, v2.length); + + while (v1.length < len) { + v1.push('0'); + } + while (v2.length < len) { + v2.push('0'); + } + + for (let i = 0; i < len; i++) { + const num1 = parseInt(v1[i]); + const num2 = parseInt(v2[i]); + + if (num1 > num2) { + return 1; + } else if (num1 < num2) { + return -1; + } + } + + return 0; + }, + // 通过绑定空事件禁止滑动事件的穿透 + handleCatchtouchMove() { + return; + }, + }, +}); diff --git a/src/mindspore/components/user-info/user-info.js b/src/mindspore/components/user-info/user-info.js index bacd4ba..5d432b4 100644 --- a/src/mindspore/components/user-info/user-info.js +++ b/src/mindspore/components/user-info/user-info.js @@ -1,70 +1,70 @@ // components/user-info/user-info.js const sessionUtil = require('../../utils/app-session.js'); const localMethods = { - getCurText() { - let timestamp = Date.parse(new Date()); - timestamp = timestamp / 1000; - let n = timestamp * 1000; - let date = new Date(n); - let h = date.getHours(); - let m = date.getMinutes(); - let hm = parseFloat(h + '.' + m); - if (23 < hm || hm <= 6) { - return '请睡吧'; - } - if (6 < hm && hm <= 12) { - return '上午好'; - } - if (12 < hm && hm <= 14) { - return '中午好'; - } - if (14 < hm && hm <= 18) { - return '下午好'; - } - if (18 < hm && hm <= 23) { - return '晚上好'; - } - }, + getCurText() { + let timestamp = Date.parse(new Date()); + timestamp = timestamp / 1000; + let n = timestamp * 1000; + let date = new Date(n); + let h = date.getHours(); + let m = date.getMinutes(); + let hm = parseFloat(h + '.' + m); + if (23 < hm || hm <= 6) { + return '请睡吧'; + } + if (6 < hm && hm <= 12) { + return '上午好'; + } + if (12 < hm && hm <= 14) { + return '中午好'; + } + if (14 < hm && hm <= 18) { + return '下午好'; + } + if (18 < hm && hm <= 23) { + return '晚上好'; + } + }, }; Component({ - /** - * 组件的属性列表 - */ - properties: {}, + /** + * 组件的属性列表 + */ + properties: {}, - /** - * 组件的初始数据 - */ - data: { - isLogin: false, - avatarUrl: '', - text: '', - nickName: '', - }, - pageLifetimes: { - // 组件所在页面的生命周期函数 + /** + * 组件的初始数据 + */ + data: { + isLogin: false, + avatarUrl: '', + text: '', + nickName: '', + }, + pageLifetimes: { + // 组件所在页面的生命周期函数 - show: function () { - this.setData({ - isLogin: sessionUtil.getUserInfoByKey('access') || false, - }); - if (this.data.isLogin) { - this.setData({ - avatarUrl: sessionUtil.getUserInfoByKey('avatarUrl'), - text: localMethods.getCurText(), - nickName: sessionUtil.getUserInfoByKey('nickName'), - }); - } - }, + show: function () { + this.setData({ + isLogin: sessionUtil.getUserInfoByKey('access') || false, + }); + if (this.data.isLogin) { + this.setData({ + avatarUrl: sessionUtil.getUserInfoByKey('avatarUrl'), + text: localMethods.getCurText(), + nickName: sessionUtil.getUserInfoByKey('nickName'), + }); + } }, - /** - * 组件的方法列表 - */ - methods: { - login() { - wx.navigateTo({ - url: '/pages/auth/auth', - }); - }, + }, + /** + * 组件的方法列表 + */ + methods: { + login() { + wx.navigateTo({ + url: '/pages/auth/auth', + }); }, -}); \ No newline at end of file + }, +}); diff --git a/src/mindspore/config/field-validate-rules.js b/src/mindspore/config/field-validate-rules.js deleted file mode 100644 index a0261d9..0000000 --- a/src/mindspore/config/field-validate-rules.js +++ /dev/null @@ -1,7 +0,0 @@ -const rules = { - email: { - regex: /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, - errorMsg: ' 无效的邮件地址', - }, -} -module.exports = rules; \ No newline at end of file diff --git a/src/mindspore/config/services-config.js b/src/mindspore/config/services-config.js index 23ba59b..666e49b 100644 --- a/src/mindspore/config/services-config.js +++ b/src/mindspore/config/services-config.js @@ -2,208 +2,208 @@ let _ = require('../utils/underscore-extend.js'); // 通用接口配置 let commonServiceConfig = { - // 登录接口 - LOGIN: '/login/', + // 登录接口 + LOGIN: '/login/', - // sig列表 - SIG_LIST: '/sigs/', + // sig列表 + SIG_LIST: '/sigs/', - // msg城市列表 - MSG_LIST: '/cities/', + // msg城市列表 + MSG_LIST: '/cities/', - // 获取当前组已添加成员列表 - GROUP_MEMBER_LIST: '/users_include/', + // 获取当前组已添加成员列表 + GROUP_MEMBER_LIST: '/users_include/', - // 查询某个城市的成员 - GROUP_CITY_MEMBER_LIST: '/users_include_city/', + // 查询某个城市的成员 + GROUP_CITY_MEMBER_LIST: '/users_include_city/', - // 查询一个用户的城市关系 - GROUP_USER_CITY: '/usercity/{id}/', + // 查询一个用户的城市关系 + GROUP_USER_CITY: '/usercity/{id}/', - // 获取当前组未添加成员列表 - GROUP_EXCLUDE_MEMBER_LIST: '/users_exclude/', + // 获取当前组未添加成员列表 + GROUP_EXCLUDE_MEMBER_LIST: '/users_exclude/', - // 查询某个城市的非成员 - GROUP_CITY_EXCLUDE_MEMBER_LIST: '/users_exclude_city/', + // 查询某个城市的非成员 + GROUP_CITY_EXCLUDE_MEMBER_LIST: '/users_exclude_city/', - //获取所有组的信息 - ALL_GROUP_LIST: '/groups/', + //获取所有组的信息 + ALL_GROUP_LIST: '/groups/', - // 添加组员 - ADD_MEMBER_LIST: '/groupuser/action/new/', + // 添加组员 + ADD_MEMBER_LIST: '/groupuser/action/new/', - // MSG城市添加组员 - ADD_CITY_MEMBER_LIST: '/cityuser/action/new/', + // MSG城市添加组员 + ADD_CITY_MEMBER_LIST: '/cityuser/action/new/', - // 删除组员 - DEL_MEMBER_LIST: '/groupuser/action/del/', + // 删除组员 + DEL_MEMBER_LIST: '/groupuser/action/del/', - // 删除MSG城市组员 - DEL_CITY_MEMBER_LIST: '/cityuser/action/del/', + // 删除MSG城市组员 + DEL_CITY_MEMBER_LIST: '/cityuser/action/del/', - // 获取sig组未添加成员列表 - GET_USER_GROUP: '/usergroup/{id}/', + // 获取sig组未添加成员列表 + GET_USER_GROUP: '/usergroup/{id}/', - // 创建会议 - SAVE_MEETING: '/meetings/', + // 创建会议 + SAVE_MEETING: '/meetings/', - // 获取会议详情 - GET_MEETING_DETAIL: '/meetings/{id}/', + // 获取会议详情 + GET_MEETING_DETAIL: '/meetings/{id}/', - // 最近的会议列表 - RECENTLY_MEETINGS: '/meetingslist/?range=recently', + // 最近的会议列表 + RECENTLY_MEETINGS: '/meetingslist/?range=recently', - // 获取当日会议列表 - GET_MEETING_DAILY: '/meetingslist/?range=daily', + // 获取当日会议列表 + GET_MEETING_DAILY: '/meetingslist/?range=daily', - // 获取前后一周会议列表 - GET_MEETING_WEEKLY: '/meetingslist/?range=weekly', + // 获取前后一周会议列表 + GET_MEETING_WEEKLY: '/meetingslist/?range=weekly', - // 删除会议 - DEL_MEETING: '/meeting/{id}/', + // 删除会议 + DEL_MEETING: '/meeting/{id}/', - // 获取用户状态 - GET_USER_STATUS: '/userinfo/{id}/', + // 获取用户状态 + GET_USER_STATUS: '/userinfo/{id}/', - // "我的"页面各项计数 - GET_COUNTS: '/counts/', + // "我的"页面各项计数 + GET_COUNTS: '/counts/', - // 保存用户giteename - SAVE_MEMBER_DETAIL: '/user/{id}/', + // 保存用户giteename + SAVE_MEMBER_DETAIL: '/user/{id}/', - // 我创建的会议列表 - MY_MEETINGS_LIST: '/mymeetings/', + // 我创建的会议列表 + MY_MEETINGS_LIST: '/mymeetings/', - // 收藏会议 - COLLECT: '/collect/', + // 收藏会议 + COLLECT: '/collect/', - // 取消收藏 - UNCOLLECT: '/collect/{id}/', + // 取消收藏 + UNCOLLECT: '/collect/{id}/', - // 收藏列表 - MY_COLLECT_LIST: '/collections/', + // 收藏列表 + MY_COLLECT_LIST: '/collections/', - // 获取发起人列表 - ENTERPRISE_MEMBER_LIST: '/sponsors/', + // 获取发起人列表 + ENTERPRISE_MEMBER_LIST: '/sponsors/', - // 获取未添加发起人名单 - ENTERPRISE_EXCLUDE_MEMBER_LIST: '/nonsponsors/', + // 获取未添加发起人名单 + ENTERPRISE_EXCLUDE_MEMBER_LIST: '/nonsponsors/', - // 添加发起人 - ENTERPRISE_ADD_MEMBER_LIST: '/sponsor/action/new/', + // 添加发起人 + ENTERPRISE_ADD_MEMBER_LIST: '/sponsor/action/new/', - // 编辑发起人信息 - ENTERPRISE_SAVE_MEMBER_DETAIL: '/user/{id}/', + // 编辑发起人信息 + ENTERPRISE_SAVE_MEMBER_DETAIL: '/user/{id}/', - // 删除发起人 - ENTERPRISE_DEL_MEMBER_LIST: '/sponsor/action/del/', + // 删除发起人 + ENTERPRISE_DEL_MEMBER_LIST: '/sponsor/action/del/', - // 发布 - PUBLISH_EVENT: '/activity/?publish=true', + // 发布 + PUBLISH_EVENT: '/activity/?publish=true', - // 保存草稿 - SAVE_DRAFT: '/activity/', + // 保存草稿 + SAVE_DRAFT: '/activity/', - // 获取草稿箱活动列表 - GET_DRAFT_LIST: '/activitiesdraft/', + // 获取草稿箱活动列表 + GET_DRAFT_LIST: '/activitiesdraft/', - // 我的待发布活动列表(发布中) - MY_WAITING_ACTIVITIES: '/mywaitingactivities/', + // 我的待发布活动列表(发布中) + MY_WAITING_ACTIVITIES: '/mywaitingactivities/', - // 待发布活动列表(超级管理员) - WAITING_ACTIVITIES: '/waitingactivities/', + // 待发布活动列表(超级管理员) + WAITING_ACTIVITIES: '/waitingactivities/', - // 活动收藏列表(已收藏) - ACTIVITY_COLLECTIONS: '/activitycollections/', + // 活动收藏列表(已收藏) + ACTIVITY_COLLECTIONS: '/activitycollections/', - // 我报名的活动(已报名) - MY_REGISTERD_ACTIVITES: '/myregisterdactivities/', + // 我报名的活动(已报名) + MY_REGISTERD_ACTIVITES: '/myregisterdactivities/', - // 活动草稿箱列表 - DRAFTS: '/drafts/', + // 活动草稿箱列表 + DRAFTS: '/drafts/', - //草稿详情 - DRAFT_DETAIL: '/draft/{id}/', + //草稿详情 + DRAFT_DETAIL: '/draft/{id}/', - // 修改草稿 - EDIT_DETAIL: '/draftupdate/{id}/', + // 修改草稿 + EDIT_DETAIL: '/draftupdate/{id}/', - // 修改草稿并发布 + // 修改草稿并发布 - EDIT_DETAIL_PUBLISH: '/draftupdate/{id}/?publish=true', + EDIT_DETAIL_PUBLISH: '/draftupdate/{id}/?publish=true', - // 驳回活动发布 - REJECT_PUBLISH: '/activity/action/deny/{id}/', + // 驳回活动发布 + REJECT_PUBLISH: '/activity/action/deny/{id}/', - // 活动审核通过 - RESOLVE_PUBLISH: '/activity/action/approve/{id}/', + // 活动审核通过 + RESOLVE_PUBLISH: '/activity/action/approve/{id}/', - // 活动审核通过 - PUBLISHER_EVENTS_LIST: '/sponsoractivitiespublishing/', + // 活动审核通过 + PUBLISHER_EVENTS_LIST: '/sponsoractivitiespublishing/', - // 我发布的活动新增 - MY_EVENTS_LISTS: '/mypublishedactivities/', - // 我发布的活动 - MY_EVENTS_LIST: '/sponsoractivities/', + // 我发布的活动新增 + MY_EVENTS_LISTS: '/mypublishedactivities/', + // 我发布的活动 + MY_EVENTS_LIST: '/sponsoractivities/', - // 我发布的活动 - DEL_EVENT: '/activity/action/del/{id}/', + // 我发布的活动 + DEL_EVENT: '/activity/action/del/{id}/', - // 所有活动 - ALL_EVENTS_LIST: '/activities/', + // 所有活动 + ALL_EVENTS_LIST: '/activities/', - // 所有活动 - EVENT_DETAIL: '/activity/{id}/', + // 所有活动 + EVENT_DETAIL: '/activity/{id}/', - // 修改日程 - EDIT_SCHEDULE: '/activityupdate/{id}/', + // 修改日程 + EDIT_SCHEDULE: '/activityupdate/{id}/', - // 修改日程 - EXAMINE_DETAIL: '/waitingactivity/{id}/', + // 修改日程 + EXAMINE_DETAIL: '/waitingactivity/{id}/', - // 收藏活动 - EVENT_COLLECT: '/activity/action/collect/', + // 收藏活动 + EVENT_COLLECT: '/activity/action/collect/', - // 收藏活动: - EVENT_COLLECTS: '/activity/action/collect/', + // 收藏活动: + EVENT_COLLECTS: '/activity/action/collect/', - // 取消收藏 - EVENT_UNCOLLECT: '/activity/action/collectdel/{id}/', + // 取消收藏 + EVENT_UNCOLLECT: '/activity/action/collectdel/{id}/', - // 活动收藏列表 - EVENT_COLLECT_LIST: '/collectactivities/', + // 活动收藏列表 + EVENT_COLLECT_LIST: '/collectactivities/', - // 最新活动列表 - LATEST_EVENTS: '/recentactivities/', + // 最新活动列表 + LATEST_EVENTS: '/recentactivities/', - // 我报名的活动 - MY_SIGNUP_EVENTS: '/registeractivities/', + // 我报名的活动 + MY_SIGNUP_EVENTS: '/registeractivities/', - // 保存意见反馈 - SAVE_FEEDBACK: '/feedback/', + // 保存意见反馈 + SAVE_FEEDBACK: '/feedback/', - // 获取已发布分类数量 - GET_EVENTS_COUNT: '/countactivities/', + // 获取已发布分类数量 + GET_EVENTS_COUNT: '/countactivities/', - // 获取我已预定的会议 - GET_MY_MEETING: '/mymeetings/', + // 获取我已预定的会议 + GET_MY_MEETING: '/mymeetings/', - // 获取我已收藏的会议 - GET_MY_COLLECT: '/collections/', + // 获取我已收藏的会议 + GET_MY_COLLECT: '/collections/', - // 同意隐私政策 - AGREE: '/agree/', + // 同意隐私政策 + AGREE: '/agree/', - //添加城市 - ADDCITY: '/city/', - // 退出登陆 - LOGOUT: '/logout/', - // 注销账号 - LOGOFF: '/logoff/', - // 撤销登陆 - REVOKE: '/revoke/' + //添加城市 + ADDCITY: '/city/', + // 退出登陆 + LOGOUT: '/logout/', + // 注销账号 + LOGOFF: '/logoff/', + // 撤销登陆 + REVOKE: '/revoke/', }; let servicesConfig = _.deepExtend(true, commonServiceConfig); -module.exports = servicesConfig; \ No newline at end of file +module.exports = servicesConfig; diff --git a/src/mindspore/package-events/events/event-detail.js b/src/mindspore/package-events/events/event-detail.js index 11fb965..aeacac0 100644 --- a/src/mindspore/package-events/events/event-detail.js +++ b/src/mindspore/package-events/events/event-detail.js @@ -277,21 +277,21 @@ Page({ return; } wx.showModal({ - title: '提示', - content: '即将唤起腾讯地图,是否同意?', - success(res) { - if (res.confirm) { - wx.openLocation({ - latitude: Number(e.currentTarget.dataset.item.latitude), - longitude: Number(e.currentTarget.dataset.item.longitude), - name: e.currentTarget.dataset.item.detail_address, // 名称 - address: e.currentTarget.dataset.item.address, // 地址 - }); - } else if (res.cancel) { - return false - } + title: '提示', + content: '即将唤起腾讯地图,是否同意?', + success(res) { + if (res.confirm) { + wx.openLocation({ + latitude: Number(e.currentTarget.dataset.item.latitude), + longitude: Number(e.currentTarget.dataset.item.longitude), + name: e.currentTarget.dataset.item.detail_address, // 名称 + address: e.currentTarget.dataset.item.address, // 地址 + }); + } else if (res.cancel) { + return false; } - }) + }, + }); }, toEditDraft() { wx.redirectTo({ diff --git a/src/mindspore/package-events/events/event-list.js b/src/mindspore/package-events/events/event-list.js index c6252d7..3c5f48b 100644 --- a/src/mindspore/package-events/events/event-list.js +++ b/src/mindspore/package-events/events/event-list.js @@ -1,331 +1,331 @@ -// package-events/events/test.js -const appAjax = require('./../../utils/app-ajax'); -const sessionUtil = require('../../utils/app-session.js'); -let that = null; - -let remoteMethods = { - getList: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service: 'ALL_EVENTS_LIST', - data: { - activity_status: that.data.activity, - activity_category: that.data.curFilterType, - search: that.data.curKeyword, - }, - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, - getCount: function (_callback) { - appAjax.postJson({ - type: 'GET', - service: 'GET_EVENTS_COUNT', - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, - delDraft: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'DELETE', - service: 'DRAFT_DETAIL', - otherParams: { - id: that.data.curId, - }, - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, - delEvent: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'PUT', - service: 'DEL_EVENT', - otherParams: { - id: that.data.curId, - }, - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, - collect: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'POST', - service: 'EVENT_COLLECT', - data: { - activity: that.data.curId, - }, - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, - unCollect: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'DELETE', - service: 'EVENT_UNCOLLECT', - otherParams: { - id: that.data.collectionId, - }, - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, -}; -Page({ - /** - * 页面的初始数据 - */ - data: { - level: 1, - user: '', - curKeyword: '', - popShow: false, - curFilterType: '', - curfilterTypeName: '全部类型', - filterType: '', - filterTypeName: '全部类型', - columns: [ - { - type: '', - name: '全部类型', - }, - { - type: 1, - name: '课程', - }, - { - type: 2, - name: 'MSG', - }, - { - type: 3, - name: '赛事', - }, - { - type: 4, - name: '其他', - }, - ], - list: [], - actionShow: false, - actions: [], - showDialogDel: false, - underDialogShow: false, - noAuthDialogShow: false, - activity: '', - allNum: 0, - signUpNum: 0, - goingNum: 0, - complatedNum: 0, - curId: '', - registerId: '', - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function () { - that = this; - remoteMethods.getList((res) => { - that.setData({ - list: res, - level: sessionUtil.getUserInfoByKey('eventLevel') || 1, - user: sessionUtil.getUserInfoByKey('userId'), - }); - }); - remoteMethods.getCount((res) => { - that.setData({ - allNum: res.all_activities_count, - signUpNum: res.registering_activities_count, - goingNum: res.going_activities_count, - complatedNum: res.completed_activities_count, - }); - }); - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () {}, - search: function (e) { - this.setData({ - curKeyword: e.detail.value, - }); - this.onLoad(); - }, - filterType: function () { - this.setData({ - popShow: true, - }); - }, - popCancel: function () { - this.setData({ - popShow: false, - filterType: this.data.curFilterType, - filterTypeName: this.data.curfilterTypeName, - }); - }, - pickerChange: function (e) { - this.setData({ - filterType: e.detail.value.type, - filterTypeName: e.detail.value.name, - }); - }, - popConfirm: function () { - this.setData({ - popShow: false, - curFilterType: this.data.filterType, - curfilterTypeName: this.data.filterTypeName, - }); - this.onLoad(); - }, - toUpdateSchedule(e) { - wx.navigateTo({ - url: `/package-events/events/event-detail?id=${e.currentTarget.dataset.id}&type=5`, - }); - }, - onActionClose() { - this.setData({ - actionShow: false, - }); - }, - - onActionSelect(e) { - if (this.data.level == 3) { - if (e.detail.operaType == 1) { - if (this.data.collectionId) { - remoteMethods.unCollect(() => { - this.onLoad(); - }); - } else { - remoteMethods.collect(() => { - this.onLoad(); - }); - } - } else if(e.detail.operaType == 2){ - this.setData({ - showDialogDel:true - }) - } - } else if (e.detail.operaType == 1) { - if (this.data.collectionId) { - remoteMethods.unCollect(() => { - this.onLoad(); - }); - } else { - remoteMethods.collect(() => { - this.onLoad(); - }); - } - } else if (e.detail.operaType == 3) { - return; - } else { - this.setData({ - underDialogShow: true, - }); - } - }, - onMore(e) { - this.setData({ - actionShow: true, - curId: e.currentTarget.dataset.item.id, - userId: e.currentTarget.dataset.item.user, - collectionId: e.currentTarget.dataset.item.collection_id || '', - registerId: e.currentTarget.dataset.item.register_id || '', - }); - const strTemp = this.data.collectionId ? '取消收藏' : '收藏活动'; - if (this.data.level == 3) { - this.setData({ - actions: [ - { - name: strTemp, - operaType: 1, - }, - { - name: '下架活动', - operaType: 2, - }, - ], - }); - } else { - if (this.data.user == this.data.userId) { - this.setData({ - actions: [ - { - name: strTemp, - operaType: 1, - }, - { - name: '下架活动', - operaType: 2, - }, - ], - }); - } else { - this.setData({ - actions: [ - { - name: strTemp, - operaType: 1, - }, - ], - }); - } - - if (this.data.registerId) { - let tempArr = this.data.actions; - tempArr.unshift({ - name: '查看门票', - operaType: 3, - }); - this.setData({ - actions: tempArr, - }); - } - } - }, - del() { - this.setData({ - showDialogDel: false, - }); - remoteMethods.delEvent(() => { - this.onLoad(); - }); - }, - delCancel() { - this.setData({ - showDialogDel: false, - }); - }, - copyWechat() { - wx.setClipboardData({ - data: 'mindspore0328', - success: () => { - this.setData({ - noAuthDialogShow: false, - underDialogShow: false, - }); - }, - }); - }, - switchTab(e) { - this.setData({ - activity: e.currentTarget.dataset.type || '', - }); - this.onLoad(); - }, - onPullDownRefresh: function () { - wx.stopPullDownRefresh(); - this.onLoad(); - }, -}); +// package-events/events/test.js +const appAjax = require('./../../utils/app-ajax'); +const sessionUtil = require('../../utils/app-session.js'); +let that = null; + +let remoteMethods = { + getList: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service: 'ALL_EVENTS_LIST', + data: { + activity_status: that.data.activity, + activity_category: that.data.curFilterType, + search: that.data.curKeyword, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + getCount: function (_callback) { + appAjax.postJson({ + type: 'GET', + service: 'GET_EVENTS_COUNT', + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + delDraft: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'DELETE', + service: 'DRAFT_DETAIL', + otherParams: { + id: that.data.curId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + delEvent: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'PUT', + service: 'DEL_EVENT', + otherParams: { + id: that.data.curId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + collect: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'POST', + service: 'EVENT_COLLECT', + data: { + activity: that.data.curId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + unCollect: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'DELETE', + service: 'EVENT_UNCOLLECT', + otherParams: { + id: that.data.collectionId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; +Page({ + /** + * 页面的初始数据 + */ + data: { + level: 1, + user: '', + curKeyword: '', + popShow: false, + curFilterType: '', + curfilterTypeName: '全部类型', + filterType: '', + filterTypeName: '全部类型', + columns: [ + { + type: '', + name: '全部类型', + }, + { + type: 1, + name: '课程', + }, + { + type: 2, + name: 'MSG', + }, + { + type: 3, + name: '赛事', + }, + { + type: 4, + name: '其他', + }, + ], + list: [], + actionShow: false, + actions: [], + showDialogDel: false, + underDialogShow: false, + noAuthDialogShow: false, + activity: '', + allNum: 0, + signUpNum: 0, + goingNum: 0, + complatedNum: 0, + curId: '', + registerId: '', + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function () { + that = this; + remoteMethods.getList((res) => { + that.setData({ + list: res, + level: sessionUtil.getUserInfoByKey('eventLevel') || 1, + user: sessionUtil.getUserInfoByKey('userId'), + }); + }); + remoteMethods.getCount((res) => { + that.setData({ + allNum: res.all_activities_count, + signUpNum: res.registering_activities_count, + goingNum: res.going_activities_count, + complatedNum: res.completed_activities_count, + }); + }); + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () {}, + search: function (e) { + this.setData({ + curKeyword: e.detail.value, + }); + this.onLoad(); + }, + filterType: function () { + this.setData({ + popShow: true, + }); + }, + popCancel: function () { + this.setData({ + popShow: false, + filterType: this.data.curFilterType, + filterTypeName: this.data.curfilterTypeName, + }); + }, + pickerChange: function (e) { + this.setData({ + filterType: e.detail.value.type, + filterTypeName: e.detail.value.name, + }); + }, + popConfirm: function () { + this.setData({ + popShow: false, + curFilterType: this.data.filterType, + curfilterTypeName: this.data.filterTypeName, + }); + this.onLoad(); + }, + toUpdateSchedule(e) { + wx.navigateTo({ + url: `/package-events/events/event-detail?id=${e.currentTarget.dataset.id}&type=5`, + }); + }, + onActionClose() { + this.setData({ + actionShow: false, + }); + }, + + onActionSelect(e) { + if (this.data.level == 3) { + if (e.detail.operaType == 1) { + if (this.data.collectionId) { + remoteMethods.unCollect(() => { + this.onLoad(); + }); + } else { + remoteMethods.collect(() => { + this.onLoad(); + }); + } + } else if (e.detail.operaType == 2) { + this.setData({ + showDialogDel: true, + }); + } + } else if (e.detail.operaType == 1) { + if (this.data.collectionId) { + remoteMethods.unCollect(() => { + this.onLoad(); + }); + } else { + remoteMethods.collect(() => { + this.onLoad(); + }); + } + } else if (e.detail.operaType == 3) { + return; + } else { + this.setData({ + underDialogShow: true, + }); + } + }, + onMore(e) { + this.setData({ + actionShow: true, + curId: e.currentTarget.dataset.item.id, + userId: e.currentTarget.dataset.item.user, + collectionId: e.currentTarget.dataset.item.collection_id || '', + registerId: e.currentTarget.dataset.item.register_id || '', + }); + const strTemp = this.data.collectionId ? '取消收藏' : '收藏活动'; + if (this.data.level == 3) { + this.setData({ + actions: [ + { + name: strTemp, + operaType: 1, + }, + { + name: '下架活动', + operaType: 2, + }, + ], + }); + } else { + if (this.data.user == this.data.userId) { + this.setData({ + actions: [ + { + name: strTemp, + operaType: 1, + }, + { + name: '下架活动', + operaType: 2, + }, + ], + }); + } else { + this.setData({ + actions: [ + { + name: strTemp, + operaType: 1, + }, + ], + }); + } + + if (this.data.registerId) { + let tempArr = this.data.actions; + tempArr.unshift({ + name: '查看门票', + operaType: 3, + }); + this.setData({ + actions: tempArr, + }); + } + } + }, + del() { + this.setData({ + showDialogDel: false, + }); + remoteMethods.delEvent(() => { + this.onLoad(); + }); + }, + delCancel() { + this.setData({ + showDialogDel: false, + }); + }, + copyWechat() { + wx.setClipboardData({ + data: 'mindspore0328', + success: () => { + this.setData({ + noAuthDialogShow: false, + underDialogShow: false, + }); + }, + }); + }, + switchTab(e) { + this.setData({ + activity: e.currentTarget.dataset.type || '', + }); + this.onLoad(); + }, + onPullDownRefresh: function () { + wx.stopPullDownRefresh(); + this.onLoad(); + }, +}); diff --git a/src/mindspore/package-events/events/poster.js b/src/mindspore/package-events/events/poster.js index 47306c3..584aa72 100644 --- a/src/mindspore/package-events/events/poster.js +++ b/src/mindspore/package-events/events/poster.js @@ -1,132 +1,132 @@ -// package-events/events/poster.js -const appAjax = require('./../../utils/app-ajax'); -const { wxml, style } = require('./wxml-to-canvas.js'); - -let that = null; -let remoteMethods = { - getDraftDetail: function (_callback) { - let service = 'EVENT_DETAIL'; - if (that.data.isDraft) { - service = 'DRAFT_DETAIL'; - } - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service, - otherParams: { - id: that.data.id, - }, - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, -}; -Page({ - /** - * 页面的初始数据 - */ - data: { - id: '', - isDraft: '', - info: {}, - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - that = this; - this.widget = this.selectComponent('.widget'); - this.setData({ - id: options.id || '', - isDraft: options.isDraft, - }); - if (this.data.id) { - remoteMethods.getDraftDetail((res) => { - res.start_date = res.start_date.replaceAll('-','.') - res.end_date = res.end_date.replaceAll('-','.') - this.setData({ - info: res, - }); - }); - } else { - this.setData({ - info: { - title: options.title, - start_date:options.starTime.replaceAll('-','.'), - end_date:options.endTime.replaceAll('-','.'), - detail_address: options.address || '', - poster: options.poster, - live_address: options.liveAddress || '', - activity_type: options.activity_type, - }, - isDraft: 1, - }); - } - }, - back() { - wx.navigateBack(); - }, - saveToAlbum() { - wx.showLoading({ - title: '保存中', - mask: true, - }); - const p1 = this.widget.renderToCanvas({ - wxml: wxml({ - title: that.data.info.title, - start_date:that.data.info.start_date.replaceAll('-','.'), - end_date:that.data.info.end_date.replaceAll('-','.'), - address: that.data.info.address, - poster: that.data.info.poster, - qrcode: that.data.info.wx_code, - liveAddress: that.data.info.live_address, - }), - style: style(), - }); - p1.then(() => { - const p2 = this.widget.canvasToTempFilePath(); - p2.then((res) => { - wx.getSetting({ - success() { - wx.saveImageToPhotosAlbum({ - filePath: res.tempFilePath, - success: function () { - wx.showToast({ - title: '保存成功', - icon: 'success', - duration: 2000, - }); - }, - fail: function (err) { - console.log(err); - }, - complete(res) { - wx.hideLoading(); - }, - }); - }, - }); - }); - }); - }, - setAndGetSysImage(data) { - const fsm = wx.getFileSystemManager(); - const fileName = Date.now() + '.png'; - return new Promise((req) => { - const filePath = wx.env.USER_DATA_PATH + '/' + fileName; - fsm.writeFile({ - filePath, - data, - encoding: 'base64', - success: () => { - req(filePath); - }, - fail: (err) => { - req(err); - }, - }); - }); - }, -}); +// package-events/events/poster.js +const appAjax = require('./../../utils/app-ajax'); +const { wxml, style } = require('./wxml-to-canvas.js'); + +let that = null; +let remoteMethods = { + getDraftDetail: function (_callback) { + let service = 'EVENT_DETAIL'; + if (that.data.isDraft) { + service = 'DRAFT_DETAIL'; + } + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service, + otherParams: { + id: that.data.id, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; +Page({ + /** + * 页面的初始数据 + */ + data: { + id: '', + isDraft: '', + info: {}, + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + that = this; + this.widget = this.selectComponent('.widget'); + this.setData({ + id: options.id || '', + isDraft: options.isDraft, + }); + if (this.data.id) { + remoteMethods.getDraftDetail((res) => { + res.start_date = res.start_date.replaceAll('-', '.'); + res.end_date = res.end_date.replaceAll('-', '.'); + this.setData({ + info: res, + }); + }); + } else { + this.setData({ + info: { + title: options.title, + start_date: options.starTime.replaceAll('-', '.'), + end_date: options.endTime.replaceAll('-', '.'), + detail_address: options.address || '', + poster: options.poster, + live_address: options.liveAddress || '', + activity_type: options.activity_type, + }, + isDraft: 1, + }); + } + }, + back() { + wx.navigateBack(); + }, + saveToAlbum() { + wx.showLoading({ + title: '保存中', + mask: true, + }); + const p1 = this.widget.renderToCanvas({ + wxml: wxml({ + title: that.data.info.title, + start_date: that.data.info.start_date.replaceAll('-', '.'), + end_date: that.data.info.end_date.replaceAll('-', '.'), + address: that.data.info.address, + poster: that.data.info.poster, + qrcode: that.data.info.wx_code, + liveAddress: that.data.info.live_address, + }), + style: style(), + }); + p1.then(() => { + const p2 = this.widget.canvasToTempFilePath(); + p2.then((res) => { + wx.getSetting({ + success() { + wx.saveImageToPhotosAlbum({ + filePath: res.tempFilePath, + success: function () { + wx.showToast({ + title: '保存成功', + icon: 'success', + duration: 2000, + }); + }, + fail: function (err) { + console.log(err); + }, + complete() { + wx.hideLoading(); + }, + }); + }, + }); + }); + }); + }, + setAndGetSysImage(data) { + const fsm = wx.getFileSystemManager(); + const fileName = Date.now() + '.png'; + return new Promise((req) => { + const filePath = wx.env.USER_DATA_PATH + '/' + fileName; + fsm.writeFile({ + filePath, + data, + encoding: 'base64', + success: () => { + req(filePath); + }, + fail: (err) => { + req(err); + }, + }); + }); + }, +}); diff --git a/src/mindspore/package-events/events/wxml-to-canvas.js b/src/mindspore/package-events/events/wxml-to-canvas.js index 44d29a2..af3b59e 100644 --- a/src/mindspore/package-events/events/wxml-to-canvas.js +++ b/src/mindspore/package-events/events/wxml-to-canvas.js @@ -1,9 +1,7 @@ const wxml = (data) => { return ` - + ${data.title} diff --git a/src/mindspore/package-events/manage/enterprise-list.js b/src/mindspore/package-events/manage/enterprise-list.js index cbf4bf2..60f26b7 100644 --- a/src/mindspore/package-events/manage/enterprise-list.js +++ b/src/mindspore/package-events/manage/enterprise-list.js @@ -40,11 +40,7 @@ Page({ '&name=' + e.currentTarget.dataset.name + '&nickname=' + - e.currentTarget.dataset.nickname + - '&email=' + - (e.currentTarget.dataset.email || '') + - '&telephone=' + - (e.currentTarget.dataset.telephone || ''), + e.currentTarget.dataset.nickname, }); }, addMember: function () { diff --git a/src/mindspore/package-events/manage/member-detail.js b/src/mindspore/package-events/manage/member-detail.js index 3d35339..0cb9438 100644 --- a/src/mindspore/package-events/manage/member-detail.js +++ b/src/mindspore/package-events/manage/member-detail.js @@ -59,7 +59,7 @@ Page({ duration: 2000, }); return; - } + } remoteMethods.saveMemberGiteeName( { id: that.data.id, @@ -77,11 +77,11 @@ Page({ this.setData({ gitee_name: e.detail.value, }); - } + } }, reset: function () { this.setData({ - gitee_name: '', + gitee_name: '', }); }, }); diff --git a/src/mindspore/package-events/publish/publish.js b/src/mindspore/package-events/publish/publish.js index d61ce31..3456863 100644 --- a/src/mindspore/package-events/publish/publish.js +++ b/src/mindspore/package-events/publish/publish.js @@ -4,896 +4,907 @@ const utils = require('./../../utils/utils.js'); utils.formateDate(); let that = null; let remoteMethods = { - addEvents: function (postData, _callback) { - let type = 'POST'; - let service = 'PUBLISH_EVENT'; - if (that.data.detailType == 4) { - type = 'PUT'; - service = 'EDIT_DETAIL_PUBLISH'; + addEvents: function (postData, _callback) { + let type = 'POST'; + let service = 'PUBLISH_EVENT'; + if (that.data.detailType == 4) { + type = 'PUT'; + service = 'EDIT_DETAIL_PUBLISH'; + } + appAjax.postJson({ + autoShowWait: true, + type, + service, + data: postData, + otherParams: { + id: that.data.id || '', + }, + success: function (ret) { + if (ret.code == 400) { + localMethods.toast(ret.msg); + return; } - appAjax.postJson({ - autoShowWait: true, - type, - service, - data: postData, - otherParams: { - id: that.data.id || '', - }, - success: function (ret) { - if (ret.code == 400) { - localMethods.toast(ret.msg); - return; - } - _callback && _callback(ret); - }, - }); - }, - saveDraft: function (postData, _callback) { - let type = 'POST'; - let service = 'SAVE_DRAFT'; - if (that.data.detailType == 4) { - type = 'PUT'; - service = 'EDIT_DETAIL'; - } else if (that.data.detailType == 5) { - type = 'PUT'; - service = 'EDIT_SCHEDULE'; - } - appAjax.postJson({ - autoShowWait: true, - type, - service, - data: postData, - otherParams: { - id: that.data.id || '', - }, - success: function (ret) { - if (ret.code == 400) { - localMethods.toast(ret.msg); - return; - } - _callback && _callback(ret); - }, - }); - }, - getDraftDetail: function (_callback) { - let service = 'DRAFT_DETAIL'; - if (that.data.detailType == 5) { - service = 'EVENT_DETAIL'; + _callback && _callback(ret); + }, + }); + }, + saveDraft: function (postData, _callback) { + let type = 'POST'; + let service = 'SAVE_DRAFT'; + if (that.data.detailType == 4) { + type = 'PUT'; + service = 'EDIT_DETAIL'; + } else if (that.data.detailType == 5) { + type = 'PUT'; + service = 'EDIT_SCHEDULE'; + } + appAjax.postJson({ + autoShowWait: true, + type, + service, + data: postData, + otherParams: { + id: that.data.id || '', + }, + success: function (ret) { + if (ret.code == 400) { + localMethods.toast(ret.msg); + return; } - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service, - otherParams: { - id: that.data.id, - }, - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, + _callback && _callback(ret); + }, + }); + }, + getDraftDetail: function (_callback) { + let service = 'DRAFT_DETAIL'; + if (that.data.detailType == 5) { + service = 'EVENT_DETAIL'; + } + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service, + otherParams: { + id: that.data.id, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, }; let localMethods = { - validation: function (data) { - if (data.activity_type === 1) { - if (!data.title) { - this.toast('请输入活动名称'); - return; - } - if (!data.start_date) { - this.toast('请选择活动起始日期'); - return; - } - if (!data.end_date) { - this.toast('请选择活动结束日期'); - return; - } - if (!data.address) { - this.toast('请输入活动城市'); - return; - } - if (!data.detail_address) { - this.toast('请输入具体地址'); - return; - } - if (data.register_method === 2 && data.register_url == '') { - this.toast('请输入报名链接'); - return; - } - let flag = true; - data.schedules.forEach((dayItem) => { - dayItem.forEach((item) => { - if (!item.start) { - flag = false; - } - if (!item.end) { - flag = false; - } - if (!item.topic) { - flag = false; - } - }); - }); - if (!flag) { - this.toast('请补充日程必填信息'); - return; - } - } else if (data.activity_type === 2) { - if (!data.title) { - this.toast('请输入活动标题'); - return; - } - if (!data.online_url) { - this.toast('请输入线上链接地址'); - return; - } - if (data.register_method === 2 && data.register_url == '') { - this.toast('请输入报名链接'); - return; - } - let flag = true; - data.schedules.forEach((dayItem) => { - dayItem.forEach((item) => { - if (!item.start) { - flag = false; - } - if (!item.end) { - flag = false; - } - if (!item.topic) { - flag = false; - } - }); - }); - if (!flag) { - this.toast('请补充填写日程必填信息'); - return; - } - } else { - if (!data.title) { - this.toast('请输入活动标题'); - return; - } - if (!data.start_date) { - this.toast('请选择活动起始日期'); - return; - } - if (!data.end_date) { - this.toast('请选择活动结束日期'); - return; - } - if (!data.online_url) { - this.toast('请输入线上链接地址'); - return; - } - if (!data.address) { - this.toast('请输入活动城市'); - return; - } - if (!data.detail_address) { - this.toast('请输入具体地址'); - return; - } - if (data.register_method === 2 && data.register_url == '') { - this.toast('请输入报名链接'); - return; - } - let flag = true; - data.schedules.forEach((dayItem) => { - dayItem.forEach((item) => { - if (!item.start) { - flag = false; - } - if (!item.end) { - flag = false; - } - if (!item.topic) { - flag = false; - } - }); - }); - if (!flag) { - this.toast('请补充填写日程必填信息'); - return; - } - } + validation: function (data) { + if (data.activity_type === 1) { + if (!data.title) { + this.toast('请输入活动名称'); + return; + } + if (!data.start_date) { + this.toast('请选择活动起始日期'); + return; + } + if (!data.end_date) { + this.toast('请选择活动结束日期'); + return; + } + if (!data.address) { + this.toast('请输入活动城市'); + return; + } + if (!data.detail_address) { + this.toast('请输入具体地址'); + return; + } + if (data.register_method === 2 && data.register_url == '') { + this.toast('请输入报名链接'); + return; + } + let flag = true; + data.schedules.forEach((dayItem) => { + dayItem.forEach((item) => { + if (!item.start) { + flag = false; + } + if (!item.end) { + flag = false; + } + if (!item.topic) { + flag = false; + } + }); + }); + if (!flag) { + this.toast('请补充日程必填信息'); + return; + } + } else if (data.activity_type === 2) { + if (!data.title) { + this.toast('请输入活动标题'); + return; + } + if (!data.online_url) { + this.toast('请输入线上链接地址'); + return; + } + if (data.register_method === 2 && data.register_url == '') { + this.toast('请输入报名链接'); + return; + } + let flag = true; + data.schedules.forEach((dayItem) => { + dayItem.forEach((item) => { + if (!item.start) { + flag = false; + } + if (!item.end) { + flag = false; + } + if (!item.topic) { + flag = false; + } + }); + }); + if (!flag) { + this.toast('请补充填写日程必填信息'); + return; + } + } else { + if (!data.title) { + this.toast('请输入活动标题'); + return; + } + if (!data.start_date) { + this.toast('请选择活动起始日期'); + return; + } + if (!data.end_date) { + this.toast('请选择活动结束日期'); + return; + } + if (!data.online_url) { + this.toast('请输入线上链接地址'); + return; + } + if (!data.address) { + this.toast('请输入活动城市'); + return; + } + if (!data.detail_address) { + this.toast('请输入具体地址'); + return; + } + if (data.register_method === 2 && data.register_url == '') { + this.toast('请输入报名链接'); + return; + } + let flag = true; + data.schedules.forEach((dayItem) => { + dayItem.forEach((item) => { + if (!item.start) { + flag = false; + } + if (!item.end) { + flag = false; + } + if (!item.topic) { + flag = false; + } + }); + }); + if (!flag) { + this.toast('请补充填写日程必填信息'); + return; + } + } - return true; - }, - toast: function (msg) { - wx.showToast({ - title: msg, - icon: 'none', - duration: 2000, - }); - }, + return true; + }, + toast: function (msg) { + wx.showToast({ + title: msg, + icon: 'none', + duration: 2000, + }); + }, }; Page({ - data: { - isStar: false, - isEnd: false, - starTime: '', - endTime: '', - id: '', - playback: '', - activeNames: [0], - detailType: 0, - title: '', - date: '', - type: '课程', - form: ['1'], - mode: '小程序报名', - address: '', - addressName: '', - registerUrl: '', - desc: '', - betweenDay: [], - schedule: [{ - start: '', - end: '', - topic: '', - speakerList: [{ - name: '', - title: '', - }, ], - }, ], - allSchedule: [], - typeList: ['课程', 'MSG', '赛事', '其他'], - modeList: ['小程序报名', '跳转其他链接报名'], - datePopShow: false, - timePopShow: false, - formShow: false, - curDate: new Date().getTime(), - currentDate: new Date().getTime(), - minDate: new Date().getTime(), - startTimeIndex: 0, - endTimeIndex: 0, + data: { + isStar: false, + isEnd: false, + starTime: '', + endTime: '', + id: '', + playback: '', + activeNames: [0], + detailType: 0, + title: '', + date: '', + type: '课程', + form: ['1'], + mode: '小程序报名', + address: '', + addressName: '', + registerUrl: '', + desc: '', + betweenDay: [], + schedule: [ + { start: '', end: '', - currentTime: '08:00', - method: 1, - actegory: 1, - tiemIndex: 1, - minTime: 8, - maxTime: 22, - minEndTime: 8, - maxEndTime: 22, - filter(type, options) { - if (type === 'minute') { - return options.filter((option) => option % 5 === 0); - } - return options; - }, - endTimePopShow: false, - currentEndTime: '08:00', - topicSelIndex: 1, - longitude: '', - latitude: '', - liveAddress: '', - }, + topic: '', + speakerList: [ + { + name: '', + title: '', + }, + ], + }, + ], + allSchedule: [], + typeList: ['课程', 'MSG', '赛事', '其他'], + modeList: ['小程序报名', '跳转其他链接报名'], + datePopShow: false, + timePopShow: false, + formShow: false, + curDate: new Date().getTime(), + currentDate: new Date().getTime(), + minDate: new Date().getTime(), + startTimeIndex: 0, + endTimeIndex: 0, + start: '', + end: '', + currentTime: '08:00', + method: 1, + actegory: 1, + tiemIndex: 1, + minTime: 8, + maxTime: 22, + minEndTime: 8, + maxEndTime: 22, + filter(type, options) { + if (type === 'minute') { + return options.filter((option) => option % 5 === 0); + } + return options; + }, + endTimePopShow: false, + currentEndTime: '08:00', + topicSelIndex: 1, + longitude: '', + latitude: '', + liveAddress: '', + }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - that = this; - this.setData({ - id: options.id, - detailType: options.type || 0, - }); - if ((this.data.id && this.data.detailType == 5) || (this.data.id && this.data.detailType == 4)) { - remoteMethods.getDraftDetail((res) => { - res.activity_type == 3 ? (res.activity_type = ['1', '2']) : (res.activity_type = [`${res.activity_type}`]); - this.setData({ - title: res.title, - starTime: res.start_date, - endTime: res.end_date, - actegory: res.activity_category, - form: res.activity_type, - playback: res.replay_url || '', - method: res.register_method, - type: this.data.typeList[res.activity_category - 1], - mode: this.data.modeList[res.register_method - 1], - registerUrl: res.register_url || '', - liveAddress: res.online_url || '', - longitude: res.longitude || '', - latitude: res.latitude || '', - address: res.address || '', - addressName: res.detail_address || '', - desc: res.synopsis || '', - betweenDay: this.getBetweenDateStr(res.start_date, res.end_date), - topicSelIndex: res.poster, - allSchedule: JSON.parse(res.schedules), - }); - }); - } - }, - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () {}, - titleInput(e) { - this.setData({ - title: e.detail.value, - }); - }, - playbackInput(e) { - this.setData({ - playback: e.detail.value, - }); - }, - setStar: function () { - this.setData({ - datePopShow: true, - isStar: true, - }); - }, - setEnd: function () { - this.setData({ - datePopShow: true, - isEnd: true, - }); - }, - dateChange(event) { - this.setData({ - activeNames: event.detail, - }); - }, - onTypeShow: function () { - this.setData({ - typeShow: true, - }); - }, - getBetweenDateStr(starDay, endDay) { - let startDate = Date.parse(starDay); - let endDate = Date.parse(endDay); - if (startDate > endDate) { - return false; - } else if (startDate == endDate) { - starDay = starDay.split(''); - starDay[4] = '年'; - starDay[7] = '月'; - starDay[10] = '日'; - starDay = starDay.join(''); - return [starDay]; - } - let arr = []; - let dates = []; + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + that = this; + this.setData({ + id: options.id, + detailType: options.type || 0, + }); + if ((this.data.id && this.data.detailType == 5) || (this.data.id && this.data.detailType == 4)) { + remoteMethods.getDraftDetail((res) => { + res.activity_type == 3 ? (res.activity_type = ['1', '2']) : (res.activity_type = [`${res.activity_type}`]); + this.setData({ + title: res.title, + starTime: res.start_date, + endTime: res.end_date, + actegory: res.activity_category, + form: res.activity_type, + playback: res.replay_url || '', + method: res.register_method, + type: this.data.typeList[res.activity_category - 1], + mode: this.data.modeList[res.register_method - 1], + registerUrl: res.register_url || '', + liveAddress: res.online_url || '', + longitude: res.longitude || '', + latitude: res.latitude || '', + address: res.address || '', + addressName: res.detail_address || '', + desc: res.synopsis || '', + betweenDay: this.getBetweenDateStr(res.start_date, res.end_date), + topicSelIndex: res.poster, + allSchedule: JSON.parse(res.schedules), + }); + }); + } + }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () {}, + titleInput(e) { + this.setData({ + title: e.detail.value, + }); + }, + playbackInput(e) { + this.setData({ + playback: e.detail.value, + }); + }, + setStar: function () { + this.setData({ + datePopShow: true, + isStar: true, + }); + }, + setEnd: function () { + this.setData({ + datePopShow: true, + isEnd: true, + }); + }, + dateChange(event) { + this.setData({ + activeNames: event.detail, + }); + }, + onTypeShow: function () { + this.setData({ + typeShow: true, + }); + }, + getBetweenDateStr(starDay, endDay) { + let startDate = Date.parse(starDay); + let endDate = Date.parse(endDay); + if (startDate > endDate) { + return false; + } else if (startDate == endDate) { + starDay = starDay.split(''); + starDay[4] = '年'; + starDay[7] = '月'; + starDay[10] = '日'; + starDay = starDay.join(''); + return [starDay]; + } + let arr = []; + let dates = []; - // 设置两个日期UTC时间 - let db = new Date(starDay); - let de = new Date(endDay); + // 设置两个日期UTC时间 + let db = new Date(starDay); + let de = new Date(endDay); - // 获取两个日期GTM时间 - let s = db.getTime() - 24 * 60 * 60 * 1000; - let d = de.getTime() - 24 * 60 * 60 * 1000; + // 获取两个日期GTM时间 + let s = db.getTime() - 24 * 60 * 60 * 1000; + let d = de.getTime() - 24 * 60 * 60 * 1000; - // 获取到两个日期之间的每一天的毫秒数 - for (let i = s; i <= d;) { - i = i + 24 * 60 * 60 * 1000; - arr.push(parseInt(i)); - } + // 获取到两个日期之间的每一天的毫秒数 + for (let i = s; i <= d; ) { + i = i + 24 * 60 * 60 * 1000; + arr.push(parseInt(i)); + } - // 获取每一天的时间 YY-MM-DD - for (let j in arr) { - let time = new Date(arr[j]); - let year = time.getFullYear(time); - let mouth = time.getMonth() + 1 >= 10 ? time.getMonth() + 1 : '0' + (time.getMonth() + 1); - let day = time.getDate() >= 10 ? time.getDate() : '0' + time.getDate(); - let YYMMDD = year + '年-' + mouth + '月' + '-' + day + '日'; - dates.push(YYMMDD); - } + // 获取每一天的时间 YY-MM-DD + for (let j in arr) { + let time = new Date(arr[j]); + let year = time.getFullYear(time); + let mouth = time.getMonth() + 1 >= 10 ? time.getMonth() + 1 : '0' + (time.getMonth() + 1); + let day = time.getDate() >= 10 ? time.getDate() : '0' + time.getDate(); + let YYMMDD = year + '年-' + mouth + '月' + '-' + day + '日'; + dates.push(YYMMDD); + } - return dates; - }, - onModeShow: function () { - this.setData({ - modeShow: true, - }); - }, - dateCancel: function () { - this.setData({ - datePopShow: false, - isStar: false, - isEnd: false, - }); - }, - dateOnInput: function (e) { - this.setData({ - currentDate: e.detail, - }); - }, - dateConfirm: function () { - let time = new Date(this.data.currentDate).Format('yyyy-MM-dd'); - let between = []; - if (this.data.isStar) { - if (this.data.endTime) { - between = this.getBetweenDateStr(time, this.data.endTime); - if (between) { - let allSchedule = []; - for (let i = 0; i < between.length; i++) { - allSchedule.push([{ - start: '', - end: '', - topic: '', - speakerList: [{ - name: '', - title: '', - }, ], - }, ]); - } - between.length > 10 ? - localMethods.toast('暂只支持10天以内活动') : - this.setData({ - starTime: time, - betweenDay: between, - allSchedule: allSchedule, - }); - } else { - localMethods.toast('结束日期应大于等于开始日期'); - } - } else { - this.setData({ - starTime: time, - }); - } - } else if (this.data.starTime) { - between = this.getBetweenDateStr(this.data.starTime, time); - if (between) { - let allSchedule = []; - for (let i = 0; i < between.length; i++) { - allSchedule.push([{ - start: '', - end: '', - topic: '', - speakerList: [{ - name: '', - title: '', - }, ], - }, ]); - } - between.length > 10 ? - localMethods.toast('暂只支持10天以内活动') : - this.setData({ - endTime: time, - betweenDay: between, - allSchedule: allSchedule, - }); - } else { - localMethods.toast('请正确填写日期'); - } + return dates; + }, + onModeShow: function () { + this.setData({ + modeShow: true, + }); + }, + dateCancel: function () { + this.setData({ + datePopShow: false, + isStar: false, + isEnd: false, + }); + }, + dateOnInput: function (e) { + this.setData({ + currentDate: e.detail, + }); + }, + dateConfirm: function () { + let time = new Date(this.data.currentDate).Format('yyyy-MM-dd'); + let between = []; + if (this.data.isStar) { + if (this.data.endTime) { + between = this.getBetweenDateStr(time, this.data.endTime); + if (between) { + let allSchedule = []; + for (let i = 0; i < between.length; i++) { + allSchedule.push([ + { + start: '', + end: '', + topic: '', + speakerList: [ + { + name: '', + title: '', + }, + ], + }, + ]); + } + between.length > 10 + ? localMethods.toast('暂只支持10天以内活动') + : this.setData({ + starTime: time, + betweenDay: between, + allSchedule: allSchedule, + }); } else { - this.setData({ - endTime: time, - }); + localMethods.toast('结束日期应大于等于开始日期'); } - this.setData({ - datePopShow: false, - isStar: false, - isEnd: false, - }); - }, - radioOnChange(e) { - this.setData({ - form: e.detail, - }); - }, - typeRadioOnChange: function (e) { - this.setData({ - type: e.detail, - }); - }, - typeClick(e) { - this.setData({ - actegory: e.currentTarget.dataset.index, - }); - }, - addSpeaker(e) { - const length = - this.data.allSchedule[e.currentTarget.dataset.dayindex][e.currentTarget.dataset.index].speakerList.length; - const key = `allSchedule[${e.currentTarget.dataset.dayindex}][${e.currentTarget.dataset.index}].speakerList[${length}]`; - this.setData({ - [key]: { - name: '', - title: '', + } else { + this.setData({ + starTime: time, + }); + } + } else if (this.data.starTime) { + between = this.getBetweenDateStr(this.data.starTime, time); + if (between) { + let allSchedule = []; + for (let i = 0; i < between.length; i++) { + allSchedule.push([ + { + start: '', + end: '', + topic: '', + speakerList: [ + { + name: '', + title: '', + }, + ], }, - }); - }, - modeRadioOnChange: function (e) { - this.setData({ - mode: e.detail, - }); - }, - radioClick(e) { - this.setData({ - method: e.currentTarget.dataset.index, - }); - }, - selAddress() { - wx.showModal({ - title: '提示', - content: '即将唤起腾讯地图,是否同意?', - success(res) { - if (res.confirm) { - wx.chooseLocation({ - success: function (res) { - that.setData({ - address: res.address, - addressName: res.name, - longitude: res.longitude, - latitude: res.latitude, - }); - }, - fail: function (res) { - console.error(res); - }, - }); - } else if (res.cancel) { - return false - } - } - }) - - }, - addressNameInput(e) { - this.setData({ - addressName: e.detail.value, - }); - }, - registerUrlInput(e) { - this.setData({ - registerUrl: e.detail.value, - }); - }, - descInput(e) { - this.setData({ - desc: e.detail.value, - }); - }, - scheduleTitleInput(e) { - const key = `allSchedule[${e.currentTarget.dataset.dayindex}][${e.currentTarget.dataset.index}].topic`; - this.setData({ - [key]: e.detail.value, - }); - }, - nameInput(e) { - const key = `allSchedule[${e.currentTarget.dataset.dayindex}][${e.currentTarget.dataset.outindex}].speakerList[${e.currentTarget.dataset.innerindex}].name`; - this.setData({ - [key]: e.detail.value, - }); - }, - speakerTitleInput(e) { - const key = `allSchedule[${e.currentTarget.dataset.dayindex}][${e.currentTarget.dataset.outindex}].speakerList[${e.currentTarget.dataset.innerindex}].title`; - this.setData({ - [key]: e.detail.value, - }); - }, - speakerInput(e) { - const key = `allSchedule[${e.currentTarget.dataset.dayindex}][${e.currentTarget.dataset.index}].speaker`; - this.setData({ - [key]: e.detail.value, - }); - }, - scheduleDescInput(e) { - const key = `allSchedule[${e.currentTarget.dataset.dayindex}][${e.currentTarget.dataset.index}].desc`; - this.setData({ - [key]: e.detail.value, - }); - }, - addSchedule(e) { - let arrTemp = this.data.allSchedule; - let index = e.currentTarget.dataset.index; - arrTemp[index].push({ - start: '', - end: '', - topic: '', - speakerList: [], - }); - this.setData({ - allSchedule: arrTemp, - }); - }, - delSchedule(e) { - let index = e.currentTarget.dataset.index; - let arrTemp = this.data.allSchedule; - arrTemp[e.currentTarget.dataset.dayindex].splice(index, 1); - this.setData({ - allSchedule: arrTemp, - }); - }, - delSpeaker(e) { - let arrTemp = this.data.allSchedule[e.currentTarget.dataset.index][e.currentTarget.dataset.outindex].speakerList; - let key = `allSchedule[${e.currentTarget.dataset.index}][${e.currentTarget.dataset.outindex}].speakerList`; - arrTemp.splice(e.currentTarget.dataset.innerindex, 1); - this.setData({ - [key]: arrTemp, - }); - }, - selTime: function (e) { - this.setData({ - tiemIndex: e.currentTarget.dataset.dayindex, - timePopShow: true, - startTimeIndex: e.currentTarget.dataset.index, - }); - }, - timeCancel: function () { - this.setData({ - timePopShow: false, - }); - }, - timeOnInput: function (e) { - this.setData({ - currentTime: e.detail, - }); - }, - timeConfirm: function () { - const key = `allSchedule[${this.data.tiemIndex}][${this.data.startTimeIndex}].start`; - this.setData({ - [key]: this.data.currentTime, - timePopShow: false, - }); - }, - typeCancel: function () { - this.setData({ - typeShow: false, - }); - }, - typeConfirm: function () { - this.setData({ - typeShow: false, - }); - }, - modeCancel: function () { - this.setData({ - modeShow: false, - }); - }, - modeConfirm: function () { - this.setData({ - modeShow: false, - }); - }, - selEndTime: function (e) { - this.setData({ - tiemIndex: e.currentTarget.dataset.dayindex, - endTimePopShow: true, - endTimeIndex: e.currentTarget.dataset.index, - }); - }, - endTimeOnInput: function (e) { - this.setData({ - currentEndTime: e.detail, - }); - }, - endTimeConfirm: function () { - const key = `allSchedule[${this.data.tiemIndex}][${this.data.endTimeIndex}].end`; - this.setData({ - [key]: this.data.currentEndTime, - endTimePopShow: false, - }); - }, - endTimeCancel: function () { - this.setData({ - endTimePopShow: false, - }); - }, - selTop(e) { - this.setData({ - topicSelIndex: e.currentTarget.dataset.index, - }); - }, - liveAddressInput(e) { - this.setData({ - liveAddress: e.detail.value, - }); - }, - publish() { - let postData = {}; - if (this.data.form.length === 0) { - localMethods.toast('请选择活动类型'); - return false; - } - if (this.data.form[0] - 0 === 1 && this.data.form.length !== 2) { - postData = { - title: this.data.title, - activity_category: this.data.actegory, - activity_type: 1, - register_method: this.data.method, - register_url: this.data.registerUrl, - start_date: this.data.starTime, - detail_address: this.data.addressName, - end_date: this.data.endTime, - synopsis: this.data.desc, - address: this.data.address, - longitude: this.data.longitude, - latitude: this.data.latitude, - poster: this.data.topicSelIndex, - schedules: this.data.allSchedule, - }; - } else if (this.data.form[0] - 0 === 2 && this.data.form.length !== 2) { - postData = { - title: this.data.title, - activity_category: this.data.actegory, - register_method: this.data.method, - register_url: this.data.registerUrl, - activity_type: 2, - start_date: this.data.starTime, - end_date: this.data.endTime, - synopsis: this.data.desc, - online_url: this.data.liveAddress, - poster: this.data.topicSelIndex, - schedules: this.data.allSchedule, - }; - } else { - postData = { - title: this.data.title, - activity_category: this.data.actegory, - register_method: this.data.method, - register_url: this.data.registerUrl, - activity_type: 3, - online_url: this.data.liveAddress, - start_date: this.data.starTime, - end_date: this.data.endTime, - synopsis: this.data.desc, - address: this.data.address, - detail_address: this.data.addressName, - longitude: this.data.longitude, - latitude: this.data.latitude, - poster: this.data.topicSelIndex, - schedules: this.data.allSchedule, - }; + ]); } - if (!localMethods.validation(postData)) { - return; - } - remoteMethods.addEvents(postData, () => { - wx.redirectTo({ - url: '/package-events/publish/success?type=2', - }); - }); - }, - saveDraft() { - let postData = {}; - if (this.data.form[0] == 1 && this.data.form.length !== 2) { - postData = { - title: this.data.title, - activity_category: this.data.actegory, - activity_type: 1, - register_method: this.data.method, - register_url: this.data.registerUrl, - start_date: this.data.starTime, - end_date: this.data.endTime, - synopsis: this.data.desc, - address: this.data.address, - detail_address: this.data.addressName, - longitude: this.data.longitude, - latitude: this.data.latitude, - poster: this.data.topicSelIndex, - schedules: this.data.allSchedule, - }; - } else if (this.data.form[0] == 2 && this.data.form.length !== 2) { - postData = { - title: this.data.title, - activity_category: this.data.actegory, - activity_type: 2, - register_url: this.data.registerUrl, - register_method: this.data.method, - start_date: this.data.starTime, - end_date: this.data.endTime, - synopsis: this.data.desc, - online_url: this.data.liveAddress, - poster: this.data.topicSelIndex, - schedules: this.data.allSchedule, - }; - } else { - postData = { - title: this.data.title, - activity_category: this.data.actegory, - activity_type: 3, - register_method: this.data.method, - register_url: this.data.registerUrl, - online_url: this.data.liveAddress, - start_date: this.data.starTime, - end_date: this.data.endTime, - synopsis: this.data.desc, - address: this.data.address, - detail_address: this.data.addressName, - longitude: this.data.longitude, - latitude: this.data.latitude, - poster: this.data.topicSelIndex, - schedules: this.data.allSchedule, - }; - } - if (!localMethods.validation(postData)) { - return; - } - remoteMethods.saveDraft(postData, () => { - wx.redirectTo({ - url: '/package-events/publish/success?type=1', - }); - }); - }, - cancelEditSchedule() { - wx.navigateBack(); - }, - editScheduleConfirm() { - let postData = {}; - if (this.data.form[0] == 1 && this.data.form.length !== 2) { - postData = { - title: this.data.title, - activity_category: this.actegory, - activity_type: 1, - replay_url: this.data.playback, - register_method: this.data.method, - register_url: this.data.registerUrl, - start_date: this.data.starTime, - end_date: this.data.endTime, - synopsis: this.data.desc, - address: this.data.address, - detail_address: this.data.addressName, - longitude: this.data.longitude, - latitude: this.data.latitude, - poster: this.data.topicSelIndex, - schedules: this.data.allSchedule, - }; - } else if (this.data.form[0] == 2 && this.data.form.length !== 2) { - postData = { - title: this.data.title, - activity_category: this.data.actegory, - activity_type: 2, - replay_url: this.data.playback, - register_url: this.data.registerUrl, - register_method: this.data.method, - start_date: this.data.starTime, - end_date: this.data.endTime, - synopsis: this.data.desc, - online_url: this.data.liveAddress, - poster: this.data.topicSelIndex, - schedules: this.data.allSchedule, - }; - } else { - postData = { - title: this.data.title, - activity_category: this.data.actegory, - activity_type: 3, - replay_url: this.data.playback, - register_method: this.data.method, - register_url: this.data.registerUrl, - online_url: this.data.liveAddress, - start_date: this.data.starTime, - end_date: this.data.endTime, - synopsis: this.data.desc, - address: this.data.address, - detail_address: this.data.addressName, - longitude: this.data.longitude, - latitude: this.data.latitude, - poster: this.data.topicSelIndex, - schedules: this.data.allSchedule, - }; - } - if (!localMethods.validation(postData)) { - return; - } - postData.schedules = JSON.stringify(this.data.allSchedule); - remoteMethods.saveDraft(postData, () => { - wx.redirectTo({ - url: '/package-events/publish/success?type=3', + between.length > 10 + ? localMethods.toast('暂只支持10天以内活动') + : this.setData({ + endTime: time, + betweenDay: between, + allSchedule: allSchedule, }); - }); - }, - toPoster() { - let activityType = 0; - if (this.data.form[0] == 1 && this.data.form.length !== 2) { - activityType = 1; - } else if (this.data.form[0] == 2) { - activityType = 2; - } else { - activityType = 3; + } else { + localMethods.toast('请正确填写日期'); + } + } else { + this.setData({ + endTime: time, + }); + } + this.setData({ + datePopShow: false, + isStar: false, + isEnd: false, + }); + }, + radioOnChange(e) { + this.setData({ + form: e.detail, + }); + }, + typeRadioOnChange: function (e) { + this.setData({ + type: e.detail, + }); + }, + typeClick(e) { + this.setData({ + actegory: e.currentTarget.dataset.index, + }); + }, + addSpeaker(e) { + const length = + this.data.allSchedule[e.currentTarget.dataset.dayindex][e.currentTarget.dataset.index].speakerList.length; + const key = `allSchedule[${e.currentTarget.dataset.dayindex}][${e.currentTarget.dataset.index}].speakerList[${length}]`; + this.setData({ + [key]: { + name: '', + title: '', + }, + }); + }, + modeRadioOnChange: function (e) { + this.setData({ + mode: e.detail, + }); + }, + radioClick(e) { + this.setData({ + method: e.currentTarget.dataset.index, + }); + }, + selAddress() { + wx.showModal({ + title: '提示', + content: '即将唤起腾讯地图,是否同意?', + success(res) { + if (res.confirm) { + wx.chooseLocation({ + success: function (res) { + that.setData({ + address: res.address, + addressName: res.name, + longitude: res.longitude, + latitude: res.latitude, + }); + }, + fail: function (res) { + console.error(res); + }, + }); + } else if (res.cancel) { + return false; } - const address = this.data.addressName; - const liveAddress = this.data.liveAddress; - wx.navigateTo({ - url: `/package-events/events/poster?title=${this.data.title}&starTime=${this.data.starTime}&endTime=${this.data.endTime}&address=${address}&poster=${this.data.topicSelIndex}&liveAddress=${liveAddress}&activity_type=${activityType}`, - }); - }, -}); \ No newline at end of file + }, + }); + }, + addressNameInput(e) { + this.setData({ + addressName: e.detail.value, + }); + }, + registerUrlInput(e) { + this.setData({ + registerUrl: e.detail.value, + }); + }, + descInput(e) { + this.setData({ + desc: e.detail.value, + }); + }, + scheduleTitleInput(e) { + const key = `allSchedule[${e.currentTarget.dataset.dayindex}][${e.currentTarget.dataset.index}].topic`; + this.setData({ + [key]: e.detail.value, + }); + }, + nameInput(e) { + const key = `allSchedule[${e.currentTarget.dataset.dayindex}][${e.currentTarget.dataset.outindex}].speakerList[${e.currentTarget.dataset.innerindex}].name`; + this.setData({ + [key]: e.detail.value, + }); + }, + speakerTitleInput(e) { + const key = `allSchedule[${e.currentTarget.dataset.dayindex}][${e.currentTarget.dataset.outindex}].speakerList[${e.currentTarget.dataset.innerindex}].title`; + this.setData({ + [key]: e.detail.value, + }); + }, + speakerInput(e) { + const key = `allSchedule[${e.currentTarget.dataset.dayindex}][${e.currentTarget.dataset.index}].speaker`; + this.setData({ + [key]: e.detail.value, + }); + }, + scheduleDescInput(e) { + const key = `allSchedule[${e.currentTarget.dataset.dayindex}][${e.currentTarget.dataset.index}].desc`; + this.setData({ + [key]: e.detail.value, + }); + }, + addSchedule(e) { + let arrTemp = this.data.allSchedule; + let index = e.currentTarget.dataset.index; + arrTemp[index].push({ + start: '', + end: '', + topic: '', + speakerList: [], + }); + this.setData({ + allSchedule: arrTemp, + }); + }, + delSchedule(e) { + let index = e.currentTarget.dataset.index; + let arrTemp = this.data.allSchedule; + arrTemp[e.currentTarget.dataset.dayindex].splice(index, 1); + this.setData({ + allSchedule: arrTemp, + }); + }, + delSpeaker(e) { + let arrTemp = this.data.allSchedule[e.currentTarget.dataset.index][e.currentTarget.dataset.outindex].speakerList; + let key = `allSchedule[${e.currentTarget.dataset.index}][${e.currentTarget.dataset.outindex}].speakerList`; + arrTemp.splice(e.currentTarget.dataset.innerindex, 1); + this.setData({ + [key]: arrTemp, + }); + }, + selTime: function (e) { + this.setData({ + tiemIndex: e.currentTarget.dataset.dayindex, + timePopShow: true, + startTimeIndex: e.currentTarget.dataset.index, + }); + }, + timeCancel: function () { + this.setData({ + timePopShow: false, + }); + }, + timeOnInput: function (e) { + this.setData({ + currentTime: e.detail, + }); + }, + timeConfirm: function () { + const key = `allSchedule[${this.data.tiemIndex}][${this.data.startTimeIndex}].start`; + this.setData({ + [key]: this.data.currentTime, + timePopShow: false, + }); + }, + typeCancel: function () { + this.setData({ + typeShow: false, + }); + }, + typeConfirm: function () { + this.setData({ + typeShow: false, + }); + }, + modeCancel: function () { + this.setData({ + modeShow: false, + }); + }, + modeConfirm: function () { + this.setData({ + modeShow: false, + }); + }, + selEndTime: function (e) { + this.setData({ + tiemIndex: e.currentTarget.dataset.dayindex, + endTimePopShow: true, + endTimeIndex: e.currentTarget.dataset.index, + }); + }, + endTimeOnInput: function (e) { + this.setData({ + currentEndTime: e.detail, + }); + }, + endTimeConfirm: function () { + const key = `allSchedule[${this.data.tiemIndex}][${this.data.endTimeIndex}].end`; + this.setData({ + [key]: this.data.currentEndTime, + endTimePopShow: false, + }); + }, + endTimeCancel: function () { + this.setData({ + endTimePopShow: false, + }); + }, + selTop(e) { + this.setData({ + topicSelIndex: e.currentTarget.dataset.index, + }); + }, + liveAddressInput(e) { + this.setData({ + liveAddress: e.detail.value, + }); + }, + publish() { + let postData = {}; + if (this.data.form.length === 0) { + localMethods.toast('请选择活动类型'); + return false; + } + if (this.data.form[0] - 0 === 1 && this.data.form.length !== 2) { + postData = { + title: this.data.title, + activity_category: this.data.actegory, + activity_type: 1, + register_method: this.data.method, + register_url: this.data.registerUrl, + start_date: this.data.starTime, + detail_address: this.data.addressName, + end_date: this.data.endTime, + synopsis: this.data.desc, + address: this.data.address, + longitude: this.data.longitude, + latitude: this.data.latitude, + poster: this.data.topicSelIndex, + schedules: this.data.allSchedule, + }; + } else if (this.data.form[0] - 0 === 2 && this.data.form.length !== 2) { + postData = { + title: this.data.title, + activity_category: this.data.actegory, + register_method: this.data.method, + register_url: this.data.registerUrl, + activity_type: 2, + start_date: this.data.starTime, + end_date: this.data.endTime, + synopsis: this.data.desc, + online_url: this.data.liveAddress, + poster: this.data.topicSelIndex, + schedules: this.data.allSchedule, + }; + } else { + postData = { + title: this.data.title, + activity_category: this.data.actegory, + register_method: this.data.method, + register_url: this.data.registerUrl, + activity_type: 3, + online_url: this.data.liveAddress, + start_date: this.data.starTime, + end_date: this.data.endTime, + synopsis: this.data.desc, + address: this.data.address, + detail_address: this.data.addressName, + longitude: this.data.longitude, + latitude: this.data.latitude, + poster: this.data.topicSelIndex, + schedules: this.data.allSchedule, + }; + } + if (!localMethods.validation(postData)) { + return; + } + remoteMethods.addEvents(postData, () => { + wx.redirectTo({ + url: '/package-events/publish/success?type=2', + }); + }); + }, + saveDraft() { + let postData = {}; + if (this.data.form[0] == 1 && this.data.form.length !== 2) { + postData = { + title: this.data.title, + activity_category: this.data.actegory, + activity_type: 1, + register_method: this.data.method, + register_url: this.data.registerUrl, + start_date: this.data.starTime, + end_date: this.data.endTime, + synopsis: this.data.desc, + address: this.data.address, + detail_address: this.data.addressName, + longitude: this.data.longitude, + latitude: this.data.latitude, + poster: this.data.topicSelIndex, + schedules: this.data.allSchedule, + }; + } else if (this.data.form[0] == 2 && this.data.form.length !== 2) { + postData = { + title: this.data.title, + activity_category: this.data.actegory, + activity_type: 2, + register_url: this.data.registerUrl, + register_method: this.data.method, + start_date: this.data.starTime, + end_date: this.data.endTime, + synopsis: this.data.desc, + online_url: this.data.liveAddress, + poster: this.data.topicSelIndex, + schedules: this.data.allSchedule, + }; + } else { + postData = { + title: this.data.title, + activity_category: this.data.actegory, + activity_type: 3, + register_method: this.data.method, + register_url: this.data.registerUrl, + online_url: this.data.liveAddress, + start_date: this.data.starTime, + end_date: this.data.endTime, + synopsis: this.data.desc, + address: this.data.address, + detail_address: this.data.addressName, + longitude: this.data.longitude, + latitude: this.data.latitude, + poster: this.data.topicSelIndex, + schedules: this.data.allSchedule, + }; + } + if (!localMethods.validation(postData)) { + return; + } + remoteMethods.saveDraft(postData, () => { + wx.redirectTo({ + url: '/package-events/publish/success?type=1', + }); + }); + }, + cancelEditSchedule() { + wx.navigateBack(); + }, + editScheduleConfirm() { + let postData = {}; + if (this.data.form[0] == 1 && this.data.form.length !== 2) { + postData = { + title: this.data.title, + activity_category: this.actegory, + activity_type: 1, + replay_url: this.data.playback, + register_method: this.data.method, + register_url: this.data.registerUrl, + start_date: this.data.starTime, + end_date: this.data.endTime, + synopsis: this.data.desc, + address: this.data.address, + detail_address: this.data.addressName, + longitude: this.data.longitude, + latitude: this.data.latitude, + poster: this.data.topicSelIndex, + schedules: this.data.allSchedule, + }; + } else if (this.data.form[0] == 2 && this.data.form.length !== 2) { + postData = { + title: this.data.title, + activity_category: this.data.actegory, + activity_type: 2, + replay_url: this.data.playback, + register_url: this.data.registerUrl, + register_method: this.data.method, + start_date: this.data.starTime, + end_date: this.data.endTime, + synopsis: this.data.desc, + online_url: this.data.liveAddress, + poster: this.data.topicSelIndex, + schedules: this.data.allSchedule, + }; + } else { + postData = { + title: this.data.title, + activity_category: this.data.actegory, + activity_type: 3, + replay_url: this.data.playback, + register_method: this.data.method, + register_url: this.data.registerUrl, + online_url: this.data.liveAddress, + start_date: this.data.starTime, + end_date: this.data.endTime, + synopsis: this.data.desc, + address: this.data.address, + detail_address: this.data.addressName, + longitude: this.data.longitude, + latitude: this.data.latitude, + poster: this.data.topicSelIndex, + schedules: this.data.allSchedule, + }; + } + if (!localMethods.validation(postData)) { + return; + } + postData.schedules = JSON.stringify(this.data.allSchedule); + remoteMethods.saveDraft(postData, () => { + wx.redirectTo({ + url: '/package-events/publish/success?type=3', + }); + }); + }, + toPoster() { + let activityType = 0; + if (this.data.form[0] == 1 && this.data.form.length !== 2) { + activityType = 1; + } else if (this.data.form[0] == 2) { + activityType = 2; + } else { + activityType = 3; + } + const address = this.data.addressName; + const liveAddress = this.data.liveAddress; + wx.navigateTo({ + url: `/package-events/events/poster?title=${this.data.title}&starTime=${this.data.starTime}&endTime=${this.data.endTime}&address=${address}&poster=${this.data.topicSelIndex}&liveAddress=${liveAddress}&activity_type=${activityType}`, + }); + }, +}); diff --git a/src/mindspore/package-meeting/meeting/detail.js b/src/mindspore/package-meeting/meeting/detail.js index b935f9b..6b4bba3 100644 --- a/src/mindspore/package-meeting/meeting/detail.js +++ b/src/mindspore/package-meeting/meeting/detail.js @@ -103,6 +103,7 @@ Page({ }); } else { wx.requestSubscribeMessage({ + //TODO::确认用途 tmplIds: ['tK51rqE72oFo5e5ajCnvkPwnsCncfydgcV1jb9ed6Qc', 'kKkokqmaH62qp_txDQrNnyoRbM5wCptTAymhmsfHT7c'], complete() { remoteMethods.collect(that.data.id, function (res) { diff --git a/src/mindspore/package-meeting/sig/member-detail.js b/src/mindspore/package-meeting/sig/member-detail.js index 37b93c8..b300d27 100644 --- a/src/mindspore/package-meeting/sig/member-detail.js +++ b/src/mindspore/package-meeting/sig/member-detail.js @@ -59,7 +59,7 @@ Page({ duration: 2000, }); return; - } + } remoteMethods.saveMemberGiteeName( { id: that.data.id, @@ -77,7 +77,7 @@ Page({ this.setData({ gitee_name: e.detail.value, }); - } else { + } else { return false; } }, diff --git a/src/mindspore/package-my/my/feedback.js b/src/mindspore/package-my/my/feedback.js index a4118a9..f07b4c5 100644 --- a/src/mindspore/package-my/my/feedback.js +++ b/src/mindspore/package-my/my/feedback.js @@ -1,18 +1,17 @@ -// package-my/my/feedback.js -Page({ - - /** - * 页面的初始数据 - */ - copyEmail: function () { - let that = this; - wx.setClipboardData({ - data: 'contact@mindspore.cn', - success: function (res) { - that.setData({ - showDialog: false - }) - } - }) - }, -}) \ No newline at end of file +// package-my/my/feedback.js +Page({ + /** + * 页面的初始数据 + */ + copyEmail: function () { + let that = this; + wx.setClipboardData({ + data: 'contact@mindspore.cn', + success: function () { + that.setData({ + showDialog: false, + }); + }, + }); + }, +}); diff --git a/src/mindspore/package-my/my/privecy-historical.js b/src/mindspore/package-my/my/privecy-historical.js index b385a83..59441a0 100644 --- a/src/mindspore/package-my/my/privecy-historical.js +++ b/src/mindspore/package-my/my/privecy-historical.js @@ -1,48 +1,47 @@ -// pages/my/privecy.js -Page({ - /** - * 页面的初始数据 - */ - data: {}, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function () {}, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () {}, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () {}, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () {}, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () {}, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () {}, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () {}, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () {}, - }); - \ No newline at end of file +// pages/my/privecy.js +Page({ + /** + * 页面的初始数据 + */ + data: {}, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function () {}, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () {}, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () {}, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () {}, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () {}, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () {}, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () {}, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () {}, +}); diff --git a/src/mindspore/package-my/my/privecy-seting.js b/src/mindspore/package-my/my/privecy-seting.js index 06e3237..ba91929 100644 --- a/src/mindspore/package-my/my/privecy-seting.js +++ b/src/mindspore/package-my/my/privecy-seting.js @@ -1,7 +1,5 @@ const appAjax = require('./../../utils/app-ajax'); -const sessionUtil = require('../../utils/app-session.js'); -let that = null; let remoteMethods = { handleLogout: function (_callback) { appAjax.postJson({ @@ -40,9 +38,6 @@ Page({ isLogoffDiaShown: false, content: '', }, - onShow: function () { - that = this; - }, shownDialog: function (e) { const operate = e.currentTarget.dataset.operate; let setDataObject = {}; diff --git a/src/mindspore/package-my/my/privecy.js b/src/mindspore/package-my/my/privecy.js index ba411f8..04c282c 100644 --- a/src/mindspore/package-my/my/privecy.js +++ b/src/mindspore/package-my/my/privecy.js @@ -1,9 +1,7 @@ -//获取应用实例 -// const app = getApp(); - -Page({ - data: { - }, - onLoad: function () { - }, -}) \ No newline at end of file +//获取应用实例 +// const app = getApp(); + +Page({ + data: {}, + onLoad: function () {}, +}); diff --git a/src/mindspore/package-my/my/qrcode.js b/src/mindspore/package-my/my/qrcode.js index 3cd73b0..d59203e 100644 --- a/src/mindspore/package-my/my/qrcode.js +++ b/src/mindspore/package-my/my/qrcode.js @@ -1,60 +1,61 @@ -// package-my/my/qrcode.js -const resourceUrl = 'https://mindspore-website.obs.cn-north-4.myhuaweicloud.com:443/mindsporeMini/'; -Page({ - /** - * 页面的初始数据 - */ - data: { - type: 0, - data: [{ - avatar: resourceUrl + 'official-acc.png', - }, - { - avatar: resourceUrl + 'live-b.png', - }, - { - avatar: resourceUrl + 'headline.png', - }, - ], - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - this.setData({ - type: options.type - 1, - }); - }, - saveQrcode() { - const that = this; - wx.getSetting({ - success() { - wx.downloadFile({ - url: that.data.data[that.data.type].avatar, - success: function (res) { - wx.saveImageToPhotosAlbum({ - filePath: res.tempFilePath, - success: function () { - wx.showToast({ - title: '保存成功', - icon: 'success', - duration: 2000, - }); - }, - fail: function (err) { - console.log(err); - }, - complete(res) { - console.log(res); - }, - }); - }, - failL: function (err) { - console.log(err); - } - }); - }, - }); - }, -}); \ No newline at end of file +// package-my/my/qrcode.js +const resourceUrl = 'https://mindspore-website.obs.cn-north-4.myhuaweicloud.com:443/mindsporeMini/'; +Page({ + /** + * 页面的初始数据 + */ + data: { + type: 0, + data: [ + { + avatar: resourceUrl + 'official-acc.png', + }, + { + avatar: resourceUrl + 'live-b.png', + }, + { + avatar: resourceUrl + 'headline.png', + }, + ], + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.setData({ + type: options.type - 1, + }); + }, + saveQrcode() { + const that = this; + wx.getSetting({ + success() { + wx.downloadFile({ + url: that.data.data[that.data.type].avatar, + success: function (res) { + wx.saveImageToPhotosAlbum({ + filePath: res.tempFilePath, + success: function () { + wx.showToast({ + title: '保存成功', + icon: 'success', + duration: 2000, + }); + }, + fail: function (err) { + console.log(err); + }, + complete(res) { + console.log(res); + }, + }); + }, + failL: function (err) { + console.log(err); + }, + }); + }, + }); + }, +}); diff --git a/src/mindspore/pages/events/events.js b/src/mindspore/pages/events/events.js index 4a6701c..9cc5e42 100644 --- a/src/mindspore/pages/events/events.js +++ b/src/mindspore/pages/events/events.js @@ -5,281 +5,285 @@ const appUser = require('../../utils/app-user.js'); let that = null; let remoteMethods = { - getList: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service: 'LATEST_EVENTS', - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, - delDraft: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'DELETE', - service: 'DRAFT_DETAIL', - otherParams: { - id: that.data.curId, - }, - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, - delEvent: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'PUT', - service: 'DEL_EVENT', - otherParams: { - id: that.data.curId, - }, - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, - collect: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'POST', - service: 'EVENT_COLLECT', - data: { - activity: that.data.curId, - }, - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, - unCollect: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'DELETE', - service: 'EVENT_UNCOLLECT', - otherParams: { - id: that.data.collectionId, - }, - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, + getList: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service: 'LATEST_EVENTS', + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + delDraft: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'DELETE', + service: 'DRAFT_DETAIL', + otherParams: { + id: that.data.curId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + delEvent: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'PUT', + service: 'DEL_EVENT', + otherParams: { + id: that.data.curId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + collect: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'POST', + service: 'EVENT_COLLECT', + data: { + activity: that.data.curId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + unCollect: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'DELETE', + service: 'EVENT_UNCOLLECT', + otherParams: { + id: that.data.collectionId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, }; Page({ - /** - * 页面的初始数据 - */ - data: { - iphoneX: false, - level: 1, - noAuthDialogShow: false, - user: '', - list: [], - typeList: ['课程', 'MSG', '赛事', '其他'], - actionShow: false, - actions: [], - underDialogShow: false, - showDialogDel: false, - curId: '', - userId: '', - collectionId: '', - registerId: '', - }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function () { - that = this; - this.setData({ - iphoneX: this.getTabBar().data.iPhoneX, - }); - appUser.updateUserInfo(function () { - that.setData({ - level: sessionUtil.getUserInfoByKey('eventLevel') || 1, - user: sessionUtil.getUserInfoByKey('userId'), - }); - remoteMethods.getList((res) => { - that.setData({ - list: res, - }); - }); - }); - }, - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - this.getTabBar().setData({ - _tabbat: 2, + /** + * 页面的初始数据 + */ + data: { + iphoneX: false, + level: 1, + noAuthDialogShow: false, + user: '', + list: [], + typeList: ['课程', 'MSG', '赛事', '其他'], + actionShow: false, + actions: [], + underDialogShow: false, + showDialogDel: false, + curId: '', + userId: '', + collectionId: '', + registerId: '', + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function () { + that = this; + this.setData({ + iphoneX: this.getTabBar().data.iPhoneX, + }); + appUser.updateUserInfo(function () { + that.setData({ + level: sessionUtil.getUserInfoByKey('eventLevel') || 1, + user: sessionUtil.getUserInfoByKey('userId'), + }); + remoteMethods.getList((res) => { + that.setData({ + list: res, }); - }, - navigateTo(e) { - const url = e.currentTarget.dataset.url; - if (url.includes('publish') && !sessionUtil.getUserInfoByKey('access')) { - wx.navigateTo({ - url: '/pages/auth/auth', - }); - return; - } - if (this.data.level === 1 && url.includes('publish')) { - this.setData({ - noAuthDialogShow: true, - }); - return; - } - wx.navigateTo({ - url, - }); - }, - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - copyWechat() { - wx.setClipboardData({ - data: 'mindspore0328', - success: () => { - this.setData({ - noAuthDialogShow: false, - underDialogShow: false, - }); - }, - fail: (err) => { - console.log(err); - } - }); - }, - onActionClose() { + }); + }); + }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + this.getTabBar().setData({ + _tabbat: 2, + }); + }, + navigateTo(e) { + const url = e.currentTarget.dataset.url; + if (url.includes('publish') && !sessionUtil.getUserInfoByKey('access')) { + wx.navigateTo({ + url: '/pages/auth/auth', + }); + return; + } + if (this.data.level === 1 && url.includes('publish')) { + this.setData({ + noAuthDialogShow: true, + }); + return; + } + wx.navigateTo({ + url, + }); + }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + copyWechat() { + wx.setClipboardData({ + data: 'mindspore0328', + success: () => { this.setData({ - actionShow: false, + noAuthDialogShow: false, + underDialogShow: false, }); - this.getTabBar().setData({ - show: true, - }); - }, - onActionSelect(e) { - if (this.data.level == 3) { - if (e.detail.operaType == 1) { - if (this.data.collectionId) { - remoteMethods.unCollect(() => { - this.onLoad(); - }); - } else { - remoteMethods.collect(() => { - this.onLoad(); - }); - } - } else if (e.detail.operaType == 2) { - this.setData({ - showDialogDel: true, - }); - } else { - this.setData({ - showDialoogDel: true, - }); - } - } else if (e.detail.operaType == 1) { - if (this.data.collectionId) { - remoteMethods.unCollect(() => { - this.onLoad(); - }); - } else { - remoteMethods.collect(() => { - this.onLoad(); - }); - } - } else if (e.detail.operaType == 3) { - return + }, + fail: (err) => { + console.log(err); + }, + }); + }, + onActionClose() { + this.setData({ + actionShow: false, + }); + this.getTabBar().setData({ + show: true, + }); + }, + onActionSelect(e) { + if (this.data.level == 3) { + if (e.detail.operaType == 1) { + if (this.data.collectionId) { + remoteMethods.unCollect(() => { + this.onLoad(); + }); } else { - this.setData({ - underDialogShow: true, - }); + remoteMethods.collect(() => { + this.onLoad(); + }); } - }, - del() { + } else if (e.detail.operaType == 2) { + this.setData({ + showDialogDel: true, + }); + } else { this.setData({ - showDialogDel: false, + showDialoogDel: true, + }); + } + } else if (e.detail.operaType == 1) { + if (this.data.collectionId) { + remoteMethods.unCollect(() => { + this.onLoad(); }); - remoteMethods.delEvent(() => { - remoteMethods.getList((res) => { - this.setData({ - list: res, - }); - }); + } else { + remoteMethods.collect(() => { + this.onLoad(); }); - }, - delCancel() { + } + } else if (e.detail.operaType == 3) { + return; + } else { + this.setData({ + underDialogShow: true, + }); + } + }, + del() { + this.setData({ + showDialogDel: false, + }); + remoteMethods.delEvent(() => { + remoteMethods.getList((res) => { this.setData({ - showDialogDel: false, + list: res, }); - }, - onMore(e) { - this.getTabBar().setData({ - show: false, + }); + }); + }, + delCancel() { + this.setData({ + showDialogDel: false, + }); + }, + onMore(e) { + this.getTabBar().setData({ + show: false, + }); + this.setData({ + actionShow: true, + curId: e.currentTarget.dataset.item.id, + userId: e.currentTarget.dataset.item.user, + collectionId: e.currentTarget.dataset.item.collection_id || '', + registerId: e.currentTarget.dataset.item.register_id || '', + }); + const strTemp = this.data.collectionId ? '取消收藏' : '收藏活动'; + if (this.data.level == 3) { + this.setData({ + actions: [ + { + name: strTemp, + operaType: 1, + }, + { + name: '下架活动', + operaType: 2, + }, + ], + }); + } else { + if (this.data.user == this.data.userId) { + this.setData({ + actions: [ + { + name: strTemp, + operaType: 1, + }, + { + name: '下架活动', + operaType: 2, + }, + ], }); + } else { this.setData({ - actionShow: true, - curId: e.currentTarget.dataset.item.id, - userId: e.currentTarget.dataset.item.user, - collectionId: e.currentTarget.dataset.item.collection_id || '', - registerId: e.currentTarget.dataset.item.register_id || '', + actions: [ + { + name: strTemp, + operaType: 1, + }, + ], }); - const strTemp = this.data.collectionId ? '取消收藏' : '收藏活动'; - if (this.data.level == 3) { - this.setData({ - actions: [{ - name: strTemp, - operaType: 1, - }, - { - name: '下架活动', - operaType: 2, - }, - ], - }); - } else { - if (this.data.user == this.data.userId) { - this.setData({ - actions: [{ - name: strTemp, - operaType: 1, - }, - { - name: '下架活动', - operaType: 2, - }, - ], - }); - } else { - this.setData({ - actions: [{ - name: strTemp, - operaType: 1, - }, ], - }); - } + } - if (this.data.registerId) { - let tempArr = this.data.actions; - tempArr.unshift({ - name: '查看门票', - operaType: 3, - }); - this.setData({ - actions: tempArr, - }); - } - } - }, - toUpdateSchedule(e) { - wx.navigateTo({ - url: `/package-events/events/event-detail?id=${e.currentTarget.dataset.id}&type=5`, + if (this.data.registerId) { + let tempArr = this.data.actions; + tempArr.unshift({ + name: '查看门票', + operaType: 3, + }); + this.setData({ + actions: tempArr, }); - }, - onPullDownRefresh: function () { - wx.stopPullDownRefresh(); - this.onLoad(); - }, -}); \ No newline at end of file + } + } + }, + toUpdateSchedule(e) { + wx.navigateTo({ + url: `/package-events/events/event-detail?id=${e.currentTarget.dataset.id}&type=5`, + }); + }, + onPullDownRefresh: function () { + wx.stopPullDownRefresh(); + this.onLoad(); + }, +}); diff --git a/src/mindspore/pages/index/index.js b/src/mindspore/pages/index/index.js index 0c57b85..86a5a8f 100644 --- a/src/mindspore/pages/index/index.js +++ b/src/mindspore/pages/index/index.js @@ -2,88 +2,88 @@ const mixin = require('../../utils/page-mixin.js').$pageMixin; const sessionUtil = require('../../utils/app-session.js'); const appUser = require('../../utils/app-user.js'); -const appAjax = require('./../../utils/app-ajax'); let that = null; Page( - mixin({ - data: { - imgUrls: [{ - url: '/static/index/banner-1.png', - }, ], - iphoneX: false, - meetingConponent: null, - autoplay: true, + mixin({ + data: { + imgUrls: [ + { + url: '/static/index/banner-1.png', }, - swithTab(e) { - wx.switchTab({ - url: e.currentTarget.dataset.url, - }); - }, - previewImage(e) { - const current = e.target.dataset.src; //获取当前点击的 图片 url - wx.previewImage({ - current, - urls: [current], - }); - }, - onLoad: function () { - wx.showShareMenu({ - withShareTicket: true, - menus: ['shareAppMessage', 'shareTimeline'], - }); - that = this; - appUser.updateUserInfo(function () { - that.setData({ - meetingConponent: that.selectComponent('.meeting1'), - iphoneX: that.getTabBar().data.iPhoneX, - }); - }); - - }, - onShow: function () { - this.getTabBar().setData({ - _tabbat: 0, - }); - }, - onPullDownRefresh: function () { - wx.stopPullDownRefresh(); - appUser.updateUserInfo(function () { - that.data.meetingConponent.initData(); - }); - }, - actionStatus(e) { - if (e.detail === 1) { - this.getTabBar().setData({ - show: false, - }); - } else { - this.getTabBar().setData({ - show: true, - }); - } - }, - checkLogin() { - if (!sessionUtil.getUserInfoByKey('access')) { - wx.navigateTo({ - url: '/pages/auth/auth', - }); - } - }, - play() { - this.setData({ - autoplay: false, - }); - }, - pause() { - this.setData({ - autoplay: true, - }); - }, - ended() { - this.setData({ - autoplay: true, - }); - }, - }) -); \ No newline at end of file + ], + iphoneX: false, + meetingConponent: null, + autoplay: true, + }, + swithTab(e) { + wx.switchTab({ + url: e.currentTarget.dataset.url, + }); + }, + previewImage(e) { + const current = e.target.dataset.src; //获取当前点击的 图片 url + wx.previewImage({ + current, + urls: [current], + }); + }, + onLoad: function () { + wx.showShareMenu({ + withShareTicket: true, + menus: ['shareAppMessage', 'shareTimeline'], + }); + that = this; + appUser.updateUserInfo(function () { + that.setData({ + meetingConponent: that.selectComponent('.meeting1'), + iphoneX: that.getTabBar().data.iPhoneX, + }); + }); + }, + onShow: function () { + this.getTabBar().setData({ + _tabbat: 0, + }); + }, + onPullDownRefresh: function () { + wx.stopPullDownRefresh(); + appUser.updateUserInfo(function () { + that.data.meetingConponent.initData(); + }); + }, + actionStatus(e) { + if (e.detail === 1) { + this.getTabBar().setData({ + show: false, + }); + } else { + this.getTabBar().setData({ + show: true, + }); + } + }, + checkLogin() { + if (!sessionUtil.getUserInfoByKey('access')) { + wx.navigateTo({ + url: '/pages/auth/auth', + }); + } + }, + play() { + this.setData({ + autoplay: false, + }); + }, + pause() { + this.setData({ + autoplay: true, + }); + }, + ended() { + this.setData({ + autoplay: true, + }); + }, + }) +); diff --git a/src/mindspore/utils/app-session.js b/src/mindspore/utils/app-session.js index 1b6e509..8bb95c4 100644 --- a/src/mindspore/utils/app-session.js +++ b/src/mindspore/utils/app-session.js @@ -1,66 +1,66 @@ -let constants = require('../config/constants.js'); -/** - * 获取用户信息 - */ -let _getUserinfo = function () { - let userInfo = wx.getStorageSync(constants.APP_USERINFO_SESSION); - - return userInfo; -}; - -/** - * 通过key获取值 - * @params key - */ -let _getValueByKey = function (key) { - if (!key) { - return; - } - - let userinfo = _getUserinfo(); - - if (!userinfo) { - return; - } - return userinfo[key]; -}; - -module.exports = { - /** - * 从缓存获取token - */ - getToken: function () { - return _getValueByKey('access'); - }, - - /** - * 通过key获取对应信息 - */ - getUserInfoByKey: function (key) { - return _getValueByKey(key); - }, - - /** - * 获取用户信息 - */ - getUserinfo: function () { - return _getUserinfo(); - }, - - /** - * 清除用户信息 - */ - clearUserInfo: function () { - wx.removeStorageSync(constants.APP_USERINFO_SESSION); - }, - - /** - * 判断是否登录 - */ - loginCheck: function () { - if (_getUserinfo() && _getValueByKey('access')) { - return true; - } - return false; - }, -}; +let constants = require('../config/constants.js'); +/** + * 获取用户信息 + */ +let _getUserinfo = function () { + let userInfo = wx.getStorageSync(constants.APP_USERINFO_SESSION); + + return userInfo; +}; + +/** + * 通过key获取值 + * @params key + */ +let _getValueByKey = function (key) { + if (!key) { + return; + } + + let userinfo = _getUserinfo(); + + if (!userinfo) { + return; + } + return userinfo[key]; +}; + +module.exports = { + /** + * 从缓存获取token + */ + getToken: function () { + return _getValueByKey('access'); + }, + + /** + * 通过key获取对应信息 + */ + getUserInfoByKey: function (key) { + return _getValueByKey(key); + }, + + /** + * 获取用户信息 + */ + getUserinfo: function () { + return _getUserinfo(); + }, + + /** + * 清除用户信息 + */ + clearUserInfo: function () { + wx.removeStorageSync(constants.APP_USERINFO_SESSION); + }, + + /** + * 判断是否登录 + */ + loginCheck: function () { + if (_getUserinfo() && _getValueByKey('access')) { + return true; + } + return false; + }, +}; diff --git a/src/mindspore/utils/app-user.js b/src/mindspore/utils/app-user.js index 68b33e9..572f251 100644 --- a/src/mindspore/utils/app-user.js +++ b/src/mindspore/utils/app-user.js @@ -1,27 +1,7 @@ -let appSession = require('./app-session.js'); let constants = require('../config/constants'); let appAjax = require('./app-ajax.js'); let app = getApp(); -let remote = { - /** - * 绑定手机 - * @param {Object} phone - * @param {Object} _callback - */ - _bindUserPhone: function (phone, _callback) { - appAjax.postJson({ - service: 'BIND_PHONE', - data: { - phone: phone, - }, - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, -}; - let privateMethods = { /** * 登录 @@ -73,58 +53,6 @@ let privateMethods = { }; let appUser = { - /** - * 需要登录的跳转 - * page为空不能传null 要 "" - */ - loginRedirect: function (page, callback) { - // 是否有登录 - if (!appSession.loginCheck()) { - appUser.login(function (result) { - if (result && !result.phone) { - wx.navigateTo({ - url: '../register/bind-phone?page=' + page, - }); - } else { - wx.navigateTo({ - url: page, - }); - } - - // 支持回调 - callback && callback(); - }); - } else { - wx.navigateTo({ - url: page, - }); - } - }, - - /** - * 需要登录的操作 - * @param page 操作页 page为空不能传null 要 "" - * @param callback - */ - loginHandle: function (page, callback) { - // 是否有登录 - if (!appSession.loginCheck()) { - appUser.login(function (result) { - if (result && !result.phone) { - wx.navigateTo({ - url: '../register/bind-phone?page=' + page, - }); - } else { - callback && callback(); - } - }); - } else { - callback && callback(); - } - }, - - bindPhone: remote._bindUserPhone, - /** * 登录 * @param {Object} successCallback @@ -149,23 +77,6 @@ let appUser = { }); }, - /** - * 退出登录 - */ - logOut: function (callback) { - wx.showModal({ - title: '', - content: '确定要退出您的账号?', - success: function (res) { - if (res.confirm) { - // 清理用户信息 - appSession.clearUserInfo(); - callback && callback(); - } - }, - }); - }, - /** * 获取微信地址 * @param {Object} callback 回调 @@ -197,7 +108,7 @@ let appUser = { type: 'GET', service: 'GET_USER_STATUS', otherParams: { - id: userInfo.userId + id: userInfo.userId, }, success: function (ret) { if (ret) { diff --git a/src/mindspore/utils/page-mixin.js b/src/mindspore/utils/page-mixin.js index a2a44bb..115fd21 100644 --- a/src/mindspore/utils/page-mixin.js +++ b/src/mindspore/utils/page-mixin.js @@ -1,6 +1,5 @@ /** * 页面通用方法 - * author xzx * since 2020-8-20 */ diff --git a/src/mindspore/utils/underscore-extend.js b/src/mindspore/utils/underscore-extend.js index c9a8c73..7bf105b 100644 --- a/src/mindspore/utils/underscore-extend.js +++ b/src/mindspore/utils/underscore-extend.js @@ -1,49 +1,51 @@ -/** - * underscore扩展方法 - */ - -let _ = require('./underscore.js'); - -_.mixin({ - /** - * 对象深拷贝 - */ - deepExtend: function (target) { - let deep = true, - args = [].slice.call(arguments, 1); - - let extend = function (target, source, deep) { - let isArray = _.isArray; - let isWindow = function (obj) { - return obj != null && obj == obj.window; - }; - let isPlainObject = function (obj) { - return _.isObject(obj) && !isWindow(obj) && obj.__proto__ == Object.prototype; - }; - for (let key in source) { - //如果深度扩展 - if (deep && (isPlainObject(source[key]) || isArray(source[key]))) { - //如果要扩展的数据是对象且target相对应的key不是对象 - if (isPlainObject(source[key]) && !isPlainObject(target[key])) target[key] = {}; - //如果要扩展的数据是数组且target相对应的key不是数组 - if (isArray(source[key]) && !isArray(target[key])) target[key] = []; - extend(target[key], source[key], deep); - } else if (source[key] !== undefined) target[key] = source[key]; - } - }; - - if (typeof target == 'boolean') { - //当第一个参数为boolean类型的值时,表示是否深度扩展 - deep = target; - target = args.shift(); //target取第二个参数 - } - - //遍历后面的参数,全部扩展到target上 - args.forEach(function (arg) { - extend(target, arg, deep); - }); - return target; - }, -}); - -module.exports = _; +function isObject(obj) { + return obj !== null && typeof obj === 'object' && !Array.isArray(obj); +} + +// 实现 isArray 方法 +function isArray(obj) { + return Array.isArray(obj); +} + +const _ = { + /** + * 对象深拷贝 + */ + deepExtend: function (target) { + let deep = true, + args = [].slice.call(arguments, 1); + + let extend = function (target, source, deep) { + let isWindow = function (obj) { + return obj != null && obj == obj.window; + }; + let isPlainObject = function (obj) { + return isObject(obj) && !isWindow(obj) && obj.__proto__ == Object.prototype; + }; + for (let key in source) { + //如果深度扩展 + if (deep && (isPlainObject(source[key]) || isArray(source[key]))) { + //如果要扩展的数据是对象且target相对应的key不是对象 + if (isPlainObject(source[key]) && !isPlainObject(target[key])) target[key] = {}; + //如果要扩展的数据是数组且target相对应的key不是数组 + if (isArray(source[key]) && !isArray(target[key])) target[key] = []; + extend(target[key], source[key], deep); + } else if (source[key] !== undefined) target[key] = source[key]; + } + }; + + if (typeof target == 'boolean') { + //当第一个参数为boolean类型的值时,表示是否深度扩展 + deep = target; + target = args.shift(); //target取第二个参数 + } + + //遍历后面的参数,全部扩展到target上 + args.forEach(function (arg) { + extend(target, arg, deep); + }); + return target; + }, +}; + +module.exports = _; diff --git a/src/mindspore/utils/underscore.js b/src/mindspore/utils/underscore.js deleted file mode 100644 index beadc7f..0000000 --- a/src/mindspore/utils/underscore.js +++ /dev/null @@ -1,871 +0,0 @@ -// Underscore.js 1.8.2 -// http://underscorejs.org -// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors -// Underscore may be freely distributed under the MIT license. -(function () { - function n(n) { - function t(t, r, e, u, i, o) { - for (; i >= 0 && o > i; i += n) { - var a = u ? u[i] : i; - e = r(e, t[a], a, t); - } - return e; - } - return function (r, e, u, i) { - e = d(e, i, 4); - var o = !w(r) && m.keys(r), - a = (o || r).length, - c = n > 0 ? 0 : a - 1; - return arguments.length < 3 && ((u = r[o ? o[c] : c]), (c += n)), t(r, e, u, o, c, a); - }; - } - function t(n) { - return function (t, r, e) { - r = b(r, e); - for (var u = null != t && t.length, i = n > 0 ? 0 : u - 1; i >= 0 && u > i; i += n) if (r(t[i], i, t)) return i; - return -1; - }; - } - function r(n, t) { - var r = S.length, - e = n.constructor, - u = (m.isFunction(e) && e.prototype) || o, - i = 'constructor'; - for (m.has(n, i) && !m.contains(t, i) && t.push(i); r--; ) - (i = S[r]), i in n && n[i] !== u[i] && !m.contains(t, i) && t.push(i); - } - var e = this, - u = e._, - i = Array.prototype, - o = Object.prototype, - a = Function.prototype, - c = i.push, - l = i.slice, - f = o.toString, - s = o.hasOwnProperty, - p = Array.isArray, - h = Object.keys, - v = a.bind, - g = Object.create, - y = function () {}, - m = function (n) { - return n instanceof m ? n : this instanceof m ? void (this._wrapped = n) : new m(n); - }; - 'undefined' != typeof exports - ? ('undefined' != typeof module && module.exports && (exports = module.exports = m), (exports._ = m)) - : (e._ = m), - (m.VERSION = '1.8.2'); - var d = function (n, t, r) { - if (t === void 0) return n; - switch (null == r ? 3 : r) { - case 1: - return function (r) { - return n.call(t, r); - }; - case 2: - return function (r, e) { - return n.call(t, r, e); - }; - case 3: - return function (r, e, u) { - return n.call(t, r, e, u); - }; - case 4: - return function (r, e, u, i) { - return n.call(t, r, e, u, i); - }; - } - return function () { - return n.apply(t, arguments); - }; - }, - b = function (n, t, r) { - return null == n ? m.identity : m.isFunction(n) ? d(n, t, r) : m.isObject(n) ? m.matcher(n) : m.property(n); - }; - m.iteratee = function (n, t) { - return b(n, t, 1 / 0); - }; - var x = function (n, t) { - return function (r) { - var e = arguments.length; - if (2 > e || null == r) return r; - for (var u = 1; e > u; u++) - for (var i = arguments[u], o = n(i), a = o.length, c = 0; a > c; c++) { - var l = o[c]; - (t && r[l] !== void 0) || (r[l] = i[l]); - } - return r; - }; - }, - _ = function (n) { - if (!m.isObject(n)) return {}; - if (g) return g(n); - y.prototype = n; - var t = new y(); - return (y.prototype = null), t; - }, - j = Math.pow(2, 53) - 1, - w = function (n) { - var t = n && n.length; - return 'number' == typeof t && t >= 0 && j >= t; - }; - (m.each = m.forEach = - function (n, t, r) { - t = d(t, r); - var e, u; - if (w(n)) for (e = 0, u = n.length; u > e; e++) t(n[e], e, n); - else { - var i = m.keys(n); - for (e = 0, u = i.length; u > e; e++) t(n[i[e]], i[e], n); - } - return n; - }), - (m.map = m.collect = - function (n, t, r) { - t = b(t, r); - for (var e = !w(n) && m.keys(n), u = (e || n).length, i = Array(u), o = 0; u > o; o++) { - var a = e ? e[o] : o; - i[o] = t(n[a], a, n); - } - return i; - }), - (m.reduce = m.foldl = m.inject = n(1)), - (m.reduceRight = m.foldr = n(-1)), - (m.find = m.detect = - function (n, t, r) { - var e; - return (e = w(n) ? m.findIndex(n, t, r) : m.findKey(n, t, r)), e !== void 0 && e !== -1 ? n[e] : void 0; - }), - (m.filter = m.select = - function (n, t, r) { - var e = []; - return ( - (t = b(t, r)), - m.each(n, function (n, r, u) { - t(n, r, u) && e.push(n); - }), - e - ); - }), - (m.reject = function (n, t, r) { - return m.filter(n, m.negate(b(t)), r); - }), - (m.every = m.all = - function (n, t, r) { - t = b(t, r); - for (var e = !w(n) && m.keys(n), u = (e || n).length, i = 0; u > i; i++) { - var o = e ? e[i] : i; - if (!t(n[o], o, n)) return !1; - } - return !0; - }), - (m.some = m.any = - function (n, t, r) { - t = b(t, r); - for (var e = !w(n) && m.keys(n), u = (e || n).length, i = 0; u > i; i++) { - var o = e ? e[i] : i; - if (t(n[o], o, n)) return !0; - } - return !1; - }), - (m.contains = - m.includes = - m.include = - function (n, t, r) { - return w(n) || (n = m.values(n)), m.indexOf(n, t, 'number' == typeof r && r) >= 0; - }), - (m.invoke = function (n, t) { - var r = l.call(arguments, 2), - e = m.isFunction(t); - return m.map(n, function (n) { - var u = e ? t : n[t]; - return null == u ? u : u.apply(n, r); - }); - }), - (m.pluck = function (n, t) { - return m.map(n, m.property(t)); - }), - (m.where = function (n, t) { - return m.filter(n, m.matcher(t)); - }), - (m.findWhere = function (n, t) { - return m.find(n, m.matcher(t)); - }), - (m.max = function (n, t, r) { - var e, - u, - i = -1 / 0, - o = -1 / 0; - if (null == t && null != n) { - n = w(n) ? n : m.values(n); - for (var a = 0, c = n.length; c > a; a++) (e = n[a]), e > i && (i = e); - } else - (t = b(t, r)), - m.each(n, function (n, r, e) { - (u = t(n, r, e)), (u > o || (u === -1 / 0 && i === -1 / 0)) && ((i = n), (o = u)); - }); - return i; - }), - (m.min = function (n, t, r) { - var e, - u, - i = 1 / 0, - o = 1 / 0; - if (null == t && null != n) { - n = w(n) ? n : m.values(n); - for (var a = 0, c = n.length; c > a; a++) (e = n[a]), i > e && (i = e); - } else - (t = b(t, r)), - m.each(n, function (n, r, e) { - (u = t(n, r, e)), (o > u || (1 / 0 === u && 1 / 0 === i)) && ((i = n), (o = u)); - }); - return i; - }), - (m.shuffle = function (n) { - for (var t, r = w(n) ? n : m.values(n), e = r.length, u = Array(e), i = 0; e > i; i++) - (t = m.random(0, i)), t !== i && (u[i] = u[t]), (u[t] = r[i]); - return u; - }), - (m.sample = function (n, t, r) { - return null == t || r - ? (w(n) || (n = m.values(n)), n[m.random(n.length - 1)]) - : m.shuffle(n).slice(0, Math.max(0, t)); - }), - (m.sortBy = function (n, t, r) { - return ( - (t = b(t, r)), - m.pluck( - m - .map(n, function (n, r, e) { - return { value: n, index: r, criteria: t(n, r, e) }; - }) - .sort(function (n, t) { - var r = n.criteria, - e = t.criteria; - if (r !== e) { - if (r > e || r === void 0) return 1; - if (e > r || e === void 0) return -1; - } - return n.index - t.index; - }), - 'value' - ) - ); - }); - var A = function (n) { - return function (t, r, e) { - var u = {}; - return ( - (r = b(r, e)), - m.each(t, function (e, i) { - var o = r(e, i, t); - n(u, e, o); - }), - u - ); - }; - }; - (m.groupBy = A(function (n, t, r) { - m.has(n, r) ? n[r].push(t) : (n[r] = [t]); - })), - (m.indexBy = A(function (n, t, r) { - n[r] = t; - })), - (m.countBy = A(function (n, t, r) { - m.has(n, r) ? n[r]++ : (n[r] = 1); - })), - (m.toArray = function (n) { - return n ? (m.isArray(n) ? l.call(n) : w(n) ? m.map(n, m.identity) : m.values(n)) : []; - }), - (m.size = function (n) { - return null == n ? 0 : w(n) ? n.length : m.keys(n).length; - }), - (m.partition = function (n, t, r) { - t = b(t, r); - var e = [], - u = []; - return ( - m.each(n, function (n, r, i) { - (t(n, r, i) ? e : u).push(n); - }), - [e, u] - ); - }), - (m.first = - m.head = - m.take = - function (n, t, r) { - return null == n ? void 0 : null == t || r ? n[0] : m.initial(n, n.length - t); - }), - (m.initial = function (n, t, r) { - return l.call(n, 0, Math.max(0, n.length - (null == t || r ? 1 : t))); - }), - (m.last = function (n, t, r) { - return null == n ? void 0 : null == t || r ? n[n.length - 1] : m.rest(n, Math.max(0, n.length - t)); - }), - (m.rest = - m.tail = - m.drop = - function (n, t, r) { - return l.call(n, null == t || r ? 1 : t); - }), - (m.compact = function (n) { - return m.filter(n, m.identity); - }); - var k = function (n, t, r, e) { - for (var u = [], i = 0, o = e || 0, a = n && n.length; a > o; o++) { - var c = n[o]; - if (w(c) && (m.isArray(c) || m.isArguments(c))) { - t || (c = k(c, t, r)); - var l = 0, - f = c.length; - for (u.length += f; f > l; ) u[i++] = c[l++]; - } else r || (u[i++] = c); - } - return u; - }; - (m.flatten = function (n, t) { - return k(n, t, !1); - }), - (m.without = function (n) { - return m.difference(n, l.call(arguments, 1)); - }), - (m.uniq = m.unique = - function (n, t, r, e) { - if (null == n) return []; - m.isBoolean(t) || ((e = r), (r = t), (t = !1)), null != r && (r = b(r, e)); - for (var u = [], i = [], o = 0, a = n.length; a > o; o++) { - var c = n[o], - l = r ? r(c, o, n) : c; - t - ? ((o && i === l) || u.push(c), (i = l)) - : r - ? m.contains(i, l) || (i.push(l), u.push(c)) - : m.contains(u, c) || u.push(c); - } - return u; - }), - (m.union = function () { - return m.uniq(k(arguments, !0, !0)); - }), - (m.intersection = function (n) { - if (null == n) return []; - for (var t = [], r = arguments.length, e = 0, u = n.length; u > e; e++) { - var i = n[e]; - if (!m.contains(t, i)) { - for (var o = 1; r > o && m.contains(arguments[o], i); o++); - o === r && t.push(i); - } - } - return t; - }), - (m.difference = function (n) { - var t = k(arguments, !0, !0, 1); - return m.filter(n, function (n) { - return !m.contains(t, n); - }); - }), - (m.zip = function () { - return m.unzip(arguments); - }), - (m.unzip = function (n) { - for (var t = (n && m.max(n, 'length').length) || 0, r = Array(t), e = 0; t > e; e++) r[e] = m.pluck(n, e); - return r; - }), - (m.object = function (n, t) { - for (var r = {}, e = 0, u = n && n.length; u > e; e++) t ? (r[n[e]] = t[e]) : (r[n[e][0]] = n[e][1]); - return r; - }), - (m.indexOf = function (n, t, r) { - var e = 0, - u = n && n.length; - if ('number' == typeof r) e = 0 > r ? Math.max(0, u + r) : r; - else if (r && u) return (e = m.sortedIndex(n, t)), n[e] === t ? e : -1; - if (t !== t) return m.findIndex(l.call(n, e), m.isNaN); - for (; u > e; e++) if (n[e] === t) return e; - return -1; - }), - (m.lastIndexOf = function (n, t, r) { - var e = n ? n.length : 0; - if (('number' == typeof r && (e = 0 > r ? e + r + 1 : Math.min(e, r + 1)), t !== t)) - return m.findLastIndex(l.call(n, 0, e), m.isNaN); - for (; --e >= 0; ) if (n[e] === t) return e; - return -1; - }), - (m.findIndex = t(1)), - (m.findLastIndex = t(-1)), - (m.sortedIndex = function (n, t, r, e) { - r = b(r, e, 1); - for (var u = r(t), i = 0, o = n.length; o > i; ) { - var a = Math.floor((i + o) / 2); - r(n[a]) < u ? (i = a + 1) : (o = a); - } - return i; - }), - (m.range = function (n, t, r) { - arguments.length <= 1 && ((t = n || 0), (n = 0)), (r = r || 1); - for (var e = Math.max(Math.ceil((t - n) / r), 0), u = Array(e), i = 0; e > i; i++, n += r) u[i] = n; - return u; - }); - var O = function (n, t, r, e, u) { - if (!(e instanceof t)) return n.apply(r, u); - var i = _(n.prototype), - o = n.apply(i, u); - return m.isObject(o) ? o : i; - }; - (m.bind = function (n, t) { - if (v && n.bind === v) return v.apply(n, l.call(arguments, 1)); - if (!m.isFunction(n)) throw new TypeError('Bind must be called on a function'); - var r = l.call(arguments, 2), - e = function () { - return O(n, e, t, this, r.concat(l.call(arguments))); - }; - return e; - }), - (m.partial = function (n) { - var t = l.call(arguments, 1), - r = function () { - for (var e = 0, u = t.length, i = Array(u), o = 0; u > o; o++) i[o] = t[o] === m ? arguments[e++] : t[o]; - for (; e < arguments.length; ) i.push(arguments[e++]); - return O(n, r, this, this, i); - }; - return r; - }), - (m.bindAll = function (n) { - var t, - r, - e = arguments.length; - if (1 >= e) throw new Error('bindAll must be passed function names'); - for (t = 1; e > t; t++) (r = arguments[t]), (n[r] = m.bind(n[r], n)); - return n; - }), - (m.memoize = function (n, t) { - var r = function (e) { - var u = r.cache, - i = '' + (t ? t.apply(this, arguments) : e); - return m.has(u, i) || (u[i] = n.apply(this, arguments)), u[i]; - }; - return (r.cache = {}), r; - }), - (m.delay = function (n, t) { - var r = l.call(arguments, 2); - return setTimeout(function () { - return n.apply(null, r); - }, t); - }), - (m.defer = m.partial(m.delay, m, 1)), - (m.throttle = function (n, t, r) { - var e, - u, - i, - o = null, - a = 0; - r || (r = {}); - var c = function () { - (a = r.leading === !1 ? 0 : m.now()), (o = null), (i = n.apply(e, u)), o || (e = u = null); - }; - return function () { - var l = m.now(); - a || r.leading !== !1 || (a = l); - var f = t - (l - a); - return ( - (e = this), - (u = arguments), - 0 >= f || f > t - ? (o && (clearTimeout(o), (o = null)), (a = l), (i = n.apply(e, u)), o || (e = u = null)) - : o || r.trailing === !1 || (o = setTimeout(c, f)), - i - ); - }; - }), - (m.debounce = function (n, t, r) { - var e, - u, - i, - o, - a, - c = function () { - var l = m.now() - o; - t > l && l >= 0 ? (e = setTimeout(c, t - l)) : ((e = null), r || ((a = n.apply(i, u)), e || (i = u = null))); - }; - return function () { - (i = this), (u = arguments), (o = m.now()); - var l = r && !e; - return e || (e = setTimeout(c, t)), l && ((a = n.apply(i, u)), (i = u = null)), a; - }; - }), - (m.wrap = function (n, t) { - return m.partial(t, n); - }), - (m.negate = function (n) { - return function () { - return !n.apply(this, arguments); - }; - }), - (m.compose = function () { - var n = arguments, - t = n.length - 1; - return function () { - for (var r = t, e = n[t].apply(this, arguments); r--; ) e = n[r].call(this, e); - return e; - }; - }), - (m.after = function (n, t) { - return function () { - return --n < 1 ? t.apply(this, arguments) : void 0; - }; - }), - (m.before = function (n, t) { - var r; - return function () { - return --n > 0 && (r = t.apply(this, arguments)), 1 >= n && (t = null), r; - }; - }), - (m.once = m.partial(m.before, 2)); - var F = !{ toString: null }.propertyIsEnumerable('toString'), - S = ['valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; - (m.keys = function (n) { - if (!m.isObject(n)) return []; - if (h) return h(n); - var t = []; - for (var e in n) m.has(n, e) && t.push(e); - return F && r(n, t), t; - }), - (m.allKeys = function (n) { - if (!m.isObject(n)) return []; - var t = []; - for (var e in n) t.push(e); - return F && r(n, t), t; - }), - (m.values = function (n) { - for (var t = m.keys(n), r = t.length, e = Array(r), u = 0; r > u; u++) e[u] = n[t[u]]; - return e; - }), - (m.mapObject = function (n, t, r) { - t = b(t, r); - for (var e, u = m.keys(n), i = u.length, o = {}, a = 0; i > a; a++) (e = u[a]), (o[e] = t(n[e], e, n)); - return o; - }), - (m.pairs = function (n) { - for (var t = m.keys(n), r = t.length, e = Array(r), u = 0; r > u; u++) e[u] = [t[u], n[t[u]]]; - return e; - }), - (m.invert = function (n) { - for (var t = {}, r = m.keys(n), e = 0, u = r.length; u > e; e++) t[n[r[e]]] = r[e]; - return t; - }), - (m.functions = m.methods = - function (n) { - var t = []; - for (var r in n) m.isFunction(n[r]) && t.push(r); - return t.sort(); - }), - (m.extend = x(m.allKeys)), - (m.extendOwn = m.assign = x(m.keys)), - (m.findKey = function (n, t, r) { - t = b(t, r); - for (var e, u = m.keys(n), i = 0, o = u.length; o > i; i++) if (((e = u[i]), t(n[e], e, n))) return e; - }), - (m.pick = function (n, t, r) { - var e, - u, - i = {}, - o = n; - if (null == o) return i; - m.isFunction(t) - ? ((u = m.allKeys(o)), (e = d(t, r))) - : ((u = k(arguments, !1, !1, 1)), - (e = function (n, t, r) { - return t in r; - }), - (o = Object(o))); - for (var a = 0, c = u.length; c > a; a++) { - var l = u[a], - f = o[l]; - e(f, l, o) && (i[l] = f); - } - return i; - }), - (m.omit = function (n, t, r) { - if (m.isFunction(t)) t = m.negate(t); - else { - var e = m.map(k(arguments, !1, !1, 1), String); - t = function (n, t) { - return !m.contains(e, t); - }; - } - return m.pick(n, t, r); - }), - (m.defaults = x(m.allKeys, !0)), - (m.clone = function (n) { - return m.isObject(n) ? (m.isArray(n) ? n.slice() : m.extend({}, n)) : n; - }), - (m.tap = function (n, t) { - return t(n), n; - }), - (m.isMatch = function (n, t) { - var r = m.keys(t), - e = r.length; - if (null == n) return !e; - for (var u = Object(n), i = 0; e > i; i++) { - var o = r[i]; - if (t[o] !== u[o] || !(o in u)) return !1; - } - return !0; - }); - var E = function (n, t, r, e) { - if (n === t) return 0 !== n || 1 / n === 1 / t; - if (null == n || null == t) return n === t; - n instanceof m && (n = n._wrapped), t instanceof m && (t = t._wrapped); - var u = f.call(n); - if (u !== f.call(t)) return !1; - switch (u) { - case '[object RegExp]': - case '[object String]': - return '' + n == '' + t; - case '[object Number]': - return +n !== +n ? +t !== +t : 0 === +n ? 1 / +n === 1 / t : +n === +t; - case '[object Date]': - case '[object Boolean]': - return +n === +t; - } - var i = '[object Array]' === u; - if (!i) { - if ('object' != typeof n || 'object' != typeof t) return !1; - var o = n.constructor, - a = t.constructor; - if ( - o !== a && - !(m.isFunction(o) && o instanceof o && m.isFunction(a) && a instanceof a) && - 'constructor' in n && - 'constructor' in t - ) - return !1; - } - (r = r || []), (e = e || []); - for (var c = r.length; c--; ) if (r[c] === n) return e[c] === t; - if ((r.push(n), e.push(t), i)) { - if (((c = n.length), c !== t.length)) return !1; - for (; c--; ) if (!E(n[c], t[c], r, e)) return !1; - } else { - var l, - s = m.keys(n); - if (((c = s.length), m.keys(t).length !== c)) return !1; - for (; c--; ) if (((l = s[c]), !m.has(t, l) || !E(n[l], t[l], r, e))) return !1; - } - return r.pop(), e.pop(), !0; - }; - (m.isEqual = function (n, t) { - return E(n, t); - }), - (m.isEmpty = function (n) { - return null == n - ? !0 - : w(n) && (m.isArray(n) || m.isString(n) || m.isArguments(n)) - ? 0 === n.length - : 0 === m.keys(n).length; - }), - (m.isElement = function (n) { - return !(!n || 1 !== n.nodeType); - }), - (m.isArray = - p || - function (n) { - return '[object Array]' === f.call(n); - }), - (m.isObject = function (n) { - var t = typeof n; - return 'function' === t || ('object' === t && !!n); - }), - m.each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp', 'Error'], function (n) { - m['is' + n] = function (t) { - return f.call(t) === '[object ' + n + ']'; - }; - }), - m.isArguments(arguments) || - (m.isArguments = function (n) { - return m.has(n, 'callee'); - }), - 'function' != typeof /./ && - 'object' != typeof Int8Array && - (m.isFunction = function (n) { - return 'function' == typeof n || !1; - }), - (m.isFinite = function (n) { - return isFinite(n) && !isNaN(parseFloat(n)); - }), - (m.isNaN = function (n) { - return m.isNumber(n) && n !== +n; - }), - (m.isBoolean = function (n) { - return n === !0 || n === !1 || '[object Boolean]' === f.call(n); - }), - (m.isNull = function (n) { - return null === n; - }), - (m.isUndefined = function (n) { - return n === void 0; - }), - (m.has = function (n, t) { - return null != n && s.call(n, t); - }), - (m.noConflict = function () { - return (e._ = u), this; - }), - (m.identity = function (n) { - return n; - }), - (m.constant = function (n) { - return function () { - return n; - }; - }), - (m.noop = function () {}), - (m.property = function (n) { - return function (t) { - return null == t ? void 0 : t[n]; - }; - }), - (m.propertyOf = function (n) { - return null == n - ? function () {} - : function (t) { - return n[t]; - }; - }), - (m.matcher = m.matches = - function (n) { - return ( - (n = m.extendOwn({}, n)), - function (t) { - return m.isMatch(t, n); - } - ); - }), - (m.times = function (n, t, r) { - var e = Array(Math.max(0, n)); - t = d(t, r, 1); - for (var u = 0; n > u; u++) e[u] = t(u); - return e; - }), - (m.random = function (n, t) { - return null == t && ((t = n), (n = 0)), n + Math.floor(Math.random() * (t - n + 1)); - }), - (m.now = - Date.now || - function () { - return new Date().getTime(); - }); - var M = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', '`': '`' }, - N = m.invert(M), - I = function (n) { - var t = function (t) { - return n[t]; - }, - r = '(?:' + m.keys(n).join('|') + ')', - e = RegExp(r), - u = RegExp(r, 'g'); - return function (n) { - return (n = null == n ? '' : '' + n), e.test(n) ? n.replace(u, t) : n; - }; - }; - (m.escape = I(M)), - (m.unescape = I(N)), - (m.result = function (n, t, r) { - var e = null == n ? void 0 : n[t]; - return e === void 0 && (e = r), m.isFunction(e) ? e.call(n) : e; - }); - var B = 0; - (m.uniqueId = function (n) { - var t = ++B + ''; - return n ? n + t : t; - }), - (m.templateSettings = { evaluate: /<%([\s\S]+?)%>/g, interpolate: /<%=([\s\S]+?)%>/g, escape: /<%-([\s\S]+?)%>/g }); - var T = /(.)^/, - R = { "'": "'", '\\': '\\', '\r': 'r', '\n': 'n', '\u2028': 'u2028', '\u2029': 'u2029' }, - q = /\\|'|\r|\n|\u2028|\u2029/g, - K = function (n) { - return '\\' + R[n]; - }; - (m.template = function (n, t, r) { - !t && r && (t = r), (t = m.defaults({}, t, m.templateSettings)); - var e = RegExp( - [(t.escape || T).source, (t.interpolate || T).source, (t.evaluate || T).source].join('|') + '|$', - 'g' - ), - u = 0, - i = "__p+='"; - n.replace(e, function (t, r, e, o, a) { - return ( - (i += n.slice(u, a).replace(q, K)), - (u = a + t.length), - r - ? (i += "'+\n((__t=(" + r + "))==null?'':_.escape(__t))+\n'") - : e - ? (i += "'+\n((__t=(" + e + "))==null?'':__t)+\n'") - : o && (i += "';\n" + o + "\n__p+='"), - t - ); - }), - (i += "';\n"), - t.variable || (i = 'with(obj||{}){\n' + i + '}\n'), - (i = - "var __t,__p='',__j=Array.prototype.join," + - "print=function(){__p+=__j.call(arguments,'');};\n" + - i + - 'return __p;\n'); - try { - var o = new Function(t.variable || 'obj', '_', i); - } catch (a) { - throw ((a.source = i), a); - } - var c = function (n) { - return o.call(this, n, m); - }, - l = t.variable || 'obj'; - return (c.source = 'function(' + l + '){\n' + i + '}'), c; - }), - (m.chain = function (n) { - var t = m(n); - return (t._chain = !0), t; - }); - var z = function (n, t) { - return n._chain ? m(t).chain() : t; - }; - (m.mixin = function (n) { - m.each(m.functions(n), function (t) { - var r = (m[t] = n[t]); - m.prototype[t] = function () { - var n = [this._wrapped]; - return c.apply(n, arguments), z(this, r.apply(m, n)); - }; - }); - }), - m.mixin(m), - m.each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function (n) { - var t = i[n]; - m.prototype[n] = function () { - var r = this._wrapped; - return t.apply(r, arguments), ('shift' !== n && 'splice' !== n) || 0 !== r.length || delete r[0], z(this, r); - }; - }), - m.each(['concat', 'join', 'slice'], function (n) { - var t = i[n]; - m.prototype[n] = function () { - return z(this, t.apply(this._wrapped, arguments)); - }; - }), - (m.prototype.value = function () { - return this._wrapped; - }), - (m.prototype.valueOf = m.prototype.toJSON = m.prototype.value), - (m.prototype.toString = function () { - return '' + this._wrapped; - }), - 'function' == typeof define && - define.amd && - define('underscore', [], function () { - return m; - }); -}.call(this || module.exports)); -//# sourceMappingURL=underscore-min.map diff --git a/src/mindspore/utils/utils.js b/src/mindspore/utils/utils.js index 919cb89..0ed2cb7 100644 --- a/src/mindspore/utils/utils.js +++ b/src/mindspore/utils/utils.js @@ -1,274 +1,105 @@ -/** - * 工具类 - */ - -let _ = require('./underscore-extend'); - -let utils = { - /** - * underscore工具库 - */ - _: _, - - /** - * 深拷贝工具 - */ - deepExtend: _.deepExtend, - - /** - * 获取时间差(小于一天) - * @param {Object} startTime 开始时间 long 毫秒数 - * @param {Object} endTime 结束时间 long 毫秒数 - * return { - * "days" : days, - * "hours" : hours, - * "minutes" : minutes, - * "seconds" : seconds - * } - */ - getDiffTime: function (startTime, endTime) { - // 相差时间 - let diffTime = endTime - startTime; - if (diffTime <= 0) { - return false; - } - // 计算出相差天数 - let days = Math.floor(diffTime / (24 * 3600 * 1000)); - // 计算出小时数 - let leave1 = diffTime % (24 * 3600 * 1000); //计算天数后剩余的毫秒数 - let hours = Math.floor(leave1 / (3600 * 1000)); - // 计算相差分钟数 - let leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数 - let minutes = Math.floor(leave2 / (60 * 1000)); - // 计算相差秒数 - let leave3 = leave2 % (60 * 1000); //计算分钟数后剩余的毫秒数 - let seconds = Math.round(leave3 / 1000); - - return { - days: days, - hours: hours, - minutes: minutes, - seconds: seconds, - }; - }, - - /** - * 返回定时器格式(若天和小时为0则隐藏天和小时) - * @param {Object} time - */ - getTiktokStr: function (time) { - let str = time.seconds + '秒'; - if (time.days != 0) { - str = time.days + '天' + time.hours + '小时' + time.minutes + '分钟' + str; - } else if (time.hours != 0) { - str = time.hours + '小时' + time.minutes + '分钟' + str; - } else if (time.minutes != 0) { - str = time.minutes + '分钟' + str; - } - return str; - }, - - /** - * 倒计时方法 - * @param {Object} startTime long 开始时间 - * @param {Object} endTime long 结束时间 - * @param {Object} renderFunc 回调渲染函数 - * @param {Object} endFunc 倒计时结束回调函数 - */ - intervalTime: function (startTime, endTime, renderFunc, endFunc) { - if (!startTime || !endTime) { - return; - } - startTime = parseInt(startTime); - endTime = parseInt(endTime); - - let that = this; - - let diffTime = that.getDiffTime(startTime, endTime); - diffTime = that.getTiktokStr(diffTime); - renderFunc && renderFunc(diffTime); - startTime += 1000; - - let interval = setInterval(function () { - diffTime = that.getDiffTime(startTime, endTime); - if (diffTime) { - startTime += 1000; - diffTime = that.getTiktokStr(diffTime); - renderFunc && renderFunc(diffTime); - } else { - clearInterval(interval); - endFunc && endFunc(); - } - }, 1000); - }, - - /** - * 判断对象是否为空 - */ - isEmptyObject: function (obj) { - let t; - for (t in obj) { - return false; - } - return true; - }, - - /** - * 获取当前页面url - */ - getCurrentUrl: function () { - let pageStack = getCurrentPages(); - let thisPage = pageStack[pageStack.length - 1]; - - let baseUrl = thisPage.route; - let paramObj = thisPage.options; - let params = ''; - - if (this.isEmptyObject(paramObj)) { - return baseUrl; - } else { - for (let i in paramObj) { - if (params.indexOf('?') >= 0) { - params += '&'; - } else { - params += '?'; - } - params += i + '=' + paramObj[i]; - } - } - - return baseUrl + params; - }, - - /** - * 替换html特殊字符串 - */ - replaceHtmlString: function (str) { - str = str.replace(/ /g, ' '); - return str; - }, - - /** - * 添加URL的参数 - * @param name 名称 - * @param value 值 - * @param url 链接地址 - */ - addUrlParam: function (name, value, url) { - if (!value) { - return url; - } - - if (url.indexOf(name + '=') > -1) { - return url; - } - let tmpUrl = url; - - // 判断是否已经有其他参数 - if (tmpUrl.indexOf('?') >= 0) { - tmpUrl += '&'; - } else { - tmpUrl += '?'; - } - tmpUrl += name + '=' + value; - - return tmpUrl; - }, - - /** - * 日期格式化 - */ - formateDate: function () { - // 对Date的扩展,将 Date 转化为指定格式的String - // 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符, - // 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字) - // 例子: - // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 - // (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18 - Date.prototype.Format = function (fmt) { - let o = { - 'M+': this.getMonth() + 1, //月份 - 'd+': this.getDate(), //日 - 'h+': this.getHours(), //小时 - 'm+': this.getMinutes(), //分 - 's+': this.getSeconds(), //秒 - 'q+': Math.floor((this.getMonth() + 3) / 3), //季度 - S: this.getMilliseconds(), //毫秒 - }; - if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)); - for (let k in o) - if (new RegExp('(' + k + ')').test(fmt)) - fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)); - return fmt; - }; - }, - - /** - * 版本比较 - * param {string} v1 > v2 ? 1 : -1 ; 相等返回0 - */ - compareVersion: function (v1, v2) { - v1 = v1.split('.'); - v2 = v2.split('.'); - let len = Math.max(v1.length, v2.length); - - while (v1.length < len) { - v1.push('0'); - } - - while (v2.length < len) { - v2.push('0'); - } - - for (let i = 0; i < len; i++) { - let num1 = parseInt(v1[i]); - let num2 = parseInt(v2[i]); - - if (num1 > num2) { - return 1; - } else if (num1 < num2) { - return -1; - } - } - - return 0; - }, - - /** - * 静态资源定时清理缓存用的后缀 - */ - resourceSuffix: function () { - let randomStr = '?' + new Date().getTime().toString().slice(0, 7) + '000000'; - return randomStr; - }, - - /** - * 资讯跳转方法(文章、图集) - * @param {Object} options - * jumpType:跳转方法名, - * infoType:资讯类型1文章 2图集 3视频 4链接(不支持), - * id:资讯详情id - */ - jumpToInfo: function (options) { - let id = options.id ? options.id : ''; - let type = options.infoType ? options.infoType : 1; - let jumpType = - options.jumpType && options.jumpType in wx && typeof wx[options.jumpType] == 'function' - ? options.jumpType - : 'navigateTo'; - - // 1文章 2图集 3视频 4链接(不支持) - let infoConfig = { - 1: '/pages/discovery/info', - 2: '/pages/discovery/picture-info', - }; - - let path = type in infoConfig ? infoConfig[type] + '?id=' + id : infoConfig[1] + '?id=' + id; - - wx[jumpType]({ - url: path, - }); - }, -}; - -module.exports = utils; +/** + * 工具类 + */ + +let _ = require('./underscore-extend'); + +let utils = { + /** + * underscore工具库 + */ + _: _, + + /** + * 深拷贝工具 + */ + deepExtend: _.deepExtend, + + /** + * 添加URL的参数 + * @param name 名称 + * @param value 值 + * @param url 链接地址 + */ + addUrlParam: function (name, value, url) { + if (!value) { + return url; + } + + if (url.indexOf(name + '=') > -1) { + return url; + } + let tmpUrl = url; + + // 判断是否已经有其他参数 + if (tmpUrl.indexOf('?') >= 0) { + tmpUrl += '&'; + } else { + tmpUrl += '?'; + } + tmpUrl += name + '=' + value; + + return tmpUrl; + }, + + /** + * 日期格式化 + */ + formateDate: function () { + // 对Date的扩展,将 Date 转化为指定格式的String + // 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符, + // 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字) + // 例子: + // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423 + // (new Date()).Format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18 + Date.prototype.Format = function (fmt) { + let o = { + 'M+': this.getMonth() + 1, //月份 + 'd+': this.getDate(), //日 + 'h+': this.getHours(), //小时 + 'm+': this.getMinutes(), //分 + 's+': this.getSeconds(), //秒 + 'q+': Math.floor((this.getMonth() + 3) / 3), //季度 + S: this.getMilliseconds(), //毫秒 + }; + if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length)); + for (let k in o) + if (new RegExp('(' + k + ')').test(fmt)) + fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)); + return fmt; + }; + }, + + /** + * 版本比较 + * param {string} v1 > v2 ? 1 : -1 ; 相等返回0 + */ + compareVersion: function (v1, v2) { + v1 = v1.split('.'); + v2 = v2.split('.'); + let len = Math.max(v1.length, v2.length); + + while (v1.length < len) { + v1.push('0'); + } + + while (v2.length < len) { + v2.push('0'); + } + + for (let i = 0; i < len; i++) { + let num1 = parseInt(v1[i]); + let num2 = parseInt(v2[i]); + + if (num1 > num2) { + return 1; + } else if (num1 < num2) { + return -1; + } + } + + return 0; + }, +}; + +module.exports = utils; diff --git a/src/mindspore/utils/wx-validate.js b/src/mindspore/utils/wx-validate.js deleted file mode 100644 index cd45ceb..0000000 --- a/src/mindspore/utils/wx-validate.js +++ /dev/null @@ -1,426 +0,0 @@ -/** - * 表单验证 - * @param {Object} rules 验证字段的规则 - * @param {Object} messages 验证字段的提示信息 - */ - -class WxValidate { - constructor(rules = {}, messages = {}) { - Object.assign(this, { - data: {}, - rules, - messages, - }); - this.__init(); - } - - /** - * __init - */ - __init() { - this.__initMethods(); - this.__initDefaults(); - this.__initData(); - } - - /** - * 初始化数据 - */ - __initData() { - this.form = {}; - this.errorList = []; - } - - /** - * 初始化默认提示信息 - */ - __initDefaults() { - this.defaults = { - messages: { - required: '这是必填字段。', - email: '请输入有效的电子邮件地址。', - tel: '请输入11位的手机号码。', - url: '请输入有效的网址。', - date: '请输入有效的日期。', - dateISO: '请输入有效的日期(ISO),例如:2009-06-23,1998/01/22。', - number: '请输入有效的数字。', - digits: '只能输入数字。', - idcard: '请输入18位的有效身份证。', - equalTo: this.formatTpl('输入值必须和 {0} 相同。'), - contains: this.formatTpl('输入值必须包含 {0}。'), - minlength: this.formatTpl('最少要输入 {0} 个字符。'), - maxlength: this.formatTpl('最多可以输入 {0} 个字符。'), - rangelength: this.formatTpl('请输入长度在 {0} 到 {1} 之间的字符。'), - min: this.formatTpl('请输入不小于 {0} 的数值。'), - max: this.formatTpl('请输入不大于 {0} 的数值。'), - range: this.formatTpl('请输入范围在 {0} 到 {1} 之间的数值。'), - }, - }; - } - - /** - * 初始化默认验证方法 - */ - __initMethods() { - const that = this; - that.methods = { - /** - * 验证必填元素 - */ - required(value, param) { - if (!that.depend(param)) { - return 'dependency-mismatch'; - } else if (typeof value === 'number') { - value = value.toString(); - } else if (typeof value === 'boolean') { - return !0; - } - - return value.length > 0; - }, - /** - * 验证电子邮箱格式 - */ - email(value) { - return ( - that.optional(value) || - /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test( - value - ) - ); - }, - /** - * 验证手机格式 - */ - tel(value) { - return that.optional(value) || /^1[3456789]\d{9}$/.test(value); - }, - /** - * 验证URL格式 - */ - url(value) { - return ( - that.optional(value) || - /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test( - value - ) - ); - }, - /** - * 验证日期格式 - */ - date(value) { - return that.optional(value) || !/Invalid|NaN/.test(new Date(value).toString()); - }, - /** - * 验证ISO类型的日期格式 - */ - dateISO(value) { - return that.optional(value) || /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(value); - }, - /** - * 验证十进制数字 - */ - number(value) { - return that.optional(value) || /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value); - }, - /** - * 验证整数 - */ - digits(value) { - return that.optional(value) || /^\d+$/.test(value); - }, - /** - * 验证身份证号码 - */ - idcard(value) { - return ( - that.optional(value) || /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(value) - ); - }, - /** - * 验证两个输入框的内容是否相同 - */ - equalTo(value, param) { - return that.optional(value) || value === that.data[param]; - }, - /** - * 验证是否包含某个值 - */ - contains(value, param) { - return that.optional(value) || value.indexOf(param) >= 0; - }, - /** - * 验证最小长度 - */ - minlength(value, param) { - return that.optional(value) || value.length >= param; - }, - /** - * 验证最大长度 - */ - maxlength(value, param) { - return that.optional(value) || value.length <= param; - }, - /** - * 验证一个长度范围[min, max] - */ - rangelength(value, param) { - return that.optional(value) || (value.length >= param[0] && value.length <= param[1]); - }, - /** - * 验证最小值 - */ - min(value, param) { - return that.optional(value) || value >= param; - }, - /** - * 验证最大值 - */ - max(value, param) { - return that.optional(value) || value <= param; - }, - /** - * 验证一个值范围[min, max] - */ - range(value, param) { - return that.optional(value) || (value >= param[0] && value <= param[1]); - }, - }; - } - - /** - * 添加自定义验证方法 - * @param {String} name 方法名 - * @param {Function} method 函数体,接收两个参数(value, param),value表示元素的值,param表示参数 - * @param {String} message 提示信息 - */ - addMethod(name, method, message) { - this.methods[name] = method; - this.defaults.messages[name] = message !== undefined ? message : this.defaults.messages[name]; - } - - /** - * 判断验证方法是否存在 - */ - isValidMethod(value) { - let methods = []; - for (let method in this.methods) { - if (method && typeof this.methods[method] === 'function') { - methods.push(method); - } - } - return methods.indexOf(value) !== -1; - } - - /** - * 格式化提示信息模板 - */ - formatTpl(source, params) { - const that = this; - if (arguments.length === 1) { - return function () { - let args = Array.from(arguments); - args.unshift(source); - return that.formatTpl.apply(this, args); - }; - } - if (params === undefined) { - return source; - } - if (arguments.length > 2 && params.constructor !== Array) { - params = Array.from(arguments).slice(1); - } - if (params.constructor !== Array) { - params = [params]; - } - params.forEach(function (n, i) { - source = source.replace(new RegExp('\\{' + i + '\\}', 'g'), function () { - return n; - }); - }); - return source; - } - - /** - * 判断规则依赖是否存在 - */ - depend(param) { - switch (typeof param) { - case 'boolean': - param = param; - break; - case 'string': - param = !!param.length; - break; - case 'function': - param = param(); - default: - param = !0; - } - return param; - } - - /** - * 判断输入值是否为空 - */ - optional(value) { - return !this.methods.required(value) && 'dependency-mismatch'; - } - - /** - * 获取自定义字段的提示信息 - * @param {String} param 字段名 - * @param {Object} rule 规则 - */ - customMessage(param, rule) { - const params = this.messages[param]; - const isObject = typeof params === 'object'; - if (params && isObject) return params[rule.method]; - } - - /** - * 获取某个指定字段的提示信息 - * @param {String} param 字段名 - * @param {Object} rule 规则 - */ - defaultMessage(param, rule) { - let message = this.customMessage(param, rule) || this.defaults.messages[rule.method]; - let type = typeof message; - - if (type === 'undefined') { - message = `Warning: No message defined for ${rule.method}.`; - } else if (type === 'function') { - message = message.call(this, rule.parameters); - } - - return message; - } - - /** - * 缓存错误信息 - * @param {String} param 字段名 - * @param {Object} rule 规则 - * @param {String} value 元素的值 - */ - formatTplAndAdd(param, rule, value) { - let msg = this.defaultMessage(param, rule); - - this.errorList.push({ - param: param, - msg: msg, - value: value, - }); - } - - /** - * 验证某个指定字段的规则 - * @param {String} param 字段名 - * @param {Object} rules 规则 - * @param {Object} data 需要验证的数据对象 - */ - checkParam(param, rules, data) { - // 缓存数据对象 - this.data = data; - - // 缓存字段对应的值 - const value = data[param] !== null && data[param] !== undefined ? data[param] : ''; - - // 遍历某个指定字段的所有规则,依次验证规则,否则缓存错误信息 - for (let method in rules) { - // 判断验证方法是否存在 - if (this.isValidMethod(method)) { - // 缓存规则的属性及值 - const rule = { - method: method, - parameters: rules[method], - }; - - // 调用验证方法 - const result = this.methods[method](value, rule.parameters); - - // 若result返回值为dependency-mismatch,则说明该字段的值为空或非必填字段 - if (result === 'dependency-mismatch') { - continue; - } - - this.setValue(param, method, result, value); - - // 判断是否通过验证,否则缓存错误信息,跳出循环 - if (!result) { - this.formatTplAndAdd(param, rule, value); - break; - } - } - } - } - - /** - * 设置字段的默认验证值 - * @param {String} param 字段名 - */ - setView(param) { - this.form[param] = { - $name: param, - $valid: true, - $invalid: false, - $error: {}, - $success: {}, - $viewValue: ``, - }; - } - - /** - * 设置字段的验证值 - * @param {String} param 字段名 - * @param {String} method 字段的方法 - * @param {Boolean} result 是否通过验证 - * @param {String} value 字段的值 - */ - setValue(param, method, result, value) { - const params = this.form[param]; - params.$valid = result; - params.$invalid = !result; - params.$error[method] = !result; - params.$success[method] = result; - params.$viewValue = value; - } - - /** - * 验证所有字段的规则,返回验证是否通过 - * @param {Object} data 需要验证数据对象 - */ - checkForm(data) { - this.__initData(); - - for (let param in this.rules) { - this.setView(param); - this.checkParam(param, this.rules[param], data); - } - - return this.valid(); - } - - /** - * 返回验证是否通过 - */ - valid() { - return this.size() === 0; - } - - /** - * 返回错误信息的个数 - */ - size() { - return this.errorList.length; - } - - /** - * 返回所有错误信息 - */ - validationErrors() { - return this.errorList; - } -} - -module.exports = WxValidate; diff --git a/src/openeuler/app.js b/src/openeuler/app.js index 4a54bad..523ebdc 100644 --- a/src/openeuler/app.js +++ b/src/openeuler/app.js @@ -1,49 +1,47 @@ //app.js App({ - onLaunch: function () { - const self = this - //判断微信版本是否 兼容小程序更新机制API的使用 - if (wx.canIUse('getUpdateManager')) { - //创建 UpdateManager 实例 - const updateManager = wx.getUpdateManager(); - console.log('是否进入模拟更新'); - //检测版本更新 - updateManager.onCheckForUpdate(function (res) { - console.log('是否获取版本'); - // 请求完新版本信息的回调 - if (res.hasUpdate) { - //监听小程序有版本更新事件 - updateManager.onUpdateReady(function () { - - updateManager.applyUpdate(); - }) - updateManager.onUpdateFailed(function () { - wx.showModal({ - title: '已经有新版本喽~', - content: '请您删除当前小程序,到微信 “发现-小程序” 页,重新搜索打开哦~', - }) - }) - } - }) - } else { + onLaunch: function () { + const self = this; + //判断微信版本是否 兼容小程序更新机制API的使用 + if (wx.canIUse('getUpdateManager')) { + //创建 UpdateManager 实例 + const updateManager = wx.getUpdateManager(); + console.log('是否进入模拟更新'); + //检测版本更新 + updateManager.onCheckForUpdate(function (res) { + console.log('是否获取版本'); + // 请求完新版本信息的回调 + if (res.hasUpdate) { + //监听小程序有版本更新事件 + updateManager.onUpdateReady(function () { + updateManager.applyUpdate(); + }); + updateManager.onUpdateFailed(function () { wx.showModal({ - title: '溫馨提示', - content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。' - }) + title: '已经有新版本喽~', + content: '请您删除当前小程序,到微信 “发现-小程序” 页,重新搜索打开哦~', + }); + }); } - wx.getSystemInfo({ - success(res) { - if (res.model.indexOf('iPhone X') >= 0) { - self.globalData.iPhoneX = true; - } - } - }) - - }, - - onShow() {}, - loginCallback: null, - globalData: { - iphoneX: false + }); + } else { + wx.showModal({ + title: '溫馨提示', + content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。', + }); } -}) \ No newline at end of file + wx.getSystemInfo({ + success(res) { + if (res.model.indexOf('iPhone X') >= 0) { + self.globalData.iPhoneX = true; + } + }, + }); + }, + + onShow() {}, + loginCallback: null, + globalData: { + iphoneX: false, + }, +}); diff --git a/src/openeuler/components/privacy-text/privacy-text.js b/src/openeuler/components/privacy-text/privacy-text.js index ba411f8..04c282c 100644 --- a/src/openeuler/components/privacy-text/privacy-text.js +++ b/src/openeuler/components/privacy-text/privacy-text.js @@ -1,9 +1,7 @@ -//获取应用实例 -// const app = getApp(); - -Page({ - data: { - }, - onLoad: function () { - }, -}) \ No newline at end of file +//获取应用实例 +// const app = getApp(); + +Page({ + data: {}, + onLoad: function () {}, +}); diff --git a/src/openeuler/components/privacy/privacy.js b/src/openeuler/components/privacy/privacy.js index 39d7b8d..6fc99c5 100644 --- a/src/openeuler/components/privacy/privacy.js +++ b/src/openeuler/components/privacy/privacy.js @@ -1,91 +1,90 @@ -// component/privacy/privacy.js -Component({ - /** - * 组件的初始数据 - */ - data: { - privacyContractName: '', - showPrivacy: false - }, - /** - * 组件的生命周期 - */ - pageLifetimes: { - show() { - const _ = this - const version = wx.getAppBaseInfo().SDKVersion - if (_.compareVersion(version, '2.32.3') >= 0) { - wx.getPrivacySetting({ - success(res) { - if (res.errMsg == "getPrivacySetting:ok") { - _.setData({ - privacyContractName: res.privacyContractName, - showPrivacy: res.needAuthorization - }) - } - } - }) - } - } - }, - /** - * 组件的方法列表 - */ - methods: { - // 打开隐私协议页面 - openPrivacyContract() { - const _ = this - wx.openPrivacyContract({ - fail: () => { - wx.showToast({ - title: '遇到错误', - icon: 'error' - }) - } - }) - }, - // 拒绝隐私协议 - exitMiniProgram() { - wx.switchTab({ - url: '/pages/index/index', - }); - }, - // 同意隐私协议 - handleAgreePrivacyAuthorization() { - const _ = this - _.setData({ - showPrivacy: false - }) - }, - // 比较版本号 - compareVersion(v1, v2) { - v1 = v1.split('.') - v2 = v2.split('.') - const len = Math.max(v1.length, v2.length) - - while (v1.length < len) { - v1.push('0') - } - while (v2.length < len) { - v2.push('0') - } - - for (let i = 0; i < len; i++) { - const num1 = parseInt(v1[i]) - const num2 = parseInt(v2[i]) - - if (num1 > num2) { - return 1 - } else if (num1 < num2) { - return -1 - } - } - - return 0 - }, - // 通过绑定空事件禁止滑动事件的穿透 - handleCatchtouchMove() { - return - } - }, -}) \ No newline at end of file +// component/privacy/privacy.js +Component({ + /** + * 组件的初始数据 + */ + data: { + privacyContractName: '', + showPrivacy: false, + }, + /** + * 组件的生命周期 + */ + pageLifetimes: { + show() { + const _ = this; + const version = wx.getAppBaseInfo().SDKVersion; + if (_.compareVersion(version, '2.32.3') >= 0) { + wx.getPrivacySetting({ + success(res) { + if (res.errMsg == 'getPrivacySetting:ok') { + _.setData({ + privacyContractName: res.privacyContractName, + showPrivacy: res.needAuthorization, + }); + } + }, + }); + } + }, + }, + /** + * 组件的方法列表 + */ + methods: { + // 打开隐私协议页面 + openPrivacyContract() { + wx.openPrivacyContract({ + fail: () => { + wx.showToast({ + title: '遇到错误', + icon: 'error', + }); + }, + }); + }, + // 拒绝隐私协议 + exitMiniProgram() { + wx.switchTab({ + url: '/pages/index/index', + }); + }, + // 同意隐私协议 + handleAgreePrivacyAuthorization() { + const _ = this; + _.setData({ + showPrivacy: false, + }); + }, + // 比较版本号 + compareVersion(v1, v2) { + v1 = v1.split('.'); + v2 = v2.split('.'); + const len = Math.max(v1.length, v2.length); + + while (v1.length < len) { + v1.push('0'); + } + while (v2.length < len) { + v2.push('0'); + } + + for (let i = 0; i < len; i++) { + const num1 = parseInt(v1[i]); + const num2 = parseInt(v2[i]); + + if (num1 > num2) { + return 1; + } else if (num1 < num2) { + return -1; + } + } + + return 0; + }, + // 通过绑定空事件禁止滑动事件的穿透 + handleCatchtouchMove() { + return; + }, + }, +}); diff --git a/src/openeuler/components/user-info/user-info.js b/src/openeuler/components/user-info/user-info.js index 0377f21..5d432b4 100644 --- a/src/openeuler/components/user-info/user-info.js +++ b/src/openeuler/components/user-info/user-info.js @@ -1,72 +1,70 @@ // components/user-info/user-info.js -const sessionUtil = require("../../utils/app-session.js"); +const sessionUtil = require('../../utils/app-session.js'); const localMethods = { - getCurText() { - let timestamp = Date.parse(new Date()); - timestamp = timestamp / 1000; - let n = timestamp * 1000; - let date = new Date(n); - let h = date.getHours(); - let m = date.getMinutes(); - let hm = parseFloat(h + '.' + m); - if (23 < hm || hm <= 6) { - return '请睡吧'; - } - if (6 < hm && hm <= 12) { - return '上午好'; - } - if (12 < hm && hm <= 14) { - return '中午好'; - } - if (14 < hm && hm <= 18) { - return '下午好'; - } - if (18 < hm && hm <= 23) { - return '晚上好'; - } + getCurText() { + let timestamp = Date.parse(new Date()); + timestamp = timestamp / 1000; + let n = timestamp * 1000; + let date = new Date(n); + let h = date.getHours(); + let m = date.getMinutes(); + let hm = parseFloat(h + '.' + m); + if (23 < hm || hm <= 6) { + return '请睡吧'; } -} + if (6 < hm && hm <= 12) { + return '上午好'; + } + if (12 < hm && hm <= 14) { + return '中午好'; + } + if (14 < hm && hm <= 18) { + return '下午好'; + } + if (18 < hm && hm <= 23) { + return '晚上好'; + } + }, +}; Component({ - /** - * 组件的属性列表 - */ - properties: { + /** + * 组件的属性列表 + */ + properties: {}, - }, + /** + * 组件的初始数据 + */ + data: { + isLogin: false, + avatarUrl: '', + text: '', + nickName: '', + }, + pageLifetimes: { + // 组件所在页面的生命周期函数 - /** - * 组件的初始数据 - */ - data: { - isLogin: false, - avatarUrl: '', - text: '', - nickName: '' + show: function () { + this.setData({ + isLogin: sessionUtil.getUserInfoByKey('access') || false, + }); + if (this.data.isLogin) { + this.setData({ + avatarUrl: sessionUtil.getUserInfoByKey('avatarUrl'), + text: localMethods.getCurText(), + nickName: sessionUtil.getUserInfoByKey('nickName'), + }); + } }, - pageLifetimes: { - // 组件所在页面的生命周期函数 - - show: function () { - this.setData({ - isLogin: sessionUtil.getUserInfoByKey('access') || false - }) - if (this.data.isLogin) { - this.setData({ - avatarUrl: sessionUtil.getUserInfoByKey('avatarUrl'), - text: localMethods.getCurText(), - nickName: sessionUtil.getUserInfoByKey('nickName') - }) - } - } + }, + /** + * 组件的方法列表 + */ + methods: { + login() { + wx.navigateTo({ + url: '/pages/auth/auth', + }); }, - /** - * 组件的方法列表 - */ - methods: { - login() { - wx.navigateTo({ - url: '/pages/auth/auth' - }) - } - } -}) \ No newline at end of file + }, +}); diff --git a/src/openeuler/config/constants.js b/src/openeuler/config/constants.js index 3a56836..0b05cb5 100644 --- a/src/openeuler/config/constants.js +++ b/src/openeuler/config/constants.js @@ -5,19 +5,18 @@ let _ = require('../utils/underscore-extend.js'); // 服务连接配置 let serviceConfig = { - // SERVICE_URL: "https://api.openeuler.org/meetings", // 正式环境 - SERVICE_URL: 'https://meetingserver-openeuler.test.osinfra.cn', // 测试环境 + SERVICE_URL: 'https://api.openeuler.org/meetings', // 正式环境 + // SERVICE_URL: 'https://meetingserver-openeuler.test.osinfra.cn', // 测试环境 }; // 存储配置 let storageConfig = { - APP_USERINFO_SESSION: "_app_userinfo_session" + APP_USERINFO_SESSION: '_app_userinfo_session', }; // 所有配置 -let constants = _.deepExtend(true, - serviceConfig, - storageConfig -); +let constants = _.deepExtend(true, serviceConfig, storageConfig); -module.exports = constants; \ No newline at end of file +console.log(constants); + +module.exports = constants; diff --git a/src/openeuler/config/services-config.js b/src/openeuler/config/services-config.js index afd9749..4c5f55b 100644 --- a/src/openeuler/config/services-config.js +++ b/src/openeuler/config/services-config.js @@ -1,167 +1,162 @@ -let _ = require('../utils/underscore-extend.js'); - -// 通用接口配置 -let commonServiceConfig = { - - // 登录接口 - LOGIN: "/login/", - - // 登录接口 - SIG_LIST: "/groups/", - - // 获取sig组已添加成员列表 - SIG_MEMBER_LIST: "/users_include/{id}/", - - // 获取sig组未添加成员列表 - SIG_EXCLUDE_MEMBER_LIST: "/users_exclude/{id}/", - - // 获取sig组未添加成员列表 - ADD_MEMBER_LIST: "/groupuser/action/new/", - - // 获取sig组已添加成员列表 - SIG_CLUDE_MEMBER_LIST: "/users_include/{id}/", - - // 获取sig组未添加成员列表 - DEL_MEMBER_LIST: "/groupuser/action/del/", - - // 获取sig组未添加成员列表 - GET_USER_GROUP: "/usergroup/{id}/", - - // 创建会议 - SAVE_MEETING: "/meetings/", - - // 获取会议详情 - GET_MEETING_DETAIL: "/meetings/{id}/", - - // 获取当日会议列表 - GET_MEETING_DAILY: "/meetings_daily/", - - // 获取前后一周会议列表 - GET_MEETING_WEEKLY: "/meetings_weekly/", - - // 删除会议 - DEL_MEETING: "/meeting/{id}/", - - // 获取用户状态 - GET_USER_STATUS: "/userinfo/{id}/", - - // 保存用户giteename - SAVE_MEMBER_DETAIL: '/user/{id}/', - - // 我创建的会议列表 - MY_MEETINGS_LIST: '/mymeetings/', - - // 收藏会议 - COLLECT: '/collect/', - - // 取消收藏 - UNCOLLECT: '/collect/{id}/', - - // 收藏列表 - MY_COLLECT_LIST: '/collections/', - - // 获取发起人列表 - ENTERPRISE_MEMBER_LIST: '/sponsors/', - - // 获取未添加发起人名单 - ENTERPRISE_EXCLUDE_MEMBER_LIST: '/nonsponsors/', - - // 添加发起人 - ENTERPRISE_ADD_MEMBER_LIST: '/sponsor/action/new/', - - // 编辑发起人信息 - ENTERPRISE_SAVE_MEMBER_DETAIL: '/sponsorinfo/{id}/', - - // 删除发起人 - ENTERPRISE_DEL_MEMBER_LIST: '/sponsor/action/del/', - - // 发布 - PUBLISH_EVENT: '/activity/', - - // 保存草稿 - SAVE_DRAFT: '/activitydraft/', - - // 获取草稿箱活动列表 - GET_DRAFT_LIST: '/activitiesdraft/', - - // 获取全量待发布 - DRAFTS: '/drafts/', - - //草稿详情 - DRAFT_DETAIL: '/sponsoractivitydraft/{id}/', - - // 修改草稿 - EDIT_DETAIL: '/draftupdate/{id}/', - - // 修改草稿并发布 - - EDIT_DETAIL_PUBLISH: '/draftpublish/{id}/', - - // 驳回活动发布 - REJECT_PUBLISH: '/activityreject/{id}/', - - // 活动审核通过 - RESOLVE_PUBLISH: '/activitypublish/{id}/', - - // 活动审核通过 - PUBLISHER_EVENTS_LIST: '/sponsoractivitiespublishing/', - - // 我发布的活动 - MY_EVENTS_LIST: '/sponsoractivities/', - - // 我发布的活动 - DEL_EVENT: '/activitydel/{id}/', - - // 所有活动 - ALL_EVENTS_LIST: '/activities/', - - // 所有活动 - EVENT_DETAIL: '/activity/{id}/', - - // 修改日程 - EDIT_SCHEDULE: '/activityupdate/{id}/', - - // 修改日程 - EXAMINE_DETAIL: '/draft/{id}/', - - // 修改日程 - EVENT_COLLECT: '/collectactivity/', - - // 修改日程 - EVENT_UNCOLLECT: '/collectactivitydel/{id}/', - - // 活动收藏列表 - EVENT_COLLECT_LIST: '/collectactivities/', - - // 最新活动列表 - LATEST_EVENTS: '/recentactivities/', - - // 保存意见反馈 - SAVE_FEEDBACK: '/feedback/', - - // 获取已发布分类数量 - GET_EVENTS_COUNT: '/countactivities/', - - // 获取我的页面各类计数 - GET_MY_COUNT: '/mycounts/', - - // 最近的会议列表 - RECENTLY_MEETINGS: '/meetings_recently/', - - // 同意隐私政策 - AGREE: '/agree/', - // 退出登陆 - LOGOUT: '/logout/', - // 注销账号 - LOGOFF: '/logoff/', - // 撤销登陆 - REVOKE: '/revoke/' -}; - - - -let servicesConfig = _.deepExtend(true, - commonServiceConfig -); - -module.exports = servicesConfig; \ No newline at end of file +let _ = require('../utils/underscore-extend.js'); + +// 通用接口配置 +let commonServiceConfig = { + // 登录接口 + LOGIN: '/login/', + + // 登录接口 + SIG_LIST: '/groups/', + + // 获取sig组已添加成员列表 + SIG_MEMBER_LIST: '/users_include/{id}/', + + // 获取sig组未添加成员列表 + SIG_EXCLUDE_MEMBER_LIST: '/users_exclude/{id}/', + + // 获取sig组未添加成员列表 + ADD_MEMBER_LIST: '/groupuser/action/new/', + + // 获取sig组已添加成员列表 + SIG_CLUDE_MEMBER_LIST: '/users_include/{id}/', + + // 获取sig组未添加成员列表 + DEL_MEMBER_LIST: '/groupuser/action/del/', + + // 获取sig组未添加成员列表 + GET_USER_GROUP: '/usergroup/{id}/', + + // 创建会议 + SAVE_MEETING: '/meetings/', + + // 获取会议详情 + GET_MEETING_DETAIL: '/meetings/{id}/', + + // 获取当日会议列表 + GET_MEETING_DAILY: '/meetings_daily/', + + // 获取前后一周会议列表 + GET_MEETING_WEEKLY: '/meetings_weekly/', + + // 删除会议 + DEL_MEETING: '/meeting/{id}/', + + // 获取用户状态 + GET_USER_STATUS: '/userinfo/{id}/', + + // 保存用户giteename + SAVE_MEMBER_DETAIL: '/user/{id}/', + + // 我创建的会议列表 + MY_MEETINGS_LIST: '/mymeetings/', + + // 收藏会议 + COLLECT: '/collect/', + + // 取消收藏 + UNCOLLECT: '/collect/{id}/', + + // 收藏列表 + MY_COLLECT_LIST: '/collections/', + + // 获取发起人列表 + ENTERPRISE_MEMBER_LIST: '/sponsors/', + + // 获取未添加发起人名单 + ENTERPRISE_EXCLUDE_MEMBER_LIST: '/nonsponsors/', + + // 添加发起人 + ENTERPRISE_ADD_MEMBER_LIST: '/sponsor/action/new/', + + // 编辑发起人信息 + ENTERPRISE_SAVE_MEMBER_DETAIL: '/sponsorinfo/{id}/', + + // 删除发起人 + ENTERPRISE_DEL_MEMBER_LIST: '/sponsor/action/del/', + + // 发布 + PUBLISH_EVENT: '/activity/', + + // 保存草稿 + SAVE_DRAFT: '/activitydraft/', + + // 获取草稿箱活动列表 + GET_DRAFT_LIST: '/activitiesdraft/', + + // 获取全量待发布 + DRAFTS: '/drafts/', + + //草稿详情 + DRAFT_DETAIL: '/sponsoractivitydraft/{id}/', + + // 修改草稿 + EDIT_DETAIL: '/draftupdate/{id}/', + + // 修改草稿并发布 + + EDIT_DETAIL_PUBLISH: '/draftpublish/{id}/', + + // 驳回活动发布 + REJECT_PUBLISH: '/activityreject/{id}/', + + // 活动审核通过 + RESOLVE_PUBLISH: '/activitypublish/{id}/', + + // 活动审核通过 + PUBLISHER_EVENTS_LIST: '/sponsoractivitiespublishing/', + + // 我发布的活动 + MY_EVENTS_LIST: '/sponsoractivities/', + + // 我发布的活动 + DEL_EVENT: '/activitydel/{id}/', + + // 所有活动 + ALL_EVENTS_LIST: '/activities/', + + // 所有活动 + EVENT_DETAIL: '/activity/{id}/', + + // 修改日程 + EDIT_SCHEDULE: '/activityupdate/{id}/', + + // 修改日程 + EXAMINE_DETAIL: '/draft/{id}/', + + // 修改日程 + EVENT_COLLECT: '/collectactivity/', + + // 修改日程 + EVENT_UNCOLLECT: '/collectactivitydel/{id}/', + + // 活动收藏列表 + EVENT_COLLECT_LIST: '/collectactivities/', + + // 最新活动列表 + LATEST_EVENTS: '/recentactivities/', + + // 保存意见反馈 + SAVE_FEEDBACK: '/feedback/', + + // 获取已发布分类数量 + GET_EVENTS_COUNT: '/countactivities/', + + // 获取我的页面各类计数 + GET_MY_COUNT: '/mycounts/', + + // 最近的会议列表 + RECENTLY_MEETINGS: '/meetings_recently/', + + // 同意隐私政策 + AGREE: '/agree/', + // 退出登陆 + LOGOUT: '/logout/', + // 注销账号 + LOGOFF: '/logoff/', + // 撤销登陆 + REVOKE: '/revoke/', +}; + +let servicesConfig = _.deepExtend(true, commonServiceConfig); + +module.exports = servicesConfig; diff --git a/src/openeuler/custom-tab-bar/index.js b/src/openeuler/custom-tab-bar/index.js index c413064..026a360 100644 --- a/src/openeuler/custom-tab-bar/index.js +++ b/src/openeuler/custom-tab-bar/index.js @@ -1,57 +1,49 @@ // custom-tab-bar/index.js -const sessionUtil = require("./../utils/app-session.js"); +const sessionUtil = require('./../utils/app-session.js'); Component({ - /** - * 组件的属性列表 - */ - properties: { - - }, - - /** - * 组件的初始数据 - */ - data: { - show: true, - _tabbat: 0, - iPhoneX: null, - urls: [ - '/pages/index/index', - '/pages/meeting/meeting', - '/pages/events/events', - '/pages/my/my' - ] - }, - attached() { - let self = this - wx.getSystemInfo({ - success(res) { - if ((res.model.indexOf('iPhone X') >= 0) || (res.model.indexOf('iPhone 11') >= 0)) { - self.setData({ - iPhoneX: true - }); - } - } - }) - }, - /** - * 组件的方法列表 - */ - methods: { - switchTap: function (e) { - if(!sessionUtil.getUserInfoByKey('access') && Number(e.currentTarget.dataset.index) ===3 ){ - wx.navigateTo({ - url: '/pages/auth/auth' - }) - return; - } - let self = this - let index = e.currentTarget.dataset.index; - let urls = self.data.urls - wx.switchTab({ - url: urls[index], - }) + /** + * 组件的属性列表 + */ + properties: {}, + /** + * 组件的初始数据 + */ + data: { + show: true, + _tabbat: 0, + iPhoneX: null, + urls: ['/pages/index/index', '/pages/meeting/meeting', '/pages/events/events', '/pages/my/my'], + }, + attached() { + let self = this; + wx.getSystemInfo({ + success(res) { + if (res.model.indexOf('iPhone X') >= 0 || res.model.indexOf('iPhone 11') >= 0) { + self.setData({ + iPhoneX: true, + }); } - } -}) \ No newline at end of file + }, + }); + }, + /** + * 组件的方法列表 + */ + methods: { + switchTap: function (e) { + if (!sessionUtil.getUserInfoByKey('access') && Number(e.currentTarget.dataset.index) === 3) { + wx.navigateTo({ + url: '/pages/auth/auth', + }); + return; + } + let self = this; + let index = e.currentTarget.dataset.index; + let urls = self.data.urls; + wx.switchTab({ + url: urls[index], + }); + }, + }, +}); diff --git a/src/openeuler/package-events/events/event-detail.js b/src/openeuler/package-events/events/event-detail.js index e9b148b..d090d97 100644 --- a/src/openeuler/package-events/events/event-detail.js +++ b/src/openeuler/package-events/events/event-detail.js @@ -1,326 +1,307 @@ -// package-events/events/event-detail.js -const appAjax = require('./../../utils/app-ajax'); -const sessionUtil = require("../../utils/app-session.js"); - -let that = null; -let remoteMethods = { - getDraftDetail: function (_callback) { - let service = 'EVENT_DETAIL'; - if (that.data.type == 5) { - service = 'EVENT_DETAIL' - } else if (that.data.type == 1) { - service = 'EXAMINE_DETAIL' - } else if (that.data.type == 4) { - service = 'DRAFT_DETAIL' - } - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service, - otherParams: { - id: that.data.id - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - reject: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'PUT', - service: 'REJECT_PUBLISH', - otherParams: { - id: that.data.id || '' - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - resolve: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'PUT', - service: 'RESOLVE_PUBLISH', - otherParams: { - id: that.data.id || '' - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - draftPublish: function (postData, _callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'PUT', - service: 'EDIT_DETAIL_PUBLISH', - data: postData, - otherParams: { - id: that.data.id || '' - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - collect: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'POST', - service: 'EVENT_COLLECT', - data: { - activity: that.data.id - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - unCollect: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'DELETE', - service: 'EVENT_UNCOLLECT', - otherParams: { - id: that.data.info.collection_id - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - } -} -Page({ - - /** - * 页面的初始数据 - */ - data: { - info: {}, - id: '', - steps: [], - tabIndex: 0, - type: 0, - level: 1, - user: '', - scene: '', - isIphoneX: false, - videoInstance: null, - videoHidden: true - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - that = this; - this.setData({ - id: options.id || decodeURIComponent(options.scene), - scene: decodeURIComponent(options.scene) || '', - type: options.type, - level: sessionUtil.getUserInfoByKey('eventLevel') || 1 - }) - wx.getSystemInfo({ - success(res) { - if ((res.model.indexOf('iPhone X') >= 0) || (res.model.indexOf('iPhone 11') >= 0)) { - that.setData({ - isIphoneX: true - }); - } - } - }) - this.setData({ - videoInstance: wx.createVideoContext('video') - }) - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - this.setData({ - user: sessionUtil.getUserInfoByKey('userId') - }) - remoteMethods.getDraftDetail((res) => { - this.setData({ - info: res - }) - let arr = []; - JSON.parse(res.schedules).forEach(item => { - if (item.speakerList) { - arr.push({ - duration: item.start + '-' + item.end, - title: item.topic, - speakerList: item.speakerList - }) - } else { - arr.push({ - duration: item.start + '-' + item.end, - title: item.topic, - speakerList: [{ - name: item.speaker || '', - title: item.desc || '' - }] - }) - } - - }); - this.setData({ - steps: arr - }) - }); - }, - switchTab(e) { - this.setData({ - tabIndex: e.currentTarget.dataset.index - }) - }, - openLocation(e) { - if (e.currentTarget.dataset.item.activity_type == 2) { - return; - } - wx.showModal({ - title: '提示', - content: '即将唤起腾讯地图,是否同意?', - success(res) { - if (res.confirm) { - wx.openLocation({ - latitude: Number(e.currentTarget.dataset.item.latitude), - longitude: Number(e.currentTarget.dataset.item.longitude), - name: e.currentTarget.dataset.item.detail_address, // 名称 - address: e.currentTarget.dataset.item.address // 地址 - }); - } else if (res.cancel) { - return false - } - } - }) - }, - toEditDraft() { - wx.redirectTo({ - url: `/package-events/publish/publish?id=${this.data.id}&type=${this.data.type}` - }) - }, - draftPublish() { - let postData = this.data.info; - postData.schedules = JSON.parse(postData.schedules); - remoteMethods.draftPublish(postData, (res) => { - if (res.code === 201) { - wx.redirectTo({ - url: '/package-events/publish/success?type=2' - }) - } else { - setTimeout(function () { - wx.showToast({ - title: res.message, - icon: "none", - duration: 2000 - }, 100); - }) - } - }) - }, - reject() { - remoteMethods.reject(() => { - wx.navigateBack(); - }) - }, - resolve() { - remoteMethods.resolve(() => { - wx.navigateBack(); - }) - }, - editSchedule() { - wx.redirectTo({ - url: `/package-events/publish/publish?id=${this.data.id}&type=${this.data.type}` - }) - }, - switchTab2() { - this.setData({ - tabIndex: 1 - }) - }, - toSignUp() { - this.setData({ - showRegister: true, - }); - }, - onShareAppMessage() { - return { - title: '活动详情', - path: `/package-events/events/event-detail?id=${that.data.id}&type=5` - } - }, - copyLink: function () { - wx.setClipboardData({ - data: this.data.info.join_url, - success: function (res) { - that.setData({ - showDialog: false - }) - } - }) - - }, - toPoster(e) { - wx.navigateTo({ - url: `/package-events/events/poster?isDraft=${e.currentTarget.dataset.flag || ''}&id=${this.data.info.id}` - }) - }, - redrictLogin() { - if (this.data.scene) { - wx.navigateTo({ - url: '/pages/auth/auth?id=' + that.data.id - }) - } else { - wx.navigateTo({ - url: '/pages/auth/auth' - }) - } - }, - collect() { - if (!this.data.info.collection_id) { - remoteMethods.collect(() => { - this.onShow(); - }) - } else { - remoteMethods.unCollect(() => { - this.onShow(); - }) - } - - }, - clickVideo() { - this.data.videoInstance.requestFullScreen({ - direction: 90 - }); - }, - copyLink(e) { - let link = e.currentTarget.dataset.link; - let that = this; - wx.setClipboardData({ - data: link, - success: function () { - that.setData({ - showDialog: false, - showReplay: false, - showRegister: false, - }); - }, - fail: function () { - that.setData({ - showDialog: false, - showReplay: false, - showRegister: false, - }); - }, - }); - }, - fullScreenChange() { - this.setData({ - videoHidden: !this.data.videoHidden - }) - } -}) \ No newline at end of file +// package-events/events/event-detail.js +const appAjax = require('./../../utils/app-ajax'); +const sessionUtil = require('../../utils/app-session.js'); + +let that = null; +let remoteMethods = { + getDraftDetail: function (_callback) { + let service = 'EVENT_DETAIL'; + if (that.data.type == 5) { + service = 'EVENT_DETAIL'; + } else if (that.data.type == 1) { + service = 'EXAMINE_DETAIL'; + } else if (that.data.type == 4) { + service = 'DRAFT_DETAIL'; + } + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service, + otherParams: { + id: that.data.id, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + reject: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'PUT', + service: 'REJECT_PUBLISH', + otherParams: { + id: that.data.id || '', + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + resolve: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'PUT', + service: 'RESOLVE_PUBLISH', + otherParams: { + id: that.data.id || '', + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + draftPublish: function (postData, _callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'PUT', + service: 'EDIT_DETAIL_PUBLISH', + data: postData, + otherParams: { + id: that.data.id || '', + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + collect: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'POST', + service: 'EVENT_COLLECT', + data: { + activity: that.data.id, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + unCollect: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'DELETE', + service: 'EVENT_UNCOLLECT', + otherParams: { + id: that.data.info.collection_id, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; +Page({ + /** + * 页面的初始数据 + */ + data: { + info: {}, + id: '', + steps: [], + tabIndex: 0, + type: 0, + level: 1, + user: '', + scene: '', + isIphoneX: false, + videoInstance: null, + videoHidden: true, + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + that = this; + this.setData({ + id: options.id || decodeURIComponent(options.scene), + scene: decodeURIComponent(options.scene) || '', + type: options.type, + level: sessionUtil.getUserInfoByKey('eventLevel') || 1, + }); + wx.getSystemInfo({ + success(res) { + if (res.model.indexOf('iPhone X') >= 0 || res.model.indexOf('iPhone 11') >= 0) { + that.setData({ + isIphoneX: true, + }); + } + }, + }); + this.setData({ + videoInstance: wx.createVideoContext('video'), + }); + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + this.setData({ + user: sessionUtil.getUserInfoByKey('userId'), + }); + remoteMethods.getDraftDetail((res) => { + this.setData({ + info: res, + }); + let arr = []; + JSON.parse(res.schedules).forEach((item) => { + if (item.speakerList) { + arr.push({ + duration: item.start + '-' + item.end, + title: item.topic, + speakerList: item.speakerList, + }); + } else { + arr.push({ + duration: item.start + '-' + item.end, + title: item.topic, + speakerList: [ + { + name: item.speaker || '', + title: item.desc || '', + }, + ], + }); + } + }); + this.setData({ + steps: arr, + }); + }); + }, + switchTab(e) { + this.setData({ + tabIndex: e.currentTarget.dataset.index, + }); + }, + openLocation(e) { + if (e.currentTarget.dataset.item.activity_type == 2) { + return; + } + wx.showModal({ + title: '提示', + content: '即将唤起腾讯地图,是否同意?', + success(res) { + if (res.confirm) { + wx.openLocation({ + latitude: Number(e.currentTarget.dataset.item.latitude), + longitude: Number(e.currentTarget.dataset.item.longitude), + name: e.currentTarget.dataset.item.detail_address, // 名称 + address: e.currentTarget.dataset.item.address, // 地址 + }); + } else if (res.cancel) { + return false; + } + }, + }); + }, + toEditDraft() { + wx.redirectTo({ + url: `/package-events/publish/publish?id=${this.data.id}&type=${this.data.type}`, + }); + }, + draftPublish() { + let postData = this.data.info; + postData.schedules = JSON.parse(postData.schedules); + remoteMethods.draftPublish(postData, (res) => { + if (res.code === 201) { + wx.redirectTo({ + url: '/package-events/publish/success?type=2', + }); + } else { + setTimeout(function () { + wx.showToast( + { + title: res.message, + icon: 'none', + duration: 2000, + }, + 100 + ); + }); + } + }); + }, + reject() { + remoteMethods.reject(() => { + wx.navigateBack(); + }); + }, + resolve() { + remoteMethods.resolve(() => { + wx.navigateBack(); + }); + }, + editSchedule() { + wx.redirectTo({ + url: `/package-events/publish/publish?id=${this.data.id}&type=${this.data.type}`, + }); + }, + switchTab2() { + this.setData({ + tabIndex: 1, + }); + }, + toSignUp() { + this.setData({ + showRegister: true, + }); + }, + onShareAppMessage() { + return { + title: '活动详情', + path: `/package-events/events/event-detail?id=${that.data.id}&type=5`, + }; + }, + copyLink: function () { + wx.setClipboardData({ + data: this.data.info.join_url, + success: function () { + that.setData({ + showDialog: false, + }); + }, + }); + }, + toPoster(e) { + wx.navigateTo({ + url: `/package-events/events/poster?isDraft=${e.currentTarget.dataset.flag || ''}&id=${this.data.info.id}`, + }); + }, + redrictLogin() { + if (this.data.scene) { + wx.navigateTo({ + url: '/pages/auth/auth?id=' + that.data.id, + }); + } else { + wx.navigateTo({ + url: '/pages/auth/auth', + }); + } + }, + collect() { + if (!this.data.info.collection_id) { + remoteMethods.collect(() => { + this.onShow(); + }); + } else { + remoteMethods.unCollect(() => { + this.onShow(); + }); + } + }, + clickVideo() { + this.data.videoInstance.requestFullScreen({ + direction: 90, + }); + }, + + fullScreenChange() { + this.setData({ + videoHidden: !this.data.videoHidden, + }); + }, +}); diff --git a/src/openeuler/package-events/events/event-list.js b/src/openeuler/package-events/events/event-list.js index adc0945..27f5738 100644 --- a/src/openeuler/package-events/events/event-list.js +++ b/src/openeuler/package-events/events/event-list.js @@ -1,333 +1,329 @@ -// package-events/events/test.js -const appAjax = require('./../../utils/app-ajax'); -const sessionUtil = require("../../utils/app-session.js"); -const appUser = require("../../utils/app-user.js"); -let that = null; - -let remoteMethods = { - getList: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service: 'ALL_EVENTS_LIST', - data: { - activity: that.data.activity, - activity_type: that.data.curFilterType, - search: that.data.curKeyword - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - getCount: function (_callback) { - appAjax.postJson({ - type: 'GET', - service: 'GET_EVENTS_COUNT', - data: { - activity_type: that.data.curFilterType, - search: that.data.curKeyword - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - delDraft: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'DELETE', - service: 'DRAFT_DETAIL', - otherParams: { - id: that.data.curId - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - delEvent: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'PUT', - service: 'DEL_EVENT', - otherParams: { - id: that.data.curId - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - collect: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'POST', - service: 'EVENT_COLLECT', - data: { - activity: that.data.curId - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - unCollect: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'DELETE', - service: 'EVENT_UNCOLLECT', - otherParams: { - id: that.data.collectionId - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, -} -Page({ - - /** - * 页面的初始数据 - */ - data: { - level: 1, - user: '', - curKeyword: '', - popShow: false, - curFilterType: '', - curfilterTypeName: '全部类型', - filterType: '', - filterTypeName: '全部类型', - columns: [{ - type: '', - name: '全部类型' - }, - { - type: 1, - name: '线下' - }, - { - type: 2, - name: '线上' - } - ], - list: [], - actionShow: false, - actions: [], - showDialogDel: false, - underDialogShow: false, - noAuthDialogShow: false, - activity: '', - allNum: 0, - signUpNum:0, - goingNum: 0, - complatedNum: 0, - curId: '', - registerId: '' - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function () { - that = this; - remoteMethods.getList(res => { - that.setData({ - list: res, - level: sessionUtil.getUserInfoByKey('eventLevel') || 1, - user: sessionUtil.getUserInfoByKey('userId') - }) - - }) - remoteMethods.getCount(res => { - that.setData({ - allNum: res.all_activities_count, - signUpNum: res.registering_activities_count, - goingNum: res.going_activities_count, - complatedNum: res.completed_activities_count - }) - }) - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - search: function (e) { - this.setData({ - curKeyword: e.detail.value - }) - this.onLoad(); - }, - filterType: function () { - this.setData({ - popShow: true - }) - }, - popCancel: function () { - this.setData({ - popShow: false, - filterType: this.data.curFilterType, - filterTypeName: this.data.curfilterTypeName - }) - }, - pickerChange: function (e) { - this.setData({ - filterType: e.detail.value.type, - filterTypeName: e.detail.value.name - }) - }, - popConfirm: function () { - this.setData({ - popShow: false, - curFilterType: this.data.filterType, - curfilterTypeName: this.data.filterTypeName - }) - this.onLoad(); - }, - toUpdateSchedule(e) { - wx.navigateTo({ - url: `/package-events/events/event-detail?id=${e.currentTarget.dataset.id}&type=5` - }) - }, - onActionClose() { - this.setData({ - actionShow: false - }) - - }, - - onActionSelect(e) { - if (this.data.level == 3) { - if (e.detail.operaType == 1) { - if (this.data.collectionId) { - remoteMethods.unCollect(() => { - this.onLoad(); - }) - } else { - remoteMethods.collect(() => { - this.onLoad(); - }) - } - } else { - this.setData({ - showDialogDel: true - }) - } - } else { - if (e.detail.operaType == 1) { - if (this.data.collectionId) { - remoteMethods.unCollect(() => { - this.onLoad(); - }) - } else { - remoteMethods.collect(() => { - this.onLoad(); - }) - } - } else if(e.detail.operaType == 3) { - return; - } else { - this.setData({ - underDialogShow: true - }) - } - } - }, - onMore(e) { - this.setData({ - actionShow: true, - curId: e.currentTarget.dataset.item.id, - userId: e.currentTarget.dataset.item.user, - collectionId: e.currentTarget.dataset.item.collection_id || '', - registerId: e.currentTarget.dataset.item.register_id || '' - }) - const strTemp = this.data.collectionId ? '取消收藏' : '收藏活动'; - if (this.data.level == 3) { - this.setData({ - actions: [{ - name: strTemp, - operaType: 1 - }, - { - name: '下架活动', - operaType: 2 - } - ] - }) - } else { - if (this.data.user == this.data.userId) { - this.setData({ - actions: [{ - name: strTemp, - operaType: 1 - }, - { - name: '下架活动', - operaType: 2 - } - ] - }) - } else { - this.setData({ - actions: [{ - name: strTemp, - operaType: 1 - }] - }) - } - - if (this.data.registerId) { - let tempArr = this.data.actions; - tempArr.unshift({ - name: '查看门票', - operaType: 3 - }) - this.setData({ - actions: tempArr - }) - } - - } - - }, - del() { - this.setData({ - showDialogDel: false - }) - remoteMethods.delEvent(() => { - this.onLoad(); - }) - }, - delCancel() { - this.setData({ - showDialogDel: false - }) - }, - copyWechat() { - wx.setClipboardData({ - data: 'openeuler123', - success: () => { - this.setData({ - noAuthDialogShow: false, - underDialogShow: false - }) - } - }) - - }, - switchTab(e) { - this.setData({ - activity: e.currentTarget.dataset.type || '' - }) - this.onLoad(); - }, - onPullDownRefresh: function () { - wx.stopPullDownRefresh(); - this.onLoad(); - } -}) \ No newline at end of file +// package-events/events/test.js +const appAjax = require('./../../utils/app-ajax'); +const sessionUtil = require('../../utils/app-session.js'); +let that = null; + +let remoteMethods = { + getList: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service: 'ALL_EVENTS_LIST', + data: { + activity: that.data.activity, + activity_type: that.data.curFilterType, + search: that.data.curKeyword, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + getCount: function (_callback) { + appAjax.postJson({ + type: 'GET', + service: 'GET_EVENTS_COUNT', + data: { + activity_type: that.data.curFilterType, + search: that.data.curKeyword, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + delDraft: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'DELETE', + service: 'DRAFT_DETAIL', + otherParams: { + id: that.data.curId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + delEvent: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'PUT', + service: 'DEL_EVENT', + otherParams: { + id: that.data.curId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + collect: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'POST', + service: 'EVENT_COLLECT', + data: { + activity: that.data.curId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + unCollect: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'DELETE', + service: 'EVENT_UNCOLLECT', + otherParams: { + id: that.data.collectionId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; +Page({ + /** + * 页面的初始数据 + */ + data: { + level: 1, + user: '', + curKeyword: '', + popShow: false, + curFilterType: '', + curfilterTypeName: '全部类型', + filterType: '', + filterTypeName: '全部类型', + columns: [ + { + type: '', + name: '全部类型', + }, + { + type: 1, + name: '线下', + }, + { + type: 2, + name: '线上', + }, + ], + list: [], + actionShow: false, + actions: [], + showDialogDel: false, + underDialogShow: false, + noAuthDialogShow: false, + activity: '', + allNum: 0, + signUpNum: 0, + goingNum: 0, + complatedNum: 0, + curId: '', + registerId: '', + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function () { + that = this; + remoteMethods.getList((res) => { + that.setData({ + list: res, + level: sessionUtil.getUserInfoByKey('eventLevel') || 1, + user: sessionUtil.getUserInfoByKey('userId'), + }); + }); + remoteMethods.getCount((res) => { + that.setData({ + allNum: res.all_activities_count, + signUpNum: res.registering_activities_count, + goingNum: res.going_activities_count, + complatedNum: res.completed_activities_count, + }); + }); + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () {}, + search: function (e) { + this.setData({ + curKeyword: e.detail.value, + }); + this.onLoad(); + }, + filterType: function () { + this.setData({ + popShow: true, + }); + }, + popCancel: function () { + this.setData({ + popShow: false, + filterType: this.data.curFilterType, + filterTypeName: this.data.curfilterTypeName, + }); + }, + pickerChange: function (e) { + this.setData({ + filterType: e.detail.value.type, + filterTypeName: e.detail.value.name, + }); + }, + popConfirm: function () { + this.setData({ + popShow: false, + curFilterType: this.data.filterType, + curfilterTypeName: this.data.filterTypeName, + }); + this.onLoad(); + }, + toUpdateSchedule(e) { + wx.navigateTo({ + url: `/package-events/events/event-detail?id=${e.currentTarget.dataset.id}&type=5`, + }); + }, + onActionClose() { + this.setData({ + actionShow: false, + }); + }, + + onActionSelect(e) { + if (this.data.level == 3) { + if (e.detail.operaType == 1) { + if (this.data.collectionId) { + remoteMethods.unCollect(() => { + this.onLoad(); + }); + } else { + remoteMethods.collect(() => { + this.onLoad(); + }); + } + } else { + this.setData({ + showDialogDel: true, + }); + } + } else { + if (e.detail.operaType == 1) { + if (this.data.collectionId) { + remoteMethods.unCollect(() => { + this.onLoad(); + }); + } else { + remoteMethods.collect(() => { + this.onLoad(); + }); + } + } else if (e.detail.operaType == 3) { + return; + } else { + this.setData({ + underDialogShow: true, + }); + } + } + }, + onMore(e) { + this.setData({ + actionShow: true, + curId: e.currentTarget.dataset.item.id, + userId: e.currentTarget.dataset.item.user, + collectionId: e.currentTarget.dataset.item.collection_id || '', + registerId: e.currentTarget.dataset.item.register_id || '', + }); + const strTemp = this.data.collectionId ? '取消收藏' : '收藏活动'; + if (this.data.level == 3) { + this.setData({ + actions: [ + { + name: strTemp, + operaType: 1, + }, + { + name: '下架活动', + operaType: 2, + }, + ], + }); + } else { + if (this.data.user == this.data.userId) { + this.setData({ + actions: [ + { + name: strTemp, + operaType: 1, + }, + { + name: '下架活动', + operaType: 2, + }, + ], + }); + } else { + this.setData({ + actions: [ + { + name: strTemp, + operaType: 1, + }, + ], + }); + } + + if (this.data.registerId) { + let tempArr = this.data.actions; + tempArr.unshift({ + name: '查看门票', + operaType: 3, + }); + this.setData({ + actions: tempArr, + }); + } + } + }, + del() { + this.setData({ + showDialogDel: false, + }); + remoteMethods.delEvent(() => { + this.onLoad(); + }); + }, + delCancel() { + this.setData({ + showDialogDel: false, + }); + }, + copyWechat() { + wx.setClipboardData({ + data: 'openeuler123', + success: () => { + this.setData({ + noAuthDialogShow: false, + underDialogShow: false, + }); + }, + }); + }, + switchTab(e) { + this.setData({ + activity: e.currentTarget.dataset.type || '', + }); + this.onLoad(); + }, + onPullDownRefresh: function () { + wx.stopPullDownRefresh(); + this.onLoad(); + }, +}); diff --git a/src/openeuler/package-events/events/poster.js b/src/openeuler/package-events/events/poster.js index 29b13c5..a8ee6a2 100644 --- a/src/openeuler/package-events/events/poster.js +++ b/src/openeuler/package-events/events/poster.js @@ -95,13 +95,13 @@ Page({ duration: 2000, }); }, - fail: function (err) { + fail: function () { wx.showModal({ title: '保存失败~', content: '请尝试点击右上角 “...” => “设置” 同意添加到相册后再保存~', }); }, - complete(res) { + complete() { wx.hideLoading(); }, }); @@ -123,7 +123,7 @@ Page({ req(filePath); }, fail: (err) => { - req(err); + rej(err); }, }); }); diff --git a/src/openeuler/package-events/events/sign.js b/src/openeuler/package-events/events/sign.js index 59fd5af..85ac7bb 100644 --- a/src/openeuler/package-events/events/sign.js +++ b/src/openeuler/package-events/events/sign.js @@ -3,44 +3,43 @@ const appAjax = require('./../../utils/app-ajax'); let that = null; let remoteMethods = { - getDraftDetail: function (_callback) { - let service = 'EVENT_DETAIL'; - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service, - otherParams: { - id: that.data.id - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - } -} + getDraftDetail: function (_callback) { + let service = 'EVENT_DETAIL'; + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service, + otherParams: { + id: that.data.id, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; Page({ + /** + * 页面的初始数据 + */ + data: { + id: '', + info: {}, + }, - /** - * 页面的初始数据 - */ - data: { - id: '', - info: {} - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - that = this; - this.setData({ - id: options.id || '' - }) - remoteMethods.getDraftDetail(res => { - this.setData({ - info: res - }) - }) - } -}) \ No newline at end of file + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + that = this; + this.setData({ + id: options.id || '', + }); + remoteMethods.getDraftDetail((res) => { + this.setData({ + info: res, + }); + }); + }, +}); diff --git a/src/openeuler/package-events/events/wxml-to-canvas.js b/src/openeuler/package-events/events/wxml-to-canvas.js index a166b08..8e3d451 100644 --- a/src/openeuler/package-events/events/wxml-to-canvas.js +++ b/src/openeuler/package-events/events/wxml-to-canvas.js @@ -1,89 +1,91 @@ -const wxml = (data) => { - return ` - - - - ${data.title} - - 时间:${data.date} - ${data.address?('地点:'+data.address):('直播地址:'+data.liveAddress)} - - 长按识别二维码,进入活动! - - - ` -} - -const style = () => { - return { - container: { - width: 325, - height: 656, - flexDirection: 'column', - alignItems: 'center' - }, - absolute: { - width: 325, - height: 656, - flexDirection: 'column', - alignItems: 'center' - }, - title: { - marginTop: 88, - color: '#fff', - width: 325, - height: 41, - fontSize: 17, - textAlign: 'center' - }, - logo: { - marginTop: 71, - width: 85, - height: 70, - marginBottom: 15 - }, - date: { - marginTop: 15, - color: '#002fa7', - width: 325, - fontSize: 12, - height: 19, - textAlign: 'center' - }, - address: { - marginTop: 10, - color: '#002fa7', - width: 325, - fontSize: 12, - height: 19, - textAlign: 'center' - }, - qrcode: { - backgroundColor: '#ffffff', - marginTop: 40, - height: 185, - width: 185, - borderRadius: 100 - }, - qrcodeText: { - color: '#ffffff', - fontSize: 12, - marginTop: 15, - height: 17, - width: 325, - textAlign: 'center' - }, - bgImg: { - position: 'absolute', - width: 325, - height: 656, - top: 0, - left: 0 - } - } -} - -module.exports = { - wxml, - style -} \ No newline at end of file +const wxml = (data) => { + return ` + + + + ${data.title} + + 时间:${data.date} + ${data.address ? '地点:' + data.address : '直播地址:' + data.liveAddress} + + 长按识别二维码,进入活动! + + + `; +}; + +const style = () => { + return { + container: { + width: 325, + height: 656, + flexDirection: 'column', + alignItems: 'center', + }, + absolute: { + width: 325, + height: 656, + flexDirection: 'column', + alignItems: 'center', + }, + title: { + marginTop: 88, + color: '#fff', + width: 325, + height: 41, + fontSize: 17, + textAlign: 'center', + }, + logo: { + marginTop: 71, + width: 85, + height: 70, + marginBottom: 15, + }, + date: { + marginTop: 15, + color: '#002fa7', + width: 325, + fontSize: 12, + height: 19, + textAlign: 'center', + }, + address: { + marginTop: 10, + color: '#002fa7', + width: 325, + fontSize: 12, + height: 19, + textAlign: 'center', + }, + qrcode: { + backgroundColor: '#ffffff', + marginTop: 40, + height: 185, + width: 185, + borderRadius: 100, + }, + qrcodeText: { + color: '#ffffff', + fontSize: 12, + marginTop: 15, + height: 17, + width: 325, + textAlign: 'center', + }, + bgImg: { + position: 'absolute', + width: 325, + height: 656, + top: 0, + left: 0, + }, + }; +}; + +module.exports = { + wxml, + style, +}; diff --git a/src/openeuler/package-events/manage/add-member.js b/src/openeuler/package-events/manage/add-member.js index 2971e42..3ef8920 100644 --- a/src/openeuler/package-events/manage/add-member.js +++ b/src/openeuler/package-events/manage/add-member.js @@ -1,105 +1,100 @@ -// pages/sig/add-member.js -const appAjax = require('./../../utils/app-ajax'); -let remoteMethods = { - getExcludeMemberList: function (postData, _callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service: "ENTERPRISE_EXCLUDE_MEMBER_LIST", - data: { - search: postData.nickname || '' - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - addMemberList: function (postData, _callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'POST', - service: "ENTERPRISE_ADD_MEMBER_LIST", - data: postData, - success: function (ret) { - _callback && _callback(ret); - } - }); - } -} -Page({ - - /** - * 页面的初始数据 - */ - data: { - list: [], - result: [], - keyword: '' - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - let that = this; - remoteMethods.getExcludeMemberList({}, function (data) { - that.setData({ - list: data - }) - }) - }, - onChange: function (e) { - this.setData({ - result: e.detail - }) - }, - comfirm: function () { - let that = this; - if (!this.data.result.length) { - wx.showToast({ - title: '请选择人员', - icon: "none", - duration: 2000 - }); - return; - } - let postData = { - ids: this.data.result.join('-') - } - remoteMethods.addMemberList(postData, function (data) { - if (data.code === 201) { - wx.showToast({ - title: '操作成功', - icon: "success", - duration: 2000 - }); - wx.navigateBack(); - } else { - wx.showToast({ - title: '操作失败', - icon: "none", - duration: 2000 - }); - } - }) - }, - searchInput: function (e) { - let that = this; - this.setData({ - keyword: e.detail.value - }) - remoteMethods.getExcludeMemberList({ - nickname: this.data.keyword - }, function (data) { - that.setData({ - list: data - }) - }) - } -}) \ No newline at end of file +// pages/sig/add-member.js +const appAjax = require('./../../utils/app-ajax'); +let remoteMethods = { + getExcludeMemberList: function (postData, _callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service: 'ENTERPRISE_EXCLUDE_MEMBER_LIST', + data: { + search: postData.nickname || '', + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + addMemberList: function (postData, _callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'POST', + service: 'ENTERPRISE_ADD_MEMBER_LIST', + data: postData, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; +Page({ + /** + * 页面的初始数据 + */ + data: { + list: [], + result: [], + keyword: '', + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + let that = this; + remoteMethods.getExcludeMemberList({}, function (data) { + that.setData({ + list: data, + }); + }); + }, + onChange: function (e) { + this.setData({ + result: e.detail, + }); + }, + comfirm: function () { + if (!this.data.result.length) { + wx.showToast({ + title: '请选择人员', + icon: 'none', + duration: 2000, + }); + return; + } + let postData = { + ids: this.data.result.join('-'), + }; + remoteMethods.addMemberList(postData, function (data) { + if (data.code === 201) { + wx.showToast({ + title: '操作成功', + icon: 'success', + duration: 2000, + }); + wx.navigateBack(); + } else { + wx.showToast({ + title: '操作失败', + icon: 'none', + duration: 2000, + }); + } + }); + }, + searchInput: function (e) { + let that = this; + this.setData({ + keyword: e.detail.value, + }); + remoteMethods.getExcludeMemberList( + { + nickname: this.data.keyword, + }, + function (data) { + that.setData({ + list: data, + }); + } + ); + }, +}); diff --git a/src/openeuler/package-events/manage/del-member.js b/src/openeuler/package-events/manage/del-member.js index 43d85a4..fcd2161 100644 --- a/src/openeuler/package-events/manage/del-member.js +++ b/src/openeuler/package-events/manage/del-member.js @@ -1,88 +1,80 @@ -// pages/sig/del-member.js -const appAjax = require('./../../utils/app-ajax'); -let remoteMethods = { - getCludeMemberList: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service: "ENTERPRISE_MEMBER_LIST", - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - delMemberList: function (postData, _callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'POST', - service: "ENTERPRISE_DEL_MEMBER_LIST", - data: postData, - success: function (ret) { - _callback && _callback(ret); - } - }); - } -} -Page({ - - /** - * 页面的初始数据 - */ - data: { - list: [], - result: [] - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - let that = this; - remoteMethods.getCludeMemberList(function (data) { - that.setData({ - list: data - }) - }) - }, - onChange: function (e) { - this.setData({ - result: e.detail - }) - }, - del: function () { - let that = this; - if (!this.data.result.length) { - wx.showToast({ - title: '请选择人员', - icon: "none", - duration: 2000 - }); - return; - } - let postData = { - ids: this.data.result.join('-') - } - remoteMethods.delMemberList(postData, function (data) { - if (data.code === 204) { - wx.showToast({ - title: '操作成功', - icon: "success", - duration: 2000 - }); - wx.navigateBack(); - } else { - wx.showToast({ - title: '操作失败', - icon: "none", - duration: 2000 - }); - } - }) - } -}) \ No newline at end of file +// pages/sig/del-member.js +const appAjax = require('./../../utils/app-ajax'); +let remoteMethods = { + getCludeMemberList: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service: 'ENTERPRISE_MEMBER_LIST', + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + delMemberList: function (postData, _callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'POST', + service: 'ENTERPRISE_DEL_MEMBER_LIST', + data: postData, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; +Page({ + /** + * 页面的初始数据 + */ + data: { + list: [], + result: [], + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + let that = this; + remoteMethods.getCludeMemberList(function (data) { + that.setData({ + list: data, + }); + }); + }, + onChange: function (e) { + this.setData({ + result: e.detail, + }); + }, + del: function () { + if (!this.data.result.length) { + wx.showToast({ + title: '请选择人员', + icon: 'none', + duration: 2000, + }); + return; + } + let postData = { + ids: this.data.result.join('-'), + }; + remoteMethods.delMemberList(postData, function (data) { + if (data.code === 204) { + wx.showToast({ + title: '操作成功', + icon: 'success', + duration: 2000, + }); + wx.navigateBack(); + } else { + wx.showToast({ + title: '操作失败', + icon: 'none', + duration: 2000, + }); + } + }); + }, +}); diff --git a/src/openeuler/package-events/manage/enterprise-list.js b/src/openeuler/package-events/manage/enterprise-list.js index 6239708..de7baec 100644 --- a/src/openeuler/package-events/manage/enterprise-list.js +++ b/src/openeuler/package-events/manage/enterprise-list.js @@ -1,54 +1,57 @@ -// package-events/manage/enterprise-list.js -const appAjax = require('./../../utils/app-ajax'); -let remoteMethods = { - getMemberList: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service: "ENTERPRISE_MEMBER_LIST", - success: function (ret) { - _callback && _callback(ret); - } - }); - } -} -Page({ - - /** - * 页面的初始数据 - */ - data: { - memberList: [] - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - let that = this; - remoteMethods.getMemberList(function (list) { - that.setData({ - memberList: list - }) - }); - }, - toDetail: function (e) { - - }, - addMember: function () { - wx.navigateTo({ - url: '/package-events/manage/add-member' - }) - }, - delMember: function () { - wx.navigateTo({ - url: '/package-events/manage/del-member' - }) - } -}) \ No newline at end of file +// package-events/manage/enterprise-list.js +const appAjax = require('./../../utils/app-ajax'); +let remoteMethods = { + getMemberList: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service: 'ENTERPRISE_MEMBER_LIST', + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; +Page({ + /** + * 页面的初始数据 + */ + data: { + memberList: [], + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + let that = this; + remoteMethods.getMemberList(function (list) { + that.setData({ + memberList: list, + }); + }); + }, + toDetail: function (e) { + wx.navigateTo({ + url: + '/package-events/manage/member-detail?id=' + + e.currentTarget.dataset.id + + '&avatar=' + + e.currentTarget.dataset.avatar + + '&name=' + + e.currentTarget.dataset.name + + '&nickname=' + + e.currentTarget.dataset.nickname, + }); + }, + addMember: function () { + wx.navigateTo({ + url: '/package-events/manage/add-member', + }); + }, + delMember: function () { + wx.navigateTo({ + url: '/package-events/manage/del-member', + }); + }, +}); diff --git a/src/openeuler/package-events/publish/publish.js b/src/openeuler/package-events/publish/publish.js index 0ca8353..bcfc314 100644 --- a/src/openeuler/package-events/publish/publish.js +++ b/src/openeuler/package-events/publish/publish.js @@ -1,617 +1,617 @@ // package-events/publish/publish.js const appAjax = require('./../../utils/app-ajax'); -const utils = require("./../../utils/utils.js"); +const utils = require('./../../utils/utils.js'); utils.formateDate(); let that = null; let remoteMethods = { - addEvents: function (postData, _callback) { - let type = 'POST'; - let service = "PUBLISH_EVENT"; - if (that.data.detailType == 4) { - type = 'PUT'; - service = 'EDIT_DETAIL_PUBLISH' - } - appAjax.postJson({ - autoShowWait: true, - type, - service, - data: postData, - otherParams: { - id: that.data.id || '' - }, - success: function (ret) { - if (ret.code == 400) { - localMethods.toast(ret.msg); - return; - } - _callback && _callback(ret); - } - }); - }, - saveDraft: function (postData, _callback) { - let type = 'POST'; - let service = "SAVE_DRAFT"; - if (that.data.detailType == 4) { - type = 'PUT'; - service = 'EDIT_DETAIL' - } else if (that.data.detailType == 5) { - type = 'PUT'; - service = 'EDIT_SCHEDULE' + addEvents: function (postData, _callback) { + let type = 'POST'; + let service = 'PUBLISH_EVENT'; + if (that.data.detailType == 4) { + type = 'PUT'; + service = 'EDIT_DETAIL_PUBLISH'; + } + appAjax.postJson({ + autoShowWait: true, + type, + service, + data: postData, + otherParams: { + id: that.data.id || '', + }, + success: function (ret) { + if (ret.code == 400) { + localMethods.toast(ret.msg); + return; } - appAjax.postJson({ - autoShowWait: true, - type, - service, - data: postData, - otherParams: { - id: that.data.id || '' - }, - success: function (ret) { - if (ret.code == 400) { - localMethods.toast(ret.msg); - return; - } - _callback && _callback(ret); - } - }); - }, - getDraftDetail: function (_callback) { - let service = 'DRAFT_DETAIL'; - if (that.data.detailType == 5) { - service = 'EVENT_DETAIL' + _callback && _callback(ret); + }, + }); + }, + saveDraft: function (postData, _callback) { + let type = 'POST'; + let service = 'SAVE_DRAFT'; + if (that.data.detailType == 4) { + type = 'PUT'; + service = 'EDIT_DETAIL'; + } else if (that.data.detailType == 5) { + type = 'PUT'; + service = 'EDIT_SCHEDULE'; + } + appAjax.postJson({ + autoShowWait: true, + type, + service, + data: postData, + otherParams: { + id: that.data.id || '', + }, + success: function (ret) { + if (ret.code == 400) { + localMethods.toast(ret.msg); + return; } - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service, - otherParams: { - id: that.data.id - }, - success: function (ret) { - _callback && _callback(ret); - } - }); + _callback && _callback(ret); + }, + }); + }, + getDraftDetail: function (_callback) { + let service = 'DRAFT_DETAIL'; + if (that.data.detailType == 5) { + service = 'EVENT_DETAIL'; } -} + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service, + otherParams: { + id: that.data.id, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; let localMethods = { - validation: function (data) { - if (data.activity_type === 1) { - if (!data.title) { - this.toast('请输入活动标题'); - return; - } - if (!data.date) { - this.toast('请选择活动日期'); - return; - } - if (!data.register_url) { - this.toast('请输入报名链接'); - return; - } - if (!data.address) { - this.toast('请输入活动城市'); - return; - } - if (!data.detail_address) { - this.toast('请输入具体地址'); - return; - } - let flag = true; - data.schedules.forEach(item => { - if (!item.start) { - flag = false; - } - if (!item.end) { - flag = false; - } - if (!item.topic) { - flag = false; - } - item.speakerList.forEach(item => { - if (!item.name) { - flag = false; - } - }) - }); - if (!flag) { - this.toast('请补充日程必填信息'); - return; - } - } else { - if (!data.title) { - this.toast('请输入活动标题'); - return; - } - if (!data.date) { - this.toast('请选择活动日期'); - return; - } - if (!data.register_url) { - this.toast('请输入报名链接'); - return; - } - if (!data.start && !data.end) { - this.toast('请选择活动时间'); - return; - } - let flag = true; - data.schedules.forEach(item => { - if (!item.start) { - flag = false; - } - if (!item.end) { - flag = false; - } - if (!item.topic) { - flag = false; - } - item.speakerList.forEach(item => { - if (!item.name) { - flag = false; - } - }) - }); - if (!flag) { - this.toast('请补充填写日程必填信息'); - return; - } + validation: function (data) { + if (data.activity_type === 1) { + if (!data.title) { + this.toast('请输入活动标题'); + return; + } + if (!data.date) { + this.toast('请选择活动日期'); + return; + } + if (!data.register_url) { + this.toast('请输入报名链接'); + return; + } + if (!data.address) { + this.toast('请输入活动城市'); + return; + } + if (!data.detail_address) { + this.toast('请输入具体地址'); + return; + } + let flag = true; + data.schedules.forEach((item) => { + if (!item.start) { + flag = false; } - - return true; - }, - toast: function (msg) { - wx.showToast({ - title: msg, - icon: "none", - duration: 2000 + if (!item.end) { + flag = false; + } + if (!item.topic) { + flag = false; + } + item.speakerList.forEach((item) => { + if (!item.name) { + flag = false; + } }); + }); + if (!flag) { + this.toast('请补充日程必填信息'); + return; + } + } else { + if (!data.title) { + this.toast('请输入活动标题'); + return; + } + if (!data.date) { + this.toast('请选择活动日期'); + return; + } + if (!data.register_url) { + this.toast('请输入报名链接'); + return; + } + if (!data.start && !data.end) { + this.toast('请选择活动时间'); + return; + } + let flag = true; + data.schedules.forEach((item) => { + if (!item.start) { + flag = false; + } + if (!item.end) { + flag = false; + } + if (!item.topic) { + flag = false; + } + item.speakerList.forEach((item) => { + if (!item.name) { + flag = false; + } + }); + }); + if (!flag) { + this.toast('请补充填写日程必填信息'); + return; + } } -} -Page({ - /** - * 页面的初始数据 - */ - data: { - id: '', - detailType: 0, - title: '', - date: '', - type: 1, - address: '', - addressName: '', - registerUrl:'', - desc: '', - schedule: [{ - start: '', - end: '', - topic: '', - speakerList: [{ - name: '', - title: '', - }] - }], - datePopShow: false, - timePopShow: false, - curDate: new Date().getTime(), - currentDate: new Date().getTime(), - minDate: new Date().getTime(), - startTimeIndex: 0, - endTimeIndex: 0, + return true; + }, + toast: function (msg) { + wx.showToast({ + title: msg, + icon: 'none', + duration: 2000, + }); + }, +}; +Page({ + /** + * 页面的初始数据 + */ + data: { + id: '', + detailType: 0, + title: '', + date: '', + type: 1, + address: '', + addressName: '', + registerUrl: '', + desc: '', + schedule: [ + { start: '', end: '', - currentTime: '08:00', - minTime: 8, - maxTime: 22, - minEndTime: 8, - maxEndTime: 22, - filter(type, options) { - if (type === 'minute') { - return options.filter((option) => option % 5 === 0); - } - - return options; - }, - endTimePopShow: false, - currentEndTime: '08:00', - topicSelIndex: 1, - longitude: '', - latitude: '', - onlineStartTime: '', - onlineEndTime: '', - isOnline: 0 - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - that = this; - this.setData({ - id: options.id, - detailType: options.type || 0 - }) - if ((this.data.id && (this.data.detailType == 5)) || (this.data.id && (this.data.detailType == 4))) { - remoteMethods.getDraftDetail(res => { - this.setData({ - title: res.title, - date: res.date, - type: res.activity_type, - registerUrl: res.register_url || '', - longitude: res.longitude || '', - latitude: res.latitude || '', - address: res.address || '', - addressName: res.detail_address || '', - desc: res.synopsis || '', - topicSelIndex: res.poster, - schedule: JSON.parse(res.schedules), - onlineStartTime: res.start || '', - onlineEndTime: res.end || '' - }) - }) - } - }, - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { + topic: '', + speakerList: [ + { + name: '', + title: '', + }, + ], + }, + ], + datePopShow: false, + timePopShow: false, + curDate: new Date().getTime(), + currentDate: new Date().getTime(), + minDate: new Date().getTime(), + startTimeIndex: 0, + endTimeIndex: 0, + start: '', + end: '', + currentTime: '08:00', + minTime: 8, + maxTime: 22, + minEndTime: 8, + maxEndTime: 22, + filter(type, options) { + if (type === 'minute') { + return options.filter((option) => option % 5 === 0); + } - }, - titleInput(e) { - this.setData({ - title: e.detail.value - }) - }, - selDate: function () { - this.setData({ - datePopShow: true - }) - }, - dateCancel: function () { - this.setData({ - datePopShow: false - }) - }, - dateOnInput: function (e) { - this.setData({ - currentDate: e.detail - }) - }, - dateConfirm: function () { - this.setData({ - date: (new Date(this.data.currentDate)).Format("yyyy-MM-dd"), - datePopShow: false - }) - }, - radioOnChange(e) { - let url; - if (e.detail === 2) { - url = 'https://space.bilibili.com/527064077' - } else { - url = ''; - } - this.setData({ - type: e.detail, - registerUrl:url - }) - }, - selAddress() { - wx.showModal({ - title: '提示', - content: '即将唤起腾讯地图,是否同意?', - success(res) { - if (res.confirm) { - wx.chooseLocation({ - success: function (res) { - that.setData({ - address: res.address, - addressName: res.name, - longitude: res.longitude, - latitude: res.latitude, - }); - }, - fail: function (res) { - console.error(res); - }, - }); - } else if (res.cancel) { - return false - } - } - }) + return options; + }, + endTimePopShow: false, + currentEndTime: '08:00', + topicSelIndex: 1, + longitude: '', + latitude: '', + onlineStartTime: '', + onlineEndTime: '', + isOnline: 0, + }, - }, - addressNameInput(e) { - this.setData({ - addressName: e.detail.value - }) - }, - registerUrlInput(e) { + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + that = this; + this.setData({ + id: options.id, + detailType: options.type || 0, + }); + if ((this.data.id && this.data.detailType == 5) || (this.data.id && this.data.detailType == 4)) { + remoteMethods.getDraftDetail((res) => { this.setData({ - registerUrl: e.detail.value, + title: res.title, + date: res.date, + type: res.activity_type, + registerUrl: res.register_url || '', + longitude: res.longitude || '', + latitude: res.latitude || '', + address: res.address || '', + addressName: res.detail_address || '', + desc: res.synopsis || '', + topicSelIndex: res.poster, + schedule: JSON.parse(res.schedules), + onlineStartTime: res.start || '', + onlineEndTime: res.end || '', }); - }, - descInput(e) { - this.setData({ - desc: e.detail.value - }) - }, - scheduleTitleInput(e) { - const key = `schedule[${e.currentTarget.dataset.index}].topic`; - this.setData({ - [key]: e.detail.value - }) - }, - nameInput(e) { - const key = `schedule[${e.currentTarget.dataset.outindex}].speakerList[${e.currentTarget.dataset.innerindex}].name`; - this.setData({ - [key]: e.detail.value - }) - }, - speakerTitleInput(e) { - const key = `schedule[${e.currentTarget.dataset.outindex}].speakerList[${e.currentTarget.dataset.innerindex}].title`; - this.setData({ - [key]: e.detail.value - }) - }, - addSchedule() { - let arrTemp = this.data.schedule; - arrTemp.push({ - start: '', - end: '', - topic: '', - speakerList: [] - }) - this.setData({ - schedule: arrTemp - }) - }, - addSpeaker(e) { - const length = this.data.schedule[e.currentTarget.dataset.index].speakerList.length; - const key = `schedule[${e.currentTarget.dataset.index}].speakerList[${length}]`; - this.setData({ - [key]: { - name: '', - title: '', - } - }) - }, - delSchedule(e) { - let arrTemp = this.data.schedule; - arrTemp.splice(e.currentTarget.dataset.index, 1); - this.setData({ - schedule: arrTemp - }) - }, - delSpeaker(e) { - let arrTemp = this.data.schedule[e.currentTarget.dataset.outindex].speakerList; - let key = `schedule[${e.currentTarget.dataset.outindex}].speakerList`; - arrTemp.splice(e.currentTarget.dataset.innerindex, 1); - this.setData({ - [key]: arrTemp - }) - }, - selTime: function (e) { - this.setData({ - timePopShow: true, - startTimeIndex: e.currentTarget.dataset.index - }) - }, - selOnlineStartTime() { - this.setData({ - timePopShow: true, - isOnline: 1 - }) - }, - timeCancel: function () { - this.setData({ - timePopShow: false, - isOnline: 0 - }) - }, - timeOnInput: function (e) { - this.setData({ - currentTime: e.detail - }) - }, - timeConfirm: function (e) { - if (this.data.isOnline) { - this.setData({ - onlineStartTime: this.data.currentTime, - isOnline: 0, - timePopShow: false, - }) - return; - } - const key = `schedule[${this.data.startTimeIndex}].start`; - this.setData({ - [key]: this.data.currentTime, - timePopShow: false, - isOnline: 0 - }) - }, - timeCancel: function () { - this.setData({ - timePopShow: false - }) - }, - endTimeCancel: function () { - this.setData({ - endTimePopShow: false - }) - }, - selEndTime: function (e) { - this.setData({ - endTimePopShow: true, - endTimeIndex: e.currentTarget.dataset.index - }) - }, - selOnlineEndTime() { - this.setData({ - endTimePopShow: true, - isOnline: 1 - }) - }, - endTimeOnInput: function (e) { - this.setData({ - currentEndTime: e.detail - }) - }, - endTimeConfirm: function () { - if (this.data.isOnline) { - this.setData({ - isOnline: 0, - onlineEndTime: this.data.currentEndTime, - endTimePopShow: false - }) - return; - } - const key = `schedule[${this.data.endTimeIndex}].end`; - this.setData({ - [key]: this.data.currentEndTime, - endTimePopShow: false, - isOnline: 0 - }) - }, - endTimeCancel: function () { - this.setData({ - endTimePopShow: false, - isOnline: 0 - }) - }, - selTop(e) { - this.setData({ - topicSelIndex: e.currentTarget.dataset.index - }) - }, - publish() { - let postData = null; - if (this.data.type === 1) { - postData = { - "title": this.data.title, - "date": this.data.date, - "activity_type": 1, - "register_url": this.data.registerUrl || '', - "synopsis": this.data.desc, - "address": this.data.address, - "detail_address": this.data.addressName, - "longitude": this.data.longitude, - "latitude": this.data.latitude, - "poster": this.data.topicSelIndex, - "schedules": this.data.schedule - } - } else { - postData = { - "title": this.data.title, - "date": this.data.date, - "activity_type": 2, - "register_url": this.data.registerUrl || '', - "synopsis": this.data.desc, - "longitude": this.data.longitude, - "latitude": this.data.latitude, - "poster": this.data.topicSelIndex, - "schedules": this.data.schedule, - "start": this.data.onlineStartTime, - "end": this.data.onlineEndTime - } - } - if (!localMethods.validation(postData)) { - return; - } - remoteMethods.addEvents(postData, (res) => { - wx.redirectTo({ - url: '/package-events/publish/success?type=2' - }) - }) - }, - saveDraft() { - let postData = null; - if (this.data.type === 1) { - postData = { - "title": this.data.title, - "date": this.data.date, - "activity_type": 1, - "register_url": this.data.registerUrl || '', - "synopsis": this.data.desc, - "address": this.data.address, - "detail_address": this.data.addressName, - "longitude": this.data.longitude, - "latitude": this.data.latitude, - "poster": this.data.topicSelIndex, - "schedules": this.data.schedule - } - } else { - postData = { - "title": this.data.title, - "date": this.data.date, - "activity_type": 2, - "register_url": this.data.registerUrl || '', - "synopsis": this.data.desc, - "longitude": this.data.longitude, - "latitude": this.data.latitude, - "poster": this.data.topicSelIndex, - "schedules": this.data.schedule, - "start": this.data.onlineStartTime, - "end": this.data.onlineEndTime - } - } - if (!localMethods.validation(postData)) { - return; - } - remoteMethods.saveDraft(postData, () => { - wx.redirectTo({ - url: '/package-events/publish/success?type=1' - }) - }) - }, - cancelEditSchedule() { - wx.navigateBack(); - }, - editScheduleConfirm() { - let postData = null; - if (this.data.type === 1) { - postData = { - "title": this.data.title, - "date": this.data.date, - "activity_type": 1, - "register_url": this.data.registerUrl || '', - "synopsis": this.data.desc, - "address": this.data.address, - "detail_address": this.data.addressName, - "longitude": this.data.longitude, - "latitude": this.data.latitude, - "poster": this.data.topicSelIndex, - "schedules": this.data.schedule - } - } else { - postData = { - "title": this.data.title, - "date": this.data.date, - "activity_type": 2, - "register_url": this.data.registerUrl || '', - "synopsis": this.data.desc, - "longitude": this.data.longitude, - "latitude": this.data.latitude, - "poster": this.data.topicSelIndex, - "schedules": this.data.schedule, - "start": this.data.onlineStartTime, - "end": this.data.onlineEndTime - } - } - if (!localMethods.validation(postData)) { - return; + }); + } + }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () {}, + titleInput(e) { + this.setData({ + title: e.detail.value, + }); + }, + selDate: function () { + this.setData({ + datePopShow: true, + }); + }, + dateCancel: function () { + this.setData({ + datePopShow: false, + }); + }, + dateOnInput: function (e) { + this.setData({ + currentDate: e.detail, + }); + }, + dateConfirm: function () { + this.setData({ + date: new Date(this.data.currentDate).Format('yyyy-MM-dd'), + datePopShow: false, + }); + }, + radioOnChange(e) { + let url; + if (e.detail === 2) { + url = 'https://space.bilibili.com/527064077'; + } else { + url = ''; + } + this.setData({ + type: e.detail, + registerUrl: url, + }); + }, + selAddress() { + wx.showModal({ + title: '提示', + content: '即将唤起腾讯地图,是否同意?', + success(res) { + if (res.confirm) { + wx.chooseLocation({ + success: function (res) { + that.setData({ + address: res.address, + addressName: res.name, + longitude: res.longitude, + latitude: res.latitude, + }); + }, + fail: function (res) { + console.error(res); + }, + }); + } else if (res.cancel) { + return false; } - postData.schedules = JSON.stringify(this.data.schedule); - remoteMethods.saveDraft(postData, () => { - wx.redirectTo({ - url: '/package-events/publish/success?type=3' - }) - }) - }, - toPoster() { - const address = this.data.type == 1 ? this.data.addressName : ''; - wx.navigateTo({ - url: `/package-events/events/poster?title=${this.data.title}&date=${this.data.date}&address=${address}&poster=${this.data.topicSelIndex}` - }) + }, + }); + }, + addressNameInput(e) { + this.setData({ + addressName: e.detail.value, + }); + }, + registerUrlInput(e) { + this.setData({ + registerUrl: e.detail.value, + }); + }, + descInput(e) { + this.setData({ + desc: e.detail.value, + }); + }, + scheduleTitleInput(e) { + const key = `schedule[${e.currentTarget.dataset.index}].topic`; + this.setData({ + [key]: e.detail.value, + }); + }, + nameInput(e) { + const key = `schedule[${e.currentTarget.dataset.outindex}].speakerList[${e.currentTarget.dataset.innerindex}].name`; + this.setData({ + [key]: e.detail.value, + }); + }, + speakerTitleInput(e) { + const key = `schedule[${e.currentTarget.dataset.outindex}].speakerList[${e.currentTarget.dataset.innerindex}].title`; + this.setData({ + [key]: e.detail.value, + }); + }, + addSchedule() { + let arrTemp = this.data.schedule; + arrTemp.push({ + start: '', + end: '', + topic: '', + speakerList: [], + }); + this.setData({ + schedule: arrTemp, + }); + }, + addSpeaker(e) { + const length = this.data.schedule[e.currentTarget.dataset.index].speakerList.length; + const key = `schedule[${e.currentTarget.dataset.index}].speakerList[${length}]`; + this.setData({ + [key]: { + name: '', + title: '', + }, + }); + }, + delSchedule(e) { + let arrTemp = this.data.schedule; + arrTemp.splice(e.currentTarget.dataset.index, 1); + this.setData({ + schedule: arrTemp, + }); + }, + delSpeaker(e) { + let arrTemp = this.data.schedule[e.currentTarget.dataset.outindex].speakerList; + let key = `schedule[${e.currentTarget.dataset.outindex}].speakerList`; + arrTemp.splice(e.currentTarget.dataset.innerindex, 1); + this.setData({ + [key]: arrTemp, + }); + }, + selTime: function (e) { + this.setData({ + timePopShow: true, + startTimeIndex: e.currentTarget.dataset.index, + }); + }, + selOnlineStartTime() { + this.setData({ + timePopShow: true, + isOnline: 1, + }); + }, + timeCancel: function () { + this.setData({ + timePopShow: false, + isOnline: 0, + }); + }, + timeOnInput: function (e) { + this.setData({ + currentTime: e.detail, + }); + }, + timeConfirm: function (e) { + if (this.data.isOnline) { + this.setData({ + onlineStartTime: this.data.currentTime, + isOnline: 0, + timePopShow: false, + }); + return; + } + const key = `schedule[${this.data.startTimeIndex}].start`; + this.setData({ + [key]: this.data.currentTime, + timePopShow: false, + isOnline: 0, + }); + }, + timeCancel: function () { + this.setData({ + timePopShow: false, + }); + }, + endTimeCancel: function () { + this.setData({ + endTimePopShow: false, + }); + }, + selEndTime: function (e) { + this.setData({ + endTimePopShow: true, + endTimeIndex: e.currentTarget.dataset.index, + }); + }, + selOnlineEndTime() { + this.setData({ + endTimePopShow: true, + isOnline: 1, + }); + }, + endTimeOnInput: function (e) { + this.setData({ + currentEndTime: e.detail, + }); + }, + endTimeConfirm: function () { + if (this.data.isOnline) { + this.setData({ + isOnline: 0, + onlineEndTime: this.data.currentEndTime, + endTimePopShow: false, + }); + return; + } + const key = `schedule[${this.data.endTimeIndex}].end`; + this.setData({ + [key]: this.data.currentEndTime, + endTimePopShow: false, + isOnline: 0, + }); + }, + endTimeCancel: function () { + this.setData({ + endTimePopShow: false, + isOnline: 0, + }); + }, + selTop(e) { + this.setData({ + topicSelIndex: e.currentTarget.dataset.index, + }); + }, + publish() { + let postData = null; + if (this.data.type === 1) { + postData = { + title: this.data.title, + date: this.data.date, + activity_type: 1, + register_url: this.data.registerUrl || '', + synopsis: this.data.desc, + address: this.data.address, + detail_address: this.data.addressName, + longitude: this.data.longitude, + latitude: this.data.latitude, + poster: this.data.topicSelIndex, + schedules: this.data.schedule, + }; + } else { + postData = { + title: this.data.title, + date: this.data.date, + activity_type: 2, + register_url: this.data.registerUrl || '', + synopsis: this.data.desc, + longitude: this.data.longitude, + latitude: this.data.latitude, + poster: this.data.topicSelIndex, + schedules: this.data.schedule, + start: this.data.onlineStartTime, + end: this.data.onlineEndTime, + }; + } + if (!localMethods.validation(postData)) { + return; + } + remoteMethods.addEvents(postData, (res) => { + wx.redirectTo({ + url: '/package-events/publish/success?type=2', + }); + }); + }, + saveDraft() { + let postData = null; + if (this.data.type === 1) { + postData = { + title: this.data.title, + date: this.data.date, + activity_type: 1, + register_url: this.data.registerUrl || '', + synopsis: this.data.desc, + address: this.data.address, + detail_address: this.data.addressName, + longitude: this.data.longitude, + latitude: this.data.latitude, + poster: this.data.topicSelIndex, + schedules: this.data.schedule, + }; + } else { + postData = { + title: this.data.title, + date: this.data.date, + activity_type: 2, + register_url: this.data.registerUrl || '', + synopsis: this.data.desc, + longitude: this.data.longitude, + latitude: this.data.latitude, + poster: this.data.topicSelIndex, + schedules: this.data.schedule, + start: this.data.onlineStartTime, + end: this.data.onlineEndTime, + }; + } + if (!localMethods.validation(postData)) { + return; + } + remoteMethods.saveDraft(postData, () => { + wx.redirectTo({ + url: '/package-events/publish/success?type=1', + }); + }); + }, + cancelEditSchedule() { + wx.navigateBack(); + }, + editScheduleConfirm() { + let postData = null; + if (this.data.type === 1) { + postData = { + title: this.data.title, + date: this.data.date, + activity_type: 1, + register_url: this.data.registerUrl || '', + synopsis: this.data.desc, + address: this.data.address, + detail_address: this.data.addressName, + longitude: this.data.longitude, + latitude: this.data.latitude, + poster: this.data.topicSelIndex, + schedules: this.data.schedule, + }; + } else { + postData = { + title: this.data.title, + date: this.data.date, + activity_type: 2, + register_url: this.data.registerUrl || '', + synopsis: this.data.desc, + longitude: this.data.longitude, + latitude: this.data.latitude, + poster: this.data.topicSelIndex, + schedules: this.data.schedule, + start: this.data.onlineStartTime, + end: this.data.onlineEndTime, + }; + } + if (!localMethods.validation(postData)) { + return; } -}) \ No newline at end of file + postData.schedules = JSON.stringify(this.data.schedule); + remoteMethods.saveDraft(postData, () => { + wx.redirectTo({ + url: '/package-events/publish/success?type=3', + }); + }); + }, + toPoster() { + const address = this.data.type == 1 ? this.data.addressName : ''; + wx.navigateTo({ + url: `/package-events/events/poster?title=${this.data.title}&date=${this.data.date}&address=${address}&poster=${this.data.topicSelIndex}`, + }); + }, +}); diff --git a/src/openeuler/package-events/publish/success.js b/src/openeuler/package-events/publish/success.js index 38f4ecd..1af62b2 100644 --- a/src/openeuler/package-events/publish/success.js +++ b/src/openeuler/package-events/publish/success.js @@ -1,42 +1,42 @@ -// package-events/publish/success.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - type: 1, - typeCn: '', - typeDesc: '' - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - if (options.type == 1) { - this.setData({ - type: 1, - typeCn: '保存', - typeDesc: '您可以在“我的 > 我的活动 > 草稿箱”查看此活动并继续修改内容' - }) - } else if(options.type == 2) { - this.setData({ - type: 2, - typeCn: '申请', - typeDesc: '审核通过后您的活动将在openEuler官网和小程序上发布,请耐心等待,您可以在“我的 > 我的活动 > 发布中”查看此活动' - }) - } else if(options.type == 3) { - this.setData({ - type: 2, - typeCn: '修改', - typeDesc: '您可以在“我的 > 我的活动 > 已发布”查看此活动并继续修改日程' - }) - } - }, - toList() { - wx.switchTab({ - url: '/pages/events/events' - }) - } -}) \ No newline at end of file +// package-events/publish/success.js +Page({ + /** + * 页面的初始数据 + */ + data: { + type: 1, + typeCn: '', + typeDesc: '', + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + if (options.type == 1) { + this.setData({ + type: 1, + typeCn: '保存', + typeDesc: '您可以在“我的 > 我的活动 > 草稿箱”查看此活动并继续修改内容', + }); + } else if (options.type == 2) { + this.setData({ + type: 2, + typeCn: '申请', + typeDesc: + '审核通过后您的活动将在openEuler官网和小程序上发布,请耐心等待,您可以在“我的 > 我的活动 > 发布中”查看此活动', + }); + } else if (options.type == 3) { + this.setData({ + type: 2, + typeCn: '修改', + typeDesc: '您可以在“我的 > 我的活动 > 已发布”查看此活动并继续修改日程', + }); + } + }, + toList() { + wx.switchTab({ + url: '/pages/events/events', + }); + }, +}); diff --git a/src/openeuler/package-meeting/meeting/detail.js b/src/openeuler/package-meeting/meeting/detail.js index 7e7f76d..4a0385e 100644 --- a/src/openeuler/package-meeting/meeting/detail.js +++ b/src/openeuler/package-meeting/meeting/detail.js @@ -1,125 +1,125 @@ -// pages/meeting/detail.js -const appAjax = require('./../../utils/app-ajax'); -const sessionUtil = require('../../utils/app-session.js'); -let remoteMethods = { - getMeetingDetail: function (id, _callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service: 'GET_MEETING_DETAIL', - otherParams: { - id: id, - }, - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, - collect: function (id, _callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'POST', - service: 'COLLECT', - data: { - meeting: id, - }, - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, - uncollect: function (id, _callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'DELETE', - service: 'UNCOLLECT', - otherParams: { - id: id, - }, - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, -}; -Page({ - /** - * 页面的初始数据 - */ - data: { - id: '', - info: {}, - collection_id: null - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - this.setData({ - id: options.id - }); - }, - getPlatform: function (target) { - console.log(target); - return this.data.platformList.find(item => { - return item.name === target - }) - }, - copy: function (e) { - wx.setClipboardData({ - data: e.currentTarget.dataset.copy, - success: function () {}, - }); - }, - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - let that = this; - remoteMethods.getMeetingDetail(this.data.id, function (data) { - if (data) { - that.setData({ - info: data, - collection_id: data.collection_id || null - }); - } - }); - }, - - onShareAppMessage: function () { - return { - title: '会议详情', - path: `/package-meeting/meeting/detail?id=${this.data.id}`, - }; - }, - collect: function () { - let that = this - if (!sessionUtil.getUserInfoByKey('access')) { - wx.navigateTo({ - url: '/pages/auth/auth', - }); - return; - } - if (this.data.collection_id != null) { - remoteMethods.uncollect(this.data.collection_id, function (res) { - that.setData({ - collection_id: null - }) - }); - } else { - wx.requestSubscribeMessage({ - tmplIds: ['2xSske0tAcOVKNG9EpBjlb1I-cjPWSZrpwPDTgqAmWI', 'UpxRbZf8Z9QiEPlZeRCgp_MKvvqHlo6tcToY8fToK50'], - success(res) { - remoteMethods.collect(that.data.id, function (res) { - if (res.code == 201) { - that.setData({ - collection_id: res.collection_id || '' - }) - } - }) - } - }) - } - }, -}); \ No newline at end of file +// pages/meeting/detail.js +const appAjax = require('./../../utils/app-ajax'); +const sessionUtil = require('../../utils/app-session.js'); +let remoteMethods = { + getMeetingDetail: function (id, _callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service: 'GET_MEETING_DETAIL', + otherParams: { + id: id, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + collect: function (id, _callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'POST', + service: 'COLLECT', + data: { + meeting: id, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + uncollect: function (id, _callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'DELETE', + service: 'UNCOLLECT', + otherParams: { + id: id, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; +Page({ + /** + * 页面的初始数据 + */ + data: { + id: '', + info: {}, + collection_id: null, + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.setData({ + id: options.id, + }); + }, + getPlatform: function (target) { + console.log(target); + return this.data.platformList.find((item) => { + return item.name === target; + }); + }, + copy: function (e) { + wx.setClipboardData({ + data: e.currentTarget.dataset.copy, + success: function () {}, + }); + }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + let that = this; + remoteMethods.getMeetingDetail(this.data.id, function (data) { + if (data) { + that.setData({ + info: data, + collection_id: data.collection_id || null, + }); + } + }); + }, + + onShareAppMessage: function () { + return { + title: '会议详情', + path: `/package-meeting/meeting/detail?id=${this.data.id}`, + }; + }, + collect: function () { + let that = this; + if (!sessionUtil.getUserInfoByKey('access')) { + wx.navigateTo({ + url: '/pages/auth/auth', + }); + return; + } + if (this.data.collection_id != null) { + remoteMethods.uncollect(this.data.collection_id, function (res) { + that.setData({ + collection_id: null, + }); + }); + } else { + wx.requestSubscribeMessage({ + tmplIds: ['2xSske0tAcOVKNG9EpBjlb1I-cjPWSZrpwPDTgqAmWI', 'UpxRbZf8Z9QiEPlZeRCgp_MKvvqHlo6tcToY8fToK50'], + success(res) { + remoteMethods.collect(that.data.id, function (res) { + if (res.code == 201) { + that.setData({ + collection_id: res.collection_id || '', + }); + } + }); + }, + }); + } + }, +}); diff --git a/src/openeuler/package-meeting/meeting/meeting-list.js b/src/openeuler/package-meeting/meeting/meeting-list.js index 9b18743..51e1bed 100644 --- a/src/openeuler/package-meeting/meeting/meeting-list.js +++ b/src/openeuler/package-meeting/meeting/meeting-list.js @@ -1,43 +1,36 @@ -// package-meeting/meeting/meeting-list.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - meetingConponent: null - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function () { - - this.setData({ - meetingConponent: this.selectComponent('#meeting') - }) - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - wx.stopPullDownRefresh(); - this.data.meetingConponent.initData(); - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file +// package-meeting/meeting/meeting-list.js +Page({ + /** + * 页面的初始数据 + */ + data: { + meetingConponent: null, + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function () { + this.setData({ + meetingConponent: this.selectComponent('#meeting'), + }); + }, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () { + wx.stopPullDownRefresh(); + this.data.meetingConponent.initData(); + }, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () {}, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () {}, +}); diff --git a/src/openeuler/package-meeting/meeting/meeting-success.js b/src/openeuler/package-meeting/meeting/meeting-success.js index 0308237..217884d 100644 --- a/src/openeuler/package-meeting/meeting/meeting-success.js +++ b/src/openeuler/package-meeting/meeting/meeting-success.js @@ -1,31 +1,28 @@ -// pages/meeting/meeting-success.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - id: '' - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - this.setData({ - id: options.id - }) - }, - toDetail: function () { - wx.redirectTo({ - url: '/package-meeting/meeting/detail?id=' + this.data.id - }) - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - } -}) \ No newline at end of file +// pages/meeting/meeting-success.js +Page({ + /** + * 页面的初始数据 + */ + data: { + id: '', + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.setData({ + id: options.id, + }); + }, + toDetail: function () { + wx.redirectTo({ + url: '/package-meeting/meeting/detail?id=' + this.data.id, + }); + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () {}, +}); diff --git a/src/openeuler/package-meeting/reserve/reserve.js b/src/openeuler/package-meeting/reserve/reserve.js index 7d15f7f..adb63be 100644 --- a/src/openeuler/package-meeting/reserve/reserve.js +++ b/src/openeuler/package-meeting/reserve/reserve.js @@ -1,378 +1,390 @@ // pages/reserve/reserve.js const appAjax = require('./../../utils/app-ajax'); -const appSession = require("./../../utils/app-session.js"); -const utils = require("./../../utils/utils.js"); +const appSession = require('./../../utils/app-session.js'); +const utils = require('./../../utils/utils.js'); utils.formateDate(); let remoteMethods = { - getUserGroup: function (id, _callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service: "GET_USER_GROUP", - otherParams: { - id: id - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - saveMeeting: function (postData, _callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'POST', - service: "SAVE_MEETING", - data: postData, - success: function (ret) { - _callback && _callback(ret); - } - }); - } -} + getUserGroup: function (id, _callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service: 'GET_USER_GROUP', + otherParams: { + id: id, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + saveMeeting: function (postData, _callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'POST', + service: 'SAVE_MEETING', + data: postData, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; let localMethods = { - validation: function (that) { - if (!that.data.topic) { - this.toast('请输入会议名称'); - return; - } - if (!that.data.sponsor) { - this.toast('请联系管理员编辑您的gitee name'); - return; - } - if (!that.data.groupId) { - this.toast('请选择所属SIG'); - return; - } - if (!that.data.date) { - this.toast('请选择日期'); - return; - } - if (!that.data.start) { - this.toast('请选择开始时间'); - return; - } - if (!that.data.end) { - this.toast('请选择结束时间'); - return; - } - if ((that.data.start.split(':')[0] > that.data.end.split(':')[0]) || (that.data.start.split(':')[0] == that.data.end.split(':')[0] && that.data.start.split(':')[1] >= that.data.end.split(':')[1])) { - this.toast('开始时间必须小于结束时间'); - return; - } - if (!that.data.privacyState) { - this.toast('请先阅读并同意隐私声明'); - return; - } - return true; - }, - toast: function (msg) { - wx.showToast({ - title: msg, - icon: "none", - duration: 2000 - }); + validation: function (that) { + if (!that.data.topic) { + this.toast('请输入会议名称'); + return; + } + if (!that.data.sponsor) { + this.toast('请联系管理员编辑您的gitee name'); + return; + } + if (!that.data.groupId) { + this.toast('请选择所属SIG'); + return; } -} + if (!that.data.date) { + this.toast('请选择日期'); + return; + } + if (!that.data.start) { + this.toast('请选择开始时间'); + return; + } + if (!that.data.end) { + this.toast('请选择结束时间'); + return; + } + if ( + that.data.start.split(':')[0] > that.data.end.split(':')[0] || + (that.data.start.split(':')[0] == that.data.end.split(':')[0] && + that.data.start.split(':')[1] >= that.data.end.split(':')[1]) + ) { + this.toast('开始时间必须小于结束时间'); + return; + } + if (!that.data.privacyState) { + this.toast('请先阅读并同意隐私声明'); + return; + } + return true; + }, + toast: function (msg) { + wx.showToast({ + title: msg, + icon: 'none', + duration: 2000, + }); + }, +}; Page({ + /** + * 页面的初始数据 + */ + data: { + privacyState: false, + record: false, + sendDev: false, + meetingType: 'zoom', + typeList: ['Zoom', 'WeLink(蓝版)', '腾讯会议'], + topic: '', + sponsor: '', + groupName: '', + groupId: '', + date: '', + start: '', + end: '', + etherpad: '', + sigEmail: '', + agenda: '', + emaillist: '', + sigPopShow: false, + sigResult: '', + sigList: [], + datePopShow: false, + curDate: new Date().getTime(), + currentDate: new Date().getTime(), + minDate: new Date().getTime(), + timePopShow: false, + currentTime: '08:00', + minTime: 8, + maxTime: 22, + endTimePopShow: false, + currentEndTime: '08:00', + minEndTime: 8, + maxEndTime: 22, + showDialogWarn: false, + filter(type, options) { + if (type === 'minute') { + return options.filter((option) => option % 15 === 0); + } - /** - * 页面的初始数据 - */ - data: { - privacyState: false, - record: false, - sendDev: false, - meetingType: 'zoom', - typeList: ['Zoom', 'WeLink(蓝版)', '腾讯会议'], - topic: '', - sponsor: '', - groupName: '', - groupId: '', - date: '', - start: '', - end: '', - etherpad: '', - sigEmail: '', - agenda: '', - emaillist: '', - sigPopShow: false, - sigResult: '', - sigList: [], - datePopShow: false, - curDate: new Date().getTime(), - currentDate: new Date().getTime(), - minDate: new Date().getTime(), - timePopShow: false, - currentTime: '08:00', - minTime: 8, - maxTime: 22, - endTimePopShow: false, - currentEndTime: '08:00', - minEndTime: 8, - maxEndTime: 22, - showDialogWarn: false, - filter(type, options) { - if (type === 'minute') { - return options.filter((option) => option % 15 === 0); - } - - return options; - } + return options; }, + }, - /** - * 生命周期函数--监听页面加载 - */ - recordoOnChange: function (event) { - this.setData({ - record: event.detail - }); - }, - devOnChange: function (event) { - this.setData({ - sendDev: event.detail, - }); - }, - toPrivacy() { - wx.navigateTo({ - url: '/package-my/my/privecy' - }) - }, - privacyStateOnChange: function (event) { - this.setData({ - privacyState: event.detail - }); - }, - reset: function () { - this.setData({ - topic: '', - groupName: '', - group_name: '', - group_id: '', - groupId: '', - date: '', - start: '', - end: '', - etherpad: '', - agenda: '', - emaillist: '' - }) - }, - meeting: function () { - if (!localMethods.validation(this)) { - return; + /** + * 生命周期函数--监听页面加载 + */ + recordoOnChange: function (event) { + this.setData({ + record: event.detail, + }); + }, + devOnChange: function (event) { + this.setData({ + sendDev: event.detail, + }); + }, + toPrivacy() { + wx.navigateTo({ + url: '/package-my/my/privecy', + }); + }, + privacyStateOnChange: function (event) { + this.setData({ + privacyState: event.detail, + }); + }, + reset: function () { + this.setData({ + topic: '', + groupName: '', + group_name: '', + group_id: '', + groupId: '', + date: '', + start: '', + end: '', + etherpad: '', + agenda: '', + emaillist: '', + }); + }, + meeting: function () { + if (!localMethods.validation(this)) { + return; + } + let that = this; + wx.requestSubscribeMessage({ + tmplIds: ['2xSske0tAcOVKNG9EpBjlb1I-cjPWSZrpwPDTgqAmWI'], + success(res) { + let email = null; + if (that.data.sendDev) { + if ( + that.data.emaillist.at(-1) == ';' || + that.data.emaillist.at(-1) == ';' || + that.data.emaillist.at(-1) == '' + ) { + email = `${that.data.emaillist}dev@openeuler.org;`; + } else { + email = `${that.data.emaillist};dev@openeuler.org;`; + } + } else { + email = that.data.emaillist; } - let that = this; - wx.requestSubscribeMessage({ - tmplIds: ['2xSske0tAcOVKNG9EpBjlb1I-cjPWSZrpwPDTgqAmWI'], - success(res) { - let email = null; - if (that.data.sendDev) { - if (that.data.emaillist.at(-1) == ';' || that.data.emaillist.at(-1) == ';' || that.data.emaillist.at(-1) == '') { - email = `${that.data.emaillist}dev@openeuler.org;`; - } else { - email = `${that.data.emaillist};dev@openeuler.org;`; - } - } else { - email = that.data.emaillist - } - remoteMethods.saveMeeting({ - topic: that.data.topic, - sponsor: that.data.sponsor, - group_name: that.data.groupName, - group_id: that.data.groupId, - date: that.data.date, - start: that.data.start, - end: that.data.end, - platform: that.data.meetingType, - etherpad: that.data.etherpad, - agenda: that.data.agenda, - emaillist: email, - record: that.data.record ? 'cloud' : '' - }, function (data) { - if (data.id) { - wx.redirectTo({ - url: '/package-meeting/meeting/meeting-success?id=' + data.id, - }) - } else { - setTimeout(function () { - wx.showToast({ - title: data.message, - icon: "none", - duration: 4000 - }, 100); - }) - } - }) + remoteMethods.saveMeeting( + { + topic: that.data.topic, + sponsor: that.data.sponsor, + group_name: that.data.groupName, + group_id: that.data.groupId, + date: that.data.date, + start: that.data.start, + end: that.data.end, + platform: that.data.meetingType, + etherpad: that.data.etherpad, + agenda: that.data.agenda, + emaillist: email, + record: that.data.record ? 'cloud' : '', + }, + function (data) { + if (data.id) { + wx.redirectTo({ + url: '/package-meeting/meeting/meeting-success?id=' + data.id, + }); + } else { + setTimeout(function () { + wx.showToast( + { + title: data.message, + icon: 'none', + duration: 4000, + }, + 100 + ); + }); } - }) - - }, - sigNameInput: function (e) { - this.setData({ - topic: e.detail.value - }) - }, - etherInput: function (e) { - this.setData({ - etherpad: e.detail.value - }) - }, - agendaInput: function (e) { - this.setData({ - agenda: e.detail.value - }) - }, - emailInput: function (e) { - this.setData({ - emaillist: e.detail.value - }) - }, - sigConfirm: function () { - let that = this; - let sigObj = this.data.sigList.filter(function (item) { - return item.group === that.data.sigResult; - }); - sigObj = sigObj.length ? sigObj[0] : {} - sigObj.maillist === 'dev@openeuler.org' ? sigObj.maillist = '' : sigObj.maillist = `${sigObj.maillist};`; - this.setData({ - groupName: sigObj.group_name || '', - groupId: sigObj.group || '', - etherpad: sigObj.etherpad || '', - emaillist: `${sigObj.maillist}` || '', - sigPopShow: false - }) - }, - dateConfirm: function () { - this.setData({ - date: (new Date(this.data.currentDate)).Format("yyyy-MM-dd"), - datePopShow: false - }) - }, - timeConfirm: function () { - this.setData({ - start: this.data.currentTime, - timePopShow: false - }) - }, - endTimeConfirm: function () { - this.setData({ - end: this.data.currentEndTime, - endTimePopShow: false - }) - }, - onTypeShow: function () { - this.setData({ - typeShow: true, - }) - }, - typeCancel: function () { - this.setData({ - typeShow: false, - }); - }, - typeConfirm: function () { - this.setData({ - typeShow: false, + } + ); + }, + }); + }, + sigNameInput: function (e) { + this.setData({ + topic: e.detail.value, + }); + }, + etherInput: function (e) { + this.setData({ + etherpad: e.detail.value, + }); + }, + agendaInput: function (e) { + this.setData({ + agenda: e.detail.value, + }); + }, + emailInput: function (e) { + this.setData({ + emaillist: e.detail.value, + }); + }, + sigConfirm: function () { + let that = this; + let sigObj = this.data.sigList.filter(function (item) { + return item.group === that.data.sigResult; + }); + sigObj = sigObj.length ? sigObj[0] : {}; + sigObj.maillist === 'dev@openeuler.org' ? (sigObj.maillist = '') : (sigObj.maillist = `${sigObj.maillist};`); + this.setData({ + groupName: sigObj.group_name || '', + groupId: sigObj.group || '', + etherpad: sigObj.etherpad || '', + emaillist: `${sigObj.maillist}` || '', + sigPopShow: false, + }); + }, + dateConfirm: function () { + this.setData({ + date: new Date(this.data.currentDate).Format('yyyy-MM-dd'), + datePopShow: false, + }); + }, + timeConfirm: function () { + this.setData({ + start: this.data.currentTime, + timePopShow: false, + }); + }, + endTimeConfirm: function () { + this.setData({ + end: this.data.currentEndTime, + endTimePopShow: false, + }); + }, + onTypeShow: function () { + this.setData({ + typeShow: true, + }); + }, + typeCancel: function () { + this.setData({ + typeShow: false, + }); + }, + typeConfirm: function () { + this.setData({ + typeShow: false, + }); + }, + typeRadioOnChange: function (e) { + this.setData({ + meetingType: e.detail, + }); + }, + radioOnChange(e) { + this.setData({ + meetingType: e.detail, + }); + }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + that = this; + this.setData({ + sponsor: appSession.getUserInfoByKey('gitee') || '', + }); + let that = this; + remoteMethods.getUserGroup(appSession.getUserInfoByKey('userId'), function (data) { + if (data && data.length) { + that.setData({ + sigList: data, }); - }, - typeRadioOnChange: function (e) { - this.setData({ - meetingType: e.detail - }); - }, - radioOnChange(e) { - this.setData({ - meetingType: e.detail, - }) - }, - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - that = this; - this.setData({ - sponsor: appSession.getUserInfoByKey('gitee') || '' - }) - let that = this; - remoteMethods.getUserGroup(appSession.getUserInfoByKey('userId'), function (data) { - if (data && data.length) { - that.setData({ - sigList: data - }) - } - }) - }, - sigRadioOnChange: function (e) { - this.setData({ - sigResult: e.detail - }) - }, + } + }); + }, + sigRadioOnChange: function (e) { + this.setData({ + sigResult: e.detail, + }); + }, - selSig: function () { - if (!this.data.sigList.length) { - this.setData({ - showDialogWarn: true - }) - return; - } - this.setData({ - sigPopShow: true - }) - }, - warnCancel: function () { - this.setData({ - showDialogWarn: false - }) - }, - sigCancel: function () { - this.setData({ - sigPopShow: false - }) - }, - selDate: function () { - this.setData({ - datePopShow: true - }) - }, - selTime: function () { - this.setData({ - timePopShow: true - }) - }, - selEndTime: function () { - this.setData({ - endTimePopShow: true - }) - }, - dateCancel: function () { - this.setData({ - datePopShow: false - }) - }, - timeCancel: function () { - this.setData({ - timePopShow: false - }) - }, - endTimeCancel: function () { - this.setData({ - endTimePopShow: false - }) - }, - dateOnInput: function (e) { - this.setData({ - currentDate: e.detail.value - }) - }, - timeOnInput: function (e) { - this.setData({ - currentTime: e.detail.value - }) - }, - endTimeOnInput: function (e) { - this.setData({ - currentEndTime: e.detail.value - }) - }, -}) \ No newline at end of file + selSig: function () { + if (!this.data.sigList.length) { + this.setData({ + showDialogWarn: true, + }); + return; + } + this.setData({ + sigPopShow: true, + }); + }, + warnCancel: function () { + this.setData({ + showDialogWarn: false, + }); + }, + sigCancel: function () { + this.setData({ + sigPopShow: false, + }); + }, + selDate: function () { + this.setData({ + datePopShow: true, + }); + }, + selTime: function () { + this.setData({ + timePopShow: true, + }); + }, + selEndTime: function () { + this.setData({ + endTimePopShow: true, + }); + }, + dateCancel: function () { + this.setData({ + datePopShow: false, + }); + }, + timeCancel: function () { + this.setData({ + timePopShow: false, + }); + }, + endTimeCancel: function () { + this.setData({ + endTimePopShow: false, + }); + }, + dateOnInput: function (e) { + this.setData({ + currentDate: e.detail.value, + }); + }, + timeOnInput: function (e) { + this.setData({ + currentTime: e.detail.value, + }); + }, + endTimeOnInput: function (e) { + this.setData({ + currentEndTime: e.detail.value, + }); + }, +}); diff --git a/src/openeuler/package-meeting/sig/add-member.js b/src/openeuler/package-meeting/sig/add-member.js index 9900608..ad3bd81 100644 --- a/src/openeuler/package-meeting/sig/add-member.js +++ b/src/openeuler/package-meeting/sig/add-member.js @@ -1,116 +1,121 @@ -// pages/sig/add-member.js -const appAjax = require('./../../utils/app-ajax'); -let remoteMethods = { - getExcludeMemberList: function (postData, _callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service: "SIG_EXCLUDE_MEMBER_LIST", - otherParams: { - id: postData.id - }, - data: { - search: postData.nickname || '' - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - addMemberList: function (postData, _callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'POST', - service: "ADD_MEMBER_LIST", - data: postData, - success: function (ret) { - _callback && _callback(ret); - } - }); - } -} -Page({ - - /** - * 页面的初始数据 - */ - data: { - list: [], - result: [], - sigId: '', - keyword: '' - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - this.setData({ - sigId: options.sigId - }) - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - let that = this; - remoteMethods.getExcludeMemberList({ - id: this.data.sigId - }, function (data) { - that.setData({ - list: data - }) - }) - }, - onChange: function (e) { - this.setData({ - result: e.detail - }) - }, - comfirm: function () { - let that = this; - if (!this.data.result.length) { - wx.showToast({ - title: '请选择人员', - icon: "none", - duration: 2000 - }); - return; - } - let postData = { - ids: this.data.result.join('-'), - group_id: this.data.sigId - } - remoteMethods.addMemberList(postData, function (data) { - if (data.code === 201) { - wx.showToast({ - title: '操作成功', - icon: "success", - duration: 2000 - }); - wx.navigateBack(); - } else { - wx.showToast({ - title: '操作失败', - icon: "none", - duration: 2000 - }); - } - }) - }, - searchInput: function (e) { - let that = this; - this.setData({ - keyword: e.detail.value - }) - remoteMethods.getExcludeMemberList({ - id: this.data.sigId, - nickname: this.data.keyword - }, function (data) { - that.setData({ - list: data - }) - }) - } -}) \ No newline at end of file +// pages/sig/add-member.js +const appAjax = require('./../../utils/app-ajax'); +let remoteMethods = { + getExcludeMemberList: function (postData, _callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service: 'SIG_EXCLUDE_MEMBER_LIST', + otherParams: { + id: postData.id, + }, + data: { + search: postData.nickname || '', + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + addMemberList: function (postData, _callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'POST', + service: 'ADD_MEMBER_LIST', + data: postData, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; +Page({ + /** + * 页面的初始数据 + */ + data: { + list: [], + result: [], + sigId: '', + keyword: '', + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.setData({ + sigId: options.sigId, + }); + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + let that = this; + remoteMethods.getExcludeMemberList( + { + id: this.data.sigId, + }, + function (data) { + that.setData({ + list: data, + }); + } + ); + }, + onChange: function (e) { + this.setData({ + result: e.detail, + }); + }, + comfirm: function () { + let that = this; + if (!this.data.result.length) { + wx.showToast({ + title: '请选择人员', + icon: 'none', + duration: 2000, + }); + return; + } + let postData = { + ids: this.data.result.join('-'), + group_id: this.data.sigId, + }; + remoteMethods.addMemberList(postData, function (data) { + if (data.code === 201) { + wx.showToast({ + title: '操作成功', + icon: 'success', + duration: 2000, + }); + wx.navigateBack(); + } else { + wx.showToast({ + title: '操作失败', + icon: 'none', + duration: 2000, + }); + } + }); + }, + searchInput: function (e) { + let that = this; + this.setData({ + keyword: e.detail.value, + }); + remoteMethods.getExcludeMemberList( + { + id: this.data.sigId, + nickname: this.data.keyword, + }, + function (data) { + that.setData({ + list: data, + }); + } + ); + }, +}); diff --git a/src/openeuler/package-meeting/sig/add-sig-member.js b/src/openeuler/package-meeting/sig/add-sig-member.js index f328117..1764eff 100644 --- a/src/openeuler/package-meeting/sig/add-sig-member.js +++ b/src/openeuler/package-meeting/sig/add-sig-member.js @@ -1,64 +1,73 @@ -// pages/sig/add-sig-member.js -const appAjax = require('./../../utils/app-ajax'); -let remoteMethods = { - getSigMemberList: function (id, _callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service: "SIG_MEMBER_LIST", - otherParams: { - id: id - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - } -} -Page({ - - /** - * 页面的初始数据 - */ - data: { - memberList: [], - id: "" - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - wx.setNavigationBarTitle({ - title: options.name - }) - this.setData({ - id: options.id - }) - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - let that = this; - remoteMethods.getSigMemberList(this.data.id, function (list) { - that.setData({ - memberList: list - }) - }); - }, - toDetail: function (e) { - - }, - addMember: function () { - wx.navigateTo({ - url: '/package-meeting/sig/add-member?sigId=' + this.data.id - }) - }, - delMember: function () { - wx.navigateTo({ - url: '/package-meeting/sig/del-member?sigId=' + this.data.id - }) - } -}) \ No newline at end of file +// pages/sig/add-sig-member.js +const appAjax = require('./../../utils/app-ajax'); +let remoteMethods = { + getSigMemberList: function (id, _callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service: 'SIG_MEMBER_LIST', + otherParams: { + id: id, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; +Page({ + /** + * 页面的初始数据 + */ + data: { + memberList: [], + id: '', + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + wx.setNavigationBarTitle({ + title: options.name, + }); + this.setData({ + id: options.id, + }); + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + let that = this; + remoteMethods.getSigMemberList(this.data.id, function (list) { + that.setData({ + memberList: list, + }); + }); + }, + toDetail: function (e) { + wx.navigateTo({ + url: + '/package-meeting/sig/member-detail?id=' + + e.currentTarget.dataset.id + + '&avatar=' + + e.currentTarget.dataset.avatar + + '&name=' + + e.currentTarget.dataset.name + + '&nickname=' + + e.currentTarget.dataset.nickname, + }); + }, + addMember: function () { + wx.navigateTo({ + url: '/package-meeting/sig/add-member?sigId=' + this.data.id, + }); + }, + delMember: function () { + wx.navigateTo({ + url: '/package-meeting/sig/del-member?sigId=' + this.data.id, + }); + }, +}); diff --git a/src/openeuler/package-meeting/sig/del-member.js b/src/openeuler/package-meeting/sig/del-member.js index 8af6389..37f92e0 100644 --- a/src/openeuler/package-meeting/sig/del-member.js +++ b/src/openeuler/package-meeting/sig/del-member.js @@ -1,98 +1,99 @@ -// pages/sig/del-member.js -const appAjax = require('./../../utils/app-ajax'); -let remoteMethods = { - getCludeMemberList: function (postData, _callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service: "SIG_CLUDE_MEMBER_LIST", - otherParams: { - id: postData.id - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - delMemberList: function (postData, _callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'POST', - service: "DEL_MEMBER_LIST", - data: postData, - success: function (ret) { - _callback && _callback(ret); - } - }); - } -} -Page({ - - /** - * 页面的初始数据 - */ - data: { - list: [], - result: [], - sigId: '' - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - this.setData({ - sigId: options.sigId - }) - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - let that = this; - remoteMethods.getCludeMemberList({ - id: this.data.sigId - }, function (data) { - that.setData({ - list: data - }) - }) - }, - onChange: function (e) { - this.setData({ - result: e.detail - }) - }, - del: function () { - let that = this; - if (!this.data.result.length) { - wx.showToast({ - title: '请选择人员', - icon: "none", - duration: 2000 - }); - return; - } - let postData = { - ids: this.data.result.join('-'), - group_id: this.data.sigId - } - remoteMethods.delMemberList(postData, function (data) { - if (data.code === 204) { - wx.showToast({ - title: '操作成功', - icon: "success", - duration: 2000 - }); - wx.navigateBack(); - } else { - wx.showToast({ - title: '操作失败', - icon: "none", - duration: 2000 - }); - } - }) - } -}) \ No newline at end of file +// pages/sig/del-member.js +const appAjax = require('./../../utils/app-ajax'); +let remoteMethods = { + getCludeMemberList: function (postData, _callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service: 'SIG_CLUDE_MEMBER_LIST', + otherParams: { + id: postData.id, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + delMemberList: function (postData, _callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'POST', + service: 'DEL_MEMBER_LIST', + data: postData, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; +Page({ + /** + * 页面的初始数据 + */ + data: { + list: [], + result: [], + sigId: '', + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.setData({ + sigId: options.sigId, + }); + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + let that = this; + remoteMethods.getCludeMemberList( + { + id: this.data.sigId, + }, + function (data) { + that.setData({ + list: data, + }); + } + ); + }, + onChange: function (e) { + this.setData({ + result: e.detail, + }); + }, + del: function () { + if (!this.data.result.length) { + wx.showToast({ + title: '请选择人员', + icon: 'none', + duration: 2000, + }); + return; + } + let postData = { + ids: this.data.result.join('-'), + group_id: this.data.sigId, + }; + remoteMethods.delMemberList(postData, function (data) { + if (data.code === 204) { + wx.showToast({ + title: '操作成功', + icon: 'success', + duration: 2000, + }); + wx.navigateBack(); + } else { + wx.showToast({ + title: '操作失败', + icon: 'none', + duration: 2000, + }); + } + }); + }, +}); diff --git a/src/openeuler/package-meeting/sig/sig-list.js b/src/openeuler/package-meeting/sig/sig-list.js index fd0c578..1ceabb9 100644 --- a/src/openeuler/package-meeting/sig/sig-list.js +++ b/src/openeuler/package-meeting/sig/sig-list.js @@ -1,64 +1,58 @@ -// pages/sig/sig-list.js -const appAjax = require('./../../utils/app-ajax'); -let remoteMethods = { - getSigList: function (keyword, _callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service: "SIG_LIST", - data: { - search: keyword - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - } -} -Page({ - - /** - * 页面的初始数据 - */ - data: { - keyword: '', - list: [] - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - let that = this; - remoteMethods.getSigList("", function (list) { - that.setData({ - list: list - }); - }) - }, - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - toAddMember: function (e) { - wx.navigateTo({ - url: '/package-meeting/sig/add-sig-member?id=' + e.currentTarget.dataset.id + '&name=' + e.currentTarget.dataset.name - }) - }, - searchInput: function (e) { - let that = this; - remoteMethods.getSigList(e.detail.value, function (list) { - that.setData({ - list: list - }); - }) - } -}) \ No newline at end of file +// pages/sig/sig-list.js +const appAjax = require('./../../utils/app-ajax'); +let remoteMethods = { + getSigList: function (keyword, _callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service: 'SIG_LIST', + data: { + search: keyword, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; +Page({ + /** + * 页面的初始数据 + */ + data: { + keyword: '', + list: [], + }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + let that = this; + remoteMethods.getSigList('', function (list) { + that.setData({ + list: list, + }); + }); + }, + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () {}, + toAddMember: function (e) { + wx.navigateTo({ + url: + '/package-meeting/sig/add-sig-member?id=' + + e.currentTarget.dataset.id + + '&name=' + + e.currentTarget.dataset.name, + }); + }, + searchInput: function (e) { + let that = this; + remoteMethods.getSigList(e.detail.value, function (list) { + that.setData({ + list: list, + }); + }); + }, +}); diff --git a/src/openeuler/package-my/events/my-list.js b/src/openeuler/package-my/events/my-list.js index 282b4cd..298e0ff 100644 --- a/src/openeuler/package-my/events/my-list.js +++ b/src/openeuler/package-my/events/my-list.js @@ -1,329 +1,325 @@ -// package-my/events/under-release.js -const appAjax = require('./../../utils/app-ajax'); -const sessionUtil = require("../../utils/app-session.js"); - -let that = null; -let remoteMethods = { - getList: function (_callback) { - let service = ''; - if (that.data.type == 4) { - service = 'GET_DRAFT_LIST' - } else if (that.data.type == 1) { - service = 'DRAFTS' - } else if (that.data.type == 5) { - service = 'PUBLISHER_EVENTS_LIST' - } else if (that.data.type == 2) { - if (that.data.level == 2) { - service = 'MY_EVENTS_LIST' - } else { - service = 'ALL_EVENTS_LIST' - } - - } else if (that.data.type == 6) { - service = 'EVENT_COLLECT_LIST' - } else if (that.data.type == 7) { - return; - } else if (that.data.type == 3) { - if (that.data.level == 2) { - service = 'MY_EVENTS_LIST' - } else { - service = 'ALL_EVENTS_LIST' - } - - } - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - delDraft: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'DELETE', - service: 'DRAFT_DETAIL', - otherParams: { - id: that.data.curId - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - delEvent: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'PUT', - service: 'DEL_EVENT', - otherParams: { - id: that.data.curId - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - collect: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'POST', - service: 'EVENT_COLLECT', - data: { - activity: that.data.curId - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - unCollect: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'DELETE', - service: 'EVENT_UNCOLLECT', - otherParams: { - id: that.data.collectionId - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, -} -Page({ - - /** - * 页面的初始数据 - */ - data: { - type: 1, - list: [], - level: 1, - actionShow: false, - actions: [], - curId: '', - userId: '', - collectionId: '', - showDialogDel: false, - noAuthDialogShow: false, - user: '', - registerId: '' - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - this.setData({ - type: options.type, - level: sessionUtil.getUserInfoByKey('eventLevel'), - user: sessionUtil.getUserInfoByKey('userId') - }) - that = this; - let title = ''; - if (options.type == 1) { - title = '待发布'; - } else if (options.type == 2) { - title = '已发布'; - } else if (options.type == 3) { - title = '报名表单'; - } else if (options.type == 4) { - title = '草稿箱'; - } else if (options.type == 5) { - title = '发布中'; - } else if (options.type == 6) { - title = '我收藏的活动'; - } else if (options.type == 7) { - title = '我报名的活动'; - } - wx.setNavigationBarTitle({ - title - }) - }, - - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - remoteMethods.getList(res => { - this.setData({ - list: res - }) - - }) - }, - toSign(e) { - wx.navigateTo({ - url: `/package-events/events/sign?id=${e.currentTarget.dataset.id}` - }) - }, - editDraft(e) { - wx.navigateTo({ - url: `/package-events/events/event-detail?id=${e.currentTarget.dataset.id}&type=4` - }) - }, - onActionClose() { - this.setData({ - actionShow: false - }) - }, - onActionSelect(e) { - if (this.data.type == 4) { - remoteMethods.delDraft(() => { - this.onShow(); - }) - } else if ((this.data.type == 2) || (this.data.type == 6) || (this.data.type == 7)) { - if (this.data.level == 3) { - if (e.detail.operaType == 1) { - if (this.data.collectionId) { - remoteMethods.unCollect(() => { - this.onShow(); - }) - } else { - remoteMethods.collect(() => { - this.onShow(); - }) - } - } else { - this.setData({ - showDialogDel: true - }) - } - } else { - if (e.detail.operaType == 1) { - if (this.data.collectionId) { - remoteMethods.unCollect(() => { - this.onShow(); - }) - } else { - remoteMethods.collect(() => { - this.onShow(); - }) - } - } else if(e.detail.operaType == 3) { - return; - } else { - this.setData({ - noAuthDialogShow: true - }) - } - } - - } - }, - onMore(e) { - this.setData({ - actionShow: true, - curId: e.currentTarget.dataset.item.id, - userId: e.currentTarget.dataset.item.user, - collectionId: e.currentTarget.dataset.item.collection_id || '', - registerId: e.currentTarget.dataset.item.register_id || '' - }) - const strTemp = this.data.collectionId ? '取消收藏' : '收藏活动'; - if (this.data.type == 4) { - this.setData({ - actions: [{ - name: '删除', - operaType: 1 - }] - }) - } else if ((this.data.type == 2) || (this.data.type == 6) || (this.data.type == 7)) { - if (this.data.level == 3) { - this.setData({ - actions: [{ - name: strTemp, - operaType: 1 - }, - { - name: '下架活动', - operaType: 2 - } - ] - }) - } else { - if (this.data.user == this.data.userId) { - this.setData({ - actions: [{ - name: strTemp, - operaType: 1 - }, - { - name: '下架活动', - operaType: 2 - } - ] - }) - } else { - this.setData({ - actions: [{ - name: strTemp, - operaType: 1 - }] - }) - } - - if (this.data.registerId) { - let tempArr = this.data.actions; - tempArr.unshift({ - name: '查看门票', - operaType: 3 - }) - this.setData({ - actions: tempArr - }) - } - } - } - - }, - toExamine(e) { - wx.navigateTo({ - url: `/package-events/events/event-detail?id=${e.currentTarget.dataset.id}&type=1` - }) - }, - del() { - this.setData({ - showDialogDel: false - }) - remoteMethods.delEvent(() => { - remoteMethods.getList(res => { - this.setData({ - list: res - }) - - }); - }) - }, - delCancel() { - this.setData({ - showDialogDel: false - }) - }, - toUpdateSchedule(e) { - if (this.data.type == 4) { - this.editDraft(e); - } else if ((this.data.type == 2) || (this.data.type == 6) || (this.data.type == 7)) { - wx.navigateTo({ - url: `/package-events/events/event-detail?id=${e.currentTarget.dataset.id}&type=5` - }) - } else if (this.data.type == 3) { - return; - } - - }, - copyWechat() { - wx.setClipboardData({ - data: 'openeuler123', - success: () => { - this.setData({ - noAuthDialogShow: false - }) - } - }) - - }, -}) \ No newline at end of file +// package-my/events/under-release.js +const appAjax = require('./../../utils/app-ajax'); +const sessionUtil = require('../../utils/app-session.js'); + +let that = null; +let remoteMethods = { + getList: function (_callback) { + let service = ''; + if (that.data.type == 4) { + service = 'GET_DRAFT_LIST'; + } else if (that.data.type == 1) { + service = 'DRAFTS'; + } else if (that.data.type == 5) { + service = 'PUBLISHER_EVENTS_LIST'; + } else if (that.data.type == 2) { + if (that.data.level == 2) { + service = 'MY_EVENTS_LIST'; + } else { + service = 'ALL_EVENTS_LIST'; + } + } else if (that.data.type == 6) { + service = 'EVENT_COLLECT_LIST'; + } else if (that.data.type == 7) { + return; + } else if (that.data.type == 3) { + if (that.data.level == 2) { + service = 'MY_EVENTS_LIST'; + } else { + service = 'ALL_EVENTS_LIST'; + } + } + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + delDraft: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'DELETE', + service: 'DRAFT_DETAIL', + otherParams: { + id: that.data.curId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + delEvent: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'PUT', + service: 'DEL_EVENT', + otherParams: { + id: that.data.curId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + collect: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'POST', + service: 'EVENT_COLLECT', + data: { + activity: that.data.curId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + unCollect: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'DELETE', + service: 'EVENT_UNCOLLECT', + otherParams: { + id: that.data.collectionId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; +Page({ + /** + * 页面的初始数据 + */ + data: { + type: 1, + list: [], + level: 1, + actionShow: false, + actions: [], + curId: '', + userId: '', + collectionId: '', + showDialogDel: false, + noAuthDialogShow: false, + user: '', + registerId: '', + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.setData({ + type: options.type, + level: sessionUtil.getUserInfoByKey('eventLevel'), + user: sessionUtil.getUserInfoByKey('userId'), + }); + that = this; + let title = ''; + if (options.type == 1) { + title = '待发布'; + } else if (options.type == 2) { + title = '已发布'; + } else if (options.type == 3) { + title = '报名表单'; + } else if (options.type == 4) { + title = '草稿箱'; + } else if (options.type == 5) { + title = '发布中'; + } else if (options.type == 6) { + title = '我收藏的活动'; + } else if (options.type == 7) { + title = '我报名的活动'; + } + wx.setNavigationBarTitle({ + title, + }); + }, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + remoteMethods.getList((res) => { + this.setData({ + list: res, + }); + }); + }, + toSign(e) { + wx.navigateTo({ + url: `/package-events/events/sign?id=${e.currentTarget.dataset.id}`, + }); + }, + editDraft(e) { + wx.navigateTo({ + url: `/package-events/events/event-detail?id=${e.currentTarget.dataset.id}&type=4`, + }); + }, + onActionClose() { + this.setData({ + actionShow: false, + }); + }, + onActionSelect(e) { + if (this.data.type == 4) { + remoteMethods.delDraft(() => { + this.onShow(); + }); + } else if (this.data.type == 2 || this.data.type == 6 || this.data.type == 7) { + if (this.data.level == 3) { + if (e.detail.operaType == 1) { + if (this.data.collectionId) { + remoteMethods.unCollect(() => { + this.onShow(); + }); + } else { + remoteMethods.collect(() => { + this.onShow(); + }); + } + } else { + this.setData({ + showDialogDel: true, + }); + } + } else { + if (e.detail.operaType == 1) { + if (this.data.collectionId) { + remoteMethods.unCollect(() => { + this.onShow(); + }); + } else { + remoteMethods.collect(() => { + this.onShow(); + }); + } + } else if (e.detail.operaType == 3) { + return; + } else { + this.setData({ + noAuthDialogShow: true, + }); + } + } + } + }, + onMore(e) { + this.setData({ + actionShow: true, + curId: e.currentTarget.dataset.item.id, + userId: e.currentTarget.dataset.item.user, + collectionId: e.currentTarget.dataset.item.collection_id || '', + registerId: e.currentTarget.dataset.item.register_id || '', + }); + const strTemp = this.data.collectionId ? '取消收藏' : '收藏活动'; + if (this.data.type == 4) { + this.setData({ + actions: [ + { + name: '删除', + operaType: 1, + }, + ], + }); + } else if (this.data.type == 2 || this.data.type == 6 || this.data.type == 7) { + if (this.data.level == 3) { + this.setData({ + actions: [ + { + name: strTemp, + operaType: 1, + }, + { + name: '下架活动', + operaType: 2, + }, + ], + }); + } else { + if (this.data.user == this.data.userId) { + this.setData({ + actions: [ + { + name: strTemp, + operaType: 1, + }, + { + name: '下架活动', + operaType: 2, + }, + ], + }); + } else { + this.setData({ + actions: [ + { + name: strTemp, + operaType: 1, + }, + ], + }); + } + + if (this.data.registerId) { + let tempArr = this.data.actions; + tempArr.unshift({ + name: '查看门票', + operaType: 3, + }); + this.setData({ + actions: tempArr, + }); + } + } + } + }, + toExamine(e) { + wx.navigateTo({ + url: `/package-events/events/event-detail?id=${e.currentTarget.dataset.id}&type=1`, + }); + }, + del() { + this.setData({ + showDialogDel: false, + }); + remoteMethods.delEvent(() => { + remoteMethods.getList((res) => { + this.setData({ + list: res, + }); + }); + }); + }, + delCancel() { + this.setData({ + showDialogDel: false, + }); + }, + toUpdateSchedule(e) { + if (this.data.type == 4) { + this.editDraft(e); + } else if (this.data.type == 2 || this.data.type == 6 || this.data.type == 7) { + wx.navigateTo({ + url: `/package-events/events/event-detail?id=${e.currentTarget.dataset.id}&type=5`, + }); + } else if (this.data.type == 3) { + return; + } + }, + copyWechat() { + wx.setClipboardData({ + data: 'openeuler123', + success: () => { + this.setData({ + noAuthDialogShow: false, + }); + }, + }); + }, +}); diff --git a/src/openeuler/package-my/my/feedback.js b/src/openeuler/package-my/my/feedback.js index ca7ed89..723b547 100644 --- a/src/openeuler/package-my/my/feedback.js +++ b/src/openeuler/package-my/my/feedback.js @@ -1,19 +1,17 @@ // package-my/my/feedback.js Page({ - - /** - * 页面的初始数据 - */ - copyEmail: function () { - let that = this; - wx.setClipboardData({ - data: 'contact@openeuler.io', - success: function (res) { - that.setData({ - showDialog: false - }) - } - }) - - }, -}) \ No newline at end of file + /** + * 页面的初始数据 + */ + copyEmail: function () { + let that = this; + wx.setClipboardData({ + data: 'contact@openeuler.io', + success: function () { + that.setData({ + showDialog: false, + }); + }, + }); + }, +}); diff --git a/src/openeuler/package-my/my/help.js b/src/openeuler/package-my/my/help.js index 4f7f4a5..526e427 100644 --- a/src/openeuler/package-my/my/help.js +++ b/src/openeuler/package-my/my/help.js @@ -1,35 +1,26 @@ -// pages/my/help.js -const resourceUrl = 'https://openeuler-website.obs.ap-southeast-1.myhuaweicloud.com/help'; - -Page({ - - /** - * 页面的初始数据 - */ - data: { - list: [ - { - name: '会议攻略', - contentImg: [ - resourceUrl + '/11.png', - resourceUrl + '/12.png', - resourceUrl + '/13.png' - ] - }, - { - name: '活动攻略', - contentImg: [ - resourceUrl + '/21.png', - resourceUrl + '/22.png', - resourceUrl + '/23.png' - ] - } - ], - curIndex: 0 - }, - switchTab(e) { - this.setData({ - curIndex: e.currentTarget.dataset.index - }) - } -}) \ No newline at end of file +// pages/my/help.js +const resourceUrl = 'https://openeuler-website.obs.ap-southeast-1.myhuaweicloud.com/help'; + +Page({ + /** + * 页面的初始数据 + */ + data: { + list: [ + { + name: '会议攻略', + contentImg: [resourceUrl + '/11.png', resourceUrl + '/12.png', resourceUrl + '/13.png'], + }, + { + name: '活动攻略', + contentImg: [resourceUrl + '/21.png', resourceUrl + '/22.png', resourceUrl + '/23.png'], + }, + ], + curIndex: 0, + }, + switchTab(e) { + this.setData({ + curIndex: e.currentTarget.dataset.index, + }); + }, +}); diff --git a/src/openeuler/package-my/my/my-collection.js b/src/openeuler/package-my/my/my-collection.js index a155d05..7277efc 100644 --- a/src/openeuler/package-my/my/my-collection.js +++ b/src/openeuler/package-my/my/my-collection.js @@ -1,10 +1,8 @@ -// pages/my/my-collection.js - -Page({ - - /** - * 页面的初始数据 - */ - data: { - } -}) \ No newline at end of file +// pages/my/my-collection.js + +Page({ + /** + * 页面的初始数据 + */ + data: {}, +}); diff --git a/src/openeuler/package-my/my/my-meetings.js b/src/openeuler/package-my/my/my-meetings.js index 361bc3f..acc355e 100644 --- a/src/openeuler/package-my/my/my-meetings.js +++ b/src/openeuler/package-my/my/my-meetings.js @@ -1,10 +1,8 @@ -// pages/my/my-meetings.js - -Page({ - - /** - * 页面的初始数据 - */ - data: { - } -}) \ No newline at end of file +// pages/my/my-meetings.js + +Page({ + /** + * 页面的初始数据 + */ + data: {}, +}); diff --git a/src/openeuler/package-my/my/privecy-historical.js b/src/openeuler/package-my/my/privecy-historical.js index b385a83..59441a0 100644 --- a/src/openeuler/package-my/my/privecy-historical.js +++ b/src/openeuler/package-my/my/privecy-historical.js @@ -1,48 +1,47 @@ -// pages/my/privecy.js -Page({ - /** - * 页面的初始数据 - */ - data: {}, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function () {}, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () {}, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () {}, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () {}, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () {}, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () {}, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () {}, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () {}, - }); - \ No newline at end of file +// pages/my/privecy.js +Page({ + /** + * 页面的初始数据 + */ + data: {}, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function () {}, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () {}, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () {}, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () {}, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () {}, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () {}, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () {}, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () {}, +}); diff --git a/src/openeuler/package-my/my/privecy.js b/src/openeuler/package-my/my/privecy.js index 142b35e..c90a22b 100644 --- a/src/openeuler/package-my/my/privecy.js +++ b/src/openeuler/package-my/my/privecy.js @@ -1,66 +1,42 @@ -// pages/my/privecy.js -Page({ - - /** - * 页面的初始数据 - */ - data: { - - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - - }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } -}) \ No newline at end of file +// pages/my/privecy.js +Page({ + /** + * 页面的初始数据 + */ + data: {}, + + /** + * 生命周期函数--监听页面初次渲染完成 + */ + onReady: function () {}, + + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () {}, + + /** + * 生命周期函数--监听页面隐藏 + */ + onHide: function () {}, + + /** + * 生命周期函数--监听页面卸载 + */ + onUnload: function () {}, + + /** + * 页面相关事件处理函数--监听用户下拉动作 + */ + onPullDownRefresh: function () {}, + + /** + * 页面上拉触底事件的处理函数 + */ + onReachBottom: function () {}, + + /** + * 用户点击右上角分享 + */ + onShareAppMessage: function () {}, +}); diff --git a/src/openeuler/package-my/my/qrcode.js b/src/openeuler/package-my/my/qrcode.js index 715ff69..94d4272 100644 --- a/src/openeuler/package-my/my/qrcode.js +++ b/src/openeuler/package-my/my/qrcode.js @@ -1,65 +1,64 @@ -// package-my/my/qrcode.js -const resourceUrl = 'https://openeuler-website.obs.ap-southeast-1.myhuaweicloud.com/qrcode/'; -Page({ - - /** - * 页面的初始数据 - */ - data: { - type: 0, - data: [ - { - avatar: resourceUrl + '编组.png', - name: 'openEuler', - qrcode: resourceUrl + 'openeuler公众号.png' - }, - { - avatar: resourceUrl + 'Bilibili-B站.png', - name: 'bilibili', - qrcode: resourceUrl + 'openeuler哩哩哔哔.png' - }, - { - avatar: resourceUrl + '今日头条.png', - name: '今日头条', - qrcode: resourceUrl + 'openeuler今日头条.png' - } - ] - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - this.setData({ - type: options.type - 1 - }) - }, - saveQrcode() { - const that = this; - wx.getSetting({ - success(res) { - wx.downloadFile({ - url: that.data.data[that.data.type].qrcode, - success: function(res) { - wx.saveImageToPhotosAlbum({ - filePath: res.tempFilePath, - success: function(data) { - wx.showToast({ - title: "保存成功", - icon: "success", - duration: 2000 - }); - }, - fail: function(err) { - console.log(err); - }, - complete(res) { - console.log(res); - } - }); - } - }); - } - }); - } -}) \ No newline at end of file +// package-my/my/qrcode.js +const resourceUrl = 'https://openeuler-website.obs.ap-southeast-1.myhuaweicloud.com/qrcode/'; +Page({ + /** + * 页面的初始数据 + */ + data: { + type: 0, + data: [ + { + avatar: resourceUrl + '编组.png', + name: 'openEuler', + qrcode: resourceUrl + 'openeuler公众号.png', + }, + { + avatar: resourceUrl + 'Bilibili-B站.png', + name: 'bilibili', + qrcode: resourceUrl + 'openeuler哩哩哔哔.png', + }, + { + avatar: resourceUrl + '今日头条.png', + name: '今日头条', + qrcode: resourceUrl + 'openeuler今日头条.png', + }, + ], + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.setData({ + type: options.type - 1, + }); + }, + saveQrcode() { + const that = this; + wx.getSetting({ + success() { + wx.downloadFile({ + url: that.data.data[that.data.type].qrcode, + success: function (res) { + wx.saveImageToPhotosAlbum({ + filePath: res.tempFilePath, + success: function () { + wx.showToast({ + title: '保存成功', + icon: 'success', + duration: 2000, + }); + }, + fail: function (err) { + console.log(err); + }, + complete(res) { + console.log(res); + }, + }); + }, + }); + }, + }); + }, +}); diff --git a/src/openeuler/pages/events/events.js b/src/openeuler/pages/events/events.js index 338f3c3..54f5c42 100644 --- a/src/openeuler/pages/events/events.js +++ b/src/openeuler/pages/events/events.js @@ -1,300 +1,286 @@ // pages/events/events.js const appAjax = require('./../../utils/app-ajax'); -const sessionUtil = require("../../utils/app-session.js"); -const appUser = require("../../utils/app-user.js"); +const sessionUtil = require('../../utils/app-session.js'); +const appUser = require('../../utils/app-user.js'); let that = null; let remoteMethods = { - getList: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'GET', - service: 'LATEST_EVENTS', - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - delDraft: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'DELETE', - service: 'DRAFT_DETAIL', - otherParams: { - id: that.data.curId - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - delEvent: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'PUT', - service: 'DEL_EVENT', - otherParams: { - id: that.data.curId - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - collect: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'POST', - service: 'EVENT_COLLECT', - data: { - activity: that.data.curId - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, - unCollect: function (_callback) { - appAjax.postJson({ - autoShowWait: true, - type: 'DELETE', - service: 'EVENT_UNCOLLECT', - otherParams: { - id: that.data.collectionId - }, - success: function (ret) { - _callback && _callback(ret); - } - }); - }, -} + getList: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'GET', + service: 'LATEST_EVENTS', + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + delDraft: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'DELETE', + service: 'DRAFT_DETAIL', + otherParams: { + id: that.data.curId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + delEvent: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'PUT', + service: 'DEL_EVENT', + otherParams: { + id: that.data.curId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + collect: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'POST', + service: 'EVENT_COLLECT', + data: { + activity: that.data.curId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, + unCollect: function (_callback) { + appAjax.postJson({ + autoShowWait: true, + type: 'DELETE', + service: 'EVENT_UNCOLLECT', + otherParams: { + id: that.data.collectionId, + }, + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; Page({ - - /** - * 页面的初始数据 - */ - data: { - iphoneX: false, - level: 1, - noAuthDialogShow: false, - user: '', - list: [], - actionShow: false, - actions: [], - underDialogShow: false, - showDialogDel: false, - curId: '', - userId: '', - collectionId: '', - registerId: '' - }, - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - that = this; + /** + * 页面的初始数据 + */ + data: { + iphoneX: false, + level: 1, + noAuthDialogShow: false, + user: '', + list: [], + actionShow: false, + actions: [], + underDialogShow: false, + showDialogDel: false, + curId: '', + userId: '', + collectionId: '', + registerId: '', + }, + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function () { + that = this; + this.setData({ + iphoneX: this.getTabBar().data.iPhoneX, + }); + appUser.updateUserInfo(function () { + that.setData({ + level: sessionUtil.getUserInfoByKey('eventLevel') || 1, + user: sessionUtil.getUserInfoByKey('userId'), + }); + remoteMethods.getList((res) => { + that.setData({ + list: res, + }); + }); + }); + }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + this.getTabBar().setData({ + _tabbat: 2, + }); + }, + navigateTo(e) { + const url = e.currentTarget.dataset.url; + if (url.includes('publish') && !sessionUtil.getUserInfoByKey('access')) { + wx.navigateTo({ + url: '/pages/auth/auth', + }); + return; + } + if (this.data.level === 1 && url.includes('publish')) { + this.setData({ + noAuthDialogShow: true, + }); + return; + } + wx.navigateTo({ + url, + }); + }, + copyWechat() { + wx.setClipboardData({ + data: 'openeuler123', + success: () => { this.setData({ - iphoneX: this.getTabBar().data.iPhoneX - }) - appUser.updateUserInfo(function () { - that.setData({ - level: sessionUtil.getUserInfoByKey('eventLevel') || 1, - user: sessionUtil.getUserInfoByKey('userId') - }) - remoteMethods.getList(res => { - that.setData({ - list: res - }) - - }) + noAuthDialogShow: false, + underDialogShow: false, }); - }, - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - this.getTabBar().setData({ - _tabbat: 2 - }) - }, - navigateTo(e) { - const url = e.currentTarget.dataset.url; - if (url.includes('publish') && !sessionUtil.getUserInfoByKey('access')) { - wx.navigateTo({ - url: '/pages/auth/auth' - }) - return; - } - if ((this.data.level === 1) && url.includes('publish')) { - this.setData({ - noAuthDialogShow: true - }) - return; + }, + }); + }, + onActionClose() { + this.setData({ + actionShow: false, + }); + this.getTabBar().setData({ + show: true, + }); + }, + onActionSelect(e) { + if (this.data.level == 3) { + if (e.detail.operaType == 1) { + if (this.data.collectionId) { + remoteMethods.unCollect(() => { + this.onLoad(); + }); + } else { + remoteMethods.collect(() => { + this.onLoad(); + }); } - wx.navigateTo({ - url - }) - }, - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - wx.stopPullDownRefresh(); - appUser.updateUserInfo(function () { - that.setData({ - level: sessionUtil.getUserInfoByKey('eventLevel') || 1 - }) - }); - }, - copyWechat() { - wx.setClipboardData({ - data: 'openeuler123', - success: () => { - this.setData({ - noAuthDialogShow: false, - underDialogShow: false - }) - } - }) - - }, - onActionClose() { + } else { this.setData({ - actionShow: false - }) - this.getTabBar().setData({ - show: true - }) - - }, - onActionSelect(e) { - if (this.data.level == 3) { - if (e.detail.operaType == 1) { - if (this.data.collectionId) { - remoteMethods.unCollect(() => { - this.onLoad(); - }) - } else { - remoteMethods.collect(() => { - this.onLoad(); - }) - } - } else { - this.setData({ - showDialoogDel: true - }) - } + showDialoogDel: true, + }); + } + } else { + if (e.detail.operaType == 1) { + if (this.data.collectionId) { + remoteMethods.unCollect(() => { + this.onLoad(); + }); } else { - if (e.detail.operaType == 1) { - if (this.data.collectionId) { - remoteMethods.unCollect(() => { - this.onLoad(); - }) - } else { - remoteMethods.collect(() => { - this.onLoad(); - }) - } - } else if(e.detail.operaType == 3) { - return; - } else { - this.setData({ - underDialogShow: true - }) - } + remoteMethods.collect(() => { + this.onLoad(); + }); } - }, - del() { + } else if (e.detail.operaType == 3) { + return; + } else { this.setData({ - showDialogDel: false - }) - remoteMethods.delEvent(() => { - remoteMethods.getList(res => { - this.setData({ - list: res - }) - - }); - }) - }, - delCancel() { + underDialogShow: true, + }); + } + } + }, + del() { + this.setData({ + showDialogDel: false, + }); + remoteMethods.delEvent(() => { + remoteMethods.getList((res) => { this.setData({ - showDialogDel: false - }) - }, - onMore(e) { - this.getTabBar().setData({ - show: false - }) + list: res, + }); + }); + }); + }, + delCancel() { + this.setData({ + showDialogDel: false, + }); + }, + onMore(e) { + this.getTabBar().setData({ + show: false, + }); + this.setData({ + actionShow: true, + curId: e.currentTarget.dataset.item.id, + userId: e.currentTarget.dataset.item.user, + collectionId: e.currentTarget.dataset.item.collection_id || '', + registerId: e.currentTarget.dataset.item.register_id || '', + }); + const strTemp = this.data.collectionId ? '取消收藏' : '收藏活动'; + if (this.data.level == 3) { + this.setData({ + actions: [ + { + name: strTemp, + operaType: 1, + }, + { + name: '下架活动', + operaType: 2, + }, + ], + }); + } else { + if (this.data.user == this.data.userId) { this.setData({ - actionShow: true, - curId: e.currentTarget.dataset.item.id, - userId: e.currentTarget.dataset.item.user, - collectionId: e.currentTarget.dataset.item.collection_id || '', - registerId: e.currentTarget.dataset.item.register_id || '' - }) - const strTemp = this.data.collectionId ? '取消收藏' : '收藏活动'; - if (this.data.level == 3) { - this.setData({ - actions: [{ - name: strTemp, - operaType: 1 - }, - { - name: '下架活动', - operaType: 2 - } - ] - }) - } else { - if (this.data.user == this.data.userId) { - this.setData({ - actions: [{ - name: strTemp, - operaType: 1 - }, - { - name: '下架活动', - operaType: 2 - } - ] - }) - } else { - this.setData({ - actions: [{ - name: strTemp, - operaType: 1 - }] - }) - } - - if (this.data.registerId) { - let tempArr = this.data.actions; - tempArr.unshift({ - name: '查看门票', - operaType: 3 - }) - this.setData({ - actions: tempArr - }) - } - - } + actions: [ + { + name: strTemp, + operaType: 1, + }, + { + name: '下架活动', + operaType: 2, + }, + ], + }); + } else { + this.setData({ + actions: [ + { + name: strTemp, + operaType: 1, + }, + ], + }); + } - }, - toUpdateSchedule(e) { - if (!sessionUtil.getUserInfoByKey('access')) { - wx.navigateTo({ - url: '/pages/auth/auth' - }) - return; - } - wx.navigateTo({ - url: `/package-events/events/event-detail?id=${e.currentTarget.dataset.id}&type=5` - }) - }, - onPullDownRefresh: function () { - wx.stopPullDownRefresh(); - this.onLoad(); - }, -}) \ No newline at end of file + if (this.data.registerId) { + let tempArr = this.data.actions; + tempArr.unshift({ + name: '查看门票', + operaType: 3, + }); + this.setData({ + actions: tempArr, + }); + } + } + }, + toUpdateSchedule(e) { + if (!sessionUtil.getUserInfoByKey('access')) { + wx.navigateTo({ + url: '/pages/auth/auth', + }); + return; + } + wx.navigateTo({ + url: `/package-events/events/event-detail?id=${e.currentTarget.dataset.id}&type=5`, + }); + }, + onPullDownRefresh: function () { + wx.stopPullDownRefresh(); + this.onLoad(); + }, +}); diff --git a/src/openeuler/pages/index/index.js b/src/openeuler/pages/index/index.js index 86386c9..62da5f3 100644 --- a/src/openeuler/pages/index/index.js +++ b/src/openeuler/pages/index/index.js @@ -1,104 +1,101 @@ //index.js -const mixin = require("../../utils/page-mixin.js").$pageMixin; -const sessionUtil = require("../../utils/app-session.js"); -const appUser = require("../../utils/app-user.js"); +const mixin = require('../../utils/page-mixin.js').$pageMixin; +const sessionUtil = require('../../utils/app-session.js'); +const appUser = require('../../utils/app-user.js'); let that = null; -Page(mixin({ +Page( + mixin({ data: { - imgUrls: [{ - type: 2, - url: 'https://openeuler-website-beijing.obs.cn-north-4.myhuaweicloud.com/detail-banner/mooc-banner.png' - }, ], - iphoneX: false, - meetingConponent: null, - autoplay: false + imgUrls: [ + { + type: 2, + url: 'https://openeuler-website-beijing.obs.cn-north-4.myhuaweicloud.com/detail-banner/mooc-banner.png', + }, + ], + iphoneX: false, + meetingConponent: null, + autoplay: false, }, handleContact(e) { - if (!sessionUtil.getUserInfoByKey('access')) { - wx.navigateTo({ - url: '/pages/auth/auth' - }) - return; - } + if (!sessionUtil.getUserInfoByKey('access')) { wx.navigateTo({ - url: e.currentTarget.dataset.src - }) + url: '/pages/auth/auth', + }); + return; + } + wx.navigateTo({ + url: e.currentTarget.dataset.src, + }); }, swithTab(e) { - // if (!sessionUtil.getUserInfoByKey('access')) { - // wx.navigateTo({ - // url: '/pages/auth/auth' - // }) - // return; - // } - wx.switchTab({ - url: e.currentTarget.dataset.url - }) + wx.switchTab({ + url: e.currentTarget.dataset.url, + }); }, previewImage(e) { - - const current = e.target.dataset.src //获取当前点击的 图片 url - wx.previewImage({ - current, - urls: [current] - }) + const current = e.target.dataset.src; //获取当前点击的 图片 url + wx.previewImage({ + current, + urls: [current], + }); }, onLoad: function () { - wx.showShareMenu({ - withShareTicket: true, - menus: ['shareAppMessage', 'shareTimeline'] - }) - that = this; - appUser.updateUserInfo(function () { - that.setData({ - meetingConponent: that.selectComponent('#meeting'), - iphoneX: that.getTabBar().data.iPhoneX, - }) + wx.showShareMenu({ + withShareTicket: true, + menus: ['shareAppMessage', 'shareTimeline'], + }); + that = this; + appUser.updateUserInfo(function () { + that.setData({ + meetingConponent: that.selectComponent('#meeting'), + iphoneX: that.getTabBar().data.iPhoneX, }); + }); }, onShow: function () { - this.getTabBar().setData({ - _tabbat: 0 - }); + this.getTabBar().setData({ + _tabbat: 0, + }); }, onPullDownRefresh: function () { - wx.stopPullDownRefresh(); - appUser.updateUserInfo(function () { - that.data.meetingConponent.initData(); - }); + wx.stopPullDownRefresh(); + appUser.updateUserInfo(function () { + that.data.meetingConponent.initData(); + }); }, actionStatus(e) { - if (e.detail === 1) { - this.getTabBar().setData({ - show: false - }) - } else { - this.getTabBar().setData({ - show: true - }) - } + if (e.detail === 1) { + this.getTabBar().setData({ + show: false, + }); + } else { + this.getTabBar().setData({ + show: true, + }); + } }, checkLogin() { - if (!sessionUtil.getUserInfoByKey('access')) { - wx.navigateTo({ - url: '/pages/auth/auth' - }) - return; - } + if (!sessionUtil.getUserInfoByKey('access')) { + wx.navigateTo({ + url: '/pages/auth/auth', + }); + return; + } }, play() { - this.setData({ - autoplay: false - }) + this.setData({ + autoplay: false, + }); }, pause() { - this.setData({ - autoplay: true - }) + this.setData({ + autoplay: true, + }); }, ended() { - this.setData({ - autoplay: true - }) - } -})) \ No newline at end of file + this.setData({ + autoplay: true, + }); + }, + }) +); diff --git a/src/openeuler/pages/meeting/meeting.js b/src/openeuler/pages/meeting/meeting.js index d809074..c523fa3 100644 --- a/src/openeuler/pages/meeting/meeting.js +++ b/src/openeuler/pages/meeting/meeting.js @@ -1,92 +1,92 @@ // pages/meeting/meeting.js -const mixin = require("../../utils/page-mixin.js").$pageMixin; -const sessionUtil = require("../../utils/app-session.js"); -const appUser = require("../../utils/app-user.js"); +const mixin = require('../../utils/page-mixin.js').$pageMixin; +const sessionUtil = require('../../utils/app-session.js'); +const appUser = require('../../utils/app-user.js'); let that = null; -Page(mixin({ - +Page( + mixin({ /** * 页面的初始数据 */ data: { - noAuthDialogShow: false, - iphoneX: false, - meetingConponent: null + noAuthDialogShow: false, + iphoneX: false, + meetingConponent: null, }, /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) { - this.setData({ - iphoneX: this.getTabBar().data.iPhoneX, - meetingConponent: this.selectComponent('#meeting') - }) - let that = this; + onLoad: function () { + this.setData({ + iphoneX: this.getTabBar().data.iPhoneX, + meetingConponent: this.selectComponent('#meeting'), + }); + let that = this; - appUser.updateUserInfo(function () { - that.setData({ - level: sessionUtil.getUserInfoByKey('level') - }) + appUser.updateUserInfo(function () { + that.setData({ + level: sessionUtil.getUserInfoByKey('level'), }); + }); }, /** * 生命周期函数--监听页面显示 */ onShow: function () { - that = this; - this.getTabBar().setData({ - _tabbat: 1 - }) + that = this; + this.getTabBar().setData({ + _tabbat: 1, + }); }, onPullDownRefresh: function () { - wx.stopPullDownRefresh(); - appUser.updateUserInfo(function () { - that.setData({ - level: sessionUtil.getUserInfoByKey('level') - }) - that.data.meetingConponent.initData(); + wx.stopPullDownRefresh(); + appUser.updateUserInfo(function () { + that.setData({ + level: sessionUtil.getUserInfoByKey('level'), }); + that.data.meetingConponent.initData(); + }); }, actionStatus(e) { - if (e.detail === 1) { - this.getTabBar().setData({ - show: false - }) - } else { - this.getTabBar().setData({ - show: true - }) - } + if (e.detail === 1) { + this.getTabBar().setData({ + show: false, + }); + } else { + this.getTabBar().setData({ + show: true, + }); + } }, navigateTo(e) { - const url = e.currentTarget.dataset.url; - if (url.includes('reserve') && !sessionUtil.getUserInfoByKey('access')) { - wx.navigateTo({ - url: '/pages/auth/auth' - }) - return; - } - if ((this.data.level === 1) && url.includes('reserve')) { - this.setData({ - noAuthDialogShow: true - }) - return; - } + const url = e.currentTarget.dataset.url; + if (url.includes('reserve') && !sessionUtil.getUserInfoByKey('access')) { wx.navigateTo({ - url - }) + url: '/pages/auth/auth', + }); + return; + } + if (this.data.level === 1 && url.includes('reserve')) { + this.setData({ + noAuthDialogShow: true, + }); + return; + } + wx.navigateTo({ + url, + }); }, copyWechat() { - wx.setClipboardData({ - data: 'openeuler123', - success: () => { - this.setData({ - noAuthDialogShow: false - }) - } - }) - - } -})) \ No newline at end of file + wx.setClipboardData({ + data: 'openeuler123', + success: () => { + this.setData({ + noAuthDialogShow: false, + }); + }, + }); + }, + }) +); diff --git a/src/openeuler/pages/my/my.js b/src/openeuler/pages/my/my.js index 74d7722..99e31e7 100644 --- a/src/openeuler/pages/my/my.js +++ b/src/openeuler/pages/my/my.js @@ -1,82 +1,78 @@ // pages/my/my.js const appAjax = require('./../../utils/app-ajax'); -const sessionUtil = require("../../utils/app-session.js"); -let that = this; +const sessionUtil = require('../../utils/app-session.js'); let remoteMethods = { - getMyCount: function (_callback) { - appAjax.postJson({ - type: 'GET', - service: 'GET_MY_COUNT', - success: function (ret) { - _callback && _callback(ret); - } - }); - } -} + getMyCount: function (_callback) { + appAjax.postJson({ + type: 'GET', + service: 'GET_MY_COUNT', + success: function (ret) { + _callback && _callback(ret); + }, + }); + }, +}; Page({ + /** + * 页面的初始数据 + */ + data: { + iphoneX: false, + avatarUrl: '', + nickName: '', + level: 1, + avtivityLevel: 1, + myCount: {}, + userId: '', + }, - /** - * 页面的初始数据 - */ - data: { - iphoneX: false, - avatarUrl: '', - nickName: '', - level: 1, - avtivityLevel: 1, - myCount: {}, - userId:'' - }, - - /** - * 生命周期函数--监听页面加载 - */ - onLoad: function (options) { - that = this; - this.setData({ - iphoneX: this.getTabBar().data.iPhoneX, - avatarUrl: sessionUtil.getUserInfoByKey('avatarUrl'), - nickName: sessionUtil.getUserInfoByKey('nickName'), - level: sessionUtil.getUserInfoByKey('level'), - userId:sessionUtil.getUserInfoByKey('userId'), - avtivityLevel: sessionUtil.getUserInfoByKey('eventLevel') - }) - remoteMethods.getMyCount(res => { - this.setData({ - myCount: res - }) - }) - }, - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - this.getTabBar().setData({ - _tabbat: 3 - }) - - }, - go(e) { - wx.navigateTo({ - url: e.currentTarget.dataset.url - }) - }, - copy: function (e) { - wx.setClipboardData({ - data:`${ e.currentTarget.dataset.copy}`, - success: function () {}, - fail:function (err) { - console.log(err); - } - }); + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function () { + this.setData({ + iphoneX: this.getTabBar().data.iPhoneX, + avatarUrl: sessionUtil.getUserInfoByKey('avatarUrl'), + nickName: sessionUtil.getUserInfoByKey('nickName'), + level: sessionUtil.getUserInfoByKey('level'), + userId: sessionUtil.getUserInfoByKey('userId'), + avtivityLevel: sessionUtil.getUserInfoByKey('eventLevel'), + }); + remoteMethods.getMyCount((res) => { + this.setData({ + myCount: res, + }); + }); + }, + /** + * 生命周期函数--监听页面显示 + */ + onShow: function () { + this.getTabBar().setData({ + _tabbat: 3, + }); + }, + go(e) { + wx.navigateTo({ + url: e.currentTarget.dataset.url, + }); + }, + copy: function (e) { + wx.setClipboardData({ + data: `${e.currentTarget.dataset.copy}`, + success: function () {}, + fail: function (err) { + console.log(err); }, - onPullDownRefresh() { - wx.stopPullDownRefresh(); - remoteMethods.getMyCount(res => { - this.setData({ - myCount: res - }) - }) - }, -}) \ No newline at end of file + }); + }, + onPullDownRefresh() { + wx.stopPullDownRefresh(); + remoteMethods.getMyCount((res) => { + this.setData({ + myCount: res, + }); + }); + }, +}); diff --git a/src/openeuler/utils/app-ajax.js b/src/openeuler/utils/app-ajax.js index ae82cb9..d5339c4 100644 --- a/src/openeuler/utils/app-ajax.js +++ b/src/openeuler/utils/app-ajax.js @@ -9,26 +9,26 @@ const CONSTANTS = require('../config/constants.js'); /* 基础通信参数 */ const _authClient = function () { - const deviceId = "miniprogram"; + const deviceId = 'miniprogram'; - const auth = { - authParams: { - timestamp: new Date().getTime(), - deviceId: deviceId, - }, - clientParams: { - os: "mini", - network: "", - deviceId: deviceId, - appVersion: CONSTANTS.APP_VERSION - }, - openId: appSession.getUserInfoByKey("openId") || '', - appId: CONSTANTS.APP_ID, - areaCode: CONSTANTS.AREA_CODE, - miniId: CONSTANTS.MINI_ID - }; + const auth = { + authParams: { + timestamp: new Date().getTime(), + deviceId: deviceId, + }, + clientParams: { + os: 'mini', + network: '', + deviceId: deviceId, + appVersion: CONSTANTS.APP_VERSION, + }, + openId: appSession.getUserInfoByKey('openId') || '', + appId: CONSTANTS.APP_ID, + areaCode: CONSTANTS.AREA_CODE, + miniId: CONSTANTS.MINI_ID, + }; - return auth; + return auth; }; /** @@ -36,155 +36,156 @@ const _authClient = function () { * @param {Object} params */ const _getInterfaceUrl = function (params) { - let interfaceUrl; - if (!params.otherParams) { - return servicesConfig[params["service"]]; - } - for (let key in params.otherParams) { - interfaceUrl = (interfaceUrl || servicesConfig[params["service"]]).replace("{" + key + "}", params.otherParams[key]); - } - - return interfaceUrl; + let interfaceUrl; + if (!params.otherParams) { + return servicesConfig[params['service']]; + } + for (let key in params.otherParams) { + interfaceUrl = (interfaceUrl || servicesConfig[params['service']]).replace( + '{' + key + '}', + params.otherParams[key] + ); + } + + return interfaceUrl; }; const _addUrlParam = function (data) { - - let postData = ""; - for (let key in data) { - if (!postData) { - postData = "?" + key + "=" + data[key]; - } else { - postData += "&" + key + "=" + data[key]; - } + let postData = ''; + for (let key in data) { + if (!postData) { + postData = '?' + key + '=' + data[key]; + } else { + postData += '&' + key + '=' + data[key]; } + } - return postData; + return postData; }; const appAjax = { + /** + * 提交请求 + * @param {Object} options + * service: "" // 接口名 + * data: "", // 请求参数 + * otherParams: "", // 通过url传递的参数 + * type : "", // 请求类型 + * success: "", // 成功回调 + * error: "", // 失败回调 + * complete: "" // 完成回调 + */ + postJson: function (params) { + let authClient = _authClient(); + + // 默认参数 + let defaultParams = { + service: '', // 服务的配置名称 + success: function (d) {}, // 成功后回调 + error: null, // 失败后回调 + autoShowWait: false, // 自动显示菊花 + loadingText: '加载中...', // 加载的提示语 + autoCloseWait: true, // 自动关闭菊花 + headers: { + 'base-params': JSON.stringify(authClient), + Authorization: appSession.getToken() ? 'Bearer ' + appSession.getToken() : '', + }, + isAsync: true, + }; + let ajaxParams = underscore.deepExtend(true, defaultParams, params); + // rest请求路径 + ajaxParams['url'] = CONSTANTS['SERVICE_URL'] + _getInterfaceUrl(ajaxParams); + if ( + (ajaxParams.type == 'GET' || ajaxParams.type == 'DELETE') && + ajaxParams.data && + typeof ajaxParams.data == 'object' + ) { + ajaxParams['url'] = ajaxParams['url'] + _addUrlParam(ajaxParams.data); + } - /** - * 提交请求 - * @param {Object} options - * service: "" // 接口名 - * data: "", // 请求参数 - * otherParams: "", // 通过url传递的参数 - * type : "", // 请求类型 - * success: "", // 成功回调 - * error: "", // 失败回调 - * complete: "" // 完成回调 - */ - postJson: function (params) { - - let authClient = _authClient(); - - // 默认参数 - let defaultParams = { - service: "", // 服务的配置名称 - success: function (d) {}, // 成功后回调 - error: null, // 失败后回调 - autoShowWait: false, // 自动显示菊花 - loadingText: "加载中...", // 加载的提示语 - autoCloseWait: true, // 自动关闭菊花 - headers: { - "base-params": JSON.stringify(authClient), - "Authorization": appSession.getToken() ? ("Bearer " + appSession.getToken()) : "" - }, - isAsync: true - }; - let ajaxParams = underscore.deepExtend(true, defaultParams, params); - // rest请求路径 - ajaxParams["url"] = CONSTANTS["SERVICE_URL"] + _getInterfaceUrl(ajaxParams); - if ((ajaxParams.type == "GET" || ajaxParams.type == "DELETE") && ajaxParams.data && typeof (ajaxParams.data) == "object") { - ajaxParams["url"] = ajaxParams["url"] + _addUrlParam(ajaxParams.data); + // 是否展示loading + if (ajaxParams.autoShowWait && wx.showLoading) { + wx.showLoading({ + title: ajaxParams.loadingText, + mask: true, + }); + } + wx.request({ + url: ajaxParams.url, + header: ajaxParams.headers, + method: ajaxParams['type'] || 'POST', + data: ajaxParams.data, + success: function (res) { + if (res?.data?.access && wx.getStorageSync(CONSTANTS.APP_USERINFO_SESSION)) { + let data = wx.getStorageSync(CONSTANTS.APP_USERINFO_SESSION); + data.access = res.data.access; + wx.setStorageSync(CONSTANTS.APP_USERINFO_SESSION, data); } - - - - // 是否展示loading - if (ajaxParams.autoShowWait && wx.showLoading) { - wx.showLoading({ - title: ajaxParams.loadingText, - mask: true + if (res.statusCode === 401) { + wx.removeStorageSync('_app_userinfo_session'); + ajaxParams.success(0, res); + wx.navigateTo({ + url: '/pages/auth/auth', + }); + return; + } + if (res.statusCode.toString()[0] != 2) { + let message = '有点忙开个小差,稍后再试~'; + if (ajaxParams.error) { + ajaxParams.error(message, res); + } else { + wx.showToast({ + title: message, + icon: 'none', + duration: 2000, }); + } + return; } - wx.request({ - url: ajaxParams.url, - header: ajaxParams.headers, - method: ajaxParams['type'] || 'POST', - data: ajaxParams.data, - success: function (res) { - if (res?.data?.access && wx.getStorageSync(CONSTANTS.APP_USERINFO_SESSION)) { - let data = wx.getStorageSync(CONSTANTS.APP_USERINFO_SESSION); - data.access = res.data.access; - wx.setStorageSync(CONSTANTS.APP_USERINFO_SESSION, data); - } - if (res.statusCode === 401) { - wx.removeStorageSync('_app_userinfo_session'); - ajaxParams.success(0, res); - wx.navigateTo({ - url: '/pages/auth/auth', - }); - return; - } - if (res.statusCode.toString()[0] != 2) { - let message = '有点忙开个小差,稍后再试~'; - if (ajaxParams.error) { - ajaxParams.error(message, res); - } else { - wx.showToast({ - title: message, - icon: 'none', - duration: 2000, - }); - } - return; - } - ajaxParams.success(res.data, res); - }, - fail: function (res) { - if (res?.data?.access) { - if (res.data.access && wx.getStorageSync(CONSTANTS.APP_USERINFO_SESSION)) { - let data = wx.getStorageSync(CONSTANTS.APP_USERINFO_SESSION); - data.access = res.data.access; - wx.setStorageSync(CONSTANTS.APP_USERINFO_SESSION, data); - } - } - let message = '有点忙开个小差,稍后再试~'; - ajaxParams.error && ajaxParams.error(message, res); - }, - complete: function (res) { - if (!res.errMsg.includes('ok')) { - wx.showToast({ - title: res.errMsg, - icon: 'none', - duration: 2000, - }); - } - // 关闭loading - if (ajaxParams.autoShowWait && wx.hideLoading) { - wx.hideLoading(); - } - }, - }); - - }, - - /** - * 上下拉 - */ - datalistParam: function () { - return { - lastdate: 0, - pageSize: 20, - type: "DOWN" // DOWN UP - }; - }, + ajaxParams.success(res.data, res); + }, + fail: function (res) { + if (res?.data?.access) { + if (res.data.access && wx.getStorageSync(CONSTANTS.APP_USERINFO_SESSION)) { + let data = wx.getStorageSync(CONSTANTS.APP_USERINFO_SESSION); + data.access = res.data.access; + wx.setStorageSync(CONSTANTS.APP_USERINFO_SESSION, data); + } + } + let message = '有点忙开个小差,稍后再试~'; + ajaxParams.error && ajaxParams.error(message, res); + }, + complete: function (res) { + if (!res.errMsg.includes('ok')) { + wx.showToast({ + title: res.errMsg, + icon: 'none', + duration: 2000, + }); + } + // 关闭loading + if (ajaxParams.autoShowWait && wx.hideLoading) { + wx.hideLoading(); + } + }, + }); + }, + + /** + * 上下拉 + */ + datalistParam: function () { + return { + lastdate: 0, + pageSize: 20, + type: 'DOWN', // DOWN UP + }; + }, - // 下拉 - scrollDown: "DOWN", - // 上拉 - scrollUp: "UP" + // 下拉 + scrollDown: 'DOWN', + // 上拉 + scrollUp: 'UP', }; -module.exports = appAjax; \ No newline at end of file +module.exports = appAjax; diff --git a/src/openeuler/utils/app-user.js b/src/openeuler/utils/app-user.js index a3d41d7..0a66b85 100644 --- a/src/openeuler/utils/app-user.js +++ b/src/openeuler/utils/app-user.js @@ -3,25 +3,6 @@ const appSession = require('./app-session.js'); const constants = require('../config/constants'); const app = getApp(); -const remote = { - /** - * 绑定手机 - * @param {Object} phone - * @param {Object} _callback - */ - _bindUserPhone: function (phone, _callback) { - appAjax.postJson({ - service: 'BIND_PHONE', - data: { - phone: phone, - }, - success: function (ret) { - _callback && _callback(ret); - }, - }); - }, -}; - const privateMethods = { /** * 登录 @@ -123,8 +104,6 @@ const appUser = { } }, - bindPhone: remote._bindUserPhone, - /** * 登录 * @param {Object} successCallback @@ -149,22 +128,6 @@ const appUser = { }); }, - /** - * 退出登录 - */ - logOut: function (callback) { - wx.showModal({ - title: '', - content: '确定要退出您的账号?', - success: function (res) { - if (res.confirm) { - appSession.clearUserInfo(); - callback && callback(); - } - }, - }); - }, - /** * 微信登录 * @param {Object} callback diff --git a/src/openeuler/utils/page-mixin.js b/src/openeuler/utils/page-mixin.js index 9e5b39b..6c3c5bf 100644 --- a/src/openeuler/utils/page-mixin.js +++ b/src/openeuler/utils/page-mixin.js @@ -1,6 +1,5 @@ /** * 页面通用方法 - * author xzx * since 2020-8-20 */ diff --git a/src/openeuler/utils/underscore-extend.js b/src/openeuler/utils/underscore-extend.js index af75d3d..86c6d26 100644 --- a/src/openeuler/utils/underscore-extend.js +++ b/src/openeuler/utils/underscore-extend.js @@ -1,10 +1,12 @@ -/** - * underscore扩展方法 - */ +function isObject(obj) { + return obj !== null && typeof obj === 'object' && !Array.isArray(obj); +} -let _ = require('./underscore.js'); - -_.mixin({ +// 实现 isArray 方法 +function isArray(obj) { + return Array.isArray(obj); +} +const _ = { /** * 对象深拷贝 */ @@ -13,12 +15,12 @@ _.mixin({ args = [].slice.call(arguments, 1); let extend = function (target, source, deep) { - let isArray = _.isArray; + // let isArray = _.isArray; let isWindow = function (obj) { return obj != null && obj == obj.window; }; let isPlainObject = function (obj) { - return _.isObject(obj) && !isWindow(obj) && obj.__proto__ == Object.prototype; + return isObject(obj) && !isWindow(obj) && obj.__proto__ == Object.prototype; }; for (let key in source) { //如果深度扩展 @@ -44,6 +46,6 @@ _.mixin({ }); return target; }, -}); +}; module.exports = _; diff --git a/src/openeuler/utils/underscore.js b/src/openeuler/utils/underscore.js deleted file mode 100644 index 2ebe814..0000000 --- a/src/openeuler/utils/underscore.js +++ /dev/null @@ -1,6 +0,0 @@ -// Underscore.js 1.8.2 -// http://underscorejs.org -// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors -// Underscore may be freely distributed under the MIT license. -(function(){function n(n){function t(t,r,e,u,i,o){for(;i>=0&&o>i;i+=n){var a=u?u[i]:i;e=r(e,t[a],a,t)}return e}return function(r,e,u,i){e=d(e,i,4);var o=!w(r)&&m.keys(r),a=(o||r).length,c=n>0?0:a-1;return arguments.length<3&&(u=r[o?o[c]:c],c+=n),t(r,e,u,o,c,a)}}function t(n){return function(t,r,e){r=b(r,e);for(var u=null!=t&&t.length,i=n>0?0:u-1;i>=0&&u>i;i+=n)if(r(t[i],i,t))return i;return-1}}function r(n,t){var r=S.length,e=n.constructor,u=m.isFunction(e)&&e.prototype||o,i="constructor";for(m.has(n,i)&&!m.contains(t,i)&&t.push(i);r--;)i=S[r],i in n&&n[i]!==u[i]&&!m.contains(t,i)&&t.push(i)}var e=this,u=e._,i=Array.prototype,o=Object.prototype,a=Function.prototype,c=i.push,l=i.slice,f=o.toString,s=o.hasOwnProperty,p=Array.isArray,h=Object.keys,v=a.bind,g=Object.create,y=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=m),exports._=m):e._=m,m.VERSION="1.8.2";var d=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}},b=function(n,t,r){return null==n?m.identity:m.isFunction(n)?d(n,t,r):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return b(n,t,1/0)};var x=function(n,t){return function(r){var e=arguments.length;if(2>e||null==r)return r;for(var u=1;e>u;u++)for(var i=arguments[u],o=n(i),a=o.length,c=0;a>c;c++){var l=o[c];t&&r[l]!==void 0||(r[l]=i[l])}return r}},_=function(n){if(!m.isObject(n))return{};if(g)return g(n);y.prototype=n;var t=new y;return y.prototype=null,t},j=Math.pow(2,53)-1,w=function(n){var t=n&&n.length;return"number"==typeof t&&t>=0&&j>=t};m.each=m.forEach=function(n,t,r){t=d(t,r);var e,u;if(w(n))for(e=0,u=n.length;u>e;e++)t(n[e],e,n);else{var i=m.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},m.map=m.collect=function(n,t,r){t=b(t,r);for(var e=!w(n)&&m.keys(n),u=(e||n).length,i=Array(u),o=0;u>o;o++){var a=e?e[o]:o;i[o]=t(n[a],a,n)}return i},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,r){var e;return e=w(n)?m.findIndex(n,t,r):m.findKey(n,t,r),e!==void 0&&e!==-1?n[e]:void 0},m.filter=m.select=function(n,t,r){var e=[];return t=b(t,r),m.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e},m.reject=function(n,t,r){return m.filter(n,m.negate(b(t)),r)},m.every=m.all=function(n,t,r){t=b(t,r);for(var e=!w(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,r){t=b(t,r);for(var e=!w(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,r){return w(n)||(n=m.values(n)),m.indexOf(n,t,"number"==typeof r&&r)>=0},m.invoke=function(n,t){var r=l.call(arguments,2),e=m.isFunction(t);return m.map(n,function(n){var u=e?t:n[t];return null==u?u:u.apply(n,r)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,r){var e,u,i=-1/0,o=-1/0;if(null==t&&null!=n){n=w(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],e>i&&(i=e)}else t=b(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(u>o||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},m.min=function(n,t,r){var e,u,i=1/0,o=1/0;if(null==t&&null!=n){n=w(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],i>e&&(i=e)}else t=b(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(o>u||1/0===u&&1/0===i)&&(i=n,o=u)});return i},m.shuffle=function(n){for(var t,r=w(n)?n:m.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=m.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},m.sample=function(n,t,r){return null==t||r?(w(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,r){return t=b(t,r),m.pluck(m.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var A=function(n){return function(t,r,e){var u={};return r=b(r,e),m.each(t,function(e,i){var o=r(e,i,t);n(u,e,o)}),u}};m.groupBy=A(function(n,t,r){m.has(n,r)?n[r].push(t):n[r]=[t]}),m.indexBy=A(function(n,t,r){n[r]=t}),m.countBy=A(function(n,t,r){m.has(n,r)?n[r]++:n[r]=1}),m.toArray=function(n){return n?m.isArray(n)?l.call(n):w(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:w(n)?n.length:m.keys(n).length},m.partition=function(n,t,r){t=b(t,r);var e=[],u=[];return m.each(n,function(n,r,i){(t(n,r,i)?e:u).push(n)}),[e,u]},m.first=m.head=m.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,r){return l.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},m.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,r){return l.call(n,null==t||r?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var k=function(n,t,r,e){for(var u=[],i=0,o=e||0,a=n&&n.length;a>o;o++){var c=n[o];if(w(c)&&(m.isArray(c)||m.isArguments(c))){t||(c=k(c,t,r));var l=0,f=c.length;for(u.length+=f;f>l;)u[i++]=c[l++]}else r||(u[i++]=c)}return u};m.flatten=function(n,t){return k(n,t,!1)},m.without=function(n){return m.difference(n,l.call(arguments,1))},m.uniq=m.unique=function(n,t,r,e){if(null==n)return[];m.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=b(r,e));for(var u=[],i=[],o=0,a=n.length;a>o;o++){var c=n[o],l=r?r(c,o,n):c;t?(o&&i===l||u.push(c),i=l):r?m.contains(i,l)||(i.push(l),u.push(c)):m.contains(u,c)||u.push(c)}return u},m.union=function(){return m.uniq(k(arguments,!0,!0))},m.intersection=function(n){if(null==n)return[];for(var t=[],r=arguments.length,e=0,u=n.length;u>e;e++){var i=n[e];if(!m.contains(t,i)){for(var o=1;r>o&&m.contains(arguments[o],i);o++);o===r&&t.push(i)}}return t},m.difference=function(n){var t=k(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,"length").length||0,r=Array(t),e=0;t>e;e++)r[e]=m.pluck(n,e);return r},m.object=function(n,t){for(var r={},e=0,u=n&&n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},m.indexOf=function(n,t,r){var e=0,u=n&&n.length;if("number"==typeof r)e=0>r?Math.max(0,u+r):r;else if(r&&u)return e=m.sortedIndex(n,t),n[e]===t?e:-1;if(t!==t)return m.findIndex(l.call(n,e),m.isNaN);for(;u>e;e++)if(n[e]===t)return e;return-1},m.lastIndexOf=function(n,t,r){var e=n?n.length:0;if("number"==typeof r&&(e=0>r?e+r+1:Math.min(e,r+1)),t!==t)return m.findLastIndex(l.call(n,0,e),m.isNaN);for(;--e>=0;)if(n[e]===t)return e;return-1},m.findIndex=t(1),m.findLastIndex=t(-1),m.sortedIndex=function(n,t,r,e){r=b(r,e,1);for(var u=r(t),i=0,o=n.length;o>i;){var a=Math.floor((i+o)/2);r(n[a])i;i++,n+=r)u[i]=n;return u};var O=function(n,t,r,e,u){if(!(e instanceof t))return n.apply(r,u);var i=_(n.prototype),o=n.apply(i,u);return m.isObject(o)?o:i};m.bind=function(n,t){if(v&&n.bind===v)return v.apply(n,l.call(arguments,1));if(!m.isFunction(n))throw new TypeError("Bind must be called on a function");var r=l.call(arguments,2),e=function(){return O(n,e,t,this,r.concat(l.call(arguments)))};return e},m.partial=function(n){var t=l.call(arguments,1),r=function(){for(var e=0,u=t.length,i=Array(u),o=0;u>o;o++)i[o]=t[o]===m?arguments[e++]:t[o];for(;e=e)throw new Error("bindAll must be passed function names");for(t=1;e>t;t++)r=arguments[t],n[r]=m.bind(n[r],n);return n},m.memoize=function(n,t){var r=function(e){var u=r.cache,i=""+(t?t.apply(this,arguments):e);return m.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},m.delay=function(n,t){var r=l.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,r){var e,u,i,o=null,a=0;r||(r={});var c=function(){a=r.leading===!1?0:m.now(),o=null,i=n.apply(e,u),o||(e=u=null)};return function(){var l=m.now();a||r.leading!==!1||(a=l);var f=t-(l-a);return e=this,u=arguments,0>=f||f>t?(o&&(clearTimeout(o),o=null),a=l,i=n.apply(e,u),o||(e=u=null)):o||r.trailing===!1||(o=setTimeout(c,f)),i}},m.debounce=function(n,t,r){var e,u,i,o,a,c=function(){var l=m.now()-o;t>l&&l>=0?e=setTimeout(c,t-l):(e=null,r||(a=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,o=m.now();var l=r&&!e;return e||(e=setTimeout(c,t)),l&&(a=n.apply(i,u),i=u=null),a}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},m.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},m.before=function(n,t){var r;return function(){return--n>0&&(r=t.apply(this,arguments)),1>=n&&(t=null),r}},m.once=m.partial(m.before,2);var F=!{toString:null}.propertyIsEnumerable("toString"),S=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];m.keys=function(n){if(!m.isObject(n))return[];if(h)return h(n);var t=[];for(var e in n)m.has(n,e)&&t.push(e);return F&&r(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var e in n)t.push(e);return F&&r(n,t),t},m.values=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},m.mapObject=function(n,t,r){t=b(t,r);for(var e,u=m.keys(n),i=u.length,o={},a=0;i>a;a++)e=u[a],o[e]=t(n[e],e,n);return o},m.pairs=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},m.invert=function(n){for(var t={},r=m.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},m.functions=m.methods=function(n){var t=[];for(var r in n)m.isFunction(n[r])&&t.push(r);return t.sort()},m.extend=x(m.allKeys),m.extendOwn=m.assign=x(m.keys),m.findKey=function(n,t,r){t=b(t,r);for(var e,u=m.keys(n),i=0,o=u.length;o>i;i++)if(e=u[i],t(n[e],e,n))return e},m.pick=function(n,t,r){var e,u,i={},o=n;if(null==o)return i;m.isFunction(t)?(u=m.allKeys(o),e=d(t,r)):(u=k(arguments,!1,!1,1),e=function(n,t,r){return t in r},o=Object(o));for(var a=0,c=u.length;c>a;a++){var l=u[a],f=o[l];e(f,l,o)&&(i[l]=f)}return i},m.omit=function(n,t,r){if(m.isFunction(t))t=m.negate(t);else{var e=m.map(k(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(e,t)}}return m.pick(n,t,r)},m.defaults=x(m.allKeys,!0),m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var r=m.keys(t),e=r.length;if(null==n)return!e;for(var u=Object(n),i=0;e>i;i++){var o=r[i];if(t[o]!==u[o]||!(o in u))return!1}return!0};var E=function(n,t,r,e){if(n===t)return 0!==n||1/n===1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var u=f.call(n);if(u!==f.call(t))return!1;switch(u){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!==+n?+t!==+t:0===+n?1/+n===1/t:+n===+t;case"[object Date]":case"[object Boolean]":return+n===+t}var i="[object Array]"===u;if(!i){if("object"!=typeof n||"object"!=typeof t)return!1;var o=n.constructor,a=t.constructor;if(o!==a&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(a)&&a instanceof a)&&"constructor"in n&&"constructor"in t)return!1}r=r||[],e=e||[];for(var c=r.length;c--;)if(r[c]===n)return e[c]===t;if(r.push(n),e.push(t),i){if(c=n.length,c!==t.length)return!1;for(;c--;)if(!E(n[c],t[c],r,e))return!1}else{var l,s=m.keys(n);if(c=s.length,m.keys(t).length!==c)return!1;for(;c--;)if(l=s[c],!m.has(t,l)||!E(n[l],t[l],r,e))return!1}return r.pop(),e.pop(),!0};m.isEqual=function(n,t){return E(n,t)},m.isEmpty=function(n){return null==n?!0:w(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=p||function(n){return"[object Array]"===f.call(n)},m.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},m.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(n){m["is"+n]=function(t){return f.call(t)==="[object "+n+"]"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(m.isFunction=function(n){return"function"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"===f.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return n===void 0},m.has=function(n,t){return null!=n&&s.call(n,t)},m.noConflict=function(){return e._=u,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=function(n){return function(t){return null==t?void 0:t[n]}},m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,r){var e=Array(Math.max(0,n));t=d(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var M={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},N=m.invert(M),I=function(n){var t=function(t){return n[t]},r="(?:"+m.keys(n).join("|")+")",e=RegExp(r),u=RegExp(r,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,t):n}};m.escape=I(M),m.unescape=I(N),m.result=function(n,t,r){var e=null==n?void 0:n[t];return e===void 0&&(e=r),m.isFunction(e)?e.call(n):e};var B=0;m.uniqueId=function(n){var t=++B+"";return n?n+t:t},m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var T=/(.)^/,R={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},q=/\\|'|\r|\n|\u2028|\u2029/g,K=function(n){return"\\"+R[n]};m.template=function(n,t,r){!t&&r&&(t=r),t=m.defaults({},t,m.templateSettings);var e=RegExp([(t.escape||T).source,(t.interpolate||T).source,(t.evaluate||T).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,o,a){return i+=n.slice(u,a).replace(q,K),u=a+t.length,r?i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":e?i+="'+\n((__t=("+e+"))==null?'':__t)+\n'":o&&(i+="';\n"+o+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var o=new Function(t.variable||"obj","_",i)}catch(a){throw a.source=i,a}var c=function(n){return o.call(this,n,m)},l=t.variable||"obj";return c.source="function("+l+"){\n"+i+"}",c},m.chain=function(n){var t=m(n);return t._chain=!0,t};var z=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var r=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return c.apply(n,arguments),z(this,r.apply(m,n))}})},m.mixin(m),m.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=i[n];m.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==n&&"splice"!==n||0!==r.length||delete r[0],z(this,r)}}),m.each(["concat","join","slice"],function(n){var t=i[n];m.prototype[n]=function(){return z(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return m})}).call(this || module.exports); -//# sourceMappingURL=underscore-min.map \ No newline at end of file diff --git a/src/openeuler/utils/utils.js b/src/openeuler/utils/utils.js index d34cdfc..0ed2cb7 100644 --- a/src/openeuler/utils/utils.js +++ b/src/openeuler/utils/utils.js @@ -15,139 +15,6 @@ let utils = { */ deepExtend: _.deepExtend, - /** - * 获取时间差(小于一天) - * @param {Object} startTime 开始时间 long 毫秒数 - * @param {Object} endTime 结束时间 long 毫秒数 - * return { - * "days" : days, - * "hours" : hours, - * "minutes" : minutes, - * "seconds" : seconds - * } - */ - getDiffTime: function (startTime, endTime) { - // 相差时间 - let diffTime = endTime - startTime; - if (diffTime <= 0) { - return false; - } - // 计算出相差天数 - let days = Math.floor(diffTime / (24 * 3600 * 1000)); - // 计算出小时数 - let leave1 = diffTime % (24 * 3600 * 1000); //计算天数后剩余的毫秒数 - let hours = Math.floor(leave1 / (3600 * 1000)); - // 计算相差分钟数 - let leave2 = leave1 % (3600 * 1000); //计算小时数后剩余的毫秒数 - let minutes = Math.floor(leave2 / (60 * 1000)); - // 计算相差秒数 - let leave3 = leave2 % (60 * 1000); //计算分钟数后剩余的毫秒数 - let seconds = Math.round(leave3 / 1000); - - return { - days: days, - hours: hours, - minutes: minutes, - seconds: seconds, - }; - }, - - /** - * 返回定时器格式(若天和小时为0则隐藏天和小时) - * @param {Object} time - */ - getTiktokStr: function (time) { - let str = time.seconds + '秒'; - if (time.days != 0) { - str = time.days + '天' + time.hours + '小时' + time.minutes + '分钟' + str; - } else if (time.hours != 0) { - str = time.hours + '小时' + time.minutes + '分钟' + str; - } else if (time.minutes != 0) { - str = time.minutes + '分钟' + str; - } - return str; - }, - - /** - * 倒计时方法 - * @param {Object} startTime long 开始时间 - * @param {Object} endTime long 结束时间 - * @param {Object} renderFunc 回调渲染函数 - * @param {Object} endFunc 倒计时结束回调函数 - */ - intervalTime: function (startTime, endTime, renderFunc, endFunc) { - if (!startTime || !endTime) { - return; - } - startTime = parseInt(startTime); - endTime = parseInt(endTime); - - let that = this; - - let diffTime = that.getDiffTime(startTime, endTime); - diffTime = that.getTiktokStr(diffTime); - renderFunc && renderFunc(diffTime); - startTime += 1000; - - let interval = setInterval(function () { - diffTime = that.getDiffTime(startTime, endTime); - if (diffTime) { - startTime += 1000; - diffTime = that.getTiktokStr(diffTime); - renderFunc && renderFunc(diffTime); - } else { - clearInterval(interval); - endFunc && endFunc(); - } - }, 1000); - }, - - /** - * 判断对象是否为空 - */ - isEmptyObject: function (obj) { - let t; - for (t in obj) { - return false; - } - return true; - }, - - /** - * 获取当前页面url - */ - getCurrentUrl: function () { - let pageStack = getCurrentPages(); - let thisPage = pageStack[pageStack.length - 1]; - - let baseUrl = thisPage.route; - let paramObj = thisPage.options; - let params = ''; - - if (this.isEmptyObject(paramObj)) { - return baseUrl; - } else { - for (let i in paramObj) { - if (params.indexOf('?') >= 0) { - params += '&'; - } else { - params += '?'; - } - params += i + '=' + paramObj[i]; - } - } - - return baseUrl + params; - }, - - /** - * 替换html特殊字符串 - */ - replaceHtmlString: function (str) { - str = str.replace(/ /g, ' '); - return str; - }, - /** * 添加URL的参数 * @param name 名称 @@ -233,42 +100,6 @@ let utils = { return 0; }, - - /** - * 静态资源定时清理缓存用的后缀 - */ - resourceSuffix: function () { - let randomStr = '?' + new Date().getTime().toString().slice(0, 7) + '000000'; - return randomStr; - }, - - /** - * 资讯跳转方法(文章、图集) - * @param {Object} options - * jumpType:跳转方法名, - * infoType:资讯类型1文章 2图集 3视频 4链接(不支持), - * id:资讯详情id - */ - jumpToInfo: function (options) { - let id = options.id ? options.id : ''; - let type = options.infoType ? options.infoType : 1; - let jumpType = - options.jumpType && options.jumpType in wx && typeof wx[options.jumpType] == 'function' - ? options.jumpType - : 'navigateTo'; - - // 1文章 2图集 3视频 4链接(不支持) - let infoConfig = { - 1: '/pages/discovery/info', - 2: '/pages/discovery/picture-info', - }; - - let path = type in infoConfig ? infoConfig[type] + '?id=' + id : infoConfig[1] + '?id=' + id; - - wx[jumpType]({ - url: path, - }); - }, }; module.exports = utils; diff --git a/src/openeuler/utils/wx-validate.js b/src/openeuler/utils/wx-validate.js deleted file mode 100644 index 36d069d..0000000 --- a/src/openeuler/utils/wx-validate.js +++ /dev/null @@ -1,417 +0,0 @@ -/** - * 表单验证 - * @param {Object} rules 验证字段的规则 - * @param {Object} messages 验证字段的提示信息 - */ - -class WxValidate { - constructor(rules = {}, messages = {}) { - Object.assign(this, { - data: {}, - rules, - messages, - }) - this.__init() - } - - /** - * __init - */ - __init() { - this.__initMethods() - this.__initDefaults() - this.__initData() - } - - /** - * 初始化数据 - */ - __initData() { - this.form = {} - this.errorList = [] - } - - /** - * 初始化默认提示信息 - */ - __initDefaults() { - this.defaults = { - messages: { - required: '这是必填字段。', - email: '请输入有效的电子邮件地址。', - tel: '请输入11位的手机号码。', - url: '请输入有效的网址。', - date: '请输入有效的日期。', - dateISO: '请输入有效的日期(ISO),例如:2009-06-23,1998/01/22。', - number: '请输入有效的数字。', - digits: '只能输入数字。', - idcard: '请输入18位的有效身份证。', - equalTo: this.formatTpl('输入值必须和 {0} 相同。'), - contains: this.formatTpl('输入值必须包含 {0}。'), - minlength: this.formatTpl('最少要输入 {0} 个字符。'), - maxlength: this.formatTpl('最多可以输入 {0} 个字符。'), - rangelength: this.formatTpl('请输入长度在 {0} 到 {1} 之间的字符。'), - min: this.formatTpl('请输入不小于 {0} 的数值。'), - max: this.formatTpl('请输入不大于 {0} 的数值。'), - range: this.formatTpl('请输入范围在 {0} 到 {1} 之间的数值。'), - } - } - } - - /** - * 初始化默认验证方法 - */ - __initMethods() { - const that = this - that.methods = { - /** - * 验证必填元素 - */ - required(value, param) { - if(!that.depend(param)) { - return 'dependency-mismatch' - } else if(typeof value === 'number') { - value = value.toString() - } else if(typeof value === 'boolean') { - return !0 - } - - return value.length > 0 - }, - /** - * 验证电子邮箱格式 - */ - email(value) { - return that.optional(value) || /^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(value) - }, - /** - * 验证手机格式 - */ - tel(value) { - return that.optional(value) || /^1[3456789]\d{9}$/.test(value) - }, - /** - * 验证URL格式 - */ - url(value) { - return that.optional(value) || /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(value) - }, - /** - * 验证日期格式 - */ - date(value) { - return that.optional(value) || !/Invalid|NaN/.test(new Date(value).toString()) - }, - /** - * 验证ISO类型的日期格式 - */ - dateISO(value) { - return that.optional(value) || /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(value) - }, - /** - * 验证十进制数字 - */ - number(value) { - return that.optional(value) || /^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(value) - }, - /** - * 验证整数 - */ - digits(value) { - return that.optional(value) || /^\d+$/.test(value) - }, - /** - * 验证身份证号码 - */ - idcard(value) { - return that.optional(value) || /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(value) - }, - /** - * 验证两个输入框的内容是否相同 - */ - equalTo(value, param) { - return that.optional(value) || value === that.data[param] - }, - /** - * 验证是否包含某个值 - */ - contains(value, param) { - return that.optional(value) || value.indexOf(param) >= 0 - }, - /** - * 验证最小长度 - */ - minlength(value, param) { - return that.optional(value) || value.length >= param - }, - /** - * 验证最大长度 - */ - maxlength(value, param) { - return that.optional(value) || value.length <= param - }, - /** - * 验证一个长度范围[min, max] - */ - rangelength(value, param) { - return that.optional(value) || (value.length >= param[0] && value.length <= param[1]) - }, - /** - * 验证最小值 - */ - min(value, param) { - return that.optional(value) || value >= param - }, - /** - * 验证最大值 - */ - max(value, param) { - return that.optional(value) || value <= param - }, - /** - * 验证一个值范围[min, max] - */ - range(value, param) { - return that.optional(value) || (value >= param[0] && value <= param[1]) - } - } - } - - /** - * 添加自定义验证方法 - * @param {String} name 方法名 - * @param {Function} method 函数体,接收两个参数(value, param),value表示元素的值,param表示参数 - * @param {String} message 提示信息 - */ - addMethod(name, method, message) { - this.methods[name] = method - this.defaults.messages[name] = message !== undefined ? message : this.defaults.messages[name] - } - - /** - * 判断验证方法是否存在 - */ - isValidMethod(value) { - let methods = [] - for(let method in this.methods) { - if(method && typeof this.methods[method] === 'function') { - methods.push(method) - } - } - return methods.indexOf(value) !== -1 - } - - /** - * 格式化提示信息模板 - */ - formatTpl(source, params) { - const that = this - if(arguments.length === 1) { - return function() { - let args = Array.from(arguments) - args.unshift(source) - return that.formatTpl.apply(this, args) - } - } - if(params === undefined) { - return source - } - if(arguments.length > 2 && params.constructor !== Array) { - params = Array.from(arguments).slice(1) - } - if(params.constructor !== Array) { - params = [params] - } - params.forEach(function(n, i) { - source = source.replace(new RegExp("\\{" + i + "\\}", "g"), function() { - return n - }) - }) - return source - } - - /** - * 判断规则依赖是否存在 - */ - depend(param) { - switch(typeof param) { - case 'boolean': - param = param - break - case 'string': - param = !!param.length - break - case 'function': - param = param() - default: - param = !0 - } - return param - } - - /** - * 判断输入值是否为空 - */ - optional(value) { - return !this.methods.required(value) && 'dependency-mismatch' - } - - /** - * 获取自定义字段的提示信息 - * @param {String} param 字段名 - * @param {Object} rule 规则 - */ - customMessage(param, rule) { - const params = this.messages[param] - const isObject = typeof params === 'object' - if(params && isObject) return params[rule.method] - } - - /** - * 获取某个指定字段的提示信息 - * @param {String} param 字段名 - * @param {Object} rule 规则 - */ - defaultMessage(param, rule) { - let message = this.customMessage(param, rule) || this.defaults.messages[rule.method] - let type = typeof message - - if(type === 'undefined') { - message = `Warning: No message defined for ${rule.method}.` - } else if(type === 'function') { - message = message.call(this, rule.parameters) - } - - return message - } - - /** - * 缓存错误信息 - * @param {String} param 字段名 - * @param {Object} rule 规则 - * @param {String} value 元素的值 - */ - formatTplAndAdd(param, rule, value) { - let msg = this.defaultMessage(param, rule) - - this.errorList.push({ - param: param, - msg: msg, - value: value, - }) - } - - /** - * 验证某个指定字段的规则 - * @param {String} param 字段名 - * @param {Object} rules 规则 - * @param {Object} data 需要验证的数据对象 - */ - checkParam(param, rules, data) { - - // 缓存数据对象 - this.data = data - - // 缓存字段对应的值 - const value = data[param] !== null && data[param] !== undefined ? data[param] : '' - - // 遍历某个指定字段的所有规则,依次验证规则,否则缓存错误信息 - for(let method in rules) { - - // 判断验证方法是否存在 - if(this.isValidMethod(method)) { - - // 缓存规则的属性及值 - const rule = { - method: method, - parameters: rules[method] - } - - // 调用验证方法 - const result = this.methods[method](value, rule.parameters) - - // 若result返回值为dependency-mismatch,则说明该字段的值为空或非必填字段 - if(result === 'dependency-mismatch') { - continue - } - - this.setValue(param, method, result, value) - - // 判断是否通过验证,否则缓存错误信息,跳出循环 - if(!result) { - this.formatTplAndAdd(param, rule, value) - break - } - } - } - } - - /** - * 设置字段的默认验证值 - * @param {String} param 字段名 - */ - setView(param) { - this.form[param] = { - $name: param, - $valid: true, - $invalid: false, - $error: {}, - $success: {}, - $viewValue: ``, - } - } - - /** - * 设置字段的验证值 - * @param {String} param 字段名 - * @param {String} method 字段的方法 - * @param {Boolean} result 是否通过验证 - * @param {String} value 字段的值 - */ - setValue(param, method, result, value) { - const params = this.form[param] - params.$valid = result - params.$invalid = !result - params.$error[method] = !result - params.$success[method] = result - params.$viewValue = value - } - - /** - * 验证所有字段的规则,返回验证是否通过 - * @param {Object} data 需要验证数据对象 - */ - checkForm(data) { - this.__initData() - - for(let param in this.rules) { - this.setView(param) - this.checkParam(param, this.rules[param], data) - } - - return this.valid() - } - - /** - * 返回验证是否通过 - */ - valid() { - return this.size() === 0 - } - - /** - * 返回错误信息的个数 - */ - size() { - return this.errorList.length - } - - /** - * 返回所有错误信息 - */ - validationErrors() { - return this.errorList - } -} - -module.exports = WxValidate; -- Gitee