index.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('com-rich-text');
  4. ComponentHelper::loadComponentView('com-dialog-select');
  5. ?>
  6. <div id="app" v-cloak>
  7. <el-card class="box-card" v-loading="loading" shadow="never" style="border:0;min-width: 1200px;" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  8. <div style="position: relative;">
  9. <template>
  10. <el-card>
  11. <el-form :model="ruleForm" size="small" ref="ruleForm" label-width="150px" id="settingForm">
  12. <el-row>
  13. <div style="display:flex;justify-content:space-between;">
  14. <el-col :span="24">
  15. <el-tabs v-model="activeName" type="card">
  16. <el-tab-pane label="基础设置" name="basic">
  17. <?php ComponentHelper::loadComponentView('basic', __DIR__ . '/'); ?>
  18. </el-tab-pane>
  19. <el-tab-pane label="充值设置" name="recharge">
  20. <?php ComponentHelper::loadComponentView('recharge', __DIR__ . '/'); ?>
  21. </el-tab-pane>
  22. <el-tab-pane label="模式设置" name="mode">
  23. <?php ComponentHelper::loadComponentView('mode', __DIR__ . '/'); ?>
  24. </el-tab-pane>
  25. <el-tab-pane label="提现设置" name="withdraw">
  26. <?php ComponentHelper::loadComponentView('withdraw', __DIR__ . '/'); ?>
  27. </el-tab-pane>
  28. <el-tab-pane label="协议" name="protocol">
  29. <?php ComponentHelper::loadComponentView('protocol', __DIR__ . '/'); ?>
  30. </el-tab-pane>
  31. <el-tab-pane label="营销设置" name="marketing">
  32. <?php ComponentHelper::loadComponentView('marketing', __DIR__ . '/'); ?>
  33. </el-tab-pane>
  34. <el-tab-pane label="收银台设置" name="cashier">
  35. <?php ComponentHelper::loadComponentView('cashier', __DIR__ . '/'); ?>
  36. </el-tab-pane>
  37. </el-tabs>
  38. </el-col>
  39. </div>
  40. <div style="position:absolute;right:0;top:0">
  41. <el-button :loading="btnLoading" class="button-item" type="primary" @click="store('ruleForm')" size="small">保存
  42. </el-button>
  43. </div>
  44. </el-row>
  45. </el-form>
  46. </el-card>
  47. </template>
  48. </div>
  49. </el-card>
  50. </div>
  51. <script>
  52. const app = new Vue({
  53. el: '#app',
  54. data() {
  55. return {
  56. select_user_type: 1,
  57. activeCollapseNames: ['hei-go-setting', 'hi-bei-setting', 'hi-value-setting'],
  58. activeName: 'basic',
  59. // activeName: 'customize_text',
  60. loading: false,
  61. btnLoading: false,
  62. dialogTableVisible: false,
  63. dialogVisible: false,
  64. list: [],
  65. pagination: null, //分页数据
  66. selectItem: {}, //被选中的券
  67. confirmItem: {}, //确认选择该券
  68. page: 1,
  69. user_levels: [],
  70. levels: [],
  71. selectUser: '', //选中的用户
  72. searchForm: {
  73. inviter_id: '',
  74. keyword: '',
  75. },
  76. searchInfo: [],
  77. listLoading: false,
  78. templateSelection: {},
  79. radioSelection: 0,
  80. activeModeDistribution: 'hiBei',
  81. activeModeAgent: 'hiBei',
  82. activeModeArea: 'hiBei',
  83. activeModeBusinessBonus: 'hiBei',
  84. commission_type: [{
  85. label: '嗨贝',
  86. name: 'hiBei'
  87. },
  88. {
  89. label: '嗨值',
  90. name: 'hiValue'
  91. },
  92. ],
  93. goods_market_arr: [{
  94. label: 1,
  95. name: '嗨贝、嗨值赠送'
  96. },
  97. {
  98. label: 2,
  99. name: '嗨值、嗨贝抵扣'
  100. },
  101. ],
  102. ruleForm: {
  103. // 基础设置
  104. basic: {
  105. is_enable: 0,
  106. hi_value_name: '',
  107. hi_bei_name: '',
  108. hi_value_decimal: 2,
  109. merchant_profit_multiple: 0,
  110. merchant_reduce_profit_enable: 0,
  111. merchant_reduce_profit_min: 0,
  112. merchant_reduce_profit_max: 0,
  113. consumer_profit_multiple: 0,
  114. commissioner_profit_multiple: 0,
  115. mode_reward_method: 0,
  116. merchant_buy_goods: 0,
  117. destroy_method: 0, //销毁方式
  118. destroy_ratio: 0, //销毁比例
  119. destroy_formula: 0, //销毁公式
  120. destroy_time: '00:00',
  121. hi_bei_total_issuance: 0, //
  122. hi_bei_decimal: 2,
  123. airdrop_method: 0,
  124. airdrop_years_config: [],
  125. airdrop_years_type: 0,
  126. airdrop_everyday_number: 0,
  127. airdrop_time: '00:00',
  128. hi_bei_pricing_method: 0,
  129. hi_bei_pricing: 0,
  130. hi_bei_pricing_radio: 0,
  131. hi_bei_ratio_pricing: 0,
  132. buy_product_prompt: '',
  133. is_order_settings: 0,
  134. destroy_settings: 0,
  135. enable_platform_account: 0,
  136. platform_account_user: {
  137. user_id: 0,
  138. nickname: '',
  139. mobile: '',
  140. created_at: '',
  141. avatar_url: '',
  142. ratio: 0
  143. },
  144. hi_bei_transfer_fee_platform: {
  145. user_id: 0,
  146. nickname: '',
  147. mobile: '',
  148. created_at: '',
  149. avatar_url: '',
  150. ratio: 0
  151. },
  152. hi_bei_transfer_fee_destroy: 0,
  153. hi_bei_transfer_fee: 0,
  154. hi_bei_transfer_enable: 0,
  155. merchant_rewards: 0,
  156. consumer_rewards: 0,
  157. merchants_incentives: 0,
  158. payment_method: 0,
  159. remaining_rewards: 0,
  160. },
  161. recharge: {
  162. enable: 0,
  163. price_setting_method: 0,
  164. price_setting_ratio: 0,
  165. price_ladder: []
  166. },
  167. merchant: {
  168. enable_reward: 0,
  169. reward_ratio: 0,
  170. handling_fee: 0,
  171. enable_hold_hi_order: false,
  172. destroy_ratio: 0,
  173. enable_platform_account: 0,
  174. rest_hibe: 0,
  175. goods_market: [],
  176. },
  177. protocol: {
  178. member_notice: '',
  179. reward_rules: '',
  180. },
  181. mode: {
  182. enable: 0,
  183. checkout_counter_enable: 0,
  184. is_install_distribution: 0,
  185. is_install_agent: 0,
  186. is_install_area: 0,
  187. is_install_business_bonus: 0,
  188. distribution: {
  189. hiBei: {
  190. enable: 0,
  191. remaining_part_ratio: 0,
  192. type: 0,
  193. level_setting: [],
  194. },
  195. hiValue: {
  196. enable: 0,
  197. remaining_part_ratio: 0,
  198. type: 0,
  199. level_setting: [],
  200. },
  201. },
  202. agent: {
  203. hiBei: {
  204. enable: 0,
  205. remaining_part_ratio: 0,
  206. level_setting: [],
  207. },
  208. hiValue: {
  209. enable: 0,
  210. remaining_part_ratio: 0,
  211. level_setting: [],
  212. },
  213. },
  214. area: {
  215. hiBei: {
  216. enable: 0,
  217. remaining_part_ratio: 0,
  218. level_setting: [{
  219. level: [],
  220. type: 0,
  221. setting_type: 'normal',
  222. title: '嗨贝配置',
  223. },
  224. {
  225. level: [],
  226. type: 0,
  227. setting_type: 'same_level',
  228. title: '嗨贝平级奖配置',
  229. }
  230. ],
  231. },
  232. hiValue: {
  233. enable: 0,
  234. remaining_part_ratio: 0,
  235. level_setting: [{
  236. level: [],
  237. type: 0,
  238. setting_type: 'normal',
  239. title: '嗨值配置',
  240. },
  241. {
  242. level: [],
  243. type: 0,
  244. setting_type: 'same_level',
  245. title: '嗨值平级奖配置',
  246. }
  247. ],
  248. },
  249. },
  250. businessBonus: {
  251. hiBei: {
  252. enable: 0,
  253. remaining_part_ratio: 0,
  254. type: 0,
  255. level_setting: [],
  256. },
  257. hiValue: {
  258. enable: 0,
  259. remaining_part_ratio: 0,
  260. type: 0,
  261. level_setting: [],
  262. },
  263. }
  264. },
  265. withdraw: {
  266. cash_status: {
  267. title: '开启提现',
  268. value: '',
  269. remark: ''
  270. },
  271. cash_type: {
  272. title: '联系号码',
  273. value: [],
  274. remark: '自动打款支付,需要申请相应小程序的相应功能,例如:微信需要申请企业付款到零钱功能',
  275. extra_type: 'checkbox',
  276. extra: {
  277. // auto:'微信自动打款',
  278. // wechat:'微信线下转账',
  279. // alipay:'支付宝线下转账',
  280. // bank:'银行卡线下转账',
  281. // joinpay:'提现到银行卡-汇聚'
  282. }
  283. },
  284. cash_service_fee: {
  285. title: '提现手续费',
  286. value: '0',
  287. remark: '单位:% (提现手续费额外从提现中扣除,例如:10%的提现手续费:提现100元,扣除手续费10元,实际到手90元)'
  288. },
  289. },
  290. marketing: {
  291. enable: 0,
  292. send_hi_value_type: 0,
  293. parent_send_hi_value: 0,
  294. register_send_hi_value: 0,
  295. goods_list: [],
  296. active_goods_list: [],
  297. },
  298. cashier: {
  299. status: 0,
  300. hi_value: 0,
  301. hi_bei: 0,
  302. parent_hi_value: 0,
  303. },
  304. },
  305. }
  306. },
  307. mounted: function() {
  308. this.loadData();
  309. },
  310. watch: {
  311. 'ruleForm.basic.destroy_settings': {
  312. handler(newVal, oldVal) {
  313. this.ruleForm.basic.remaining_rewards = 100 - newVal - this.ruleForm.basic.platform_account_user.ratio;
  314. },
  315. immediate: true,
  316. deep: false
  317. },
  318. 'ruleForm.basic.platform_account_user.ratio': {
  319. handler(newVal, oldVal) {
  320. this.ruleForm.basic.remaining_rewards = 100 - newVal - this.ruleForm.basic.destroy_settings;
  321. },
  322. immediate: true,
  323. deep: false
  324. },
  325. 'ruleForm.basic.hi_bei_transfer_fee_destroy': {
  326. handler(newVal, oldVal) {
  327. this.ruleForm.basic.hi_bei_transfer_fee_platform.ratio = 100 - newVal;
  328. },
  329. immediate: true,
  330. deep: true
  331. },
  332. },
  333. methods: {
  334. assiginObj(target = {}, sources = {}) {
  335. let obj = target;
  336. if (typeof target != 'object' || typeof sources != 'object') {
  337. return sources; // 如果其中一个不是对象 就返回sources
  338. }
  339. for (let key in sources) {
  340. // 如果target也存在 那就再次合并
  341. if (target.hasOwnProperty(key)) {
  342. obj[key] = this.assiginObj(target[key], sources[key]);
  343. } else {
  344. // 不存在就直接添加
  345. obj[key] = sources[key];
  346. }
  347. }
  348. return obj;
  349. },
  350. loadData() {
  351. if (this.loading === true) return;
  352. this.loading = true;
  353. request({
  354. params: {
  355. r: 'hi-go/setting/index',
  356. },
  357. method: 'get'
  358. }).then(e => {
  359. this.loading = false;
  360. if (e.data.code == 0) {
  361. let basic = e.data.data.configs.basic;
  362. let protocol = e.data.data.configs.protocol;
  363. let recharge = e.data.data.configs.recharge;
  364. let withdraw = e.data.data.configs.withdraw;
  365. let marketing = e.data.data.configs.marketing;
  366. let cashier = e.data.data.configs.cashier;
  367. // let merchant = e.data.data.configs.merchant;
  368. let mode = e.data.data.configs.mode;
  369. this.ruleForm.basic = this.assiginObj(this.ruleForm.basic, basic);
  370. this.ruleForm.protocol = this.assiginObj(this.ruleForm.protocol, protocol);
  371. this.ruleForm.recharge = this.assiginObj(this.ruleForm.recharge, recharge);
  372. this.ruleForm.mode = this.assiginObj(this.ruleForm.mode, mode);
  373. this.ruleForm.withdraw = this.assiginObj(this.ruleForm.withdraw, withdraw);
  374. this.ruleForm.marketing = this.assiginObj(this.ruleForm.marketing, marketing);
  375. this.ruleForm.cashier = this.assiginObj(this.ruleForm.cashier, cashier);
  376. // this.ruleForm.merchant = this.assiginObj(this.ruleForm.merchant, merchant);
  377. // this.$nextTick(() => {
  378. // this.ruleForm.merchant.goods_market = merchant.goods_market;
  379. // });
  380. for (let i = 0; i < this.ruleForm.basic.airdrop_years_config.length; i++) {
  381. let date = new Date();
  382. date.setFullYear(this.ruleForm.basic.airdrop_years_config[i].year);
  383. this.ruleForm.basic.airdrop_years_config[i].year = date;
  384. }
  385. }
  386. }).catch(e => {
  387. this.loading = false;
  388. })
  389. },
  390. forceChange() {
  391. this.$forceUpdate();
  392. },
  393. store(formName) {
  394. if (this.ruleForm.basic.airdrop_years_config.length > 0) {
  395. for (let i = 0; i < this.ruleForm.basic.airdrop_years_config.length; i++) {
  396. if (this.ruleForm.basic.airdrop_years_config[i].year instanceof Date) {
  397. this.ruleForm.basic.airdrop_years_config[i].year = this.ruleForm.basic.airdrop_years_config[i].year.getFullYear();
  398. }
  399. }
  400. }
  401. if (this.ruleForm.basic.airdrop_years_type == 1) {
  402. for (let i = 0; i < this.ruleForm.basic.airdrop_years_config.length; i++) {
  403. if (this.ruleForm.basic.airdrop_years_config[i].value > 100) {
  404. this.$message.error('年份对应的比例不能超过100%,请重新输入');
  405. return;
  406. }
  407. }
  408. }
  409. if (this.ruleForm.withdraw.cash_status.value == 1 && (this.ruleForm.withdraw.cash_service_fee.value >= 100 || this.ruleForm.withdraw.cash_service_fee.value < 0)) {
  410. this.$message.error('请设置有效的手续费');
  411. return;
  412. }
  413. this.$refs[formName].validate((valid) => {
  414. if (valid) {
  415. if (this.btnLoading) return
  416. this.btnLoading = true;
  417. request({
  418. params: {
  419. r: 'hi-go/setting/index',
  420. },
  421. method: 'post',
  422. data: this.ruleForm
  423. }).then(e => {
  424. this.btnLoading = false;
  425. if (e.data.code == 0) {
  426. this.$message.success(e.data.msg);
  427. } else {
  428. this.$message.error(e.data.msg);
  429. }
  430. }).catch(e => {
  431. this.$message.error(e);
  432. this.btnLoading = false;
  433. })
  434. } else {
  435. this.btnLoading = false;
  436. console.log('error submit!!');
  437. return false;
  438. }
  439. });
  440. },
  441. addYearsConfig() {
  442. let item = {
  443. year: '',
  444. value: 0,
  445. method: 0,
  446. };
  447. this.ruleForm.basic.airdrop_years_config.push(item);
  448. },
  449. delYearsConfig(index) {
  450. this.ruleForm.basic.airdrop_years_config.splice(index, 1);
  451. },
  452. addPriceLadder() {
  453. let item = {
  454. uuid: this.uuid(),
  455. money: 0,
  456. give: 0,
  457. };
  458. this.ruleForm.recharge.price_ladder.push(item);
  459. },
  460. delPriceLadder(index) {
  461. this.ruleForm.recharge.price_ladder.splice(index, 1);
  462. },
  463. uuid() {
  464. var s = [];
  465. var hexDigits = "0123456789abcdef";
  466. for (var i = 0; i < 36; i++) {
  467. s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  468. }
  469. s[14] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
  470. s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
  471. s[8] = s[13] = s[18] = s[23] = "-";
  472. var uuid = s.join("");
  473. return uuid;
  474. },
  475. dialogVisiblePop(select_user_type) {
  476. this.select_user_type = select_user_type;
  477. this.searchForm = {
  478. inviter_id: '',
  479. keyword: '',
  480. }
  481. this.searchInfo.splice(0, this.searchInfo.length);
  482. this.radioSelection = 0;
  483. this.selectUser = null;
  484. this.dialogVisible = true;
  485. },
  486. confirmSelectUser(type = 1) {
  487. this.dialogVisible = false;
  488. this.btnLoading = false;
  489. let userinfo = this.searchInfo[0];
  490. if (type == 1) {
  491. this.ruleForm.basic.platform_account_user.user_id = userinfo.id;
  492. this.ruleForm.basic.platform_account_user.nickname = userinfo.nickname;
  493. this.ruleForm.basic.platform_account_user.mobile = userinfo.mobile;
  494. this.ruleForm.basic.platform_account_user.avatar_url = userinfo.avatar_url;
  495. this.ruleForm.basic.platform_account_user.created_at = userinfo.created_at;
  496. } else {
  497. this.ruleForm.basic.hi_bei_transfer_fee_platform.user_id = userinfo.id;
  498. this.ruleForm.basic.hi_bei_transfer_fee_platform.nickname = userinfo.nickname;
  499. this.ruleForm.basic.hi_bei_transfer_fee_platform.mobile = userinfo.mobile;
  500. this.ruleForm.basic.hi_bei_transfer_fee_platform.avatar_url = userinfo.avatar_url;
  501. this.ruleForm.basic.hi_bei_transfer_fee_platform.created_at = userinfo.created_at;
  502. }
  503. },
  504. // 搜索
  505. searchFun() {
  506. if (!this.searchForm.inviter_id && !this.searchForm.keyword) {
  507. this.$message.error('查询内容不能为空');
  508. this.listLoading = false;
  509. return false;
  510. }
  511. this.listLoading = true;
  512. request({
  513. params: {
  514. r: 'hi-go/default/get-platform-user',
  515. inviter_id: this.searchForm.inviter_id,
  516. keyword: this.searchForm.keyword,
  517. user_id: this.user_id,
  518. },
  519. }).then(e => {
  520. this.listLoading = false;
  521. if (e.data.code === 0) {
  522. this.searchInfo = e.data.data.list.list;
  523. } else {
  524. this.$message.error(res.data.msg);
  525. }
  526. }).catch(e => {
  527. this.listLoading = false;
  528. });
  529. },
  530. selectionChange(e) {
  531. console.log(e, 'dfhkdhkjsfhdjkfhdskjfh');
  532. this.selectUser = e;
  533. },
  534. delPlatformUser(type = 1) {
  535. if (type == 1) {
  536. this.ruleForm.basic.platform_account_user.user_id = 0;
  537. this.ruleForm.basic.platform_account_user.nickname = '';
  538. this.ruleForm.basic.platform_account_user.mobile = '';
  539. this.ruleForm.basic.platform_account_user.created_at = '';
  540. this.ruleForm.basic.platform_account_user.avatar_url = '';
  541. this.ruleForm.basic.platform_account_user.ratio = 0;
  542. } else {
  543. this.ruleForm.basic.hi_bei_transfer_fee_platform.user_id = 0;
  544. this.ruleForm.basic.hi_bei_transfer_fee_platform.nickname = '';
  545. this.ruleForm.basic.hi_bei_transfer_fee_platform.mobile = '';
  546. this.ruleForm.basic.hi_bei_transfer_fee_platform.created_at = '';
  547. this.ruleForm.basic.hi_bei_transfer_fee_platform.avatar_url = '';
  548. this.ruleForm.basic.hi_bei_transfer_fee_platform.ratio = 0;
  549. }
  550. },
  551. checkNum(key) {
  552. if (this.ruleForm.basic.airdrop_years_type == 1) {
  553. if (this.ruleForm.basic.airdrop_years_config[key].value > 100) {
  554. this.ruleForm.basic.airdrop_years_config[key].value = 0;
  555. this.forceChange();
  556. this.$message.error('年份对应的比例不能超过100%,请重新输入');
  557. }
  558. }
  559. },
  560. // 选中商品处理
  561. goodsSelect(param) {
  562. let params = param;
  563. //params.push(param);
  564. for (let j in params) {
  565. let item = params[j];
  566. let flag = true;
  567. if (flag) {
  568. //this.ruleForm.marketing.goods_list = [];
  569. this.ruleForm.marketing.goods_list.push({
  570. id: item.id,
  571. price: item.price,
  572. status: item.status,
  573. goods_stock: item.stock,
  574. goods_name: item.goods_name,
  575. cover_pic: item.cover_pic,
  576. });
  577. }
  578. }
  579. },
  580. // 选中商品处理
  581. goodsActiveSelect(param) {
  582. let params = param;
  583. //params.push(param);
  584. for (let j in params) {
  585. let item = params[j];
  586. let flag = true;
  587. if (flag) {
  588. //this.ruleForm.marketing.active_goods_list = [];
  589. this.ruleForm.marketing.active_goods_list.push({
  590. id: item.id,
  591. price: item.price,
  592. status: item.status,
  593. goods_stock: item.stock,
  594. goods_name: item.goods_name,
  595. cover_pic: item.cover_pic,
  596. });
  597. console.log(this.ruleForm.marketing.active_goods_list);
  598. }
  599. }
  600. },
  601. // 删除商品
  602. delFun(index) {
  603. this.ruleForm.marketing.goods_list.splice(index, 1);
  604. },
  605. // 删除商品
  606. delActiveFun(index) {
  607. this.ruleForm.marketing.active_goods_list.splice(index, 1);
  608. },
  609. },
  610. });
  611. </script>
  612. <style>
  613. .el-collapse-item__header {
  614. font-size: 14px;
  615. }
  616. #settingForm .el-form-item__label {
  617. font-size: 13px;
  618. }
  619. .my-desc-label {
  620. font-size: 13px;
  621. }
  622. </style>