<template> <view class="addressList"> <view class="addressList-hd"> <view class="item"> <view class="a">店铺名称</view> <view class="b"> <input type="text" v-model="shop_name" placeholder="请输入店铺名称" /> </view> </view> <view class="item"> <view class="a">店铺地址</view> <view class="b"> <input type="text" v-model="address" placeholder="请输入店铺地址" /> </view> </view> <view class="item"> <view class="a">联系方式</view> <view class="b"> <input type="number" v-model="phone" placeholder="请输入手机号" /> </view> </view> <view class="items"> <view class="a">微信二维码</view> <view class="c"> <u-upload :action="action" :header="header" @on-uploaded="success" @on-remove="removePic" width="180" height="180" :file-list="fileList" :custom-btn="true" max-count="1"> <template v-slot:addBtn> <view class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150"> <image :src="$picUrl+'/static/news/icon-upload.png'"></image> <view class="1">上传图片</view> </view> </template> </u-upload> </view> </view> </view> <view class="addressList-fd"> <view class="btn" @click="toSubmit()">保存</view> </view> </view> </template> <script> import Config from '@/core/config' import * as GoodsApi from '@/api/home/index.js'; export default { data() { return { shop_name: "", address: "", phone: "", action: "", wechat_img_id: "", fileList: [], clickFlag: true, header: {}, shop_id: "" }; }, onReady() { this.shop_id = uni.getStorageSync("cityInfo").shop_id; this.shop_name = uni.getStorageSync("cityInfo").shop_name this.address = uni.getStorageSync("cityInfo").address this.phone = uni.getStorageSync("cityInfo").phone this.wechat_img_id = uni.getStorageSync("cityInfo").wechat; this.fileList = [{ url: uni.getStorageSync("cityInfo").wechat }] console.log(uni.getStorageSync("cityInfo")) console.log(uni.getStorageSync("cityInfo").parking_name) this.action = (Config.get('apiUrl')+'upload/image').replace("index.php?s=/","") this.header = { 'Storeid': uni.getStorageSync('Store').storeInfo.store_id, 'Access-Token': uni.getStorageSync('AccessToken'), 'platform': "MP-WEIXIN", } }, methods: { //提交修改 async toSubmit(){ if(!this.shop_name){ uni.showToast({ icon: "none", title: "门店名称不能为空!" }) return ; } if(!this.address){ uni.showToast({ icon: "none", title: "门店地址不能为空" }) return ; } if(!this.phone){ uni.showToast({ icon: "none", title: "手机号不能为空!" }) return ; } if(!/^1[23456789]\d{9}$/.test(this.phone)){ uni.showToast({ icon: "none", title: "手机格式不正确!" }) return ; } if(!this.wechat_img_id){ uni.showToast({ icon: "none", title: "请上传微信二维码!" }) return ; } if(this.clickFlag == false){ return ; } this.clickFlag = false; const { status, message } = await GoodsApi.editShop({ shop_id: this.shop_id, shop_name: this.shop_name, address: this.address, phone: this.phone, wechat_img_id: this.wechat_img_id }); if(status == 200){ this.clickFlag = true; uni.showToast({ title: "提交成功" }) this.getCityInfo(); }else{ this.clickFlag = true uni.showToast({ icon: "none", title: message }) } }, getCityInfo(){ const that =this GoodsApi.cityInfo().then(res => { if (res.status == 200) { that.cityInfo = res.data; uni.setStorageSync("cityInfo",res.data) setTimeout(()=>{ uni.navigateBack({ delta: 1 }) },2000) } }) .finally(() => {}) }, removePic(i){ console.log(i) }, //接受上传返回的数据 success(list) { if(list.length > 0){ const {response} = list[0]; if(response.status == 200){ uni.showToast({ title: "上传成功" }) this.wechat_img_id = response.data.fileInfo.file_id } } } } } </script> <style lang="scss" scoped> .addressList{ padding: 0 0 20rpx; overflow: hidden; &-hd{ background-color: #fff; padding: 0 25rpx 25rpx; overflow: hidden; .item{ padding: 20rpx 0; line-height: 50rpx; font-size: 28rpx; color: #212121; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #F7F7F7; .b{ font-size: 28rpx; color: #9D9D9D; flex: 1; text-align: right; input{ width: 100%; line-height: 50rpx; font-size: 28rpx; color: #212121; } .select{ color: #C7C7C7; &-on{ color: #212121; } } } } .items{ padding: 20rpx 0; line-height: 50rpx; font-size: 28rpx; color: #212121; .c{ padding-top: 20rpx; overflow: hidden; .slot-btn{ width: 80px; height: 80px; background: #FFFFFF; border-radius: 10rpx; border: 1px solid #C0C0C0; text-align: center; font-size: 24rpx; font-weight: 500; color: #D1D1D1; image{ width: 50rpx; height: 50rpx; margin-top: 20rpx; } } } } } &-fd{ width: 100%; position: fixed; left: 0; bottom: 0; padding: 30rpx; background-color: #fafafa; box-sizing: border-box; .btn{ width: 100%; line-height: 96rpx; background: #F34A40; border-radius: 8rpx; text-align: center; font-size: 28rpx; font-weight: 500; color: #FFFFFF; } } } </style>