123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396 |
- <template>
- <view class="content">
- <view class="item">
- <view class="item-tit">店铺名称</view>
- <input type="text" v-model="store.name" placeholder="请输入店铺名称" :disabled="type == 'look'"/>
- </view>
- <view class="item">
- <view class="item-tit">店铺logo</view>
- <view class="up-wrapper">
- <image :src="store.image" mode="" v-if="store.image" @click.stop="type != 'look'?upImg():''"></image>
- <image src="../../static/img/add.png" mode="" v-else @click.stop="type != 'look'?upImg():''"></image>
- </view>
- </view>
- <view class="item">
- <view class="item-tit">联系电话</view>
- <input type="number" v-model="store.phone" placeholder="请输入商家电话" v-if="type != 'look'"/>
- <input type="number" v-model="store.phone" placeholder="请输入商家电话" :disabled="type == 'look'" v-else @click="call(store.phone)"/>
- </view>
- <view class="item">
- <view class="item-tit">营业时间</view>
- <template v-if="type != 'look'">
- <picker mode="time" :value="bgtime" @change="bindBgtimeChange" class="picker">
- <view class="uni-input">{{ bgtime }}</view>
- </picker>
- <view class="line">至</view>
- <picker mode="time" :value="edtime" @change="bindEdtimeChange" class="picker prcker-t">
- <view class="uni-input">{{ edtime }}</view>
- </picker>
- </template>
- <input type="text" v-model="store.day_time" placeholder="" :disabled="type == 'look'" v-if="type == 'look'"/>
- </view>
- <view class="item" @click="getLocation" v-if="type == 'add'">
- <view class="item-tit">经纬度</view>
- <input type="text" v-model="store.latlng" placeholder="请选择经纬度" />
- </view>
- <view class="item">
- <view class="item-tit">详细地址</view>
- <input type="text" v-model="store.detailed_address" placeholder="请输入详细地址" :disabled="type == 'look'"/>
- </view>
- <view class="item" v-if="type != 'look'">
- <view class="item-tit">申请等级</view>
- <input type="text" v-model="chooselevel" placeholder="请选择申请等级" disabled v-if="type=='edit'"/>
- <template v-if="type == 'add'">
- <picker mode="selector" :range="levelList" @change="bindLevelChange" class="picker">
- <input type="text" v-model="chooselevel" placeholder="请选择申请等级" disabled />
- </picker>
- </template>
-
- </view>
- <view class="sub" @click="sub" v-if="type == 'edit'">确认修改</view>
- <view class="sub" @click="add" v-if="type == 'add'">提交</view>
- <view class="sub" @click="goto" v-if="type == 'look'">
- 一键导航
- </view>
- </view>
- </template>
- <script>
- import {
- mapState,
- mapMutations
- } from 'vuex';
- import {
- myStore,
- editStore
- } from '@/api/user.js';
- import {
- upload
- } from '@/api/order.js';
- export default {
- data() {
- return {
- store: {
- name: '',
- phone: '',
- id: '',
- image: '',
- id: '',
- detailed_address: '',
- day_time: '',
- latlng: ''
- },
- chooselevel: '',
- levelList: ['美容院', '美容院B'],
- bgtime: '请选择时间',
- edtime: '请选择时间',
- detailed_address: '',
- type: 'edit'
- };
- },
- computed: {
- ...mapState('user',['showStore'])
- },
- onLoad(opt) {
- if (opt.type == 'edit') {
- this.loadData();
- }
- if(opt.type == 'look') {
- this.type = 'look'
- uni.setNavigationBarTitle({
- title: '美容院详情'
- })
- this.store = uni.getStorageSync('showStore')
- let arr = this.store.day_time.split('- ')
- console.log(arr,'arr')
- this.bgtime = arr[0]
- this.edtime = arr[1]
- }
- if (opt.type == 'add') {
- this.type = 'add';
- this.bgtime = '00:00';
- this.edtime = '00:00';
- }
- },
- methods: {
- goto() {
- let latitude = this.store.latitude
- let longitude = this.store.longitude
- let address = this.store.name
- window.location.href =
- `http://apis.map.qq.com/uri/v1/marker?marker=coord:${latitude},${longitude};addr:${address}`;
- },
- call(phone) {
- uni.makePhoneCall({
- phoneNumber:phone
- })
- },
- bindLevelChange(e) {
- console.log(e)
- this.chooselevel = this.levelList[e.detail.value];
- },
- loadData() {
- myStore().then(({
- data
- }) => {
- this.store = data[0];
- this.chooselevel = this.store.level == 3? '美容院': '美容院B'
- let time = this.store.day_time.split(' - ');
- this.bgtime = time[0].substring(0, 5);
- this.edtime = time[1].substring(0, 5);
- });
- },
-
- getLocation() {
- console.log('选择当前位置');
- let obj = this;
- uni.chooseLocation({
- success: function(res) {
-
- console.log('位置名称:' + res.name);
- console.log('详细地址:' + res.address);
- console.log('纬度:' + res.latitude);
- console.log('经度:' + res.longitude);
-
-
- obj.$set(obj.store, 'latlng', res.latitude + ',' + res.longitude);
- // obj.store.latlng = res.latitude + ',' + res.longitude
- }
- });
- },
- bindBgtimeChange(e) {
- console.log(e);
- this.bgtime = e.detail.value;
- },
- bindEdtimeChange(e) {
- console.log(e);
- this.edtime = e.detail.value;
- },
- indicatorStyle() {},
-
- upImg() {
- let obj = this;
- upload({
- filename: ''
- }).then(res => {
- console.log(res[0].url);
- obj.store.image = res[0].url;
- });
- },
-
- sub() {
- let obj = this;
- let store = obj.store;
- if (store.name == '') {
- obj.$api.msg('请输入店铺名称');
- return;
- }
- if (store.phone == '') {
- obj.$api.msg('请输入店铺电话');
- return;
- }
- if (store.image == '') {
- obj.$api.msg('请选择店铺logo');
- return;
- }
- if (store.day_time == '') {
- obj.$api.msg('请输入营业时间');
- return;
- }
- if (store.detailed_address == '') {
- obj.$api.msg('请输入店铺地址');
- return;
- }
- if (obj.chooselevel == '') {
- obj.$api.msg('请选择申请等级');
- return;
- }
- uni.showLoading({
- title: '提交中...',
- mask: true
- });
- let day_time = obj.bgtime + ':00 - ' + obj.edtime + ':00';
- editStore({
- id: store.id,
- name: store.name,
- detailed_address: store.detailed_address,
- image: store.image,
- phone: store.phone,
- day_time: day_time,
- latlng: store.latitude + ',' + store.longitude,
- level: obj.chooselevel == '美容院' ? 3 : 4
- })
- .then(res => {
- uni.hideLoading();
- uni.showToast({
- title: '提交成功',
- duration: 2000
- });
- obj.$api.prePage().refreshList();
- setTimeout(function() {
- uni.navigateBack();
- }, 800);
- })
- .catch(err => {
- uni.hideLoading();
- console.log(err);
- });
- },
- add() {
- let obj = this;
- let store = obj.store;
- if (store.name == '') {
- obj.$api.msg('请输入店铺名称');
- return;
- }
- if (store.phone == '') {
- obj.$api.msg('请输入店铺电话');
- return;
- }
- if (store.image == '') {
- obj.$api.msg('请选择店铺头像');
- return;
- }
-
-
-
-
- if (store.introduction == '') {
- obj.$api.msg('请输入店铺简介');
- return;
- }
- if (store.detailed_address == '') {
- obj.$api.msg('请输入店铺地址');
- return;
- }
- let day_time = obj.bgtime + ':00 - ' + obj.edtime + ':00';
- editStore({
- id: 0,
- name: store.name,
- introduction: store.introduction,
- image: store.image,
- phone: store.phone,
- day_time: day_time,
- latlng: store.latlng,
- detailed_address: store.detailed_address,
- is_show: 0
- })
- .then(res => {
- uni.hideLoading();
- uni.showToast({
- title: '提交成功',
- duration: 2000
- });
- obj.$api.prePage().refreshList();
- setTimeout(function() {
- uni.navigateBack();
- }, 800);
- })
- .catch(err => {
- uni.hideLoading();
- console.log(err);
- });
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- page {
- height: 100%;
- background-color: #f8f6f6;
- }
- .item {
- background-color: #fff !important;
- min-height: 100rpx;
- display: flex;
- width: 750px;
- border: 1px #f4f4f4 solid;
- .line {
- display: inline-block;
- line-height: 100rpx;
- }
- .item-tit {
- height: 100rpx;
- line-height: 100rpx;
- padding-left: 30rpx;
- width: 200rpx;
- font-size: 30rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #666666;
- flex-shrink: 0;
- }
- input {
- width: 550rpx;
- height: 100rpx;
- line-height: 100rpx;
- font-size: 30rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #333333;
- }
- textarea {
- width: 550rpx;
- height: 257rpx;
- padding-top: 25rpx;
- padding-right: 30rpx;
- line-height: 50rpx;
- font-size: 30rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #333333;
- }
- .up-wrapper {
- height: 352rpx;
- width: 550rpx;
- position: relative;
- image {
- position: absolute;
- height: 160rpx;
- width: 160rpx;
- top: 0;
- bottom: 0;
- left: 94rpx;
- margin: auto;
- }
- }
- }
- .sub {
- width: 674rpx;
- height: 88rpx;
- background: #ff4c4c;
- border-radius: 44rpx;
- line-height: 88rpx;
- text-align: center;
- font-size: 36rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #ffffff;
- position: absolute;
- bottom: 35rpx;
- left: 0;
- right: 0;
- margin: auto;
- }
- .picker {
- display: inline-block;
- padding-right: 40rpx;
- height: 100rpx;
- line-height: 100rpx;
- }
- .prcker-t {
- padding-left: 40rpx;
- }
- </style>
|