123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- <template>
- <view class="content-add">
- <view class="add-body">
- <view class="form-data">
- <view class="flex flex_column data-item">
- <text>名称</text>
- <view class="list-item-right flex_1 flex justify_between">
- <u-input class="flex_1" :custom-style="inputClass" v-model="form.contactName" placeholder="请输入店铺名称" placeholder-style="color:'#bbb';font-size:18px"/>
- </view>
- </view>
- <view class="flex flex_column data-item last">
- <view class="flex align_center">
- <view style="color:#666E75">电话</view>
- <u-image src="/static/billing_icon.png" width="24" height="24" style="margin:0 0 10rpx 10rpx;"></u-image>
- </view>
-
- <view class="list-item-right flex_1 flex justify_between">
- <u-input class="flex_1" :custom-style="inputClass" v-model="form.contactPhone" placeholder="请输入联系电话" placeholder-style="color:'#bbb';font-size:18px"/>
- </view>
- </view>
- </view>
- <view class="form-data">
- <view class="flex flex_column data-item">
- <text>地址</text>
- <view class="list-item-right flex_1 flex justify_between">
- <u-input class="flex_1" :custom-style="inputClass" v-model="form.contactAddress" @click="selectAddress" :disabled="true" placeholder="请选择通信地址" placeholder-style="color:'#bbb';font-size:18px"/>
- <u-icon class="back-img" name="arrow-right" color="#9DA8B5" @click="selectAddress"></u-icon>
- </view>
- </view>
- <view class="flex flex_column data-item last">
- <text>详细地址</text>
- <view class="list-item-right flex_1 flex justify_between">
- <u-input class="flex_1" :custom-style="inputClass" v-model="form.detailAddress" placeholder="请输入详细地址" placeholder-style="color:'#bbb';font-size:18px"/>
- </view>
- </view>
- </view>
- <view class="form-data">
- <view class="headerImgTitle"> 门头照片 <text style="color: #bbbbbb;">(仅可上传1张,10MB以内)</text></view>
- <view class="info-main">
- <view class="camera-btn" v-if="photograph.length<1">
- <view @click="goPhotograph" class="photograph-camera">
- <u-icon name="camera" color="#bfbfbf" size="60" ></u-icon>
- </view>
- </view>
- <view v-show="photograph.length" v-for="(item,index) in photograph" :key="index" class="photograph-con">
- <u-icon name="close-circle-fill" color="#fa3534" size="50" class="close-circle-icon" @click="cancelPhotograph(index)"></u-icon>
- <u-image width="100%" height="100%" :src="item" @click="previewPictures(item)"></u-image>
- </view>
- </view>
- </view>
- </view>
- <view class="footer" @click="submit">
- <view class="submit-btn flex justify_center align_center">保存</view>
- </view>
- </view>
- </template>
- <script>
- import {saveImgToAliOss} from '@/libs/tools.js'
- export default{
- data(){
- return{
- photograph: [],
- imageHeader:'', // 图片路径
- form:{
- contactName:'', // 名称
- contactPhone:'', // 手机号码
- contactAddress:"", // 通信地址
- detailAddress:'' // 详细地址
- },
- itemId:'',// 店铺id
- pageInfo:{}, // 页面数据
- }
- },
- onLoad(option) {
- if(option.id){
- console.log(option,option.id)
- uni.setNavigationBarTitle({
- title: '修改店铺'
- });
- this.itemId=option.id
- this.getDetailInfo()
- }
- },
- methods:{
- // 获取详情信息
- getDetailInfo(){
- getDetailInfo({id:this.itemId}).then(res=>{
- if(res.status==200){
- this.pageInfo=res.data
- }else{
- uni.showToast({
- title: res.message,
- icon:'none',
- })
- }
- })
- },
- // 选择通信地址
- selectAddress(){
- wx.chooseLocation({
- success:(res)=>{
- if(res){
- this.getArea(res.address)
- console.log(res,'------------------地址信息',this.getArea(res.address))
- this.form.contactAddress=res.address
- this.form.lat=res.latitude
- this.form.lng=res.longitude
-
- }
- }
- })
- },
- // 拍照或从相册选图片
- goPhotograph() {
- uni.chooseImage({
- count: 1, //默认9
- sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
- sourceType: ['album','camera'], //从相册选择
- success: (res) =>{
- if(res.tempFiles[0].size>10485760){
- uni.showToast({
- title: '图片过大无法上传!',
- icon: 'none'
- })
- return
- }
- uni.showLoading({
- title:'正在保存图片...',
- mask: true
- })
- saveImgToAliOss(res.tempFilePaths[0],(ret)=>{
- this.photograph.push(ret.data)
- uni.hideLoading()
- })
- }
- });
- },
- // 预览图片
- previewPictures(item) {
- const photograph = [item];
- uni.previewImage({
- urls: photograph,
- });
- },
- // 删除图片
- cancelPhotograph(index) {
- setTimeout(() => {
- this.photograph.splice(index)
- }, 500);
- },
- // 保存
- submit(){
- const testVal=/^1[34578]\d{9}$/
- if (!testVal.test(this.form.contactPhone)) {
- uni.showToast({
- title: '请输入正确的联系电话',
- icon: 'none'
- })
- return false
- }
- }
- }
- }
- </script>
- <style lang="less">
- .content-add{
- width: 100%;
- height: 100vh;
- background-color: #f5f5f5;
- display: flex;
- flex-direction: column;
- .add-body{
- width: 100%;
- padding: 20upx 30upx;
- flex: 1;
- overflow-y: scroll;
- .form-data{
- width: 100%;
- background-color: #fff;
- border-radius: 24upx;
- margin-bottom: 20upx;
- .data-item{
- margin: 0 32upx;
- padding: 36upx 0;
- border-bottom: 1px solid #e5e5e5;
- }
- .data-item>text:first-child{
- color:#666E75;
- }
- .last{
- border-bottom:none;
- }
- .headerImgTitle{
- padding-top:36upx;
- margin: 0 32upx;
- color:#666E75;
- }
- .info-main {
- margin:0 32upx;
- padding: 10upx 0 36upx;
- border-radius: 12upx;
- background-color: #fff;
- display: flex;
- .location-icon {
- padding-left: 10upx;
- vertical-align: sub;
- }
- .photograph-camera {
- border: 2upx dashed #bfbfbf;
- border-radius: 12upx;
- width: 140upx;
- height: 140upx;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .camera-btn{
- display: flex;
- flex-direction: column;
- align-items: center;
- color: #999999;
- font-size: 24upx;
- }
- .photograph-con {
- margin: 0 20upx;
- width: 140upx;
- height: 140upx;
- text-align: center;
- position: relative;
- .photograph-icon {
- display: inline-block;
- padding-top: 48upx;
- }
- .close-circle-icon {
- background-color: #fff;
- border-radius: 50%;
- position: absolute;
- right: -23upx;
- top: -23upx;
- z-index: 9;
- }
- }
- }
- }
- }
- .footer{
- width: 100%;
- padding: 14upx 32upx 32upx;
- background-color: #fff;
- color: #fff;
- font-weight: 500;
- .submit-btn{
- height: 84upx;
- background: #1995FF;
- opacity: 1;
- border-radius: 16upx;
- }
- }
- }
- </style>
|