fillTable.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  1. <template>
  2. <view class="content">
  3. <view class="item">
  4. <view class="item-tit">店铺名称</view>
  5. <input type="text" v-model="store.name" placeholder="请输入店铺名称" :disabled="type == 'look'"/>
  6. </view>
  7. <view class="item">
  8. <view class="item-tit">店铺logo</view>
  9. <view class="up-wrapper">
  10. <image :src="store.image" mode="" v-if="store.image" @click.stop="type != 'look'?upImg():''"></image>
  11. <image src="../../static/img/add.png" mode="" v-else @click.stop="type != 'look'?upImg():''"></image>
  12. </view>
  13. </view>
  14. <view class="item">
  15. <view class="item-tit">联系电话</view>
  16. <input type="number" v-model="store.phone" placeholder="请输入商家电话" v-if="type != 'look'"/>
  17. <input type="number" v-model="store.phone" placeholder="请输入商家电话" :disabled="type == 'look'" v-else @click="call(store.phone)"/>
  18. </view>
  19. <view class="item">
  20. <view class="item-tit">营业时间</view>
  21. <template v-if="type != 'look'">
  22. <picker mode="time" :value="bgtime" @change="bindBgtimeChange" class="picker">
  23. <view class="uni-input">{{ bgtime }}</view>
  24. </picker>
  25. <view class="line"></view>
  26. <picker mode="time" :value="edtime" @change="bindEdtimeChange" class="picker prcker-t">
  27. <view class="uni-input">{{ edtime }}</view>
  28. </picker>
  29. </template>
  30. <input type="text" v-model="store.day_time" placeholder="" :disabled="type == 'look'" v-if="type == 'look'"/>
  31. </view>
  32. <view class="item" @click="getLocation" v-if="type == 'add'">
  33. <view class="item-tit">经纬度</view>
  34. <input type="text" v-model="store.latlng" placeholder="请选择经纬度" />
  35. </view>
  36. <view class="item">
  37. <view class="item-tit">详细地址</view>
  38. <input type="text" v-model="store.detailed_address" placeholder="请输入详细地址" :disabled="type == 'look'"/>
  39. </view>
  40. <view class="item" v-if="type != 'look'">
  41. <view class="item-tit">申请等级</view>
  42. <input type="text" v-model="chooselevel" placeholder="请选择申请等级" disabled v-if="type=='edit'"/>
  43. <template v-if="type == 'add'">
  44. <picker mode="selector" :range="levelList" @change="bindLevelChange" class="picker">
  45. <input type="text" v-model="chooselevel" placeholder="请选择申请等级" disabled />
  46. </picker>
  47. </template>
  48. </view>
  49. <view class="sub" @click="sub" v-if="type == 'edit'">确认修改</view>
  50. <view class="sub" @click="add" v-if="type == 'add'">提交</view>
  51. <view class="sub" @click="goto" v-if="type == 'look'">
  52. 一键导航
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. import {
  58. mapState,
  59. mapMutations
  60. } from 'vuex';
  61. import {
  62. myStore,
  63. editStore
  64. } from '@/api/user.js';
  65. import {
  66. upload
  67. } from '@/api/order.js';
  68. export default {
  69. data() {
  70. return {
  71. store: {
  72. name: '',
  73. phone: '',
  74. id: '',
  75. image: '',
  76. id: '',
  77. detailed_address: '',
  78. day_time: '',
  79. latlng: ''
  80. },
  81. chooselevel: '',
  82. levelList: ['美容院', '美容院B'],
  83. bgtime: '请选择时间',
  84. edtime: '请选择时间',
  85. detailed_address: '',
  86. type: 'edit'
  87. };
  88. },
  89. computed: {
  90. ...mapState('user',['showStore'])
  91. },
  92. onLoad(opt) {
  93. if (opt.type == 'edit') {
  94. this.loadData();
  95. }
  96. if(opt.type == 'look') {
  97. this.type = 'look'
  98. uni.setNavigationBarTitle({
  99. title: '美容院详情'
  100. })
  101. this.store = uni.getStorageSync('showStore')
  102. let arr = this.store.day_time.split('- ')
  103. console.log(arr,'arr')
  104. this.bgtime = arr[0]
  105. this.edtime = arr[1]
  106. }
  107. if (opt.type == 'add') {
  108. this.type = 'add';
  109. this.bgtime = '00:00';
  110. this.edtime = '00:00';
  111. }
  112. },
  113. methods: {
  114. goto() {
  115. let latitude = this.store.latitude
  116. let longitude = this.store.longitude
  117. let address = this.store.name
  118. window.location.href =
  119. `http://apis.map.qq.com/uri/v1/marker?marker=coord:${latitude},${longitude};addr:${address}`;
  120. },
  121. call(phone) {
  122. uni.makePhoneCall({
  123. phoneNumber:phone
  124. })
  125. },
  126. bindLevelChange(e) {
  127. console.log(e)
  128. this.chooselevel = this.levelList[e.detail.value];
  129. },
  130. loadData() {
  131. myStore().then(({
  132. data
  133. }) => {
  134. this.store = data[0];
  135. this.chooselevel = this.store.level == 3? '美容院': '美容院B'
  136. let time = this.store.day_time.split(' - ');
  137. this.bgtime = time[0].substring(0, 5);
  138. this.edtime = time[1].substring(0, 5);
  139. });
  140. },
  141. // 选择当前位置
  142. getLocation() {
  143. console.log('选择当前位置');
  144. let obj = this;
  145. uni.chooseLocation({
  146. success: function(res) {
  147. // obj.addressData.area = res.name;
  148. console.log('位置名称:' + res.name);
  149. console.log('详细地址:' + res.address);
  150. console.log('纬度:' + res.latitude);
  151. console.log('经度:' + res.longitude);
  152. // obj.addressData.latitude = res.latitude;
  153. // obj.addressData.longitude = res.longitude;
  154. obj.$set(obj.store, 'latlng', res.latitude + ',' + res.longitude);
  155. // obj.store.latlng = res.latitude + ',' + res.longitude
  156. }
  157. });
  158. },
  159. bindBgtimeChange(e) {
  160. console.log(e);
  161. this.bgtime = e.detail.value;
  162. },
  163. bindEdtimeChange(e) {
  164. console.log(e);
  165. this.edtime = e.detail.value;
  166. },
  167. indicatorStyle() {},
  168. // 修改logo
  169. upImg() {
  170. let obj = this;
  171. upload({
  172. filename: ''
  173. }).then(res => {
  174. console.log(res[0].url);
  175. obj.store.image = res[0].url;
  176. });
  177. },
  178. //提交
  179. sub() {
  180. let obj = this;
  181. let store = obj.store;
  182. if (store.name == '') {
  183. obj.$api.msg('请输入店铺名称');
  184. return;
  185. }
  186. if (store.phone == '') {
  187. obj.$api.msg('请输入店铺电话');
  188. return;
  189. }
  190. if (store.image == '') {
  191. obj.$api.msg('请选择店铺logo');
  192. return;
  193. }
  194. if (store.day_time == '') {
  195. obj.$api.msg('请输入营业时间');
  196. return;
  197. }
  198. if (store.detailed_address == '') {
  199. obj.$api.msg('请输入店铺地址');
  200. return;
  201. }
  202. if (obj.chooselevel == '') {
  203. obj.$api.msg('请选择申请等级');
  204. return;
  205. }
  206. uni.showLoading({
  207. title: '提交中...',
  208. mask: true
  209. });
  210. let day_time = obj.bgtime + ':00 - ' + obj.edtime + ':00';
  211. editStore({
  212. id: store.id,
  213. name: store.name,
  214. detailed_address: store.detailed_address,
  215. image: store.image,
  216. phone: store.phone,
  217. day_time: day_time,
  218. latlng: store.latitude + ',' + store.longitude,
  219. level: obj.chooselevel == '美容院' ? 3 : 4
  220. })
  221. .then(res => {
  222. uni.hideLoading();
  223. uni.showToast({
  224. title: '提交成功',
  225. duration: 2000
  226. });
  227. obj.$api.prePage().refreshList();
  228. setTimeout(function() {
  229. uni.navigateBack();
  230. }, 800);
  231. })
  232. .catch(err => {
  233. uni.hideLoading();
  234. console.log(err);
  235. });
  236. },
  237. add() {
  238. let obj = this;
  239. let store = obj.store;
  240. if (store.name == '') {
  241. obj.$api.msg('请输入店铺名称');
  242. return;
  243. }
  244. if (store.phone == '') {
  245. obj.$api.msg('请输入店铺电话');
  246. return;
  247. }
  248. if (store.image == '') {
  249. obj.$api.msg('请选择店铺头像');
  250. return;
  251. }
  252. // if (store.day_time == '') {
  253. // obj.$api.msg('请输入营业时间');
  254. // return;
  255. // }
  256. if (store.introduction == '') {
  257. obj.$api.msg('请输入店铺简介');
  258. return;
  259. }
  260. if (store.detailed_address == '') {
  261. obj.$api.msg('请输入店铺地址');
  262. return;
  263. }
  264. let day_time = obj.bgtime + ':00 - ' + obj.edtime + ':00';
  265. editStore({
  266. id: 0,
  267. name: store.name,
  268. introduction: store.introduction,
  269. image: store.image,
  270. phone: store.phone,
  271. day_time: day_time,
  272. latlng: store.latlng,
  273. detailed_address: store.detailed_address,
  274. is_show: 0
  275. })
  276. .then(res => {
  277. uni.hideLoading();
  278. uni.showToast({
  279. title: '提交成功',
  280. duration: 2000
  281. });
  282. obj.$api.prePage().refreshList();
  283. setTimeout(function() {
  284. uni.navigateBack();
  285. }, 800);
  286. })
  287. .catch(err => {
  288. uni.hideLoading();
  289. console.log(err);
  290. });
  291. }
  292. }
  293. };
  294. </script>
  295. <style lang="scss" scoped>
  296. page {
  297. height: 100%;
  298. background-color: #f8f6f6;
  299. }
  300. .item {
  301. background-color: #fff !important;
  302. min-height: 100rpx;
  303. display: flex;
  304. width: 750px;
  305. border: 1px #f4f4f4 solid;
  306. .line {
  307. display: inline-block;
  308. line-height: 100rpx;
  309. }
  310. .item-tit {
  311. height: 100rpx;
  312. line-height: 100rpx;
  313. padding-left: 30rpx;
  314. width: 200rpx;
  315. font-size: 30rpx;
  316. font-family: PingFang SC;
  317. font-weight: 500;
  318. color: #666666;
  319. flex-shrink: 0;
  320. }
  321. input {
  322. width: 550rpx;
  323. height: 100rpx;
  324. line-height: 100rpx;
  325. font-size: 30rpx;
  326. font-family: PingFang SC;
  327. font-weight: 500;
  328. color: #333333;
  329. }
  330. textarea {
  331. width: 550rpx;
  332. height: 257rpx;
  333. padding-top: 25rpx;
  334. padding-right: 30rpx;
  335. line-height: 50rpx;
  336. font-size: 30rpx;
  337. font-family: PingFang SC;
  338. font-weight: 500;
  339. color: #333333;
  340. }
  341. .up-wrapper {
  342. height: 352rpx;
  343. width: 550rpx;
  344. position: relative;
  345. image {
  346. position: absolute;
  347. height: 160rpx;
  348. width: 160rpx;
  349. top: 0;
  350. bottom: 0;
  351. left: 94rpx;
  352. margin: auto;
  353. }
  354. }
  355. }
  356. .sub {
  357. width: 674rpx;
  358. height: 88rpx;
  359. background: #ff4c4c;
  360. border-radius: 44rpx;
  361. line-height: 88rpx;
  362. text-align: center;
  363. font-size: 36rpx;
  364. font-family: PingFang SC;
  365. font-weight: 500;
  366. color: #ffffff;
  367. position: absolute;
  368. bottom: 35rpx;
  369. left: 0;
  370. right: 0;
  371. margin: auto;
  372. }
  373. .picker {
  374. display: inline-block;
  375. padding-right: 40rpx;
  376. height: 100rpx;
  377. line-height: 100rpx;
  378. }
  379. .prcker-t {
  380. padding-left: 40rpx;
  381. }
  382. </style>