float-button.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. <?php
  2. /**
  3. * @link:http://www.gdqijianshi.com/
  4. * @copyright: Copyright (c) 2020 广东七件事集团
  5. * Created by PhpStorm
  6. * Author: lun
  7. * Date: 2021-09-15
  8. * Time: 12:36
  9. */
  10. use common\helpers\ComponentHelper;
  11. ComponentHelper::loadComponentView('com-attachment');
  12. ComponentHelper::loadComponentView('com-image');
  13. ?>
  14. <style>
  15. .el-tabs__header {
  16. padding: 0 20px;
  17. height: 56px;
  18. line-height: 56px;
  19. background-color: #fff;
  20. margin-bottom: 0;
  21. }
  22. .title {
  23. margin-top: 10px;
  24. padding: 18px 20px;
  25. border-top: 1px solid #F3F3F3;
  26. border-bottom: 1px solid #F3F3F3;
  27. background-color: #fff;
  28. }
  29. .form-body {
  30. background-color: #fff;
  31. padding: 20px 50% 20px 0;
  32. }
  33. .button-item {
  34. padding: 9px 25px;
  35. }
  36. .form-body .item {
  37. width: 300px;
  38. margin-bottom: 50px;
  39. margin-right: 25px;
  40. }
  41. .item-img {
  42. height: 550px;
  43. padding: 25px 10px;
  44. border-radius: 30px;
  45. border: 1px solid #CCCCCC;
  46. background-color: #fff;
  47. }
  48. .item .el-form-item {
  49. width: 300px;
  50. margin: 20px auto;
  51. }
  52. .left-setting-menu {
  53. width: 260px;
  54. }
  55. .left-setting-menu .el-form-item {
  56. height: 60px;
  57. padding-left: 20px;
  58. display: flex;
  59. align-items: center;
  60. margin-bottom: 0;
  61. cursor: pointer;
  62. }
  63. .left-setting-menu .el-form-item .el-form-item__label {
  64. cursor: pointer;
  65. }
  66. .left-setting-menu .el-form-item.active {
  67. background-color: #F3F5F6;
  68. border-top-left-radius: 10px;
  69. width: 105%;
  70. border-bottom-left-radius: 10px;
  71. }
  72. .left-setting-menu .el-form-item .el-form-item__content {
  73. margin-left: 0 !important
  74. }
  75. .no-radius {
  76. border-top-left-radius: 0 !important;
  77. }
  78. .del-btn {
  79. position: absolute;
  80. right: -8px;
  81. top: -8px;
  82. padding: 4px 4px;
  83. }
  84. .reset {
  85. position: absolute;
  86. top: 3px;
  87. left: 90px;
  88. }
  89. .app-tip {
  90. position: absolute;
  91. right: 24px;
  92. top: 16px;
  93. height: 72px;
  94. line-height: 72px;
  95. max-width: calc(100% - 78px);
  96. }
  97. .app-tip:before {
  98. content: ' ';
  99. width: 0;
  100. height: 0;
  101. border-color: inherit;
  102. position: absolute;
  103. top: -32px;
  104. right: 100px;
  105. border-width: 16px;
  106. border-style: solid;
  107. }
  108. .tip-content {
  109. display: block;
  110. white-space: nowrap;
  111. width: 100%;
  112. overflow: hidden;
  113. text-overflow: ellipsis;
  114. margin: 0 28px;
  115. font-size: 28px;
  116. }
  117. .btn-abs{
  118. position: absolute;
  119. top: 12px;
  120. right: 18px;
  121. }
  122. .form-body .app-share {
  123. padding-top: 12px;
  124. border-top: 1px solid #e2e2e2;
  125. margin-top: -20px;
  126. }
  127. .form-body .app-share .app-share-bg {
  128. position: relative;
  129. width: 310px;
  130. height: 360px;
  131. background-repeat: no-repeat;
  132. background-size: contain;
  133. background-position: center
  134. }
  135. .form-body .app-share .app-share-bg .title {
  136. width: 160px;
  137. height: 29px;
  138. line-height: 1;
  139. word-break: break-all;
  140. text-overflow: ellipsis;
  141. display: -webkit-box;
  142. -webkit-box-orient: vertical;
  143. -webkit-line-clamp: 2;
  144. overflow: hidden;
  145. }
  146. .form-body .app-share .app-share-bg .pic-image {
  147. background-repeat: no-repeat;
  148. background-position: 0 0;
  149. background-size: cover;
  150. width: 160px;
  151. height: 130px;
  152. }
  153. </style>
  154. <div id="app" v-cloak>
  155. <el-card v-loading="loading" style="border:0" shadow="never" body-style="background-color: #f3f3f3;padding: 0 0;">
  156. <el-form :model="ruleForm" ref="ruleForm" label-width="172px" style="position: relative" size="small">
  157. <el-row>
  158. <el-col :span="24">
  159. <div class="title"><span>悬浮窗设置</span></div>
  160. <div class="form-body" style="margin-bottom: 0px;">
  161. <el-form-item label="启用悬浮按钮">
  162. <el-switch
  163. v-model="ruleForm.is_quick_navigation"
  164. :active-value="1"
  165. :inactive-value="0"
  166. active-color="#409EFF">
  167. </el-switch>
  168. </el-form-item>
  169. <el-form-item label="悬浮按钮样式" prop="quick_navigation_style">
  170. <el-radio v-model="ruleForm.quick_navigation_style" :label="1">展开收起</el-radio>
  171. <el-radio v-model="ruleForm.quick_navigation_style" :label="2">固定展开</el-radio>
  172. </el-form-item>
  173. <el-form-item label="展开图标">
  174. <com-attachment :multiple="false" :max="1" @selected="quickNavigationOpenedPic">
  175. <el-tooltip effect="dark" content="建议尺寸:100 * 100" placement="top">
  176. <el-button size="mini">选择图标</el-button>
  177. </el-tooltip>
  178. </com-attachment>
  179. <el-button size="mini" @click="resetImg('quick_navigation_opened_pic')" class="reset" type="primary">恢复默认</el-button>
  180. <com-image style="width: 80px; height: 80px;" :src="ruleForm.quick_navigation_opened_pic"></com-image>
  181. </el-form-item>
  182. <el-form-item label="收起图标">
  183. <com-attachment :multiple="false" :max="1" @selected="quickNavigationClosedPic">
  184. <el-tooltip effect="dark" content="建议尺寸:100 * 100" placement="top">
  185. <el-button size="mini">选择图标</el-button>
  186. </el-tooltip>
  187. </com-attachment>
  188. <el-button size="mini" @click="resetImg('quick_navigation_closed_pic')" class="reset" type="primary">恢复默认</el-button>
  189. <com-image style="width: 80px; height: 80px;" :src="ruleForm.quick_navigation_closed_pic"></com-image>
  190. </el-form-item>
  191. </div>
  192. </el-col>
  193. <el-col :span="24">
  194. <div class="title"><span>客服开关设置</span></div>
  195. <div class="form-body" style="background-color: #ffffff;padding: 0 0 20px 0;margin-bottom: 0px;">
  196. <el-form-item label="在线客服开关" style="padding-top: 20px;border-top: 1px solid #F3F3F3;">
  197. <el-switch
  198. v-model="ruleForm.is_customer_services"
  199. :active-value="1"
  200. :inactive-value="0"
  201. active-color="#409EFF">
  202. </el-switch>
  203. </el-form-item>
  204. <el-form-item label="客服图标">
  205. <com-attachment :multiple="false" :max="1" @selected="customerServicesPic">
  206. <el-tooltip effect="dark" content="建议尺寸:100 * 100" placement="top">
  207. <el-button size="mini">选择图标</el-button>
  208. </el-tooltip>
  209. </com-attachment>
  210. <el-button size="mini" @click="resetImg('customer_services_pic')" class="reset" type="primary">恢复默认</el-button>
  211. <com-image style="width: 80px; height: 80px;" :src="ruleForm.customer_services_pic"></com-image>
  212. </el-form-item>
  213. </div>
  214. <div class="title">
  215. <span>悬浮按钮设置</span>
  216. <el-tooltip effect="dark" content="用于商品列表页" placement="top">
  217. <i class="el-icon-info"></i>
  218. </el-tooltip>
  219. </div>
  220. <div class="form-body">
  221. <el-form-item label="启用回到顶部悬浮按钮" prop="is_show_scroll_top">
  222. <el-switch
  223. v-model="ruleForm.is_show_scroll_top"
  224. :active-value="1"
  225. :inactive-value="0"
  226. active-color="#409EFF">
  227. </el-switch>
  228. </el-form-item>
  229. </div>
  230. </el-col>
  231. </el-row>
  232. <el-button :loading="submitLoading" class="button-item" size="small" type="primary"
  233. @click="submit()">保存
  234. </el-button>
  235. <div style="height: 30px;"></div>
  236. </el-form>
  237. </el-card>
  238. </div>
  239. <script>
  240. const app = new Vue({
  241. el: '#app',
  242. data() {
  243. return {
  244. loading: false,
  245. submitLoading: false,
  246. ruleForm: {
  247. is_quick_navigation: 0,// 启用悬浮按钮
  248. quick_navigation_style: 1,// 悬浮按钮样式
  249. quick_navigation_opened_pic: '',//悬浮按钮展开图标
  250. quick_navigation_closed_pic: '',// 悬浮按钮收起图标
  251. is_customer_services: 0,// 在线客服开关
  252. customer_services_pic: '',// 客服图标
  253. is_show_scroll_top: 0,// 启用回到顶部悬浮按钮
  254. }
  255. };
  256. },
  257. created() {
  258. this.loadData();
  259. },
  260. mounted: function () {
  261. },
  262. methods: {
  263. loadData() {
  264. this.loading = true;
  265. request({
  266. params: {
  267. r: 'mall/decorate/float-button',
  268. },
  269. }).then(e => {
  270. this.loading = false;
  271. if (e.data.code === 0) {
  272. if (!isEmpty(e.data.data)) {
  273. this.ruleForm = e.data.data;
  274. }
  275. } else {
  276. this.$message.error(e.data.msg);
  277. }
  278. }).catch(e => {
  279. });
  280. },
  281. submit(){
  282. this.submitLoading = true;
  283. request({
  284. params: {
  285. r: 'mall/decorate/float-button',
  286. },
  287. method: 'post',
  288. data: {
  289. ruleForm: this.ruleForm
  290. },
  291. }).then(e => {
  292. this.submitLoading = false;
  293. if (e.data.code === 0) {
  294. this.$message.success(e.data.msg);
  295. } else {
  296. this.$message.error(e.data.msg);
  297. }
  298. }).catch(e => {
  299. });
  300. },
  301. //客服图标
  302. customerServicesPic(e) {
  303. if (e.length) {
  304. this.ruleForm.customer_services_pic = e[0].url;
  305. }
  306. },
  307. //拨号图标
  308. dialPic(e) {
  309. if (e.length) {
  310. this.ruleForm.dial_pic = e[0].url;
  311. }
  312. },
  313. //客服外链图标
  314. webServicePic(e) {
  315. if (e.length) {
  316. this.ruleForm.web_service_pic = e[0].url;
  317. }
  318. },
  319. //快捷导航图标(展开)
  320. quickNavigationOpenedPic(e) {
  321. if (e.length) {
  322. this.ruleForm.quick_navigation_opened_pic = e[0].url;
  323. }
  324. },
  325. //快捷导航图标(收起)
  326. quickNavigationClosedPic(e) {
  327. if (e.length) {
  328. this.ruleForm.quick_navigation_closed_pic = e[0].url;
  329. }
  330. },
  331. //客服外链图标
  332. smallAppPic(e) {
  333. if (e.length) {
  334. this.ruleForm.small_app_pic = e[0].url;
  335. }
  336. },
  337. //一键导航图标
  338. quickMapPic(e) {
  339. if (e.length) {
  340. this.ruleForm.quick_map_pic = e[0].url;
  341. }
  342. },
  343. resetImg(type) {
  344. const host = "<?php echo \Yii::$app->request->hostInfo . \Yii::$app->request->baseUrl . "/" ?>";
  345. if (type == 'quick_navigation_opened_pic') {
  346. this.ruleForm.quick_navigation_opened_pic = host + 'resources/img/mall/quick_navigation_opened_pic.png';
  347. } else if (type == 'quick_navigation_closed_pic') {
  348. this.ruleForm.quick_navigation_closed_pic = host + 'resources/img/mall/quick_navigation_closed_pic.png';
  349. } else if (type == 'small_app_pic') {
  350. this.ruleForm.small_app_pic = host + 'resources/img/mall/small_app_pic.png';
  351. } else if (type == 'quick_map_pic') {
  352. this.ruleForm.quick_map_pic = host + 'resources/img/mall/quick_map_pic.png';
  353. } else if (type == 'web_service_pic') {
  354. this.ruleForm.web_service_pic = host + 'resources/img/mall/web_service_pic.png';
  355. } else if (type == 'dial_pic') {
  356. this.ruleForm.dial_pic = host + 'resources/img/mall/dial_pic.png';
  357. } else if (type == 'quick_home_pic') {
  358. this.ruleForm.quick_home_pic = host + 'resources/img/mall/quick_home_pic.png';
  359. } else if (type == 'customer_services_pic') {
  360. this.ruleForm.customer_services_pic = host + 'resources/img/mall/customer_services_pic.png';
  361. }
  362. },
  363. },
  364. computed: {
  365. appTip() {
  366. let setting = this.ruleForm.setting;
  367. return `background-color:${setting.add_app_bg_color};` +
  368. `opacity:${setting.add_app_bg_transparency / 100};` +
  369. `border-radius:${setting.add_app_bg_radius}px;` +
  370. `border-color: transparent transparent ${setting.add_app_bg_color} transparent;` +
  371. `color:${setting.add_app_text_color}`;
  372. }
  373. }
  374. });
  375. </script>
  376. <style>
  377. .el-tabs__header {
  378. padding: 0 20px;
  379. height: 56px;
  380. line-height: 56px;
  381. background-color: #fff;
  382. margin-bottom: 0;
  383. }
  384. .title {
  385. margin-top: 10px;
  386. padding: 18px 20px;
  387. border-top: 1px solid #F3F3F3;
  388. border-bottom: 1px solid #F3F3F3;
  389. background-color: #fff;
  390. }
  391. .form-body {
  392. background-color: #fff;
  393. padding: 20px 50% 20px 0;
  394. }
  395. .button-item {
  396. margin-top: 12px;
  397. padding: 9px 25px;
  398. }
  399. .form-body .item {
  400. width: 300px;
  401. margin-bottom: 50px;
  402. margin-right: 25px;
  403. }
  404. .item-img {
  405. height: 550px;
  406. padding: 25px 10px;
  407. border-radius: 30px;
  408. border: 1px solid #CCCCCC;
  409. background-color: #fff;
  410. }
  411. .item .el-form-item {
  412. width: 300px;
  413. margin: 20px auto;
  414. }
  415. .left-setting-menu {
  416. width: 260px;
  417. }
  418. .left-setting-menu .el-form-item {
  419. height: 60px;
  420. padding-left: 20px;
  421. display: flex;
  422. align-items: center;
  423. margin-bottom: 0;
  424. cursor: pointer;
  425. }
  426. .left-setting-menu .el-form-item .el-form-item__label {
  427. cursor: pointer;
  428. }
  429. .left-setting-menu .el-form-item.active {
  430. background-color: #F3F5F6;
  431. border-top-left-radius: 10px;
  432. width: 105%;
  433. border-bottom-left-radius: 10px;
  434. }
  435. .left-setting-menu .el-form-item .el-form-item__content {
  436. margin-left: 0 !important
  437. }
  438. .no-radius {
  439. border-top-left-radius: 0 !important;
  440. }
  441. .del-btn {
  442. position: absolute;
  443. right: -8px;
  444. top: -8px;
  445. padding: 4px 4px;
  446. }
  447. .reset {
  448. position: absolute;
  449. top: 3px;
  450. left: 90px;
  451. }
  452. .app-tip {
  453. position: absolute;
  454. right: 24px;
  455. top: 16px;
  456. height: 72px;
  457. line-height: 72px;
  458. max-width: calc(100% - 78px);
  459. }
  460. .app-tip:before {
  461. content: ' ';
  462. width: 0;
  463. height: 0;
  464. border-color: inherit;
  465. position: absolute;
  466. top: -32px;
  467. right: 100px;
  468. border-width: 16px;
  469. border-style: solid;
  470. }
  471. .tip-content {
  472. display: block;
  473. white-space: nowrap;
  474. width: 100%;
  475. overflow: hidden;
  476. text-overflow: ellipsis;
  477. margin: 0 28px;
  478. font-size: 28px;
  479. }
  480. </style>