diff --git a/app.js b/app.js index 49088b3..66dee61 100644 --- a/app.js +++ b/app.js @@ -1,19 +1,33 @@ // app.js +var restAjax = require('utils/restAjax.js'); App({ + restAjax: restAjax, + apis: restAjax.apis, + baseUrls: restAjax.baseUrl, onLaunch() { - //设置状态栏 - wx.getSystemInfo({ - success: e => { - this.globalData.StatusBar = e.statusBarHeight; - let capsule = wx.getMenuButtonBoundingClientRect(); - if (capsule) { - this.globalData.Custom = capsule; - this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight; - } else { - this.globalData.CustomBar = e.statusBarHeight + 50; + this.globalData.windowHeight = wx.getSystemInfoSync().windowHeight + //设置状态栏 + wx.getSystemInfo({ + success: e => { + this.globalData.StatusBar = e.statusBarHeight; + let capsule = wx.getMenuButtonBoundingClientRect(); + if (capsule) { + this.globalData.Custom = capsule; + this.globalData.CustomBar = capsule.bottom + capsule.top - e.statusBarHeight; + } else { + this.globalData.CustomBar = e.statusBarHeight + 50; + } + } + }) + //获取是否绑定手机号 + try { + var bindPhone = wx.getStorageSync('bindPhone') + if (bindPhone != '' && bindPhone.length > 0) { + this.globalData.bindPhone = bindPhone + } + } catch (error) { + } - } -}) // 登录 wx.login({ success: res => { @@ -21,7 +35,46 @@ App({ } }) }, + // 登录 + doLogin: function () { + var self = this; + wx.login({ + success(res) { + console.log(res) + app.restAjax.post(app.restAjax.path(apis.login, [baseUrls.loginUrl]), { + jsCode: res.code + }, null, function (code, data) { + var token = data.data.split('_')[0] + self.setData({ + token: token, + bindPhone: data.data.split('_')[1] + }) + wx.setStorageSync('token', token) + wx.setStorageSync('bindPhone', data.data.split('_')[1]) + app.globalData.token = token + self.getUserInfo() + }, function (code, data) { + app.dialog.msg(data.msg); + }); + } + }) + }, + // 获取用户信息 + getUserInfo: function () { + var self = this + app.restAjax.get(app.restAjax.path('{loginUrl}app/user/get-app-user', [app.personIntroUrl]), {}, { + headers: { + token: app.globalData.token + } + }, function (code, data) { + app.globalData.userInfo = data + }, function (code, data) { + app.dialog.msg(data.msg); + }); + }, globalData: { - userInfo: null + userInfo: null, + bindPhone: '', + token: 'dEIwTEV0MEp5d1o2dlNBYUd4MVp0akV2MXVFbktCMWZ5cjFIbGpNMytQWkRLMWUvdjBUcDkrSk13ajBiYzJSS2JtY1p0cTlhYUxqRm10TUM4S1lSSFhabHVZdlRJRkwrUjA2Uk5pN2UyU0FYYXVQWVpxZHhEUTlCT1p3QURHcVNKVlVrakhOUlZJb2lyQ05wdVQvY1hCSHM5Wmk5VDBEM0ZOQlV1MWlwYm0yVjRGdmExNzRTS3Iyb1IyTThhSkczQk9uS3NOL25jVzJJSEJlbWpId2lKakREWm8yOHVhaUlRZVVKVmptbFdvbGZtUllBUG43M3pjKzhNcm11ZUY2ZHpsZmk1dU5kS04yTWM0Z0JiSmljV1E9PQ==' } -}) +}) \ No newline at end of file diff --git a/app.json b/app.json index 5d86d13..cc010a4 100644 --- a/app.json +++ b/app.json @@ -12,7 +12,8 @@ "pages/results/resultsdetail", "pages/card/carddetail", "pages/index/mineinfo", - "pages/branches/branchesdetail" + "pages/branches/branchesdetail", + "pages/answer/answerdetail" ], "window": { "backgroundTextStyle": "dark", @@ -30,6 +31,7 @@ "van-swipe-cell": "/vant/dist/swipe-cell/index", "van-cell-group": "/vant/dist/cell-group/index", "van-cell": "/vant/dist/cell/index", - "van-empty": "/vant/dist/empty/index" + "van-empty": "/vant/dist/empty/index", + "van-popup": "/vant/dist/popup/index" } } \ No newline at end of file diff --git a/app.wxss b/app.wxss index fdfd149..31dbdd1 100644 --- a/app.wxss +++ b/app.wxss @@ -27,7 +27,7 @@ page { } .content { - width: 80%; + width: 70%; display: flex; flex-direction: column; justify-content: space-around; @@ -94,6 +94,22 @@ page { border-radius: 20rpx; } +.table-item-no { + display: flex; + width: 96%; + flex-direction: row; + padding-top: 20rpx; + padding-bottom: 20rpx; +} + +.line-gray { + display: flex; + width: 90%; + flex-direction: row; + height: 1rpx; + background-color: #f5f5f5; +} + .table-title-border { display: flex; width: 96%; @@ -139,6 +155,12 @@ page { align-self: center; } +.border-bottom-gray { + border-bottom-width: 1rpx; + border-bottom-style: solid; + border-bottom-color: gray; +} + .table-item-title-1 { flex: 1.3; text-align: center; @@ -148,6 +170,22 @@ page { align-self: center; } +.table-item-title { + flex: 0.7; + text-align: justify; + align-items: center; + justify-content: center; + align-self: center; +} + +.table-item-content-3 { + flex: 1.3; + text-align: center; + align-items: center; + justify-content: center; + align-self: center; +} + .table-item-title-4 { flex: 0.4; text-align: center; diff --git a/images/icons/answer_default.jpeg b/images/icons/answer_default.jpeg new file mode 100644 index 0000000..82cd823 Binary files /dev/null and b/images/icons/answer_default.jpeg differ diff --git a/images/icons/ic_user_default.png b/images/icons/ic_user_default.png deleted file mode 100644 index ad8642e..0000000 Binary files a/images/icons/ic_user_default.png and /dev/null differ diff --git a/images/icons/institutions_default.jpeg b/images/icons/institutions_default.jpeg new file mode 100644 index 0000000..3a80565 Binary files /dev/null and b/images/icons/institutions_default.jpeg differ diff --git a/images/icons/notice_default.jpeg b/images/icons/notice_default.jpeg new file mode 100644 index 0000000..f37930e Binary files /dev/null and b/images/icons/notice_default.jpeg differ diff --git a/pages/answer/answerdetail.js b/pages/answer/answerdetail.js new file mode 100644 index 0000000..525658e --- /dev/null +++ b/pages/answer/answerdetail.js @@ -0,0 +1,40 @@ +// pages/notices/noticedetail.js +const app = getApp() +Page({ + + /** + * 页面的初始数据 + */ + data: { + noticeContent: '', + articleId: '', + detailBean: null + }, + + /** + * 生命周期函数--监听页面加载 + */ + onLoad: function (options) { + this.setData({ + articleId: options.id + }) + this.getArticleDetail() + }, + getArticleDetail() { + var _self = this + wx.showLoading({ + title: '加载中...', + }) + app.restAjax.get(app.restAjax.path(app.apis.getArticleDetailById, [app.baseUrls.cardUrl, _self.data.articleId]), {}, {}, + (code, data) => { + wx.hideLoading({}) + if (code == 200) { + _self.setData({ + detailBean: data + }) + } + }, (code, err) => { + wx.hideLoading({}) + }) + } +}) \ No newline at end of file diff --git a/pages/answer/answerdetail.json b/pages/answer/answerdetail.json new file mode 100644 index 0000000..8835af0 --- /dev/null +++ b/pages/answer/answerdetail.json @@ -0,0 +1,3 @@ +{ + "usingComponents": {} +} \ No newline at end of file diff --git a/pages/answer/answerdetail.wxml b/pages/answer/answerdetail.wxml new file mode 100644 index 0000000..7710d21 --- /dev/null +++ b/pages/answer/answerdetail.wxml @@ -0,0 +1,21 @@ + + + 问答详情 + + + + + + {{detailBean.title}} + + + 发布日期:{{detailBean.publishDate}} + 来源:{{detailBean.source}} + + + + + + + + \ No newline at end of file diff --git a/pages/answer/answerdetail.wxss b/pages/answer/answerdetail.wxss new file mode 100644 index 0000000..31072a6 --- /dev/null +++ b/pages/answer/answerdetail.wxss @@ -0,0 +1 @@ +/* pages/answer/answerdetail.wxss */ \ No newline at end of file diff --git a/pages/answer/answerlist.js b/pages/answer/answerlist.js index c3bf899..fe650bd 100644 --- a/pages/answer/answerlist.js +++ b/pages/answer/answerlist.js @@ -1,4 +1,4 @@ -// pages/answer/answerlist.js +// pages/notices/noticeslist.js const app = getApp() Page({ @@ -10,14 +10,37 @@ Page({ CustomBar: app.globalData.CustomBar, countTime: 2000, //延迟搜索 时间 searchWaiting: false, //是否等待搜索倒计时中, - searchKey: '' + searchKey: '', + contentHeight: app.globalData.windowHeight, + currentPage: 1, + totalSize: 0 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + this.getResultsList('') + }, + showDetail(e) { + var item = e.currentTarget.dataset.item + wx.navigateTo({ + url: './answerdetail?id=' + item.contentId, + }) + }, + doLoadMore() { + var _self = this + if (_self.data.totalSize > _self.data.answerList.length) { + _self.setData({ + currentPage: ++_self.data.currentPage + }) + _self.getResultsList(_self.data.searchKey) + } else { + wx.showToast({ + title: '无更多数据了', + icon: 'none' + }) + } }, doSearch(e) { this.setData({ @@ -30,14 +53,52 @@ Page({ } }, getResultsList(key) { - console.log('搜索中' + key) + var _self = this + app.restAjax.get(app.restAjax.path(app.apis.getArticleList, [app.baseUrls.cardUrl]), { + categoryId: '494bf3cc-cab6-4710-a0b2-d84f4591c992', + page: _self.data.currentPage, + rows: '10', + keywords: key + }, {}, + function (code, data) { + wx.hideLoading({}) + if (code == 200) { + for (var i = 0; i < data.rows.length; i++) { + var item = data.rows[i] + if (item.coverPhotos.length > 0) { + var photos = item.coverPhotos.split(',') + data.rows[i].showPhoto = app.baseUrls.cardUrl + app.baseUrls.baseImgUrl + photos[0] + } else { + data.rows[i].showPhoto = '../../images/icons/answer_default.jpeg' + } + } + if (_self.data.currentPage > 1) { + if (data.rows.length > 0) { + _self.data.answerList = _self.data.answerList.concat(data.rows) + } + } else { + _self.data.answerList = data.rows + } + _self.setData({ + answerList: _self.data.answerList, + totalSize: data.total + }) + } + }, + function (code, err) { + wx.hideLoading({}) + console.log(err) + }) }, /** * 延迟搜索 */ timer() { + var _self = this; this.setData({ + currentPage: 1, + totalSize: 0, searchWaiting: true }) let promise = new Promise((resolve, reject) => { @@ -48,6 +109,7 @@ Page({ countTime: _self.data.countTime - 1000 }) if (_self.data.countTime <= 0) { + console.log('开始搜索: ' + _self.data.searchKey); _self.setData({ countTime: 2000, @@ -58,6 +120,9 @@ Page({ }, 1000) }) promise.then((setTimer) => { + wx.showLoading({ + title: '搜索中...', + }) _self.getResultsList(_self.data.searchKey) clearInterval(setTimer) //清除计时器 }) diff --git a/pages/answer/answerlist.wxml b/pages/answer/answerlist.wxml index 9b98dae..a6fb68f 100644 --- a/pages/answer/answerlist.wxml +++ b/pages/answer/answerlist.wxml @@ -2,15 +2,24 @@ 报考问答 - + + + + + + + - - - + + - 2021年4-6月特种设备作业人员培训开班通知 - 新东方在线 + {{item.title}} + + {{item.source}} + {{item.publishDate}} + diff --git a/pages/branches/branchesdetail.js b/pages/branches/branchesdetail.js index b9c6b67..37b6f10 100644 --- a/pages/branches/branchesdetail.js +++ b/pages/branches/branchesdetail.js @@ -1,11 +1,26 @@ // pages/branches/branchesdetail.js +const app = getApp() Page({ /** * 页面的初始数据 */ data: { - + noticeContent: `
+

