grads.blade.php 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. @extends('layouts.base')
  2. @section('content')
  3. <style scoped>
  4. .all {
  5. color: #101010;
  6. font-size: 14px;
  7. margin-bottom: 80px;
  8. }
  9. .ladder {
  10. display: flex;
  11. flex-wrap: wrap;
  12. align-items: center;
  13. width: 600px;
  14. margin: 20px 0 20px 236px;
  15. }
  16. .tips{
  17. width: 100%;
  18. font-size: 13px;
  19. color: #666;
  20. margin: 6px 0 0 64px;
  21. }
  22. .ladder .text {
  23. margin-right: 10px;
  24. }
  25. .grads {
  26. width: 600px;
  27. margin-left: 140px;
  28. }
  29. .grads .title {
  30. display: flex;
  31. text-align: center;
  32. padding: 10px 0;
  33. border-bottom: 1px solid #C9C9C9;
  34. }
  35. .grads .title div {
  36. width: 50%;
  37. }
  38. .list .list-item {
  39. display: flex;
  40. width: 100%;
  41. margin: 20px 0;
  42. align-items: center;
  43. }
  44. .list .list-item .el-icon-delete-solid {
  45. font-size: 20px;
  46. color: #666;
  47. }
  48. .list .list-item div {
  49. width: 50%;
  50. display: flex;
  51. justify-content: center;
  52. align-items: center;
  53. }
  54. .list .list-item .el-input {
  55. width: 80px;
  56. }
  57. .list .list-item .line {
  58. width: 20px;
  59. height: 1px;
  60. background-color: #ccc;
  61. margin: 0 4px;
  62. }
  63. .push {
  64. display: flex;
  65. align-items: center;
  66. margin: 20px 0 20px 50px;
  67. }
  68. .push .text {
  69. color: #666;
  70. margin-left: 20px;
  71. }
  72. .fixed {
  73. width: calc(100% - 250px);
  74. padding: 7px;
  75. padding-top: 10px;
  76. position: fixed;
  77. bottom: 0px;
  78. z-index: 199;
  79. box-sizing: border-box;
  80. box-shadow: 0px -1px 10px rgb(0 0 0 / 10%);
  81. margin-left: -14px;
  82. background-color: #fff;
  83. }
  84. .fixed_box {
  85. height: 60px;
  86. display: flex;
  87. justify-content: center;
  88. align-items: center;
  89. }
  90. </style>
  91. @include('public.admin.box-item')
  92. <div class="all">
  93. <div id="app">
  94. <box-item text="梯度设置">
  95. <div class="ladder">
  96. <div class="text">红包阶梯</div>
  97. <el-switch v-model="is_grads" active-color="#39b283" inactive-color="#ccc" :active-value="1" :inactive-value="0" @change="change"></el-switch>
  98. <div class="tips">1,请勿随意关闭更改红包阶梯,以免造成红包金额混乱;</div>
  99. <div class="tips">2,额度范围后设置后第二天才生效,请勿随意更改;</div>
  100. <div class="tips">3,不在额度范围里的会员领取随机生成的红包;</div>
  101. <div class="tips">4,若额度范围内的红包数量已领取完,则剩下的人随机领取红包;</div>
  102. <div class="tips">5,在额度范围内领取的红包金额不随基础设置的奖励金额和红包最高金额限制;</div>
  103. <div class="tips">6,会员领取的红包是根据当前的梯度设置进行查询,如果前一天的设置是有梯度1-100元的,后面用户领取的时候该梯度改成了1-99元,视为更改过设置,领取随机红包。</div>
  104. </div>
  105. <div class="grads" v-show="is_grads=='1'">
  106. <div class="title">
  107. <div>个人红包额度范围</div>
  108. <div>领取红包额度范围</div>
  109. </div>
  110. <div class="list">
  111. <div class="list-item" v-for="(item,i) in grads" :key="i">
  112. <div>
  113. <el-input v-model="item.quota[0]" placeholder="最小值"></el-input>
  114. <div class="line"></div>
  115. <el-input v-model="item.quota[1]" placeholder="最大值"></el-input>
  116. </div>
  117. <div>
  118. <el-input v-model="item.amount[0]" placeholder="最小值"></el-input>
  119. <div class="line"></div>
  120. <el-input v-model="item.amount[1]" placeholder="最大值"></el-input>
  121. </div>
  122. <i @click="grads.splice(i,1)" class="el-icon-delete-solid" v-if="i>0" style="font-size: 20px;color: #666;"></i>
  123. <i class="el-icon-delete-solid" v-else style="opacity: 0;"></i>
  124. </div>
  125. </div>
  126. <div class="push">
  127. <el-button type="primary" icon="el-icon-plus" @click="push">添加阶梯</el-button>
  128. <div class="text">梯度最多只能添加到20层</div>
  129. </div>
  130. </div>
  131. </box-item>
  132. <div class="fixed">
  133. <div class="fixed_box">
  134. <el-button type="primary" @click="Submit">提交</el-button>
  135. </div>
  136. </div>
  137. </div>
  138. </div>
  139. <script>
  140. const vm = new Vue({
  141. el: "#app",
  142. delimiters: ['[[', ']]'],
  143. data() {
  144. return {
  145. is_grads: "",
  146. grads: [{
  147. quota: ["",""],
  148. amount: ["",""]
  149. }]
  150. }
  151. },
  152. created() {
  153. this.getData();
  154. },
  155. methods: {
  156. initData(list, type = "split") {
  157. let grads = [];
  158. list.forEach(item => {
  159. grads.push({
  160. quota: item.quota[type]("_"),
  161. amount: item.amount[type]("_")
  162. })
  163. })
  164. return grads;
  165. },
  166. getData() {
  167. this.$http.post("{!! yzWebUrl('plugin.red-packet.admin.set.gradsSave') !!}").then(({
  168. data
  169. }) => {
  170. if (data.result == 1) {
  171. this.is_grads = data.data.is_grads;
  172. this.grads = this.initData(data.data.grads, "split");
  173. } else this.$message.error(data.msg);
  174. })
  175. },
  176. push() {
  177. if (this.grads.length >= 20) {
  178. this.$message.error('梯度最多只能添加到20层');
  179. return false
  180. }
  181. this.grads.push({
  182. quota: ["",""],
  183. amount: ["",""]
  184. })
  185. },
  186. Submit() {
  187. for (let index = 0; index < this.grads.length; index++) {
  188. let { quota,amount} = this.grads[index],bool = false;
  189. for(let j = 0;j<quota.length;j++){
  190. if (quota[j]=="" || amount[j]=="") {
  191. bool = true;
  192. this.$message.error("红包额度范围不能为空");
  193. return false;
  194. }else if(isNaN(quota[j]) || isNaN(amount[j])){
  195. bool = true;
  196. this.$message.error("红包额度范围只能为数字");
  197. return false;
  198. }
  199. }
  200. if (quota[0] * 1>quota[1] *1 || amount[0] * 1>amount[1] * 1) return this.$message.error("红包额度最小值不能大于最大值");
  201. if(bool) return fasle;
  202. }
  203. const loading = this.$loading({
  204. lock: true,
  205. text: '正在保存中...',
  206. spinner: 'el-icon-loading',
  207. background: 'rgba(0, 0, 0, 0.7)'
  208. });
  209. let data = {
  210. is_grads: this.is_grads,
  211. grads: this.initData(this.grads, "join"),
  212. }
  213. this.$http.post("{!! yzWebUrl('plugin.red-packet.admin.set.gradsSave') !!}", {
  214. data
  215. }).then(({
  216. data
  217. }) => {
  218. loading.close();
  219. this.$message[data.result == 1 ? "success" : "error"](data.msg)
  220. });
  221. },
  222. change(val){
  223. if (val==0) {
  224. this.is_grads = 1;
  225. this.$confirm('是否确定关闭红包阶梯,关闭后将不再发放红包阶梯的红包金额,只发放原来设置的红包金额。', '提示', {
  226. confirmButtonText: '确定',
  227. cancelButtonText: '取消',
  228. type: 'warning'
  229. }).then(() => {
  230. this.is_grads = 0;
  231. }).catch(() => {
  232. });
  233. }
  234. }
  235. }
  236. })
  237. </script>
  238. @endsection