123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- import { routers, viewImage, sharePage, isFn, getGlobalVal, formatDate } from '../../../utils/util.js'
- import { GetVipInfo, UploadFile, SaveVipInfo, PostApplyBookList } from '../../../utils/api.js'
- const { navigateTo, redirectTo, navigateBack } = routers()
- const { globalData, hasLibraryService, hasVipService } = getApp()
- const { baseImgUrl, qrcodeInvalidToastText } = globalData
- Page({
-
- data: {
- baseImgUrl,
- isLoaded: 0,
- Selectdate:'',
- bookList: [],
- gradeIndex: 0,
- startTime: formatDate(new Date()),
- sexIndex: 0,
- paiDate: formatDate(new Date()),
- footerArray: [
- {
- type: 1,
- text: '取消'
- },
- {
- type: 2,
- text: '保存'
- }
- ]
- },
-
- onLoad: function (options) {
- options.vipId = getGlobalVal('vipId', `vipId_${getGlobalVal('userId')}`) || ''
- options.libId = getGlobalVal('list').length > 0 ? getGlobalVal('list')[0].libId : ''
- this.setData({ options })
-
-
-
-
- },
-
- onReady: function () {
- const obj = { navigateTo, redirectTo, navigateBack, viewImage }
- for (const i in obj) {
- this[i] = obj[i]
- }
- },
-
- onShow: function () {
- let _this = this
- wx.getStorage({
- key: 'infofrominput',
- success: function (res) {
- _this.setData({
- infofromstorage: res.data,
- })
- }
- })
- },
-
- onHide: function () {
- },
-
- onUnload: function () {
- },
-
- onPullDownRefresh: function () {
- },
-
- onReachBottom: function () {
- },
-
- onShareAppMessage: function () {
- if (isFn(sharePage)) return sharePage()
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- uploadImgCtl: function () {
- const continuousFn = { fn: this.uploadImgCtl, param: { ...arguments } }
- wx.chooseImage({
- count: 1,
- success: res => {
- UploadFile({ file: res.tempFilePaths, continuousFn }).then(res => {
- this.setData({ bookImg: res[0] })
- })
- }
- })
- },
-
- inputCtl: function (e) {
- const { value } = e.detail
- const { type } = e.currentTarget.dataset
- const { bookList } = this.data
- var temp={}
-
- temp[`${type}`] = value
-
- this.setData(temp)
- },
-
- submitCtl: function (e) {
- const continuousFn = { fn: this.submitCtl, param: { ...arguments } }
- const { libId } = this.data.options;
- const { type } = e.currentTarget.dataset
- const { bookList, bookImg, title, publish, paiDate, bookSrc, infofromstorage } = this.data
- if (type == 1) {
- wx.navigateBack({
- delta: 1
- })
- } else if (type == 2) {
- if (!title) {
- wx.showToast({
- title: '请输入书名',
- icon: 'none'
- })
- return
- }
- if (!publish) {
- wx.showToast({
- title: '请输入出版社作者',
- icon: 'none'
- })
- return
- }
- if (!bookSrc) {
- wx.showToast({
- title: '请填写书目来源',
- icon: 'none'
- })
- return
- }
-
- const bookList = infofromstorage || []
- bookList.push({
- bookImg,
- title,
- publish,
- paiDate,
- bookSrc
- })
- wx.setStorageSync('infofrominput', bookList)
- wx.showToast({
- title: '保存成功',
- })
- setTimeout(() => {
- navigateBack()
- }, 2000)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- },
-
- deleteImg:function(){
- this.setData({ bookImg:''})
- }
- })
|