free-delivery.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <template>
  2. <view class="distribution-page">
  3. <scroll-view scroll-y class="scroll-content">
  4. <view class="title">配送费设置</view>
  5. <view class="form-item">
  6. <view class="label flex-center">是否免配送费</view>
  7. <view class="value flex-start">
  8. <switch :checked="freeDeliveryFeeFlag" @change="changeDeliveryfeeFlag" size="22" class="switch" style="transform:scale(0.7)"></switch>
  9. </view>
  10. </view>
  11. </scroll-view>
  12. <view class="footer-btn">
  13. <view class="save" @click="updateFreeDeliveryFeeFlag">保存</view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. import { mapState } from 'vuex';
  19. export default {
  20. data () {
  21. return {
  22. newDiscountsUrl: '/storeInfoManageApi/getStoreFreeDeliveryFlg',
  23. updateUrl: '/storeInfoManageApi/updateStoreFreeDeliveryFlg',
  24. freeDeliveryFeeFlag: 0
  25. }
  26. },
  27. computed: {
  28. ...mapState(['storeInfo'])
  29. },
  30. methods: {
  31. loadData () {
  32. uni.showLoading({
  33. title: '加载中'
  34. });
  35. var dateStr = (new Date()).getTime();
  36. var sign = this.getSign('' + this.storeInfo.storeId + dateStr);
  37. this.requst({
  38. url: this.newDiscountsUrl,
  39. data: {
  40. timestamp: dateStr,
  41. sign: sign,
  42. storeId: this.storeInfo.storeId
  43. },
  44. success: res => {
  45. this.freeDeliveryFeeFlag = res.data.obj;
  46. uni.hideLoading();
  47. },
  48. fail: (e) => {
  49. console.log("接口调用失败:" + JSON.stringify(e));
  50. uni.hideLoading();
  51. },
  52. })
  53. },
  54. changeDeliveryfeeFlag (e) {
  55. if (e.detail.value){
  56. this.freeDeliveryFeeFlag = 1
  57. } else {
  58. this.freeDeliveryFeeFlag = 0
  59. }
  60. },
  61. updateFreeDeliveryFeeFlag () {
  62. uni.showLoading({
  63. title: '保存中'
  64. });
  65. var dateStr = (new Date()).getTime();
  66. var sign = this.getSign('' + this.storeInfo.storeId + dateStr);
  67. this.requst({
  68. url: this.updateUrl,
  69. data: {
  70. timestamp: dateStr,
  71. sign: sign,
  72. storeId: this.storeInfo.storeId,
  73. flg: this.freeDeliveryFeeFlag
  74. },
  75. success:res => {
  76. if (res.data.rtnBean.rtnCode == 0) {
  77. uni.hideLoading();
  78. uni.showToast({
  79. title: "保存成功",
  80. duration: 3000,
  81. icon: 'none',
  82. });
  83. this.loadData();
  84. } else {
  85. uni.hideLoading();
  86. if (res.data.rtnBean.rtnMsg != '') {
  87. this.$api.msg(res.data.rtnBean.rtnMsg);
  88. }
  89. }
  90. },
  91. fail: (e) => {
  92. console.log("接口调用失败:" + JSON.stringify(e));
  93. uni.hideLoading();
  94. },
  95. });
  96. },
  97. updateNewDiscounts () {
  98. let regPrice = (/^[0-9]\d*(,\d{3})*(\.\d{1,2})?$|^0\.\d{1,2}$/);
  99. if (this.newDiscounts == '' || this.newDiscounts == null) {
  100. this.$api.msg("立减金额不能为空");
  101. return;
  102. }
  103. if (!regPrice.test(this.newDiscounts)) {
  104. this.$api.msg("价格只能是整数或小数点后两位");
  105. return;
  106. }
  107. }
  108. },
  109. onShow () {
  110. },
  111. onLoad () {
  112. this.loadData()
  113. }
  114. }
  115. </script>
  116. <style lang="scss" scoped>
  117. .distribution-page {
  118. height: 100vh;
  119. background-color: #f5f5f5;
  120. }
  121. .scroll-content {
  122. height: calc(100vh - 120rpx - env(safe-area-inset-bottom));
  123. height: calc(100vh - 120rpx - constant(safe-area-inset-bottom));
  124. }
  125. .title {
  126. font-size: 36rpx;
  127. color: $title-color;
  128. margin: 24rpx 0 16rpx;
  129. padding: 0 20rpx;
  130. }
  131. .form-item {
  132. background-color: #fff;
  133. @include flexStart(flex-start);
  134. padding: 20rpx 60rpx;
  135. box-sizing: border-box;
  136. .label {
  137. margin-right: 20rpx;
  138. margin-top: 20rpx;
  139. font-size: $font-base;
  140. color: $text-color;
  141. width: 180rpx;
  142. }
  143. .label.flex-center {
  144. margin-top: 6rpx;
  145. }
  146. .desc {
  147. font-size: $font-sm;
  148. color: $uni-color-button;
  149. }
  150. .flex-start {
  151. @include flexStart;
  152. .desc {
  153. margin-left: 20rpx;
  154. color: $text-color;
  155. }
  156. }
  157. }
  158. .form-item.pb0 {
  159. padding-bottom: 0;
  160. }
  161. .form-item.flex-center {
  162. @include flexStart(center);
  163. .label {
  164. margin-top: 0;
  165. }
  166. .btn {
  167. font-size: $font-base;
  168. color: #fff;
  169. background-color: $theme-color;
  170. @include flexCenter;
  171. padding: 6rpx 20rpx;
  172. border-radius: 10rpx;
  173. }
  174. .deliveryman {
  175. height: 52rpx;
  176. @include flexStart;
  177. font-size: $font-base;
  178. color: $text-color;
  179. }
  180. .del {
  181. color: $uni-color-button;
  182. margin-left: 20rpx;
  183. }
  184. }
  185. /deep/ .u-radio {
  186. margin-right: 50rpx;
  187. }
  188. .footer-btn {
  189. width: 100vw;
  190. margin-top: 40rpx;
  191. .save {
  192. margin: 0 10vw;
  193. width: 80vw;
  194. height: 80rpx;
  195. border-radius: 40rpx;
  196. background-color: $theme-color;
  197. color: #fff;
  198. @include flexCenter;
  199. }
  200. }
  201. </style>