index.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. <div id="app" v-cloak>
  2. <el-card v-loading="loading" style="border:0;min-width: 800px;" shadow="never"
  3. body-style="background-color: #f3f3f3;padding: 0 0;">
  4. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="172px" style="position: relative"
  5. size="small" :rules="rules">
  6. <el-tabs v-model="activeName">
  7. <!-- 基础设置 -->
  8. <el-tab-pane label="基础设置" name="first">
  9. <el-row>
  10. <el-col :span="24">
  11. <div class="title">
  12. <span>基础设置</span>
  13. </div>
  14. <div class="form-body">
  15. <!-- appKey -->
  16. <el-form-item label="appKey" prop="app_key">
  17. <el-input @focus="updateHideStatus(1)" v-if="hideStatus_1" readonly
  18. :placeholder="ruleForm.app_key ? 'app_key 被隐藏,点击查看' : '请填写 app_key'">
  19. </el-input>
  20. <el-input v-else v-model="ruleForm.app_key" placeholder="请填写 app_key">
  21. </el-input>
  22. </el-form-item>
  23. <!-- appSecret -->
  24. <el-form-item label="appSecret" prop="app_secret">
  25. <el-input @focus="updateHideStatus(2)" v-if="hideStatus_2" readonly
  26. :placeholder="ruleForm.app_secret ? 'app_secret 被隐藏,点击查看' : '请填写 app_secret'">
  27. </el-input>
  28. <el-input v-else v-model="ruleForm.app_secret" placeholder="请填写 app_secret">
  29. </el-input>
  30. </el-form-item>
  31. <!-- 回调地址 -->
  32. <el-form-item label="回调地址">
  33. <el-input readonly v-model="ruleForm.callback_url" disabled>
  34. <el-button
  35. slot="append"
  36. class="copy_btn"
  37. @click="copyLink(ruleForm.callback_url)"
  38. >复制</el-button>
  39. </el-input>
  40. </el-form-item>
  41. </div>
  42. </el-col>
  43. </el-row>
  44. </el-tab-pane>
  45. <!-- 更新设置 -->
  46. <el-tab-pane label="更新设置" name="second" v-if="1">
  47. <el-row>
  48. <el-col :span="24">
  49. <div class="title">
  50. <span>更新设置</span>
  51. </div>
  52. <div class="form-body">
  53. <!-- 自动更新商品现价 -->
  54. <el-form-item label="自动更新商品价格" prop="status">
  55. <el-switch v-model="ruleForm.auto_present_price" active-value="1"
  56. inactive-value="0">
  57. </el-switch>
  58. </el-form-item>
  59. <!-- 自动更新商品基本信息 -->
  60. <el-form-item label="自动更新商品基本信息" prop="status">
  61. <el-switch v-model="ruleForm.auto_base_info" active-value="1" inactive-value="0">
  62. </el-switch>
  63. </el-form-item>
  64. </div>
  65. </el-col>
  66. </el-row>
  67. </el-tab-pane>
  68. <!-- 定价策略 -->
  69. <el-tab-pane label="定价策略" name="third">
  70. <el-row>
  71. <el-col :span="24">
  72. <div class="title">
  73. <span>定价策略</span>
  74. </div>
  75. <div class="form-body">
  76. <!-- 售价 定价策略 -->
  77. <el-form-item label="售价 定价策略" prop="sell_strategy">
  78. <el-radio-group v-model="ruleForm.sell_strategy" size="medium" class="redio-center">
  79. <!-- 官方销售价 -->
  80. <el-radio label="1">{{''}}</el-radio>
  81. <el-form-item prop="sell_guide">
  82. <span class="redio-input">
  83. <el-input style="width:300px;" v-model="ruleForm.sell_guide"
  84. minlength="1" maxlength="3"
  85. oninput="value=value.replace(/[^\d]/g,'')" required="required">
  86. <template slot="prepend">官方销售价 x 定价系数</template>
  87. <template slot="append">%</template>
  88. </el-input>
  89. </span>
  90. </el-form-item>
  91. <!-- 采购价 -->
  92. <el-radio label="2">{{''}}</el-radio>
  93. <el-form-item prop="sell_sales">
  94. <span class="redio-input">
  95. <el-input style="width:300px;" v-model="ruleForm.sell_sales" min="1"
  96. oninput="value=value.replace(/[^\d]/g,'')">
  97. <template slot="prepend">采购价 x 定价系数</template>
  98. <template slot="append">%</template>
  99. </el-input>
  100. </span>
  101. </el-form-item>
  102. <!-- 建议零售价 -->
  103. <el-radio label="3">{{''}}</el-radio>
  104. <el-form-item prop="sell_market">
  105. <span class="redio-input">
  106. <el-input style="width:300px;" v-model="ruleForm.sell_market" min="1"
  107. oninput="value=value.replace(/[^\d]/g,'')">
  108. <template slot="prepend">建议零售价 x 定价系数</template>
  109. <template slot="append">%</template>
  110. </el-input>
  111. </span>
  112. </el-form-item>
  113. </el-radio-group>
  114. <div class="tab_tpis">
  115. 举例:采购价50元 官方销售价100元<br>
  116. 采购价 x 定价系数 即 50 x 130% = 65 元<br>
  117. 官方销售价 x 定价系数 即 100 x 80% = 80 元<br>
  118. </div>
  119. </el-form-item>
  120. <!-- 成本价 定价策略 -->
  121. <el-form-item label="成本价 定价策略" prop="status">
  122. <el-radio-group v-model="ruleForm.cost_strategy" size="medium" class="redio-center">
  123. <!-- 官方销售价 -->
  124. <el-radio label="1">{{''}}</el-radio>
  125. <el-form-item prop="cost_guide">
  126. <span class="redio-input">
  127. <el-input style="width:300px;" v-model="ruleForm.cost_guide" min="1"
  128. oninput="value=value.replace(/[^\d]/g,'')">
  129. <template slot="prepend">官方销售价 x 定价系数</template>
  130. <template slot="append">%</template>
  131. </el-input>
  132. </span>
  133. </el-form-item>
  134. <!-- 采购价 -->
  135. <el-radio label="2">{{''}}</el-radio>
  136. <el-form-item prop="cost_sales">
  137. <span class="redio-input">
  138. <el-input style="width:300px;" v-model="ruleForm.cost_sales" min="1"
  139. oninput="value=value.replace(/[^\d]/g,'')">
  140. <template slot="prepend">采购价 x 定价系数</template>
  141. <template slot="append">%</template>
  142. </el-input>
  143. </span>
  144. </el-form-item>
  145. <!-- 建议零售价 -->
  146. <el-radio label="3">{{''}}</el-radio>
  147. <el-form-item prop="cost_market">
  148. <span class="redio-input">
  149. <el-input style="width:300px;" v-model="ruleForm.cost_market" min="1"
  150. oninput="value=value.replace(/[^\d]/g,'')">
  151. <template slot="prepend">建议零售价 x 定价系数</template>
  152. <template slot="append">%</template>
  153. </el-input>
  154. </span>
  155. </el-form-item>
  156. </el-radio-group>
  157. <div class="tab_tpis">
  158. </div>
  159. </el-form-item>
  160. <!-- 原价 定价策略 -->
  161. <el-form-item label="原价 定价策略" prop="status">
  162. <el-radio-group v-model="ruleForm.original_strategy" size="medium"
  163. class="redio-center">
  164. <!-- 官方销售价 -->
  165. <el-radio label="1">{{''}}</el-radio>
  166. <el-form-item prop="original_guide">
  167. <span class="redio-input">
  168. <el-input style="width:300px;" v-model="ruleForm.original_guide" min="1"
  169. oninput="value=value.replace(/[^\d]/g,'')">
  170. <template slot="prepend">官方销售价 x 定价系数</template>
  171. <template slot="append">%</template>
  172. </el-input>
  173. </span>
  174. </el-form-item>
  175. <!-- 采购价 -->
  176. <el-radio label="2">{{''}}</el-radio>
  177. <el-form-item prop="original_sales">
  178. <span class="redio-input">
  179. <el-input style="width:300px;" v-model="ruleForm.original_sales" min="1"
  180. oninput="value=value.replace(/[^\d]/g,'')">
  181. <template slot="prepend">采购价 x 定价系数</template>
  182. <template slot="append">%</template>
  183. </el-input>
  184. </span>
  185. </el-form-item>
  186. <!-- 建议零售价 -->
  187. <el-radio label="3">{{''}}</el-radio>
  188. <el-form-item prop="original_market">
  189. <span class="redio-input">
  190. <el-input style="width:300px;" v-model="ruleForm.original_market"
  191. min="1" oninput="value=value.replace(/[^\d]/g,'')">
  192. <template slot="prepend">建议零售价 x 定价系数</template>
  193. <template slot="append">%</template>
  194. </el-input>
  195. </span>
  196. </el-form-item>
  197. </el-radio-group>
  198. <div class="tab_tpis">
  199. </div>
  200. </el-form-item>
  201. </div>
  202. </el-col>
  203. </el-row>
  204. </el-tab-pane>
  205. <!-- 推送设置 -->
  206. <el-tab-pane label="推送设置" name="four">
  207. <el-row>
  208. <el-col :span="24">
  209. <div class="title">
  210. <span>推送设置</span>
  211. </div>
  212. <div class="form-body">
  213. <!-- 售后推送 -->
  214. <el-form-item label="售后推送" prop="status">
  215. <el-switch
  216. v-model="ruleForm.refund_auto_push"
  217. active-value="1"
  218. active-text="自动推送"
  219. inactive-value="0"
  220. inactive-text="手动推送"
  221. active-color="#13ce66"
  222. inactive-color="#ff4949"
  223. >
  224. </el-switch>
  225. </el-form-item>
  226. </div>
  227. </el-col>
  228. </el-row>
  229. </el-tab-pane>
  230. </el-tabs>
  231. <el-button :loading="submitLoading" class="button-item" size="small" type="primary"
  232. @click="submit('ruleForm')">保存
  233. </el-button>
  234. </el-form>
  235. </el-card>
  236. </div>
  237. <script>
  238. const app = new Vue({
  239. el: '#app',
  240. data() {
  241. return {
  242. hideStatus_1: true,
  243. hideStatus_2: true,
  244. loading: false,
  245. submitLoading: false,
  246. activeName: getQuery('tab') ? getQuery('tab') : 'first',
  247. ruleForm: {
  248. sell_strategy: "1",
  249. cost_strategy: "1",
  250. original_strategy: "1",
  251. sell_guide: 100,
  252. sell_sales: 100,
  253. sell_market: 100,
  254. cost_guide: 100,
  255. cost_sales: 100,
  256. cost_market: 100,
  257. original_guide: 100,
  258. original_sales: 100,
  259. original_market: 100,
  260. auto_present_price: "1",
  261. auto_base_info: "1",
  262. refund_auto_push: 0,
  263. },
  264. rules: {
  265. app_key: [
  266. { required: true, message: '不能为空' },
  267. ],
  268. app_secret: [
  269. { required: true, message: '不能为空' },
  270. ],
  271. sell_strategy: [
  272. { required: true, message: '不能为空' },
  273. ],
  274. cost_strategy: [
  275. { required: true, message: '不能为空' },
  276. ],
  277. original_strategy: [
  278. { required: true, message: '不能为空' },
  279. ],
  280. sell_guide: [
  281. { required: true, message: '不能为空' },
  282. ],
  283. sell_sales: [
  284. { required: true, message: '不能为空' },
  285. ],
  286. sell_market: [
  287. { required: true, message: '不能为空' },
  288. ],
  289. cost_guide: [
  290. { required: true, message: '不能为空' },
  291. ],
  292. cost_sales: [
  293. { required: true, message: '不能为空' },
  294. ],
  295. cost_market: [
  296. { required: true, message: '不能为空' },
  297. ],
  298. original_guide: [
  299. { required: true, message: '不能为空' },
  300. ],
  301. original_sales: [
  302. { required: true, message: '不能为空' },
  303. ],
  304. original_market: [
  305. { required: true, message: '不能为空' },
  306. ],
  307. },
  308. };
  309. },
  310. created() {
  311. this.loadData();
  312. },
  313. mounted: function () {
  314. this.getTab();
  315. },
  316. methods: {
  317. // 点击显示apikey
  318. updateHideStatus(type) {
  319. if (type == 1) {
  320. this.hideStatus_1 = false;
  321. }
  322. if (type == 2) {
  323. this.hideStatus_2 = false;
  324. }
  325. },
  326. getTab() {
  327. let tab_name = getQuery('tab');
  328. },
  329. loadData() {
  330. this.loading = true;
  331. request({
  332. params: {
  333. r: 'star-chain/default/index',
  334. },
  335. }).then(e => {
  336. this.loading = false;
  337. if (e.data.code === 0) {
  338. let copyForm = Object.assign({}, this.ruleForm)
  339. let form = Object.assign(copyForm, e.data.data)
  340. this.ruleForm = form
  341. console.log("ruleForm:", form);
  342. } else {
  343. this.$message.error(e.data.msg);
  344. }
  345. }).catch(e => {
  346. });
  347. },
  348. submit(formName) {
  349. console.log(this.ruleForm)
  350. this.$refs[formName].validate(valid => {
  351. if (valid) {
  352. this.submitLoading = true;
  353. request({
  354. params: {
  355. r: 'star-chain/default/edit',
  356. },
  357. method: 'post',
  358. data: {
  359. setting: this.ruleForm
  360. },
  361. }).then(e => {
  362. if (e.data.code === 0) {
  363. this.$message.success(e.data.msg);
  364. } else {
  365. this.$message.error(e.data.msg);
  366. }
  367. this.submitLoading = false;
  368. }).catch(e => {
  369. });
  370. } else {
  371. this.$message.error('部分参数验证不通过');
  372. }
  373. });
  374. },
  375. copyLink(url) { //复制链接
  376. var clipboard = new ClipboardJS('.copy_btn', {
  377. text: function () {
  378. return url;
  379. }
  380. });
  381. clipboard.on('success', (e) => {
  382. this.$message.success('复制成功!');
  383. clipboard.destroy()
  384. });
  385. clipboard.on('error', (e) => {
  386. this.$message.error('复制失败!');
  387. this.clipboard.destroy()
  388. });
  389. },
  390. },
  391. computed: {
  392. }
  393. });
  394. </script>
  395. <style>
  396. .el-tabs__header {
  397. padding: 0 20px;
  398. height: 56px;
  399. line-height: 56px;
  400. background-color: #fff;
  401. margin-bottom: 0;
  402. }
  403. .title {
  404. margin-top: 10px;
  405. padding: 18px 20px;
  406. border-top: 1px solid #F3F3F3;
  407. border-bottom: 1px solid #F3F3F3;
  408. background-color: #fff;
  409. }
  410. .form-body {
  411. background-color: #fff;
  412. padding: 20px 50% 20px 0;
  413. }
  414. .button-item {
  415. margin-top: 12px;
  416. padding: 9px 25px;
  417. }
  418. .form-body .item {
  419. width: 300px;
  420. margin-bottom: 50px;
  421. margin-right: 25px;
  422. }
  423. .item-img {
  424. height: 550px;
  425. padding: 25px 10px;
  426. border-radius: 30px;
  427. border: 1px solid #CCCCCC;
  428. background-color: #fff;
  429. }
  430. .item .el-form-item {
  431. width: 300px;
  432. margin: 20px auto;
  433. }
  434. .left-setting-menu {
  435. width: 260px;
  436. }
  437. .left-setting-menu .el-form-item {
  438. height: 60px;
  439. padding-left: 20px;
  440. display: flex;
  441. align-items: center;
  442. margin-bottom: 0;
  443. cursor: pointer;
  444. }
  445. .left-setting-menu .el-form-item .el-form-item__label {
  446. cursor: pointer;
  447. }
  448. .left-setting-menu .el-form-item.active {
  449. background-color: #F3F5F6;
  450. border-top-left-radius: 10px;
  451. width: 105%;
  452. border-bottom-left-radius: 10px;
  453. }
  454. .left-setting-menu .el-form-item .el-form-item__content {
  455. margin-left: 0 !important
  456. }
  457. .no-radius {
  458. border-top-left-radius: 0 !important;
  459. }
  460. .del-btn {
  461. position: absolute;
  462. right: -8px;
  463. top: -8px;
  464. padding: 4px 4px;
  465. }
  466. .reset {
  467. position: absolute;
  468. top: 3px;
  469. left: 90px;
  470. }
  471. .app-tip {
  472. position: absolute;
  473. right: 24px;
  474. top: 16px;
  475. height: 72px;
  476. line-height: 72px;
  477. max-width: calc(100% - 78px);
  478. }
  479. .app-tip:before {
  480. content: ' ';
  481. width: 0;
  482. height: 0;
  483. border-color: inherit;
  484. position: absolute;
  485. top: -32px;
  486. right: 100px;
  487. border-width: 16px;
  488. border-style: solid;
  489. }
  490. .tip-content {
  491. display: block;
  492. white-space: nowrap;
  493. width: 100%;
  494. overflow: hidden;
  495. text-overflow: ellipsis;
  496. margin: 0 28px;
  497. font-size: 28px;
  498. }
  499. .el-tabs__header {
  500. padding: 0 20px;
  501. height: 56px;
  502. line-height: 56px;
  503. background-color: #fff;
  504. margin-bottom: 0;
  505. }
  506. .title {
  507. margin-top: 10px;
  508. padding: 18px 20px;
  509. border-top: 1px solid #F3F3F3;
  510. border-bottom: 1px solid #F3F3F3;
  511. background-color: #fff;
  512. }
  513. .form-body {
  514. background-color: #fff;
  515. padding: 20px 50% 20px 0;
  516. }
  517. .button-item {
  518. padding: 9px 25px;
  519. }
  520. .form-body .item {
  521. width: 300px;
  522. margin-bottom: 50px;
  523. margin-right: 25px;
  524. }
  525. .item-img {
  526. height: 550px;
  527. padding: 25px 10px;
  528. border-radius: 30px;
  529. border: 1px solid #CCCCCC;
  530. background-color: #fff;
  531. }
  532. .item .el-form-item {
  533. width: 300px;
  534. margin: 20px auto;
  535. }
  536. .left-setting-menu {
  537. width: 260px;
  538. }
  539. .left-setting-menu .el-form-item {
  540. height: 60px;
  541. padding-left: 20px;
  542. display: flex;
  543. align-items: center;
  544. margin-bottom: 0;
  545. cursor: pointer;
  546. }
  547. .left-setting-menu .el-form-item .el-form-item__label {
  548. cursor: pointer;
  549. }
  550. .left-setting-menu .el-form-item.active {
  551. background-color: #F3F5F6;
  552. border-top-left-radius: 10px;
  553. width: 105%;
  554. border-bottom-left-radius: 10px;
  555. }
  556. .left-setting-menu .el-form-item .el-form-item__content {
  557. margin-left: 0 !important
  558. }
  559. .no-radius {
  560. border-top-left-radius: 0 !important;
  561. }
  562. .del-btn {
  563. position: absolute;
  564. right: -8px;
  565. top: -8px;
  566. padding: 4px 4px;
  567. }
  568. .reset {
  569. position: absolute;
  570. top: 3px;
  571. left: 90px;
  572. }
  573. .app-tip {
  574. position: absolute;
  575. right: 24px;
  576. top: 16px;
  577. height: 72px;
  578. line-height: 72px;
  579. max-width: calc(100% - 78px);
  580. }
  581. .app-tip:before {
  582. content: ' ';
  583. width: 0;
  584. height: 0;
  585. border-color: inherit;
  586. position: absolute;
  587. top: -32px;
  588. right: 100px;
  589. border-width: 16px;
  590. border-style: solid;
  591. }
  592. .tip-content {
  593. display: block;
  594. white-space: nowrap;
  595. width: 100%;
  596. overflow: hidden;
  597. text-overflow: ellipsis;
  598. margin: 0 28px;
  599. font-size: 28px;
  600. }
  601. .btn-abs {
  602. position: absolute;
  603. top: 12px;
  604. right: 18px;
  605. }
  606. .form-body .app-share {
  607. padding-top: 12px;
  608. border-top: 1px solid #e2e2e2;
  609. margin-top: -20px;
  610. }
  611. .form-body .app-share .app-share-bg {
  612. position: relative;
  613. width: 310px;
  614. height: 360px;
  615. background-repeat: no-repeat;
  616. background-size: contain;
  617. background-position: center
  618. }
  619. .form-body .app-share .app-share-bg .title {
  620. width: 160px;
  621. height: 29px;
  622. line-height: 1;
  623. word-break: break-all;
  624. text-overflow: ellipsis;
  625. display: -webkit-box;
  626. -webkit-box-orient: vertical;
  627. -webkit-line-clamp: 2;
  628. overflow: hidden;
  629. }
  630. .form-body .app-share .app-share-bg .pic-image {
  631. background-repeat: no-repeat;
  632. background-position: 0 0;
  633. background-size: cover;
  634. width: 160px;
  635. height: 130px;
  636. }
  637. .form-body .tab_tpis {
  638. font-size: 12px;
  639. color: #737373;
  640. }
  641. .redio-center {
  642. display: flex;
  643. align-items: center;
  644. }
  645. .redio-input {
  646. margin-left: -28px;
  647. margin-right: 20px;
  648. }
  649. .el-form-item--mini.el-form-item,
  650. .el-form-item--small.el-form-item {
  651. /* margin-bottom: 0; */
  652. }
  653. .el-radio {
  654. padding-bottom: 16px;
  655. }
  656. </style>