fillTable.vue 7.1 KB

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