接口使用PUT方法

//从pages页面跳转到编辑infoEdit页面
/pages/pages/inddex

//infoEdit编辑页面路径
/pages/infoEdit/index?id=16c7e32c4a424503b2cc536b827878ae


<view>
<-- v-model="info.name" 展示后台数据获取的info.name -->
<form @submit="formSubmit">
<view class="list">
<view class="item">
姓名:
<input name="name" v-model="info.name" placeholder="请输入姓名" />
</view>
<view class="item">
博客地址:
<input name="name" v-model="info.url" placeholder="请输入博客地址" />
</view>
<view class="item">
照片:
<image v-if="this.img!==''" src="this.img"></image>
<text class="del" v-if="this.img!==''">X</text>
<image v-else src="this.noImg" v-else @click(chooseImageWeixin('img'))></image>
</view>
</view>
<view>
<button form-type="submit" v-if="this.disabled===false">提交</button>
<button class="no" v-else>提交</button>
</view>
</form>

</view>

<script>
data() {
info: '',//展示获取存储的数据
img: '',//首次展示获取存储的info.img 后续新图片路径存储在此img变量
disabled: false;//按钮禁用点击关闭 防止重复点击 默认可以提交
},
onLoad(parms) {
this.getWarehouseEnterprise();//获取存储的数据
},

motheds:{
getWarehouseEnterprise() {
//shop.shopWarehouseEnterprise: 'warehouseEnterpriseApi/getByCurrentAccount',//云仓申请信息
this.$Request.get(this.$api.shop.shopWarehouseEnterprise).then(res => {//url
if(res.data.code===1) {
this.info = res.data.data;//获取存储的数据
this.img = info.img;//获取存储数据里的img
}
},err =>{console.log("err: ",JSON.stringify(err);})

},
formSubmit(e) {
let formData = e.deatil.value;//获取整个表单的值
let data = {
name: form.name;//获取input name为name的值
img: this.img;
id: this.info.id;//必传
};
let phoneReg = /^1[0-9]{10,10}$/;//校验手机号
if(form.name==='') {
uni.showToast({title: '请输入姓名',icon: 'none'});
this.disabled = false;//按钮禁止点击关闭
} else if(form.url==='') {
uni.showToast({title: '请输入博客',icon: 'none'});
this.disabled = false;
} else if(form.mobile='') {
uni.showToast({title: '请输入手机号',icon: 'none'});
this.disabled = false;
} else if(!phoneReg.test(form.mobile)) {//判断手机号是否匹配phoneReg !取反
uni.showToast({title: '请输入11位手机号'});
this.disabled = false;
} else if(this.img) {
uni.showToast({title: ''请上传照片,icon: 'none'});
this.disabled = false;
} else if(checkRes) {
this.submit(data);
}
else {
this.disabled = false;
uni.showToast({title: err,icon: 'none'});
}
},
chooseImageWeiXin(who) {
uni.chooseImage({
count: 1,
success: (res) => {
let image = res.tempFilePaths[0];
let tempFileSize = res.tempFile[0].size;
if(tempFile <= 20000000) {
let itemCode = '0020010005';
uni.uploadFile({
url: this.$commonImage.pageBasePath + 'fileApi/upload?itemCode=' + itemCode + '&batchCode=' + this.$utils.randomNum(20),//仅为示例,非真实的接口地址
filePath: image,
name: 'file',
header: {
'Api-Version': "2.0",
'Call-Source': "WEB",
'Authorization': uni.getStorageSync('Authorization') !== undefined ? uni.getStorageSync('Authorization'): '',
},
success: (res) => {
let f = JSON.parse(res.data);
if(f.code===1) {
_self.img = f.data.serverPath;
}
},
fail: (err) => {console.log("err: ",err);},
});
} else{uni.showToast({title: '上传的图片不能大于20M!',icon: 'none'})}
},
})
},
sumbit(data) {
let _self = this;
//shop.warehouseEnterpriseApi: 'warehouseEnterpriseApi',//云仓申请
this.$Request.post(this.$api.shop.warehouseEnterpriseApi +"/"+this.info.id,'PUT',data) {//url method data
if(res.data.code ===1) {
uni.showToast({title: "修改成功,等待审核",icon: "none",duration: 2000});
uni.setStorageSync('isHaveStore',"true");
setTimeout(function () {
_self.$utils.jump("",switchTab);
},2000)
}
}
},
}
</script>