Merge refs/remotes/origin/master into refs/heads/master
| | |
| | | "pages/sampleBooks/index", |
| | | "pages/personalCenter/publishBooks/index", |
| | | "pages/feedBack/index", |
| | | "pages/aboutUs/index" |
| | | "pages/aboutUs/index", |
| | | "pages/userSetting/index" |
| | | ] |
| | | }, |
| | | { |
| | |
| | | }, |
| | | //上传文件 |
| | | upload(data) { |
| | | console.log(data) |
| | | return request({ |
| | | url: "/file/api/ApiUpload", |
| | | method: "post", |
| | | data |
| | | header: { |
| | | 'content-type': data.contentType, |
| | | }, |
| | | data: data.buffer, |
| | | }); |
| | | }, |
| | | |
| | |
| | | }, |
| | | |
| | | newSession(data) { |
| | | let token = wx.getStorageSync(config.tokenKey) ? wx.getStorageSync(config.tokenKey) : '' |
| | | let token = wx.getStorageSync(tokenKey) ? wx.getStorageSync(tokenKey) : '' |
| | | return request({ |
| | | url: token ? "/job/api/AppUserNewSession" : "/job/api/NewSession", |
| | | method: "post", |
| | |
| | | } |
| | | |
| | | export function UpdateworksDataBytool(initData, res, value, linkList) { |
| | | let arr = [] |
| | | let arr = []; |
| | | let newArr = []; |
| | | for (let i = 0; i < initData.length; i++) { |
| | | const ele = initData[i] |
| | | const ele = initData[i]; |
| | | for (let j = 0; j < res.length; j++) { |
| | | const item = res[j] |
| | | const item = res[j]; |
| | | if (item.sequenceNum == ele.sequenceNum) { |
| | | item.refCode = ele.typeField.refCode |
| | | item.refCode = ele.typeField.refCode; |
| | | } |
| | | } |
| | | } |
| | | res.forEach((item) => { |
| | | initData.forEach((citem) => { |
| | | const updateOldData = res.find((f) => f.sequenceNum == citem.sequenceNum); |
| | | if (updateOldData) { |
| | | const obj = { |
| | | baseType: item.baseType, |
| | | baseType: citem.typeField.baseType, |
| | | order: 0, |
| | | id: item.id, |
| | | typeFieldId: item.fieldId, |
| | | sequenceNum: item.sequenceNum, |
| | | setDataAndFileLinkListRequest: [] |
| | | } |
| | | id: updateOldData.id, |
| | | typeFieldId: citem.typeField.id, |
| | | sequenceNum: citem.sequenceNum, |
| | | setDataAndFileLinkListRequest: [], |
| | | }; |
| | | for (let k in value) { |
| | | if (item.refCode === k) { |
| | | if (typeof value[k] == 'object') { |
| | | obj.strValue = JSON.stringify(value[k][0]) |
| | | obj.setDataAndFileLinkListRequest = linkList |
| | | if (citem.typeField.refCode === k) { |
| | | if (typeof value[k] == "object" && k != "region") { |
| | | obj.strValue = JSON.stringify(linkList); |
| | | obj.setDataAndFileLinkListRequest = linkList; |
| | | } else if (typeof value[k] == "object" && k == "region") { |
| | | obj.strValue = value[k]?.join("/"); |
| | | obj.setDataAndFileLinkListRequest = [{ area: value[k] }]; |
| | | } else { |
| | | if (obj.baseType === 'String') { |
| | | obj.strValue = value[k] + '' |
| | | } else if (obj.baseType === 'Text') { |
| | | obj.textValue = value[k] + '' |
| | | obj.strValue = value[k].toString(); |
| | | } |
| | | } |
| | | } |
| | | if (obj.strValue) { |
| | | arr.push(obj); |
| | | } |
| | | } else { |
| | | obj.strValue = value[k] + '' |
| | | const newObj = { |
| | | baseType: citem.typeField.baseType, |
| | | order: 0, |
| | | typeFieldId: citem.typeField.id, |
| | | sequenceNum: citem.sequenceNum, |
| | | setDataAndFileLinkListRequest: [], |
| | | }; |
| | | for (let k in value) { |
| | | if (citem.typeField.refCode === k) { |
| | | if (typeof value[k] == "object") { |
| | | newObj.strValue = JSON.stringify(linkList); |
| | | newObj.setDataAndFileLinkListRequest = linkList; |
| | | } else { |
| | | newObj.strValue = value[k].toString(); |
| | | } |
| | | } |
| | | } |
| | | if (newObj.strValue) { |
| | | newArr.push(newObj); |
| | | } |
| | | // if (obj.strValue) { |
| | | arr.push(obj) |
| | | // } |
| | | }) |
| | | return arr |
| | | } |
| | | }); |
| | | return { |
| | | updateData: arr, |
| | | newData: newArr, |
| | | }; |
| | | } |
| | | |
| | | export function download(url) { |
| | |
| | | return uuid.join('') |
| | | } |
| | | |
| | | export function getFileMd5(file, chunkSize) { |
| | | export function getFileMd5(file) { |
| | | return new Promise((resolve, reject) => { |
| | | let blobSlice = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice |
| | | let chunks = Math.ceil(file.size / chunkSize) |
| | | let currentChunk = 0 |
| | | let spark = new SparkMD5.ArrayBuffer() |
| | | let fileReader = new FileReader() |
| | | fileReader.onload = function (e) { |
| | | spark.append(e.target.result) |
| | | currentChunk++ |
| | | if (currentChunk < chunks) { |
| | | loadNext() |
| | | } else { |
| | | const md5 = spark.end() |
| | | spark.append(file) |
| | | const md5 = spark.end(false) |
| | | resolve(md5) |
| | | } |
| | | } |
| | | fileReader.onerror = function (e) { |
| | | reject(e) |
| | | } |
| | | |
| | | function loadNext() { |
| | | let start = currentChunk * chunkSize |
| | | let end = start + chunkSize |
| | | if (end > file.size) { |
| | | end = file.size |
| | | } |
| | | fileReader.readAsArrayBuffer(blobSlice.call(file, start, end)) |
| | | } |
| | | loadNext() |
| | | }) |
| | | } |
| | | |
| | |
| | | }) |
| | | if (this.data.userInfo.role == 'Teacher') { |
| | | this.setData({ |
| | | teacherInfo: { |
| | | schoolName: JSON.parse(this.data.userInfo.data).schoolName, |
| | | courseName: JSON.parse(this.data.userInfo.data).courseName, |
| | | }, |
| | | contactInfo: { |
| | | fullName: JSON.parse(this.data.userInfo.data).fullName, |
| | | phone: JSON.parse(this.data.userInfo.data).phone, |
| | | detailedAddress: JSON.parse(this.data.userInfo.data).detailedAddress |
| | | } |
| | | 'teacherInfo.schoolName': JSON.parse(this.data.userInfo.data).schoolName, |
| | | 'teacherInfo.courseName': JSON.parse(this.data.userInfo.data).courseName, |
| | | 'contactInfo.fullName': JSON.parse(this.data.userInfo.data).fullName, |
| | | 'contactInfo.phone': JSON.parse(this.data.userInfo.data).phone, |
| | | 'contactInfo.detailedAddress': JSON.parse(this.data.userInfo.data).detailedAddress, |
| | | }) |
| | | } |
| | | if (wx.getStorageSync("paperBookList")) { |
| | | this.setData({ |
| | | paperBookList: JSON.parse(wx.getStorageSync("paperBookList")), |
| | | bookList: JSON.parse(wx.getStorageSync("paperBookList")) |
| | | paperBookList: wx.getStorageSync("paperBookList"), |
| | | bookList: wx.getStorageSync("paperBookList") |
| | | }) |
| | | } |
| | | if (wx.getStorageSync("electronicBookList")) { |
| | | this.setData({ |
| | | electronicBookList: JSON.parse(wx.getStorageSync("electronicBookList")) |
| | | electronicBookList: wx.getStorageSync("electronicBookList") |
| | | }) |
| | | } |
| | | this.getSelectBookCount(); |
| | |
| | | app.MG.resource.getCmsTypeByRefCode({ refCodes: ['jsek_electronicSampleBook'] }).then((res) => { |
| | | this.setData({ |
| | | description: res[0].description, |
| | | teacherInfo: { |
| | | workInfo: res[0].cmsTypeLinks[0].children |
| | | }, |
| | | 'teacherInfo.workInfo': res[0].cmsTypeLinks[0].children, |
| | | }) |
| | | }) |
| | | }, |
| | |
| | | if (res && res.length > 0) { |
| | | this.setData({ |
| | | description: res[0].description, |
| | | teacherInfo: { |
| | | workInfo: res[0].cmsTypeLinks[0].children |
| | | }, |
| | | 'teacherInfo.workInfo': res[0].cmsTypeLinks[0].children, |
| | | }) |
| | | } |
| | | }) |
| | |
| | | } |
| | | applyInfo = { |
| | | ticketRefCodeOrGuid: 'electronicSampleBookapplyNum', |
| | | roleId: userStore.userInfo.roleId, |
| | | roleId: that.data.userInfo.roleId, |
| | | refType: 'applyBook' |
| | | } |
| | | } else { |
| | |
| | | success: function (res) { |
| | | if (res.confirm) { |
| | | if (that.data.active == '1') { |
| | | that.data.electronicBookList.forEach((obj, index) => { |
| | | let eList = that.data.electronicBookList; |
| | | eList.forEach((obj, index) => { |
| | | if (obj.id == item.id) { |
| | | that.data.electronicBookList.splice(index, 1); |
| | | eList.splice(index, 1); |
| | | } |
| | | }) |
| | | that.setData({ |
| | | bookList: that.data.electronicBookList |
| | | bookList: eList |
| | | }) |
| | | wx.setStorageSync("electronicBookList", that.data.electronicBookList); |
| | | wx.setStorageSync("electronicBookList", eList); |
| | | } else { |
| | | that.data.paperBookList.forEach((obj, index) => { |
| | | let pList = that.data.paperBookList; |
| | | pList.forEach((obj, index) => { |
| | | if (obj.id == item.id) { |
| | | that.data.paperBookList.splice(index, 1); |
| | | pList.splice(index, 1); |
| | | } |
| | | }) |
| | | that.setData({ |
| | | bookList: this.data.paperBookList |
| | | bookList: pList |
| | | }) |
| | | wx.setStorageSync("paperBookList", that.data.paperBookList); |
| | | wx.setStorageSync("paperBookList", pList); |
| | | } |
| | | } else if (res.cancel) { |
| | | } |
| | |
| | | <t-cell title="左滑单操作" note="辅助信息" bordered="{{false}}"> |
| | | <view class="listItem flex"> |
| | | <view class="specialSubject-img"> |
| | | <image src="{{item.icon}}" mode="aspectFill" class="img" /> |
| | | <image src="{{item.icon}}" mode="aspectFill" class="img" wx:if="{{item.icon}}" /> |
| | | <image src="/static/images/default-book-img.png" mode="aspectFill" class="img" wx:else="" /> |
| | | </view> |
| | | <view class="body-info"> |
| | | <view class="name">{{item.name}}</view> |
| | | <view class="name">{{item.title}}</view> |
| | | <view class="author">作者:{{item.author}}</view> |
| | | <view class="author">ISBN:{{item.isbn}}</view> |
| | | <view class="author">出版时间:{{item.publicationDate}}</view> |
| | |
| | | electronicBookList: [], //样书单电子书 |
| | | paperBookCount: 0, //纸质书剩余次数 |
| | | ebookCount: 0, //电子书剩余次数 |
| | | num: 0, |
| | | }, |
| | | |
| | | /** |
| | |
| | | }) |
| | | } |
| | | this.getIconTypeList(); |
| | | this.getBookList(false); |
| | | |
| | | // 获取重点项目 |
| | | this.getProjectList('bookClassification'); |
| | | //新形态教材 |
| | |
| | | } |
| | | if (wx.getStorageSync("paperBookList")) { |
| | | this.setData({ |
| | | paperBookList: wx.getStorageSync("paperBookList") |
| | | paperBookList: wx.getStorageSync("paperBookList"), |
| | | }) |
| | | } |
| | | if (wx.getStorageSync("electronicBookList")) { |
| | | this.setData({ |
| | | electronicBookList: wx.getStorageSync("electronicBookList") |
| | | electronicBookList: wx.getStorageSync("electronicBookList"), |
| | | }) |
| | | } |
| | | this.setData({ |
| | | num: this.data.paperBookList.length + this.data.electronicBookList.length |
| | | }) |
| | | this.getBookList(false); |
| | | }, |
| | | |
| | | /** |
| | |
| | | this.setData({ |
| | | 'newTextBook.options': options, |
| | | }); |
| | | console.log('重点项目', this.data.newTextBook); |
| | | } |
| | | }); |
| | | }, |
| | |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | if (that.data.alreadyElectronicBookList.length > 0) { |
| | | that.data.alreadyElectronicBookList.forEach((eBook) => { |
| | | eBook.content.forEach((eBookItem) => { |
| | |
| | | }, |
| | | // 搜索图书 |
| | | searchBook(e) { |
| | | console.log(e.detail.value); |
| | | this.setData({ |
| | | searchValue: e.detail.value, |
| | | }); |
| | |
| | | } |
| | | } |
| | | app.MG.ugc.getTopicMessageList(data).then((res) => { |
| | | let list = []; |
| | | res.datas.map((item) => { |
| | | if (item.content) { |
| | | item.content = JSON.parse(item.content) |
| | | } |
| | | list.push(item) |
| | | }) |
| | | this.setData({ |
| | | alreadyPaperBookList: res.datas, |
| | | alreadyPaperBookList: list, |
| | | }); |
| | | }) |
| | | }, |
| | |
| | | } |
| | | app.MG.ugc.getTopicMessageList(data).then((res) => { |
| | | let list = [] |
| | | if (res.datas.length > 0) { |
| | | res.datas.map((item) => { |
| | | if (item.feedBack) { |
| | | item.feedBack = JSON.parse(item.feedBack) |
| | |
| | | this.setData({ |
| | | alreadyElectronicBookList: list, |
| | | }); |
| | | this.getBookList(false); |
| | | } |
| | | }) |
| | | }, |
| | | |
| | |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (item.paperChecked) { |
| | | if (this.data.paperBookList.length > 0) { |
| | | this.data.paperBookList.forEach((obj, index) => { |
| | | let pList = this.data.paperBookList; |
| | | if (pList.length > 0) { |
| | | pList.forEach((obj, index) => { |
| | | if (obj.id == item.id) { |
| | | this.data.paperBookList.splice(index, 1); |
| | | pList.splice(index, 1); |
| | | } |
| | | }) |
| | | } |
| | |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | wx.setStorageSync("paperBookList", JSON.stringify(this.data.paperBookList)); |
| | | this.setData({ |
| | | paperBookList: pList, |
| | | num: pList.length + this.data.electronicBookList.length |
| | | }) |
| | | wx.setStorageSync("paperBookList", JSON.stringify(pList)); |
| | | return |
| | | } |
| | | if (role == 'Teacher') { |
| | |
| | | return |
| | | } |
| | | if (item.electronChecked) { |
| | | if (this.data.electronicBookList) { |
| | | this.data.electronicBookList.forEach((obj, index) => { |
| | | let eList = this.data.electronicBookList; |
| | | if (eList.length > 0) { |
| | | eList.forEach((obj, index) => { |
| | | if (obj.id == item.id) { |
| | | this.data.electronicBookList.splice(index, 1); |
| | | eList.splice(index, 1); |
| | | } |
| | | }) |
| | | } |
| | |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | wx.setStorageSync("electronicBookList", JSON.stringify(this.data.electronicBookList)); |
| | | this.setData({ |
| | | electronicBookList: eList, |
| | | num: eList.length + this.data.paperBookList.length |
| | | }) |
| | | wx.setStorageSync("electronicBookList", eList); |
| | | return |
| | | } |
| | | if (role == 'Teacher') { |
| | |
| | | } |
| | | }) |
| | | } |
| | | } else { |
| | | item.electronChecked = false |
| | | } |
| | | }, |
| | | getSelectBookCount(item) { |
| | |
| | | duration: 1000, |
| | | }) |
| | | this.setData({ |
| | | electronicBookList: [...this.data.electronicBookList, ...[item]] |
| | | electronicBookList: [...this.data.electronicBookList, ...[itemAttr]], |
| | | num: this.data.electronicBookList.length + this.data.paperBookList.length |
| | | }) |
| | | wx.setStorageSync("electronicBookList", JSON.stringify(this.data.electronicBookList)); |
| | | wx.setStorageSync("electronicBookList", this.data.electronicBookList); |
| | | } else { |
| | | let list = this.data.electronicBookList; |
| | | list.forEach((obj, index) => { |
| | | if (obj.id == item.id) { |
| | | list.splice(index, 1); |
| | | } |
| | | }) |
| | | item.electronChecked = false |
| | | wx.showToast({ |
| | | title: "该书已在清单列表中", |
| | | title: "已从样书申请单移除", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }) |
| | | this.setData({ |
| | | electronicBookList: list, |
| | | num: list.length + this.data.paperBookList.length |
| | | }) |
| | | wx.setStorageSync("electronicBookList", list); |
| | | } |
| | | } else { |
| | | wx.showToast({ |
| | |
| | | duration: 1000, |
| | | }) |
| | | this.setData({ |
| | | electronicBookList: [...this.data.electronicBookList, ...[item]] |
| | | electronicBookList: [itemAttr], |
| | | num: 1 + this.data.paperBookList.length |
| | | }) |
| | | wx.setStorageSync("electronicBookList", JSON.stringify(this.data.electronicBookList)); |
| | | wx.setStorageSync("electronicBookList", [itemAttr]); |
| | | } |
| | | } else { |
| | | item.electronChecked = false |
| | |
| | | duration: 1000, |
| | | }) |
| | | this.setData({ |
| | | paperBookList: [...this.data.paperBookList, ...[item]] |
| | | paperBookList: [...this.data.paperBookList, ...[itemAttr]], |
| | | num: this.data.paperBookList.lenght + this.data.electronicBookList.length |
| | | }) |
| | | wx.setStorageSync("paperBookList", JSON.stringify(this.data.paperBookList)); |
| | | console.log(this.data.paperBookList, "3") |
| | | wx.setStorageSync("paperBookList", this.data.paperBookList); |
| | | } else { |
| | | let list = this.data.paperBookList; |
| | | list.forEach((obj, index) => { |
| | | if (obj.id == item.id) { |
| | | list.splice(index, 1); |
| | | } |
| | | }) |
| | | item.paperChecked = false |
| | | wx.showToast({ |
| | | title: "该书已在清单列表中", |
| | | icon: 'none', |
| | | title: "已从样书申请单移除", |
| | | icon: "none", |
| | | duration: 1000, |
| | | }) |
| | | this.setData({ |
| | | paperChecked: list, |
| | | num: list.length + this.data.electronicBookList.length |
| | | }) |
| | | wx.setStorageSync("paperBookList", list); |
| | | } |
| | | } else { |
| | | item.paperChecked = true; |
| | |
| | | duration: 1000, |
| | | }) |
| | | this.setData({ |
| | | paperBookList: [item] |
| | | paperBookList: [itemAttr], |
| | | num: 1 + this.data.electronicBookList.length |
| | | }) |
| | | wx.setStorageSync("paperBookList", JSON.stringify(this.data.paperBookList)); |
| | | console.log(this.data.paperBookList, "4") |
| | | wx.setStorageSync("paperBookList", [itemAttr]); |
| | | } |
| | | } else { |
| | | item.paperChecked = false |
| | |
| | | <view class="header-scroll"> |
| | | <scroll-view scroll-x scroll-with-animation='true' class="srcolbox"> |
| | | <t-dropdown-menu> |
| | | <t-dropdown-item label="总分类" options="{{iconList.options}}" value="{{iconList.value}}" optionsColumns="2" bindchange="onChangeIcon" arrow-icon="" /> |
| | | <t-dropdown-item label="总分类" options="{{iconList.options}}" default-value="{{iconList.value}}" optionsColumns="2" bindchange="onChangeIcon" arrow-icon="" /> |
| | | <t-dropdown-item label="一级" options="{{stairList.options}}" value="{{stairList.value}}" optionsColumns="2" bindchange="onChangeStair" arrow-icon="" /> |
| | | <t-dropdown-item label="二级" options="{{secondList.options}}" optionsColumns="2" multiple value="{{secondList.value}}" bind:confirm="onConfirmSecond" bind:change="onChangeSecond" /> |
| | | </t-dropdown-menu> |
| | |
| | | <view class="applyBox" bindtap="goApply"> |
| | | <view class="box"> |
| | | <t-image src="/static/images/home/yangshuForm.png" mode="heightFix" class="img" /> |
| | | <view class="num">{{num}}</view> |
| | | <view class="num" wx:if="{{num > 0}}">{{num}}</view> |
| | | </view> |
| | | </view> |
| | |
| | | white-space: nowrap; |
| | | } |
| | | |
| | | .srcolbox .t-button--primary { |
| | | border-radius: 50rpx !important; |
| | | background: #FF6C00 !important; |
| | | border: none; |
| | | } |
| | | |
| | | .srcolbox .t-button--light { |
| | | background: #fff !important; |
| | | border-radius: 50rpx !important; |
| | | color: #545C63 !important; |
| | | border: 2rpx solid #979797 !important; |
| | | } |
| | | |
| | | .t-dropdown-menu:after, |
| | | .t-dropdown-menu::after { |
| | | height: 0px; |
| | |
| | | border-radius: 40rpx 40rpx 0 0; |
| | | } |
| | | |
| | | .t-radio__title { |
| | | font-size: 28rpx !important; |
| | | } |
| | | |
| | | .t-dropdown-menu__item--active, |
| | | .t-radio__icon--checked, |
| | | .t-checkbox__icon--checked { |
| | | color: #FF6C00 !important |
| | | .t-checkbox__icon--checked, |
| | | .t-radio__title--checked, |
| | | .t-checkbox__title--checked { |
| | | color: #FF6C00 !important; |
| | | } |
| | | |
| | | .srcolbox .t-checkbox--checked { |
| | | background-color: #FFECDE !important; |
| | | } |
| | | |
| | | .t-checkbox__icon--disabled { |
| | |
| | | } |
| | | |
| | | .t-radio--block { |
| | | padding: 20rpx !important; |
| | | padding: 10rpx !important; |
| | | } |
| | | |
| | | .t-radio__border { |
| | |
| | | height: 184rpx; |
| | | position: fixed; |
| | | bottom: 20%; |
| | | right: 20rpx; |
| | | right: 0; |
| | | } |
| | | |
| | | .applyBox .box { |
| | | width: 184rpx; |
| | | height: 184rpx; |
| | | color: #fff; |
| | | position: relative; |
| | | } |
| | | |
| | | .applyBox .box .t-image { |
| | | width: 100%; |
| | | height: 100%; |
| | | } |
| | | |
| | | .num { |
| | | background-color: #FD3D16; |
| | | color: #fff; |
| | | border: 2rpx solid #FFFFFF; |
| | | font-size: 24rpx; |
| | | line-height: 30rpx; |
| | | font-weight: 400; |
| | | width: 48rpx; |
| | | height: 32rpx; |
| | | text-align: center; |
| | | border-radius: 9px; |
| | | position: absolute; |
| | | top: 30rpx; |
| | | left: 118rpx; |
| | | } |
| | |
| | | const app = getApp(); |
| | | import tool from "../../../assets/js/toolClass.js"; |
| | | import { getTopicMsgCmsItemFile } from '../../../assets/js/middleGround/tool.js' |
| | | import { getTopicMsgCmsItemFile } from '../../../assets/js/middleGround/tool.js'; |
| | | import FormData from '../../../utils/formdata/index.js'; |
| | | Page({ |
| | | |
| | | /** |
| | |
| | | topicId: "", |
| | | worksInfo: [], |
| | | userId: '', |
| | | fileList: [], |
| | | imgPics: [], |
| | | file: "", |
| | | imgs: [], |
| | | protocolTxt: '', //教师协议 |
| | | protocolShow: false, |
| | | editState: true, |
| | | reasonTxt: "" |
| | | reasonTxt: "", |
| | | reasonTxtShow: false, |
| | | }, |
| | | |
| | | /** |
| | |
| | | role: 'Student' |
| | | } |
| | | } |
| | | wx.setStorageSync(app.config.userInfoKey, JSON.stringify(this.data.userInfo)); |
| | | wx.setStorageSync(app.config.userInfoKey, JSON.stringify(defaultUser)); |
| | | } |
| | | }) |
| | | }, |
| | |
| | | app.MG.ugc.getTopicMessageList(data).then((res) => { |
| | | try { |
| | | this.setData({ |
| | | fileList: [], |
| | | imgPics: [], |
| | | }) |
| | | const resData = res.datas.find((i) => i.appUserCreator.userId === this.data.userId) |
| | | if (resData) { |
| | |
| | | }) |
| | | } |
| | | let info = getTopicMsgCmsItemFile(this.data.worksInfo, resData.cmsItemDataList) |
| | | console.log(info) |
| | | this.setData({ |
| | | 'teacherInfo.fullName': info.fullName, |
| | | 'teacherInfo.schoolName ': info.schoolName, |
| | |
| | | 'teacherInfo.agree': true, |
| | | 'teacherInfo.state': resData.state, |
| | | topicId: resData.id, |
| | | topicMessageList: resData.cmsItemDataList |
| | | topicMessageList: resData.cmsItemDataList, |
| | | teachText: info.positionalTitle, |
| | | }) |
| | | if (resData.feedBack != null) { |
| | | this.setData({ |
| | |
| | | }) |
| | | } |
| | | if (this.data.teacherInfo.relevantCertificates.length > 0) { |
| | | let arr = []; |
| | | if (typeof this.data.teacherInfo.relevantCertificates == 'object') { |
| | | this.data.teacherInfo.relevantCertificates.forEach((ele) => { |
| | | let imgObj = { |
| | | md5: ele.file.md5, |
| | | linkType: 'LinkFile', |
| | | linkProtectType: 'Public', |
| | | url: app.config.requestCtx + `/file/GetPreViewImage?md5=` + ele.file.md5 |
| | | url: app.config.requestCtx + `/file/GetPreViewImage?md5=` + ele.md5 |
| | | } |
| | | this.data.fileList.push(imgObj) |
| | | arr.push(imgObj); |
| | | this.setData({ |
| | | imgPics: arr, |
| | | }); |
| | | }) |
| | | } else { |
| | | let imgObj = { |
| | |
| | | url: |
| | | app.config.requestCtx + `/file/GetPreViewImage?md5=` + this.data.teacherInfo.relevantCertificates |
| | | } |
| | | this.data.fileList.push(imgObj) |
| | | arr.push(imgObj); |
| | | this.setData({ |
| | | imgPics: arr, |
| | | }); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } catch (error) { |
| | | } |
| | |
| | | } |
| | | }) |
| | | }, |
| | | //学校名称 |
| | | onSchoolNameInput(e) { |
| | | this.setData({ |
| | | "teacherInfo.schoolName": e.detail.value, |
| | | }); |
| | | }, |
| | | //姓名 |
| | | onFullNameInput(e) { |
| | | this.setData({ |
| | | "teacherInfo.fullName": e.detail.value, |
| | | }); |
| | | }, |
| | | // 任教课程 |
| | | onCourseNameInput(e) { |
| | | this.setData({ |
| | | "teacherInfo.courseName": e.detail.value, |
| | | }); |
| | | }, |
| | | //详细地址 |
| | | onAddressInput(e) { |
| | | this.setData({ |
| | | "teacherInfo.detailedAddress": e.detail.value, |
| | | }); |
| | | }, |
| | | |
| | | |
| | | //选择职称 |
| | | onTeachPicker() { |
| | |
| | | if (phoneError === isPhoneNumber) { |
| | | this.setData({ |
| | | phoneError: !isPhoneNumber, |
| | | "teacherInfo.phone": e.detail.value, |
| | | }); |
| | | } |
| | | }, |
| | |
| | | if (telphoneError === isPhoneNumber) { |
| | | this.setData({ |
| | | telphoneError: !isPhoneNumber, |
| | | "teacherInfo.telphone": e.detail.value, |
| | | }); |
| | | } |
| | | }, |
| | |
| | | if (emailError === isPhoneNumber) { |
| | | this.setData({ |
| | | emailError: !isPhoneNumber, |
| | | "teacherInfo.email": e.detail.value, |
| | | }); |
| | | } |
| | | }, |
| | | handleAdd(e) { |
| | | const { fileList } = this.data; |
| | | console.log(e) |
| | | const { files } = e.detail; |
| | | // 方法2:每次选择图片都上传,展示每次上传图片的进度 |
| | | files.forEach(file => { |
| | | this.onUpload(file) |
| | | }) |
| | | }, |
| | | onUpload(file) { |
| | | console.log(file, '123') |
| | | const isLt2M = (0.5 * file.size) / 1024 / 1024 < 0.5 |
| | | if (!isLt2M) { |
| | | wx.showToast({ |
| | | title: "上传文件大小不能超过 500KB!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | return reject() |
| | | // 上传图片事件 |
| | | chooseImg(e) { |
| | | var that = this; |
| | | wx.chooseMedia({ |
| | | // count: 1, // 默认9 |
| | | sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有 |
| | | sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有 |
| | | success: function (res) { |
| | | // 返回选定照片的本地文件路径列表,tempFilePath也可以作为img标签的src属性显示图片 |
| | | console.log(res.tempFiles[0]) |
| | | tool.getFileMd5(res.tempFiles[0]).then((e) => { |
| | | console.log(e, 4) |
| | | if (!that.data.imgPics.find((item) => item.md5 == e)) { |
| | | let formData = new FormData(); |
| | | formData.append('Md5', e); |
| | | formData.append('FileName', e); |
| | | formData.append('FileType', res.tempFiles[0].fileType); |
| | | formData.appendFile("file", res.tempFiles[0].tempFilePath); |
| | | const data = formData.getData(); |
| | | let _token = wx.getStorageSync(app.config.tokenKey); |
| | | let header = {}; |
| | | if (_token == null) { |
| | | header["Authorization"] = `Basic ${Base64.encode(website.clientId + ":" + website.clientSecret)}`; |
| | | } else { |
| | | header["Authorization"] = `Bearer ` + _token; |
| | | } |
| | | const FileName = file.name.split('.')[0] |
| | | const Extension = file.name.split('.')[1] |
| | | const FileType = file.type |
| | | let size = 1024 |
| | | tool.getFileMd5(file, size * 1024).then((e) => { |
| | | if (!this.data.fileList.find((item) => item.md5 == e)) { |
| | | const imgData = new FormData() |
| | | imgData.append('Md5', e) |
| | | imgData.append('FileName', FileName) |
| | | imgData.append('Extension', Extension) |
| | | imgData.append('FileType', FileType) |
| | | imgData.append('MetaData', null) |
| | | imgData.append('file', file) |
| | | app.MG.file.upload(imgData).then(() => { |
| | | this.data.fileList.push({ |
| | | new Promise((resolve, reject) => { |
| | | wx.request({ |
| | | url: app.config.requestCtx + '/file/api/ApiUpload', |
| | | method: 'POST', |
| | | header: { |
| | | 'content-type': data.contentType, |
| | | ...header |
| | | }, |
| | | data: data.buffer, |
| | | success(res) { |
| | | if (res.statusCode == 200) { |
| | | resolve(res.data); if (res.data) { |
| | | let arr = []; |
| | | let imgObj = { |
| | | md5: e, |
| | | linkType: 'LinkFile', |
| | | linkProtectType: 'Public', |
| | | name: FileName, |
| | | type: FileType, |
| | | url: app.config.requestCtx + `/file/GetPreViewImage?md5=` + e |
| | | url: |
| | | app.config.requestCtx + `/file/GetPreViewImage?md5=` + e |
| | | } |
| | | arr = [...that.data.imgPics, ...[imgObj]]; |
| | | |
| | | that.setData({ |
| | | imgPics: arr, |
| | | }); |
| | | } |
| | | } else { |
| | | reject('运行时错误,请稍后再试'); |
| | | } |
| | | } |
| | | }) |
| | | }) |
| | | } else { |
| | | ElMessage.error('当前文件已上传,请勿重复操作!') |
| | | wx.showToast({ |
| | | title: "当前文件已上传,请勿重复操作!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | } |
| | | }) |
| | | .catch((e) => { |
| | | console.error(e) |
| | | }) |
| | | }, |
| | | handleRemove(e) { |
| | | const { index } = e.detail; |
| | | const { fileList } = this.data; |
| | | fileList.splice(index, 1); |
| | | this.setData({ |
| | | fileList, |
| | | } |
| | | }); |
| | | }, |
| | | // 删除图片 |
| | | deleteImg(e) { |
| | | var imgs = this.data.imgPics; |
| | | var index = e.currentTarget.dataset.index; |
| | | imgs.splice(index, 1); |
| | | this.setData({ |
| | | imgPics: imgs |
| | | }); |
| | | }, |
| | | // 预览现场图片 |
| | | previewImg(e) { |
| | | //获取当前图片的下标 |
| | | var index = e.currentTarget.dataset.index; |
| | | //所有图片 |
| | | let imgs = []; |
| | | this.data.imgPics.forEach(item => { |
| | | imgs.push(item.url) |
| | | }) |
| | | wx.previewImage({ |
| | | //当前显示图片 |
| | | current: imgs[index], |
| | | //所有图片 |
| | | urls: imgs |
| | | }) |
| | | }, |
| | | onChange() { |
| | | console.log(this.data.teacherInfo.agree, 12) |
| | | if (this.data.teacherInfo.agree) { |
| | | this.setData({ |
| | | 'teacherInfo.agree': false, |
| | | }); |
| | | } else { |
| | | this.setData({ |
| | | 'teacherInfo.agree': true, |
| | | }); |
| | | } |
| | | |
| | | }, |
| | | //查看教师认证服务 |
| | |
| | | onVisibleChange(e) { |
| | | this.setData({ |
| | | protocolShow: e.detail.visible, |
| | | reasonTxtShow: e.detail.visible |
| | | }); |
| | | }, |
| | | |
| | | //查看为通过原因 |
| | | previewReason() { |
| | | this.setData({ |
| | | reasonTxtShow: true, |
| | | }); |
| | | }, |
| | | |
| | | submit() { |
| | | let that = this; |
| | | if (!that.data.teacherInfo.schoolName) { |
| | | wx.showToast({ |
| | | title: "请填写学校名称!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | return |
| | | } |
| | | if (!that.data.teacherInfo.fullName) { |
| | | wx.showToast({ |
| | | title: "请填写真实姓名!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | return |
| | | } |
| | | if (!that.data.teacherInfo.courseName) { |
| | | wx.showToast({ |
| | | title: "请填写任教课程!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | return |
| | | } |
| | | if (!that.data.teacherInfo.phone) { |
| | | wx.showToast({ |
| | | title: "请填写联系电话!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | return |
| | | } |
| | | if (!that.data.teacherInfo.email) { |
| | | wx.showToast({ |
| | | title: "请填写邮箱!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | return |
| | | } |
| | | if (that.data.teacherInfo.relevantCertificates.length == 0) { |
| | | wx.showToast({ |
| | | title: "请上传工作证!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | return |
| | | } |
| | | console.log(that.data.teacherInfo.fullName) |
| | | if (that.data.teacherInfo.agree) { |
| | | if (that.data.topicMessageList.length > 0) { |
| | | let dataRequests = tool.UpdateworksDataBytool( |
| | | that.data.worksInfo, |
| | | that.data.topicMessageList, |
| | | that.data.teacherInfo, |
| | | that.data.imgPics |
| | | ); |
| | | console.log(dataRequests, 4) |
| | | const data = { |
| | | description: '', |
| | | icon: '', |
| | | id: that.data.topicId, |
| | | topicIdOrRefCode: 'teacherRoleApproval', |
| | | name: that.data.teacherInfo.fullName + '', |
| | | content: '', |
| | | state: 'WaitAudit', |
| | | type: 'teacherRegister', |
| | | newDataRequests: dataRequests.newData, |
| | | updateDataRequests: dataRequests.updateData, |
| | | delDataRequest: { |
| | | ids: [] |
| | | } |
| | | } |
| | | let basicInfo = JSON.parse(JSON.stringify(that.data.teacherInfo)) |
| | | delete basicInfo.worksInfo |
| | | delete basicInfo.state |
| | | const userInfo = { |
| | | requests: [ |
| | | { |
| | | data: JSON.stringify(basicInfo), |
| | | name: that.data.teacherInfo.fullName + '', |
| | | type: 'newTeacherInfo' |
| | | } |
| | | ] |
| | | } |
| | | app.MG.identity.setAppUserInfo(userInfo).then((res) => { |
| | | if (res) { |
| | | app.MG.ugc.updateTopicMessage(data).then(() => { |
| | | if (res !== false) { |
| | | wx.showToast({ |
| | | title: "提交成功!请等待审核...", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | that.newGetTeacherInfo() |
| | | } |
| | | }) |
| | | } |
| | | }) |
| | | } else { |
| | | const data = { |
| | | topicIdOrRefCode: 'teacherRoleApproval', |
| | | name: that.data.teacherInfo.fullName + '', |
| | | content: '', |
| | | state: 'WaitAudit', |
| | | type: 'teacherRegister', |
| | | cmsTypeRefCode: 'jsek_teacherCertification', |
| | | newDataListRequest: tool.worksDataBytool(that.data.worksInfo, that.data.teacherInfo, that.data.imgPics) |
| | | } |
| | | |
| | | let basicInfo = JSON.parse(JSON.stringify(that.data.teacherInfo)) |
| | | delete basicInfo.worksInfo |
| | | delete basicInfo.state |
| | | const userInfo = { |
| | | requests: [ |
| | | { |
| | | data: JSON.stringify(basicInfo), |
| | | name: that.data.teacherInfo.fullName + '', |
| | | type: 'teacherInfo' |
| | | } |
| | | ] |
| | | } |
| | | app.MG.identity.setAppUserInfo(userInfo).then((res) => { |
| | | app.MG.ugc.newTopicMessage(data).then(() => { |
| | | if (res !== false) { |
| | | wx.showToast({ |
| | | title: "提交成功!请等待审核...", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | that.newGetTeacherInfo() |
| | | } |
| | | }) |
| | | }) |
| | | } |
| | | } else { |
| | | wx.showToast({ |
| | | title: "请同意《教师认证服务条款》!", |
| | | icon: 'none', |
| | | duration: 1000, |
| | | }) |
| | | } |
| | | |
| | | }, |
| | | |
| | |
| | | "t-input": "tdesign-miniprogram/input/input", |
| | | "t-upload": "tdesign-miniprogram/upload/upload", |
| | | "t-popup": "tdesign-miniprogram/popup/popup", |
| | | "t-checkbox": "tdesign-miniprogram/checkbox/checkbox" |
| | | "t-checkbox": "tdesign-miniprogram/checkbox/checkbox", |
| | | "t-image": "tdesign-miniprogram/image/image" |
| | | } |
| | | } |
| | |
| | | <text class="yes" wx:if="{{teacherInfo.state == 'Normal'}}">已认证</text> |
| | | <text class="no" wx:if="{{teacherInfo.state == 'Reject'}}">已驳回</text> |
| | | <text class="wait" wx:if="{{teacherInfo.state == ''}}">待认证</text> |
| | | <view class="reasonTxt" bindtap="previewReason" wx:if="{{teacherInfo.state == 'Reject'}}">查看原因</view> |
| | | </view> |
| | | </view> |
| | | <view class="from-item"> |
| | | <view class="label"> 学校: </view> |
| | | <view class="item-content"> |
| | | <t-input placeholder="请输入学校" borderless value="{{teacherInfo.schoolName}}" disabled="{{!editState}}" /> |
| | | <t-input placeholder="请输入学校" borderless value="{{teacherInfo.schoolName}}" disabled="{{!editState}}" bindchange="onSchoolNameInput" /> |
| | | </view> |
| | | </view> |
| | | <view class="from-item"> |
| | | <view class="label"> 真实姓名: </view> |
| | | <view class="item-content"> |
| | | <t-input placeholder="请输入真实姓名" borderless value="{{teacherInfo.fullName}}" disabled="{{!editState}}" /> |
| | | <t-input placeholder="请输入真实姓名" borderless value="{{teacherInfo.fullName}}" disabled="{{!editState}}" bindchange="onFullNameInput" /> |
| | | </view> |
| | | </view> |
| | | <view class="from-item"> |
| | | <view class="label"> 职称: </view> |
| | | <view class="item-content"> |
| | | <view class="item-content state" wx:if="{{editState}}"> |
| | | <t-cell arrow note="{{teachText}}" bind:click="onTeachPicker" /> |
| | | <t-picker visible="{{teachVisible}}" default-value="{{teacherInfo.positionalTitle}}" title="选择职称" cancelBtn="取消" confirmBtn="确认" bindchange="onPickerChange" bindcancel="onPickerCancel"> |
| | | <t-picker visible="{{teachVisible}}" value="{{teacherInfo.positionalTitle}}" title="选择职称" cancelBtn="取消" confirmBtn="确认" bindchange="onPickerChange" bindcancel="onPickerCancel"> |
| | | <t-picker-item options="{{teachPosts}}" /> |
| | | </t-picker> |
| | | </view> |
| | | <view class="item-content" wx:if="{{!editState}}"> |
| | | <t-cell arrow note="{{teachText}}" /> |
| | | </view> |
| | | </view> |
| | | <view class="from-item"> |
| | | <view class="label"> 任教课程: </view> |
| | | <view class="item-content"> |
| | | <t-input placeholder="请输入任教课程" borderless value="{{teacherInfo.courseName}}" /> |
| | | <t-input placeholder="请输入任教课程" borderless value="{{teacherInfo.courseName}}" bindchange="onCourseNameInput" disabled="{{!editState}}" /> |
| | | </view> |
| | | </view> |
| | | <view class="from-item"> |
| | | <view class="label"> 手机号: </view> |
| | | <view class="item-content"> |
| | | <t-input placeholder="输入手机号码" borderless value="{{teacherInfo.phone}}" type="number" tips="{{phoneError ? '手机号输入不正确' : ''}}" bindchange="onPhoneInput" /> |
| | | <t-input placeholder="输入手机号码" borderless value="{{teacherInfo.phone}}" type="number" tips="{{phoneError ? '手机号输入不正确' : ''}}" bindchange="onPhoneInput" disabled="{{!editState}}" /> |
| | | </view> |
| | | </view> |
| | | <view class="from-item"> |
| | | <view class="label"> 座机: </view> |
| | | <view class="item-content"> |
| | | <t-input placeholder="输入座机号" borderless value="{{teacherInfo.telphone}}" type="number" tips="{{telphoneError ? '座机号输入不正确' : ''}}" bindchange="onTelphoneInput" /> |
| | | <t-input placeholder="输入座机号" borderless value="{{teacherInfo.telphone}}" type="number" tips="{{telphoneError ? '座机号输入不正确' : ''}}" bindchange="onTelphoneInput" disabled="{{!editState}}" /> |
| | | </view> |
| | | </view> |
| | | <view class="from-item"> |
| | | <view class="label"> 邮箱: </view> |
| | | <view class="item-content"> |
| | | <t-input placeholder="输入邮箱" borderless value="{{teacherInfo.email}}" type="number" tips="{{emailError ? '邮箱输入不正确' : ''}}" bindchange="onEmailInput" /> |
| | | <t-input placeholder="输入邮箱" borderless value="{{teacherInfo.email}}" type="number" tips="{{emailError ? '邮箱输入不正确' : ''}}" bindchange="onEmailInput" disabled="{{!editState}}" /> |
| | | </view> |
| | | </view> |
| | | <view class="from-item"> |
| | | <view class="label"> 详细地址: </view> |
| | | <view class="item-content"> |
| | | <t-input placeholder="请输入详细地址" borderless value="{{teacherInfo.detailedAddress}}" /> |
| | | <t-input placeholder="请输入详细地址" borderless value="{{teacherInfo.detailedAddress}}" bindchange="onAddressInput" disabled="{{!editState}}" /> |
| | | </view> |
| | | </view> |
| | | </view> |
| | |
| | | <view class="from-item"> |
| | | <view class="label"> 在职教师工作证: </view> |
| | | <view class="imageBox"> |
| | | <view class="wrapper"> |
| | | <t-upload mediaType="{{['image']}}" files="{{fileList}}" bind:add="handleAdd" bind:remove="handleRemove"> |
| | | </t-upload> |
| | | <view class="weui-uploader"> |
| | | <view class='pics' wx:for="{{imgPics}}" wx:for-item="item" wx:key="*this"> |
| | | <image class='weui-uploader__img' src="{{item.url}}" data-index="{{index}}" mode="aspectFill" bindtap="previewImg"> |
| | | <icon type='cancel' class="delete-btn" data-index="{{index}}" catchtap="deleteImg"></icon> |
| | | </image> |
| | | </view> |
| | | <view class="tp_cont {{tj_ycang?'':'hide'}}" bindtap="chooseImg" wx:if="{{editState}}"> |
| | | <view class="tp_add">+</view> |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <view class="fileTip"> |
| | |
| | | </view> |
| | | </view> |
| | | <view class="protocolBox"> |
| | | <t-checkbox label="" icon="rectangle" default-checked="{{teacherInfo.agree}}" bind:change="onChange" /> |
| | | <t-checkbox label="" icon="rectangle" checked="{{teacherInfo.agree}}" bind:change="onChange" disabled="{{!editState}}" /> |
| | | <text class="wait" bind:tap="viewContent">《教师认证服务条款》</text> |
| | | </view> |
| | | <view class="btn-area"> |
| | | <button class="submit" formType="submit">提交</button> |
| | | <view class="btn-area" wx:if="{{editState}}"> |
| | | <button class="submit" bindtap="submit">提交</button> |
| | | </view> |
| | | </view> |
| | | <view class="popupBox"> |
| | | <t-popup visible="{{protocolShow}}" bind:visible-change="onVisibleChange" placement="center" close-btn> |
| | | <view class="block"> |
| | | <rich-text space="emsp" nodes="{{protocolTxt}}" class="content" /> |
| | | </view> |
| | | </t-popup> |
| | | <t-popup visible="{{reasonTxtShow}}" bind:visible-change="onVisibleChange" placement="center" close-btn> |
| | | <view class="reasonBlock"> |
| | | {{reasonTxt}} |
| | | </view> |
| | | </t-popup> |
| | | </view> |
| | | </view> |
| | |
| | | } |
| | | |
| | | .from-item .item-content { |
| | | width: 56%; |
| | | width: 75%; |
| | | border: 2rpx solid #D9D9D9; |
| | | padding: 10rpx; |
| | | } |
| | | |
| | | .from-item .stateBox { |
| | | padding: 10rpx; |
| | | display: flex; |
| | | } |
| | | |
| | | .reasonTxt { |
| | | margin-left: 40rpx; |
| | | color: #ff6d00; |
| | | } |
| | | |
| | | .from-item .t-input { |
| | |
| | | .t-cell__note { |
| | | justify-content: flex-start !important; |
| | | display: block !important; |
| | | font-size: 28rpx !important; |
| | | /* width: 300rpx; */ |
| | | } |
| | | |
| | | .state .t-cell__note { |
| | | color: #333 !important; |
| | | } |
| | | |
| | | .t-input__wrap .t-input__content, |
| | |
| | | padding: 20rpx; |
| | | } |
| | | |
| | | .wrapper { |
| | | width: 100%; |
| | | } |
| | | |
| | | .fileTip { |
| | | font-size: 24rpx; |
| | | color: #949494; |
| | |
| | | color: #ff6c00 !important; |
| | | } |
| | | |
| | | .t-popup { |
| | | .popupBox .t-popup { |
| | | width: 80% !important; |
| | | } |
| | | |
| | | .t-popup__content { |
| | | .popupBox .t-popup__content { |
| | | padding: 40rpx 10rpx !important; |
| | | padding-top: 80rpx !important; |
| | | } |
| | |
| | | .block { |
| | | height: 450px !important; |
| | | overflow: auto !important; |
| | | } |
| | | |
| | | .reasonBlock { |
| | | height: 450px !important; |
| | | overflow: auto !important; |
| | | font-size: 28rpx; |
| | | line-height: 48rpx; |
| | | } |
| | | |
| | | .btn-area { |
| | |
| | | color: #fff; |
| | | border-radius: 50rpx; |
| | | } |
| | | |
| | | /* 上传图片样式 */ |
| | | .weui-uploader { |
| | | height: 152rpx; |
| | | } |
| | | |
| | | .tp_add { |
| | | width: 152rpx; |
| | | height: 152rpx; |
| | | border-radius: 10rpx; |
| | | opacity: 1; |
| | | border: 2rpx dashed #999999; |
| | | display: flex; |
| | | justify-content: center; |
| | | align-items: center; |
| | | font-size: 59rpx; |
| | | } |
| | | |
| | | .pics { |
| | | float: left; |
| | | position: relative; |
| | | margin-right: 15px; |
| | | } |
| | | |
| | | .pics image { |
| | | width: 152rpx; |
| | | height: 152rpx; |
| | | } |
| | | |
| | | .delete-btn { |
| | | width: 20rpx; |
| | | height: 20rpx; |
| | | position: absolute; |
| | | top: -15rpx; |
| | | right: -5rpx; |
| | | } |
New file |
| | |
| | | // packagePersonal/pages/userSetting/index.js |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面初次渲染完成 |
| | | */ |
| | | onReady() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | onHide() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面卸载 |
| | | */ |
| | | onUnload() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | |
| | | }, |
| | | |
| | | /** |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | } |
| | | }) |
New file |
| | |
| | | { |
| | | "usingComponents": {} |
| | | } |
New file |
| | |
| | | <!--packagePersonal/pages/userSetting/index.wxml--> |
| | | <text>packagePersonal/pages/userSetting/index.wxml</text> |
New file |
| | |
| | | /* packagePersonal/pages/userSetting/index.wxss */ |
| | |
| | | const app = getApp() |
| | | Page({ |
| | | data: { |
| | | barHeight: '', |
| | | navBarHeight: '', |
| | | searchVal: '', |
| | | isWhite: false, |
| | | backUrl: null, |
| | |
| | | }, |
| | | |
| | | onLoad(options) { |
| | | const systInfo = wx.getSystemInfoSync(); |
| | | const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 |
| | | const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 |
| | | this.setData({ |
| | | barHeight: systInfo.statusBarHeight, |
| | | navBarHeight: navBarHeight, |
| | | }); |
| | | if (options.backUrl) { |
| | | let backUrl = JSON.parse(decodeURIComponent(options.backUrl)); |
| | | if (backUrl.options) { |
| | |
| | | getBannerList() { |
| | | const list = [] |
| | | app.MG.resource.getItem({ |
| | | path: 'jsek_banner\\jsek_homeBanner', |
| | | path: 'jsek_banner\\jsek_homeBannerApplet', |
| | | fields: { jsek_link: [] }, |
| | | paging: { start: 0, size: 9 } |
| | | }).then(res => { |
| | |
| | | <view style="text-align: center; color: #b9b9b9" wx:if="{{pageLoading}}"> |
| | | <t-loading theme="circular" size="40rpx" text="加载中..." inherit-color /> |
| | | </view> |
| | | <view class="background {{ isWhite ? 'white':''}}"> |
| | | |
| | | <view class="background {{ isWhite ? 'white':''}}" style="padding-top: {{barHeight}}px"> |
| | | <text class="text">京师E课</text> |
| | | </view> |
| | | <view class="home-page-header"> |
| | |
| | | </view> |
| | | <view class="body-info"> |
| | | <view class="name">{{item.name}}</view> |
| | | <view class="author">{{item.author}}</view> |
| | | <!-- <view class="author">{{item.author}}</view> --> |
| | | </view> |
| | | </view> |
| | | </view> |
| | |
| | | top: 0; |
| | | left: 0; |
| | | height: 80rpx; |
| | | line-height: 80rpx; |
| | | z-index: 3; |
| | | text-align: center; |
| | | padding-top: 110rpx; |
| | |
| | | |
| | | .body-info .name { |
| | | font-size: 30rpx; |
| | | height: 88rpx; |
| | | height: 80rpx; |
| | | color: #333333; |
| | | font-weight: bold; |
| | | line-height: 40rpx; |
| | |
| | | font-size: 26rpx; |
| | | display: flex; |
| | | justify-content: space-between; |
| | | display: -webkit-box; |
| | | /* 使用弹性盒子布局模型 */ |
| | | -webkit-line-clamp: 1; |
| | | /* 控制文本的行数 */ |
| | | -webkit-box-orient: vertical; |
| | | /* 设置盒子的子元素排列方向 */ |
| | | overflow: hidden; |
| | | /* 超出部分隐藏 */ |
| | | text-overflow: ellipsis; |
| | | /* 超出部分显示省略号 */ |
| | | white-space: normal; |
| | | } |
| | | |
| | | .body-info .price { |
| | |
| | | } |
| | | |
| | | .listBox2 .booksListItemBox { |
| | | width: calc(100%/3 - 30rpx); |
| | | width: calc(100%/3 - 32rpx); |
| | | margin-bottom: 30rpx; |
| | | margin-right: 45rpx; |
| | | } |
| | |
| | | height: 80rpx; |
| | | width: 188rpx; |
| | | color: #333333; |
| | | line-height: 30rpx; |
| | | overflow: hidden; |
| | | text-overflow: ellipsis; |
| | | line-height: 40rpx; |
| | | display: -webkit-box; |
| | | /* 使用弹性盒子布局模型 */ |
| | | -webkit-line-clamp: 2; |
| | | /* 控制文本的行数 */ |
| | | -webkit-box-orient: vertical; |
| | | /* 设置盒子的子元素排列方向 */ |
| | | overflow: hidden; |
| | | /* 超出部分隐藏 */ |
| | | text-overflow: ellipsis; |
| | | /* 超出部分显示省略号 */ |
| | | white-space: normal; |
| | | } |
| | |
| | | gotoUserEditPage() { |
| | | this.triggerEvent('gotoUserEditPage'); |
| | | }, |
| | | editUserType() { |
| | | this.triggerEvent('editUserType'); |
| | | }, |
| | | }, |
| | | }); |
| | |
| | | <block wx:if="{{currAuthStep === AuthStepType.ONE}}"> |
| | | <view class="user-center-card__header" bind:tap="gotoUserEditPage"> |
| | | <t-avatar image="{{userInfo.avatarUrl || defaultAvatarUrl}}" class="user-center-card__header__avatar" /> |
| | | <view> |
| | | <view class="user-center-card__header__name">{{'请登录'}}</view> |
| | | </view> |
| | | <view class="setting" bind:tap="gotoUserEditPage"> |
| | | <image src="/static/images/personal/setting.png" mode="heightFix" class="img" /> |
| | | <text>设置</text> |
| | |
| | | <!-- 已登录但未授权用户信息情况 --> |
| | | <block wx:if="{{currAuthStep === AuthStepType.TWO}}"> |
| | | <view class="user-center-card__header"> |
| | | <t-avatar image="{{userInfo.avatarUrl || defaultAvatarUrl}}" class="user-center-card__header__avatar" /> |
| | | <view class="user-center-card__header__name">{{userInfo.nickName || '微信用户'}}</view> |
| | | <!-- 需要授权用户信息,通过slot添加弹窗 --> |
| | | <view class="user-center-card__header__transparent" wx:if="{{isNeedGetUserInfo}}"> |
| | | <slot name="getUserInfo" /> |
| | | <t-avatar image="{{userInfo.icon || defaultAvatarUrl}}" class="user-center-card__header__avatar" /> |
| | | <view> |
| | | <view class="user-center-card__header__name">{{userInfo.fullName || '微信用户'}}</view> |
| | | <view class="userTypeBox"> |
| | | <text>{{userInfo.userType}}</text> |
| | | <text class="edit" bindtap="editUserType">修改</text> |
| | | </view> |
| | | </view> |
| | | |
| | | <!-- 不需要授权用户信息,仍然触发gotoUserEditPage事件 --> |
| | | <view class="user-center-card__header__transparent" bind:tap="gotoUserEditPage" wx:else></view> |
| | | <view class="setting" bind:tap="gotoUserEditPage"> |
| | | <image src="/static/images/personal/setting.png" mode="heightFix" class="img" /> |
| | | <text>设置</text> |
| | | </view> |
| | | </view> |
| | | </block> |
| | | <!-- 已登录且已经授权用户信息的情况 --> |
| | | <block wx:if="{{currAuthStep === AuthStepType.THREE}}"> |
| | | <view class="user-center-card__header" bind:tap="gotoUserEditPage"> |
| | | <t-avatar t-class="avatar" mode="aspectFill" class="user-center-card__header__avatar" image="{{userInfo.avatarUrl || defaultAvatarUrl}}" /> |
| | | <view class="user-center-card__header__name">{{userInfo.nickName || '微信用户'}}</view> |
| | | <view class="user-center-card__header"> |
| | | <t-avatar t-class="avatar" mode="aspectFill" class="user-center-card__header__avatar" image="{{userInfo.icon || defaultAvatarUrl}}" /> |
| | | <view> |
| | | <view class="user-center-card__header__name">{{userInfo.fullName || '微信用户'}}</view> |
| | | <view class="userTypeBox"> |
| | | <text>{{userInfo.userType}}</text> |
| | | <text bindtap="editUserType">修改</text> |
| | | </view> |
| | | </view> |
| | | <view class="setting" bind:tap="gotoUserEditPage"> |
| | | <image src="/static/images/personal/setting.png" mode="heightFix" class="img" /> |
| | | <text>设置</text> |
| | | </view> |
| | | </view> |
| | | </block> |
| | | </view> |
| | |
| | | margin-top: 160rpx; |
| | | margin-bottom: 30rpx; |
| | | margin-left: 20rpx; |
| | | height: 96rpx; |
| | | height: 120rpx; |
| | | line-height: 48rpx; |
| | | display: flex; |
| | | justify-content: flex-start; |
| | |
| | | } |
| | | |
| | | .user-center-card__header__avatar { |
| | | width: 96rpx; |
| | | height: 96rpx; |
| | | width: 120rpx; |
| | | height: 120rpx; |
| | | border-radius: 48rpx; |
| | | overflow: hidden; |
| | | } |
| | |
| | | margin-right: 16rpx; |
| | | } |
| | | |
| | | .userTypeBox { |
| | | margin-left: 24rpx; |
| | | font-size: 28rpx; |
| | | padding-top: 15rpx; |
| | | } |
| | | |
| | | .edit { |
| | | margin-left: 20rpx; |
| | | color: #ff6d00; |
| | | } |
| | | |
| | | .user-center-card__header__transparent { |
| | | position: absolute; |
| | | left: 0; |
| | |
| | | type: 'contact', |
| | | } |
| | | ]; |
| | | const userTypeList = [ |
| | | { |
| | | lable: '中职教师', |
| | | value: 'vocSchoolTeachers' |
| | | }, |
| | | { |
| | | lable: '高职教师', |
| | | value: 'vocCollegeTeachers' |
| | | }, |
| | | { |
| | | lable: '普通高校教师', |
| | | value: 'ordUniversityTeachers' |
| | | }, |
| | | { |
| | | lable: '其他读者', |
| | | value: 'otherReaders' |
| | | } |
| | | ]; |
| | | Page({ |
| | | |
| | | /** |
| | | * 页面的初始数据 |
| | | */ |
| | | data: { |
| | | barHeight: '', |
| | | navBarHeight: '', |
| | | isWhite: false, |
| | | show: false, |
| | | userInfo: { |
| | | avatarUrl: |
| | | 'https://we-retail-static-1300977798.cos.ap-guangzhou.myqcloud.com/retail-ui/components-exp/avatar/avatar-1.jpg', |
| | | nickName: 'TDesign', |
| | | phoneNumber: '13438358888', |
| | | }, |
| | | userInfo: {}, |
| | | currAuthStep: 1, |
| | | userTypeActive: '', |
| | | userTypeList, |
| | | teacherState: { |
| | | state: '', |
| | | reasonTxt: '', |
| | |
| | | integral: 0, |
| | | menuData, |
| | | moreMenu, |
| | | moreMenu1 |
| | | moreMenu1, |
| | | visible: false, |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面加载 |
| | | */ |
| | | onLoad(options) { |
| | | console.log(options); |
| | | }, |
| | | |
| | | |
| | | /** |
| | | * 生命周期函数--监听页面显示 |
| | | */ |
| | | onShow() { |
| | | if (wx.getStorageSync(app.config.userInfoKey)) { |
| | | onLoad() { |
| | | const systInfo = wx.getSystemInfoSync(); |
| | | const menu = wx.getMenuButtonBoundingClientRect(); // 胶囊信息 |
| | | const navBarHeight = (menu.top - systInfo.statusBarHeight) * 2 + menu.height; // 导航栏高度 |
| | | this.setData({ |
| | | show: true, |
| | | userInfo: JSON.parse(wx.getStorageSync(app.config.userInfoKey)) |
| | | }) |
| | | |
| | | if (typeof this.getTabBar === 'function' && this.getTabBar()) { |
| | | this.getTabBar().setData({ |
| | | selected: 4 //这个数字是当前页面在tabBar中list数组的索引 |
| | | }) |
| | | } |
| | | this.getTeacherInfo() |
| | | barHeight: systInfo.statusBarHeight, |
| | | navBarHeight: navBarHeight, |
| | | }); |
| | | if (wx.getStorageSync(app.config.tokenKey)) { |
| | | this.setData({ |
| | | currAuthStep: 2, |
| | | }); |
| | | this.getUserInfo() |
| | | } else { |
| | | this.setData({ |
| | | currAuthStep: 1, |
| | | }); |
| | | wx.navigateTo({ |
| | | url: "/pages/testLogin/index", |
| | | }); |
| | | } |
| | | |
| | | }, |
| | | /** |
| | | * 生命周期函数--监听页面隐藏 |
| | | */ |
| | | onHide() { |
| | | this.setData({ |
| | | show: false |
| | | }) |
| | | onShow() { |
| | | |
| | | }, |
| | | /** |
| | | * 页面相关事件处理函数--监听用户下拉动作 |
| | | */ |
| | | onPullDownRefresh() { |
| | | this.init(); |
| | | this.getUserInfo() |
| | | }, |
| | | /** |
| | | * 页面上拉触底事件的处理函数 |
| | | */ |
| | | onReachBottom() { |
| | | }, |
| | | // 获取登录用户身份 |
| | | getUserInfo() { |
| | | app.MG.identity.getCurrentAppUser().then(res => { |
| | | // 用户信息优先级:教师认证 > 微信 > 学生(注册时默认) |
| | | if (res) { |
| | | //获取用户类型 |
| | | let userTypeData = res.infoList.find((item) => item.type == 'userType') |
| | | let type = ""; |
| | | if (userTypeData) { |
| | | this.data.userTypeActive = JSON.parse(userTypeData.data).userType; |
| | | type = userTypeList.find((item) => item.value === this.data.userTypeActive)?.lable; |
| | | } else { |
| | | type = '-' |
| | | } |
| | | let defaultUser = {}; |
| | | let teacherRole = res.roleLinks.find((item) => item.role.refCode == 'teacher') |
| | | let teacherInfos = res.infoList.find((item) => item.type == 'teacherInfo') |
| | | let secretData = res.secretList.find(i => i.type == 'LoginNameAndPassword') |
| | | let WeChatInfo = res.infoList.find((item) => item.type === "WeChat"); |
| | | if (teacherRole && teacherInfos) { |
| | | defaultUser = { |
| | | ...teacherInfos, |
| | | fullName: teacherInfos.fullName, |
| | | icon: teacherInfos.icon, |
| | | userId: res.userId, |
| | | role: 'Teacher', |
| | | roleId: teacherRole.role.id, |
| | | userType: type |
| | | } |
| | | this.setData({ |
| | | currAuthStep: 2, |
| | | }); |
| | | |
| | | } else if (WeChatInfo) { |
| | | defaultUser = { |
| | | ...WeChatInfo, |
| | | fullName: WeChatInfo.name, |
| | | icon: WeChatInfo.icon, |
| | | userId: res.userId, |
| | | userType: type |
| | | } |
| | | this.setData({ |
| | | currAuthStep: 3, |
| | | }); |
| | | } else if (secretData) { |
| | | defaultUser = { |
| | | fullName: secretData.credential, |
| | | icon: "", |
| | | userId: res.userId, |
| | | userType: type |
| | | } |
| | | } |
| | | this.setData({ |
| | | userInfo: defaultUser |
| | | }) |
| | | this.getTeacherInfo() |
| | | wx.setStorageSync(app.config.userInfoKey, JSON.stringify(this.data.userInfo)); |
| | | } |
| | | }); |
| | | }, |
| | | //教师信息 |
| | | getTeacherInfo() { |
| | |
| | | } |
| | | } |
| | | app.MG.ugc.getTopicMessageList(data).then((res) => { |
| | | console.log(this.data.userInfo, "userInfo") |
| | | const resData = res.datas.find((i) => i.appUserCreator.userId == this.data.userInfo.userId) |
| | | if (resData) { |
| | | this.setData({ |
| | |
| | | toCertification() { |
| | | wx.navigateTo({ |
| | | url: "/packageDomain/pages/teacherCertification/index", |
| | | }); |
| | | }, |
| | | //修改用户类型 |
| | | editUserType() { |
| | | console.log(44) |
| | | if (!this.data.visible) { |
| | | this.setData({ |
| | | visible: true, |
| | | }); |
| | | } |
| | | }, |
| | | onVisibleChange(e) { |
| | | this.setData({ |
| | | visible: e.detail.visible, |
| | | }); |
| | | }, |
| | | //设置 |
| | | gotoUserEditPage() { |
| | | wx.navigateTo({ |
| | | url: "/packagePersonal/pages/userSetting/index", |
| | | }); |
| | | }, |
| | | |
| | |
| | | * 用户点击右上角分享 |
| | | */ |
| | | onShareAppMessage() { |
| | | |
| | | }, |
| | | |
| | | onPageScroll(e) { |
| | | this.setData({ |
| | | isWhite: e.scrollTop > 50 ? true : false |
| | | }) |
| | | |
| | | }, |
| | | //跳转关于我们和联系我们 |
| | |
| | | "navigationStyle": "custom", |
| | | "usingComponents": { |
| | | "t-user-center-card": "./components/user-center-card/index", |
| | | "t-image": "tdesign-miniprogram/image/image" |
| | | "t-image": "tdesign-miniprogram/image/image", |
| | | "t-popup": "tdesign-miniprogram/popup/popup" |
| | | }, |
| | | "enablePullDownRefresh": true |
| | | } |
| | |
| | | <view class="background {{ isWhite ? 'white':''}}"> |
| | | <view style="width: 100%; height: {{barHeight}}px;"></view> |
| | | <view class="background {{ isWhite ? 'white':''}}" style="padding-top: {{barHeight}}px"> |
| | | <text class="text">个人中心</text> |
| | | </view> |
| | | <view class="home-page"> |
| | | <view class="bg"> |
| | | <image src="/static/images/personal/my-bg.png" mode="heightFix" class="image" /> |
| | | </view> |
| | | <!-- <image class="background" src="/static/images/personal/my-bg.png" mode="heightFix" /> --> |
| | | <t-user-center-card userInfo="{{userInfo}}" isPhoneHide="{{true}}" name-class="custom-name-class" phone-class="custom-phone-class" avatar-class="customer-avatar-class" currAuthStep="{{currAuthStep}}" bind:gotoUserEditPage="gotoUserEditPage" /> |
| | | <t-user-center-card userInfo="{{userInfo}}" isPhoneHide="{{true}}" name-class="custom-name-class" phone-class="custom-phone-class" avatar-class="customer-avatar-class" currAuthStep="{{currAuthStep}}" bind:gotoUserEditPage="gotoUserEditPage" bind:editUserType="editUserType" /> |
| | | <view class="content-wrapper"> |
| | | <view class="topBox"> |
| | | <view class="teacherBox"> |
| | |
| | | </view> |
| | | </view> |
| | | </view> |
| | | <t-popup visible="{{visible}}" bind:visible-change="onVisibleChange" placement="bottom"> |
| | | <view class="block"> |
| | | <view class="header"> |
| | | <view class="title">请选择您的用户类型</view> |
| | | </view> |
| | | <view class="body"> |
| | | <view wx:for="{{userTypeList}}" wx:for-item="item" wx:for-index="index" wx:key="index" data-info="{{item}}" bindtap="tabUserTypeClick" :class="item.value == userTypeActive ? 'activeItem item hover' : 'item hover'"> |
| | | {{ item.lable }} |
| | | </view> |
| | | </view> |
| | | <view class="footer"> |
| | | <button class="submit" bindtap="submit">提交</button> |
| | | </view> |
| | | </view> |
| | | </t-popup> |
| | | </view> |
| | |
| | | top: 0; |
| | | left: 0; |
| | | height: 80rpx; |
| | | line-height: 80rpx; |
| | | z-index: 3; |
| | | text-align: center; |
| | | padding-top: 60rpx; |
| | | font-size: 36rpx; |
| | | } |
| | | |
| | |
| | | text-align: center; |
| | | margin-top: 20rpx; |
| | | } |
| | | |
| | | .block { |
| | | width: 100vw; |
| | | height: 240px; |
| | | background: #fff; |
| | | border-top-left-radius: 16rpx; |
| | | border-top-right-radius: 16rpx; |
| | | } |
| | | |
| | | .header { |
| | | display: flex; |
| | | align-items: center; |
| | | height: 116rpx; |
| | | } |
| | | |
| | | .title { |
| | | flex: 1; |
| | | text-align: center; |
| | | font-weight: 600; |
| | | font-size: 36rpx; |
| | | } |
| | |
| | | } else if (secretData) { |
| | | defaultUser = { |
| | | nickName: secretData.credential, |
| | | avatarUrl: "../../static/images/index/tab.png", |
| | | avatarUrl: "", |
| | | userId: res.userId |
| | | } |
| | | } |
New file |
| | |
| | | import mimeMap from './mimeMap' |
| | | |
| | | function FormData(){ |
| | | let fileManager = wx.getFileSystemManager(); |
| | | let data = {}; |
| | | let files = []; |
| | | |
| | | this.append = (name, value)=>{ |
| | | data[name] = value; |
| | | return true; |
| | | } |
| | | |
| | | this.appendFile = (name, path)=>{ |
| | | let buffer = fileManager.readFileSync(path); |
| | | if(Object.prototype.toString.call(buffer).indexOf("ArrayBuffer") < 0){ |
| | | return false; |
| | | } |
| | | files.push({ |
| | | name: name, |
| | | buffer: buffer, |
| | | fileName: getFileNameFromPath(path) |
| | | }); |
| | | return true; |
| | | } |
| | | |
| | | this.getData = ()=>convert(data, files) |
| | | } |
| | | |
| | | function getFileNameFromPath(path){ |
| | | let idx=path.lastIndexOf("/"); |
| | | return path.substr(idx+1); |
| | | } |
| | | |
| | | function convert(data, files){ |
| | | let boundaryKey = 'wxmpFormBoundary' + randString(); // 数据分割符,一般是随机的字符串 |
| | | let boundary = '--' + boundaryKey; |
| | | let endBoundary = boundary + '--'; |
| | | |
| | | let postArray = []; |
| | | //拼接参数 |
| | | if(data && Object.prototype.toString.call(data) == "[object Object]"){ |
| | | for(let key in data){ |
| | | postArray = postArray.concat(formDataArray(boundary, key, data[key])); |
| | | } |
| | | } |
| | | //拼接文件 |
| | | if(files && Object.prototype.toString.call(files) == "[object Array]"){ |
| | | for(let i in files){ |
| | | let file = files[i]; |
| | | postArray = postArray.concat(formDataArray(boundary, file.name, file.buffer, file.fileName)); |
| | | } |
| | | } |
| | | //结尾 |
| | | let endBoundaryArray = []; |
| | | for (var i = 0; i < endBoundary.length; i++) { // 最后取出结束boundary的charCode |
| | | endBoundaryArray.push(...endBoundary.utf8CodeAt(i)); |
| | | } |
| | | postArray = postArray.concat(endBoundaryArray); |
| | | return { |
| | | contentType: 'multipart/form-data; boundary=' + boundaryKey, |
| | | buffer: new Uint8Array(postArray).buffer |
| | | } |
| | | } |
| | | |
| | | function randString() { |
| | | let res = ""; |
| | | for (let i = 0; i < 17; i++) { |
| | | let n = parseInt(Math.random() * 62); |
| | | if (n <= 9) { |
| | | res += n; |
| | | } |
| | | else if (n <= 35) { |
| | | res += String.fromCharCode(n + 55); |
| | | } |
| | | else { |
| | | res += String.fromCharCode(n + 61); |
| | | } |
| | | } |
| | | return res; |
| | | } |
| | | |
| | | function formDataArray(boundary, name, value, fileName){ |
| | | let dataString = ''; |
| | | let isFile = !!fileName; |
| | | |
| | | dataString += boundary + '\r\n'; |
| | | dataString += 'Content-Disposition: form-data; name="' + name + '"'; |
| | | if (isFile){ |
| | | dataString += '; filename="' + fileName + '"' + '\r\n'; |
| | | dataString += 'Content-Type: ' + getFileMime(fileName) + '\r\n\r\n'; |
| | | } |
| | | else{ |
| | | dataString += '\r\n\r\n'; |
| | | dataString += value; |
| | | } |
| | | |
| | | var dataArray = []; |
| | | for (var i = 0; i < dataString.length; i++) { // 取出文本的charCode(10进制) |
| | | dataArray.push(...dataString.utf8CodeAt(i)); |
| | | } |
| | | |
| | | if (isFile) { |
| | | let fileArray = new Uint8Array(value); |
| | | dataArray = dataArray.concat(Array.prototype.slice.call(fileArray)); |
| | | } |
| | | dataArray.push(..."\r".utf8CodeAt()); |
| | | dataArray.push(..."\n".utf8CodeAt()); |
| | | |
| | | return dataArray; |
| | | } |
| | | |
| | | function getFileMime(fileName){ |
| | | let idx = fileName.lastIndexOf("."); |
| | | let mime = mimeMap[fileName.substr(idx)]; |
| | | return mime?mime:"application/octet-stream" |
| | | } |
| | | |
| | | String.prototype.utf8CodeAt = function(i) { |
| | | var str = this; |
| | | var out = [], p = 0; |
| | | var c = str.charCodeAt(i); |
| | | if (c < 128) { |
| | | out[p++] = c; |
| | | } else if (c < 2048) { |
| | | out[p++] = (c >> 6) | 192; |
| | | out[p++] = (c & 63) | 128; |
| | | } else if ( |
| | | ((c & 0xFC00) == 0xD800) && (i + 1) < str.length && |
| | | ((str.charCodeAt(i + 1) & 0xFC00) == 0xDC00)) { |
| | | // Surrogate Pair |
| | | c = 0x10000 + ((c & 0x03FF) << 10) + (str.charCodeAt(++i) & 0x03FF); |
| | | out[p++] = (c >> 18) | 240; |
| | | out[p++] = ((c >> 12) & 63) | 128; |
| | | out[p++] = ((c >> 6) & 63) | 128; |
| | | out[p++] = (c & 63) | 128; |
| | | } else { |
| | | out[p++] = (c >> 12) | 224; |
| | | out[p++] = ((c >> 6) & 63) | 128; |
| | | out[p++] = (c & 63) | 128; |
| | | } |
| | | return out; |
| | | }; |
| | | |
| | | |
| | | export default FormData; |
New file |
| | |
| | | const mimeMap = { |
| | | "0.001": "application/x-001", |
| | | "0.323": "text/h323", |
| | | "0.907": "drawing/907", |
| | | ".acp": "audio/x-mei-aac", |
| | | ".aif": "audio/aiff", |
| | | ".aiff": "audio/aiff", |
| | | ".asa": "text/asa", |
| | | ".asp": "text/asp", |
| | | ".au": "audio/basic", |
| | | ".awf": "application/vnd.adobe.workflow", |
| | | ".bmp": "application/x-bmp", |
| | | ".c4t": "application/x-c4t", |
| | | ".cal": "application/x-cals", |
| | | ".cdf": "application/x-netcdf", |
| | | ".cel": "application/x-cel", |
| | | ".cg4": "application/x-g4", |
| | | ".cit": "application/x-cit", |
| | | ".cml": "text/xml", |
| | | ".cmx": "application/x-cmx", |
| | | ".crl": "application/pkix-crl", |
| | | ".csi": "application/x-csi", |
| | | ".cut": "application/x-cut", |
| | | ".dbm": "application/x-dbm", |
| | | ".dcd": "text/xml", |
| | | ".der": "application/x-x509-ca-cert", |
| | | ".dib": "application/x-dib", |
| | | ".doc": "application/msword", |
| | | ".drw": "application/x-drw", |
| | | ".dwf": "Model/vnd.dwf", |
| | | ".dwg": "application/x-dwg", |
| | | ".dxf": "application/x-dxf", |
| | | ".emf": "application/x-emf", |
| | | ".ent": "text/xml", |
| | | ".eps": "application/x-ps", |
| | | ".etd": "application/x-ebx", |
| | | ".fax": "image/fax", |
| | | ".fif": "application/fractals", |
| | | ".frm": "application/x-frm", |
| | | ".gbr": "application/x-gbr", |
| | | ".gif": "image/gif", |
| | | ".gp4": "application/x-gp4", |
| | | ".hmr": "application/x-hmr", |
| | | ".hpl": "application/x-hpl", |
| | | ".hrf": "application/x-hrf", |
| | | ".htc": "text/x-component", |
| | | ".html": "text/html", |
| | | ".htx": "text/html", |
| | | ".ico": "image/x-icon", |
| | | ".iff": "application/x-iff", |
| | | ".igs": "application/x-igs", |
| | | ".img": "application/x-img", |
| | | ".isp": "application/x-internet-signup", |
| | | ".java": "java/*", |
| | | ".jpe": "image/jpeg", |
| | | ".jpeg": "image/jpeg", |
| | | ".jpg": "application/x-jpg", |
| | | ".jsp": "text/html", |
| | | ".lar": "application/x-laplayer-reg", |
| | | ".lavs": "audio/x-liquid-secure", |
| | | ".lmsff": "audio/x-la-lms", |
| | | ".ltr": "application/x-ltr", |
| | | ".m2v": "video/x-mpeg", |
| | | ".m4e": "video/mpeg4", |
| | | ".man": "application/x-troff-man", |
| | | ".mdb": "application/msaccess", |
| | | ".mfp": "application/x-shockwave-flash", |
| | | ".mhtml": "message/rfc822", |
| | | ".mid": "audio/mid", |
| | | ".mil": "application/x-mil", |
| | | ".mnd": "audio/x-musicnet-download", |
| | | ".mocha": "application/x-javascript", |
| | | ".mp1": "audio/mp1", |
| | | ".mp2v": "video/mpeg", |
| | | ".mp4": "video/mpeg4", |
| | | ".mpd": "application/vnd.ms-project", |
| | | ".mpeg": "video/mpg", |
| | | ".mpga": "audio/rn-mpeg", |
| | | ".mps": "video/x-mpeg", |
| | | ".mpv": "video/mpg", |
| | | ".mpw": "application/vnd.ms-project", |
| | | ".mtx": "text/xml", |
| | | ".net": "image/pnetvue", |
| | | ".nws": "message/rfc822", |
| | | ".out": "application/x-out", |
| | | ".p12": "application/x-pkcs12", |
| | | ".p7c": "application/pkcs7-mime", |
| | | ".p7r": "application/x-pkcs7-certreqresp", |
| | | ".pc5": "application/x-pc5", |
| | | ".pcl": "application/x-pcl", |
| | | ".pdf": "application/pdf", |
| | | ".pdx": "application/vnd.adobe.pdx", |
| | | ".pgl": "application/x-pgl", |
| | | ".pko": "application/vnd.ms-pki.pko", |
| | | ".plg": "text/html", |
| | | ".plt": "application/x-plt", |
| | | ".png": "application/x-png", |
| | | ".ppa": "application/vnd.ms-powerpoint", |
| | | ".pps": "application/vnd.ms-powerpoint", |
| | | ".ppt": "application/x-ppt", |
| | | ".prf": "application/pics-rules", |
| | | ".prt": "application/x-prt", |
| | | ".ps": "application/postscript", |
| | | ".pwz": "application/vnd.ms-powerpoint", |
| | | ".ra": "audio/vnd.rn-realaudio", |
| | | ".ras": "application/x-ras", |
| | | ".rdf": "text/xml", |
| | | ".red": "application/x-red", |
| | | ".rjs": "application/vnd.rn-realsystem-rjs", |
| | | ".rlc": "application/x-rlc", |
| | | ".rm": "application/vnd.rn-realmedia", |
| | | ".rmi": "audio/mid", |
| | | ".rmm": "audio/x-pn-realaudio", |
| | | ".rms": "application/vnd.rn-realmedia-secure", |
| | | ".rmx": "application/vnd.rn-realsystem-rmx", |
| | | ".rp": "image/vnd.rn-realpix", |
| | | ".rsml": "application/vnd.rn-rsml", |
| | | ".rtf": "application/msword", |
| | | ".rv": "video/vnd.rn-realvideo", |
| | | ".sat": "application/x-sat", |
| | | ".sdw": "application/x-sdw", |
| | | ".slb": "application/x-slb", |
| | | ".slk": "drawing/x-slk", |
| | | ".smil": "application/smil", |
| | | ".snd": "audio/basic", |
| | | ".sor": "text/plain", |
| | | ".spl": "application/futuresplash", |
| | | ".ssm": "application/streamingmedia", |
| | | ".stl": "application/vnd.ms-pki.stl", |
| | | ".sty": "application/x-sty", |
| | | ".swf": "application/x-shockwave-flash", |
| | | ".tg4": "application/x-tg4", |
| | | ".tif": "image/tiff", |
| | | ".tiff": "image/tiff", |
| | | ".top": "drawing/x-top", |
| | | ".tsd": "text/xml", |
| | | ".uin": "application/x-icq", |
| | | ".vcf": "text/x-vcard", |
| | | ".vdx": "application/vnd.visio", |
| | | ".vpg": "application/x-vpeg005", |
| | | ".vsd": "application/x-vsd", |
| | | ".vst": "application/vnd.visio", |
| | | ".vsw": "application/vnd.visio", |
| | | ".vtx": "application/vnd.visio", |
| | | ".wav": "audio/wav", |
| | | ".wb1": "application/x-wb1", |
| | | ".wb3": "application/x-wb3", |
| | | ".wiz": "application/msword", |
| | | ".wk4": "application/x-wk4", |
| | | ".wks": "application/x-wks", |
| | | ".wma": "audio/x-ms-wma", |
| | | ".wmf": "application/x-wmf", |
| | | ".wmv": "video/x-ms-wmv", |
| | | ".wmz": "application/x-ms-wmz", |
| | | ".wpd": "application/x-wpd", |
| | | ".wpl": "application/vnd.ms-wpl", |
| | | ".wr1": "application/x-wr1", |
| | | ".wrk": "application/x-wrk", |
| | | ".ws2": "application/x-ws", |
| | | ".wsdl": "text/xml", |
| | | ".xdp": "application/vnd.adobe.xdp", |
| | | ".xfd": "application/vnd.adobe.xfd", |
| | | ".xhtml": "text/html", |
| | | ".xls": "application/x-xls", |
| | | ".xml": "text/xml", |
| | | ".xq": "text/xml", |
| | | ".xquery": "text/xml", |
| | | ".xsl": "text/xml", |
| | | ".xwd": "application/x-xwd", |
| | | ".sis": "application/vnd.symbian.install", |
| | | ".x_t": "application/x-x_t", |
| | | ".apk": "application/vnd.android.package-archive", |
| | | "0.301": "application/x-301", |
| | | "0.906": "application/x-906", |
| | | ".a11": "application/x-a11", |
| | | ".ai": "application/postscript", |
| | | ".aifc": "audio/aiff", |
| | | ".anv": "application/x-anv", |
| | | ".asf": "video/x-ms-asf", |
| | | ".asx": "video/x-ms-asf", |
| | | ".avi": "video/avi", |
| | | ".biz": "text/xml", |
| | | ".bot": "application/x-bot", |
| | | ".c90": "application/x-c90", |
| | | ".cat": "application/vnd.ms-pki.seccat", |
| | | ".cdr": "application/x-cdr", |
| | | ".cer": "application/x-x509-ca-cert", |
| | | ".cgm": "application/x-cgm", |
| | | ".class": "java/*", |
| | | ".cmp": "application/x-cmp", |
| | | ".cot": "application/x-cot", |
| | | ".crt": "application/x-x509-ca-cert", |
| | | ".css": "text/css", |
| | | ".dbf": "application/x-dbf", |
| | | ".dbx": "application/x-dbx", |
| | | ".dcx": "application/x-dcx", |
| | | ".dgn": "application/x-dgn", |
| | | ".dll": "application/x-msdownload", |
| | | ".dot": "application/msword", |
| | | ".dtd": "text/xml", |
| | | ".dwf": "application/x-dwf", |
| | | ".dxb": "application/x-dxb", |
| | | ".edn": "application/vnd.adobe.edn", |
| | | ".eml": "message/rfc822", |
| | | ".epi": "application/x-epi", |
| | | ".eps": "application/postscript", |
| | | ".exe": "application/x-msdownload", |
| | | ".fdf": "application/vnd.fdf", |
| | | ".fo": "text/xml", |
| | | ".g4": "application/x-g4", |
| | | ".tif": "image/tiff", |
| | | ".gl2": "application/x-gl2", |
| | | ".hgl": "application/x-hgl", |
| | | ".hpg": "application/x-hpgl", |
| | | ".hqx": "application/mac-binhex40", |
| | | ".hta": "application/hta", |
| | | ".htm": "text/html", |
| | | ".htt": "text/webviewhtml", |
| | | ".icb": "application/x-icb", |
| | | ".ico": "application/x-ico", |
| | | ".ig4": "application/x-g4", |
| | | ".iii": "application/x-iphone", |
| | | ".ins": "application/x-internet-signup", |
| | | ".IVF": "video/x-ivf", |
| | | ".jfif": "image/jpeg", |
| | | ".jpe": "application/x-jpe", |
| | | ".jpg": "image/jpeg", |
| | | ".js": "application/x-javascript", |
| | | ".la1": "audio/x-liquid-file", |
| | | ".latex": "application/x-latex", |
| | | ".lbm": "application/x-lbm", |
| | | ".ls": "application/x-javascript", |
| | | ".m1v": "video/x-mpeg", |
| | | ".m3u": "audio/mpegurl", |
| | | ".mac": "application/x-mac", |
| | | ".math": "text/xml", |
| | | ".mdb": "application/x-mdb", |
| | | ".mht": "message/rfc822", |
| | | ".mi": "application/x-mi", |
| | | ".midi": "audio/mid", |
| | | ".mml": "text/xml", |
| | | ".mns": "audio/x-musicnet-stream", |
| | | ".movie": "video/x-sgi-movie", |
| | | ".mp2": "audio/mp2", |
| | | ".mp3": "audio/mp3", |
| | | ".mpa": "video/x-mpg", |
| | | ".mpe": "video/x-mpeg", |
| | | ".mpg": "video/mpg", |
| | | ".mpp": "application/vnd.ms-project", |
| | | ".mpt": "application/vnd.ms-project", |
| | | ".mpv2": "video/mpeg", |
| | | ".mpx": "application/vnd.ms-project", |
| | | ".mxp": "application/x-mmxp", |
| | | ".nrf": "application/x-nrf", |
| | | ".odc": "text/x-ms-odc", |
| | | ".p10": "application/pkcs10", |
| | | ".p7b": "application/x-pkcs7-certificates", |
| | | ".p7m": "application/pkcs7-mime", |
| | | ".p7s": "application/pkcs7-signature", |
| | | ".pci": "application/x-pci", |
| | | ".pcx": "application/x-pcx", |
| | | ".pdf": "application/pdf", |
| | | ".pfx": "application/x-pkcs12", |
| | | ".pic": "application/x-pic", |
| | | ".pl": "application/x-perl", |
| | | ".pls": "audio/scpls", |
| | | ".png": "image/png", |
| | | ".pot": "application/vnd.ms-powerpoint", |
| | | ".ppm": "application/x-ppm", |
| | | ".ppt": "application/vnd.ms-powerpoint", |
| | | ".pr": "application/x-pr", |
| | | ".prn": "application/x-prn", |
| | | ".ps": "application/x-ps", |
| | | ".ptn": "application/x-ptn", |
| | | ".r3t": "text/vnd.rn-realtext3d", |
| | | ".ram": "audio/x-pn-realaudio", |
| | | ".rat": "application/rat-file", |
| | | ".rec": "application/vnd.rn-recording", |
| | | ".rgb": "application/x-rgb", |
| | | ".rjt": "application/vnd.rn-realsystem-rjt", |
| | | ".rle": "application/x-rle", |
| | | ".rmf": "application/vnd.adobe.rmf", |
| | | ".rmj": "application/vnd.rn-realsystem-rmj", |
| | | ".rmp": "application/vnd.rn-rn_music_package", |
| | | ".rmvb": "application/vnd.rn-realmedia-vbr", |
| | | ".rnx": "application/vnd.rn-realplayer", |
| | | ".rpm": "audio/x-pn-realaudio-plugin", |
| | | ".rt": "text/vnd.rn-realtext", |
| | | ".rtf": "application/x-rtf", |
| | | ".sam": "application/x-sam", |
| | | ".sdp": "application/sdp", |
| | | ".sit": "application/x-stuffit", |
| | | ".sld": "application/x-sld", |
| | | ".smi": "application/smil", |
| | | ".smk": "application/x-smk", |
| | | ".sol": "text/plain", |
| | | ".spc": "application/x-pkcs7-certificates", |
| | | ".spp": "text/xml", |
| | | ".sst": "application/vnd.ms-pki.certstore", |
| | | ".stm": "text/html", |
| | | ".svg": "text/xml", |
| | | ".tdf": "application/x-tdf", |
| | | ".tga": "application/x-tga", |
| | | ".tif": "application/x-tif", |
| | | ".tld": "text/xml", |
| | | ".torrent": "application/x-bittorrent", |
| | | ".txt": "text/plain", |
| | | ".uls": "text/iuls", |
| | | ".vda": "application/x-vda", |
| | | ".vml": "text/xml", |
| | | ".vsd": "application/vnd.visio", |
| | | ".vss": "application/vnd.visio", |
| | | ".vst": "application/x-vst", |
| | | ".vsx": "application/vnd.visio", |
| | | ".vxml": "text/xml", |
| | | ".wax": "audio/x-ms-wax", |
| | | ".wb2": "application/x-wb2", |
| | | ".wbmp": "image/vnd.wap.wbmp", |
| | | ".wk3": "application/x-wk3", |
| | | ".wkq": "application/x-wkq", |
| | | ".wm": "video/x-ms-wm", |
| | | ".wmd": "application/x-ms-wmd", |
| | | ".wml": "text/vnd.wap.wml", |
| | | ".wmx": "video/x-ms-wmx", |
| | | ".wp6": "application/x-wp6", |
| | | ".wpg": "application/x-wpg", |
| | | ".wq1": "application/x-wq1", |
| | | ".wri": "application/x-wri", |
| | | ".ws": "application/x-ws", |
| | | ".wsc": "text/scriptlet", |
| | | ".wvx": "video/x-ms-wvx", |
| | | ".xdr": "text/xml", |
| | | ".xfdf": "application/vnd.adobe.xfdf", |
| | | ".xls": "application/vnd.ms-excel", |
| | | ".xlw": "application/x-xlw", |
| | | ".xpl": "audio/scpls", |
| | | ".xql": "text/xml", |
| | | ".xsd": "text/xml", |
| | | ".xslt": "text/xml", |
| | | ".x_b": "application/x-x_b", |
| | | ".sisx": "application/vnd.symbian.install", |
| | | ".ipa": "application/vnd.iphone", |
| | | ".xap": "application/x-silverlight-app", |
| | | ".zip": "application/x-zip-compressed", |
| | | } |
| | | export default mimeMap; |