config.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. var configIndex = new Vue({
  5. el: "#configIndex",
  6. data() {
  7. return {
  8. activeName: "basic",
  9. configData: {
  10. basic: [{
  11. id: 'shopro',
  12. title: '商城信息',
  13. tip: '配置商城基本信息',
  14. message: '商城名称、H5域名、Logo',
  15. icon: 'shopro-icon',
  16. leaf: '#6ACAA5',
  17. background: 'linear-gradient(180deg, #BAF0DD 0%, #51BC99 100%)',
  18. url: "{:url(shopro.config/platform?type=shopro')}",
  19. button: {
  20. background: '#E0F1EB',
  21. color: '#13986C'
  22. },
  23. }, {
  24. id: 'user',
  25. title: '会员配置',
  26. tip: '配置默认会员信息',
  27. message: '默认昵称、头像、分组、余额、积分',
  28. icon: 'user-icon',
  29. leaf: '#E0B163',
  30. background: 'linear-gradient(180deg, #FCE6B7 0%, #E9A848 100%)',
  31. button: {
  32. background: '#F7EDDD',
  33. color: '#B07318'
  34. },
  35. }, {
  36. id: 'share',
  37. title: '分享配置',
  38. tip: '配置默认分享信息',
  39. message: '分享标题、图片、海报背景',
  40. icon: 'share-icon',
  41. leaf: '#915CF9',
  42. background: 'linear-gradient(180deg, #D5B8FA 0%, #8F62C9 100%)',
  43. button: {
  44. background: '#E7DEF6',
  45. color: '#6625CF'
  46. },
  47. }, {
  48. id: 'score',
  49. title: '积分配置',
  50. tip: '配置默认积分规则',
  51. message: '签到积分、连续签到规则',
  52. icon: 'score-icon',
  53. leaf: '#EC9371',
  54. background: 'linear-gradient(180deg, #FADDC0 0%, #E47F6D 100%)',
  55. button: {
  56. background: '#F6E5E1',
  57. color: '#D75125'
  58. },
  59. }, {
  60. id: 'withdraw',
  61. title: '提现配置',
  62. tip: '配置默认提现规则',
  63. message: '手续费、最小最大金额',
  64. icon: 'withdraw-icon',
  65. leaf: '#EA6670',
  66. background: 'linear-gradient(180deg, #FCB7BE 0%, #D36068 100%)',
  67. button: {
  68. background: '#F3DCDE',
  69. color: '#D61226'
  70. },
  71. }, {
  72. id: 'order',
  73. title: '商城配置',
  74. tip: '配置默认商城规则',
  75. message: '库存预警,订单自动关闭,订单自动收货,订单自动评价',
  76. icon: 'order-icon',
  77. leaf: '#6991E7',
  78. background: 'linear-gradient(180deg, #AFCBFD 0%, #5A7CCF 100%)',
  79. button: {
  80. background: '#DBE2F6',
  81. color: '#1B5EE7'
  82. },
  83. }, {
  84. id: 'services',
  85. title: '第三方服务',
  86. tip: '配置物流及位置信息',
  87. message: '快递鸟物流、高德地图',
  88. icon: 'services-icon',
  89. leaf: '#14B0F3',
  90. background: 'linear-gradient(180deg, #A5E2FC 0%, #158CBF 100%)',
  91. button: {
  92. background: '#DBE2F6',
  93. color: '#00A3D7'
  94. },
  95. }, {
  96. id: 'chat',
  97. title: '客服配置',
  98. tip: '配置客服信息',
  99. message: '配置客服信息,快速沟通',
  100. icon: 'chat-icon',
  101. leaf: '#27C9C3',
  102. background: 'linear-gradient(180deg, #A1F3DE 0%, #3DA0A7 100%)',
  103. button: {
  104. background: '#D6E9EA',
  105. color: '#159198'
  106. },
  107. }, {
  108. id: 'store',
  109. title: '门店配置',
  110. tip: '配置门店协议',
  111. message: '配置门店协议',
  112. icon: 'store-icon',
  113. leaf: '#487EE5',
  114. background: 'linear-gradient(180deg, #84C4FF 0%, #3C68BE 100%)',
  115. button: {
  116. background: '#DFE7EE',
  117. color: '#1C54BD'
  118. },
  119. }],
  120. platform: [{
  121. id: 'wxOfficialAccount',
  122. title: '微信公众号',
  123. tip: '配置微信公众号',
  124. message: 'AppId、AppSecret、自动登录',
  125. icon: 'wxOfficialAccount-icon',
  126. leaf: '#6ACAA4',
  127. background: 'linear-gradient(180deg, #AAF0D7 0%, #5CC09F 100%)',
  128. buttonMessage: '公众号设置',
  129. button: {
  130. background: '#DEF0EA',
  131. color: '#0EA753'
  132. },
  133. }, {
  134. id: 'wxMiniProgram',
  135. title: '小程序',
  136. tip: '配置小程序',
  137. message: 'AppId、AppSecret、自动登录',
  138. icon: 'wxMiniProgram-icon',
  139. leaf: '#6962F7',
  140. background: 'linear-gradient(180deg, #C1BFFF 0%, #6563C9 100%)',
  141. buttonMessage: '小程序设置',
  142. button: {
  143. background: '#D8D8F1',
  144. color: '#3932BF'
  145. },
  146. }, {
  147. id: 'H5',
  148. title: 'H5',
  149. tip: '配置H5平台',
  150. message: '微信H5支付信息',
  151. icon: 'h5-icon',
  152. leaf: '#EC9371',
  153. background: 'linear-gradient(180deg, #FADDC0 0%, #E5806D 100%)',
  154. buttonMessage: 'H5设置',
  155. button: {
  156. background: '#F7E6E1',
  157. color: '#D75E37'
  158. },
  159. }, {
  160. id: 'App',
  161. title: 'App',
  162. tip: '配置App平台',
  163. message: '生成App实现多端同步使用',
  164. icon: 'App-icon',
  165. leaf: '#6990E6',
  166. background: 'linear-gradient(180deg, #BED6FF 0%, #6785CD 100%)',
  167. buttonMessage: 'App设置',
  168. button: {
  169. background: '#DAE1F6',
  170. color: '#1666D3'
  171. },
  172. }],
  173. payment: [{
  174. id: 'wechat',
  175. title: '微信支付',
  176. tip: '',
  177. message: '',
  178. icon: 'wechat-icon',
  179. leaf: '#6ACAA4',
  180. background: 'linear-gradient(180deg, #AAF0D7 0%, #5DC1A0 100%)',
  181. button: {
  182. background: '#DEF0EA',
  183. color: '#0EA753'
  184. },
  185. }, {
  186. id: 'alipay',
  187. title: '支付宝支付',
  188. tip: '',
  189. message: '',
  190. icon: 'alipay-icon',
  191. leaf: '#6990E6',
  192. background: 'linear-gradient(180deg, #BFD6FF 0%, #6786CE 100%)',
  193. button: {
  194. background: '#DAE1F6',
  195. color: '#005AD7',
  196. },
  197. }, {
  198. id: 'wallet',
  199. title: '余额支付',
  200. tip: '',
  201. message: '',
  202. icon: 'wallet-icon',
  203. leaf: '#EC9371',
  204. background: 'linear-gradient(180deg, #FADDC0 0%, #E6816E 100%)',
  205. button: {
  206. background: '#F7E6E1',
  207. color: '#D75E37'
  208. },
  209. }, {
  210. id: 'apple',
  211. title: 'Apple Pay',
  212. tip: '',
  213. message: '',
  214. icon: 'apple-icon',
  215. leaf: '#6962F7',
  216. background: 'linear-gradient(180deg, #C2C0FF 0%, #6563C9 100%) ',
  217. button: {
  218. background: '#D8D8F1',
  219. color: '#1E14E0',
  220. cursor: 'auto'
  221. },
  222. }]
  223. }
  224. }
  225. },
  226. methods: {
  227. tabClick(tab, event) {
  228. this.activeName = tab.name;
  229. },
  230. operation(id, title) {
  231. let that = this;
  232. Fast.api.open("shopro/config/platform?type=" + id + "&tab=" + that.activeName + "&title=" + title, title);
  233. },
  234. },
  235. })
  236. },
  237. platform: function () {
  238. function debounce(handle, delay) {
  239. let time = null;
  240. return function () {
  241. let self = this,
  242. arg = arguments;
  243. clearTimeout(time);
  244. time = setTimeout(function () {
  245. handle.apply(self, arg);
  246. }, delay)
  247. }
  248. }
  249. var configPlatform = new Vue({
  250. el: "#configPlatform",
  251. data() {
  252. return {
  253. platformData: {
  254. shopro: {
  255. name: '',
  256. domain: '',
  257. version: '',
  258. logo: '',
  259. logo_arr: [],
  260. copyright: ['', ''],
  261. user_protocol: '',
  262. privacy_protocol: '',
  263. about_us: '',
  264. },
  265. user: {
  266. nickname: '',
  267. avatar: '',
  268. avatar_arr: [],
  269. group_id: '',
  270. money: '',
  271. score: '',
  272. },
  273. share: {
  274. title: '',
  275. image: '',
  276. goods_poster_bg: '',
  277. user_poster_bg: '',
  278. groupon_poster_bg: '',
  279. image_arr: [],
  280. goods_poster_bg_arr: [],
  281. user_poster_bg_arr: [],
  282. groupon_poster_bg_arr: [],
  283. },
  284. score: {
  285. everyday: '',
  286. until_day: '',
  287. inc_value: '',
  288. },
  289. withdraw: {
  290. methods: [],
  291. wechat_alipay_auto: 0,
  292. service_fee: '',
  293. min: '',
  294. max: '',
  295. },
  296. order: {
  297. order_auto_close: '',
  298. order_auto_confirm: '',
  299. order_auto_comment: '',
  300. order_comment_content: '',
  301. goods: {
  302. stock_warning: 0
  303. }
  304. },
  305. services: {
  306. amap: {
  307. appkey: ''
  308. },
  309. express: {
  310. ebusiness_id: '',
  311. type: 'free',
  312. appkey: '',
  313. jd_code: '',
  314. Sender: {
  315. Name: '',
  316. Mobile: '',
  317. ProvinceName: '',
  318. CityName: '',
  319. ExpAreaName: '',
  320. Address: '',
  321. },
  322. PayType: 1,
  323. ExpType: 1,
  324. CustomerName: '',
  325. CustomerPwd: '',
  326. ShipperCode: '',
  327. },
  328. area_arr: []
  329. },
  330. chat: {
  331. type: 'shopro',
  332. basic: {
  333. last_customer_service: 1,
  334. allocate: 'busy',
  335. notice: '显示在用户端头部',
  336. },
  337. system: {
  338. is_ssl: 0,
  339. ssl_type: 'cert',
  340. ssl_cert: '/www/server/panel/vhost/cert/****/fullchain.pem',
  341. ssl_key: '/www/server/panel/vhost/cert/****/privkey.pem',
  342. gateway_port: 1819,
  343. gateway_num: 2,
  344. gateway_start_port: 2010,
  345. business_worker_port: 2238,
  346. business_worker_num: 4
  347. }
  348. },
  349. store: {
  350. protocol: '',
  351. selfetch_protocol: '',
  352. },
  353. wxOfficialAccount: {
  354. name: '',
  355. wx_type: '',
  356. avatar: '',
  357. qrcode: '',
  358. avatar_arr: [],
  359. qrcode_arr: [],
  360. app_id: '',
  361. secret: '',
  362. url: '',
  363. token: '',
  364. aes_key: '',
  365. auto_login: '',
  366. status: ''
  367. },
  368. wxMiniProgram: {
  369. name: '',
  370. avatar: '',
  371. qrcode: '',
  372. avatar_arr: [],
  373. qrcode_arr: [],
  374. app_id: '',
  375. secret: '',
  376. auto_login: '',
  377. },
  378. H5: {
  379. app_id: '',
  380. secret: '',
  381. },
  382. App: {
  383. app_id: '',
  384. secret: '',
  385. },
  386. wechat: {
  387. platform: [],
  388. mch_id: '',
  389. key: '',
  390. cert_client: '',
  391. cert_key: '',
  392. mode: 'normal',
  393. sub_mch_id: '',
  394. appid: '',
  395. app_id: '',
  396. miniapp_id: '',
  397. },
  398. alipay: {
  399. platform: [],
  400. app_id: '',
  401. ali_public_key: '',
  402. app_cert_public_key: '',
  403. alipay_root_cert: '',
  404. private_key: '',
  405. mode: 'normal',
  406. pid: '',
  407. },
  408. wallet: {
  409. platform: [],
  410. },
  411. },
  412. type: new URLSearchParams(location.search).get('type'),
  413. tab: new URLSearchParams(location.search).get('tab'),
  414. title: new URLSearchParams(location.search).get('title'),
  415. groupList: [],
  416. detailForm: {},
  417. must_delete: ['logo_arr', 'avatar_arr', 'image_arr', 'goods_poster_bg_arr', 'user_poster_bg_arr', 'groupon_poster_bg_arr', 'qrcode_arr', 'area_arr'],
  418. expressAddress: window.location.origin + '/addons/shopro/express/callback',
  419. deliverCompany: [],
  420. areaOptions: []
  421. }
  422. },
  423. mounted() {
  424. this.operationData();
  425. if (this.type == 'services') {
  426. this.getDeliverCompany();
  427. this.getAreaOptions()
  428. }
  429. },
  430. methods: {
  431. operationData() {
  432. this.detailForm = this.platformData[this.type]
  433. if (Config.row) {
  434. for (key in this.detailForm) {
  435. if (Config.row[key]) {
  436. if(Config.row[key] instanceof Object){
  437. for(inner in Config.row[key]){
  438. if(Config.row[key][inner]){
  439. this.detailForm[key][inner]=Config.row[key][inner]
  440. }
  441. }
  442. }else{
  443. this.detailForm[key] = Config.row[key]
  444. }
  445. }
  446. }
  447. }
  448. if (this.type == 'shopro') {
  449. this.detailForm.logo_arr = []
  450. this.detailForm.logo_arr.push(Fast.api.cdnurl(this.detailForm.logo))
  451. } else if (this.type == 'user') {
  452. this.groupList = Config.groupList
  453. this.detailForm.avatar_arr = []
  454. this.detailForm.avatar_arr.push(Fast.api.cdnurl(this.detailForm.avatar))
  455. } else if (this.type == 'share') {
  456. this.detailForm.image_arr = []
  457. this.detailForm.image_arr.push(Fast.api.cdnurl(this.detailForm.image))
  458. this.detailForm.goods_poster_bg_arr = []
  459. this.detailForm.goods_poster_bg_arr.push(Fast.api.cdnurl(this.detailForm.goods_poster_bg))
  460. this.detailForm.user_poster_bg_arr = []
  461. this.detailForm.user_poster_bg_arr.push(Fast.api.cdnurl(this.detailForm.user_poster_bg))
  462. this.detailForm.groupon_poster_bg_arr = []
  463. this.detailForm.groupon_poster_bg_arr.push(Fast.api.cdnurl(this.detailForm.groupon_poster_bg))
  464. } else if (this.type == 'withdraw') {
  465. this.detailForm.service_fee = this.detailForm.service_fee * 100
  466. } else if (this.type == 'services') {
  467. this.detailForm.area_arr = []
  468. if (this.detailForm.express && this.detailForm.express.Sender) {
  469. this.detailForm.area_arr = [this.detailForm.express.Sender.ProvinceName, this.detailForm.express.Sender.CityName, this.detailForm.express.Sender.ExpAreaName]
  470. }
  471. } else if (this.type == 'chat') {
  472. if(!this.detailForm.system.ssl_type){
  473. this.$set(this.detailForm.system,'ssl_type','cert')
  474. }
  475. } else if (this.type == 'wxOfficialAccount') {
  476. this.detailForm.avatar_arr = []
  477. this.detailForm.avatar_arr.push(Fast.api.cdnurl(this.detailForm.avatar))
  478. this.detailForm.qrcode_arr = []
  479. this.detailForm.qrcode_arr.push(Fast.api.cdnurl(this.detailForm.qrcode))
  480. } else if (this.type == 'wxMiniProgram') {
  481. this.detailForm.avatar_arr = []
  482. this.detailForm.avatar_arr.push(Fast.api.cdnurl(this.detailForm.avatar))
  483. this.detailForm.qrcode_arr = []
  484. this.detailForm.qrcode_arr.push(Fast.api.cdnurl(this.detailForm.qrcode))
  485. }
  486. },
  487. richtextSelect(field) {
  488. let that = this;
  489. Fast.api.open("shopro/richtext/select?multiple=false", "选择协议", {
  490. callback: function (data) {
  491. that.detailForm[field] = data.data.id;
  492. }
  493. });
  494. return false;
  495. },
  496. attachmentSelect(type, field) {
  497. let that = this;
  498. Fast.api.open("general/attachment/select?multiple=false", "选择", {
  499. callback: function (data) {
  500. switch (type) {
  501. case "image":
  502. that.detailForm[field] = data.url;
  503. that.detailForm[field + '_arr'] = data.url;
  504. break;
  505. // case "file":
  506. // that.detailForm[field] = data.url;
  507. // break;
  508. case "ssl":
  509. that.detailForm.system[field] = data.url;
  510. break;
  511. }
  512. }
  513. });
  514. return false;
  515. },
  516. delImg(type, field) {
  517. let that = this;
  518. switch (type) {
  519. case "image":
  520. that.detailForm[field] = '';
  521. that.detailForm[field + '_arr'] = [];
  522. break;
  523. case "file":
  524. that.detailForm[field] = '';
  525. break;
  526. }
  527. },
  528. submitFrom(type) {
  529. let that = this;
  530. if (type == 'yes') {
  531. let submitData = JSON.parse(JSON.stringify(that.detailForm))
  532. if (that.type == 'withdraw') {
  533. submitData.service_fee = (Number(submitData.service_fee) / 100).toFixed(2)
  534. }
  535. if (that.type == 'services') {
  536. submitData.express.Sender.ProvinceName = submitData.area_arr[0];
  537. submitData.express.Sender.CityName = submitData.area_arr[1];
  538. submitData.express.Sender.ExpAreaName = submitData.area_arr[2];
  539. }
  540. that.must_delete.forEach(i => {
  541. if (submitData[i]) {
  542. delete submitData[i]
  543. }
  544. });
  545. Fast.api.ajax({
  546. url: 'shopro/config/platform?type=' + that.type,
  547. loading: true,
  548. type: 'POST',
  549. data: {
  550. data: JSON.stringify(submitData),
  551. group: that.tab,
  552. title: that.title
  553. },
  554. }, function (ret, res) {
  555. Fast.api.close()
  556. })
  557. } else {
  558. Fast.api.close()
  559. }
  560. },
  561. getDeliverCompany(searchWhere = '') {
  562. let that = this;
  563. Fast.api.ajax({
  564. url: 'shopro/express/select',
  565. loading: false,
  566. type: 'GET',
  567. data: {
  568. searchWhere: searchWhere,
  569. }
  570. }, function (ret, res) {
  571. that.deliverCompany = res.data.rows;
  572. return false
  573. })
  574. },
  575. deliverDebounceFilter: debounce(function (searchWhere) {
  576. this.getDeliverCompany(searchWhere)
  577. }, 1000),
  578. deliverFilter(searchWhere) {
  579. this.deliverDebounceFilter(searchWhere);
  580. },
  581. getAreaOptions() {
  582. var that = this;
  583. Fast.api.ajax({
  584. url: `shopro/area/select`,
  585. loading: false,
  586. type: 'GET',
  587. }, function (ret, res) {
  588. that.areaOptions = res.data;
  589. return false;
  590. })
  591. },
  592. changeWechatType() {
  593. for (key in this.detailForm) {
  594. if (key != 'mode' && key != 'platform') {
  595. this.detailForm[key] = ''
  596. }
  597. }
  598. },
  599. ajaxUpload(id) {
  600. let that = this;
  601. var formData = new FormData();
  602. formData.append("file", $('#' + id)[0].files[0]);
  603. $.ajax({
  604. type: "post",
  605. url: "ajax/upload",
  606. data: formData,
  607. cache: false,
  608. processData: false,
  609. contentType: false,
  610. success: function (data) {
  611. if(data.code==1){
  612. that.detailForm[id] = data.data.url
  613. }else{
  614. that.$notify({
  615. title: '警告',
  616. message: data.msg,
  617. type: 'warning'
  618. });
  619. }
  620. }
  621. })
  622. },
  623. },
  624. })
  625. },
  626. add: function () {
  627. Controller.api.bindevent();
  628. },
  629. edit: function () {
  630. Controller.api.bindevent();
  631. },
  632. api: {
  633. bindevent: function () {
  634. Form.api.bindevent($("form[role=form]"));
  635. }
  636. }
  637. };
  638. return Controller;
  639. });