| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 | 
							- import {
 
-     ApiModel
 
- } from "../../utils/api";
 
- const _Http = new ApiModel();
 
- import {
 
-     TestVerify
 
- } from "../../utils/verify";
 
- const _Verify = new TestVerify();
 
- Page({
 
-     /**
 
-      * 页面的初始数据
 
-      */
 
-     data: {
 
-         fprodname: "", //产品名称
 
-         fprodnum: "", //产品编码
 
-         attinfos: [], //附件列表
 
-         fintroduction: "", //产品说明
 
-         ftag: [], //产品标签
 
-         showSaleprod: "", //标签显示
 
-         tagents_productid: 0, //识别产品ID
 
-         checked: false, //开关控件
 
-         errTips: {
 
-             fprodname: false,
 
-             fprodnum: false,
 
-             showSaleprod: false,
 
-         }
 
-     },
 
-     /**
 
-      * 生命周期函数--监听页面加载
 
-      */
 
-     onLoad: function (options) {
 
-         if (options.data) {
 
-             const data = JSON.parse(options.data)
 
-             console.log(data)
 
-             let attinfos = [];
 
-             for (let i = 0; i < data.attinfos.length; i++) {
 
-                 let arr = {
 
-                     url: data.attinfos[i].fobsurl,
 
-                     ownerid: data.attinfos[i].ownerid,
 
-                     tattachmentid: data.attinfos[i].tattachmentid,
 
-                     ownertable: data.attinfos[i].ownertable,
 
-                     fdocument: data.attinfos[i].fdocument
 
-                 }
 
-                 attinfos.push(arr)
 
-             };
 
-             /* 是否上架 */
 
-             const checked = (data.fisonsale == 1) ? true : false
 
-             let showSaleprod = "",
 
-                 ftag = data.ftag
 
-             /* 空标签转换为数组格式 */
 
-             if (data.ftag == null || data.ftag == '') {
 
-                 ftag = []
 
-             } else {
 
-                 /* 字符串数组转换数组 */
 
-                 for (var i = 0; i < ftag.length; i++) {
 
-                     showSaleprod += ftag[i] + ' ';
 
-                 }
 
-             }
 
-             /* 渲染数据 */
 
-             this.setData({
 
-                 fprodname: data.fprodname, //产品名称
 
-                 fprodnum: data.fprodnum, //产品编码
 
-                 attinfos, //附件列表
 
-                 fintroduction: data.fintroduction, //产品说明
 
-                 fisonsale: data.fisonsale, //是否上架
 
-                 ftag: ftag, //产品标签
 
-                 tagents_productid: data.tagents_productid, //识别产品ID
 
-                 showSaleprod, // 显示标签
 
-                 checked, //是否上架
 
-             });
 
-         }
 
-     },
 
-     /**
 
-      * 生命周期函数--监听页面初次渲染完成
 
-      */
 
-     onReady: function () {
 
-     },
 
-     /* 添加图片 */
 
-     imageChange(data) {
 
-         this.setData({
 
-             attinfos: data.detail.fileList
 
-         })
 
-     },
 
-     /* 上架开关 */
 
-     switchChange() {
 
-         const checked = !this.data.checked,
 
-             fisonsale = (checked) ? 1 : 0;
 
-         this.setData({
 
-             checked,
 
-             fisonsale
 
-         });
 
-     },
 
-     /* 表单验证 */
 
-     formVerify() {
 
-         let errTips = this.data.errTips,
 
-             verify = true;
 
-         /* 验证产品名称  */
 
-         if (!_Verify.required(this.data.fprodname)) {
 
-             errTips.fprodname = true;
 
-             verify = false;
 
-         }
 
-         /* 验证产品编码  */
 
-         if (!_Verify.required(this.data.fprodnum)) {
 
-             errTips.fprodnum = true;
 
-             verify = false;
 
-         }
 
-         /* 验证附件列表  */
 
-         if (!_Verify.required(this.data.attinfos, "请上传产品图片")) {
 
-             errTips.fprodnum = true;
 
-         }
 
-         this.setData({
 
-             errTips
 
-         })
 
-         return verify;
 
-     },
 
-     /* 提交 */
 
-     submit() {
 
-         if (!this.formVerify()) return;
 
-         //请求参数
 
-         _Http.basic({
 
-             "accesstoken": wx.getStorageSync('userData').token,
 
-             "classname": "customer.products.products",
 
-             "method": "insertOrModifyProducts",
 
-             "content": {
 
-                 "tagents_productid": this.data.tagents_productid,
 
-                 "fprodnum": this.data.fprodnum,
 
-                 "fprodname": this.data.fprodname,
 
-                 "fintroduction": this.data.fintroduction,
 
-                 "ftag": this.data.ftag,
 
-                 "fisonsale": this.data.fisonsale
 
-             }
 
-         }).then(res => {
 
-             console.log(res)
 
-             if (res.msg != "成功") return;
 
-             let content = {
 
-                 ownerid: res.data[0].tagents_productid,
 
-                 ownertable: "tagents_product",
 
-                 tattachmentid: 0
 
-             };
 
-             this.selectComponent("#UploadFiles").saveTheChanges(content);
 
-             wx.showToast({
 
-                 title: '保存成功',
 
-             })
 
-             setTimeout(() => {
 
-                 wx.navigateBack({
 
-                     delta: 1,
 
-                 })
 
-             }, 500)
 
-         })
 
-     },
 
-     /* 获取焦点 */
 
-     inputFocus(e) {
 
-         const {
 
-             name
 
-         } = e.currentTarget.dataset;
 
-         let errTips = this.data.errTips;
 
-         errTips[name] = false;
 
-         /* 经营类目提示框 */
 
-         if (name == 'showSaleprod') {
 
-             errTips[name] = true;
 
-             console.log(23)
 
-         }
 
-         this.setData({
 
-             errTips
 
-         })
 
-     },
 
-     /* 失去焦点 */
 
-     inputBlur(e) {
 
-         const {
 
-             name
 
-         } = e.currentTarget.dataset;
 
-         const {
 
-             value
 
-         } = e.detail;
 
-         /* 经营类目提示框,字符串转化数组 */
 
-         if (name == 'showSaleprod') {
 
-             let errTips = this.data.errTips;
 
-             const ftag = this.data.showSaleprod.split(" ");
 
-             errTips[name] = false;
 
-             this.setData({
 
-                 ftag,
 
-                 errTips
 
-             })
 
-         };
 
-         if (value.trim() == "") {
 
-             let errTips = this.data.errTips;
 
-             errTips[name] = true;
 
-             this.setData({
 
-                 errTips
 
-             })
 
-         }
 
-     },
 
-     /**
 
-      * 生命周期函数--监听页面显示
 
-      */
 
-     onShow: function () {
 
-     },
 
-     /**
 
-      * 生命周期函数--监听页面隐藏
 
-      */
 
-     onHide: function () {
 
-     },
 
-     /**
 
-      * 生命周期函数--监听页面卸载
 
-      */
 
-     onUnload: function () {},
 
-     /**
 
-      * 页面相关事件处理函数--监听用户下拉动作
 
-      */
 
-     onPullDownRefresh: function () {
 
-     },
 
-     /**
 
-      * 页面上拉触底事件的处理函数
 
-      */
 
-     onReachBottom: function () {
 
-     },
 
-     /**
 
-      * 用户点击右上角分享
 
-      */
 
-     onShareAppMessage: function () {
 
-     }
 
- })
 
 
  |