|
@@ -1,20 +1,250 @@
|
|
|
-// pages/storeMessage/index.js
|
|
|
+import {
|
|
|
+ ApiModel
|
|
|
+} from "../../utils/api";
|
|
|
+const _Http = new ApiModel();
|
|
|
+import {
|
|
|
+ TestVerify
|
|
|
+} from "../../utils/verify";
|
|
|
+const _Verify = new TestVerify();
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
-
|
|
|
+ fisadministrator: (wx.getStorageSync('userData').fisadministrator == 1) ? true : false, //是否主账号
|
|
|
+ butText: "保存", //按钮文字
|
|
|
+ disabled: false, //禁用
|
|
|
+ popups: false, //弹出层控制
|
|
|
+ /* */
|
|
|
+ fbrand: "", //品牌名称
|
|
|
+ attinfos: [], // 图片列表
|
|
|
+ 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) {
|
|
|
-
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('userData').token,
|
|
|
+ "classname": "customer.tagents.tagents",
|
|
|
+ "method": "query_enterpriseAgentsMain",
|
|
|
+ "content": {}
|
|
|
+ }).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ const data = res.data[0];
|
|
|
+ let butText = '保存',
|
|
|
+ disabled = false;
|
|
|
+ if (data.ftype == '个人' && data.fisauthenticating == 1) {
|
|
|
+ wx.showToast({
|
|
|
+ title: '商户信息审核中',
|
|
|
+ icon: "none",
|
|
|
+ duration: 5000,
|
|
|
+ })
|
|
|
+ butText = "审核中";
|
|
|
+ disabled = true;
|
|
|
+ this.returnData(data)
|
|
|
+ } else if (data.ftype == '个人' && data.fisauthenticating == 0) {
|
|
|
+ butText = "立即认证";
|
|
|
+ this.setData({
|
|
|
+ requestType: "商户认证"
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.returnData(data)
|
|
|
+ };
|
|
|
+ this.setData({
|
|
|
+ butText,
|
|
|
+ disabled
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 选择类目回调 */
|
|
|
+ saleprodChange(arr) {
|
|
|
+ let {
|
|
|
+ detail
|
|
|
+ } = arr, showSaleprodclass = "";
|
|
|
+ console.log(arr)
|
|
|
+ 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) {
|
|
|
+ console.log(data)
|
|
|
+ let imageData = [];
|
|
|
+ if (data.attinfos.length >= 1) {
|
|
|
+ imageData = [{
|
|
|
+ url: data.attinfos[0].fobsurl,
|
|
|
+ ownerid: data.attinfos[0].ownerid,
|
|
|
+ tattachmentid: data.attinfos[0].tattachmentid
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ this.saleprodChange({
|
|
|
+ detali: data.saleprodclass
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ fbrand: data.fbrand,
|
|
|
+ saleprodclass: data.saleprodclass,
|
|
|
+ fcontact: data.fcontact,
|
|
|
+ fphonenumber: data.fphonenumber,
|
|
|
+ fintroduction: data.fintroduction,
|
|
|
+ fagentname: data.fagentname,
|
|
|
+ faddress: data.faddress,
|
|
|
+ fdutyparagraph: data.fdutyparagraph,
|
|
|
+ attinfos: imageData,
|
|
|
+ isLogo: imageData
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 提交数据 */
|
|
|
+ submit() {
|
|
|
+ if (!this.formVerify()) return wx.showToast({
|
|
|
+ title: '请检查表单内容',
|
|
|
+ icon: "error"
|
|
|
+ });
|
|
|
+ /* 验证附件列表 */
|
|
|
+ if (!_Verify.required(this.data.isLogo, "请上传品牌logo")) return;
|
|
|
+ /* 发送请求 */
|
|
|
+ _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.data == '成功') {
|
|
|
+ wx.showToast({
|
|
|
+ title: '提交成功',
|
|
|
+ });
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: 1,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 表单验证 */
|
|
|
+ formVerify() {
|
|
|
+ let errTips = this.data.errTips,
|
|
|
+ verify = true;
|
|
|
+ /* 验证品牌名 */
|
|
|
+ if (!_Verify.required(this.data.fbrand)) {
|
|
|
+ errTips.fbrand = true;
|
|
|
+ verify = false;
|
|
|
+ }
|
|
|
+ /* 验证经营类目 */
|
|
|
+ if (!_Verify.required(this.data.saleprodclass)) {
|
|
|
+ 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() {
|
|
|
+ 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;
|
|
|
+ /* 联系方式验证 */
|
|
|
+ if (name == 'fphonenumber') {
|
|
|
+ _Verify.phoneNumber(this.data.fphonenumber, true)
|
|
|
+ }
|
|
|
+ if (value.trim() == "") {
|
|
|
+ let errTips = this.data.errTips;
|
|
|
+ errTips[name] = true;
|
|
|
+ this.setData({
|
|
|
+ errTips
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /* 更改logo */
|
|
|
+ logoChange(data) {
|
|
|
+ this.setData({
|
|
|
+ isLogo: data.detail.fileList
|
|
|
+ })
|
|
|
},
|
|
|
-
|
|
|
/**
|
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
|
*/
|