| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331 | import {    ApiModel} from "../../utils/api";const _Http = new ApiModel();import {    TestVerify} from "../../utils/verify";const _Verify = new TestVerify();var WxParse = require('../../wxParse/wxParse.js')Page({    /**     * 页面的初始数据     */    data: {        isDisabled: false, //是否禁用        butText: "保存", //按钮文字        popups: false, //弹出层控制        /*  */        fbrand: "", //品牌名称        attinfos: [], // 图片列表        coverAttinfos: [], //品牌展示图        isLogo: [], //用于判断是否上传logo        saleprodclass: [], //经营类目        showSaleprodclass: "", //显示经营类目        fcontact: "", //联系人        fphonenumber: "", //联系方式        fagentname: "", //商户名称        fintroduction: "", //商户介绍        faddress: "", //地址        fdutyparagraph: "", //统一社会代码        requestType: "普通修改", //请求类型        /*  */        errTips: {            fbrand: false,            attinfos: false,            saleprodclass: false,            fcontact: false,            fphonenumber: false,            fagentname: false,            fintroduction: false,            faddress: false,        }    },    /**     * 生命周期函数--监听页面加载     */    onLoad: function (options) {        // 判断主子账号 是否禁用        this.setData({            isDisabled: (wx.getStorageSync('userData').fisadministrator == 1) ? false : true        });        //判断进入方式        if (options.data == null) {            console.log("注册进入")            this.setData({                requestType: "商户认证"            })        } else if (options.data == 1) {            wx.showToast({                title: '商户信息审核中',                icon: 'none',                duration: 5000            });            this.setData({                requestType: "商户认证",                isDisabled: true            })        } else {            //解析富文本            var article = decodeURIComponent(options.fintroduction);            var that = this;            WxParse.wxParse('article', 'html', article, that, 5);            //处理数据            const data = JSON.parse(options.data);            this.returnData(data)        }    },    /* 添加图片 */    imageChange(data) {        this.setData({            attinfos: data.detail.fileList        })    },    coverImageChange(data) {        this.setData({            coverAttinfos: data.detail.fileList        })    },    /* 选择类目回调 */    saleprodChange(arr) {        let detail = arr.detail,            showSaleprodclass = "";        for (let i = 0; i < detail.length; i++) {            showSaleprodclass += (detail[i] + ',');        };        this.setData({            popups: false,            saleprodclass: detail,            showSaleprodclass: showSaleprodclass.slice(0, showSaleprodclass.length - 1)        })    },    /* 返回数据 */    returnData(data) {        var attinfos = [],            coverAttinfos = [];        // 格式化图片        for (let i = 0; i < data.attinfos.length; i++) {            const Data = {                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            };            (data.attinfos[i].ftype == "brandlogo") ? attinfos.unshift(Data): coverAttinfos.unshift(Data);        }        //格式化经营类目        if (data.saleprodclass.length >= 1) {            this.saleprodChange({                detail: data.saleprodclass            })        }        /* fintroduction: data.fintroduction, */        this.setData({            fbrand: data.fbrand,            saleprodclass: data.saleprodclass,            fcontact: data.fcontact,            fphonenumber: data.fphonenumber,            fagentname: data.fagentname,            faddress: data.faddress,            fdutyparagraph: data.fdutyparagraph,            attinfos,            coverAttinfos        })    },    /* 提交数据 */    submit() {        if (!this.formVerify()) return wx.showToast({            title: '请检查表单内容',            icon: "error"        });        if (this.data.attinfos.length < 1) return wx.showToast({            title: '请上传品牌LOGO!',            icon: "none"        });        if (this.data.coverAttinfos.length < 1) return wx.showToast({            title: '请上传品牌展示图!',            icon: "none"        });        const that = this;        if (this.data.requestType == '普通修改') {            wx.showModal({                title: '提示',                content: "是否确认修改商户信息",                success: (res => {                    if (res.confirm) {                        that.requestToSend();                    };                })            })        } else {            that.requestToSend();        }    },    /* 发送请求 */    requestToSend() {        _Http.basic({            "accesstoken": wx.getStorageSync('userData').token,            "classname": "customer.tagents.tagents",            "method": "modify_enterpriseAgent",            "content": {                "ftype": this.data.requestType,                "data": [{                    "fbrand": this.data.fbrand,                    "saleprodclass": this.data.saleprodclass,                    "fcontact": this.data.fcontact,                    "fphonenumber": this.data.fphonenumber,                    "fagentname": this.data.fagentname,                    "fintroduction": this.data.fintroduction,                    "faddress": this.data.faddress,                    "fdutyparagraph": this.data.fdutyparagraph,                }]            }        }).then(res => {            if (res.msg != '成功') return wx.showToast({                title: res.data,            })            wx.showToast({                title: '提交成功',            });            setTimeout(() => {                wx.navigateBack({                    delta: 1,                })            }, 500)        })    },    /* 表单验证 */    formVerify() {        let errTips = this.data.errTips,            verify = true;        /* 验证品牌名 */        if (!_Verify.required(this.data.fbrand)) {            errTips.fbrand = true;            verify = false;        }        /* 验证经营类目  */        if (!_Verify.required(this.data.showSaleprodclass)) {            errTips.saleprodclass = true;            verify = false;        }        /* 验证联系人  */        if (!_Verify.required(this.data.fcontact)) {            errTips.fcontact = true;            verify = false;        }        /* 验证联系方式  */        if (!_Verify.phoneNumber(this.data.fphonenumber)) {            errTips.fphonenumber = true;            verify = false;        }        /* 验证商户名称  */        if (!_Verify.required(this.data.fagentname)) {            errTips.fagentname = true;            verify = false;        }        /* 验证商户介绍  */        if (!_Verify.required(this.data.fintroduction)) {            errTips.fintroduction = true;            verify = false;        }        /* 验证地址  */        if (!_Verify.required(this.data.faddress)) {            errTips.faddress = true;            verify = false;        }        this.setData({            errTips        })        return verify;    },    /* 弹出层 */    showPop() {        if (this.data.isDisabled) return;        this.setData({            popups: !this.data.popups        })    },    /* 获取焦点 */    inputFocus(e) {        const {            name        } = e.currentTarget.dataset;        let errTips = this.data.errTips;        errTips[name] = false;        this.setData({            errTips        })    },    /* 失去焦点 */    inputBlur(e) {        const {            name        } = e.currentTarget.dataset;        const {            value        } = e.detail;        let errTips = this.data.errTips;        /* 联系方式验证 */        if (name == 'fphonenumber') {            if (!_Verify.phoneNumber(this.data.fphonenumber, true)) errTips[name] = true;        }        if (value.trim() == "") {            errTips[name] = true;        }        this.setData({            errTips        })    },    /**     * 生命周期函数--监听页面初次渲染完成     */    onReady: function () {    },    /**     * 生命周期函数--监听页面显示     */    onShow: function () {    },    /**     * 生命周期函数--监听页面隐藏     */    onHide: function () {    },    /**     * 生命周期函数--监听页面卸载     */    onUnload: function () {    },    /**     * 页面相关事件处理函数--监听用户下拉动作     */    onPullDownRefresh: function () {    },    /**     * 页面上拉触底事件的处理函数     */    onReachBottom: function () {    },    /**     * 用户点击右上角分享     */    onShareAppMessage: function () {    }})
 |