addStore.vue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. <template>
  2. <view class="container">
  3. <view style="height:25rpx;"></view>
  4. <form @submit="onSubmit">
  5. <view class="page-block">
  6. <view class="page-title-block">
  7. <view class="title">门店信息</view>
  8. </view>
  9. <view class="content">
  10. <view class="cell flex flex-y-center">
  11. <view class="title-block">
  12. <text>名称</text>
  13. </view>
  14. <view class="desc">
  15. <input type="text" name="title" :value="info.title" placeholder="请输入名称" />
  16. </view>
  17. </view>
  18. <view class="cell flex flex-y-center">
  19. <view class="title-block">
  20. <text>联系电话</text>
  21. </view>
  22. <view class="desc">
  23. <input type="text" name="tel" :value="info.tel" placeholder="请输入联系电话" />
  24. </view>
  25. </view>
  26. <view class="cell flex flex-y-center box-pack-between" @click="open" data-type="1">
  27. <view class="title-block">
  28. <text>省市区</text>
  29. </view>
  30. <view class="desc flex-grow-0" style="flex-grow: 0;">
  31. {{address.Prov_title}}{{address.City_title}}{{address.Dist_title}}
  32. <text class="iconfont icongengduo"></text>
  33. </view>
  34. </view>
  35. <view class="cell flex flex-y-center" data-type="1">
  36. <view class="title-block">
  37. <text>门店地址</text>
  38. </view>
  39. <view class="desc">
  40. <input type="text" name="address" :value="addr_input" placeholder="请输入门店地址"
  41. @input="onInputAddr" />
  42. </view>
  43. <view class="positon-btn flex-center" @click="chooseAddr">
  44. <image src="../../static/images/map.png" mode="aspectFit" class="icon-map"></image>定位
  45. </view>
  46. </view>
  47. <navigator url="./category" class="cell flex flex-y-center">
  48. <view class="title-block">
  49. <text>经营类目</text>
  50. </view>
  51. <view class="desc box-pack-between flex-y-center">
  52. <view class="input-box">{{new_shop_category_txt}}</view>
  53. <text class="iconfont icongengduo"></text>
  54. </view>
  55. </navigator>
  56. <view class="cell flex flex-y-center">
  57. <view class="title-block">
  58. <text>支付方式</text>
  59. </view>
  60. <view class=" flex-center">
  61. <view class="checklist-box " @click="choicepay(index)" v-for="(item,index) of pay_list"
  62. :key='index' :class="is_pay==index?'actt':''">
  63. <view class="radio__inner" :class="is_pay==index?'act_border':''">
  64. <view :class="is_pay==index?'is-default-checked':''"
  65. class="radio__inner-icon radio__inner-icon ">
  66. </view>
  67. </view>
  68. <text class="checklist-text">{{item}}</text>
  69. </view>
  70. </view>
  71. </view>
  72. <view class="cell flex flex-y-center">
  73. <view class="title-block">
  74. <text>是否开启会员</text>
  75. </view>
  76. <view class="desc flex-center ">
  77. <view class="checklist-box " @click="choicemenber(index)"
  78. v-for="(item,index) of menber_list" :key='index' :class="is_menber==index?'actt':''">
  79. <view class="radio__inner" :class="is_menber==index?'act_border':''">
  80. <view :class="is_menber==index?'is-default-checked':''"
  81. class="radio__inner-icon radio__inner-icon ">
  82. </view>
  83. </view>
  84. <text class="checklist-text">{{item}}</text>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="cell flex flex-y-center">
  89. <view class="title-block">
  90. <text>是否开启堂食</text>
  91. </view>
  92. <view class="desc flex-center ">
  93. <view class="checklist-box " @click="choicehall(index)"
  94. v-for="(item,index) of hall_list" :key='index' :class="is_hall==index?'actt':''">
  95. <view class="radio__inner" :class="is_hall==index?'act_border':''">
  96. <view :class="is_hall==index?'is-default-checked':''"
  97. class="radio__inner-icon radio__inner-icon ">
  98. </view>
  99. </view>
  100. <text class="checklist-text">{{item}}</text>
  101. </view>
  102. </view>
  103. </view>
  104. <view class="cell flex flex-y-center">
  105. <view class="title-block">
  106. <text>是否开启外卖</text>
  107. </view>
  108. <view class="desc flex-center">
  109. <view class="checklist-box " @click="choicewai(index)" v-for="(item,index) of wai_list"
  110. :key='index' :class="is_wai==index?'actt':''">
  111. <view class="radio__inner" :class="is_wai==index?'act_border':''">
  112. <view :class="is_wai==index?'is-default-checked':''"
  113. class="radio__inner-icon radio__inner-icon ">
  114. </view>
  115. </view>
  116. <text class="checklist-text">{{item}}</text>
  117. </view>
  118. </view>
  119. </view>
  120. <view class="cell flex flex-y-center">
  121. <view class="title-block">
  122. <text>是否开启到店自提</text>
  123. </view>
  124. <view class="desc flex-center">
  125. <view class="checklist-box " @click="choicezt(index)" v-for="(item,index) of zt_list"
  126. :key='index' :class="is_zt==index?'actt':''">
  127. <view class="radio__inner" :class="is_zt==index?'act_border':''">
  128. <view :class="is_zt==index?'is-default-checked':''"
  129. class="radio__inner-icon radio__inner-icon ">
  130. </view>
  131. </view>
  132. <text class="checklist-text">{{item}}</text>
  133. </view>
  134. </view>
  135. </view>
  136. </view>
  137. </view>
  138. <view class="info-car">
  139. <view class="title-block">
  140. <view class="title">
  141. 门店公告
  142. </view>
  143. </view>
  144. <view class="content">
  145. <input type="text" name="announcement" :value="info.announcement" placeholder="请输入内容(选填)" />
  146. </view>
  147. </view>
  148. <view class="info-car">
  149. <view class="title-block">
  150. <view class="title">
  151. 请上传LOGO
  152. </view>
  153. </view>
  154. <view class="content" @click="ChooseImage">
  155. <image :src="thumb?URL+thumb:'../static/images/icon_6.png'" class="logo-img" mode="">
  156. </image>
  157. </view>
  158. </view>
  159. <view style="height:30rpx;"></view>
  160. <view class="footer-bar">
  161. <view class="content flex flex-center" style="background: none;position: relative;z-index: 1;">
  162. <button class="btn" hover-class="none" form-type="submit">
  163. 立即提交
  164. </button>
  165. </view>
  166. </view>
  167. </form>
  168. <zx-uni-popup ref="uniScroll" type="bottom">
  169. <uni-scroll :Prov_arr="Prov_arr" @select="select"></uni-scroll>
  170. </zx-uni-popup>
  171. </view>
  172. </template>
  173. <script>
  174. import zxUniPopup from '@/components/zx-uni-popup/uni-popup.vue'
  175. import uniScroll from '@/components/uni-scroll/uni-scroll.vue'
  176. export default {
  177. components: {
  178. zxUniPopup,
  179. uniScroll,
  180. },
  181. data() {
  182. return {
  183. URL: getApp().globalData.URL,
  184. info: {},
  185. pay_list: [
  186. '餐前付款',
  187. '餐后付款'
  188. ],
  189. id: "",
  190. is_pay: 0,
  191. menber_list: [
  192. '否', '是'
  193. ],
  194. is_menber: 0,
  195. hall_list: [
  196. '否', '是'
  197. ],
  198. is_hall:0,
  199. wai_list: [
  200. '否', '是'
  201. ],
  202. is_wai: 0,
  203. Prov_arr: [],
  204. address: {
  205. Prov_title: "",
  206. City_title: "",
  207. Dist_title: ""
  208. },
  209. imgid: "",
  210. admin_id: "",
  211. shop_category: "",
  212. three_code: "",
  213. thumb: "",
  214. zt_list: [
  215. '否', '是'
  216. ],
  217. is_zt: 0,
  218. is_out: true,
  219. addr_input: '', //用户输入地址
  220. lat: '',
  221. lng: '',
  222. new_shop_category: {},
  223. new_shop_category_txt: '',
  224. }
  225. },
  226. onLoad(e) {
  227. // this.storeinfo();
  228. this.Prov();
  229. this.admin_id = uni.getStorageSync("admin_id");
  230. if (e.id) {
  231. this.id = e.id;
  232. this.store_user_info(e.id)
  233. }
  234. },
  235. onShow() {
  236. let cate = uni.getStorageSync("category")
  237. if (cate.three_code) {
  238. this.shop_category = cate.three_category;
  239. this.three_code = cate.three_code;
  240. }
  241. },
  242. methods: {
  243. onInputAddr(e) {
  244. this.addr_input = e.detail.value
  245. },
  246. chooseAddr() {
  247. let params = {
  248. province: '',
  249. city: '',
  250. county: '',
  251. address: '',
  252. }
  253. let flag = true
  254. if (this.address.Prov_code) {
  255. params.province = this.address.Prov_code
  256. params.city = this.address.City_code
  257. params.county = this.address.Dist_code
  258. flag = true
  259. }
  260. if (this.addr_input) {
  261. params.address = this.addr_input
  262. flag = true
  263. }
  264. if (flag) {
  265. this.request({
  266. url: 'Smdcshop/getLocation',
  267. data: params
  268. }).then(res => {
  269. if (res && res.code == 200) {
  270. this.chooseLocation(res.data.lat, res.data.lng)
  271. } else {
  272. this.chooseLocation()
  273. }
  274. }).catch(e => {
  275. this.chooseLocation()
  276. })
  277. } else {
  278. this.chooseLocation()
  279. }
  280. },
  281. chooseLocation(lat = '', lng = '') {
  282. uni.chooseLocation({
  283. latitude: lat,
  284. longitude: lng,
  285. success: res => {
  286. this.lat = res.latitude
  287. this.lng = res.longitude
  288. if (this.addr_input === '') {
  289. this.addr_input = res.address
  290. }
  291. },
  292. complete: r => {
  293. }
  294. });
  295. },
  296. choicezt(index) {
  297. this.is_zt = index;
  298. },
  299. choicehall(index) {
  300. this.is_hall = index;
  301. },
  302. //获取详情
  303. store_user_info(id) {
  304. this.request({
  305. url: 'Smdcshop/storeinfo',
  306. data: {
  307. store_id: id,
  308. }
  309. }).then(res => {
  310. if (res.code == 200) {
  311. this.info = res.data;
  312. this.thumb = res.data.thumb;
  313. this.address = {
  314. Prov_code: res.data.province_code,
  315. Prov_title: res.data.province_name,
  316. City_code: res.data.city_code,
  317. City_title: res.data.city_name,
  318. Dist_code: res.data.district_code,
  319. Dist_title: res.data.district_name
  320. }
  321. this.addr_input = res.data.address || ''
  322. this.lat = res.data.lat
  323. this.lng = res.data.lng
  324. this.is_pay = Number(res.data.pay_type) - 1;
  325. this.is_menber = res.data.is_vip;
  326. this.is_wai = res.data.is_waimai;
  327. this.is_zt = res.data.is_ziti;
  328. this.is_hall = res.data.is_hall;
  329. if(res.data.one_category && res.data.two_category){
  330. this.new_shop_category = {
  331. one_category: {
  332. code: res.data.one_category,
  333. id: res.data.one_category_id,
  334. name: res.data.one_category_name,
  335. },
  336. two_category: {
  337. code: res.data.two_category,
  338. id: res.data.two_category_id,
  339. name: res.data.two_category_name,
  340. }
  341. }
  342. this.new_shop_category_txt =
  343. `${res.data.one_category_name}>${res.data.two_category_name}`
  344. }
  345. }
  346. })
  347. },
  348. open(e) {
  349. this.$refs.uniScroll.open();
  350. },
  351. select(e) {
  352. this.address = e;
  353. },
  354. Prov(e) {
  355. this.request({
  356. url: "Smdcshop/citys",
  357. data: {},
  358. }).then(res => {
  359. if (res.code === '200') {
  360. this.Prov_arr = res.data;
  361. }
  362. });
  363. },
  364. ChooseImage(e) {
  365. let type = e.currentTarget.dataset.type;
  366. uni.chooseImage({
  367. count: 1, //默认9
  368. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  369. sourceType: ['album'], //从相册选择
  370. success: (res) => {
  371. // var tempFilesSize = res.tempFiles[0].size;//获取图片的大小,单位B
  372. res.tempFilePaths.forEach((v, i) => {
  373. //
  374. this.Upload({
  375. url: "Smdcshop/upload",
  376. data: {
  377. url: v,
  378. type: "",
  379. token: "",
  380. admin_id: this.admin_id
  381. }
  382. }).then(res => {
  383. this.imgid = res.id;
  384. this.thumb = res.src;
  385. }).catch(err => {
  386. uni.showToast({
  387. title: err.message,
  388. icon: 'none'
  389. })
  390. });
  391. })
  392. },
  393. });
  394. },
  395. choicepay(index) {
  396. this.is_pay = index;
  397. },
  398. choicemenber(index) {
  399. this.is_menber = index;
  400. },
  401. choicewai(index) {
  402. this.is_wai = index;
  403. },
  404. onSubmit(e) {
  405. let params = {
  406. admin_id: this.admin_id,
  407. province_code: this.address.Prov_code,
  408. city_code: this.address.City_code,
  409. district_code: this.address.Dist_code,
  410. pay_type: Number(this.is_pay) + 1,
  411. is_vip: this.is_menber,
  412. is_hall:this.is_hall,
  413. is_waimai: this.is_wai,
  414. num: 1,
  415. is_ziti: this.is_zt,
  416. is_hall:this.is_hall,
  417. thumb: this.imgid,
  418. lat: this.lat,
  419. lng: this.lng,
  420. },
  421. url;
  422. if (this.id) {
  423. params.id = this.id
  424. url = 'Smdcshop/store_update'
  425. } else {
  426. url = 'Smdcshop/shop_store_add'
  427. }
  428. var data = Object.assign(params, e.detail.value);
  429. if (!data.title || !data.tel || !data.city_code || !data.address) {
  430. uni.showToast({
  431. title: "必填项不能为空",
  432. icon: 'none'
  433. })
  434. return false
  435. }
  436. if (!this.new_shop_category_txt) {
  437. uni.showToast({
  438. title: "请选择经营类目",
  439. icon: 'none'
  440. })
  441. return false
  442. } else {
  443. data.one_category = this.new_shop_category.one_category.code
  444. data.two_category = this.new_shop_category.two_category.code
  445. }
  446. this.request({
  447. url,
  448. data: data
  449. }).then(res => {
  450. if (res.code == 200) {
  451. uni.showToast({
  452. title: res.message,
  453. icon: 'none'
  454. })
  455. setTimeout(() => {
  456. uni.navigateBack()
  457. }, 3000)
  458. }
  459. }).catch((res) => {
  460. uni.showToast({
  461. title: res.message,
  462. icon: 'none'
  463. })
  464. });
  465. },
  466. }
  467. }
  468. </script>
  469. <style>
  470. @import url("../static/css/common.css");
  471. .info-car {
  472. margin-top: 25rpx;
  473. background-color: #fff;
  474. padding: 0 25rpx;
  475. }
  476. .info-car .title-block {
  477. border-bottom: 1rpx solid #f5f5f5;
  478. }
  479. .info-car .title {
  480. height: 100rpx;
  481. line-height: 100rpx;
  482. font-size: 30rpx;
  483. color: #333;
  484. font-weight: 600;
  485. }
  486. .info-car .content {
  487. padding: 30rpx 0;
  488. }
  489. .info-car .input-box {
  490. font-size: 30rpx;
  491. color: #000;
  492. }
  493. .info-car .logo-img {
  494. display: block;
  495. width: 120rpx;
  496. height: 120rpx;
  497. }
  498. page {
  499. background-color: #F4F5F7;
  500. }
  501. .header {
  502. height: 148rpx;
  503. padding: 0 25rpx;
  504. background-color: #fff;
  505. }
  506. .header .logo-img {
  507. display: block;
  508. width: 100rpx;
  509. height: 100rpx;
  510. border-radius: 8rpx;
  511. margin-right: 24rpx;
  512. }
  513. .checklist-box {
  514. display: -webkit-box;
  515. display: -webkit-flex;
  516. display: flex;
  517. -webkit-box-orient: horizontal;
  518. -webkit-box-direction: normal;
  519. -webkit-flex-direction: row;
  520. flex-direction: row;
  521. -webkit-box-align: center;
  522. -webkit-align-items: center;
  523. align-items: center;
  524. margin: 5px 0;
  525. margin-right: 22px;
  526. }
  527. .radio__inner {
  528. -webkit-flex-shrink: 0;
  529. flex-shrink: 0;
  530. display: -webkit-box;
  531. display: -webkit-flex;
  532. display: flex;
  533. -webkit-box-pack: center;
  534. -webkit-justify-content: center;
  535. justify-content: center;
  536. -webkit-box-align: center;
  537. -webkit-align-items: center;
  538. align-items: center;
  539. position: relative;
  540. border: 1px solid #DCDFE6;
  541. border-radius: 2px;
  542. box-sizing: border-box;
  543. width: 16px;
  544. height: 16px;
  545. border-radius: 16px;
  546. background-color: #fff;
  547. z-index: 1;
  548. -webkit-transition: border-color .3s;
  549. transition: border-color .3s;
  550. }
  551. .radio__inner-icon {
  552. width: 8px;
  553. height: 8px;
  554. border-radius: 10px;
  555. opacity: 0;
  556. -webkit-transition: -webkit-transform .3s;
  557. transition: -webkit-transform .3s;
  558. transition: transform .3s;
  559. transition: transform .3s, -webkit-transform .3s;
  560. }
  561. .is-default-checked {
  562. opacity: 1;
  563. background-color: #007aff;
  564. -webkit-transform: rotate(45deg) scaleY(1);
  565. transform: rotate(45deg) scaleY(1);
  566. }
  567. page .act_border {
  568. border-color: #007AFF;
  569. }
  570. .checklist-text {
  571. font-size: 28rpx;
  572. margin-left: 5px;
  573. -webkit-transition: color 0.2s;
  574. transition: color 0.2s;
  575. color: #000;
  576. }
  577. .positon-btn {
  578. font-size: 26rpx;
  579. color: #007aff;
  580. }
  581. .positon-btn .icon-map {
  582. display: block;
  583. width: 30rpx;
  584. height: 30rpx;
  585. }
  586. </style>