|
@@ -1,8 +1,14 @@
|
|
|
+//引入网络请求
|
|
|
+import {
|
|
|
+ ApiModel
|
|
|
+} from "../../utils/api.js"
|
|
|
//引入文本校验
|
|
|
import {
|
|
|
TestVerify
|
|
|
} from "../../utils/verify"
|
|
|
+
|
|
|
const _Verify = new TestVerify()
|
|
|
+const _Http = new ApiModel()
|
|
|
Page({
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
@@ -19,20 +25,33 @@ Page({
|
|
|
fileList: "", //logo
|
|
|
//必填项状态 是否红色字体
|
|
|
ErrRed: {
|
|
|
- brandNameErrRed:false,//品牌名
|
|
|
+ brandNameErrRed: false, //品牌名
|
|
|
logoErrRed: false, //logo
|
|
|
- classifyErrRed: false,//经营类目
|
|
|
- contactErrRed: false,//联系人
|
|
|
+ classifyErrRed: false, //经营类目
|
|
|
+ contactErrRed: false, //联系人
|
|
|
telephoneErrRed: false, //联系方式
|
|
|
},
|
|
|
+ logoErrTips: "", //logo格式/大小错误提示
|
|
|
telephoneErrTitle: "", //手机号错误提示
|
|
|
+ tagentsid: "", //上传图片使用
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad: function (options) {
|
|
|
-
|
|
|
+ /* 查询商户信息 */
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('token'),
|
|
|
+ "classname": "customer.tagents.tagents",
|
|
|
+ "method": "query_enterpriseAgentsMain",
|
|
|
+ "content": {}
|
|
|
+ }).then(s => {
|
|
|
+ if (s.msg != "成功") return;
|
|
|
+ this.setData({
|
|
|
+ tagentsid: s.data[0].tagentsid
|
|
|
+ })
|
|
|
+ })
|
|
|
},
|
|
|
/* 必填项,获得焦点更新状态 */
|
|
|
isInputFocus(e) {
|
|
@@ -65,39 +84,172 @@ Page({
|
|
|
telephoneErrTitle: "",
|
|
|
})
|
|
|
},
|
|
|
+ /* 上传图片 */
|
|
|
afterRead(event) {
|
|
|
- console.log(event)
|
|
|
- // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
|
|
|
- /* wx.uploadFile({
|
|
|
- url: 'https://example.weixin.qq.com/upload', // 仅为示例,非真实的接口地址
|
|
|
- filePath: file.url,
|
|
|
- name: 'file',
|
|
|
- formData: {
|
|
|
- user: 'test'
|
|
|
- },
|
|
|
- success(res) {
|
|
|
- // 上传完成需要更新 fileList
|
|
|
- const {
|
|
|
- fileList = []
|
|
|
- } = this.data;
|
|
|
- fileList.push({
|
|
|
- ...file,
|
|
|
- url: res.data
|
|
|
- });
|
|
|
- this.setData({
|
|
|
- fileList
|
|
|
- });
|
|
|
- },
|
|
|
- }); */
|
|
|
- },
|
|
|
- /* 完善设置商户信息 */
|
|
|
+ // 初始化数据
|
|
|
+ this.setData({
|
|
|
+ logoErrTips: ""
|
|
|
+ })
|
|
|
+ var that = this
|
|
|
+ const {
|
|
|
+ file
|
|
|
+ } = event.detail;
|
|
|
+ var index = file.url.lastIndexOf(".");
|
|
|
+ var ext = file.url.substr(index + 1);
|
|
|
+ const fileName = file.url.split('/'),
|
|
|
+ name = fileName[fileName.length - 1];
|
|
|
+ //验证文件格式大小
|
|
|
+ const Uploader = _Verify.verifyUploader({
|
|
|
+ file
|
|
|
+ });
|
|
|
+ if (Uploader == "发送请求") {
|
|
|
+ wx.getFileSystemManager().readFile({
|
|
|
+ filePath: file.url,
|
|
|
+ // encoding:'utf-8',
|
|
|
+ success: result => {
|
|
|
+ //返回临时文件路径
|
|
|
+ const fileData = result.data
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('token'),
|
|
|
+ "classname": "system.system.docManage",
|
|
|
+ "method": "getFileName",
|
|
|
+ "content": {
|
|
|
+ "filename": name,
|
|
|
+ "filetype": ext,
|
|
|
+ "ownertable": "tagents",
|
|
|
+ "ownerid": that.data.tagentsid,
|
|
|
+ "ftype": "brandlogo"
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ that.uploadFile(res, fileData)
|
|
|
+ }).catch(err => {
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: console.error
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ logoErrTips: Uploader
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /* 上传成功反馈 */
|
|
|
+ uploadFile(res, data) {
|
|
|
+ var that = this
|
|
|
+ wx.request({
|
|
|
+ url: res.data.obsuploadurl,
|
|
|
+ method: "PUT",
|
|
|
+ data: data,
|
|
|
+ header: {
|
|
|
+ 'content-type': 'application/octet-stream' // 默认值
|
|
|
+ },
|
|
|
+ success() {
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('token'),
|
|
|
+ "classname": "system.system.docManage",
|
|
|
+ "method": "uploadSuccsess",
|
|
|
+ "content": {
|
|
|
+ "obsfilename": res.data.obsfilename
|
|
|
+ }
|
|
|
+ }).then(res => {
|
|
|
+ if (res.msg != "成功") return;
|
|
|
+ const fileList = [{
|
|
|
+ url: res.data[0].fobsurl,
|
|
|
+ tattachmentid: res.data[0].tattachmentid
|
|
|
+ }]
|
|
|
+ that.setData({
|
|
|
+ fileList
|
|
|
+ })
|
|
|
+ }).catch(err => {
|
|
|
+ console.log(err)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 删除logo */
|
|
|
+ logoDelete() {
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('token'),
|
|
|
+ "classname": "system.system.docManage",
|
|
|
+ "method": "deleteDoc",
|
|
|
+ "content": {
|
|
|
+ "ownertable": "tagents",
|
|
|
+ "ownerid": this.data.tagentsid,
|
|
|
+ "tattachmentid": this.data.fileList.tattachmentid
|
|
|
+ }
|
|
|
+ }).then(s => {
|
|
|
+ console.log(s)
|
|
|
+ if (s.msg != "成功") return;
|
|
|
+ this.setData({
|
|
|
+ fileList: "",
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ /* 必填项目检测 */
|
|
|
+ inputCertain() {
|
|
|
+ let ErrRed = this.data.ErrRed,
|
|
|
+ state = true;
|
|
|
+ /* 品牌名 */
|
|
|
+ if (!_Verify.required(this.data.brandName)) {
|
|
|
+ ErrRed.brandNameErrRed = true;
|
|
|
+ state = false;
|
|
|
+ };
|
|
|
+ /* logo */
|
|
|
+ if (this.data.fileList == '') {
|
|
|
+ this.setData({
|
|
|
+ logoErrTips: "品牌Logo还未上传"
|
|
|
+ })
|
|
|
+ state = false;
|
|
|
+ };
|
|
|
+ /* 经营类目 */
|
|
|
+ if (!_Verify.required(this.data.classify)) {
|
|
|
+ ErrRed.classifyErrRed = true;
|
|
|
+ state = false;
|
|
|
+ };
|
|
|
+ /* 联系人 */
|
|
|
+ if (!_Verify.required(this.data.contact)) {
|
|
|
+ ErrRed.contactErrRed = true;
|
|
|
+ state = false;
|
|
|
+ };
|
|
|
+ /* 电话号 */
|
|
|
+ if (!_Verify.phoneNumber(this.data.telephone)) {
|
|
|
+ ErrRed.telephoneErrRed = true;
|
|
|
+ state = false;
|
|
|
+ };
|
|
|
+ this.setData({
|
|
|
+ ErrRed
|
|
|
+ });
|
|
|
+ return state;
|
|
|
+ },
|
|
|
+ /* 立即创建--完善设置商户信息 */
|
|
|
setUserMsg() {
|
|
|
- // _Verify.userName(this.data.brandName)
|
|
|
- // _Verify.phoneNumber(this.data.telephone)
|
|
|
- // console.log(_Verify.phoneNumber(this.data.telephone))
|
|
|
- _Verify.required(this.data.classify) //经营类目
|
|
|
-
|
|
|
+ //必填项,校验
|
|
|
+ if (!this.inputCertain()) return;
|
|
|
+ console.log(!this.inputCertain())
|
|
|
+ _Http.basic({
|
|
|
+ "accesstoken": wx.getStorageSync('token'),
|
|
|
+ "classname": "customer.tagents.tagents",
|
|
|
+ "method": "modify_enterpriseAgent",
|
|
|
+ "content": {
|
|
|
+ "ftype": "商户认证",
|
|
|
+ "data": [{
|
|
|
+ "fagentnum": this.data.companyName,
|
|
|
+ "fbrand": this.data.brandName,
|
|
|
+ "fcontact": this.data.contact,
|
|
|
+ "fphonenumber": this.data.telephone,
|
|
|
+ "faddress": this.data.companyAddress,
|
|
|
+ "fdutyparagraph": this.data.userCode,
|
|
|
+ "fintroduction": this.data.companyIntroduce,
|
|
|
+ "saleprodclass": this.data.classify
|
|
|
+ }]
|
|
|
+ }
|
|
|
+ }).then(s => {
|
|
|
+ if (s.msg != "成功") return;
|
|
|
+ this.toHomePage();
|
|
|
+ })
|
|
|
},
|
|
|
+ /* 跳过 */
|
|
|
toHomePage() {
|
|
|
wx.reLaunch({
|
|
|
url: '/pages/tabbarPage/Home/index'
|