123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- <template>
- <view>
- <view class="cn">
- <u-steps :list="numList" mode="number" :current="num" active-color="#c74547"></u-steps>
- <u-subsection :list="subsection" :current="current" @change="section" button-color="#c74547" active-color="#ffffff"></u-subsection>
- <view class="info">
- <view class="form_group hr">
- <view class="lable">商铺名称</view>
- <input type="text" placeholder="请输入商铺名称" v-model="item.name" />
- </view>
- <view class="form_group hr">
- <view class="lable">商铺地址</view>
- <input type="text" placeholder="请输入商铺地址" v-model="item.addres" />
- <view class="dw icon" @click="wz(1)"></view>
- </view>
- <view class="form_group hr">
- <view class="lable">地图坐标</view>
- <input type="number" placeholder="请在地图上选择坐标" @click="wz(2)" v-model="zb" :disabled="true" />
- </view>
- <view class="form_group hr">
- <view class="lable">老板名称</view>
- <input type="text" placeholder="请输入老板名称" v-model="item.bossName" />
- </view>
- <view class="form_group hr">
- <view class="lable">老板电话</view>
- <input type="number" placeholder="请输入老板电话" v-model="item.bossPhone" />
- </view>
- <view class="form_group"><view class="lable">商铺展示</view></view>
- <view class="pl5">
- <u-upload
- :ip="ip"
- :action="upload.action"
- :header="upload.header"
- :size-type="upload.size"
- :max-count="upload.count"
- :name="upload.name"
- :file-list="item.showPictures"
- :deletable="item.auditFlag != 1"
- :show-progress="item.auditFlag != 1"
- :custom-btn="item.auditFlag == 1"
- ref="uUpload"
- width="140"
- height="140"
- ></u-upload>
- </view>
- <view class="form_group"><view class="lable">商铺简介</view></view>
- <textarea placeholder="请输入商铺简介(200字以内)" v-model="item.briefContent" maxlength="200" />
- </view>
- <button class="btn" @click="up()" v-if="!item.auditFlag">申请开通</button>
- <button class="btn" @click="up()" v-if="item.auditFlag == 0">更新资料</button>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- ip: this.$http.urls.ip,
- subsection: [{ name: '商铺', value: 1 }, { name: '酒店', value: 2 }],
- numList: [{ name: '资料填写' }, { name: '资料审核' }, { name: '审核通过' }],
- num: 0,
- current: 0,
- item: { showPictures: [] },
- zb: '', //坐标
- upload: {
- header: { apiToken: this.$getUser().apiToken },
- name: 'img',
- action: this.$http.urls.uploadImg,
- size_type: 'compressed ',
- count: 5
- }
- };
- },
- onLoad(e) {
- if (e.item) {
- this.item = JSON.parse(e.item);
- if (this.item.lat) {
- this.zb = '纬度:' + this.item.lat + ' 经度:' + this.item.lng;
- }
- this.subsection.forEach((item, index) => {
- if (item.value == this.item.shopType) {
- this.current = index;
- }
- });
- this.item.shopType = this.subsection[this.current].value;
- if (this.item.auditFlag == 0) {
- this.num = 1;
- }
- if (this.item.auditFlag == 1) {
- this.num = 2;
- }
- }
- },
- methods: {
- section(current) {
- this.current = current;
- },
- //定位
- wz(index) {
- uni.chooseLocation({
- success: r => {
- if (index == 1) {
- this.item.addres = r.address;
- }
- this.zb = '纬度:' + r.latitude + ' 经度:' + r.longitude;
- this.item.lat = r.latitude;
- this.item.lng = r.longitude;
- this.$forceUpdate();
- }
- });
- },
- up() {
- this.item.showPictures = [];
- let files = this.$refs.uUpload.lists.filter(val => {
- return val.progress == 100;
- });
- files.forEach(item => {
- if (item.response) {
- this.item.showPictures.push({ url: item.response.fileName }); //获取上传成功的网络地址
- } else {
- this.item.showPictures.push({ url: item.url }); //原来的地址
- }
- });
- let rule = [
- { name: 'name', checkType: 'notnull', errorMsg: '请输入商铺名称' },
- { name: 'addres', checkType: 'notnull', errorMsg: '请输入商铺地址' },
- { name: 'bossName', checkType: 'notnull', errorMsg: '请输入老板名称' },
- { name: 'bossPhone', checkType: 'notnull', errorMsg: '请输入老板电话' },
- { name: 'lat', checkType: 'notnull', errorMsg: '请在地图上选择坐标' },
- { name: 'showPictures', checkType: 'notnull', errorMsg: '请上传至少1张展示图' }
- ];
- if (!this.$verify.check(this.item, rule)) {
- uni.showModal({ content: this.$verify.error, showCancel: false });
- return;
- }
- this.item.shopType = this.subsection[this.current].value;
- this.item.memberId = this.$getUser().memberId;
- this.item.showPictures = JSON.stringify(this.item.showPictures);
- this.$http.request({
- method: 'POST',
- url: this.item.shopId ? this.$http.urls.updateShop : this.$http.urls.shopApply,
- data: this.item,
- success: res => {
- uni.showToast({ title: '提交成功' });
- setTimeout(() => {
- uni.$emit('shop');
- uni.navigateBack();
- }, 700);
- }
- });
- }
- }
- };
- </script>
- <style lang="scss">
- .steps {
- text-align: center;
- margin-top: 20px;
- }
- .u-subsection {
- margin-top: 20px;
- }
- .cn {
- padding: 15px;
- .info {
- background-color: white;
- border-radius: 5px;
- margin-top: 10px;
- padding-bottom: 10px;
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
- .dw {
- top: 11px;
- font-size: 19px;
- right: 9px;
- position: absolute;
- }
- }
- textarea {
- margin-left: 17px;
- font-size: 14px;
- padding: 10px;
- width: 85%;
- height: 85px;
- border: 1px solid #f1f1f1;
- border-radius: 5px;
- }
- .btn {
- margin-top: 25px;
- }
- }
- </style>
|