distribution.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <template>
  2. <view class="distribution-page">
  3. <view class="scroll-content">
  4. <view class="title">自取设置</view>
  5. <view class="form-item pb0">
  6. <view class="label flex-center">是否开启自取</view>
  7. <view class="value flex-start">
  8. <switch :checked="form.pickupStatus" disabled="true" size="22" class="switch" style="transform:scale(0.7)"></switch>
  9. <text class="desc">若需修改请联系运营方</text>
  10. </view>
  11. </view>
  12. <view class="form-item pb0">
  13. <view class="label flex-center">是否开启堂食</view>
  14. <view class="value flex-start">
  15. <switch :checked="form.dineStatus" disabled="true" size="22" class="switch" style="transform:scale(0.7)"></switch>
  16. <text class="desc">若需修改请联系运营方</text>
  17. </view>
  18. </view>
  19. <view class="title">外卖设置</view>
  20. <view class="form-item pb0">
  21. <view class="label flex-center">是否开启外卖</view>
  22. <view class="value flex-start">
  23. <switch :checked="form.takeoutStatus" disabled="true" @change="changeTakeoutStatus" size="22" class="switch" style="transform:scale(0.7)"></switch>
  24. <text class="desc">若需修改请联系运营方</text>
  25. </view>
  26. </view>
  27. <view class="form-item flex-center mr10-0" v-if="form.takeoutStatus == 1">
  28. <view class="label">配送方式</view>
  29. <view class="value">
  30. <view style="font-size: 26rpx;">
  31. {{form.deliveryType == 0 ? "自配送" : "平台配送"}}
  32. </view>
  33. <!-- <u-radio-group v-model="form.deliveryType" activeColor="#04be02" disabled="true" placement="row">
  34. <u-radio label="平台配送" :name="1"></u-radio>
  35. <u-radio label="自配送" :name="0"></u-radio>
  36. </u-radio-group> -->
  37. </view>
  38. </view>
  39. <view class="form-item flex-center mt10" v-if="form.deliveryType == 0">
  40. <view class="label">专属配送员</view>
  41. <view class="value">
  42. <view class="btn" @click="handSettingClerk">配置专属配送员</view>
  43. </view>
  44. </view>
  45. </view>
  46. <!-- <view class="footer-btn">
  47. <view class="save" @click="handSave">保存</view>
  48. </view> -->
  49. </view>
  50. </template>
  51. <script>
  52. import { mapState } from 'vuex';
  53. export default {
  54. data () {
  55. return {
  56. deliveryUrl: '/storeDeliveryManageApi/getDeliveryInfo',
  57. updateUrl: '/storeDeliveryManageApi/update',
  58. form: {
  59. pickupStatus: '',
  60. takeoutStatus: '',
  61. deliveryType: 1,
  62. riderId: '',
  63. riderName: '',
  64. telNo: '',
  65. }
  66. }
  67. },
  68. computed: {
  69. ...mapState(['storeInfo'])
  70. },
  71. methods: {
  72. loadData () {
  73. uni.showLoading({
  74. title: '加载中'
  75. });
  76. var dateStr = (new Date()).getTime();
  77. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  78. this.requst({
  79. url: this.deliveryUrl,
  80. data: {
  81. timestamp: dateStr,
  82. sign: sign,
  83. storeId: this.storeInfo.storeId,
  84. storeUserId: this.storeInfo.storeUserId
  85. },
  86. success: res => {
  87. if (res.data.rtnBean.rtnCode == 0) {
  88. this.form = res.data.obj;
  89. console.log('this.form :>> ', this.form);
  90. }
  91. uni.hideLoading();
  92. },
  93. fail: (e) => {
  94. console.log("接口调用失败:" + JSON.stringify(e));
  95. uni.hideLoading();
  96. }
  97. })
  98. },
  99. handSettingClerk () {
  100. uni.navigateTo({
  101. url: `/pages/store/deliveryman`
  102. });
  103. },
  104. deleteDeliveryman () {
  105. this.form.deliverymanName = ''
  106. this.form.deliverymanPhone = ''
  107. this.form.deliverymanId = ''
  108. },
  109. changeTakeoutStatus (e) {
  110. this.form.takeoutStatus = e.detail.value
  111. },
  112. handSave () {
  113. console.log('save', this.form);
  114. if (this.form.takeoutStatus == null || this.form.takeoutStatus == undefined) {
  115. uni.showToast({
  116. title: '请选择是否开启外卖',
  117. icon: 'none'
  118. })
  119. return
  120. }
  121. if (this.form.pickupStatus == 0 && this.form.takeoutStatus == 0 ) {
  122. uni.showToast({
  123. title: '外卖和自取不可以同时关闭',
  124. icon: 'none'
  125. })
  126. return
  127. }
  128. uni.showLoading({
  129. title: '加载中'
  130. });
  131. var dateStr = (new Date()).getTime();
  132. var sign = this.getSign('' + this.storeInfo.storeUserId + dateStr);
  133. this.requst({
  134. url: this.updateUrl,
  135. data: {
  136. timestamp: dateStr,
  137. sign: sign,
  138. storeId: this.storeInfo.storeId,
  139. storeUserId: this.storeInfo.storeUserId,
  140. takeoutStatus: this.form.takeoutStatus ? 1 : 0,
  141. deliveryType: this.form.deliveryType
  142. },
  143. success: res => {
  144. uni.hideLoading();
  145. if (res.data.rtnBean.rtnCode == 0) {
  146. uni.showToast({
  147. title: '保存成功',
  148. icon: 'none'
  149. })
  150. this.form = {
  151. pickupStatus: '',
  152. takeoutStatus: '',
  153. deliveryType: '',
  154. riderId: '',
  155. riderName: '',
  156. telNo: ''
  157. }
  158. this.loadData()
  159. }
  160. },
  161. fail: (e) => {
  162. console.log("接口调用失败:" + JSON.stringify(e));
  163. uni.hideLoading();
  164. }
  165. })
  166. },
  167. takeawayTimeInput (e,val){
  168. // 只能输入数字
  169. const inputType = /[^\d]/g
  170. this.$nextTick(function () {
  171. this.form.takeawayTime = e.replace(inputType,'');
  172. })
  173. },
  174. pickupTimeInput (e,val) {
  175. // 只能输入数字
  176. const inputType = /[^\d]/g
  177. this.$nextTick(function () {
  178. this.form.pickupTime = e.replace(inputType,'');
  179. })
  180. }
  181. },
  182. onShow () {
  183. },
  184. onLoad () {
  185. this.loadData()
  186. }
  187. }
  188. </script>
  189. <style lang="scss" scoped>
  190. .distribution-page {
  191. height: 95vh;
  192. background-color: #f5f5f5;
  193. }
  194. .scroll-content {
  195. height: calc(100vh - 120rpx - env(safe-area-inset-bottom));
  196. height: calc(100vh - 120rpx - constant(safe-area-inset-bottom));
  197. }
  198. .title {
  199. font-size: 36rpx;
  200. color: $title-color;
  201. margin: 24rpx 0 16rpx;
  202. padding: 0 20rpx;
  203. }
  204. .form-item {
  205. background-color: #fff;
  206. @include flexStart(flex-start);
  207. padding: 20rpx 60rpx;
  208. box-sizing: border-box;
  209. .label {
  210. margin-right: 20rpx;
  211. margin-top: 20rpx;
  212. font-size: $font-base;
  213. color: $text-color;
  214. width: 180rpx;
  215. }
  216. .label.flex-center {
  217. margin-top: 6rpx;
  218. }
  219. .desc {
  220. font-size: $font-sm;
  221. color: $uni-color-button;
  222. }
  223. .flex-start {
  224. @include flexStart;
  225. .desc {
  226. margin-left: 20rpx;
  227. color: $text-color;
  228. }
  229. }
  230. }
  231. .form-item.pb0 {
  232. padding-bottom: 0;
  233. }
  234. .form-item.flex-center {
  235. @include flexStart(center);
  236. .label {
  237. margin-top: 0;
  238. }
  239. .btn {
  240. font-size: $font-base;
  241. color: #fff;
  242. background-color: $theme-color;
  243. @include flexCenter;
  244. padding: 6rpx 20rpx;
  245. border-radius: 10rpx;
  246. }
  247. .deliveryman {
  248. height: 52rpx;
  249. @include flexStart;
  250. font-size: $font-base;
  251. color: $text-color;
  252. }
  253. .del {
  254. color: $uni-color-button;
  255. margin-left: 20rpx;
  256. }
  257. }
  258. /deep/ .u-radio {
  259. margin-right: 50rpx;
  260. }
  261. .footer-btn {
  262. width: 100vw;
  263. margin-top: 40rpx;
  264. .save {
  265. margin: 0 10vw;
  266. width: 80vw;
  267. height: 80rpx;
  268. border-radius: 40rpx;
  269. background-color: $theme-color;
  270. color: #fff;
  271. @include flexCenter;
  272. }
  273. }
  274. </style>