各有关单位:
+ 为满足企业对特种设备作业人员专业素质的需求,支持企业对特种设备作业人员进行专业知识、操作技能和安全教育工作,推进行业专业技术水平的提升,广州市特种设备行业协会对国家市场监管总局已取消的特种设备作业项目,组织行业相关特种设备作业人员进行继续教育培训考核,欢迎各相关单位学员自愿参加对考核合格的特种设备作业人员,由广州市特种设备行业协会发放《广州市特种设备行业协会培训证书》。本协会定于2020年1-3月举办下列培训班,现将有关事项通知如下:
+ + 一、报名日期:即日起至开班前两个工作日办理报名交费手续。
+ 二、报名交费地点:广州市东风东路754号之八(城迹酒店)8楼。咨询电话: 020-34277197转分机号801~808或13342813020\\13500003204。
+ 三、报名须知:
+ (一)年满18周岁,且不超过60周岁;
+ (二)申请人员身体健康,能够适应所申请考核作业项目的需要;
+ (三)具有初中及以上文化程度;
+ (四)具备必要的安全技术知识与技能;
+ (五)安全教育须提前1个月提交资料报名,且年龄不超65周岁。
+ 四、《广州市特种设备行业协会培训证书》考证、安全教育需提交资料
+

+
` }, /** @@ -14,53 +29,4 @@ Page({ onLoad: function (options) { }, - - /** - * 生命周期函数--监听页面初次渲染完成 - */ - onReady: function () { - - }, - - /** - * 生命周期函数--监听页面显示 - */ - onShow: function () { - - }, - - /** - * 生命周期函数--监听页面隐藏 - */ - onHide: function () { - - }, - - /** - * 生命周期函数--监听页面卸载 - */ - onUnload: function () { - - }, - - /** - * 页面相关事件处理函数--监听用户下拉动作 - */ - onPullDownRefresh: function () { - - }, - - /** - * 页面上拉触底事件的处理函数 - */ - onReachBottom: function () { - - }, - - /** - * 用户点击右上角分享 - */ - onShareAppMessage: function () { - - } }) \ No newline at end of file diff --git a/pages/branches/branchesdetail.wxml b/pages/branches/branchesdetail.wxml index e3d28e0..d2fa64a 100644 --- a/pages/branches/branchesdetail.wxml +++ b/pages/branches/branchesdetail.wxml @@ -2,3 +2,16 @@ 考试网点 + + + + + 新东方学校 + + + + + + + + \ No newline at end of file diff --git a/pages/branches/brancheslist.js b/pages/branches/brancheslist.js index dde0458..e63fe35 100644 --- a/pages/branches/brancheslist.js +++ b/pages/branches/brancheslist.js @@ -5,7 +5,7 @@ Page({ * 页面的初始数据 */ data: { - branchesList: [], + branchesList: [{},{},{},{}], CustomBar: app.globalData.CustomBar, countTime: 2000, //延迟搜索 时间 searchWaiting: false, //是否等待搜索倒计时中, @@ -17,6 +17,12 @@ Page({ */ onLoad: function (options) { + }, + showDetail(e) { + var item = e.currentTarget.dataset.item + wx.navigateTo({ + url: './branchesdetail', + }) }, doSearch(e) { this.setData({ diff --git a/pages/branches/brancheslist.wxml b/pages/branches/brancheslist.wxml index cf3fa27..82fc11f 100644 --- a/pages/branches/brancheslist.wxml +++ b/pages/branches/brancheslist.wxml @@ -10,7 +10,7 @@
- + diff --git a/pages/card/carddetail.js b/pages/card/carddetail.js index 68ebdb6..b0090ac 100644 --- a/pages/card/carddetail.js +++ b/pages/card/carddetail.js @@ -1,18 +1,21 @@ // pages/card/carddetail.js +const app = getApp() Page({ /** * 页面的初始数据 */ data: { - + cardData: '' }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + this.setData({ + cardData: options.data + }) }, /** diff --git a/pages/card/carddetail.wxml b/pages/card/carddetail.wxml index 0825ce0..e348807 100644 --- a/pages/card/carddetail.wxml +++ b/pages/card/carddetail.wxml @@ -2,86 +2,5 @@ 准考证 - - - - 2019年注册安全工程师准考证 - - - - - - - 考生姓名 - 张三 - - - 性别 - - - - 证件号码 - 111111111111111116 - - - 报名序号 - 1123412341234 - - - - - - - - - 档案号 - 1234123412341234123412341234 - - - 报考专业 - 建筑施工安全 - - - 工作单位 - 内蒙古呼和浩特市 - - - 考点地址 - 内蒙古呼和浩特市 - - - - 考试科目 - 考试时间 - 考场 - 座位 - - - 安全生产法律法规 - 2021-11-11 09:00-11:20 - 10 - 99 - - - 安全生产法律法规 - 2021-11-11 09:00-11:20 - 10 - 99 - - - 安全生产法律法规 - 2021-11-11 09:00-11:20 - 10 - 99 - - - 考试须知 - - 考试须知考试须知考试须知考试须知考试须知考试须知考试须知考试须知考试须知考试须知考试须知考试须知考试须知考试须知考试须知考试须知考试须知考试须知考试须知考试须知考试须知 - - - - + \ No newline at end of file diff --git a/pages/card/cardlist.js b/pages/card/cardlist.js index 475a05b..6d75fb5 100644 --- a/pages/card/cardlist.js +++ b/pages/card/cardlist.js @@ -6,24 +6,60 @@ Page({ * 页面的初始数据 */ data: { - cardList: [{}, {}, {}, {}], + cardList: [], CustomBar: app.globalData.CustomBar, countTime: 2000, //延迟搜索 时间 searchWaiting: false, //是否等待搜索倒计时中, - searchKey: '' + searchKey: '', + show: false, + cardData: '', //当前显示的准考证 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + this.getMyExam() + }, + getMyExam() { + wx.showLoading({ + title: '加载中...', + }) + var _self = this + app.restAjax.get(app.restAjax.path(app.apis.getCardList, [app.baseUrls.cardUrl]), {}, { + headers: { + token: app.globalData.token + } + }, (code, data) => { + wx.hideLoading({}) + if (code == 200) { + _self.setData({ + cardList: data + }) + } + }, (code, error) => { + wx.hideLoading({}) + if (error) { + wx.showToast({ + title: error.msg, + }) + } else { + wx.showToast({ + title: '网络错误', + icon: 'error' + }) + } + }) }, showDetail(e) { var item = e.currentTarget.dataset.item - wx.navigateTo({ - url: './carddetail', + this.setData({ + cardData: item.distributionCardCode, + show: true }) + // wx.navigateTo({ + // url: './carddetail?data=' + item.distributionCardCode, + // }) }, doSearch(e) { this.setData({ @@ -68,4 +104,9 @@ Page({ clearInterval(setTimer) //清除计时器 }) }, + onClose(e) { + this.setData({ + show: false + }) + }, }) \ No newline at end of file diff --git a/pages/card/cardlist.wxml b/pages/card/cardlist.wxml index cda4f7e..037e44b 100644 --- a/pages/card/cardlist.wxml +++ b/pages/card/cardlist.wxml @@ -2,23 +2,37 @@ 准考证查询 - - - - - - - + - - + + + {{item.planName}} + + + 开始时间:{{item.examTimeStart}} + + + + 结束时间:{{item.examTimeEnd}} + + + + 培训机构:{{item.orgName}} + + + + 地址:{{item.examAddress}} + - - 2021年4-6月特种设备作业人员培训开班通知 - 新东方在线 + + - \ No newline at end of file + + + + + + \ No newline at end of file diff --git a/pages/index/index.js b/pages/index/index.js index 3249732..64b5c5a 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -1,17 +1,77 @@ // index.js // 获取应用实例 const app = getApp() - +var utils = require('../../utils/util.js') Page({ data: { index: 1, - noticeList: [{}, {}, {}, {}, {}], //开班通告 - answerList: [{}, {}, {}, {}, {}], //报考问答 + noticeList: [], //开班通告 + answerList: [], //报考问答 userIcon: '../../images/icons/ic_user_default.png', nickName: '点击授权', + show: false, + phone: '', //要绑定的手机号 }, onLoad() { this.getUserInfo() + this.getNoticeList() + this.getAnswerList() + }, + //获取开班通告 + getNoticeList() { + var _self = this + app.restAjax.get(app.restAjax.path(app.apis.getArticleList, [app.baseUrls.cardUrl]), { + categoryId: '2ff8f6be-a435-46c1-98b7-47b16c621395', + page: '1', + rows: '6' + }, {}, + function (code, data) { + if (code == 200) { + for (var i = 0; i < data.rows.length; i++) { + var item = data.rows[i] + if (item.coverPhotos.length > 0) { + var photos = item.coverPhotos.split(',') + data.rows[i].showPhoto = app.baseUrls.cardUrl + app.baseUrls.baseImgUrl + photos[0] + } else { + data.rows[i].showPhoto = '../../images/icons/notice_default.jpeg' + } + } + _self.setData({ + noticeList: data.rows + }) + } + }, + function (code, err) { + console.log(err) + }) + }, + //报考问答 + getAnswerList() { + var _self = this + app.restAjax.get(app.restAjax.path(app.apis.getArticleList, [app.baseUrls.cardUrl]), { + categoryId: '494bf3cc-cab6-4710-a0b2-d84f4591c992', + page: '1', + rows: '6' + }, {}, + function (code, data) { + if (code == 200) { + for (var i = 0; i < data.rows.length; i++) { + var item = data.rows[i] + if (item.coverPhotos.length > 0) { + var photos = item.coverPhotos.split(',') + data.rows[i].showPhoto = app.baseUrls.cardUrl + app.baseUrls.baseImgUrl + photos[0] + } else { + data.rows[i].showPhoto = '../../images/icons/answer_default.jpeg' + } + } + _self.setData({ + answerList: data.rows + }) + } + }, + function (code, err) { + console.log(err) + }) }, //获取个人信息 getUserInfo() { @@ -28,6 +88,7 @@ Page({ _self.setData({ userIcon: icon }) + _self.checkBindPhone() } else { wx.showModal({ title: '提示', @@ -44,6 +105,58 @@ Page({ } }, + showMineInfo(e) { + try { + var icon = wx.getStorageSync('userIcon') + if (icon) { + wx.navigateTo({ + url: './mineinfo', + }) + } else { + this.getUserProfile(e) + } + } catch (err) { + + } + }, + //弹框关闭 + onClose(e) { + this.setData({ + show: false + }) + }, + //进行手机号绑定 + doBindPhone(e) { + var _self = this + if (_self.checkPhonelegal()) { + app.globalData.bindPhone = _self.data.phone + wx.setStorage({ + data: _self.data.phone, + key: 'bindPhone', + }) + _self.setData({ + show: false + }) + } + }, + checkPhonelegal() { + var _self = this + if (!utils.isMobile(_self.data.phone)) { + wx.showToast({ + title: '请输入正确的手机号', + icon: 'none' + }) + return false + } else { + return true + } + }, + //绑定手机号输入监听 + bindPhone(e) { + this.setData({ + phone: e.detail.value + }) + }, //显示更多数据 showMoreList() { if (this.data.index == 1) { @@ -56,11 +169,13 @@ Page({ }) } }, + //新闻切换 tabSelect(e) { this.setData({ index: e.currentTarget.dataset.id }) }, + //页面跳转 choosePage(e) { var pagePath = '' switch (e.currentTarget.dataset.page) { @@ -77,9 +192,19 @@ Page({ pagePath = '../branches/brancheslist' break } - wx.navigateTo({ - url: pagePath, - }) + if (e.currentTarget.dataset.page == '2' || e.currentTarget.dataset.page == '3') { + if (app.globalData.bindPhone != '' && app.globalData.bindPhone.length > 0) { + wx.navigateTo({ + url: pagePath, + }) + } else { + this.checkBindPhone() + } + } else { + wx.navigateTo({ + url: pagePath, + }) + } }, // 获取个人信息 getUserProfile(e) { let _self = this @@ -98,24 +223,45 @@ Page({ nickName: res.userInfo.nickName, userIcon: res.userInfo.avatarUrl }) + _self.checkBindPhone() }, fail(err) { - console.log(err) + //判断是否绑定手机号 wx.showToast({ title: '获取个人信息失败', - icon: 'error' + icon: 'error', + success() { + _self.checkBindPhone() + } }) } }) }, + //判断是否绑定手机号 + checkBindPhone() { + try { + var _self = this + var bindPhone = wx.getStorageSync('bindPhone') + if (bindPhone == '' || bindPhone.length <= 0) { + _self.setData({ + show: true + }) + } + } catch (error) { + + } + }, showNoticeDetail(e) { var item = e.currentTarget.dataset.item wx.navigateTo({ - url: '../notices/noticedetail', + url: '../notices/noticedetail?id=' + item.contentId, }) }, showAnswerDetail(e) { var item = e.currentTarget.dataset.item + wx.navigateTo({ + url: '../answer/answerdetail?id=' + item.contentId, + }) } }) \ No newline at end of file diff --git a/pages/index/index.wxml b/pages/index/index.wxml index 1b6e834..90f4251 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -4,7 +4,7 @@ - + @@ -63,12 +63,14 @@ - - + - 2021年4-6月特种设备作业人员培训开班通知 - 新东方在线 + {{item.title}} + + {{item.source}} + {{item.publishDate}} + @@ -78,13 +80,15 @@ - - - + + - 怎么注册? - 新东方在线 + {{item.title}} + + {{item.source}} + {{item.publishDate}} + @@ -93,4 +97,17 @@ - \ No newline at end of file + + + + 手机号绑定 + + + + + + + 绑定 + + \ No newline at end of file diff --git a/pages/index/mineinfo.wxml b/pages/index/mineinfo.wxml index ab22662..e4070e1 100644 --- a/pages/index/mineinfo.wxml +++ b/pages/index/mineinfo.wxml @@ -1,4 +1,53 @@ 个人信息 - \ No newline at end of file + + + + + + + 姓名: + 姓名 + + + + 证件号码: + 188888888888888 + + + + 出生日期: + 188888888888888 + + + + 性别: + 188888888888888 + + + + 文化程度: + 188888888888888 + + + + 电话号码: + 188888888888888 + + + + 单位名称: + 188888888888888 + + + + 通信地址: + 内蒙古呼和浩特市赛罕区内蒙古呼和浩特市赛罕区内蒙古呼和浩特市赛罕区内蒙古呼和浩特市赛罕区 + + + + + + + \ No newline at end of file diff --git a/pages/institutions/institutionsdetail.js b/pages/institutions/institutionsdetail.js index 4832b55..529f930 100644 --- a/pages/institutions/institutionsdetail.js +++ b/pages/institutions/institutionsdetail.js @@ -6,27 +6,42 @@ Page({ * 页面的初始数据 */ data: { - noticeContent: `
-

