fillTable.vue 8.6 KB

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