123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- // pages/login/login.js
- import WxValidate from '../../utils/wxValidate'
- const app = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- frameStyle: { useTop: true, name: '信息管理', leftArrow: true, useBar: false },
- // 主体高度
- infoHeight: '',
- // 类型
- typeList: [
- { id: '0', name: '其他' },
- { id: '1', name: '办公生活用品' },
- { id: '2', name: '办公机械' },
- { id: '3', name: '金融用品' },
- { id: '4', name: '纸制品' },
- { id: '5', name: '书写工具' },
- { id: '6', name: '桌面办公文具' },
- ],
- info: { id: '1234567', name: '11', type_name: '办公室生活用品', num: '11', money: '111', brief: '无' },
- form: {},
- stock_type: '',
- // 图片
- img_url: [],
- // 商品类型
- stock_typeList: [
- { value: '1', label: '固定资产' },
- { value: '2', label: '商品' },
- ]
- },
- back: function () {
- wx.navigateBack({ url: '/pages/home/index' })
- },
- initValidate() {
- const rules = { stock_type: { required: true, }, code: { required: false, }, type_name: { required: true, }, name: { required: true, }, num: { required: true, }, money: { required: true, }, brief: { required: true, } }
- // 验证字段的提示信息,若不传则调用默认的信息
- const messages = { stock_type: { required: '请选择商品类型', }, code: { required: '请输入固定资产编号', }, type_name: { required: '请选择类型', }, name: { required: '请输入商品名称', }, num: { required: '请输入商品数量', }, money: { required: '请输入商品单价', }, brief: { required: '请输入商品简介', } };
- this.WxValidate = new WxValidate(rules, messages)
- },
- back: function () {
- wx.navigateBack({ url: '/pages/stock/index' })
- },
- // 类型选择
- stocktypeChange: function (e) {
- let { value } = e.detail;
- let data = this.data.stock_typeList[value];
- this.setData({ 'stock_type': data.value })
- this.setData({ 'form.stock_type': data.value })
- this.setData({ 'form.stock_type_name': data.label })
- },
- // 类型选择
- typeChange: function (e) {
- let { value } = e.detail;
- let data = this.data.typeList[value];
- this.setData({ 'form.type_id': data.id })
- this.setData({ 'form.type_name': data.name })
- },
- // 上传图片
- afterRead: function (event) {
- console.log(event.detail);
- },
- // 删除图片
- uploadDelete: function (e) {
- console.log(e);
- },
- // 取消保存
- onReset: function (e) {
- this.back()
- },
- // 提交保存
- onSubmit: function (e) {
- console.log(e.detail.value);
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- if (options.id) {
- this.setData({ 'form': this.data.info })
- }
- //验证规则函数
- this.initValidate()
- // 计算高度
- this.searchHeight()
- },
- // 计算高度
- searchHeight: function () {
- let frameStyle = this.data.frameStyle;
- let client = app.globalData.client;
- let infoHeight = client.windowHeight;
- // 是否去掉状态栏
- if (frameStyle.useTop) infoHeight = infoHeight - (client.statusBarHeight + client.getMenu.height + (client.getMenu.top - client.statusBarHeight) * 2);
- // 是否减去底部菜单
- if (frameStyle.useBar) infoHeight = infoHeight - 50;
- if (infoHeight) this.setData({ infoHeight: infoHeight })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|