operate.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. <template>
  2. <base-page>
  3. <view class="common-wrap common-form fixd common-scrollbar">
  4. <view class="common-title">运营设置</view>
  5. <view class="common-form-item">
  6. <label class="form-label">门店名称</label>
  7. <view class="form-input-inline"><input type="text" v-model="storeData.store_name" disabled class="form-input" /></view>
  8. <text class="form-word-aux-line">门店的名称(招牌)</text>
  9. </view>
  10. <view class="common-form-item">
  11. <label class="form-label">是否营业</label>
  12. <view class="form-inline">
  13. <radio-group @change="statusChange" class="form-radio-group">
  14. <label class="radio form-radio-item">
  15. <radio value="1" :checked="storeData.status == 1" />
  16. </label>
  17. <label class="radio form-radio-item">
  18. <radio value="0" :checked="storeData.status == 0" />
  19. </label>
  20. </radio-group>
  21. </view>
  22. </view>
  23. <view class="common-form-item">
  24. <label class="form-label">营业时间</label>
  25. <view class="form-inline">
  26. <view class="form-input-inline long"><input type="text" v-model="storeData.open_date" class="form-input" /></view>
  27. </view>
  28. </view>
  29. <view class="common-form-item">
  30. <label class="form-label">物流配送</label>
  31. <view class="form-inline">
  32. <radio-group @change="expressChange" class="form-radio-group">
  33. <label class="radio form-radio-item">
  34. <radio value="1" :checked="storeData.is_express == 1" />
  35. 开启
  36. </label>
  37. <label class="radio form-radio-item">
  38. <radio value="0" :checked="storeData.is_express == 0" />
  39. 关闭
  40. </label>
  41. </radio-group>
  42. </view>
  43. <text class="form-word-aux-line">物流配送只有在连锁门店模式有效,在平台运营模式,按照总店查询</text>
  44. </view>
  45. <view class="common-form-item">
  46. <label class="form-label">同城配送</label>
  47. <view class="form-inline">
  48. <radio-group @change="o2oChange" class="form-radio-group">
  49. <label class="radio form-radio-item">
  50. <radio value="1" :checked="storeData.is_o2o == 1" />
  51. 开启
  52. </label>
  53. <label class="radio form-radio-item">
  54. <radio value="0" :checked="storeData.is_o2o == 0" />
  55. 关闭
  56. </label>
  57. </radio-group>
  58. </view>
  59. <text class="form-word-aux-line">开启同城配送需要门店设置配送费用以及配送员</text>
  60. </view>
  61. <view class="common-form-item">
  62. <label class="form-label">门店自提</label>
  63. <view class="form-inline">
  64. <radio-group @change="pickupChange" class="form-radio-group">
  65. <label class="radio form-radio-item">
  66. <radio value="1" :checked="storeData.is_pickup == 1" />
  67. 开启
  68. </label>
  69. <label class="radio form-radio-item">
  70. <radio value="0" :checked="storeData.is_pickup == 0" />
  71. 关闭
  72. </label>
  73. </radio-group>
  74. </view>
  75. </view>
  76. <block v-if="storeData.is_pickup == 1">
  77. <view class="common-form-item">
  78. <label class="form-label">自提日期</label>
  79. <view class="form-inline">
  80. <radio-group @change="timeTypeChange" class="form-radio-group">
  81. <label class="radio form-radio-item">
  82. <radio value="0" :checked="storeData.time_type == 0" />
  83. 每天
  84. </label>
  85. <label class="radio form-radio-item">
  86. <radio value="1" :checked="storeData.time_type == 1" />
  87. 自定义
  88. </label>
  89. </radio-group>
  90. </view>
  91. </view>
  92. <view class="common-form-item" v-if="storeData.time_type == 1">
  93. <label class="form-label">自提时间</label>
  94. <view class="form-block">
  95. <checkbox-group class="form-checkbox-group" @change="checkboxChange">
  96. <label class="form-checkbox-item">
  97. <checkbox value="1" :checked="storeData.time_week.includes('1') || storeData.time_week.includes(1)" />
  98. 周一
  99. </label>
  100. <label class="form-checkbox-item">
  101. <checkbox value="2" :checked="storeData.time_week.includes('2') || storeData.time_week.includes(2)" />
  102. 周二
  103. </label>
  104. <label class="form-checkbox-item">
  105. <checkbox value="3" :checked="storeData.time_week.includes('3') || storeData.time_week.includes(3)" />
  106. 周三
  107. </label>
  108. <label class="form-checkbox-item">
  109. <checkbox value="4" :checked="storeData.time_week.includes('4') || storeData.time_week.includes(4)" />
  110. 周四
  111. </label>
  112. <label class="form-checkbox-item">
  113. <checkbox value="5" :checked="storeData.time_week.includes('5') || storeData.time_week.includes(5)" />
  114. 周五
  115. </label>
  116. <label class="form-checkbox-item">
  117. <checkbox value="6" :checked="storeData.time_week.includes('6') || storeData.time_week.includes(6)" />
  118. 周六
  119. </label>
  120. <label class="form-checkbox-item">
  121. <checkbox value="0" :checked="storeData.time_week.includes('0') || storeData.time_week.includes(0)" />
  122. 周日
  123. </label>
  124. </checkbox-group>
  125. </view>
  126. </view>
  127. <view class="common-form-item" v-for="(item, index) in storeData.delivery_time" :key="index">
  128. <label class="form-label">{{ index == 0 ? '时段设置' : '' }}</label>
  129. <view class="form-inline">
  130. <view class="form-input-inline">
  131. <picker mode="time" class="form-input" :value="timeFormat(item.start_time)" @change="bindStartTimeChange($event, index)">
  132. <view class="uni-input">{{ item.start_time ? timeFormat(item.start_time) : '' }}</view>
  133. </picker>
  134. </view>
  135. <text class="form-mid">-</text>
  136. <view class="form-input-inline">
  137. <picker mode="time" class="form-input" :value="timeFormat(item.end_time)" @change="bindEndTimeChange($event, index)">
  138. <view class="uni-input">{{ item.end_time ? timeFormat(item.end_time) : '' }}</view>
  139. </picker>
  140. </view>
  141. <view class="time-operation" v-if="index == 0" @click="addDeliveryTime">添加</view>
  142. <view class="time-operation" v-else @click="deleteDeliveryTime(index)">删除</view>
  143. </view>
  144. </view>
  145. <view class="common-form-item">
  146. <label class="form-label">细分时段</label>
  147. <view class="form-block">
  148. <radio-group @change="timeIntervalChange" class="form-radio-group">
  149. <label class="radio form-radio-item">
  150. <radio value="30" :checked="storeData.time_interval == 30" />
  151. 30分钟
  152. </label>
  153. <label class="radio form-radio-item">
  154. <radio value="60" :checked="storeData.time_interval == 60" />
  155. 一小时
  156. </label>
  157. <label class="radio form-radio-item">
  158. <radio value="90" :checked="storeData.time_interval == 90" />
  159. 90分钟
  160. </label>
  161. <label class="radio form-radio-item">
  162. <radio value="120" :checked="storeData.time_interval == 120" />
  163. 两小时
  164. </label>
  165. </radio-group>
  166. </view>
  167. </view>
  168. <view class="common-form-item">
  169. <label class="form-label">提现预约</label>
  170. <view class="form-block">
  171. <radio-group @change="advanceDayChange" class="form-radio-group">
  172. <label class="radio form-radio-item">
  173. <radio value="0" :checked="storeData.advance_day === 0" />
  174. 无需提前
  175. </label>
  176. <label class="radio form-radio-item">
  177. <radio value="1" :checked="storeData.advance_day !== 0" />
  178. 需提前
  179. <input
  180. type="number"
  181. v-model="storeData.advance_day"
  182. class="radio-input"
  183. :class="{ disabled: storeData.advance_day === 0 }"
  184. :disabled="storeData.advance_day === 0"
  185. />
  186. </label>
  187. </radio-group>
  188. </view>
  189. <text class="form-word-aux-line">预约提货是否需提前进行预约</text>
  190. </view>
  191. <view class="common-form-item">
  192. <label class="form-label">最长预约</label>
  193. <view class="form-block">
  194. <radio-group @change="mostDayChange" class="form-radio-group">
  195. <label class="radio form-radio-item">
  196. <radio value="0" :checked="storeData.most_day === 0" />
  197. 无需提前
  198. </label>
  199. <label class="radio form-radio-item">
  200. <radio value="1" :checked="storeData.most_day !== 0" />
  201. 可预约
  202. <input
  203. type="number"
  204. v-model="storeData.most_day"
  205. class="radio-input"
  206. :class="{ disabled: storeData.most_day === 0 }"
  207. :disabled="storeData.most_day === 0"
  208. />
  209. 天内
  210. </label>
  211. </radio-group>
  212. </view>
  213. <text class="form-word-aux-line">预约提货最长可预约多少天内进行提货</text>
  214. </view>
  215. </block>
  216. <view class="common-form-item">
  217. <label class="form-label">库存设置</label>
  218. <view class="form-inline">
  219. <radio-group @change="stockTypeChange" class="form-radio-group">
  220. <label class="radio form-radio-item">
  221. <radio value="all" :disabled="Boolean(storeData.is_default)" :checked="storeData.stock_type == 'all'" />
  222. 总部统一库存
  223. </label>
  224. <label class="radio form-radio-item">
  225. <radio value="store" :disabled="Boolean(storeData.is_default)" :checked="storeData.stock_type == 'store'" />
  226. 门店独立库存
  227. </label>
  228. </radio-group>
  229. </view>
  230. </view>
  231. <view class="common-btn-wrap">
  232. <button type="default" class="screen-btn" @click="saveFn">保存</button>
  233. <button type="default" @click="$util.redirectTo('/pages/store/index')">返回</button>
  234. </view>
  235. <nc-loading :layer-background="{ background: 'rgba(255,255,255,.8)' }" ref="loading"></nc-loading>
  236. </view>
  237. </base-page>
  238. </template>
  239. <script>
  240. export default {
  241. data() {
  242. return {
  243. storeData: {},
  244. covers: [
  245. {
  246. latitude: 39.909,
  247. longitude: 116.39742,
  248. iconPath: '/static/location.png'
  249. }
  250. ],
  251. defaultRegions: []
  252. };
  253. },
  254. onLoad() {},
  255. onShow() {
  256. this.getData();
  257. },
  258. methods: {
  259. getData() {
  260. this.$api.sendRequest({
  261. url: '/store/storeapi/store/info',
  262. success: res => {
  263. if (res.code >= 0) {
  264. this.storeData = res.data;
  265. this.storeData.start_time = this.timeFormat(this.storeData.start_time);
  266. this.storeData.end_time = this.timeFormat(this.storeData.end_time);
  267. this.$refs.loading.hide();
  268. } else {
  269. this.$util.showToast({
  270. title: res.message
  271. });
  272. }
  273. }
  274. });
  275. },
  276. statusChange(e) {
  277. this.storeData.status = e.detail.value;
  278. },
  279. o2oChange(e) {
  280. this.storeData.is_o2o = e.detail.value;
  281. },
  282. expressChange(e) {
  283. this.storeData.is_express = e.detail.value;
  284. },
  285. pickupChange(e) {
  286. this.storeData.is_pickup = e.detail.value;
  287. },
  288. timeTypeChange(e) {
  289. this.storeData.time_type = e.detail.value;
  290. },
  291. bindStartTimeChange(e, index) {
  292. this.storeData.delivery_time[index].start_time = this.timeTurnTimeStamp(e.detail.value);
  293. },
  294. bindEndTimeChange(e, index) {
  295. this.storeData.delivery_time[index].end_time = this.timeTurnTimeStamp(e.detail.value);
  296. },
  297. stockTypeChange(e) {
  298. this.storeData.stock_type = e.detail.value;
  299. },
  300. timeIntervalChange(e) {
  301. this.storeData.time_interval = e.detail.value;
  302. },
  303. checkboxChange(e) {
  304. this.storeData.time_week = e.detail.value;
  305. },
  306. advanceDayChange(e) {
  307. if (e.detail.value == 1) this.storeData.advance_day = '';
  308. else this.storeData.advance_day = 0;
  309. },
  310. mostDayChange(e) {
  311. if (e.detail.value == 1) this.storeData.most_day = '';
  312. else this.storeData.most_day = 0;
  313. },
  314. getSaveData() {
  315. let data = Object.assign({}, this.storeData);
  316. data.start_time = this.timeTurnTimeStamp(data.start_time);
  317. data.end_time = this.timeTurnTimeStamp(data.end_time);
  318. data.time_week = this.storeData.time_week.toString();
  319. data.advance_day = parseInt(this.storeData.advance_day);
  320. data.most_day = parseInt(this.storeData.most_day);
  321. data.delivery_time = JSON.stringify(this.storeData.delivery_time);
  322. return data;
  323. },
  324. checkData(data) {
  325. if (data.is_pickup) {
  326. let deliveryTimeVerify = true;
  327. for (let i = 0; i < this.storeData.delivery_time.length; i++) {
  328. let time = this.storeData.delivery_time[i];
  329. if (time.start_time == 0) {
  330. this.$util.showToast({ title: '请选择时段开始时间' });
  331. deliveryTimeVerify = false;
  332. break;
  333. }
  334. if (time.end_time == 0) {
  335. this.$util.showToast({ title: '请选择时段结束时间' });
  336. deliveryTimeVerify = false;
  337. break;
  338. }
  339. if (parseInt(time.start_time) > parseInt(time.end_time)) {
  340. this.$util.showToast({ title: '时段结束时间不能小于开始时间' });
  341. deliveryTimeVerify = false;
  342. break;
  343. }
  344. if ((parseInt(time.end_time) - parseInt(time.start_time)) / 60 < parseInt(data.time_interval)) {
  345. this.$util.showToast({ title: '时段时间间隔不能小于' + data.time_interval + '分钟' });
  346. deliveryTimeVerify = false;
  347. break;
  348. }
  349. }
  350. if (!deliveryTimeVerify) return deliveryTimeVerify;
  351. if (isNaN(data.advance_day)) {
  352. this.$util.showToast({
  353. title: '提前预约时间格式错误'
  354. });
  355. return false;
  356. }
  357. if (data.advance_day < 0) {
  358. this.$util.showToast({
  359. title: '提前预约时间不能为负数'
  360. });
  361. return false;
  362. }
  363. if (isNaN(data.most_day)) {
  364. this.$util.showToast({
  365. title: '最长可预约时间格式错误'
  366. });
  367. return false;
  368. }
  369. if (data.most_day < 0) {
  370. this.$util.showToast({
  371. title: '最长可预约时间不能为负数'
  372. });
  373. return false;
  374. }
  375. if (data.most_day > 15) {
  376. this.$util.showToast({
  377. title: '最长可预约时间不能超过15天'
  378. });
  379. return false;
  380. }
  381. }
  382. return true;
  383. },
  384. saveFn() {
  385. let data = this.getSaveData();
  386. if (this.checkData(data)) {
  387. if (this.flag) return false;
  388. this.flag = true;
  389. this.$api.sendRequest({
  390. url: '/store/storeapi/store/edit',
  391. data: data,
  392. success: res => {
  393. this.flag = false;
  394. this.$util.showToast({
  395. title: res.message
  396. });
  397. if (res.code >= 0) {
  398. this.$refs.loading.show();
  399. this.getData();
  400. }
  401. }
  402. });
  403. }
  404. },
  405. timeTurnTimeStamp(_time) {
  406. let data = _time.split(':');
  407. return data[0] * 3600 + data[1] * 60;
  408. },
  409. timeFormat(time) {
  410. let h = parseInt(time / 3600);
  411. let i = parseInt((time % 3600) / 60);
  412. h = h < 10 ? '0' + h : h;
  413. i = i < 10 ? '0' + i : i;
  414. return h + ':' + i;
  415. },
  416. addDeliveryTime() {
  417. if (this.storeData.delivery_time.length >= 3) {
  418. this.$util.showToast({
  419. title: '最多添加三个时段'
  420. });
  421. return false;
  422. }
  423. this.storeData.delivery_time.push({ start_time: 0, end_time: 0 });
  424. },
  425. deleteDeliveryTime(index) {
  426. this.storeData.delivery_time.splice(index, 1);
  427. }
  428. }
  429. };
  430. </script>
  431. <style lang="scss">
  432. .common-wrap {
  433. padding: 30rpx;
  434. height: 100vh;
  435. overflow-y: auto;
  436. }
  437. .upload-box {
  438. border: 0.01rem dashed #e6e6e6 !important;
  439. width: 2.5rem !important;
  440. height: 1.2rem !important;
  441. display: flex;
  442. align-items: center;
  443. justify-content: center;
  444. .upload {
  445. text-align: center;
  446. color: #5a5a5a;
  447. .iconfont {
  448. font-size: 0.3rem;
  449. }
  450. image {
  451. max-width: 100%;
  452. height: 1.2rem !important;
  453. }
  454. }
  455. }
  456. .store-img {
  457. align-items: flex-start !important;
  458. }
  459. .map-box {
  460. width: 6.5rem;
  461. height: 5rem;
  462. position: relative;
  463. .map-icon {
  464. position: absolute;
  465. top: calc(50% - 0.36rem);
  466. left: calc(50% - 0.18rem);
  467. width: 0.36rem;
  468. height: 0.36rem;
  469. z-index: 100;
  470. }
  471. }
  472. .form-input {
  473. font-size: 0.16rem;
  474. }
  475. .form-input-inline.btn {
  476. height: 0.37rem;
  477. line-height: 0.35rem;
  478. box-sizing: border-box;
  479. border: 0.01rem solid #e6e6e6;
  480. text-align: center;
  481. cursor: pointer;
  482. }
  483. .common-title {
  484. font-size: 0.18rem;
  485. margin-bottom: 0.2rem;
  486. }
  487. .radio-input {
  488. width: 0.6rem;
  489. height: 0.35rem;
  490. line-height: 0.35rem;
  491. padding: 0 0.1rem;
  492. margin: 0 0.1rem;
  493. border: 0.01rem solid #eee;
  494. &.disabled {
  495. background: #f5f5f5;
  496. }
  497. }
  498. .time-operation {
  499. color: $primary-color;
  500. cursor: pointer;
  501. }
  502. </style>