各有关单位:
- 为满足企业对特种设备作业人员专业素质的需求,支持企业对特种设备作业人员进行专业知识、操作技能和安全教育工作,推进行业专业技术水平的提升,广州市特种设备行业协会对国家市场监管总局已取消的特种设备作业项目,组织行业相关特种设备作业人员进行继续教育培训考核,欢迎各相关单位学员自愿参加对考核合格的特种设备作业人员,由广州市特种设备行业协会发放《广州市特种设备行业协会培训证书》。本协会定于2020年1-3月举办下列培训班,现将有关事项通知如下:
- -一、报名日期:即日起至开班前两个工作日办理报名交费手续。
-二、报名交费地点:广州市东风东路754号之八(城迹酒店)8楼。咨询电话: 020-34277197转分机号801~808或13342813020\\13500003204。
-三、报名须知:
-(一)年满18周岁,且不超过60周岁;
-(二)申请人员身体健康,能够适应所申请考核作业项目的需要;
-(三)具有初中及以上文化程度;
-(四)具备必要的安全技术知识与技能;
-(五)安全教育须提前1个月提交资料报名,且年龄不超65周岁。
-四、《广州市特种设备行业协会培训证书》考证、安全教育需提交资料
-

-
` + noticeContent: '', + inId: '', + detailBean: null }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + this.setData({ + inId: options.id + }) + this.getInstitutionDetail() }, + getInstitutionDetail() { + var _self = this + wx.showLoading({ + title: '加载中...', + }) + app.restAjax.get(app.restAjax.path(app.apis.getInstitutionDetailById, [app.baseUrls.cardUrl, _self.data.inId]), {}, {}, + (code, data) => { + wx.hideLoading({}) + if (code == 200) { + var ps = data.institutionImage.split(',') + var photos = [] + for (var i = 0; i < ps.length; i++) { + var urls = app.baseUrls.cardUrl + app.baseUrls.baseImgUrl + ps[i] + photos = photos.concat(urls) + } + data.showPhoto = photos + _self.setData({ + detailBean: data + }) + } + }, (code, error) => { + wx.hideLoading({}) + }) + } }) \ No newline at end of file diff --git a/pages/institutions/institutionsdetail.wxml b/pages/institutions/institutionsdetail.wxml index b85ff6e..4128ef9 100644 --- a/pages/institutions/institutionsdetail.wxml +++ b/pages/institutions/institutionsdetail.wxml @@ -6,11 +6,35 @@ - 东方红培训机构 + {{detailBean.institutionName}} - - - + + + + + 负责人:{{detailBean.institutionPrincipal}} + + + + + 联系方式:{{detailBean.institutionContact}} + + + + + 成立日期:{{detailBean.institutionFoundingTime}} + + + + 地址:{{detailBean.institutionAddress}} + + + + + + + + diff --git a/pages/institutions/institutionslist.js b/pages/institutions/institutionslist.js index df7db5a..69685ee 100644 --- a/pages/institutions/institutionslist.js +++ b/pages/institutions/institutionslist.js @@ -8,31 +8,56 @@ Page({ */ data: { CustomBar: app.globalData.CustomBar, - institutionsList: [{}, {}], + institutionsList: [], countTime: 2000, //延迟搜索 时间 searchWaiting: false, //是否等待搜索倒计时中, searchKey: '', - mapLocs: [] + mapLocs: [], + currentPage: 1, + totalSize: 0 }, /** * 生命周期函数--监听页面加载 */ - onLoad: function (options) {}, + onLoad: function (options) { + this.getInstitutionsList('') + }, + doLoadMore() { + var _self = this + if (_self.data.totalSize > _self.data.institutionsList.length) { + _self.setData({ + currentPage: ++_self.data.currentPage + }) + _self.getInstitutionsList(_self.data.searchKey) + } else { + wx.showToast({ + title: '无更多数据了', + icon: 'none' + }) + } + }, doNavigation(e) { var item = e.currentTarget.dataset.item - var locs = utils.bdMapToQQMap(116.34304, 39.948131) - var lng = locs[0] - var lat = locs[1] - wx.openLocation({ - latitude: Number(lat), - longitude: Number(lng), - }) + if (item.institutionX == '' || item.institutionY == '') { + wx.showToast({ + title: '机构坐标有误', + icon: 'error' + }) + } else { + var locs = utils.bdMapToQQMap(item.institutionX, item.institutionY) + var lng = locs[0] + var lat = locs[1] + wx.openLocation({ + latitude: Number(lat), + longitude: Number(lng), + }) + } }, showDetail(e) { var item = e.currentTarget.dataset.item wx.navigateTo({ - url: './institutionsdetail', + url: './institutionsdetail?id=' + item.institutionId, }) }, doSearch(e) { @@ -46,14 +71,48 @@ Page({ } }, getInstitutionsList(key) { - console.log('搜索中' + key) + var _self = this + app.restAjax.get(app.restAjax.path(app.apis.getInstitutionList, [app.baseUrls.cardUrl]), { + page: _self.data.currentPage, + keywords: key + }, {}, + (code, data) => { + wx.hideLoading({}) + if (code == 200) { + for (var i = 0; i < data.rows.length; i++) { + var item = data.rows[i] + if (item.institutionImage.length > 0) { + var photos = item.institutionImage.split(',') + data.rows[i].showPhoto = app.baseUrls.cardUrl + app.baseUrls.baseImgUrl + photos[0] + } else { + data.rows[i].showPhoto = '../../images/icons/institutions_default.jpeg' + } + } + if (_self.data.currentPage > 1) { + if (data.rows.length > 0) { + _self.data.institutionsList = _self.data.institutionsList.concat(data.rows) + } + } else { + _self.data.institutionsList = data.rows + } + _self.setData({ + institutionsList: _self.data.institutionsList, + totalSize: data.total + }) + } + }, (code, err) => { + wx.hideLoading({}) + }) }, + // /** * 延迟搜索 */ timer() { var _self = this; this.setData({ + currentPage: 1, + totalSize: 0, searchWaiting: true }) let promise = new Promise((resolve, reject) => { @@ -64,6 +123,7 @@ Page({ countTime: _self.data.countTime - 1000 }) if (_self.data.countTime <= 0) { + console.log('开始搜索: ' + _self.data.searchKey); _self.setData({ countTime: 2000, @@ -74,6 +134,9 @@ Page({ }, 1000) }) promise.then((setTimer) => { + wx.showLoading({ + title: '搜索中...', + }) _self.getInstitutionsList(_self.data.searchKey) clearInterval(setTimer) //清除计时器 }) diff --git a/pages/institutions/institutionslist.wxml b/pages/institutions/institutionslist.wxml index 48536a4..92605d8 100644 --- a/pages/institutions/institutionslist.wxml +++ b/pages/institutions/institutionslist.wxml @@ -11,23 +11,23 @@ - - + 包头市东方红培训机构 + data-item="{{item}}">{{item.institutionName}} - 0472-8888888 + {{item.institutionContact}} 包头市昆区团结路88号包头市昆区团结路88号包头市昆区团结路88号包头市昆区团结路88号 + class="margin-left-smm">{{item.institutionAddress}} - 2021-12-12 + {{item.institutionFoundingTime}} diff --git a/pages/notices/noticedetail.js b/pages/notices/noticedetail.js index 2df46ae..f14e77c 100644 --- a/pages/notices/noticedetail.js +++ b/pages/notices/noticedetail.js @@ -6,28 +6,47 @@ Page({ * 页面的初始数据 */ data: { - noticeContent: `
-

