const Parse = getApp().Parse const company = getApp().globalData.company const dateF = require('../../../../utils/date') const rechText = require('../../../../utils/rech-text') Page({ /** * 页面的初始数据 */ data: { twoModal: false, tives: 1, region: ['江西省', '南昌市', '东湖区'], // 初始值 showheader: true, showfoot: false, type: '', title: "", show: false, nextShow: false, name: '', mobile: '', company: '', product: '' }, bindRegionChange: function(e) { // picker值发生改变都会触发该方法 console.log('picker发送选择改变,携带值为', e.detail.value) this.setData({ region: e.detail.value }) }, hideRule: function() { this.setData({ twoModal: false }) }, nextstep(e) { let { tives } = e.currentTarget.dataset let name = this.data.name let mobile = this.data.mobile if (!name || !mobile) { wx.showToast({ title: '请将信息填写完整', icon: 'none' }) return } let myreg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/; if (!myreg.test(mobile)) { wx.showToast({ title: '请填写正确手机号', icon: 'none' }) return } this.setData({ tives }) }, prostep() { let { tives } = e.currentTarget.dataset this.setData({ tives }) }, shopsubmit: function() { this.setData({ twoModal: true }) }, submit() { let company = this.data.company let product = this.data.product if (!company || product) { wx.showToast({ title: '请将信息填写完整', icon: 'none' }) return } wx.showToast({ title: '提交成功', icon: 'success' }) }, shoppreventTouchMove: function() { this.setData({ twoModal: false }) }, cancenlClicknext: function() { this.setData({ twoModal: false }) }, confirmClick1: function() { console.log('确认收货了') this.setData({ twoModal: false }) }, go1: function() { this.setData({ twoModal: false }) }, showPopup() { this.setData({ show: true }); }, nextPopup() { this.setData({ nextShow: true }); }, onClose() { this.setData({ show: false }); }, /** * 生命周期函数--监听页面加载 */ onLoad: async function(options) { let title = options.title let aid = options.aid let showheader = true console.log(options) let article = await this.getArticle(aid) // let user = article.getUser if (options.showheader) { showheader = true this.setData({ showheader: true }) } let showfoot = false let type = '' if (title == '链商城') { showfoot = true type = 'open-shop' } console.log(article) if (article && article.objectId) { this.setData({ title: title, article: article, showfoot: showfoot, type: type }) } }, async getArticle(aid) { let Article = new Parse.Query('Article') Article.include('author') let article = await Article.get(aid) if (article && article.id) { console.log(article) let articleJSON = article.toJSON() articleJSON.date = articleJSON.publishDate ? dateF.formatTime("YYYY-mm-dd", articleJSON.publishDate.iso) : dateF.formatTime("YYYY-mm-dd", articleJSON.createdAt) if (articleJSON.content) { articleJSON.content = rechText.formatRichText(articleJSON.content) } return articleJSON } }, blur(e) { let name = e.currentTarget.dataset.name this.setData({ [name]: e.detail.value }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { let user = Parse.User.current() let title = this.data.article.title let aid = this.data.article.objectId let image = this.data.article.image let query if (user) { query = `invite=${user.id}&aid=${aid}` } else { query = `aid=${aid}` } return { title: title, query: query, imageUrl: image, success: function(res) { // 转发成功 }, fail: function(res) { // 转发失败 }, }; } })