vip_setting.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <div id="vip-setting">
  3. <el-button
  4. v-for="(title, i) of titles"
  5. :key="i"
  6. :type="i === currentIndex ? 'primary' : 'button'"
  7. @click="clickTitle(i)"
  8. >{{title}}</el-button>
  9. <el-form style="padding-top: 1%" v-if="shows" :model="ruleForm" :rules="rules" ref="ruleForm">
  10. <h3>会员定价</h3>
  11. <el-form-item label="统一" prop="job_reduction_rate">
  12. <h4>月付</h4>
  13. <el-form-item label="原价" prop="monthly_origin_price">
  14. <el-input v-model="ruleForm.monthly_origin_price"></el-input>
  15. </el-form-item>
  16. <el-form-item label="现价" prop="monthly_real_price">
  17. <el-input v-model="ruleForm.monthly_real_price"></el-input>
  18. </el-form-item>
  19. <el-form-item prop="can_buy_monthly">
  20. <el-checkbox label="支持购买" v-model="ruleForm.can_buy_monthly"></el-checkbox>
  21. </el-form-item>
  22. <h4>季付</h4>
  23. <el-form-item label="原价" prop="quarterly_origin_price">
  24. <el-input v-model="ruleForm.quarterly_origin_price"></el-input>
  25. </el-form-item>
  26. <el-form-item label="现价" prop="quarterly_real_price">
  27. <el-input v-model="ruleForm.quarterly_real_price"></el-input>
  28. </el-form-item>
  29. <el-form-item prop="can_buy_quarterly">
  30. <el-checkbox label="支持购买" v-model="ruleForm.can_buy_quarterly"></el-checkbox>
  31. </el-form-item>
  32. <h4>半年</h4>
  33. <el-form-item label="原价" prop="half_yearly_origin_price">
  34. <el-input v-model="ruleForm.half_yearly_origin_price"></el-input>
  35. </el-form-item>
  36. <el-form-item label="现价" prop="half_yearly_real_price">
  37. <el-input v-model="ruleForm.half_yearly_real_price"></el-input>
  38. </el-form-item>
  39. <el-form-item prop="can_buy_half_yearly">
  40. <el-checkbox label="支持购买" v-model="ruleForm.can_buy_half_yearly"></el-checkbox>
  41. </el-form-item>
  42. <h4>年付</h4>
  43. <el-form-item label="原价" prop="yearly_origin_price">
  44. <el-input v-model="ruleForm.yearly_origin_price"></el-input>
  45. </el-form-item>
  46. <el-form-item label="现价" prop="yearly_real_price">
  47. <el-input v-model="ruleForm.yearly_real_price"></el-input>
  48. </el-form-item>
  49. <el-form-item prop="can_buy_yearly">
  50. <el-checkbox label="支持购买" v-model="ruleForm.can_buy_yearly"></el-checkbox>
  51. </el-form-item>
  52. </el-form-item>
  53. <el-form-item label="iOS" prop="job_reduction_rate">
  54. <h4>月付</h4>
  55. <el-form-item label="原价" prop="apple_monthly_origin_price">
  56. <el-input v-model="ruleForm.apple_monthly_origin_price"></el-input>
  57. </el-form-item>
  58. <el-form-item label="现价" prop="apple_monthly_real_price">
  59. <el-input v-model="ruleForm.apple_monthly_real_price"></el-input>
  60. </el-form-item>
  61. <el-form-item prop="can_buy_monthly">
  62. <el-checkbox label="支持购买" v-model="ruleForm.can_buy_monthly"></el-checkbox>
  63. </el-form-item>
  64. <h4>季付</h4>
  65. <el-form-item label="原价" prop="apple_quarterly_origin_price">
  66. <el-input v-model="ruleForm.apple_quarterly_origin_price"></el-input>
  67. </el-form-item>
  68. <el-form-item label="现价" prop="quarterly_real_price">
  69. <el-input v-model="ruleForm.apple_quarterly_real_price"></el-input>
  70. </el-form-item>
  71. <el-form-item prop="can_buy_quarterly">
  72. <el-checkbox label="支持购买" v-model="ruleForm.can_buy_quarterly"></el-checkbox>
  73. </el-form-item>
  74. <h4>半年</h4>
  75. <el-form-item label="原价" prop="apple_half_yearly_origin_price">
  76. <el-input v-model="ruleForm.apple_half_yearly_origin_price"></el-input>
  77. </el-form-item>
  78. <el-form-item label="现价" prop="half_yearly_real_price">
  79. <el-input v-model="ruleForm.apple_half_yearly_real_price"></el-input>
  80. </el-form-item>
  81. <el-form-item prop="can_buy_half_yearly">
  82. <el-checkbox label="支持购买" v-model="ruleForm.can_buy_half_yearly"></el-checkbox>
  83. </el-form-item>
  84. <h4>年付</h4>
  85. <el-form-item label="原价" prop="apple_yearly_origin_price">
  86. <el-input v-model="ruleForm.apple_yearly_origin_price"></el-input>
  87. </el-form-item>
  88. <el-form-item label="现价" prop="apple_yearly_real_price">
  89. <el-input v-model="ruleForm.apple_yearly_real_price"></el-input>
  90. </el-form-item>
  91. <el-form-item prop="can_buy_yearly">
  92. <el-checkbox label="支持购买" v-model="ruleForm.can_buy_yearly"></el-checkbox>
  93. </el-form-item>
  94. </el-form-item>
  95. <h3>权益设置</h3>
  96. <el-form v-if="ruleForm.id==2">
  97. <el-form-item :label="ruleForm.name+rights1" prop="accept_times">
  98. <el-input style="width: 30%" v-model="ruleForm.accept_times"></el-input>次
  99. </el-form-item>
  100. <br />
  101. <el-form-item :label="ruleForm.name+rights2" prop="accept_count">
  102. <el-input style="width: 30%" v-model="ruleForm.accept_count"></el-input>个
  103. </el-form-item>
  104. </el-form>
  105. <el-form v-else>
  106. <el-form-item :label="ruleForm.name+rights1" prop="chat_times">
  107. <el-input style="width: 30%" v-model="ruleForm.chat_times"></el-input>次
  108. </el-form-item>
  109. <br />
  110. <el-form-item :label="ruleForm.name+rights2" prop="hire_times">
  111. <el-input style="width: 30%" v-model="ruleForm.hire_times"></el-input>个
  112. </el-form-item>
  113. </el-form>
  114. <el-form-item :label="ruleForm.name+'整包减免费率'" prop="project_reduction_rate">
  115. &#12288;<el-input style="width: 30%" v-model="ruleForm.project_reduction_rate"></el-input>%
  116. </el-form-item>
  117. <br />
  118. <el-form-item :label="ruleForm.name+'云端减免费率'" prop="job_reduction_rate">
  119. &#12288;<el-input style="width: 30%" v-model="ruleForm.job_reduction_rate"></el-input>%
  120. </el-form-item>
  121. <br />
  122. <el-form-item>
  123. <el-button type="primary" @click="submitForm('ruleForm')">保存</el-button>
  124. </el-form-item>
  125. </el-form>
  126. <el-form v-else="shows" :model="ruleForm" ref="commonRights">
  127. <h3 style="padding-top: 1%;">普通开发者用户权益设置</h3>
  128. <el-form-item style="padding: 4%">
  129. <el-form-item label="普通用户每月可接单次数" prop="project_reduction_rate">
  130. <el-input style="width: 30%" v-model="commonRights.limit1"></el-input>次
  131. </el-form-item>
  132. </el-form-item>
  133. <h3>普通企业方用户权益设置</h3>
  134. <el-form-item style="padding: 4%">
  135. <el-form-item label="普通用户每天可聊一聊次数" prop="project_reduction_rate">
  136. <el-input style="width: 30%" v-model="commonRights.limit2"></el-input>次
  137. </el-form-item>
  138. <br /><br />
  139. <el-form-item label="普通用户每天可发布雇佣数" prop="job_reduction_rate">
  140. <el-input style="width: 30%" v-model="commonRights.limit3"></el-input>个
  141. </el-form-item>
  142. </el-form-item>
  143. <br />
  144. <el-form-item>
  145. <el-button type="primary" @click="submitForm('commonRights')">保存</el-button>
  146. </el-form-item>
  147. </el-form>
  148. </div>
  149. </template>
  150. <script>
  151. import {validAlphabets} from "../../../utils/validate";
  152. export default {
  153. data() {
  154. return {
  155. ruleForm: {},
  156. rules: {
  157. mOrigin: [{ required: true, message: "请输入数字", trigger: "blur" }],
  158. mCurrent: [{ required: true, message: "请输入数字", trigger: "blur" }],
  159. sOrigin: [{ required: true, message: "请输入数字", trigger: "blur" }],
  160. sCurrent: [{ required: true, message: "请输入数字", trigger: "blur" }],
  161. yOrigin: [{ required: true, message: "请输入数字", trigger: "blur" }],
  162. sCurrent: [{ required: true, message: "请输入数字", trigger: "blur" }],
  163. tPercent: [{ required: true, message: "请输入数字", trigger: "blur" }],
  164. cPercent: [{ required: true, message: "请输入数字", trigger: "blur" }]
  165. },
  166. // 当前 title 索引
  167. currentIndex: 0,
  168. // vip 的类型名字
  169. titles: [],
  170. // vip 列表
  171. list: [],
  172. // 设备类型, iOS/其他
  173. device: "其他",
  174. rights1:'',
  175. rights2:'',
  176. shows:true,
  177. commonRights:{}
  178. };
  179. },
  180. mounted() {
  181. this.getList();
  182. },
  183. methods: {
  184. /**
  185. * 点击 title
  186. */
  187. clickTitle(i) {
  188. this.currentIndex = i;
  189. this.resetForm();
  190. this.getDetail(this.list[i]);
  191. },
  192. /**
  193. * 重置
  194. */
  195. resetForm(formName = "ruleForm") {
  196. if(this.shows){
  197. this.$refs[formName].resetFields();
  198. }
  199. },
  200. /**
  201. * 保存或更新
  202. */
  203. async update() {
  204. let res;
  205. if (this.shows){
  206. const ruleForm = this.ruleForm;
  207. const can_buy_monthly = ruleForm.can_buy_monthly ? "1" : "0";
  208. const can_buy_quarterly = ruleForm.can_buy_quarterly ? "1" : "0";
  209. const can_buy_half_yearly = ruleForm.can_buy_half_yearly ? "1" : "0";
  210. const can_buy_yearly = ruleForm.can_buy_yearly ? "1" : "0";
  211. res = await this.$post("/api/admin/vip/update", {
  212. ...ruleForm,
  213. can_buy_monthly,
  214. can_buy_quarterly,
  215. can_buy_half_yearly,
  216. can_buy_yearly
  217. });
  218. }else{
  219. const rights = {
  220. 'id':4,
  221. 'limit1':this.commonRights.limit1,
  222. 'limit2':this.commonRights.limit2,
  223. 'limit3':this.commonRights.limit3,
  224. };
  225. res = await this.$post("/api/admin/vip/set_rights", rights);
  226. }
  227. if (res)
  228. this.$message({
  229. message: "更新成功",
  230. type: "success"
  231. });
  232. },
  233. /**
  234. * 提交
  235. */
  236. submitForm(formName) {
  237. this.$refs[formName].validate(valid => {
  238. if (valid) {
  239. // console.log(this.ruleForm);
  240. this.update();
  241. } else {
  242. // console.log("error submit!!");
  243. return false;
  244. }
  245. });
  246. },
  247. /**
  248. * 获取详情数据
  249. */
  250. async getDetail({ id }) {
  251. switch ({ id }.id) {
  252. case '2':
  253. this.shows = true;
  254. this.rights1 = '每月可接单次数';
  255. this.rights2 = '可同时接单数量';
  256. break;
  257. case '1':
  258. case '3':
  259. this.shows = true;
  260. this.rights1 = '每月可雇佣次数';
  261. this.rights2 = '每天聊一聊次数';
  262. break;
  263. case '4':
  264. this.shows = false;
  265. const res = await this.$post("/api/admin/vip/get_rights", { id });
  266. this.commonRights = res.data;
  267. return ;
  268. break;
  269. }
  270. const res = await this.$post("/api/admin/vip/getDetail", { id });
  271. const data = res.data;
  272. // console.log({id}.id);
  273. const can_buy_monthly = data.can_buy_monthly === "1";
  274. const can_buy_quarterly = data.can_buy_quarterly === "1";
  275. const can_buy_half_yearly = data.can_buy_half_yearly === "1";
  276. const can_buy_yearly = data.can_buy_yearly === "1";
  277. // ruleForm 相当于 detail, 这里同步下关键词
  278. this.ruleForm = {
  279. ...data,
  280. can_buy_monthly,
  281. can_buy_quarterly,
  282. can_buy_half_yearly,
  283. can_buy_yearly
  284. };
  285. },
  286. /**
  287. * 获取列表数据
  288. */
  289. async getList() {
  290. const res = await this.$post("/api/admin/vip/getList");
  291. // console.log(res)
  292. //更改显示顺序
  293. this.list = res.data;
  294. let temp = this.list[0];
  295. this.list[0] = this.list[1];
  296. this.list[1] = temp;
  297. this.list.push({
  298. id :'4',
  299. name: "普通用户权益",
  300. });
  301. this.titles = this.list.map(i => i.name);
  302. // console.log(this.titles);
  303. // 模拟点击一次
  304. this.clickTitle(0);
  305. }
  306. }
  307. };
  308. </script>
  309. <style>
  310. #vip-setting {
  311. padding: 20px;
  312. }
  313. .table {
  314. height: 100%;
  315. height: calc(100% - 80px);
  316. }
  317. .el-input {
  318. width: auto;
  319. }
  320. .el-check-group,
  321. .el-form-item,
  322. .el-form-item__content {
  323. display: inline-block;
  324. }
  325. .device-select {
  326. margin-bottom: 20px;
  327. }
  328. </style>