各有关单位:
- 为满足企业对特种设备作业人员专业素质的需求,支持企业对特种设备作业人员进行专业知识、操作技能和安全教育工作,推进行业专业技术水平的提升,广州市特种设备行业协会对国家市场监管总局已取消的特种设备作业项目,组织行业相关特种设备作业人员进行继续教育培训考核,欢迎各相关单位学员自愿参加对考核合格的特种设备作业人员,由广州市特种设备行业协会发放《广州市特种设备行业协会培训证书》。本协会定于2020年1-3月举办下列培训班,现将有关事项通知如下:
- -一、报名日期:即日起至开班前两个工作日办理报名交费手续。
-二、报名交费地点:广州市东风东路754号之八(城迹酒店)8楼。咨询电话: 020-34277197转分机号801~808或13342813020\\13500003204。
-三、报名须知:
-(一)年满18周岁,且不超过60周岁;
-(二)申请人员身体健康,能够适应所申请考核作业项目的需要;
-(三)具有初中及以上文化程度;
-(四)具备必要的安全技术知识与技能;
-(五)安全教育须提前1个月提交资料报名,且年龄不超65周岁。
-四、《广州市特种设备行业协会培训证书》考证、安全教育需提交资料
-

-
` + noticeContent: '', + articleId: '', + detailBean: null }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + this.setData({ + articleId: options.id + }) + this.getArticleDetail() }, - + getArticleDetail() { + var _self = this + wx.showLoading({ + title: '加载中...', + }) + app.restAjax.get(app.restAjax.path(app.apis.getArticleDetailById, [app.baseUrls.cardUrl, _self.data.articleId]), {}, {}, + (code, data) => { + wx.hideLoading({}) + if (code == 200) { + data.content = _self.checkImgSrc(data.content) + _self.setData({ + detailBean: data + }) + } + }, (code, err) => { + wx.hideLoading({}) + }) + }, + checkImgSrc(content) { + if (content.indexOf('img') != -1) { //判断img是否存在 + var result = content.replace(/]*src=['"]([^'"]+)[^>]*>/gi, function (match, capture) { + console.log(capture); + return ''; + }); + return result + } else { + return content + } + } }) \ No newline at end of file diff --git a/pages/notices/noticedetail.wxml b/pages/notices/noticedetail.wxml index 021c80e..4141ea7 100644 --- a/pages/notices/noticedetail.wxml +++ b/pages/notices/noticedetail.wxml @@ -6,11 +6,15 @@ - 2020年1-3月广州市特种设备行业协会培训证书开班通知 + {{detailBean.title}} - - - + + 发布日期:{{detailBean.publishDate}} + 培训机构:{{detailBean.source}} + + + + diff --git a/pages/notices/noticeslist.js b/pages/notices/noticeslist.js index 47f7419..ae2e541 100644 --- a/pages/notices/noticeslist.js +++ b/pages/notices/noticeslist.js @@ -10,21 +10,38 @@ Page({ CustomBar: app.globalData.CustomBar, countTime: 2000, //延迟搜索 时间 searchWaiting: false, //是否等待搜索倒计时中, - searchKey: '' + searchKey: '', + contentHeight: app.globalData.windowHeight, + currentPage: 1, + totalSize: 0 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + this.getResultsList('') }, showDetail(e) { var item = e.currentTarget.dataset.item wx.navigateTo({ - url: './noticedetail', + url: './noticedetail?id=' + item.contentId, }) }, + doLoadMore() { + var _self = this + if (_self.data.totalSize > _self.data.noticeList.length) { + _self.setData({ + currentPage: ++_self.data.currentPage + }) + _self.getResultsList(_self.data.searchKey) + } else { + wx.showToast({ + title: '无更多数据了', + icon: 'none' + }) + } + }, doSearch(e) { this.setData({ countTime: 2000, @@ -36,7 +53,42 @@ Page({ } }, getResultsList(key) { - console.log('搜索中' + key) + var _self = this + app.restAjax.get(app.restAjax.path(app.apis.getArticleList, [app.baseUrls.cardUrl]), { + categoryId: '2ff8f6be-a435-46c1-98b7-47b16c621395', + page: _self.data.currentPage, + rows: '10', + keywords: key + }, {}, + function (code, data) { + wx.hideLoading({}) + if (code == 200) { + for (var i = 0; i < data.rows.length; i++) { + var item = data.rows[i] + if (item.coverPhotos.length > 0) { + var photos = item.coverPhotos.split(',') + data.rows[i].showPhoto = app.baseUrls.cardUrl + app.baseUrls.baseImgUrl + photos[0] + } else { + data.rows[i].showPhoto = 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.czcaizhi.com%2FContent%2FUploadFiles%2Fimage%2F20180920%2F20180920133956_3429.jpg&refer=http%3A%2F%2Fwww.czcaizhi.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1622110389&t=4ae9d4f943c30ac6d43801515eec97e5' + } + } + if (_self.data.currentPage > 1) { + if (data.rows.length > 0) { + _self.data.noticeList = _self.data.noticeList.concat(data.rows) + } + } else { + _self.data.noticeList = data.rows + } + _self.setData({ + noticeList: _self.data.noticeList, + totalSize: data.total + }) + } + }, + function (code, err) { + wx.hideLoading({}) + console.log(err) + }) }, /** * 延迟搜索 @@ -44,6 +96,8 @@ Page({ timer() { var _self = this; this.setData({ + currentPage: 1, + totalSize: 0, searchWaiting: true }) let promise = new Promise((resolve, reject) => { @@ -55,6 +109,7 @@ Page({ }) if (_self.data.countTime <= 0) { console.log('开始搜索: ' + _self.data.searchKey); + _self.setData({ countTime: 2000, searchWaiting: false, @@ -64,6 +119,9 @@ Page({ }, 1000) }) promise.then((setTimer) => { + wx.showLoading({ + title: '搜索中...', + }) _self.getResultsList(_self.data.searchKey) clearInterval(setTimer) //清除计时器 }) diff --git a/pages/notices/noticeslist.wxml b/pages/notices/noticeslist.wxml index 25c470f..d17b45e 100644 --- a/pages/notices/noticeslist.wxml +++ b/pages/notices/noticeslist.wxml @@ -8,15 +8,18 @@
- - + + - - + - 2021年4-6月特种设备作业人员培训开班通知 - 新东方在线 + {{item.title}} + + {{item.source}} + {{item.publishDate}} + diff --git a/pages/results/resultslist.js b/pages/results/resultslist.js index 75291ca..db80853 100644 --- a/pages/results/resultslist.js +++ b/pages/results/resultslist.js @@ -6,7 +6,7 @@ Page({ * 页面的初始数据 */ data: { - resultsList: [{}, {}], + resultsList: [], CustomBar: app.globalData.CustomBar, countTime: 2000, //延迟搜索 时间 searchWaiting: false, //是否等待搜索倒计时中, @@ -17,13 +17,38 @@ Page({ * 生命周期函数--监听页面加载 */ onLoad: function (options) { - + this.getResultsList('') + }, + getResultsList(key) { + var _self = this + wx.showLoading({ + title: '加载中...', + }) + app.restAjax.get(app.restAjax.path(app.apis.getScoreList, [app.baseUrls.cardUrl]), {}, { + headers: { + token: app.globalData.token + } + }, + (code, data) => { + wx.hideLoading({}) + if (code == 200) { + _self.setData({ + resultsList: data + }) + } + }, (code, error) => { + wx.hideLoading({}) + wx.showToast({ + title: '网络错误', + icon: 'error' + }) + }) }, showDetail(e) { - var item = e.currentTarget.dataset.item - wx.navigateTo({ - url: './resultsdetail', - }) + // var item = e.currentTarget.dataset.item + // wx.navigateTo({ + // url: './resultsdetail', + // }) }, doSearch(e) { this.setData({ @@ -35,9 +60,6 @@ Page({ this.timer(); } }, - getResultsList(key) { - console.log('搜索中' + key) - }, /** * 延迟搜索 */ diff --git a/pages/results/resultslist.wxml b/pages/results/resultslist.wxml index ccef27f..55afcf5 100644 --- a/pages/results/resultslist.wxml +++ b/pages/results/resultslist.wxml @@ -2,23 +2,34 @@ 成绩查询 - + + - - - + - 2021年4月考试成绩 - - - 考试日期:2021-12-12 + {{item.classPlanDTO.planName}} + + + 考试日期:{{item.examStartTime}} + + + + 培训机构:{{item.classPlanDTO.orgName}} + + + + 专业:{{item.classPlanDTO.workerCatalogName}} + + + + 成绩: + {{item.applyTestScores}} + diff --git a/utils/api.js b/utils/api.js new file mode 100644 index 0000000..5215de8 --- /dev/null +++ b/utils/api.js @@ -0,0 +1,24 @@ +var baseUrls = { + userCenter: 'https://192.168.0.103:7001/usercenter/', + cardUrl: 'http://192.168.0.111:8089/signup/', + loginUrl: 'http://192.168.0.111:8088/businesscard/', + tradeUrl: 'http://192.168.0.111:8088/businesscard/', + baseImgUrl: 'route/file/download/true/' +} + +var apis = { + login: '', + doUploadImg: '{baseUrl}app/file/uploadimage', //上传图片 + doUploadVideo: '{baseUrl}app/file/uploadvideo', //上传视频 + getArticleList: '{baseUrl}app/contentrelease/listpage', //获取开班通告或报考问答 根据categoryId获取 + getArticleDetailById: '{baseUrl}app/contentrelease/get/{contentId}', //获取开班通告报考问答详情 + getInstitutionList: '{baseUrl}app/traininginstitution/listpagerelease', //培训机构列表 + getInstitutionDetailById: '{baseUrl}app/traininginstitution/get/release/{applyId}', //培训机构详情 + getCardList: '{baseUrl}app/basic-staff-info/list-my-exam', //获取我的考试列表 + getScoreList: '{baseUrl}app/applystudents/list', //获取成绩列表 +} + +module.exports = { + apis, + baseUrls +} \ No newline at end of file diff --git a/utils/restAjax.js b/utils/restAjax.js new file mode 100644 index 0000000..24e26d7 --- /dev/null +++ b/utils/restAjax.js @@ -0,0 +1,239 @@ +const api = require('../utils/api'); + +var methods = { + POST_METHOD: 'POST', + DELETE_METHOD: 'DELETE', + PUT_METHOD: 'PUT', + GET_METHOD: 'GET' +}; + +/** + * 新增 + * @param url + * @param dataObj + * @param args + * @param successCallback + * @param errorCallback + * @param completeCallback + */ +function postJson(url, dataObj, args, successCallback, errorCallback, completeCallback) { + doAjax(url, methods.POST_METHOD, dataObj, args, successCallback, errorCallback, completeCallback); +} + +/** + * 删除 + * @param url + * @param dataObj + * @param args + * @param successCallback + * @param errorCallback + * @param completeCallback + */ +function deleteForm(url, dataObj, args, successCallback, errorCallback, completeCallback) { + doAjax(url, methods.DELETE_METHOD, dataObj, args, successCallback, errorCallback, completeCallback); +} + +/** + * 修改 + * @param url + * @param dataObj + * @param args + * @param successCallback + * @param errorCallback + * @param completeCallback + */ +function putJson(url, dataObj, args, successCallback, errorCallback, completeCallback) { + doAjax(url, methods.PUT_METHOD, dataObj, args, successCallback, errorCallback, completeCallback); +} + +/** + * 查询 + * @param url + * @param dataObj + * @param args + * @param successCallback + * @param errorCallback + * @param completeCallback + */ +function getForm(url, dataObj, args, successCallback, errorCallback, completeCallback) { + doAjax(url, methods.GET_METHOD, dataObj, args, successCallback, errorCallback, completeCallback); +} + +/** + * 执行上传 + * @param url + * @param method + * @param dataObj + * @param args + * @param successCallback + * @param errorCallback + * @param completeCallback + */ +function doAjax(url, method, dataObj, args, successCallback, errorCallback, completeCallback) { + var headers = {}; + if (args != null && typeof (args.headers) != 'undefined' && args.headers != null) { + headers = args.headers; + } + wx.request({ + url: url, + method: method, + data: dataObj, + header: headers, + dataType: 'json', + success: function (response) { + if (response.statusCode == 200) { + successCallback(response.statusCode, response.data, args); + } else { + if (errorCallback && typeof (errorCallback) == 'function') { + errorCallback(response.statusCode, response.data); + } + } + }, + fail: function (response) { + if (errorCallback && typeof errorCallback == 'function') { + errorCallback(response.statusCode, response) + } + }, + complete: function () { + if (completeCallback && typeof (completeCallback) == 'function') { + completeCallback(); + } + } + }) +} + +/** + * 检测是路径参数有重复值 + * @param pathArgArray + * @returns {boolean} + */ +function pathArgsHasSameValue(pathArgArray) { + var tempArgIndex = 0; + var tempArgs = pathArgArray[tempArgIndex]; + for (var i = (tempArgIndex + 1), item; item = pathArgArray[i]; i++) { + if (tempArgs == item) { + throw new Error('参数' + item + '有重复值!!!'); + } + if (i == pathArgArray.length - 1) { + tempArgs = pathArgArray[++tempArgIndex]; + i = tempArgIndex; + continue; + } + } +} + +/** + * 获取页面间传递的参数 + * @param url + */ +function getParamsArg(url) { + var params = url.split('?')[1]; + var paramsObj = {}; + if (typeof (params) == 'undefined' || params == null) { + return paramsObj; + } + var paramsKVs = params.split('&'); + for (var i = 0, item = null; item = paramsKVs[i++];) { + var kvs = item.split('='); + if (kvs.length == 1) { + paramsObj[kvs[0]] = null; + } + if (kvs.length == 2) { + paramsObj[kvs[0]] = decodeURI(kvs[1]); + } + } + return paramsObj; +} + +/** + * 构建路径 + * @param basePath 请求路径,{参数}, + * @param pathArgs 替换的路径参数,不能重复 + * @returns {*} + */ +function buildPath(basePath, pathArgs) { + var path = basePath; + if (!basePath || !(typeof (basePath) == 'string')) { + throw new Error('basePath必须为字符串!!!'); + } + if (!pathArgs || !Array.isArray(pathArgs)) { + throw new Error('pathArgs必须为数组!!!'); + } + var pathArgArray = basePath.match(/\{\w+\}/g); + if (!pathArgArray) { + return path; + } + pathArgsHasSameValue(pathArgArray); + for (var i = 0, item; item = pathArgArray[i]; i++) { + path = path.replace(item, pathArgs[i]); + } + return path; +} + +/** + * 通过form对象上传文件 + * @param url + * @param formData + * @param args + * @param successCallback + * @param errorCallback + * @param beforeCallback + * @param completeCallback + */ +function postFile(url, path, name, args, successCallback, errorCallback, completeCallback) { + var headers = {}; + if (args != null && typeof (args.headers) != 'undefined' && args.headers != null) { + headers = args.headers; + } + wx.uploadFile({ + filePath: path, + name: name, + url: url, + header: headers, + success: function (response) { + if (response.statusCode == 200) { + successCallback(response.statusCode, response.data, args); + } else { + if (errorCallback && typeof (errorCallback) == 'function') { + errorCallback(response.statusCode, response.data); + } + } + }, + fail: function (response) { + if (errorCallback && typeof errorCallback == 'function') { + errorCallback(response.statusCode, response.data) + } + }, + complete: function () { + if (completeCallback && typeof (completeCallback) == 'function') { + completeCallback(); + } + } + }) +}; + +/** + * xss 转义 + * @param html + * @returns {string} + */ +function escape(html) { + return String(html || '').replace(/&(?!#?[a-zA-Z0-9]+;)/g, '&') + .replace(//g, '>') + .replace(/'/g, ''').replace(/"/g, '"'); +} + + + +module.exports = { + post: postJson, + delete: deleteForm, + put: putJson, + get: getForm, + params: getParamsArg, + path: buildPath, + escape: escape, + file: postFile, + apis: api.apis, + baseUrl: api.baseUrls +} \ No newline at end of file diff --git a/utils/util.js b/utils/util.js index 6d78a94..a02f313 100644 --- a/utils/util.js +++ b/utils/util.js @@ -49,10 +49,19 @@ function qqMapToBMap(lng, lat) { var lng = (z * Math.cos(theta) + 0.0065).toFixed(5); var lat = (z * Math.sin(theta) + 0.006).toFixed(5); return [lng, lat]; +} +function isMobile(phone) { + var myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/; + if (!myreg.test(phone)) { + return false + } else { + return true + } } module.exports = { formatTime, bdMapToQQMap, - qqMapToBMap + qqMapToBMap, + isMobile } \ No newline at end of file