setup-add.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <view class="container">
  3. <form @submit="onSubmit">
  4. <view class="page-block">
  5. <view class="content">
  6. <view class="cell flex flex-y-center">
  7. <view class="title-block required">
  8. <text>充值名称</text>
  9. </view>
  10. <view class="desc">
  11. <input type="num" :value="obj.name" name="name" class="input-box"
  12. placeholder="请输入充值名称" placeholder-class="desc-placeholder">
  13. </view>
  14. </view>
  15. <view class="cell flex flex-y-center">
  16. <view class="title-block required">
  17. <text>支付金额</text>
  18. </view>
  19. <view class="desc">
  20. <input type="num" :value="obj.pay_price" name="pay_price" class="input-box"
  21. placeholder="用户支付多少就充值多少" placeholder-class="desc-placeholder">
  22. </view>
  23. </view>
  24. <view class="cell flex flex-y-center">
  25. <view class="title-block required">
  26. <text>赠送金额</text>
  27. </view>
  28. <view class="desc">
  29. <input type="num" :value="obj.send_price" name="send_price" class="input-box"
  30. placeholder="用户充值时,赠送的金额,默认为0" placeholder-class="desc-placeholder">
  31. </view>
  32. </view>
  33. <view class="cell flex flex-y-center">
  34. <view class="title-block requsired">
  35. <text>排序</text>
  36. </view>
  37. <view class="desc">
  38. <input type="num" :value="obj.num" class="input-box" placeholder="请输入"
  39. placeholder-class="desc-placeholder">
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="footer-bar">
  45. <view class="content flex flex-center" style="background: none;">
  46. <button class="btn" hover-class="none" form-type="submit">
  47. {{obj.id?'修改':'添加'}}
  48. </button>
  49. </view>
  50. </view>
  51. </form>
  52. </view>
  53. </template>
  54. <script>
  55. export default {
  56. data() {
  57. return {
  58. is_integral:0,
  59. device_type: 1,
  60. tableType: "",
  61. store_id: "",
  62. info: {},
  63. obj:{},
  64. }
  65. },
  66. onLoad(e) {
  67. if (e.id) {
  68. this.info = e;
  69. this.http();
  70. uni.setNavigationBarTitle({
  71. title:"修改充值方案"
  72. })
  73. }
  74. this.admin_id = uni.getStorageSync("admin_id");
  75. },
  76. methods: {
  77. http(){
  78. this.request({
  79. url:"Smdcshop/recharge_info",
  80. data: {
  81. id:this.info.id,
  82. }
  83. }).then(res => {
  84. if (res.code == 200) {
  85. this.obj=res.data;
  86. }
  87. }).catch((res) => {
  88. uni.showToast({
  89. title: res.message,
  90. icon: 'none'
  91. })
  92. });
  93. },
  94. onSubmit(e) {
  95. let params = e.detail.value,
  96. url;
  97. params.admin_id=this.admin_id;
  98. if (this.info.id) {
  99. params.id = this.info.id
  100. url = "Smdcshop/recharge_update"
  101. } else {
  102. url = 'Smdcshop/recharge_add'
  103. }
  104. if (params.name == "") {
  105. uni.showToast({
  106. title: "请输入名称",
  107. icon: 'none'
  108. })
  109. return false
  110. }
  111. this.request({
  112. url,
  113. data: params
  114. }).then(res => {
  115. if (res.code == 200) {
  116. uni.showToast({
  117. title: res.message,
  118. icon: 'none'
  119. })
  120. setTimeout(() => {
  121. uni.navigateBack()
  122. }, 2000)
  123. }
  124. }).catch((res) => {
  125. uni.showToast({
  126. title: res.message,
  127. icon: 'none'
  128. })
  129. });
  130. },
  131. }
  132. }
  133. </script>
  134. <style>
  135. @import url("../static/css/common.css");
  136. page {
  137. background-color: #F4F5F7;
  138. }
  139. </style>