// pages/article/publish2.js import request from '../../utils/request' Page({ /** * 页面的初始数据 */ data: { categoryList:[], currentTab: 0, layerHide:false, typeName:'', countPic:1,//上传图片最大数量 showImgUrl: "https://api.fireflysg.com", //路径拼接,一般上传返回的都是文件名, uploadImgUrl:'https://api.fireflysg.com/firefly/media-room/photo/upload',//图片的上传的路径 switch: false, content:'', title:'', point:'', imgList:[], categoryId:1, address:'', servicePhone:'', longitude:0, latitude:0 }, submit(){ let datas={ storeName:this.data.title, intro:this.data.content, servicePhone:this.data.servicePhone, address:this.data.address, logo:this.data.logo, mediaList:this.data.imgList, longitude:this.data.longitude, latitude:this.data.latitude } console.log(datas) request._post('/firefly/store/add/new',datas, res=>{ if(res.retCode == 0){ wx.hideLoading(); setTimeout(() => { wx.showToast({ title: '发布成功,获得'+res.body.points+'积分!', icon: 'none', duration:2000 }) }, 100); wx.switchTab({ url: '/pages/near/index', }) } } ) }, currentTab: function (e) { var categoryItem = e.currentTarget.dataset.item if (this.data.categoryId == categoryItem.id){ return; } this.setData({ categoryId: categoryItem.id, typeName: categoryItem.name, layerHide: false }) }, getInputTitle(e){ this.setData({ title: e.detail.value }) }, getInputAddress(e){ this.setData({ address: e.detail.value }) }, getInputservicePhone(e){ this.setData({ servicePhone: e.detail.value }) }, getInputContent(e){ this.setData({ content: e.detail.value }) }, getInputPoint(e){ this.setData({ point: e.detail.value }) }, //监听组件事件,返回的结果 myEventListener:function(e){ console.log("上传的图片结果集合") console.log(e.detail.picsList) this.setData({ imgList:e.detail.picsList }) }, myEventListener1:function(e){ console.log("上传的图片结果集合") console.log(e.detail.picsList) this.setData({ logo:e.detail.picsList[0].mediaPath }) }, typeEvent(){ this.setData({layerHide:true}) }, getAddress(){ var _this = this wx.choosePoi({ success(res){ console.log(res,'成功') _this.setData({ address:res.address, longitude:res.longitude, latitude:res.latitude }) }, fail(res){ console.log(res,'失败') }, complete(res){ console.log(res,'结束') }, }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.getcategory() }, getcategory(){ request._post('/firefly/category/list',{type:2}, res=>{ if(res.retCode == 0){ this.setData({ categoryList:res.body }) } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })