// pages/style/style.js const $api = require('../../utils/api.js').API; Page({ /** * 页面的初始数据 */ data: { arr1: ['短线', '中线', '长线'], arr2: ['分仓', '重仓', '全仓', '融资'], arr3: ['首板', '接力', '半路', '低吸', '价值投机', '波段锁仓', '可转债'], arr4: ['5厘米', '10厘米', '20厘米', '次新股','N字头','可转债'], form:{ join_time: '', zq: '', cw: '', df: '', init_fund: '', account_img: '' } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { $api.getEnumList().then(res => { this.setData({ arr1: res.data.data.zq, arr2: res.data.data.cw, arr3: res.data.data.df, arr4: res.data.data.pz }) }) $api.getMyStyle().then(res=>{ this.setData({ form:res.data.data }) }) }, change(e){ let value = e.target.dataset.id, item = e.target.dataset.item; let form=this.data.form; form[item] = value; this.setData({ form: form }) }, bindDateChange(e) { let form = this.data.form; form.join_time = e.detail.value; this.setData({ form: form }) }, bindinput(e){ let form = this.data.form; form.init_fund = e.detail.value; this.setData({ form: form }) }, uploadImg(){ var form = this.data.form; wx.chooseImage({ success: res => { wx.showLoading({ title: '正在上传', }) const tempFilePaths = res.tempFiles for (let i = 0; i < tempFilePaths.length; i++) { $api.upload(tempFilePaths[i].path,'file').then(res=>{ wx.hideLoading() if(res.code == 0){ form.account_img=res.data.url; this.setData({ form: form }) }else{ wx.showToast({ title: '上传失败', }) } }) .catch(err=>{ wx.hideLoading() }) } } }) }, preview(){ wx.previewImage({ urls: [this.data.form.account_img], current: this.data.form.account_img }) }, del(){ let form = this.data.form; form.account_img =''; this.setData({ form: form }) }, post(){ var form=this.data.form; if (!form.join_time){ wx.showToast({ title: '请选择入市时间', }) return } if (!form.init_fund) { wx.showToast({ title: '请输入参赛金额', }) return } if (!form.account_img) { wx.showToast({ title: '请上传账号截图', }) return } wx.showLoading({ title: '正在提交', }) $api.updateStyle(form).then(res=>{ wx.hideLoading() wx.showToast({ title: '保存成功', icon:'success' }) }) .catch(err=>{ wx.hideLoading() }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })