new-customer.vue 4.6 KB

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